Ensure we don't AddLocalReference a bogus value when returning to native code from an upcall that threw.
Also add a few missing CHECKs.
Change-Id: Icf29506b258a2177b5e80c75cd2710761431ba4b
diff --git a/src/oat/runtime/x86/context_x86.cc b/src/oat/runtime/x86/context_x86.cc
index 2af95bb..d6f45da 100644
--- a/src/oat/runtime/x86/context_x86.cc
+++ b/src/oat/runtime/x86/context_x86.cc
@@ -25,7 +25,7 @@
#ifndef NDEBUG
// Initialize registers with easy to spot debug values.
for (int i = 0; i < 8; i++) {
- gprs_[i] = 0xEBAD6070+i;
+ gprs_[i] = kBadGprBase + i;
}
eip_ = 0xEBAD601F;
#endif
@@ -48,6 +48,13 @@
}
}
+void X86Context::SmashCallerSaves() {
+ gprs_[EAX] = 0; // This needs to be 0 because we want a null/zero return value.
+ gprs_[ECX] = kBadGprBase + ECX;
+ gprs_[EDX] = kBadGprBase + EDX;
+ gprs_[EBX] = kBadGprBase + EBX;
+}
+
void X86Context::DoLongJump() {
#if defined(__i386__)
// We push all the registers using memory-memory pushes, we then pop-all to get the registers
diff --git a/src/oat/runtime/x86/context_x86.h b/src/oat/runtime/x86/context_x86.h
index 72dc719..845f6c3 100644
--- a/src/oat/runtime/x86/context_x86.h
+++ b/src/oat/runtime/x86/context_x86.h
@@ -45,6 +45,7 @@
return gprs_[reg];
}
+ virtual void SmashCallerSaves();
virtual void DoLongJump();
private: