diff options
author | 2025-02-12 14:30:16 +0000 | |
---|---|---|
committer | 2025-02-18 07:29:58 -0800 | |
commit | 17c7ed2de734cf892b005b1d15b3db9855506f14 (patch) | |
tree | ec7cd925e8648e601166e835a061d7b290940e00 | |
parent | cb3c3b2819f326d54a6bd960a9a82c5290aa69b0 (diff) |
Refactor `Instrumentation` out of `Runtime`.
Avoid indirectly `#include`-ing `instrumentation.h` in every
compilation unit that needs the `runtime.h`. This reduces
incremental compilation times when touching certain files.
The additional load when accessing `Instrumentation` via the
`Runtime` has negligible performance impact.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: Ibaf96696693b105e843c7c2cbf4e7604b126808e
-rw-r--r-- | runtime/arch/arm/quick_entrypoints_arm.S | 3 | ||||
-rw-r--r-- | runtime/arch/arm64/quick_entrypoints_arm64.S | 3 | ||||
-rw-r--r-- | runtime/arch/riscv64/quick_entrypoints_riscv64.S | 3 | ||||
-rw-r--r-- | runtime/arch/x86/quick_entrypoints_x86.S | 3 | ||||
-rw-r--r-- | runtime/arch/x86_64/quick_entrypoints_x86_64.S | 3 | ||||
-rw-r--r-- | runtime/common_runtime_test.cc | 1 | ||||
-rw-r--r-- | runtime/debugger.h | 1 | ||||
-rw-r--r-- | runtime/entrypoints/quick/quick_thread_entrypoints.cc | 1 | ||||
-rw-r--r-- | runtime/gc/allocation_record.cc | 1 | ||||
-rw-r--r-- | runtime/jni/jni_internal.cc | 1 | ||||
-rw-r--r-- | runtime/quick_exception_handler.cc | 1 | ||||
-rw-r--r-- | runtime/runtime.cc | 2 | ||||
-rw-r--r-- | runtime/runtime.h | 11 | ||||
-rw-r--r-- | runtime/runtime_callbacks_test.cc | 1 | ||||
-rw-r--r-- | test/2011-stack-walk-concurrent-instrument/stack_walk_concurrent.cc | 1 | ||||
-rw-r--r-- | test/597-deopt-new-string/deopt.cc | 1 | ||||
-rw-r--r-- | tools/cpp-define-generator/asm_defines.def | 1 | ||||
-rw-r--r-- | tools/cpp-define-generator/instrumentation.def | 22 | ||||
-rw-r--r-- | tools/cpp-define-generator/runtime.def | 4 |
19 files changed, 51 insertions, 13 deletions
diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S index ddfe70dc51..150780b921 100644 --- a/runtime/arch/arm/quick_entrypoints_arm.S +++ b/runtime/arch/arm/quick_entrypoints_arm.S @@ -1482,7 +1482,8 @@ ENTRY art_quick_generic_jni_trampoline vmov d0, r0, r1 LOAD_RUNTIME_INSTANCE r2 - ldrb r2, [r2, #RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE] + ldr r2, [r2, #RUNTIME_INSTRUMENTATION_OFFSET] + ldrb r2, [r2, #INSTRUMENTATION_RUN_EXIT_HOOKS_OFFSET] CFI_REMEMBER_STATE cbnz r2, .Lcall_method_exit_hook .Lcall_method_exit_hook_done: diff --git a/runtime/arch/arm64/quick_entrypoints_arm64.S b/runtime/arch/arm64/quick_entrypoints_arm64.S index bcf6fb2f54..98b7e969fc 100644 --- a/runtime/arch/arm64/quick_entrypoints_arm64.S +++ b/runtime/arch/arm64/quick_entrypoints_arm64.S @@ -1832,7 +1832,8 @@ ENTRY art_quick_generic_jni_trampoline mov sp, x28 LOAD_RUNTIME_INSTANCE x1 - ldrb w1, [x1, #RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE] + ldr x1, [x1, #RUNTIME_INSTRUMENTATION_OFFSET] + ldrb w1, [x1, #INSTRUMENTATION_RUN_EXIT_HOOKS_OFFSET] CFI_REMEMBER_STATE cbnz w1, .Lcall_method_exit_hook .Lcall_method_exit_hook_done: diff --git a/runtime/arch/riscv64/quick_entrypoints_riscv64.S b/runtime/arch/riscv64/quick_entrypoints_riscv64.S index f0abb8d2e7..e97c786b91 100644 --- a/runtime/arch/riscv64/quick_entrypoints_riscv64.S +++ b/runtime/arch/riscv64/quick_entrypoints_riscv64.S @@ -357,7 +357,8 @@ ENTRY art_quick_generic_jni_trampoline .cfi_def_cfa_register sp LOAD_RUNTIME_INSTANCE a1 - lb a1, RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE(a1) + ld a1, RUNTIME_INSTRUMENTATION_OFFSET(a1) + lb a1, INSTRUMENTATION_RUN_EXIT_HOOKS_OFFSET(a1) bnez a1, .Lcall_method_exit_hook .Lcall_method_exit_hook_done: diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S index 1078480c8c..1a3539c66d 100644 --- a/runtime/arch/x86/quick_entrypoints_x86.S +++ b/runtime/arch/x86/quick_entrypoints_x86.S @@ -1721,7 +1721,8 @@ DEFINE_FUNCTION art_quick_generic_jni_trampoline punpckldq %xmm1, %xmm0 LOAD_RUNTIME_INSTANCE ebx - cmpb MACRO_LITERAL(0), RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE(%ebx) + movl RUNTIME_INSTRUMENTATION_OFFSET(%ebx), %ebx + cmpb MACRO_LITERAL(0), INSTRUMENTATION_RUN_EXIT_HOOKS_OFFSET(%ebx) CFI_REMEMBER_STATE jne .Lcall_method_exit_hook .Lcall_method_exit_hook_done: diff --git a/runtime/arch/x86_64/quick_entrypoints_x86_64.S b/runtime/arch/x86_64/quick_entrypoints_x86_64.S index 4d00022ff8..96c152492e 100644 --- a/runtime/arch/x86_64/quick_entrypoints_x86_64.S +++ b/runtime/arch/x86_64/quick_entrypoints_x86_64.S @@ -1560,7 +1560,8 @@ DEFINE_FUNCTION art_quick_generic_jni_trampoline movq %rax, %xmm0 LOAD_RUNTIME_INSTANCE rcx - cmpb MACRO_LITERAL(0), RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE(%rcx) + movq RUNTIME_INSTRUMENTATION_OFFSET(%rcx), %rcx + cmpb MACRO_LITERAL(0), INSTRUMENTATION_RUN_EXIT_HOOKS_OFFSET(%rcx) CFI_REMEMBER_STATE jne .Lcall_method_exit_hook .Lcall_method_exit_hook_done: diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index fba0f1c758..16b594d527 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -49,6 +49,7 @@ #include "gc_root-inl.h" #include "gtest/gtest.h" #include "handle_scope-inl.h" +#include "instrumentation.h" #include "interpreter/unstarted_runtime.h" #include "jni/java_vm_ext.h" #include "jni/jni_internal.h" diff --git a/runtime/debugger.h b/runtime/debugger.h index fd261ab51a..b554a80f51 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -28,6 +28,7 @@ #include "base/locks.h" #include "base/logging.h" #include "base/macros.h" +#include "instrumentation.h" #include "jni.h" #include "runtime.h" #include "runtime_callbacks.h" diff --git a/runtime/entrypoints/quick/quick_thread_entrypoints.cc b/runtime/entrypoints/quick/quick_thread_entrypoints.cc index e3511c80d5..2e79605c5e 100644 --- a/runtime/entrypoints/quick/quick_thread_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_thread_entrypoints.cc @@ -16,6 +16,7 @@ #include "arch/context.h" #include "callee_save_frame.h" +#include "instrumentation.h" #include "jit/jit.h" #include "runtime.h" #include "thread-inl.h" diff --git a/runtime/gc/allocation_record.cc b/runtime/gc/allocation_record.cc index 59ec9f2d1b..f89a0695d8 100644 --- a/runtime/gc/allocation_record.cc +++ b/runtime/gc/allocation_record.cc @@ -20,6 +20,7 @@ #include "base/logging.h" // For VLOG #include "base/pointer_size.h" #include "base/stl_util.h" +#include "instrumentation.h" #include "obj_ptr-inl.h" #include "object_callbacks.h" #include "stack.h" diff --git a/runtime/jni/jni_internal.cc b/runtime/jni/jni_internal.cc index a9a5d8b868..1dde2de741 100644 --- a/runtime/jni/jni_internal.cc +++ b/runtime/jni/jni_internal.cc @@ -43,6 +43,7 @@ #include "handle_scope.h" #include "hidden_api.h" #include "indirect_reference_table-inl.h" +#include "instrumentation.h" #include "interpreter/interpreter.h" #include "java_vm_ext.h" #include "jni_env_ext.h" diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index 365a63459d..8180d0a5b3 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -34,6 +34,7 @@ #include "entrypoints/quick/quick_entrypoints_enum.h" #include "entrypoints/runtime_asm_entrypoints.h" #include "handle_scope-inl.h" +#include "instrumentation.h" #include "interpreter/shadow_frame-inl.h" #include "jit/jit.h" #include "jit/jit_code_cache.h" diff --git a/runtime/runtime.cc b/runtime/runtime.cc index d4677d5b86..0186740015 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -282,7 +282,7 @@ Runtime::Runtime() abort_(nullptr), stats_enabled_(false), is_running_on_memory_tool_(kRunningOnMemoryTool), - instrumentation_(), + instrumentation_(new instrumentation::Instrumentation()), main_thread_group_(nullptr), system_thread_group_(nullptr), system_class_loader_(nullptr), diff --git a/runtime/runtime.h b/runtime/runtime.h index 63a0707424..9661f9e514 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -40,7 +40,6 @@ #include "dex/dex_file_types.h" #include "experimental_flags.h" #include "gc_root.h" -#include "instrumentation.h" #include "jdwp_provider.h" #include "jni/jni_id_manager.h" #include "jni_id_type.h" @@ -63,6 +62,10 @@ namespace hiddenapi { enum class EnforcementPolicy; } // namespace hiddenapi +namespace instrumentation { +class Instrumentation; +} // namespace instrumentation + namespace jit { class Jit; class JitCodeCache; @@ -607,11 +610,11 @@ class Runtime { bool profile_system_server = false); const instrumentation::Instrumentation* GetInstrumentation() const { - return &instrumentation_; + return instrumentation_.get(); } instrumentation::Instrumentation* GetInstrumentation() { - return &instrumentation_; + return instrumentation_.get(); } void RegisterAppInfo(const std::string& package_name, @@ -1331,7 +1334,7 @@ class Runtime { std::unique_ptr<TraceConfig> trace_config_; - instrumentation::Instrumentation instrumentation_; + std::unique_ptr<instrumentation::Instrumentation> instrumentation_; jobject main_thread_group_; jobject system_thread_group_; diff --git a/runtime/runtime_callbacks_test.cc b/runtime/runtime_callbacks_test.cc index f63b2f4096..0fd9efa65e 100644 --- a/runtime/runtime_callbacks_test.cc +++ b/runtime/runtime_callbacks_test.cc @@ -35,6 +35,7 @@ #include "dex/class_reference.h" #include "handle.h" #include "handle_scope-inl.h" +#include "instrumentation.h" #include "mirror/class-alloc-inl.h" #include "mirror/class_loader.h" #include "monitor-inl.h" diff --git a/test/2011-stack-walk-concurrent-instrument/stack_walk_concurrent.cc b/test/2011-stack-walk-concurrent-instrument/stack_walk_concurrent.cc index 9ae1bedd23..a6ce0521e4 100644 --- a/test/2011-stack-walk-concurrent-instrument/stack_walk_concurrent.cc +++ b/test/2011-stack-walk-concurrent-instrument/stack_walk_concurrent.cc @@ -19,6 +19,7 @@ #include "arch/context.h" #include "art_method-inl.h" +#include "instrumentation.h" #include "jni.h" #include "scoped_thread_state_change.h" #include "stack.h" diff --git a/test/597-deopt-new-string/deopt.cc b/test/597-deopt-new-string/deopt.cc index b8828157e0..d14257f307 100644 --- a/test/597-deopt-new-string/deopt.cc +++ b/test/597-deopt-new-string/deopt.cc @@ -18,6 +18,7 @@ #include "gc/gc_cause.h" #include "gc/scoped_gc_critical_section.h" +#include "instrumentation.h" #include "mirror/class-inl.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" diff --git a/tools/cpp-define-generator/asm_defines.def b/tools/cpp-define-generator/asm_defines.def index fb011a2ba3..86bceb005e 100644 --- a/tools/cpp-define-generator/asm_defines.def +++ b/tools/cpp-define-generator/asm_defines.def @@ -23,6 +23,7 @@ #include "art_method.def" #include "code_item.def" #include "lockword.def" +#include "instrumentation.def" #include "mirror_array.def" #include "mirror_class.def" #include "mirror_object.def" diff --git a/tools/cpp-define-generator/instrumentation.def b/tools/cpp-define-generator/instrumentation.def new file mode 100644 index 0000000000..e1a13c4d36 --- /dev/null +++ b/tools/cpp-define-generator/instrumentation.def @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2025 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. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "instrumentation.h" +#endif + +ASM_DEFINE(INSTRUMENTATION_RUN_EXIT_HOOKS_OFFSET, + art::instrumentation::Instrumentation::RunExitHooksOffset().Int32Value()) diff --git a/tools/cpp-define-generator/runtime.def b/tools/cpp-define-generator/runtime.def index fd6567d87e..66a542a5d1 100644 --- a/tools/cpp-define-generator/runtime.def +++ b/tools/cpp-define-generator/runtime.def @@ -31,6 +31,4 @@ ASM_DEFINE(RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET, ASM_DEFINE(RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET, art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveRefsOnly)) ASM_DEFINE(RUNTIME_INSTRUMENTATION_OFFSET, art::Runtime::GetInstrumentationOffset().Int32Value()) -ASM_DEFINE(RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE, - art::Runtime::GetInstrumentationOffset().Int32Value() + - art::instrumentation::Instrumentation::RunExitHooksOffset().Int32Value()) + |