Cleanup invoke's receiver handling in interpreter.
To comply with a moving collector, we used to load invoke's receiver (for non
static methods only) from the caller shadow frame after resolving the method
itself (in case the garbage collector is triggered inside) but before passing
invoke arguments, including loading receiver from the caller's shadow frame
into the callee's shadow frame. Therefore, we used to load the receiver 3 times
in the fast path but only twice in the slow path.
The slow path is rarely used (only in method requiring extra runtime checks) so
we now move this extra reload to the slow path. Therefore an invoke using the
fast path loads the receiver twice while the slow path loads it 3 times.
I don't expect much improvement here. The main reason is to keep extra code in
the slow path.
Change-Id: I10e96b10de4b8c2992e276bd564bc3e2f191779c
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index a9b8909..4481210 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -87,7 +87,7 @@
// DoInvokeVirtualQuick functions.
// Returns true on success, otherwise throws an exception and returns false.
template<bool is_range, bool do_assignability_check>
-bool DoCall(ArtMethod* method, Object* receiver, Thread* self, ShadowFrame& shadow_frame,
+bool DoCall(ArtMethod* method, Thread* self, ShadowFrame& shadow_frame,
const Instruction* inst, uint16_t inst_data, JValue* result);
// Handles invoke-XXX/range instructions.
@@ -101,10 +101,6 @@
ArtMethod* const method = FindMethodFromCode<type, do_access_check>(method_idx, receiver,
shadow_frame.GetMethod(),
self);
- if (type != kStatic) {
- // Reload the vreg since the GC may have moved the object.
- receiver = shadow_frame.GetVRegReference(vregC);
- }
if (UNLIKELY(method == nullptr)) {
CHECK(self->IsExceptionPending());
result->SetJ(0);
@@ -114,8 +110,7 @@
result->SetJ(0);
return false;
} else {
- return DoCall<is_range, do_access_check>(method, receiver, self, shadow_frame, inst,
- inst_data, result);
+ return DoCall<is_range, do_access_check>(method, self, shadow_frame, inst, inst_data, result);
}
}
@@ -145,7 +140,7 @@
return false;
} else {
// No need to check since we've been quickened.
- return DoCall<is_range, false>(method, receiver, self, shadow_frame, inst, inst_data, result);
+ return DoCall<is_range, false>(method, self, shadow_frame, inst, inst_data, result);
}
}