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/art_module.ll b/src/compiler_llvm/art_module.ll
index f831736..457efa2 100644
--- a/src/compiler_llvm/art_module.ll
+++ b/src/compiler_llvm/art_module.ll
@@ -36,7 +36,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
declare %JavaObject* @art_get_current_thread_from_code()
-declare void @art_set_current_thread_from_code(%JavaObject*)
+declare %JavaObject* @art_set_current_thread_from_code(%JavaObject*)
declare void @art_lock_object_from_code(%JavaObject*, %JavaObject*)
declare void @art_unlock_object_from_code(%JavaObject*, %JavaObject*)
diff --git a/src/compiler_llvm/generated/art_module.cc b/src/compiler_llvm/generated/art_module.cc
index 2a8100b..491d1ec 100644
--- a/src/compiler_llvm/generated/art_module.cc
+++ b/src/compiler_llvm/generated/art_module.cc
@@ -70,7 +70,7 @@
std::vector<Type*>FuncTy_4_args;
FuncTy_4_args.push_back(PointerTy_1);
FunctionType* FuncTy_4 = FunctionType::get(
- /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Result=*/PointerTy_1,
/*Params=*/FuncTy_4_args,
/*isVarArg=*/false);
@@ -84,36 +84,35 @@
std::vector<Type*>FuncTy_6_args;
FuncTy_6_args.push_back(PointerTy_1);
-FuncTy_6_args.push_back(PointerTy_2);
-FuncTy_6_args.push_back(PointerTy_1);
-FuncTy_6_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_6 = FunctionType::get(
- /*Result=*/PointerTy_2,
+ /*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_6_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_7_args;
+FuncTy_7_args.push_back(PointerTy_1);
FuncTy_7_args.push_back(PointerTy_2);
+FuncTy_7_args.push_back(PointerTy_1);
+FuncTy_7_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_7 = FunctionType::get(
- /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Result=*/PointerTy_2,
/*Params=*/FuncTy_7_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_8_args;
+FuncTy_8_args.push_back(PointerTy_2);
FunctionType* FuncTy_8 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 1),
+ /*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_8_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_9_args;
FunctionType* FuncTy_9 = FunctionType::get(
- /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Result=*/IntegerType::get(mod->getContext(), 1),
/*Params=*/FuncTy_9_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_10_args;
-FuncTy_10_args.push_back(IntegerType::get(mod->getContext(), 32));
-FuncTy_10_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_10 = FunctionType::get(
/*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_10_args,
@@ -121,14 +120,13 @@
std::vector<Type*>FuncTy_11_args;
FuncTy_11_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_11_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_11 = FunctionType::get(
/*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_11_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_12_args;
-FuncTy_12_args.push_back(PointerTy_1);
-FuncTy_12_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_12_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_12 = FunctionType::get(
/*Result=*/Type::getVoidTy(mod->getContext()),
@@ -138,24 +136,23 @@
std::vector<Type*>FuncTy_13_args;
FuncTy_13_args.push_back(PointerTy_1);
FuncTy_13_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_13_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_13 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_13_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_14_args;
+FuncTy_14_args.push_back(PointerTy_1);
FuncTy_14_args.push_back(IntegerType::get(mod->getContext(), 32));
-FuncTy_14_args.push_back(PointerTy_1);
-FuncTy_14_args.push_back(PointerTy_1);
FunctionType* FuncTy_14 = FunctionType::get(
- /*Result=*/PointerTy_1,
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_14_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_15_args;
FuncTy_15_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_15_args.push_back(PointerTy_1);
-FuncTy_15_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_15_args.push_back(PointerTy_1);
FunctionType* FuncTy_15 = FunctionType::get(
/*Result=*/PointerTy_1,
@@ -165,42 +162,43 @@
std::vector<Type*>FuncTy_16_args;
FuncTy_16_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_16_args.push_back(PointerTy_1);
+FuncTy_16_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_16_args.push_back(PointerTy_1);
FunctionType* FuncTy_16 = FunctionType::get(
- /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Result=*/PointerTy_1,
/*Params=*/FuncTy_16_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_17_args;
FuncTy_17_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_17_args.push_back(PointerTy_1);
-FuncTy_17_args.push_back(PointerTy_1);
-FuncTy_17_args.push_back(PointerTy_1);
FunctionType* FuncTy_17 = FunctionType::get(
- /*Result=*/PointerTy_1,
+ /*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_17_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_18_args;
-FuncTy_18_args.push_back(PointerTy_1);
FuncTy_18_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_18_args.push_back(PointerTy_1);
+FuncTy_18_args.push_back(PointerTy_1);
+FuncTy_18_args.push_back(PointerTy_1);
FunctionType* FuncTy_18 = FunctionType::get(
/*Result=*/PointerTy_1,
/*Params=*/FuncTy_18_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_19_args;
-FuncTy_19_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_19_args.push_back(PointerTy_1);
FuncTy_19_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_19 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Result=*/PointerTy_1,
/*Params=*/FuncTy_19_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_20_args;
FuncTy_20_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_20_args.push_back(PointerTy_1);
-FuncTy_20_args.push_back(IntegerType::get(mod->getContext(), 64));
+FuncTy_20_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_20 = FunctionType::get(
/*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_20_args,
@@ -209,7 +207,7 @@
std::vector<Type*>FuncTy_21_args;
FuncTy_21_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_21_args.push_back(PointerTy_1);
-FuncTy_21_args.push_back(PointerTy_1);
+FuncTy_21_args.push_back(IntegerType::get(mod->getContext(), 64));
FunctionType* FuncTy_21 = FunctionType::get(
/*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_21_args,
@@ -218,6 +216,7 @@
std::vector<Type*>FuncTy_22_args;
FuncTy_22_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_22_args.push_back(PointerTy_1);
+FuncTy_22_args.push_back(PointerTy_1);
FunctionType* FuncTy_22 = FunctionType::get(
/*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_22_args,
@@ -227,7 +226,7 @@
FuncTy_23_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_23_args.push_back(PointerTy_1);
FunctionType* FuncTy_23 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_23_args,
/*isVarArg=*/false);
@@ -235,17 +234,15 @@
FuncTy_24_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_24_args.push_back(PointerTy_1);
FunctionType* FuncTy_24 = FunctionType::get(
- /*Result=*/PointerTy_1,
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
/*Params=*/FuncTy_24_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_25_args;
FuncTy_25_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_25_args.push_back(PointerTy_1);
-FuncTy_25_args.push_back(PointerTy_1);
-FuncTy_25_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_25 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Result=*/PointerTy_1,
/*Params=*/FuncTy_25_args,
/*isVarArg=*/false);
@@ -253,7 +250,7 @@
FuncTy_26_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_26_args.push_back(PointerTy_1);
FuncTy_26_args.push_back(PointerTy_1);
-FuncTy_26_args.push_back(IntegerType::get(mod->getContext(), 64));
+FuncTy_26_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_26 = FunctionType::get(
/*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_26_args,
@@ -263,7 +260,7 @@
FuncTy_27_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_27_args.push_back(PointerTy_1);
FuncTy_27_args.push_back(PointerTy_1);
-FuncTy_27_args.push_back(PointerTy_1);
+FuncTy_27_args.push_back(IntegerType::get(mod->getContext(), 64));
FunctionType* FuncTy_27 = FunctionType::get(
/*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_27_args,
@@ -273,69 +270,72 @@
FuncTy_28_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_28_args.push_back(PointerTy_1);
FuncTy_28_args.push_back(PointerTy_1);
+FuncTy_28_args.push_back(PointerTy_1);
FunctionType* FuncTy_28 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_28_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_29_args;
+FuncTy_29_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_29_args.push_back(PointerTy_1);
FuncTy_29_args.push_back(PointerTy_1);
FunctionType* FuncTy_29 = FunctionType::get(
- /*Result=*/PointerTy_1,
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
/*Params=*/FuncTy_29_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_30_args;
FuncTy_30_args.push_back(PointerTy_1);
-FuncTy_30_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_30_args.push_back(PointerTy_1);
-FuncTy_30_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_30 = FunctionType::get(
- /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Result=*/PointerTy_1,
/*Params=*/FuncTy_30_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_31_args;
FuncTy_31_args.push_back(PointerTy_1);
+FuncTy_31_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_31_args.push_back(PointerTy_1);
+FuncTy_31_args.push_back(IntegerType::get(mod->getContext(), 32));
FunctionType* FuncTy_31 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Result=*/Type::getVoidTy(mod->getContext()),
/*Params=*/FuncTy_31_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_32_args;
-FuncTy_32_args.push_back(Type::getDoubleTy(mod->getContext()));
+FuncTy_32_args.push_back(PointerTy_1);
+FuncTy_32_args.push_back(PointerTy_1);
FunctionType* FuncTy_32 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_32_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_33_args;
FuncTy_33_args.push_back(Type::getDoubleTy(mod->getContext()));
FunctionType* FuncTy_33 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
/*Params=*/FuncTy_33_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_34_args;
-FuncTy_34_args.push_back(Type::getFloatTy(mod->getContext()));
+FuncTy_34_args.push_back(Type::getDoubleTy(mod->getContext()));
FunctionType* FuncTy_34 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_34_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_35_args;
FuncTy_35_args.push_back(Type::getFloatTy(mod->getContext()));
FunctionType* FuncTy_35 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
/*Params=*/FuncTy_35_args,
/*isVarArg=*/false);
std::vector<Type*>FuncTy_36_args;
-FuncTy_36_args.push_back(PointerTy_1);
+FuncTy_36_args.push_back(Type::getFloatTy(mod->getContext()));
FunctionType* FuncTy_36 = FunctionType::get(
- /*Result=*/PointerTy_1,
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
/*Params=*/FuncTy_36_args,
/*isVarArg=*/false);
@@ -407,7 +407,7 @@
Function* func_art_test_suspend_from_code = mod->getFunction("art_test_suspend_from_code");
if (!func_art_test_suspend_from_code) {
func_art_test_suspend_from_code = Function::Create(
- /*Type=*/FuncTy_4,
+ /*Type=*/FuncTy_6,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_test_suspend_from_code", mod); // (external, no body)
func_art_test_suspend_from_code->setCallingConv(CallingConv::C);
@@ -418,7 +418,7 @@
Function* func_art_push_shadow_frame_from_code = mod->getFunction("art_push_shadow_frame_from_code");
if (!func_art_push_shadow_frame_from_code) {
func_art_push_shadow_frame_from_code = Function::Create(
- /*Type=*/FuncTy_6,
+ /*Type=*/FuncTy_7,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_push_shadow_frame_from_code", mod); // (external, no body)
func_art_push_shadow_frame_from_code->setCallingConv(CallingConv::C);
@@ -429,7 +429,7 @@
Function* func_art_pop_shadow_frame_from_code = mod->getFunction("art_pop_shadow_frame_from_code");
if (!func_art_pop_shadow_frame_from_code) {
func_art_pop_shadow_frame_from_code = Function::Create(
- /*Type=*/FuncTy_7,
+ /*Type=*/FuncTy_8,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_pop_shadow_frame_from_code", mod); // (external, no body)
func_art_pop_shadow_frame_from_code->setCallingConv(CallingConv::C);
@@ -440,7 +440,7 @@
Function* func_art_is_exception_pending_from_code = mod->getFunction("art_is_exception_pending_from_code");
if (!func_art_is_exception_pending_from_code) {
func_art_is_exception_pending_from_code = Function::Create(
- /*Type=*/FuncTy_8,
+ /*Type=*/FuncTy_9,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_is_exception_pending_from_code", mod); // (external, no body)
func_art_is_exception_pending_from_code->setCallingConv(CallingConv::C);
@@ -451,7 +451,7 @@
Function* func_art_throw_div_zero_from_code = mod->getFunction("art_throw_div_zero_from_code");
if (!func_art_throw_div_zero_from_code) {
func_art_throw_div_zero_from_code = Function::Create(
- /*Type=*/FuncTy_9,
+ /*Type=*/FuncTy_10,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_div_zero_from_code", mod); // (external, no body)
func_art_throw_div_zero_from_code->setCallingConv(CallingConv::C);
@@ -462,7 +462,7 @@
Function* func_art_throw_array_bounds_from_code = mod->getFunction("art_throw_array_bounds_from_code");
if (!func_art_throw_array_bounds_from_code) {
func_art_throw_array_bounds_from_code = Function::Create(
- /*Type=*/FuncTy_10,
+ /*Type=*/FuncTy_11,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_array_bounds_from_code", mod); // (external, no body)
func_art_throw_array_bounds_from_code->setCallingConv(CallingConv::C);
@@ -473,7 +473,7 @@
Function* func_art_throw_no_such_method_from_code = mod->getFunction("art_throw_no_such_method_from_code");
if (!func_art_throw_no_such_method_from_code) {
func_art_throw_no_such_method_from_code = Function::Create(
- /*Type=*/FuncTy_11,
+ /*Type=*/FuncTy_12,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_no_such_method_from_code", mod); // (external, no body)
func_art_throw_no_such_method_from_code->setCallingConv(CallingConv::C);
@@ -484,7 +484,7 @@
Function* func_art_throw_null_pointer_exception_from_code = mod->getFunction("art_throw_null_pointer_exception_from_code");
if (!func_art_throw_null_pointer_exception_from_code) {
func_art_throw_null_pointer_exception_from_code = Function::Create(
- /*Type=*/FuncTy_11,
+ /*Type=*/FuncTy_12,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_null_pointer_exception_from_code", mod); // (external, no body)
func_art_throw_null_pointer_exception_from_code->setCallingConv(CallingConv::C);
@@ -495,7 +495,7 @@
Function* func_art_throw_stack_overflow_from_code = mod->getFunction("art_throw_stack_overflow_from_code");
if (!func_art_throw_stack_overflow_from_code) {
func_art_throw_stack_overflow_from_code = Function::Create(
- /*Type=*/FuncTy_9,
+ /*Type=*/FuncTy_10,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_stack_overflow_from_code", mod); // (external, no body)
func_art_throw_stack_overflow_from_code->setCallingConv(CallingConv::C);
@@ -506,7 +506,7 @@
Function* func_art_throw_exception_from_code = mod->getFunction("art_throw_exception_from_code");
if (!func_art_throw_exception_from_code) {
func_art_throw_exception_from_code = Function::Create(
- /*Type=*/FuncTy_4,
+ /*Type=*/FuncTy_6,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_exception_from_code", mod); // (external, no body)
func_art_throw_exception_from_code->setCallingConv(CallingConv::C);
@@ -517,7 +517,7 @@
Function* func_art_throw_verification_error_from_code = mod->getFunction("art_throw_verification_error_from_code");
if (!func_art_throw_verification_error_from_code) {
func_art_throw_verification_error_from_code = Function::Create(
- /*Type=*/FuncTy_12,
+ /*Type=*/FuncTy_13,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_throw_verification_error_from_code", mod); // (external, no body)
func_art_throw_verification_error_from_code->setCallingConv(CallingConv::C);
@@ -528,7 +528,7 @@
Function* func_art_find_catch_block_from_code = mod->getFunction("art_find_catch_block_from_code");
if (!func_art_find_catch_block_from_code) {
func_art_find_catch_block_from_code = Function::Create(
- /*Type=*/FuncTy_13,
+ /*Type=*/FuncTy_14,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_catch_block_from_code", mod); // (external, no body)
func_art_find_catch_block_from_code->setCallingConv(CallingConv::C);
@@ -539,7 +539,7 @@
Function* func_art_alloc_object_from_code = mod->getFunction("art_alloc_object_from_code");
if (!func_art_alloc_object_from_code) {
func_art_alloc_object_from_code = Function::Create(
- /*Type=*/FuncTy_14,
+ /*Type=*/FuncTy_15,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_alloc_object_from_code", mod); // (external, no body)
func_art_alloc_object_from_code->setCallingConv(CallingConv::C);
@@ -550,7 +550,7 @@
Function* func_art_alloc_object_from_code_with_access_check = mod->getFunction("art_alloc_object_from_code_with_access_check");
if (!func_art_alloc_object_from_code_with_access_check) {
func_art_alloc_object_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_14,
+ /*Type=*/FuncTy_15,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_alloc_object_from_code_with_access_check", mod); // (external, no body)
func_art_alloc_object_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -561,7 +561,7 @@
Function* func_art_alloc_array_from_code = mod->getFunction("art_alloc_array_from_code");
if (!func_art_alloc_array_from_code) {
func_art_alloc_array_from_code = Function::Create(
- /*Type=*/FuncTy_15,
+ /*Type=*/FuncTy_16,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_alloc_array_from_code", mod); // (external, no body)
func_art_alloc_array_from_code->setCallingConv(CallingConv::C);
@@ -572,7 +572,7 @@
Function* func_art_alloc_array_from_code_with_access_check = mod->getFunction("art_alloc_array_from_code_with_access_check");
if (!func_art_alloc_array_from_code_with_access_check) {
func_art_alloc_array_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_15,
+ /*Type=*/FuncTy_16,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_alloc_array_from_code_with_access_check", mod); // (external, no body)
func_art_alloc_array_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -583,7 +583,7 @@
Function* func_art_check_and_alloc_array_from_code = mod->getFunction("art_check_and_alloc_array_from_code");
if (!func_art_check_and_alloc_array_from_code) {
func_art_check_and_alloc_array_from_code = Function::Create(
- /*Type=*/FuncTy_15,
+ /*Type=*/FuncTy_16,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_check_and_alloc_array_from_code", mod); // (external, no body)
func_art_check_and_alloc_array_from_code->setCallingConv(CallingConv::C);
@@ -594,7 +594,7 @@
Function* func_art_check_and_alloc_array_from_code_with_access_check = mod->getFunction("art_check_and_alloc_array_from_code_with_access_check");
if (!func_art_check_and_alloc_array_from_code_with_access_check) {
func_art_check_and_alloc_array_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_15,
+ /*Type=*/FuncTy_16,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_check_and_alloc_array_from_code_with_access_check", mod); // (external, no body)
func_art_check_and_alloc_array_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -605,7 +605,7 @@
Function* func_art_find_instance_field_from_code = mod->getFunction("art_find_instance_field_from_code");
if (!func_art_find_instance_field_from_code) {
func_art_find_instance_field_from_code = Function::Create(
- /*Type=*/FuncTy_16,
+ /*Type=*/FuncTy_17,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_instance_field_from_code", mod); // (external, no body)
func_art_find_instance_field_from_code->setCallingConv(CallingConv::C);
@@ -616,7 +616,7 @@
Function* func_art_find_static_field_from_code = mod->getFunction("art_find_static_field_from_code");
if (!func_art_find_static_field_from_code) {
func_art_find_static_field_from_code = Function::Create(
- /*Type=*/FuncTy_16,
+ /*Type=*/FuncTy_17,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_static_field_from_code", mod); // (external, no body)
func_art_find_static_field_from_code->setCallingConv(CallingConv::C);
@@ -627,7 +627,7 @@
Function* func_art_find_static_method_from_code_with_access_check = mod->getFunction("art_find_static_method_from_code_with_access_check");
if (!func_art_find_static_method_from_code_with_access_check) {
func_art_find_static_method_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_17,
+ /*Type=*/FuncTy_18,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_static_method_from_code_with_access_check", mod); // (external, no body)
func_art_find_static_method_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -638,7 +638,7 @@
Function* func_art_find_direct_method_from_code_with_access_check = mod->getFunction("art_find_direct_method_from_code_with_access_check");
if (!func_art_find_direct_method_from_code_with_access_check) {
func_art_find_direct_method_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_17,
+ /*Type=*/FuncTy_18,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_direct_method_from_code_with_access_check", mod); // (external, no body)
func_art_find_direct_method_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -649,7 +649,7 @@
Function* func_art_find_virtual_method_from_code_with_access_check = mod->getFunction("art_find_virtual_method_from_code_with_access_check");
if (!func_art_find_virtual_method_from_code_with_access_check) {
func_art_find_virtual_method_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_17,
+ /*Type=*/FuncTy_18,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_virtual_method_from_code_with_access_check", mod); // (external, no body)
func_art_find_virtual_method_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -660,7 +660,7 @@
Function* func_art_find_super_method_from_code_with_access_check = mod->getFunction("art_find_super_method_from_code_with_access_check");
if (!func_art_find_super_method_from_code_with_access_check) {
func_art_find_super_method_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_17,
+ /*Type=*/FuncTy_18,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_super_method_from_code_with_access_check", mod); // (external, no body)
func_art_find_super_method_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -671,7 +671,7 @@
Function* func_art_find_interface_method_from_code_with_access_check = mod->getFunction("art_find_interface_method_from_code_with_access_check");
if (!func_art_find_interface_method_from_code_with_access_check) {
func_art_find_interface_method_from_code_with_access_check = Function::Create(
- /*Type=*/FuncTy_17,
+ /*Type=*/FuncTy_18,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_interface_method_from_code_with_access_check", mod); // (external, no body)
func_art_find_interface_method_from_code_with_access_check->setCallingConv(CallingConv::C);
@@ -682,7 +682,7 @@
Function* func_art_find_interface_method_from_code = mod->getFunction("art_find_interface_method_from_code");
if (!func_art_find_interface_method_from_code) {
func_art_find_interface_method_from_code = Function::Create(
- /*Type=*/FuncTy_17,
+ /*Type=*/FuncTy_18,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_find_interface_method_from_code", mod); // (external, no body)
func_art_find_interface_method_from_code->setCallingConv(CallingConv::C);
@@ -693,7 +693,7 @@
Function* func_art_initialize_static_storage_from_code = mod->getFunction("art_initialize_static_storage_from_code");
if (!func_art_initialize_static_storage_from_code) {
func_art_initialize_static_storage_from_code = Function::Create(
- /*Type=*/FuncTy_14,
+ /*Type=*/FuncTy_15,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_initialize_static_storage_from_code", mod); // (external, no body)
func_art_initialize_static_storage_from_code->setCallingConv(CallingConv::C);
@@ -704,7 +704,7 @@
Function* func_art_initialize_type_from_code = mod->getFunction("art_initialize_type_from_code");
if (!func_art_initialize_type_from_code) {
func_art_initialize_type_from_code = Function::Create(
- /*Type=*/FuncTy_14,
+ /*Type=*/FuncTy_15,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_initialize_type_from_code", mod); // (external, no body)
func_art_initialize_type_from_code->setCallingConv(CallingConv::C);
@@ -715,7 +715,7 @@
Function* func_art_initialize_type_and_verify_access_from_code = mod->getFunction("art_initialize_type_and_verify_access_from_code");
if (!func_art_initialize_type_and_verify_access_from_code) {
func_art_initialize_type_and_verify_access_from_code = Function::Create(
- /*Type=*/FuncTy_14,
+ /*Type=*/FuncTy_15,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_initialize_type_and_verify_access_from_code", mod); // (external, no body)
func_art_initialize_type_and_verify_access_from_code->setCallingConv(CallingConv::C);
@@ -726,7 +726,7 @@
Function* func_art_resolve_string_from_code = mod->getFunction("art_resolve_string_from_code");
if (!func_art_resolve_string_from_code) {
func_art_resolve_string_from_code = Function::Create(
- /*Type=*/FuncTy_18,
+ /*Type=*/FuncTy_19,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_resolve_string_from_code", mod); // (external, no body)
func_art_resolve_string_from_code->setCallingConv(CallingConv::C);
@@ -737,7 +737,7 @@
Function* func_art_set32_static_from_code = mod->getFunction("art_set32_static_from_code");
if (!func_art_set32_static_from_code) {
func_art_set32_static_from_code = Function::Create(
- /*Type=*/FuncTy_19,
+ /*Type=*/FuncTy_20,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_set32_static_from_code", mod); // (external, no body)
func_art_set32_static_from_code->setCallingConv(CallingConv::C);
@@ -748,7 +748,7 @@
Function* func_art_set64_static_from_code = mod->getFunction("art_set64_static_from_code");
if (!func_art_set64_static_from_code) {
func_art_set64_static_from_code = Function::Create(
- /*Type=*/FuncTy_20,
+ /*Type=*/FuncTy_21,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_set64_static_from_code", mod); // (external, no body)
func_art_set64_static_from_code->setCallingConv(CallingConv::C);
@@ -759,7 +759,7 @@
Function* func_art_set_obj_static_from_code = mod->getFunction("art_set_obj_static_from_code");
if (!func_art_set_obj_static_from_code) {
func_art_set_obj_static_from_code = Function::Create(
- /*Type=*/FuncTy_21,
+ /*Type=*/FuncTy_22,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_set_obj_static_from_code", mod); // (external, no body)
func_art_set_obj_static_from_code->setCallingConv(CallingConv::C);
@@ -770,7 +770,7 @@
Function* func_art_get32_static_from_code = mod->getFunction("art_get32_static_from_code");
if (!func_art_get32_static_from_code) {
func_art_get32_static_from_code = Function::Create(
- /*Type=*/FuncTy_22,
+ /*Type=*/FuncTy_23,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_get32_static_from_code", mod); // (external, no body)
func_art_get32_static_from_code->setCallingConv(CallingConv::C);
@@ -781,7 +781,7 @@
Function* func_art_get64_static_from_code = mod->getFunction("art_get64_static_from_code");
if (!func_art_get64_static_from_code) {
func_art_get64_static_from_code = Function::Create(
- /*Type=*/FuncTy_23,
+ /*Type=*/FuncTy_24,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_get64_static_from_code", mod); // (external, no body)
func_art_get64_static_from_code->setCallingConv(CallingConv::C);
@@ -792,7 +792,7 @@
Function* func_art_get_obj_static_from_code = mod->getFunction("art_get_obj_static_from_code");
if (!func_art_get_obj_static_from_code) {
func_art_get_obj_static_from_code = Function::Create(
- /*Type=*/FuncTy_24,
+ /*Type=*/FuncTy_25,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_get_obj_static_from_code", mod); // (external, no body)
func_art_get_obj_static_from_code->setCallingConv(CallingConv::C);
@@ -803,7 +803,7 @@
Function* func_art_set32_instance_from_code = mod->getFunction("art_set32_instance_from_code");
if (!func_art_set32_instance_from_code) {
func_art_set32_instance_from_code = Function::Create(
- /*Type=*/FuncTy_25,
+ /*Type=*/FuncTy_26,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_set32_instance_from_code", mod); // (external, no body)
func_art_set32_instance_from_code->setCallingConv(CallingConv::C);
@@ -814,7 +814,7 @@
Function* func_art_set64_instance_from_code = mod->getFunction("art_set64_instance_from_code");
if (!func_art_set64_instance_from_code) {
func_art_set64_instance_from_code = Function::Create(
- /*Type=*/FuncTy_26,
+ /*Type=*/FuncTy_27,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_set64_instance_from_code", mod); // (external, no body)
func_art_set64_instance_from_code->setCallingConv(CallingConv::C);
@@ -825,7 +825,7 @@
Function* func_art_set_obj_instance_from_code = mod->getFunction("art_set_obj_instance_from_code");
if (!func_art_set_obj_instance_from_code) {
func_art_set_obj_instance_from_code = Function::Create(
- /*Type=*/FuncTy_27,
+ /*Type=*/FuncTy_28,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_set_obj_instance_from_code", mod); // (external, no body)
func_art_set_obj_instance_from_code->setCallingConv(CallingConv::C);
@@ -836,7 +836,7 @@
Function* func_art_get32_instance_from_code = mod->getFunction("art_get32_instance_from_code");
if (!func_art_get32_instance_from_code) {
func_art_get32_instance_from_code = Function::Create(
- /*Type=*/FuncTy_21,
+ /*Type=*/FuncTy_22,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_get32_instance_from_code", mod); // (external, no body)
func_art_get32_instance_from_code->setCallingConv(CallingConv::C);
@@ -847,7 +847,7 @@
Function* func_art_get64_instance_from_code = mod->getFunction("art_get64_instance_from_code");
if (!func_art_get64_instance_from_code) {
func_art_get64_instance_from_code = Function::Create(
- /*Type=*/FuncTy_28,
+ /*Type=*/FuncTy_29,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_get64_instance_from_code", mod); // (external, no body)
func_art_get64_instance_from_code->setCallingConv(CallingConv::C);
@@ -858,7 +858,7 @@
Function* func_art_get_obj_instance_from_code = mod->getFunction("art_get_obj_instance_from_code");
if (!func_art_get_obj_instance_from_code) {
func_art_get_obj_instance_from_code = Function::Create(
- /*Type=*/FuncTy_14,
+ /*Type=*/FuncTy_15,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_get_obj_instance_from_code", mod); // (external, no body)
func_art_get_obj_instance_from_code->setCallingConv(CallingConv::C);
@@ -869,7 +869,7 @@
Function* func_art_decode_jobject_in_thread = mod->getFunction("art_decode_jobject_in_thread");
if (!func_art_decode_jobject_in_thread) {
func_art_decode_jobject_in_thread = Function::Create(
- /*Type=*/FuncTy_29,
+ /*Type=*/FuncTy_30,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_decode_jobject_in_thread", mod); // (external, no body)
func_art_decode_jobject_in_thread->setCallingConv(CallingConv::C);
@@ -880,7 +880,7 @@
Function* func_art_fill_array_data_from_code = mod->getFunction("art_fill_array_data_from_code");
if (!func_art_fill_array_data_from_code) {
func_art_fill_array_data_from_code = Function::Create(
- /*Type=*/FuncTy_30,
+ /*Type=*/FuncTy_31,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_fill_array_data_from_code", mod); // (external, no body)
func_art_fill_array_data_from_code->setCallingConv(CallingConv::C);
@@ -891,7 +891,7 @@
Function* func_art_is_assignable_from_code = mod->getFunction("art_is_assignable_from_code");
if (!func_art_is_assignable_from_code) {
func_art_is_assignable_from_code = Function::Create(
- /*Type=*/FuncTy_31,
+ /*Type=*/FuncTy_32,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_is_assignable_from_code", mod); // (external, no body)
func_art_is_assignable_from_code->setCallingConv(CallingConv::C);
@@ -924,7 +924,7 @@
Function* func_art_d2l = mod->getFunction("art_d2l");
if (!func_art_d2l) {
func_art_d2l = Function::Create(
- /*Type=*/FuncTy_32,
+ /*Type=*/FuncTy_33,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_d2l", mod); // (external, no body)
func_art_d2l->setCallingConv(CallingConv::C);
@@ -935,7 +935,7 @@
Function* func_art_d2i = mod->getFunction("art_d2i");
if (!func_art_d2i) {
func_art_d2i = Function::Create(
- /*Type=*/FuncTy_33,
+ /*Type=*/FuncTy_34,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_d2i", mod); // (external, no body)
func_art_d2i->setCallingConv(CallingConv::C);
@@ -946,7 +946,7 @@
Function* func_art_f2l = mod->getFunction("art_f2l");
if (!func_art_f2l) {
func_art_f2l = Function::Create(
- /*Type=*/FuncTy_34,
+ /*Type=*/FuncTy_35,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_f2l", mod); // (external, no body)
func_art_f2l->setCallingConv(CallingConv::C);
@@ -957,7 +957,7 @@
Function* func_art_f2i = mod->getFunction("art_f2i");
if (!func_art_f2i) {
func_art_f2i = Function::Create(
- /*Type=*/FuncTy_35,
+ /*Type=*/FuncTy_36,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_f2i", mod); // (external, no body)
func_art_f2i->setCallingConv(CallingConv::C);
@@ -979,7 +979,7 @@
Function* func_art_fix_stub_from_code = mod->getFunction("art_fix_stub_from_code");
if (!func_art_fix_stub_from_code) {
func_art_fix_stub_from_code = Function::Create(
- /*Type=*/FuncTy_36,
+ /*Type=*/FuncTy_4,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"art_fix_stub_from_code", mod); // (external, no body)
func_art_fix_stub_from_code->setCallingConv(CallingConv::C);
diff --git a/src/compiler_llvm/runtime_support_builder.cc b/src/compiler_llvm/runtime_support_builder.cc
index 9095c02..00a8efa 100644
--- a/src/compiler_llvm/runtime_support_builder.cc
+++ b/src/compiler_llvm/runtime_support_builder.cc
@@ -94,9 +94,9 @@
irb_.StoreToObjectOffset(thread, offset, value, s_ty);
}
-void RuntimeSupportBuilder::EmitSetCurrentThread(llvm::Value* thread) {
+llvm::Value* RuntimeSupportBuilder::EmitSetCurrentThread(llvm::Value* thread) {
Function* func = GetRuntimeSupportFunction(runtime_support::SetCurrentThread);
- irb_.CreateCall(func, thread);
+ return irb_.CreateCall(func, thread);
}
diff --git a/src/compiler_llvm/runtime_support_builder.h b/src/compiler_llvm/runtime_support_builder.h
index 7b54c69..8fd0d17 100644
--- a/src/compiler_llvm/runtime_support_builder.h
+++ b/src/compiler_llvm/runtime_support_builder.h
@@ -47,7 +47,7 @@
TBAASpecialType s_ty);
virtual void EmitStoreToThreadOffset(int64_t offset, llvm::Value* value,
TBAASpecialType s_ty);
- virtual void EmitSetCurrentThread(llvm::Value* thread);
+ virtual llvm::Value* EmitSetCurrentThread(llvm::Value* thread);
/* ShadowFrame */
virtual llvm::Value* EmitPushShadowFrame(llvm::Value* new_shadow_frame,
diff --git a/src/compiler_llvm/runtime_support_builder_arm.cc b/src/compiler_llvm/runtime_support_builder_arm.cc
index 6ce9ea4..16ecff4 100644
--- a/src/compiler_llvm/runtime_support_builder_arm.cc
+++ b/src/compiler_llvm/runtime_support_builder_arm.cc
@@ -67,10 +67,26 @@
irb_.SetTBAA(call_inst, s_ty);
}
-void RuntimeSupportBuilderARM::EmitSetCurrentThread(llvm::Value* thread) {
- Function* ori_func = GetRuntimeSupportFunction(runtime_support::SetCurrentThread);
- InlineAsm* func = InlineAsm::get(ori_func->getFunctionType(), "mov r9, $0", "r", true);
+llvm::Value*
+RuntimeSupportBuilderARM::EmitSetCurrentThread(llvm::Value* thread) {
+ // Separate to two InlineAsm: The first one produces the return value, while the second,
+ // sets the current thread.
+ // LLVM can delete the first one if the caller in LLVM IR doesn't use the return value.
+ //
+ // Here we don't call EmitGetCurrentThread, because we mark it as DoesNotAccessMemory and
+ // ConstJObject. We denote side effect to "true" below instead, so LLVM won't
+ // reorder these instructions incorrectly.
+ Function* ori_func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
+ InlineAsm* func = InlineAsm::get(ori_func->getFunctionType(), "mov $0, r9", "=r", true);
+ CallInst* old_thread_register = irb_.CreateCall(func);
+ old_thread_register->setOnlyReadsMemory();
+
+ FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+ /*Params=*/irb_.getJObjectTy(),
+ /*isVarArg=*/false);
+ func = InlineAsm::get(func_ty, "mov r9, $0", "r", true);
irb_.CreateCall(func, thread);
+ return old_thread_register;
}
diff --git a/src/compiler_llvm/runtime_support_builder_arm.h b/src/compiler_llvm/runtime_support_builder_arm.h
index 8828925..264689b 100644
--- a/src/compiler_llvm/runtime_support_builder_arm.h
+++ b/src/compiler_llvm/runtime_support_builder_arm.h
@@ -33,7 +33,7 @@
TBAASpecialType s_ty);
virtual void EmitStoreToThreadOffset(int64_t offset, llvm::Value* value,
TBAASpecialType s_ty);
- virtual void EmitSetCurrentThread(llvm::Value* thread);
+ virtual llvm::Value* EmitSetCurrentThread(llvm::Value* thread);
/* Monitor */
virtual void EmitLockObject(llvm::Value* object);
diff --git a/src/compiler_llvm/runtime_support_builder_x86.cc b/src/compiler_llvm/runtime_support_builder_x86.cc
index 1a0a78a..a927fc5 100644
--- a/src/compiler_llvm/runtime_support_builder_x86.cc
+++ b/src/compiler_llvm/runtime_support_builder_x86.cc
@@ -68,8 +68,9 @@
irb_.SetTBAA(call_inst, s_ty);
}
-void RuntimeSupportBuilderX86::EmitSetCurrentThread(llvm::Value*) {
+llvm::Value* RuntimeSupportBuilderX86::EmitSetCurrentThread(llvm::Value*) {
/* Nothing to be done. */
+ return llvm::UndefValue::get(irb_.getJObjectTy());
}
diff --git a/src/compiler_llvm/runtime_support_builder_x86.h b/src/compiler_llvm/runtime_support_builder_x86.h
index ee5d0a3..29a7d88 100644
--- a/src/compiler_llvm/runtime_support_builder_x86.h
+++ b/src/compiler_llvm/runtime_support_builder_x86.h
@@ -33,7 +33,7 @@
TBAASpecialType s_ty);
virtual void EmitStoreToThreadOffset(int64_t offset, llvm::Value* value,
TBAASpecialType s_ty);
- virtual void EmitSetCurrentThread(llvm::Value* thread);
+ virtual llvm::Value* EmitSetCurrentThread(llvm::Value* thread);
};
} // namespace compiler_llvm
diff --git a/src/compiler_llvm/runtime_support_llvm.cc b/src/compiler_llvm/runtime_support_llvm.cc
index 27541c3..2463bc5 100644
--- a/src/compiler_llvm/runtime_support_llvm.cc
+++ b/src/compiler_llvm/runtime_support_llvm.cc
@@ -61,8 +61,9 @@
#endif
}
-void art_set_current_thread_from_code(void* thread_object_addr) {
+void* art_set_current_thread_from_code(void* thread_object_addr) {
// Nothing to be done.
+ return NULL;
}
void art_lock_object_from_code(Object* obj, Thread* thread) {
diff --git a/src/compiler_llvm/runtime_support_llvm.h b/src/compiler_llvm/runtime_support_llvm.h
index 6757ff5..8ab28c6 100644
--- a/src/compiler_llvm/runtime_support_llvm.h
+++ b/src/compiler_llvm/runtime_support_llvm.h
@@ -55,7 +55,7 @@
void art_test_suspend_from_code(Thread* thread);
-void art_set_current_thread_from_code(void* thread_object_addr);
+void* art_set_current_thread_from_code(void* thread_object_addr);
//----------------------------------------------------------------------------
// Runtime Support Function Lookup Callback
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