From 6ed19fd1b08abbc438781ae3e6fea111c1f92315 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 20 Mar 2014 08:10:17 -0700 Subject: [PATCH] 64bit: make runtime offsets more deterministic. STL implementations vary causing offsets not to be consistent. Place member variables we care about the offsets of at the start of Runtime. Change-Id: I3ad7fe606cb99bcdd884a8fdbdd06bd7e047cd84 --- runtime/arch/arm64/asm_support_arm64.h | 6 +++--- runtime/arch/x86_64/asm_support_x86_64.h | 6 +++--- runtime/runtime.cc | 10 +++++----- runtime/runtime.h | 16 ++++++---------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/runtime/arch/arm64/asm_support_arm64.h b/runtime/arch/arm64/asm_support_arm64.h index 44c3e6047..263a764ef 100644 --- a/runtime/arch/arm64/asm_support_arm64.h +++ b/runtime/arch/arm64/asm_support_arm64.h @@ -22,11 +22,11 @@ // TODO Thread offsets need to be checked when on Aarch64. // Offset of field Runtime::callee_save_methods_[kSaveAll] -#define RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET 320 +#define RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET 0 // Offset of field Runtime::callee_save_methods_[kRefsOnly] -#define RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET 328 +#define RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET 8 // Offset of field Runtime::callee_save_methods_[kRefsAndArgs] -#define RUNTIME_REF_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET 336 +#define RUNTIME_REF_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET 16 // Register holding Thread::Current(). #define xSELF x18 diff --git a/runtime/arch/x86_64/asm_support_x86_64.h b/runtime/arch/x86_64/asm_support_x86_64.h index 5a4e63e9a..03d9e249e 100644 --- a/runtime/arch/x86_64/asm_support_x86_64.h +++ b/runtime/arch/x86_64/asm_support_x86_64.h @@ -20,11 +20,11 @@ #include "asm_support.h" // Offset of field Runtime::callee_save_methods_[kSaveAll] -#define RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET 200 +#define RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET 0 // Offset of field Runtime::callee_save_methods_[kRefsOnly] -#define RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET 208 +#define RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET 8 // Offset of field Runtime::callee_save_methods_[kRefsAndArgs] -#define RUNTIME_REF_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET 216 +#define RUNTIME_REF_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET 16 // Offset of field Thread::self_ verified in InitCpu #define THREAD_SELF_OFFSET 72 diff --git a/runtime/runtime.cc b/runtime/runtime.cc index eaa27defc..21d79c393 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -80,7 +80,11 @@ namespace art { Runtime* Runtime::instance_ = NULL; Runtime::Runtime() - : compiler_callbacks_(nullptr), + : pre_allocated_OutOfMemoryError_(nullptr), + resolution_method_(nullptr), + imt_conflict_method_(nullptr), + default_imt_(nullptr), + compiler_callbacks_(nullptr), is_zygote_(false), is_concurrent_gc_enabled_(true), is_explicit_gc_disabled_(false), @@ -94,10 +98,6 @@ Runtime::Runtime() class_linker_(nullptr), signal_catcher_(nullptr), java_vm_(nullptr), - pre_allocated_OutOfMemoryError_(nullptr), - resolution_method_(nullptr), - imt_conflict_method_(nullptr), - default_imt_(nullptr), fault_message_lock_("Fault message lock"), fault_message_(""), method_verifier_lock_("Method verifiers lock"), diff --git a/runtime/runtime.h b/runtime/runtime.h index eeaaa2be2..50c88d3e0 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -442,6 +442,12 @@ class Runtime { // A pointer to the active runtime or NULL. static Runtime* instance_; + mirror::ArtMethod* callee_save_methods_[kLastCalleeSaveType]; + mirror::Throwable* pre_allocated_OutOfMemoryError_; + mirror::ArtMethod* resolution_method_; + mirror::ArtMethod* imt_conflict_method_; + mirror::ObjectArray* default_imt_; + CompilerCallbacks* compiler_callbacks_; bool is_zygote_; bool is_concurrent_gc_enabled_; @@ -475,16 +481,6 @@ class Runtime { JavaVMExt* java_vm_; - mirror::Throwable* pre_allocated_OutOfMemoryError_; - - mirror::ArtMethod* callee_save_methods_[kLastCalleeSaveType]; - - mirror::ArtMethod* resolution_method_; - - mirror::ArtMethod* imt_conflict_method_; - - mirror::ObjectArray* default_imt_; - // Fault message, printed when we get a SIGSEGV. Mutex fault_message_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; std::string fault_message_ GUARDED_BY(fault_message_lock_); -- 2.11.0