Index: src/interpreter/interpreter.cc |
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc |
index 9b6662eeba69b99a80accd162fe29957611e5f86..48e29f4173bf2ae88f633f39652e3fb00c4abfd1 100644 |
--- a/src/interpreter/interpreter.cc |
+++ b/src/interpreter/interpreter.cc |
@@ -12,6 +12,7 @@ |
#include "src/compilation-info.h" |
#include "src/compiler.h" |
#include "src/factory.h" |
+#include "src/interpreter/bytecode-array-iterator.h" |
#include "src/interpreter/bytecode-flags.h" |
#include "src/interpreter/bytecode-generator.h" |
#include "src/interpreter/bytecodes.h" |
@@ -261,6 +262,19 @@ uintptr_t Interpreter::GetDispatchCounter(Bytecode from, Bytecode to) const { |
to_index]; |
} |
+// static |
+int Interpreter::AdvanceBytecodeOffset(BytecodeArray* bytecode_array, |
+ int bytecode_offset) { |
+ DisallowHeapAllocation no_gc; |
+ HandleScope scope(bytecode_array->GetIsolate()); |
+ BytecodeArrayIterator it(handle(bytecode_array)); |
+ int offset = bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; |
+ while (it.current_offset() < offset) it.Advance(); |
+ DCHECK_EQ(offset, it.current_offset()); |
+ it.Advance(); // Advance by one bytecode. |
+ return it.current_offset() + BytecodeArray::kHeaderSize - kHeapObjectTag; |
+} |
+ |
Local<v8::Object> Interpreter::GetDispatchCountersObject() { |
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(isolate_); |
Local<v8::Context> context = isolate->GetCurrentContext(); |