summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2024-05-17 10:37:36 +0200
committer VladimĂ­r Marko <vmarko@google.com> 2024-06-20 16:19:04 +0000
commit05a5ff2a4152571e8e82ba4c407cf0fba0a57ddd (patch)
tree734fecaae333684a016f0a29be400fd32b9f87c2
parent9e9f99747ad3bdb06be114263c732c39fba9a692 (diff)
Move some classes from `runtime/` to `dex2oat/`.
Move the transactional interpreter, `AotClassLinker`, `Transaction` and `SdkChecker`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: If001e06711ee345ce5b937ed764e66b26a0abcd6
-rw-r--r--dex2oat/Android.bp10
-rw-r--r--dex2oat/aot_class_linker.cc (renamed from runtime/oat/aot_class_linker.cc)6
-rw-r--r--dex2oat/aot_class_linker.h (renamed from runtime/oat/aot_class_linker.h)11
-rw-r--r--dex2oat/art_standalone_dex2oat_tests.xml1
-rw-r--r--dex2oat/common_transaction_test.cc (renamed from runtime/common_transaction_test.cc)25
-rw-r--r--dex2oat/common_transaction_test.h (renamed from runtime/common_transaction_test.h)18
-rw-r--r--dex2oat/dex/quick_compiler_callbacks.cc5
-rw-r--r--dex2oat/dex/quick_compiler_callbacks.h2
-rw-r--r--dex2oat/dex2oat.cc15
-rw-r--r--dex2oat/driver/compiler_driver.cc6
-rw-r--r--dex2oat/interpreter/interpreter_switch_impl1.cc (renamed from runtime/interpreter/interpreter_switch_impl1.cc)4
-rw-r--r--dex2oat/interpreter/unstarted_runtime_transaction_test.cc (renamed from runtime/interpreter/unstarted_runtime_transaction_test.cc)2
-rw-r--r--dex2oat/sdk_checker.cc (renamed from runtime/sdk_checker.cc)0
-rw-r--r--dex2oat/sdk_checker.h (renamed from runtime/sdk_checker.h)6
-rw-r--r--dex2oat/transaction.cc (renamed from runtime/transaction.cc)2
-rw-r--r--dex2oat/transaction.h (renamed from runtime/transaction.h)6
-rw-r--r--dex2oat/transaction_test.cc (renamed from runtime/transaction_test.cc)0
-rw-r--r--dex2oat/verifier_deps_test.cc5
-rw-r--r--runtime/Android.bp9
-rw-r--r--runtime/art_standalone_runtime_tests.xml1
-rw-r--r--runtime/class_linker.cc7
-rw-r--r--runtime/class_linker.h5
-rw-r--r--runtime/common_runtime_test.cc2
-rw-r--r--runtime/common_throws.h28
-rw-r--r--runtime/compiler_callbacks.h4
-rw-r--r--runtime/entrypoints/entrypoint_utils-inl.h1
-rw-r--r--runtime/entrypoints/entrypoint_utils.h2
-rw-r--r--runtime/intern_table.h6
-rw-r--r--runtime/interpreter/interpreter.cc13
-rw-r--r--runtime/interpreter/interpreter_common.h66
-rw-r--r--runtime/interpreter/interpreter_switch_impl.h20
-rw-r--r--runtime/interpreter/lock_count_data.h8
-rw-r--r--runtime/interpreter/mterp/nterp.cc4
-rw-r--r--runtime/noop_compiler_callbacks.h28
-rw-r--r--runtime/runtime.cc3
35 files changed, 214 insertions, 117 deletions
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 347d85bd34..3e62abe006 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -29,11 +29,13 @@ art_cc_defaults {
defaults: ["art_defaults"],
host_supported: true,
srcs: [
+ "aot_class_linker.cc",
"dex/quick_compiler_callbacks.cc",
"dex/verification_results.cc",
"driver/compiled_method.cc",
"driver/compiled_method_storage.cc",
"driver/compiler_driver.cc",
+ "interpreter/interpreter_switch_impl1.cc",
"linker/code_info_table_deduper.cc",
"linker/elf_writer.cc",
"linker/elf_writer_quick.cc",
@@ -41,6 +43,8 @@ art_cc_defaults {
"linker/multi_oat_relative_patcher.cc",
"linker/oat_writer.cc",
"linker/relative_patcher.cc",
+ "sdk_checker.cc",
+ "transaction.cc",
"utils/swap_space.cc",
],
@@ -395,6 +399,7 @@ art_cc_library_static {
defaults: ["libart-gtest-defaults"],
srcs: [
"common_compiler_driver_test.cc",
+ "common_transaction_test.cc",
],
static_libs: [
"libart-dex2oat",
@@ -410,6 +415,7 @@ art_cc_library_static {
],
srcs: [
"common_compiler_driver_test.cc",
+ "common_transaction_test.cc",
],
static_libs: [
"libartd-dex2oat",
@@ -444,12 +450,14 @@ art_cc_defaults {
":art-gtest-jars-Statics",
":art-gtest-jars-StringLiterals",
":art-gtest-jars-SuperWithAccessChecks",
+ ":art-gtest-jars-Transaction",
":art-gtest-jars-VerifierDeps",
":art-gtest-jars-VerifierDepsMulti",
":art-gtest-jars-VerifySoftFailDuringClinit",
],
tidy_timeout_srcs: [
"dex2oat_test.cc",
+ "transaction_test.cc",
"verifier_deps_test.cc",
"linker/arm/relative_patcher_thumb2_test.cc",
"linker/arm64/relative_patcher_arm64_test.cc",
@@ -460,6 +468,7 @@ art_cc_defaults {
"dex2oat_image_test.cc",
"driver/compiled_method_storage_test.cc",
"driver/compiler_driver_test.cc",
+ "interpreter/unstarted_runtime_transaction_test.cc",
"linker/code_info_table_deduper_test.cc",
"linker/elf_writer_test.cc",
"linker/image_test.cc",
@@ -467,6 +476,7 @@ art_cc_defaults {
"linker/index_bss_mapping_encoder_test.cc",
"linker/multi_oat_relative_patcher_test.cc",
"linker/oat_writer_test.cc",
+ "transaction_test.cc",
"verifier_deps_test.cc",
"utils/swap_space_test.cc",
],
diff --git a/runtime/oat/aot_class_linker.cc b/dex2oat/aot_class_linker.cc
index 0a85fa094b..6efddb2f42 100644
--- a/runtime/oat/aot_class_linker.cc
+++ b/dex2oat/aot_class_linker.cc
@@ -22,6 +22,7 @@
#include "dex/class_reference.h"
#include "gc/heap.h"
#include "handle_scope-inl.h"
+#include "interpreter/interpreter_switch_impl.h"
#include "mirror/class-inl.h"
#include "runtime.h"
#include "scoped_thread_state_change-inl.h"
@@ -511,4 +512,9 @@ void AotClassLinker::VisitTransactionRoots(RootVisitor* visitor) {
}
}
+const void* AotClassLinker::GetTransactionalInterpreter() {
+ return reinterpret_cast<const void*>(
+ &interpreter::ExecuteSwitchImplCpp</*transaction_active=*/ true>);
+}
+
} // namespace art
diff --git a/runtime/oat/aot_class_linker.h b/dex2oat/aot_class_linker.h
index 0ee2fe1b42..0321fff0e2 100644
--- a/runtime/oat/aot_class_linker.h
+++ b/dex2oat/aot_class_linker.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_OAT_AOT_CLASS_LINKER_H_
-#define ART_RUNTIME_OAT_AOT_CLASS_LINKER_H_
+#ifndef ART_DEX2OAT_AOT_CLASS_LINKER_H_
+#define ART_DEX2OAT_AOT_CLASS_LINKER_H_
#include <forward_list>
@@ -31,7 +31,6 @@ namespace gc {
class Heap;
} // namespace gc
-// TODO: move to dex2oat/.
// AotClassLinker is only used for AOT compiler, which includes some logic for class initialization
// which will only be used in pre-compilation.
class AotClassLinker : public ClassLinker {
@@ -138,9 +137,13 @@ class AotClassLinker : public ClassLinker {
REQUIRES_SHARED(Locks::mutator_lock_);
bool IsTransactionAborted() const override;
+ // Visit transaction roots for AOT compilation.
void VisitTransactionRoots(RootVisitor* visitor) override
REQUIRES_SHARED(Locks::mutator_lock_);
+ // Get transactional switch interpreter entrypoint for AOT compilation.
+ const void* GetTransactionalInterpreter() override;
+
protected:
// Overridden version of PerformClassVerification allows skipping verification if the class was
// previously verified but unloaded.
@@ -179,4 +182,4 @@ class AotClassLinker : public ClassLinker {
} // namespace art
-#endif // ART_RUNTIME_OAT_AOT_CLASS_LINKER_H_
+#endif // ART_DEX2OAT_AOT_CLASS_LINKER_H_
diff --git a/dex2oat/art_standalone_dex2oat_tests.xml b/dex2oat/art_standalone_dex2oat_tests.xml
index d0c3f40738..d86eb154bb 100644
--- a/dex2oat/art_standalone_dex2oat_tests.xml
+++ b/dex2oat/art_standalone_dex2oat_tests.xml
@@ -49,6 +49,7 @@
<option name="push" value="art-gtest-jars-StaticLeafMethods.jar->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-StaticLeafMethods.jar" />
<option name="push" value="art-gtest-jars-Statics.jar->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-Statics.jar" />
<option name="push" value="art-gtest-jars-StringLiterals.jar->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-StringLiterals.jar" />
+ <option name="push" value="art-gtest-jars-Transaction.jar->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-Transaction.jar" />
<option name="push" value="art-gtest-jars-VerifierDeps.dex->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-VerifierDeps.dex" />
<option name="push" value="art-gtest-jars-VerifierDepsMulti.dex->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-VerifierDepsMulti.dex" />
<option name="push" value="art-gtest-jars-VerifySoftFailDuringClinit.dex->/data/local/tmp/art_standalone_dex2oat_tests/art-gtest-jars-VerifySoftFailDuringClinit.dex" />
diff --git a/runtime/common_transaction_test.cc b/dex2oat/common_transaction_test.cc
index 85f176944a..d24acd575d 100644
--- a/runtime/common_transaction_test.cc
+++ b/dex2oat/common_transaction_test.cc
@@ -16,11 +16,34 @@
#include "common_transaction_test.h"
-#include "oat/aot_class_linker.h"
+#include "aot_class_linker.h"
#include "runtime.h"
namespace art HIDDEN {
+class CommonTransactionTestCompilerCallbacks : public CompilerCallbacks {
+ public:
+ CommonTransactionTestCompilerCallbacks()
+ : CompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp) {}
+
+ ClassLinker* CreateAotClassLinker(InternTable* intern_table) override {
+ return new AotClassLinker(intern_table);
+ }
+
+ void AddUncompilableMethod([[maybe_unused]] MethodReference ref) override {}
+ void AddUncompilableClass([[maybe_unused]] ClassReference ref) override {}
+ void ClassRejected([[maybe_unused]] ClassReference ref) override {}
+
+ verifier::VerifierDeps* GetVerifierDeps() const override { return nullptr; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CommonTransactionTestCompilerCallbacks);
+};
+
+CompilerCallbacks* CommonTransactionTestImpl::CreateCompilerCallbacks() {
+ return new CommonTransactionTestCompilerCallbacks();
+}
+
void CommonTransactionTestImpl::EnterTransactionMode() {
CHECK(!Runtime::Current()->IsActiveTransaction());
AotClassLinker* class_linker = down_cast<AotClassLinker*>(Runtime::Current()->GetClassLinker());
diff --git a/runtime/common_transaction_test.h b/dex2oat/common_transaction_test.h
index 937662009f..6580822a61 100644
--- a/runtime/common_transaction_test.h
+++ b/dex2oat/common_transaction_test.h
@@ -14,15 +14,19 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_COMMON_TRANSACTION_TEST_H_
-#define ART_RUNTIME_COMMON_TRANSACTION_TEST_H_
+#ifndef ART_DEX2OAT_COMMON_TRANSACTION_TEST_H_
+#define ART_DEX2OAT_COMMON_TRANSACTION_TEST_H_
#include "common_runtime_test.h"
+#include "compiler_callbacks.h"
+
namespace art HIDDEN {
class CommonTransactionTestImpl {
protected:
+ static CompilerCallbacks* CreateCompilerCallbacks();
+
static void EnterTransactionMode() REQUIRES_SHARED(Locks::mutator_lock_);
static void ExitTransactionMode();
static void RollbackAndExitTransactionMode() REQUIRES_SHARED(Locks::mutator_lock_);
@@ -30,10 +34,16 @@ class CommonTransactionTestImpl {
};
template <typename TestType>
-class CommonTransactionTestBase : public TestType, public CommonTransactionTestImpl {};
+class CommonTransactionTestBase : public TestType, public CommonTransactionTestImpl {
+ public:
+ void SetUpRuntimeOptions(RuntimeOptions* options) override {
+ TestType::SetUpRuntimeOptions(options);
+ this->callbacks_.reset(CommonTransactionTestImpl::CreateCompilerCallbacks());
+ }
+};
using CommonTransactionTest = CommonTransactionTestBase<CommonRuntimeTest>;
} // namespace art
-#endif // ART_RUNTIME_COMMON_TRANSACTION_TEST_H_
+#endif // ART_DEX2OAT_COMMON_TRANSACTION_TEST_H_
diff --git a/dex2oat/dex/quick_compiler_callbacks.cc b/dex2oat/dex/quick_compiler_callbacks.cc
index c3b1c9b530..6261cc27c5 100644
--- a/dex2oat/dex/quick_compiler_callbacks.cc
+++ b/dex2oat/dex/quick_compiler_callbacks.cc
@@ -16,12 +16,17 @@
#include "quick_compiler_callbacks.h"
+#include "aot_class_linker.h"
#include "dex/verification_results.h"
#include "driver/compiler_driver.h"
#include "mirror/class-inl.h"
namespace art {
+ClassLinker* QuickCompilerCallbacks::CreateAotClassLinker(InternTable* intern_table) {
+ return new AotClassLinker(intern_table);
+}
+
void QuickCompilerCallbacks::AddUncompilableMethod(MethodReference ref) {
if (verification_results_ != nullptr) {
verification_results_->AddUncompilableMethod(ref);
diff --git a/dex2oat/dex/quick_compiler_callbacks.h b/dex2oat/dex/quick_compiler_callbacks.h
index a7a482b4ca..bb5bed38a2 100644
--- a/dex2oat/dex/quick_compiler_callbacks.h
+++ b/dex2oat/dex/quick_compiler_callbacks.h
@@ -33,6 +33,8 @@ class QuickCompilerCallbacks final : public CompilerCallbacks {
~QuickCompilerCallbacks() { }
+ ClassLinker* CreateAotClassLinker(InternTable* intern_table) override;
+
void AddUncompilableMethod(MethodReference ref) override;
void AddUncompilableClass(ClassReference ref) override;
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 31a83bd198..f39f892396 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -39,12 +39,14 @@
#endif // __arm__
#endif
-#include "android-base/parseint.h"
-#include "android-base/properties.h"
-#include "android-base/scopeguard.h"
-#include "android-base/stringprintf.h"
-#include "android-base/strings.h"
-#include "android-base/unique_fd.h"
+#include <android-base/parseint.h>
+#include <android-base/properties.h>
+#include <android-base/scopeguard.h>
+#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
+
+#include "aot_class_linker.h"
#include "arch/instruction_set_features.h"
#include "art_method-inl.h"
#include "base/callee_save_type.h"
@@ -95,7 +97,6 @@
#include "mirror/class_loader.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
-#include "oat/aot_class_linker.h"
#include "oat/elf_file.h"
#include "oat/oat.h"
#include "oat/oat_file.h"
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index b01e9af495..bbf7ea5468 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -25,9 +25,10 @@
#include <string_view>
#include <vector>
-#include "android-base/logging.h"
-#include "android-base/strings.h"
+#include <android-base/logging.h>
+#include <android-base/strings.h>
+#include "aot_class_linker.h"
#include "art_field-inl.h"
#include "art_method-inl.h"
#include "base/arena_allocator.h"
@@ -72,7 +73,6 @@
#include "mirror/object-refvisitor-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/throwable.h"
-#include "oat/aot_class_linker.h"
#include "object_lock.h"
#include "profile/profile_compilation_info.h"
#include "runtime.h"
diff --git a/runtime/interpreter/interpreter_switch_impl1.cc b/dex2oat/interpreter/interpreter_switch_impl1.cc
index 9c5b5b3266..c7e2ed1ad3 100644
--- a/runtime/interpreter/interpreter_switch_impl1.cc
+++ b/dex2oat/interpreter/interpreter_switch_impl1.cc
@@ -17,9 +17,9 @@
// The interpreter function takes considerable time to compile and link.
// We compile the explicit definitions separately to speed up the build.
-#include "interpreter_switch_impl-inl.h"
+#include "interpreter/interpreter_switch_impl-inl.h"
-#include "oat/aot_class_linker.h"
+#include "aot_class_linker.h"
#include "transaction.h"
namespace art HIDDEN {
diff --git a/runtime/interpreter/unstarted_runtime_transaction_test.cc b/dex2oat/interpreter/unstarted_runtime_transaction_test.cc
index abbcbbb12e..ec308c2c18 100644
--- a/runtime/interpreter/unstarted_runtime_transaction_test.cc
+++ b/dex2oat/interpreter/unstarted_runtime_transaction_test.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "unstarted_runtime_test.h"
+#include "interpreter/unstarted_runtime_test.h"
#include "class_root-inl.h"
#include "common_transaction_test.h"
diff --git a/runtime/sdk_checker.cc b/dex2oat/sdk_checker.cc
index 40987e96b5..40987e96b5 100644
--- a/runtime/sdk_checker.cc
+++ b/dex2oat/sdk_checker.cc
diff --git a/runtime/sdk_checker.h b/dex2oat/sdk_checker.h
index 08e4479846..a409d59981 100644
--- a/runtime/sdk_checker.h
+++ b/dex2oat/sdk_checker.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_SDK_CHECKER_H_
-#define ART_RUNTIME_SDK_CHECKER_H_
+#ifndef ART_DEX2OAT_SDK_CHECKER_H_
+#define ART_DEX2OAT_SDK_CHECKER_H_
#include "art_field.h"
#include "art_method.h"
@@ -74,4 +74,4 @@ class SdkChecker {
} // namespace art
-#endif // ART_RUNTIME_SDK_CHECKER_H_
+#endif // ART_DEX2OAT_SDK_CHECKER_H_
diff --git a/runtime/transaction.cc b/dex2oat/transaction.cc
index ea0bcb4776..eb7eea31bb 100644
--- a/runtime/transaction.cc
+++ b/dex2oat/transaction.cc
@@ -18,6 +18,7 @@
#include <android-base/logging.h>
+#include "aot_class_linker.h"
#include "base/mutex-inl.h"
#include "base/stl_util.h"
#include "common_throws.h"
@@ -30,7 +31,6 @@
#include "mirror/dex_cache-inl.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
-#include "oat/aot_class_linker.h"
#include "obj_ptr-inl.h"
#include "runtime.h"
diff --git a/runtime/transaction.h b/dex2oat/transaction.h
index 324188614f..79041e321f 100644
--- a/runtime/transaction.h
+++ b/dex2oat/transaction.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_TRANSACTION_H_
-#define ART_RUNTIME_TRANSACTION_H_
+#ifndef ART_DEX2OAT_TRANSACTION_H_
+#define ART_DEX2OAT_TRANSACTION_H_
#include "base/scoped_arena_containers.h"
#include "base/macros.h"
@@ -386,4 +386,4 @@ class Transaction final {
} // namespace art
-#endif // ART_RUNTIME_TRANSACTION_H_
+#endif // ART_DEX2OAT_TRANSACTION_H_
diff --git a/runtime/transaction_test.cc b/dex2oat/transaction_test.cc
index 17a78ad6af..17a78ad6af 100644
--- a/runtime/transaction_test.cc
+++ b/dex2oat/transaction_test.cc
diff --git a/dex2oat/verifier_deps_test.cc b/dex2oat/verifier_deps_test.cc
index 1ede9e07bc..2cddcedcfa 100644
--- a/dex2oat/verifier_deps_test.cc
+++ b/dex2oat/verifier_deps_test.cc
@@ -17,6 +17,7 @@
// Test is in compiler, as it uses compiler related code.
#include "verifier/verifier_deps.h"
+#include "aot_class_linker.h"
#include "art_method-inl.h"
#include "base/indenter.h"
#include "class_linker.h"
@@ -46,6 +47,10 @@ class VerifierDepsCompilerCallbacks : public CompilerCallbacks {
: CompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp),
deps_(nullptr) {}
+ ClassLinker* CreateAotClassLinker(InternTable* intern_table) override {
+ return new AotClassLinker(intern_table);
+ }
+
void AddUncompilableMethod([[maybe_unused]] MethodReference ref) override {}
void AddUncompilableClass([[maybe_unused]] ClassReference ref) override {}
void ClassRejected([[maybe_unused]] ClassReference ref) override {}
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 276e25c1de..5c5bcdbd10 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -301,7 +301,6 @@ cc_defaults {
"interpreter/interpreter_cache.cc",
"interpreter/interpreter_common.cc",
"interpreter/interpreter_switch_impl0.cc",
- "interpreter/interpreter_switch_impl1.cc",
"interpreter/lock_count_data.cc",
"interpreter/shadow_frame.cc",
"interpreter/unstarted_runtime.cc",
@@ -379,7 +378,6 @@ cc_defaults {
"native_stack_dump.cc",
"non_debuggable_classes.cc",
"nterp_helpers.cc",
- "oat/aot_class_linker.cc",
"oat/elf_file.cc",
"oat/image.cc",
"oat/index_bss_mapping.cc",
@@ -408,7 +406,6 @@ cc_defaults {
"runtime_intrinsics.cc",
"runtime_options.cc",
"scoped_thread_state_change.cc",
- "sdk_checker.cc",
"signal_catcher.cc",
"stack.cc",
"startup_completed_task.cc",
@@ -418,7 +415,6 @@ cc_defaults {
"thread_pool.cc",
"ti/agent.cc",
"trace.cc",
- "transaction.cc",
"var_handles.cc",
"vdex_file.cc",
"verifier/class_verifier.cc",
@@ -944,7 +940,6 @@ art_cc_defaults {
],
srcs: [
"common_runtime_test.cc",
- "common_transaction_test.cc",
"dexopt_test.cc",
],
static_libs: [
@@ -1019,7 +1014,6 @@ art_cc_defaults {
":art-gtest-jars-StaticLeafMethods",
":art-gtest-jars-Statics",
":art-gtest-jars-StaticsFromCode",
- ":art-gtest-jars-Transaction",
":art-gtest-jars-VerifierDeps",
":art-gtest-jars-VerifierDepsMulti",
":art-gtest-jars-XandY",
@@ -1038,7 +1032,6 @@ art_cc_defaults {
"oat/oat_file_assistant_test.cc",
"runtime_callbacks_test.cc",
"subtype_check_test.cc",
- "transaction_test.cc",
"verifier/reg_type_test.cc",
],
srcs: [
@@ -1090,7 +1083,6 @@ art_cc_defaults {
"intern_table_test.cc",
"interpreter/safe_math_test.cc",
"interpreter/unstarted_runtime_test.cc",
- "interpreter/unstarted_runtime_transaction_test.cc",
"jit/jit_memory_region_test.cc",
"jit/profile_saver_test.cc",
"jit/profiling_info_test.cc",
@@ -1119,7 +1111,6 @@ art_cc_defaults {
"subtype_check_test.cc",
"thread_pool_test.cc",
"thread_test.cc",
- "transaction_test.cc",
"two_runtimes_test.cc",
"vdex_file_test.cc",
"verifier/method_verifier_test.cc",
diff --git a/runtime/art_standalone_runtime_tests.xml b/runtime/art_standalone_runtime_tests.xml
index d0e959c345..e48db7a26c 100644
--- a/runtime/art_standalone_runtime_tests.xml
+++ b/runtime/art_standalone_runtime_tests.xml
@@ -59,7 +59,6 @@
<option name="push" value="art-gtest-jars-StaticLeafMethods.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-StaticLeafMethods.jar" />
<option name="push" value="art-gtest-jars-Statics.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-Statics.jar" />
<option name="push" value="art-gtest-jars-StaticsFromCode.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-StaticsFromCode.jar" />
- <option name="push" value="art-gtest-jars-Transaction.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-Transaction.jar" />
<option name="push" value="art-gtest-jars-VerifierDeps.dex->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-VerifierDeps.dex" />
<option name="push" value="art-gtest-jars-VerifierDepsMulti.dex->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-VerifierDepsMulti.dex" />
<option name="push" value="art-gtest-jars-XandY.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-XandY.jar" />
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 72e4d14789..ca1ab1d8d6 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -155,7 +155,6 @@
#include "thread.h"
#include "thread_list.h"
#include "trace.h"
-#include "transaction.h"
#include "vdex_file.h"
#include "verifier/class_verifier.h"
#include "verifier/verifier_deps.h"
@@ -11341,6 +11340,12 @@ void ClassLinker::VisitTransactionRoots([[maybe_unused]] RootVisitor* visitor) {
// Nothing to do for normal `ClassLinker`, only `AotClassLinker` handles transactions.
}
+const void* ClassLinker::GetTransactionalInterpreter() {
+ // Should not be called on ClassLinker, only on AotClassLinker that overrides this.
+ LOG(FATAL) << "UNREACHABLE";
+ UNREACHABLE();
+}
+
void ClassLinker::RemoveDexFromCaches(const DexFile& dex_file) {
ReaderMutexLock mu(Thread::Current(), *Locks::dex_lock_);
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 660e4be20e..bc9f5931ee 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -954,10 +954,13 @@ class EXPORT ClassLinker {
REQUIRES_SHARED(Locks::mutator_lock_);
virtual bool IsTransactionAborted() const;
- // Vist transaction roots for AOT compilation.
+ // Visit transaction roots for AOT compilation.
virtual void VisitTransactionRoots(RootVisitor* visitor)
REQUIRES_SHARED(Locks::mutator_lock_);
+ // Get transactional switch interpreter entrypoint for AOT compilation.
+ virtual const void* GetTransactionalInterpreter();
+
void RemoveDexFromCaches(const DexFile& dex_file);
ClassTable* GetBootClassTable() REQUIRES_SHARED(Locks::classlinker_classes_lock_) {
return boot_class_table_.get();
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 311391dbbf..165b3a9c8a 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -58,7 +58,6 @@
#include "mirror/object_array-alloc-inl.h"
#include "native/dalvik_system_DexFile.h"
#include "noop_compiler_callbacks.h"
-#include "oat/aot_class_linker.h"
#include "profile/profile_compilation_info.h"
#include "runtime-inl.h"
#include "runtime_intrinsics.h"
@@ -112,6 +111,7 @@ void CommonRuntimeTestImpl::SetUp() {
static bool gSlowDebugTestFlag = false;
RegisterRuntimeDebugFlag(&gSlowDebugTestFlag);
+ // Create default compiler callbacks. `SetUpRuntimeOptions()` can replace or remove this.
callbacks_.reset(new NoopCompilerCallbacks());
SetUpRuntimeOptions(&options);
diff --git a/runtime/common_throws.h b/runtime/common_throws.h
index 71b0968fc0..9b5da327f2 100644
--- a/runtime/common_throws.h
+++ b/runtime/common_throws.h
@@ -48,7 +48,7 @@ void ThrowAbstractMethodError(uint32_t method_idx, const DexFile& dex_file)
// ArithmeticException
-void ThrowArithmeticExceptionDivideByZero() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
+EXPORT void ThrowArithmeticExceptionDivideByZero() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
// ArrayIndexOutOfBoundsException
@@ -79,7 +79,7 @@ void ThrowClassCircularityError(ObjPtr<mirror::Class> c, const char* fmt, ...)
// ClassCastException
-void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type)
+EXPORT void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
void ThrowClassCastException(const char* msg)
@@ -111,7 +111,7 @@ EXPORT void ThrowIllegalAccessErrorField(ObjPtr<mirror::Class> referrer, ArtFiel
EXPORT void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowIllegalAccessError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
+EXPORT void ThrowIllegalAccessError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
__attribute__((__format__(__printf__, 2, 3)))
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
@@ -143,14 +143,12 @@ void ThrowIncompatibleClassChangeError(InvokeType expected_type,
ArtMethod* referrer)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* interface_method,
- ObjPtr<mirror::Object> this_object,
- ArtMethod* referrer)
+EXPORT void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(
+ ArtMethod* interface_method, ObjPtr<mirror::Object> this_object, ArtMethod* referrer)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-EXPORT void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field,
- bool is_static,
- ArtMethod* referrer)
+EXPORT void ThrowIncompatibleClassChangeErrorField(
+ ArtField* resolved_field, bool is_static, ArtMethod* referrer)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
void ThrowIncompatibleClassChangeError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
@@ -191,7 +189,7 @@ void ThrowWrappedLinkageError(ObjPtr<mirror::Class> referrer, const char* fmt, .
// NegativeArraySizeException
-void ThrowNegativeArraySizeException(int size)
+EXPORT void ThrowNegativeArraySizeException(int size)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
void ThrowNegativeArraySizeException(const char* msg)
@@ -218,16 +216,14 @@ void ThrowNoSuchMethodError(InvokeType type,
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
// NullPointerException
-
+EXPORT
void ThrowNullPointerExceptionForFieldAccess(ArtField* field, ArtMethod* method, bool is_read)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx,
- InvokeType type)
+EXPORT void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx, InvokeType type)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method,
- InvokeType type)
+void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method, InvokeType type)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
void ThrowNullPointerExceptionFromDexPC(bool check_address = false, uintptr_t addr = 0)
@@ -236,7 +232,7 @@ void ThrowNullPointerExceptionFromDexPC(bool check_address = false, uintptr_t ad
EXPORT void ThrowNullPointerException(const char* msg)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerException()
+EXPORT void ThrowNullPointerException()
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
// ReadOnlyBufferException
diff --git a/runtime/compiler_callbacks.h b/runtime/compiler_callbacks.h
index cd6f6b893b..e196b0b921 100644
--- a/runtime/compiler_callbacks.h
+++ b/runtime/compiler_callbacks.h
@@ -25,7 +25,9 @@
namespace art HIDDEN {
+class ClassLinker;
class CompilerDriver;
+class InternTable;
namespace mirror {
@@ -48,6 +50,8 @@ class CompilerCallbacks {
virtual ~CompilerCallbacks() { }
+ virtual ClassLinker* CreateAotClassLinker(InternTable* intern_table) = 0;
+
virtual void AddUncompilableMethod(MethodReference ref) = 0;
virtual void AddUncompilableClass(ClassReference ref) = 0;
virtual void ClassRejected(ClassReference ref) = 0;
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index b0d0ab4b07..fde8043032 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -509,6 +509,7 @@ static inline bool IsStringInit(const Instruction& instr, ArtMethod* caller)
return false;
}
+LIBART_PROTECTED
extern "C" size_t NterpGetMethod(Thread* self, ArtMethod* caller, const uint16_t* dex_pc_ptr);
template <InvokeType type>
diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h
index 3dfeaae024..a5408752be 100644
--- a/runtime/entrypoints/entrypoint_utils.h
+++ b/runtime/entrypoints/entrypoint_utils.h
@@ -181,7 +181,7 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa,
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Roles::uninterruptible_);
-bool FillArrayData(ObjPtr<mirror::Object> obj, const Instruction::ArrayDataPayload* payload)
+EXPORT bool FillArrayData(ObjPtr<mirror::Object> obj, const Instruction::ArrayDataPayload* payload)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Roles::uninterruptible_);
diff --git a/runtime/intern_table.h b/runtime/intern_table.h
index 6a76c74c3a..d91a3216c6 100644
--- a/runtime/intern_table.h
+++ b/runtime/intern_table.h
@@ -294,11 +294,11 @@ class InternTable {
// Note: Transaction rollback calls these helper functions directly.
EXPORT ObjPtr<mirror::String> InsertStrong(ObjPtr<mirror::String> s, uint32_t hash)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(Locks::intern_table_lock_);
- ObjPtr<mirror::String> InsertWeak(ObjPtr<mirror::String> s, uint32_t hash)
+ EXPORT ObjPtr<mirror::String> InsertWeak(ObjPtr<mirror::String> s, uint32_t hash)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(Locks::intern_table_lock_);
- void RemoveStrong(ObjPtr<mirror::String> s, uint32_t hash)
+ EXPORT void RemoveStrong(ObjPtr<mirror::String> s, uint32_t hash)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(Locks::intern_table_lock_);
- void RemoveWeak(ObjPtr<mirror::String> s, uint32_t hash)
+ void EXPORT RemoveWeak(ObjPtr<mirror::String> s, uint32_t hash)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(Locks::intern_table_lock_);
// Change the weak root state. May broadcast to waiters.
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index fb6f36d5e7..eeeb300a92 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -237,13 +237,12 @@ static JValue ExecuteSwitch(Thread* self,
ShadowFrame& shadow_frame,
JValue result_register,
bool interpret_one_instruction) REQUIRES_SHARED(Locks::mutator_lock_) {
- if (Runtime::Current()->IsActiveTransaction()) {
- return ExecuteSwitchImpl<true>(
- self, accessor, shadow_frame, result_register, interpret_one_instruction);
- } else {
- return ExecuteSwitchImpl<false>(
- self, accessor, shadow_frame, result_register, interpret_one_instruction);
- }
+ Runtime* runtime = Runtime::Current();
+ auto switch_impl_cpp = runtime->IsActiveTransaction()
+ ? runtime->GetClassLinker()->GetTransactionalInterpreter()
+ : reinterpret_cast<const void*>(&ExecuteSwitchImplCpp</*transaction_active=*/ false>);
+ return ExecuteSwitchImpl(
+ self, accessor, shadow_frame, result_register, interpret_one_instruction, switch_impl_cpp);
}
NO_STACK_PROTECTOR
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index bad54ee448..ce6c412ba8 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -66,7 +66,7 @@
namespace art HIDDEN {
namespace interpreter {
-void ThrowNullPointerExceptionFromInterpreter()
+EXPORT void ThrowNullPointerExceptionFromInterpreter()
REQUIRES_SHARED(Locks::mutator_lock_);
static inline void DoMonitorEnter(Thread* self, ShadowFrame* frame, ObjPtr<mirror::Object> ref)
@@ -114,13 +114,13 @@ static inline bool DoMonitorCheckOnExit(Thread* self, ShadowFrame* frame)
// DoFastInvoke and DoInvokeVirtualQuick functions.
// Returns true on success, otherwise throws an exception and returns false.
template<bool is_range>
-bool DoCall(ArtMethod* called_method,
- Thread* self,
- ShadowFrame& shadow_frame,
- const Instruction* inst,
- uint16_t inst_data,
- bool string_init,
- JValue* result);
+EXPORT bool DoCall(ArtMethod* called_method,
+ Thread* self,
+ ShadowFrame& shadow_frame,
+ const Instruction* inst,
+ uint16_t inst_data,
+ bool string_init,
+ JValue* result);
// Called by the switch interpreter to know if we can stay in it.
bool ShouldStayInSwitchInterpreter(ArtMethod* method)
@@ -133,7 +133,8 @@ NO_INLINE bool CheckStackOverflow(Thread* self, size_t frame_size)
// Sends the normal method exit event.
// Returns true if the events succeeded and false if there is a pending exception.
-template <typename T> bool SendMethodExitEvents(
+template <typename T>
+bool SendMethodExitEvents(
Thread* self,
const instrumentation::Instrumentation* instrumentation,
ShadowFrame& frame,
@@ -149,6 +150,7 @@ NeedsMethodExitEvent(const instrumentation::Instrumentation* ins)
COLD_ATTR void UnlockHeldMonitors(Thread* self, ShadowFrame* shadow_frame)
REQUIRES_SHARED(Locks::mutator_lock_);
+EXPORT
void PerformNonStandardReturn(Thread* self,
ShadowFrame& frame,
JValue& result,
@@ -211,18 +213,18 @@ ART_INTRINSICS_LIST(DECLARE_SIGNATURE_POLYMORPHIC_HANDLER)
// Performs a invoke-polymorphic or invoke-polymorphic-range.
template<bool is_range>
-bool DoInvokePolymorphic(Thread* self,
- ShadowFrame& shadow_frame,
- const Instruction* inst,
- uint16_t inst_data,
- JValue* result)
+EXPORT bool DoInvokePolymorphic(Thread* self,
+ ShadowFrame& shadow_frame,
+ const Instruction* inst,
+ uint16_t inst_data,
+ JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_);
-bool DoInvokeCustom(Thread* self,
- ShadowFrame& shadow_frame,
- uint32_t call_site_idx,
- const InstructionOperands* operands,
- JValue* result)
+EXPORT bool DoInvokeCustom(Thread* self,
+ ShadowFrame& shadow_frame,
+ uint32_t call_site_idx,
+ const InstructionOperands* operands,
+ JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_);
// Performs a custom invoke (invoke-custom/invoke-custom-range).
@@ -278,11 +280,13 @@ ALWAYS_INLINE static JValue GetFieldValue(const ShadowFrame& shadow_frame, uint3
return field_value;
}
+LIBART_PROTECTED
extern "C" size_t NterpGetStaticField(Thread* self,
ArtMethod* caller,
const uint16_t* dex_pc_ptr,
size_t resolve_field_type);
+LIBART_PROTECTED
extern "C" uint32_t NterpGetInstanceFieldOffset(Thread* self,
ArtMethod* caller,
const uint16_t* dex_pc_ptr,
@@ -422,10 +426,10 @@ static inline bool DoLongRemainder(ShadowFrame& shadow_frame,
// Handles filled-new-array and filled-new-array-range instructions.
// Returns true on success, otherwise throws an exception and returns false.
template <bool is_range>
-bool DoFilledNewArray(const Instruction* inst,
- const ShadowFrame& shadow_frame,
- Thread* self,
- JValue* result);
+EXPORT bool DoFilledNewArray(const Instruction* inst,
+ const ShadowFrame& shadow_frame,
+ Thread* self,
+ JValue* result);
// Handles packed-switch instruction.
// Returns the branch offset to the next instruction to execute.
@@ -498,14 +502,14 @@ static inline int32_t DoSparseSwitch(const Instruction* inst, const ShadowFrame&
// This function accepts a null Instrumentation* as a way to cause instrumentation events not to be
// reported.
// TODO We might wish to reconsider how we cause some events to be ignored.
-bool MoveToExceptionHandler(Thread* self,
- ShadowFrame& shadow_frame,
- bool skip_listeners,
- bool skip_throw_listener) REQUIRES_SHARED(Locks::mutator_lock_);
-
-NO_RETURN void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame)
- __attribute__((cold))
- REQUIRES_SHARED(Locks::mutator_lock_);
+EXPORT bool MoveToExceptionHandler(Thread* self,
+ ShadowFrame& shadow_frame,
+ bool skip_listeners,
+ bool skip_throw_listener) REQUIRES_SHARED(Locks::mutator_lock_);
+
+NO_RETURN EXPORT void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame)
+ COLD_ATTR
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Set true if you want TraceExecution invocation before each bytecode execution.
constexpr bool kTraceExecutionEnabled = false;
diff --git a/runtime/interpreter/interpreter_switch_impl.h b/runtime/interpreter/interpreter_switch_impl.h
index c390692f10..0b5a86f22d 100644
--- a/runtime/interpreter/interpreter_switch_impl.h
+++ b/runtime/interpreter/interpreter_switch_impl.h
@@ -51,16 +51,17 @@ void ExecuteSwitchImplCpp(SwitchImplContext* ctx)
// Hand-written assembly method which wraps the C++ implementation,
// while defining the DEX PC in the CFI so that libunwind can resolve it.
-extern "C" void ExecuteSwitchImplAsm(SwitchImplContext* ctx, void* impl, const uint16_t* dexpc)
- REQUIRES_SHARED(Locks::mutator_lock_);
+extern "C" void ExecuteSwitchImplAsm(
+ SwitchImplContext* ctx, const void* impl, const uint16_t* dexpc)
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Wrapper around the switch interpreter which ensures we can unwind through it.
-template<bool transaction_active>
-ALWAYS_INLINE JValue ExecuteSwitchImpl(Thread* self,
- const CodeItemDataAccessor& accessor,
- ShadowFrame& shadow_frame,
- JValue result_register,
- bool interpret_one_instruction)
+ALWAYS_INLINE inline JValue ExecuteSwitchImpl(Thread* self,
+ const CodeItemDataAccessor& accessor,
+ ShadowFrame& shadow_frame,
+ JValue result_register,
+ bool interpret_one_instruction,
+ const void* switch_impl_cpp)
REQUIRES_SHARED(Locks::mutator_lock_) {
SwitchImplContext ctx {
.self = self,
@@ -70,9 +71,8 @@ ALWAYS_INLINE JValue ExecuteSwitchImpl(Thread* self,
.interpret_one_instruction = interpret_one_instruction,
.result = JValue(),
};
- void* impl = reinterpret_cast<void*>(&ExecuteSwitchImplCpp<transaction_active>);
const uint16_t* dex_pc = ctx.accessor.Insns();
- ExecuteSwitchImplAsm(&ctx, impl, dex_pc);
+ ExecuteSwitchImplAsm(&ctx, switch_impl_cpp, dex_pc);
return ctx.result;
}
diff --git a/runtime/interpreter/lock_count_data.h b/runtime/interpreter/lock_count_data.h
index ec108fc5c1..6e6b6c986d 100644
--- a/runtime/interpreter/lock_count_data.h
+++ b/runtime/interpreter/lock_count_data.h
@@ -41,18 +41,18 @@ class LockCountData {
public:
// Add the given object to the list of monitors, that is, objects that have been locked. This
// will not throw (but be skipped if there is an exception pending on entry).
- void AddMonitor(Thread* self, mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void AddMonitor(Thread* self, mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
// Try to remove the given object from the monitor list, indicating an unlock operation.
// This will throw an IllegalMonitorStateException (clearing any already pending exception), in
// case that there wasn't a lock recorded for the object.
- void RemoveMonitorOrThrow(Thread* self,
- const mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT void RemoveMonitorOrThrow(Thread* self,
+ const mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
// Check whether all acquired monitors have been released. This will potentially throw an
// IllegalMonitorStateException, clearing any already pending exception. Returns true if the
// check shows that everything is OK wrt/ lock counting, false otherwise.
- bool CheckAllMonitorsReleasedOrThrow(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
+ EXPORT bool CheckAllMonitorsReleasedOrThrow(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
template <typename T, typename... Args>
void VisitMonitors(T visitor, Args&&... args) REQUIRES_SHARED(Locks::mutator_lock_) {
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index 64f04d6fde..d3f2423b87 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -314,7 +314,7 @@ static constexpr std::array<uint8_t, 256u> GenerateOpcodeInvokeTypes() {
static constexpr std::array<uint8_t, 256u> kOpcodeInvokeTypes = GenerateOpcodeInvokeTypes();
-FLATTEN
+LIBART_PROTECTED FLATTEN
extern "C" size_t NterpGetMethod(Thread* self, ArtMethod* caller, const uint16_t* dex_pc_ptr)
REQUIRES_SHARED(Locks::mutator_lock_) {
UpdateHotness(caller);
@@ -387,6 +387,7 @@ extern "C" size_t NterpGetMethod(Thread* self, ArtMethod* caller, const uint16_t
}
}
+LIBART_PROTECTED
extern "C" size_t NterpGetStaticField(Thread* self,
ArtMethod* caller,
const uint16_t* dex_pc_ptr,
@@ -442,6 +443,7 @@ extern "C" size_t NterpGetStaticField(Thread* self,
}
}
+LIBART_PROTECTED
extern "C" uint32_t NterpGetInstanceFieldOffset(Thread* self,
ArtMethod* caller,
const uint16_t* dex_pc_ptr,
diff --git a/runtime/noop_compiler_callbacks.h b/runtime/noop_compiler_callbacks.h
index 34e15e71ad..557ed6ef6e 100644
--- a/runtime/noop_compiler_callbacks.h
+++ b/runtime/noop_compiler_callbacks.h
@@ -18,15 +18,21 @@
#define ART_RUNTIME_NOOP_COMPILER_CALLBACKS_H_
#include "base/macros.h"
+#include "class_linker.h"
#include "compiler_callbacks.h"
namespace art HIDDEN {
+// Used for tests and some tools that pretend to be a compiler (say, oatdump).
class NoopCompilerCallbacks final : public CompilerCallbacks {
public:
NoopCompilerCallbacks() : CompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp) {}
~NoopCompilerCallbacks() {}
+ ClassLinker* CreateAotClassLinker(InternTable* intern_table) override {
+ return new PermissiveClassLinker(intern_table);
+ }
+
void AddUncompilableMethod([[maybe_unused]] MethodReference ref) override {}
void AddUncompilableClass([[maybe_unused]] ClassReference ref) override {}
void ClassRejected([[maybe_unused]] ClassReference ref) override {}
@@ -34,6 +40,28 @@ class NoopCompilerCallbacks final : public CompilerCallbacks {
verifier::VerifierDeps* GetVerifierDeps() const override { return nullptr; }
private:
+ // When we supply compiler callbacks, we need an appropriate `ClassLinker` that can
+ // handle `SdkChecker`-related calls that are unimplemented in the base `ClassLinker`.
+ class PermissiveClassLinker : public ClassLinker {
+ public:
+ explicit PermissiveClassLinker(InternTable* intern_table)
+ : ClassLinker(intern_table, /*fast_class_not_found_exceptions=*/ false) {}
+
+ bool DenyAccessBasedOnPublicSdk([[maybe_unused]] ArtMethod* art_method) const override
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ return false;
+ }
+ bool DenyAccessBasedOnPublicSdk([[maybe_unused]] ArtField* art_field) const override
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ return false;
+ }
+ bool DenyAccessBasedOnPublicSdk(
+ [[maybe_unused]] std::string_view type_descriptor) const override {
+ return false;
+ }
+ void SetEnablePublicSdkChecks([[maybe_unused]] bool enabled) override {}
+ };
+
DISALLOW_COPY_AND_ASSIGN(NoopCompilerCallbacks);
};
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 701d68176c..18df2ff092 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -154,7 +154,6 @@
#include "native_stack_dump.h"
#include "nativehelper/scoped_local_ref.h"
#include "nterp_helpers.h"
-#include "oat/aot_class_linker.h"
#include "oat/elf_file.h"
#include "oat/image-inl.h"
#include "oat/oat.h"
@@ -1956,7 +1955,7 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) {
CHECK_GE(GetHeap()->GetContinuousSpaces().size(), 1U);
if (UNLIKELY(IsAotCompiler())) {
- class_linker_ = new AotClassLinker(intern_table_);
+ class_linker_ = compiler_callbacks_->CreateAotClassLinker(intern_table_);
} else {
class_linker_ = new ClassLinker(
intern_table_,