From 56b337f7e63bf033818413909c7abb655f0bc3f9 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Mon, 24 Apr 2017 16:49:00 -0400 Subject: [PATCH] [async-iteration] delete AsyncGeneratorYield builtin The AsyncGeneratorYield builtin just invoked the AsyncGeneratorResolve() stub anyways, so this removes the middle-man. Really minor refactoring, but clears out a bit of snapshot size and another context index. BUG=v8:5855 R=rmcilroy@chromium.org, bmeurer@chromium.org Change-Id: I3385a5c5412e8d58493601874c2ad6b60e613012 Reviewed-on: https://chromium-review.googlesource.com/471913 Commit-Queue: Caitlin Potter Reviewed-by: Ross McIlroy Cr-Commit-Position: refs/heads/master@{#44820} --- src/bootstrapper.cc | 6 ------ src/builtins/builtins-async-generator-gen.cc | 22 ++++---------------- src/builtins/builtins-definitions.h | 5 ----- src/contexts.h | 4 +--- src/interpreter/bytecode-generator.cc | 6 ++++-- 5 files changed, 9 insertions(+), 34 deletions(-) diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index b1de03eb259a..080ce9aeea25 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1410,12 +1410,6 @@ void Genesis::InitializeGlobal(Handle global_object, InstallWithIntrinsicDefaultProto(isolate, await_uncaught, Context::ASYNC_GENERATOR_AWAIT_UNCAUGHT); - Handle yield = - SimpleCreateFunction(isolate, factory->empty_string(), - Builtins::kAsyncGeneratorYield, 2, false); - InstallWithIntrinsicDefaultProto(isolate, yield, - Context::ASYNC_GENERATOR_YIELD); - Handle code = isolate->builtins()->AsyncGeneratorAwaitResolveClosure(); Handle info = diff --git a/src/builtins/builtins-async-generator-gen.cc b/src/builtins/builtins-async-generator-gen.cc index 4e118fa2ffd0..b3cb3d8ebd0d 100644 --- a/src/builtins/builtins-async-generator-gen.cc +++ b/src/builtins/builtins-async-generator-gen.cc @@ -360,24 +360,6 @@ TF_BUILTIN(AsyncGeneratorPrototypeThrow, AsyncGeneratorBuiltinsAssembler) { "[AsyncGenerator].prototype.throw"); } -TF_BUILTIN(AsyncGeneratorYield, AsyncGeneratorBuiltinsAssembler) { - Node* const generator = Parameter(Descriptor::kReceiver); - Node* const value = Parameter(Descriptor::kValue); - Node* const context = Parameter(Descriptor::kContext); - - CSA_ASSERT_JS_ARGC_EQ(this, 1); - CSA_SLOW_ASSERT(this, - HasInstanceType(generator, JS_ASYNC_GENERATOR_OBJECT_TYPE)); - CSA_ASSERT(this, IsGeneratorNotSuspendedForAwait(generator)); - - CallBuiltin(Builtins::kAsyncGeneratorResolve, context, generator, value, - FalseConstant()); - - // Yield must have been reached via ResumeNext(), so don't recursively call - // it. - Return(UndefinedConstant()); -} - TF_BUILTIN(AsyncGeneratorAwaitResolveClosure, AsyncGeneratorBuiltinsAssembler) { Node* value = Parameter(Descriptor::kValue); Node* context = Parameter(Descriptor::kContext); @@ -493,6 +475,10 @@ TF_BUILTIN(AsyncGeneratorResolve, AsyncGeneratorBuiltinsAssembler) { Node* const done = Parameter(Descriptor::kDone); Node* const context = Parameter(Descriptor::kContext); + CSA_SLOW_ASSERT(this, + HasInstanceType(generator, JS_ASYNC_GENERATOR_OBJECT_TYPE)); + CSA_ASSERT(this, IsGeneratorNotSuspendedForAwait(generator)); + Node* const next = TakeFirstAsyncGeneratorRequestFromQueue(generator); Node* const promise = LoadPromiseFromAsyncGeneratorRequest(next); diff --git a/src/builtins/builtins-definitions.h b/src/builtins/builtins-definitions.h index ac7a773a8bda..716f1812211d 100644 --- a/src/builtins/builtins-definitions.h +++ b/src/builtins/builtins-definitions.h @@ -980,11 +980,6 @@ namespace internal { TFJ(AsyncGeneratorAwaitResolveClosure, 1, kValue) \ TFJ(AsyncGeneratorAwaitRejectClosure, 1, kValue) \ \ - /* GeneratorYield (proposal-async-iteration/#sec-generatoryield) with */ \ - /* resume behaviour specific to Async Generators. Internal / not exposed */ \ - /* to JS code. */ \ - TFJ(AsyncGeneratorYield, 1, kValue) \ - \ /* Async-from-Sync Iterator */ \ \ /* %AsyncFromSyncIteratorPrototype% */ \ diff --git a/src/contexts.h b/src/contexts.h index e452088b1910..0db6ceef04eb 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -86,9 +86,7 @@ enum ContextLookupFlags { V(PROMISE_HANDLE_INDEX, JSFunction, promise_handle) \ V(PROMISE_HANDLE_REJECT_INDEX, JSFunction, promise_handle_reject) \ V(ASYNC_GENERATOR_AWAIT_CAUGHT, JSFunction, async_generator_await_caught) \ - V(ASYNC_GENERATOR_AWAIT_UNCAUGHT, JSFunction, \ - async_generator_await_uncaught) \ - V(ASYNC_GENERATOR_YIELD, JSFunction, async_generator_yield) + V(ASYNC_GENERATOR_AWAIT_UNCAUGHT, JSFunction, async_generator_await_uncaught) #define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \ V(ARRAY_CONCAT_INDEX, JSFunction, array_concat) \ diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc index a03e6e5b897c..6cf3216f8542 100644 --- a/src/interpreter/bytecode-generator.cc +++ b/src/interpreter/bytecode-generator.cc @@ -2394,14 +2394,16 @@ void BytecodeGenerator::VisitSuspend(Suspend* expr) { if (expr->IsNonInitialAsyncGeneratorYield()) { // AsyncGenerator yields (with the exception of the initial yield) delegate // to AsyncGeneratorResolve(), implemented via the runtime call below. - RegisterList args = register_allocator()->NewRegisterList(2); + RegisterList args = register_allocator()->NewRegisterList(3); // AsyncGeneratorYield: // perform AsyncGeneratorResolve(, , false). builder() ->MoveRegister(generator, args[0]) .MoveRegister(value, args[1]) - .CallJSRuntime(Context::ASYNC_GENERATOR_YIELD, args); + .LoadFalse() + .StoreAccumulatorInRegister(args[2]) + .CallRuntime(Runtime::kInlineAsyncGeneratorResolve, args); } else { builder()->LoadAccumulatorWithRegister(value); }