Remove Frame, merge shadow and quick representations.
Change-Id: I5ae03a5e52111792d2df7e83cbd89ab25777844b
diff --git a/src/oat/runtime/arm/context_arm.cc b/src/oat/runtime/arm/context_arm.cc
index 50c386f..2959ef6 100644
--- a/src/oat/runtime/arm/context_arm.cc
+++ b/src/oat/runtime/arm/context_arm.cc
@@ -33,18 +33,19 @@
#endif
}
-void ArmContext::FillCalleeSaves(const Frame& fr) {
+void ArmContext::FillCalleeSaves(const StackVisitor& fr) {
Method* method = fr.GetMethod();
uint32_t core_spills = method->GetCoreSpillMask();
uint32_t fp_core_spills = method->GetFpSpillMask();
size_t spill_count = __builtin_popcount(core_spills);
size_t fp_spill_count = __builtin_popcount(fp_core_spills);
+ size_t frame_size = method->GetFrameSizeInBytes();
if (spill_count > 0) {
// Lowest number spill is furthest away, walk registers and fill into context
int j = 1;
for (int i = 0; i < 16; i++) {
if (((core_spills >> i) & 1) != 0) {
- gprs_[i] = fr.LoadCalleeSave(spill_count - j);
+ gprs_[i] = fr.LoadCalleeSave(spill_count - j, frame_size);
j++;
}
}
@@ -54,7 +55,7 @@
int j = 1;
for (int i = 0; i < 32; i++) {
if (((fp_core_spills >> i) & 1) != 0) {
- fprs_[i] = fr.LoadCalleeSave(spill_count + fp_spill_count - j);
+ fprs_[i] = fr.LoadCalleeSave(spill_count + fp_spill_count - j, frame_size);
j++;
}
}
diff --git a/src/oat/runtime/arm/context_arm.h b/src/oat/runtime/arm/context_arm.h
index 73cb50f..6f42cc3 100644
--- a/src/oat/runtime/arm/context_arm.h
+++ b/src/oat/runtime/arm/context_arm.h
@@ -28,7 +28,7 @@
ArmContext();
virtual ~ArmContext() {}
- virtual void FillCalleeSaves(const Frame& fr);
+ virtual void FillCalleeSaves(const StackVisitor& fr);
virtual void SetSP(uintptr_t new_sp) {
gprs_[SP] = new_sp;
diff --git a/src/oat/runtime/context.h b/src/oat/runtime/context.h
index 6c7359b..7002f6a 100644
--- a/src/oat/runtime/context.h
+++ b/src/oat/runtime/context.h
@@ -22,7 +22,7 @@
namespace art {
-class Frame;
+class StackVisitor;
// Representation of a thread's context on the executing machine
class Context {
@@ -34,7 +34,7 @@
// Read values from callee saves in the given frame. The frame also holds
// the method that holds the layout.
- virtual void FillCalleeSaves(const Frame& fr) = 0;
+ virtual void FillCalleeSaves(const StackVisitor& fr) = 0;
// Set the stack pointer value
virtual void SetSP(uintptr_t new_sp) = 0;
diff --git a/src/oat/runtime/support_jni.cc b/src/oat/runtime/support_jni.cc
index ff19a4c..cfa1a11 100644
--- a/src/oat/runtime/support_jni.cc
+++ b/src/oat/runtime/support_jni.cc
@@ -90,7 +90,7 @@
// | unused |
// | unused |
// | unused | <- sp
- Method* jni_method = self->GetTopOfStack().GetMethod();
+ Method* jni_method = self->GetCurrentMethod();
DCHECK(jni_method->IsNative()) << PrettyMethod(jni_method);
intptr_t* arg_ptr = sp + 4; // pointer to r1 on stack
// Fix up this/jclass argument
diff --git a/src/oat/runtime/support_stubs.cc b/src/oat/runtime/support_stubs.cc
index 2a46c8b..522ccf2 100644
--- a/src/oat/runtime/support_stubs.cc
+++ b/src/oat/runtime/support_stubs.cc
@@ -221,9 +221,8 @@
#else // ART_USE_LLVM_COMPILER
const void* UnresolvedDirectMethodTrampolineFromCode(Method* called, Method** called_addr,
Thread* thread, Runtime::TrampolineType type) {
- NthCallerVisitor visitor(0);
- thread->WalkStack(&visitor);
- Method* caller = visitor.caller;
+ uint32_t dex_pc;
+ Method* caller = thread->GetCurrentMethod(&dex_pc);
ClassLinker* linker = Runtime::Current()->GetClassLinker();
bool is_static;
@@ -231,8 +230,6 @@
uint32_t dex_method_idx;
if (type == Runtime::kUnknownMethod) {
DCHECK(called->IsRuntimeMethod());
- // less two as return address may span into next dex instruction
- uint32_t dex_pc = static_cast<uint32_t>(visitor.pc);
const DexFile::CodeItem* code = MethodHelper(caller).GetCodeItem();
CHECK_LT(dex_pc, code->insns_size_in_code_units_);
const Instruction* instr = Instruction::At(&code->insns_[dex_pc]);
diff --git a/src/oat/runtime/support_throw.cc b/src/oat/runtime/support_throw.cc
index 4293228..31cf7d9 100644
--- a/src/oat/runtime/support_throw.cc
+++ b/src/oat/runtime/support_throw.cc
@@ -49,11 +49,8 @@
// Called by generated call to throw a NPE exception.
extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, Method** sp) {
FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll);
- Frame frame = self->GetTopOfStack();
- uintptr_t throw_native_pc = frame.GetReturnPC();
- frame.Next();
- Method* throw_method = frame.GetMethod();
- uint32_t dex_pc = throw_method->ToDexPC(throw_native_pc - 2);
+ uint32_t dex_pc;
+ Method* throw_method = self->GetCurrentMethod(&dex_pc);
ThrowNullPointerExceptionFromDexPC(self, throw_method, dex_pc);
self->DeliverException();
}
@@ -88,9 +85,7 @@
extern "C" void artThrowNoSuchMethodFromCode(int32_t method_idx, Thread* self, Method** sp) {
FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll);
- Frame frame = self->GetTopOfStack(); // We need the calling method as context for the method_idx
- frame.Next();
- Method* method = frame.GetMethod();
+ Method* method = self->GetCurrentMethod();
self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
MethodNameFromIndex(method, method_idx, verifier::VERIFY_ERROR_REF_METHOD, false).c_str());
self->DeliverException();
@@ -98,9 +93,7 @@
extern "C" void artThrowVerificationErrorFromCode(int32_t kind, int32_t ref, Thread* self, Method** sp) {
FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll);
- Frame frame = self->GetTopOfStack(); // We need the calling method as context to interpret 'ref'
- frame.Next();
- Method* method = frame.GetMethod();
+ Method* method = self->GetCurrentMethod();
ThrowVerificationError(self, method, kind, ref);
self->DeliverException();
}
diff --git a/src/oat/runtime/x86/context_x86.cc b/src/oat/runtime/x86/context_x86.cc
index 412b655..4d84f2b 100644
--- a/src/oat/runtime/x86/context_x86.cc
+++ b/src/oat/runtime/x86/context_x86.cc
@@ -31,17 +31,18 @@
#endif
}
-void X86Context::FillCalleeSaves(const Frame& fr) {
+void X86Context::FillCalleeSaves(const StackVisitor& fr) {
Method* method = fr.GetMethod();
uint32_t core_spills = method->GetCoreSpillMask();
size_t spill_count = __builtin_popcount(core_spills);
- CHECK_EQ(method->GetFpSpillMask(), 0u);
+ DCHECK_EQ(method->GetFpSpillMask(), 0u);
+ size_t frame_size = method->GetFrameSizeInBytes();
if (spill_count > 0) {
// Lowest number spill is furthest away, walk registers and fill into context.
int j = 2; // Offset j to skip return address spill.
for (int i = 0; i < 8; i++) {
if (((core_spills >> i) & 1) != 0) {
- gprs_[i] = fr.LoadCalleeSave(spill_count - j);
+ gprs_[i] = fr.LoadCalleeSave(spill_count - j, frame_size);
j++;
}
}
diff --git a/src/oat/runtime/x86/context_x86.h b/src/oat/runtime/x86/context_x86.h
index 845f6c3..3d6b1d9 100644
--- a/src/oat/runtime/x86/context_x86.h
+++ b/src/oat/runtime/x86/context_x86.h
@@ -29,7 +29,7 @@
virtual ~X86Context() {}
// No callee saves on X86
- virtual void FillCalleeSaves(const Frame& fr);
+ virtual void FillCalleeSaves(const StackVisitor& fr);
virtual void SetSP(uintptr_t new_sp) {
gprs_[ESP] = new_sp;