[VM interpreter] Use a helper to test entry frame pc marker.
Change-Id: I6256f0337d2ab84722d32d4e6af97b966c619162
Reviewed-on: https://dart-review.googlesource.com/75987
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
diff --git a/runtime/vm/interpreter.cc b/runtime/vm/interpreter.cc
index 728ad6d..b0bbb27 100644
--- a/runtime/vm/interpreter.cc
+++ b/runtime/vm/interpreter.cc
@@ -943,7 +943,7 @@
// Unwind to entry frame.
fp_ = *FP;
pc_ = reinterpret_cast<uword>(SavedCallerPC(fp_));
- while ((pc_ & 2) == 0) {
+ while (!IsEntryFrameMarker(pc_)) {
fp_ = SavedCallerFP(fp_);
pc_ = reinterpret_cast<uword>(SavedCallerPC(fp_));
}
@@ -1525,7 +1525,7 @@
do { \
FP = reinterpret_cast<RawObject**>(fp_); \
pc = reinterpret_cast<uint32_t*>(pc_); \
- if ((reinterpret_cast<uword>(pc) & 2) != 0) { /* Entry frame? */ \
+ if (IsEntryFrameMarker(reinterpret_cast<uword>(pc))) { \
pp_ = reinterpret_cast<RawObjectPool*>(fp_[kKBCSavedPpSlotFromEntryFp]); \
argdesc_ = \
reinterpret_cast<RawArray*>(fp_[kKBCSavedArgDescSlotFromEntryFp]); \
@@ -1553,7 +1553,7 @@
do { \
FP = reinterpret_cast<RawObject**>(fp_); \
pc = reinterpret_cast<uint32_t*>(pc_); \
- if ((reinterpret_cast<uword>(pc) & 2) != 0) { /* Entry frame? */ \
+ if (IsEntryFrameMarker(reinterpret_cast<uword>(pc))) { \
pp_ = reinterpret_cast<RawObjectPool*>(fp_[kKBCSavedPpSlotFromEntryFp]); \
argdesc_ = \
reinterpret_cast<RawArray*>(fp_[kKBCSavedArgDescSlotFromEntryFp]); \
@@ -1632,7 +1632,7 @@
pc_ = reinterpret_cast<uword>(*pc); // For the profiler.
// Check if it is a fake PC marking the entry frame.
- ASSERT((reinterpret_cast<uword>(*pc) & 2) == 0);
+ ASSERT(!IsEntryFrameMarker(reinterpret_cast<uword>(*pc)));
// Restore SP, FP and PP.
// Unoptimized frame SP is one below FrameArguments(...) because
@@ -3483,7 +3483,7 @@
pc_ = reinterpret_cast<uword>(pc); // For the profiler.
// Check if it is a fake PC marking the entry frame.
- if ((reinterpret_cast<uword>(pc) & 2) != 0) {
+ if (IsEntryFrameMarker(reinterpret_cast<uword>(pc))) {
// Pop entry frame.
fp_ = SavedCallerFP(FP);
// Restore exit frame info saved in entry frame.
@@ -4798,7 +4798,8 @@
// Restore caller context as we are going to throw NoSuchMethod.
pc = SavedCallerPC(FP);
- const bool has_dart_caller = (reinterpret_cast<uword>(pc) & 2) == 0;
+ const bool has_dart_caller =
+ !IsEntryFrameMarker(reinterpret_cast<uword>(pc));
const intptr_t argc = has_dart_caller ? KernelBytecode::DecodeArgc(pc[-1])
: (reinterpret_cast<uword>(pc) >> 2);
const intptr_t type_args_len =
diff --git a/runtime/vm/interpreter.h b/runtime/vm/interpreter.h
index 3d98670..73fcadb 100644
--- a/runtime/vm/interpreter.h
+++ b/runtime/vm/interpreter.h
@@ -59,6 +59,9 @@
return frame >= stack_base() && frame <= get_fp();
}
+ // Identify an entry frame by looking at its pc marker value.
+ static bool IsEntryFrameMarker(uword pc) { return (pc & 2) != 0; }
+
// Call on program start.
static void InitOnce();
diff --git a/runtime/vm/stub_code.cc b/runtime/vm/stub_code.cc
index 759469a..472a825 100644
--- a/runtime/vm/stub_code.cc
+++ b/runtime/vm/stub_code.cc
@@ -11,6 +11,7 @@
#include "vm/compiler/assembler/disassembler.h"
#include "vm/flags.h"
#include "vm/heap/safepoint.h"
+#include "vm/interpreter.h"
#include "vm/object_store.h"
#include "vm/snapshot.h"
#include "vm/virtual_memory.h"
@@ -96,7 +97,7 @@
if (FLAG_enable_interpreter) {
if (is_interpreted_frame) {
// Recognize special marker set up by interpreter in entry frame.
- return (pc & 2) != 0;
+ return Interpreter::IsEntryFrameMarker(pc);
}
{
uword entry = StubCode::InvokeDartCodeFromBytecode_entry()->EntryPoint();