Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index a5da88a0b3b2e0b5e44b17e0918d17655ea38e09..480c67599305458bf7eac8112993faeb960f156a 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -18863,5 +18863,22 @@ void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
} |
} |
+int JSGeneratorObject::source_position() const { |
+ CHECK(is_suspended()); |
+ if (function()->shared()->HasBytecodeArray()) { |
+ // New-style generators. |
+ int offset = Smi::cast(input_or_debug_pos())->value(); |
+ // The stored bytecode offset is relative to a different base than what |
+ // is used in the source position table, hence the subtraction. |
+ offset -= BytecodeArray::kHeaderSize - kHeapObjectTag; |
+ return function()->shared()->bytecode_array()->SourcePosition(offset); |
+ } else { |
+ // Old-style generators. |
+ int offset = continuation(); |
+ CHECK(0 <= offset && offset < function()->code()->instruction_size()); |
+ return function()->code()->SourcePosition(offset); |
+ } |
+} |
+ |
} // namespace internal |
} // namespace v8 |