Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: src/objects.cc

Issue 2079613003: [generators] Implement %GeneratorGetSourcePosition. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rename again, and move subtraction to runtime Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698