From dbc33874d03c4a0a7919e2c78a68cba8a4afe7bd Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 12 Jun 2023 13:01:02 +0100 Subject: Move CodeGenerationData into its own header file. To facilitate doing compiler experiments. Test: test.py Change-Id: I48943e6bcedb9023abf90ce6e6ea9b94866309d1 --- compiler/optimizing/code_generation_data.cc | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 compiler/optimizing/code_generation_data.cc (limited to 'compiler/optimizing/code_generation_data.cc') 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>* 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*>(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*>(address)); + DCHECK(roots->back() != nullptr); + DCHECK(roots->back()->IsClass()); + entry.second = index; + ++index; + } +} + +} // namespace art -- cgit v1.2.3-59-g8ed1b