summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generation_data.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2023-06-12 13:01:02 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2023-06-13 16:13:03 +0000
commitdbc33874d03c4a0a7919e2c78a68cba8a4afe7bd (patch)
tree94a865ed6fab44c174bad475e4f26c5e59cdbef9 /compiler/optimizing/code_generation_data.cc
parent42266245f036f92d2f2c8900793ea6eea822a29e (diff)
Move CodeGenerationData into its own header file.
To facilitate doing compiler experiments. Test: test.py Change-Id: I48943e6bcedb9023abf90ce6e6ea9b94866309d1
Diffstat (limited to 'compiler/optimizing/code_generation_data.cc')
-rw-r--r--compiler/optimizing/code_generation_data.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generation_data.cc b/compiler/optimizing/code_generation_data.cc
new file mode 100644
index 0000000000..7b23d46dc5
--- /dev/null
+++ b/compiler/optimizing/code_generation_data.cc
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "class_linker.h"
+#include "code_generation_data.h"
+#include "code_generator.h"
+#include "intern_table.h"
+#include "mirror/object-inl.h"
+#include "runtime.h"
+
+namespace art HIDDEN {
+
+void CodeGenerationData::EmitJitRoots(
+ /*out*/std::vector<Handle<mirror::Object>>* roots) {
+ DCHECK(roots->empty());
+ roots->reserve(GetNumberOfJitRoots());
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ size_t index = 0;
+ for (auto& entry : jit_string_roots_) {
+ // Update the `roots` with the string, and replace the address temporarily
+ // stored to the index in the table.
+ uint64_t address = entry.second;
+ roots->emplace_back(reinterpret_cast<StackReference<mirror::Object>*>(address));
+ DCHECK(roots->back() != nullptr);
+ DCHECK(roots->back()->IsString());
+ entry.second = index;
+ // Ensure the string is strongly interned. This is a requirement on how the JIT
+ // handles strings. b/32995596
+ class_linker->GetInternTable()->InternStrong(roots->back()->AsString());
+ ++index;
+ }
+ for (auto& entry : jit_class_roots_) {
+ // Update the `roots` with the class, and replace the address temporarily
+ // stored to the index in the table.
+ uint64_t address = entry.second;
+ roots->emplace_back(reinterpret_cast<StackReference<mirror::Object>*>(address));
+ DCHECK(roots->back() != nullptr);
+ DCHECK(roots->back()->IsClass());
+ entry.second = index;
+ ++index;
+ }
+}
+
+} // namespace art