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

Unified Diff: src/factory.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/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 877b3f7c685750688f890c2c16b0e11a44193bc1..7d28cb348fdff0b21499f1a0450211495c05ac9e 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1515,7 +1515,9 @@ Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
// can be from a different context.
Handle<Context> native_context(function->context()->native_context());
Handle<Map> new_map;
- if (IsResumableFunction(function->shared()->kind())) {
+ if (IsAsyncGeneratorFunction(function->shared()->kind())) {
+ new_map = handle(native_context->async_generator_object_prototype_map());
+ } else if (IsResumableFunction(function->shared()->kind())) {
// Generator and async function prototypes can share maps since they
// don't have "constructor" properties.
new_map = handle(native_context->generator_object_prototype_map());
@@ -1892,7 +1894,8 @@ Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
DCHECK(IsResumableFunction(function->shared()->kind()));
JSFunction::EnsureHasInitialMap(function);
Handle<Map> map(function->initial_map());
- DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type());
+ DCHECK(JS_GENERATOR_OBJECT_TYPE == map->instance_type() ||
+ JS_ASYNC_GENERATOR_OBJECT_TYPE == map->instance_type());
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateJSObjectFromMap(*map),
@@ -1957,6 +1960,17 @@ Handle<JSIteratorResult> Factory::NewJSIteratorResult(Handle<Object> value,
return js_iter_result;
}
+Handle<JSAsyncFromSyncIterator> Factory::NewJSAsyncFromSyncIterator(
+ Handle<HeapObject> sync_iterator) {
+ Handle<Map> map(
+ isolate()->native_context()->initial_async_from_sync_iterator_map());
+ Handle<JSAsyncFromSyncIterator> iterator =
+ Handle<JSAsyncFromSyncIterator>::cast(NewJSObjectFromMap(map));
+
+ iterator->set_sync_iterator(*sync_iterator);
+ return iterator;
+}
+
Handle<JSMap> Factory::NewJSMap() {
Handle<Map> map(isolate()->native_context()->js_map_map());
Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map));
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698