Skip to content

Commit

Permalink
[async-iteration] delete AsyncGeneratorYield builtin
Browse files Browse the repository at this point in the history
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 <caitp@igalia.com>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44820}
  • Loading branch information
caitp authored and Commit Bot committed Apr 24, 2017
1 parent 56e07b4 commit 56b337f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 34 deletions.
6 changes: 0 additions & 6 deletions src/bootstrapper.cc
Expand Up @@ -1410,12 +1410,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallWithIntrinsicDefaultProto(isolate, await_uncaught,
Context::ASYNC_GENERATOR_AWAIT_UNCAUGHT);

Handle<JSFunction> yield =
SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kAsyncGeneratorYield, 2, false);
InstallWithIntrinsicDefaultProto(isolate, yield,
Context::ASYNC_GENERATOR_YIELD);

Handle<Code> code =
isolate->builtins()->AsyncGeneratorAwaitResolveClosure();
Handle<SharedFunctionInfo> info =
Expand Down
22 changes: 4 additions & 18 deletions src/builtins/builtins-async-generator-gen.cc
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 0 additions & 5 deletions src/builtins/builtins-definitions.h
Expand Up @@ -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% */ \
Expand Down
4 changes: 1 addition & 3 deletions src/contexts.h
Expand Up @@ -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) \
Expand Down
6 changes: 4 additions & 2 deletions src/interpreter/bytecode-generator.cc
Expand Up @@ -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(<generator>, <value>, 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);
}
Expand Down

0 comments on commit 56b337f

Please sign in to comment.