Save R9 when up-call.
Thanks to Ian who found this bug. This change can also fix a jni_internal_test
on device when we use -O2 instead of -O0.
Change-Id: I38ac829409aeacb120f5b3d239aedcd39ec32e63
diff --git a/src/compiler_llvm/stub_compiler.cc b/src/compiler_llvm/stub_compiler.cc
index 84447b2..991dbe6 100644
--- a/src/compiler_llvm/stub_compiler.cc
+++ b/src/compiler_llvm/stub_compiler.cc
@@ -91,7 +91,7 @@
llvm::Value* retval_addr = arg_iter++;
// Setup thread pointer
- irb_.Runtime().EmitSetCurrentThread(thread_object_addr);
+ llvm::Value* old_thread_register = irb_.Runtime().EmitSetCurrentThread(thread_object_addr);
// Accurate function type
llvm::Type* accurate_ret_type = irb_.getJType(shorty[0], kAccurate);
@@ -163,6 +163,8 @@
llvm::BasicBlock* block_cont = llvm::BasicBlock::Create(*context_, "cont", func);
irb_.CreateCondBr(exception_pending, block_unwind, block_cont);
irb_.SetInsertPoint(block_unwind);
+ // Restore thread register
+ irb_.Runtime().EmitSetCurrentThread(old_thread_register);
irb_.CreateRetVoid();
irb_.SetInsertPoint(block_cont);
#endif
@@ -177,6 +179,8 @@
irb_.CreateStore(retval, ret_addr, kTBAAStackTemp);
}
+ // Restore thread register
+ irb_.Runtime().EmitSetCurrentThread(old_thread_register);
irb_.CreateRetVoid();
// Verify the generated function