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

Unified Diff: src/objects.cc

Issue 2622833002: WIP [esnext] implement async iteration proposal (Closed)
Patch Set: simplify AsyncIteratorValueUnwrap Created 3 years, 11 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-body-descriptors-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 23bcd150a801325191373928bf7076cce97ec28c..e296d39f981473ab8ca2dd35664b75c10a5a9ca0 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2761,6 +2761,14 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
accumulator->Add("<JS Generator>");
break;
}
+ case JS_ASYNC_GENERATOR_OBJECT_TYPE: {
+ accumulator->Add("<JS AsyncGenerator>");
+ break;
+ }
+ case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: {
+ accumulator->Add("<JS AsyncFromSyncIterator>");
+ break;
+ }
// All other JSObjects are rather similar to each other (JSObject,
// JSGlobalProxy, JSGlobalObject, JSUndetectable, JSValue).
default: {
@@ -8645,7 +8653,8 @@ Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size,
DCHECK(*map == JSFunction::cast(constructor)->initial_map() ||
*map == *isolate->strict_function_map() ||
*map == *isolate->generator_function_map() ||
- *map == *isolate->async_function_map());
+ *map == *isolate->async_function_map() ||
+ *map == *isolate->async_generator_function_map());
#endif
// Initial maps must always own their descriptors and it's descriptor array
// does not contain descriptors that do not belong to the map.
@@ -12638,6 +12647,8 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_type) {
case JS_DATE_TYPE:
case JS_FUNCTION_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
+ case JS_ASYNC_GENERATOR_OBJECT_TYPE:
+ case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE:
case JS_MAP_ITERATOR_TYPE:
case JS_MAP_TYPE:
case JS_MESSAGE_OBJECT_TYPE:
@@ -12711,7 +12722,9 @@ void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) {
// suggested by the function.
InstanceType instance_type;
if (IsResumableFunction(function->shared()->kind())) {
- instance_type = JS_GENERATOR_OBJECT_TYPE;
+ instance_type = IsAsyncGeneratorFunction(function->shared()->kind())
+ ? JS_ASYNC_GENERATOR_OBJECT_TYPE
+ : JS_GENERATOR_OBJECT_TYPE;
} else {
instance_type = JS_OBJECT_TYPE;
}
@@ -19286,7 +19299,16 @@ int JSGeneratorObject::source_position() const {
CHECK(is_suspended());
DCHECK(function()->shared()->HasBytecodeArray());
DCHECK(!function()->shared()->HasBaselineCode());
- int code_offset = Smi::cast(input_or_debug_pos())->value();
+
+ int code_offset;
+ const JSAsyncGeneratorObject* async =
+ IsJSAsyncGeneratorObject() ? JSAsyncGeneratorObject::cast(this) : nullptr;
+ if (async != nullptr && async->awaited_promise()->IsJSPromise()) {
+ code_offset = Smi::cast(async->await_input())->value();
+ } else {
+ code_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.
code_offset -= BytecodeArray::kHeaderSize - kHeapObjectTag;
« no previous file with comments | « src/objects.h ('k') | src/objects-body-descriptors-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698