Spill possibly reference holding registers for runtime calls.
Live references may be in registers when we crawl a stack for GC during
a runtime call. Whilst an exception won't occur we need to save the
callee save registers into the frame so the stack crawl can find their
values. Create variants of the callee save method to save just the
registers that are necessary.
Change-Id: I6fa479bffcbc333fe846f9bd3ef2e626e0209ed9
diff --git a/src/space.cc b/src/space.cc
index d498b8b..248f7e8 100644
--- a/src/space.cc
+++ b/src/space.cc
@@ -97,7 +97,7 @@
bool Space::InitFromImage(const std::string& image_file_name) {
- const Runtime* runtime = Runtime::Current();
+ Runtime* runtime = Runtime::Current();
if (runtime->IsVerboseStartup()) {
LOG(INFO) << "Space::InitFromImage entering"
<< " image_file_name=" << image_file_name;
@@ -129,23 +129,27 @@
DCHECK_EQ(0, memcmp(&image_header, image_header_, sizeof(ImageHeader)));
Object* jni_stub_array = image_header.GetImageRoot(ImageHeader::kJniStubArray);
- Runtime::Current()->SetJniStubArray(down_cast<ByteArray*>(jni_stub_array));
+ runtime->SetJniStubArray(down_cast<ByteArray*>(jni_stub_array));
Object* ame_stub_array = image_header.GetImageRoot(ImageHeader::kAbstractMethodErrorStubArray);
- Runtime::Current()->SetAbstractMethodErrorStubArray(down_cast<ByteArray*>(ame_stub_array));
+ runtime->SetAbstractMethodErrorStubArray(down_cast<ByteArray*>(ame_stub_array));
Object* resolution_stub_array = image_header.GetImageRoot(ImageHeader::kInstanceResolutionStubArray);
- Runtime::Current()->SetResolutionStubArray(
+ runtime->SetResolutionStubArray(
down_cast<ByteArray*>(resolution_stub_array), Runtime::kInstanceMethod);
resolution_stub_array = image_header.GetImageRoot(ImageHeader::kStaticResolutionStubArray);
- Runtime::Current()->SetResolutionStubArray(
+ runtime->SetResolutionStubArray(
down_cast<ByteArray*>(resolution_stub_array), Runtime::kStaticMethod);
resolution_stub_array = image_header.GetImageRoot(ImageHeader::kUnknownMethodResolutionStubArray);
- Runtime::Current()->SetResolutionStubArray(
+ runtime->SetResolutionStubArray(
down_cast<ByteArray*>(resolution_stub_array), Runtime::kUnknownMethod);
Object* callee_save_method = image_header.GetImageRoot(ImageHeader::kCalleeSaveMethod);
- Runtime::Current()->SetCalleeSaveMethod(down_cast<Method*>(callee_save_method));
+ runtime->SetCalleeSaveMethod(down_cast<Method*>(callee_save_method), Runtime::kSaveAll);
+ callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsOnlySaveMethod);
+ runtime->SetCalleeSaveMethod(down_cast<Method*>(callee_save_method), Runtime::kRefsOnly);
+ callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod);
+ runtime->SetCalleeSaveMethod(down_cast<Method*>(callee_save_method), Runtime::kRefsAndArgs);
Init(map.release());
if (runtime->IsVerboseStartup()) {