Revert "Stop interpreter from accessing code items of compiled code."
The entrypoint of a method can change concurrently.
Bug: 35800981
This reverts commit 178dce79220c16e6f0061bcd12e9e9683ec045ee.
Change-Id: I25ae8d0d2830eb8412c52f61736bac7b16281c11
diff --git a/runtime/common_dex_operations.h b/runtime/common_dex_operations.h
index 8776061..6693eef 100644
--- a/runtime/common_dex_operations.h
+++ b/runtime/common_dex_operations.h
@@ -36,8 +36,8 @@
void ArtInterpreterToCompiledCodeBridge(Thread* self,
ArtMethod* caller,
+ const DexFile::CodeItem* code_item,
ShadowFrame* shadow_frame,
- uint16_t arg_offset,
JValue* result);
} // namespace interpreter
@@ -56,7 +56,7 @@
interpreter::ArtInterpreterToInterpreterBridge(self, code_item, callee_frame, result);
} else {
interpreter::ArtInterpreterToCompiledCodeBridge(
- self, caller_method, callee_frame, first_dest_reg, result);
+ self, caller_method, code_item, callee_frame, result);
}
} else {
interpreter::UnstartedRuntime::Invoke(self, code_item, callee_frame, result, first_dest_reg);
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index f3ca338..bf49e84 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -264,11 +264,7 @@
// Pop the shadow frame before calling into compiled code.
self->PopShadowFrame();
- // Calculate the offset of the first input reg. The input registers are in the high regs.
- // The frame may only contain room for the inputs, in which case the arg offset is 0.
- uint16_t arg_offset = code_item->registers_size_ == shadow_frame.NumberOfVRegs() ?
- code_item->registers_size_ - code_item->ins_size_ : 0;
- ArtInterpreterToCompiledCodeBridge(self, nullptr, &shadow_frame, arg_offset, &result);
+ ArtInterpreterToCompiledCodeBridge(self, nullptr, code_item, &shadow_frame, &result);
// Push the shadow frame back as the caller will expect it.
self->PushShadowFrame(&shadow_frame);
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index d8c17f2..ef0ddb3 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -458,8 +458,8 @@
void ArtInterpreterToCompiledCodeBridge(Thread* self,
ArtMethod* caller,
+ const DexFile::CodeItem* code_item,
ShadowFrame* shadow_frame,
- uint16_t arg_offset,
JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_) {
ArtMethod* method = shadow_frame->GetMethod();
@@ -482,15 +482,9 @@
method = shadow_frame->GetMethod();
}
}
- // Basic checks for the arg_offset. If there's no code item, the arg_offset must be 0. Otherwise,
- // check that the arg_offset isn't greater than the number of registers. A stronger check is
- // difficult since the frame may contain space for all the registers in the method, or only enough
- // space for the arguments.
- if (method->GetCodeItem() == nullptr) {
- DCHECK_EQ(0u, arg_offset) << method->PrettyMethod();
- } else {
- DCHECK_LE(arg_offset, shadow_frame->NumberOfVRegs());
- }
+ uint16_t arg_offset = (code_item == nullptr)
+ ? 0
+ : code_item->registers_size_ - code_item->ins_size_;
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr && caller != nullptr) {
jit->NotifyInterpreterToCompiledCodeTransition(self, caller);
@@ -924,20 +918,12 @@
// Compute method information.
const DexFile::CodeItem* code_item = called_method->GetCodeItem();
+
// Number of registers for the callee's call frame.
uint16_t num_regs;
if (LIKELY(code_item != nullptr)) {
- // When transitioning to compiled code, space only needs to be reserved for the input registers.
- // The rest of the frame gets discarded. This also prevents accessing the called method's code
- // item, saving memory by keeping code items of compiled code untouched.
- if (Runtime::Current()->IsStarted() &&
- !ClassLinker::ShouldUseInterpreterEntrypoint(
- called_method, called_method->GetEntryPointFromQuickCompiledCode())) {
- num_regs = number_of_inputs;
- } else {
- num_regs = code_item->registers_size_;
- DCHECK_EQ(string_init ? number_of_inputs - 1 : number_of_inputs, code_item->ins_size_);
- }
+ num_regs = code_item->registers_size_;
+ DCHECK_EQ(string_init ? number_of_inputs - 1 : number_of_inputs, code_item->ins_size_);
} else {
DCHECK(called_method->IsNative() || called_method->IsProxyMethod());
num_regs = number_of_inputs;
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index 67e072d..2589ad0 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -527,11 +527,10 @@
}
}
-// The arg_offset is the offset to the first input register in the frame.
void ArtInterpreterToCompiledCodeBridge(Thread* self,
ArtMethod* caller,
+ const DexFile::CodeItem* code_item,
ShadowFrame* shadow_frame,
- uint16_t arg_offset,
JValue* result);
// Set string value created from StringFactory.newStringFromXXX() into all aliases of