Commit fa1a3397 authored by Caitlin Potter's avatar Caitlin Potter Committed by Commit Bot

[async-iteration] eliminate implicit Await when resuming with .return()

AsyncGenerators, when resumed with a "return" completion, Await the sent
value to provide consistency with syntactic return statements. This
moves the await to during AsyncGeneratorResumeNext, shrinking the number
of bytecodes.

There's a minor change to BytecodeGenerator which removes a
%_GeneratorClose() call, since it's inserted implicitly by the parser.

BUG=v8:5855
TBR=neis@chromium.org

Change-Id: I2965c610e5985ac24c713b481e62f6b97f96a3d8
Reviewed-on: https://chromium-review.googlesource.com/582218
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47253}
parent 06f5f846
......@@ -219,13 +219,7 @@ void AstNumberingVisitor::VisitSuspend(Suspend* node) {
Visit(node->expression());
}
void AstNumberingVisitor::VisitYield(Yield* node) {
node->set_suspend_id(suspend_count_++);
if (IsAsyncGeneratorFunction(function_kind_)) {
node->set_await_return_value_suspend_id(suspend_count_++);
}
Visit(node->expression());
}
void AstNumberingVisitor::VisitYield(Yield* node) { VisitSuspend(node); }
void AstNumberingVisitor::VisitYieldStar(YieldStar* node) {
VisitSuspend(node);
......
......@@ -2275,24 +2275,10 @@ class Suspend : public Expression {
};
class Yield final : public Suspend {
public:
inline int await_return_value_suspend_id() const {
DCHECK_NE(await_return_value_suspend_id_, -1);
return await_return_value_suspend_id_;
}
void set_await_return_value_suspend_id(int id) {
await_return_value_suspend_id_ = id;
}
private:
friend class AstNodeFactory;
Yield(Expression* expression, int pos, OnAbruptResume on_abrupt_resume)
: Suspend(kYield, expression, pos, on_abrupt_resume),
await_return_value_suspend_id_(-1) {}
// TODO(caitp): remove from class once `await` handled by AsyncGeneratorReturn
// stub.
int await_return_value_suspend_id_;
: Suspend(kYield, expression, pos, on_abrupt_resume) {}
};
class YieldStar final : public Suspend {
......
......@@ -1500,11 +1500,19 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
info->set_length(1);
native_context()->set_async_generator_return_resolve_shared_fun(*info);
code = BUILTIN_CODE(isolate, AsyncGeneratorReturnRejectClosure);
code = BUILTIN_CODE(isolate, AsyncGeneratorReturnClosedResolveClosure);
info = factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1);
info->set_length(1);
native_context()->set_async_generator_return_reject_shared_fun(*info);
native_context()->set_async_generator_return_closed_resolve_shared_fun(
*info);
code = BUILTIN_CODE(isolate, AsyncGeneratorReturnClosedRejectClosure);
info = factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1);
info->set_length(1);
native_context()->set_async_generator_return_closed_reject_shared_fun(
*info);
}
{ // --- A r r a y ---
......
......@@ -22,7 +22,7 @@ class ValueUnwrapContext {
Node* AsyncBuiltinsAssembler::Await(
Node* context, Node* generator, Node* value, Node* outer_promise,
int context_length, const ContextInitializer& init_closure_context,
int on_resolve_context_index, int on_reject_context_index,
Node* on_resolve_context_index, Node* on_reject_context_index,
Node* is_predicted_as_caught) {
DCHECK_GE(context_length, Context::MIN_CONTEXT_SLOTS);
......@@ -173,7 +173,7 @@ Node* AsyncBuiltinsAssembler::Await(
void AsyncBuiltinsAssembler::InitializeNativeClosure(Node* context,
Node* native_context,
Node* function,
int context_index) {
Node* context_index) {
Node* const function_map = LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
StoreMapNoWriteBarrier(function, function_map);
......
......@@ -26,8 +26,18 @@ class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
Node* Await(Node* context, Node* generator, Node* value, Node* outer_promise,
int context_length,
const ContextInitializer& init_closure_context,
int on_resolve_context_index, int on_reject_context_index,
Node* on_resolve_context_index, Node* on_reject_context_index,
Node* is_predicted_as_caught);
Node* Await(Node* context, Node* generator, Node* value, Node* outer_promise,
int context_length,
const ContextInitializer& init_closure_context,
int on_resolve_context_index, int on_reject_context_index,
Node* is_predicted_as_caught) {
return Await(context, generator, value, outer_promise, context_length,
init_closure_context, IntPtrConstant(on_resolve_context_index),
IntPtrConstant(on_reject_context_index),
is_predicted_as_caught);
}
Node* Await(Node* context, Node* generator, Node* value, Node* outer_promise,
int context_length,
const ContextInitializer& init_closure_context,
......@@ -45,7 +55,7 @@ class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
private:
void InitializeNativeClosure(Node* context, Node* native_context,
Node* function, int context_index);
Node* function, Node* context_index);
Node* AllocateAsyncIteratorValueUnwrapContext(Node* native_context,
Node* done);
};
......
......@@ -28,6 +28,15 @@ class AsyncGeneratorBuiltinsAssembler : public AsyncBuiltinsAssembler {
explicit AsyncGeneratorBuiltinsAssembler(CodeAssemblerState* state)
: AsyncBuiltinsAssembler(state) {}
inline Node* TaggedIsAsyncGenerator(Node* tagged_object) {
Node* if_notsmi = TaggedIsNotSmi(tagged_object);
return Select(if_notsmi,
[=]() {
return HasInstanceType(tagged_object,
JS_ASYNC_GENERATOR_OBJECT_TYPE);
},
[=]() { return if_notsmi; }, MachineRepresentation::kBit);
}
inline Node* LoadGeneratorState(Node* const generator) {
return LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
}
......@@ -150,8 +159,7 @@ void AsyncGeneratorBuiltinsAssembler::AsyncGeneratorEnqueue(
Label enqueue(this), if_receiverisincompatible(this, Label::kDeferred);
GotoIf(TaggedIsSmi(generator), &if_receiverisincompatible);
Branch(HasInstanceType(generator, JS_ASYNC_GENERATOR_OBJECT_TYPE), &enqueue,
Branch(TaggedIsAsyncGenerator(generator), &enqueue,
&if_receiverisincompatible);
BIND(&enqueue);
......@@ -216,8 +224,7 @@ void AsyncGeneratorBuiltinsAssembler::AsyncGeneratorAwaitResumeClosure(
JSAsyncGeneratorObject::ResumeMode resume_mode) {
Node* const generator =
LoadContextElement(context, AwaitContext::kGeneratorSlot);
CSA_SLOW_ASSERT(this,
HasInstanceType(generator, JS_ASYNC_GENERATOR_OBJECT_TYPE));
CSA_SLOW_ASSERT(this, TaggedIsAsyncGenerator(generator));
#if defined(DEBUG) && defined(ENABLE_SLOW_DCHECKS)
Node* const awaited_promise = LoadGeneratorAwaitedPromise(generator);
......@@ -243,11 +250,10 @@ void AsyncGeneratorBuiltinsAssembler::AsyncGeneratorAwait(bool is_catchable) {
Node* value = Parameter(Descriptor::kAwaited);
Node* context = Parameter(Descriptor::kContext);
CSA_SLOW_ASSERT(this,
HasInstanceType(generator, JS_ASYNC_GENERATOR_OBJECT_TYPE));
CSA_SLOW_ASSERT(this, TaggedIsAsyncGenerator(generator));
Node* const request = LoadFirstAsyncGeneratorRequestFromQueue(generator);
CSA_ASSERT(this, WordNotEqual(request, UndefinedConstant()));
CSA_ASSERT(this, IsNotUndefined(request));
ContextInitializer init_closure_context = [&](Node* context) {
StoreContextElementNoWriteBarrier(context, AwaitContext::kGeneratorSlot,
......@@ -311,10 +317,10 @@ Node* AsyncGeneratorBuiltinsAssembler::TakeFirstAsyncGeneratorRequestFromQueue(
Node* generator) {
// Removes and returns the first AsyncGeneratorRequest from a
// JSAsyncGeneratorObject's queue. Asserts that the queue is not empty.
CSA_ASSERT(this, HasInstanceType(generator, JS_ASYNC_GENERATOR_OBJECT_TYPE));
CSA_ASSERT(this, TaggedIsAsyncGenerator(generator));
Node* request =
LoadObjectField(generator, JSAsyncGeneratorObject::kQueueOffset);
CSA_ASSERT(this, WordNotEqual(request, UndefinedConstant()));
CSA_ASSERT(this, IsNotUndefined(request));
Node* next = LoadObjectField(request, AsyncGeneratorRequest::kNextOffset);
......@@ -438,7 +444,7 @@ TF_BUILTIN(AsyncGeneratorResumeNext, AsyncGeneratorBuiltinsAssembler) {
Branch(IsAbruptResumeType(resume_type), &if_abrupt, &if_normal);
BIND(&if_abrupt);
{
Label settle_promise(this), fulfill_promise(this), reject_promise(this);
Label settle_promise(this), if_return(this), if_throw(this);
GotoIfNot(IsGeneratorStateSuspendedAtStart(var_state.value()),
&settle_promise);
CloseGenerator(generator);
......@@ -447,20 +453,27 @@ TF_BUILTIN(AsyncGeneratorResumeNext, AsyncGeneratorBuiltinsAssembler) {
Goto(&settle_promise);
BIND(&settle_promise);
GotoIfNot(IsGeneratorStateClosed(var_state.value()), &resume_generator);
Node* next_value = LoadValueFromAsyncGeneratorRequest(next);
Branch(SmiEqual(resume_type, SmiConstant(JSGeneratorObject::kReturn)),
&fulfill_promise, &reject_promise);
BIND(&fulfill_promise);
// Unwrap Promise values for "return" in state "suspendedStart".
// This simulates `return await request.[[Completion]].[[Value]]`
TailCallBuiltin(Builtins::kAsyncGeneratorReturnProcessor, context,
generator);
BIND(&reject_promise);
&if_return, &if_throw);
BIND(&if_return);
// For "return" completions, await the sent value. If the Await succeeds,
// and the generator is not closed, resume the generator with a "return"
// completion to allow `finally` blocks to be evaluated. Otherwise, perform
// AsyncGeneratorResolve(awaitedValue, true). If the await fails and the
// generator is not closed, resume the generator with a "throw" completion.
// If the generator was closed, perform AsyncGeneratorReject(thrownValue).
// In all cases, the last step is to call AsyncGeneratorResumeNext.
Node* is_caught = CallRuntime(Runtime::kAsyncGeneratorHasCatchHandlerForPC,
context, generator);
TailCallBuiltin(Builtins::kAsyncGeneratorReturn, context, generator,
next_value, is_caught);
BIND(&if_throw);
GotoIfNot(IsGeneratorStateClosed(var_state.value()), &resume_generator);
CallBuiltin(Builtins::kAsyncGeneratorReject, context, generator,
LoadValueFromAsyncGeneratorRequest(next));
next_value);
var_next.Bind(LoadFirstAsyncGeneratorRequestFromQueue(generator));
Goto(&start);
}
......@@ -491,8 +504,7 @@ 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_SLOW_ASSERT(this, TaggedIsAsyncGenerator(generator));
CSA_ASSERT(this, IsGeneratorNotSuspendedForAwait(generator));
// If this assertion fails, the `value` component was not Awaited as it should
......@@ -581,27 +593,58 @@ TF_BUILTIN(AsyncGeneratorYieldResolveClosure, AsyncGeneratorBuiltinsAssembler) {
TailCallBuiltin(Builtins::kAsyncGeneratorResumeNext, context, generator);
}
TF_BUILTIN(AsyncGeneratorReturnProcessor, AsyncGeneratorBuiltinsAssembler) {
TF_BUILTIN(AsyncGeneratorReturn, AsyncGeneratorBuiltinsAssembler) {
// AsyncGeneratorReturn is called when resuming requests with "return" resume
// modes. It is similar to AsyncGeneratorAwait(), but selects different
// resolve/reject closures depending on whether or not the generator is marked
// as closed.
//
// In particular, non-closed generators will resume the generator with either
// "return" or "throw" resume modes, allowing finally blocks or catch blocks
// to be evaluated, as if the `await` were performed within the body of the
// generator. (per proposal-async-iteration/#sec-asyncgeneratoryield step 8.b)
//
// Closed generators do not resume the generator in the resolve/reject
// closures, but instead simply perform AsyncGeneratorResolve or
// AsyncGeneratorReject with the awaited value
// (per proposal-async-iteration/#sec-asyncgeneratorresumenext step 10.b.i)
//
// In all cases, the final step is to jump back to AsyncGeneratorResumeNext.
Node* const generator = Parameter(Descriptor::kGenerator);
Node* const value = Parameter(Descriptor::kValue);
Node* const is_caught = Parameter(Descriptor::kIsCaught);
Node* const req = LoadFirstAsyncGeneratorRequestFromQueue(generator);
CSA_SLOW_ASSERT(this, SmiEqual(LoadResumeTypeFromAsyncGeneratorRequest(req),
SmiConstant(JSGeneratorObject::kReturn)));
CSA_ASSERT(this, IsNotUndefined(req));
Label perform_await(this);
VARIABLE(var_on_resolve, MachineType::PointerRepresentation(),
IntPtrConstant(
Context::ASYNC_GENERATOR_RETURN_CLOSED_RESOLVE_SHARED_FUN));
VARIABLE(
var_on_reject, MachineType::PointerRepresentation(),
IntPtrConstant(Context::ASYNC_GENERATOR_RETURN_CLOSED_REJECT_SHARED_FUN));
Node* const state = LoadGeneratorState(generator);
GotoIf(IsGeneratorStateClosed(state), &perform_await);
var_on_resolve.Bind(
IntPtrConstant(Context::ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN));
var_on_reject.Bind(
IntPtrConstant(Context::ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN));
Goto(&perform_await);
BIND(&perform_await);
ContextInitializer init_closure_context = [&](Node* context) {
StoreContextElementNoWriteBarrier(context, AwaitContext::kGeneratorSlot,
generator);
};
const bool kIsPredictedAsCaught = false;
Node* const context = Parameter(Descriptor::kContext);
Node* const outer_promise = LoadPromiseFromAsyncGeneratorRequest(req);
Node* const value = LoadValueFromAsyncGeneratorRequest(req);
Node* const promise = Await(
context, generator, value, outer_promise, AwaitContext::kLength,
init_closure_context, Context::ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN,
Context::ASYNC_GENERATOR_RETURN_REJECT_SHARED_FUN, kIsPredictedAsCaught);
Node* const promise =
Await(context, generator, value, outer_promise, AwaitContext::kLength,
init_closure_context, var_on_resolve.value(), var_on_reject.value(),
is_caught);
CSA_SLOW_ASSERT(this, IsGeneratorNotSuspendedForAwait(generator));
StoreObjectField(generator, JSAsyncGeneratorObject::kAwaitedPromiseOffset,
......@@ -609,16 +652,32 @@ TF_BUILTIN(AsyncGeneratorReturnProcessor, AsyncGeneratorBuiltinsAssembler) {
Return(UndefinedConstant());
}
// On-resolve closure for Await in AsyncGeneratorReturn
// Resume the generator with "return" resume_mode, and finally perform
// AsyncGeneratorResumeNext. Per
// proposal-async-iteration/#sec-asyncgeneratoryield step 8.e
TF_BUILTIN(AsyncGeneratorReturnResolveClosure,
AsyncGeneratorBuiltinsAssembler) {
Node* const context = Parameter(Descriptor::kContext);
Node* const value = Parameter(Descriptor::kValue);
AsyncGeneratorAwaitResumeClosure(context, value, JSGeneratorObject::kReturn);
}
// On-resolve closure for Await in AsyncGeneratorReturn
// Perform AsyncGeneratorResolve({awaited_value}, true) and finally perform
// AsyncGeneratorResumeNext.
TF_BUILTIN(AsyncGeneratorReturnClosedResolveClosure,
AsyncGeneratorBuiltinsAssembler) {
Node* const context = Parameter(Descriptor::kContext);
Node* const value = Parameter(Descriptor::kValue);
Node* const generator =
LoadContextElement(context, AwaitContext::kGeneratorSlot);
CSA_SLOW_ASSERT(this, IsGeneratorSuspendedForAwait(generator));
ClearAwaitedPromise(generator);
// https://tc39.github.io/proposal-async-iteration/
// #async-generator-resume-next-return-processor-fulfilled step 2:
// Return ! AsyncGeneratorResolve(_F_.[[Generator]], _value_, *true*).
CallBuiltin(Builtins::kAsyncGeneratorResolve, context, generator, value,
TrueConstant());
......@@ -626,7 +685,8 @@ TF_BUILTIN(AsyncGeneratorReturnResolveClosure,
TailCallBuiltin(Builtins::kAsyncGeneratorResumeNext, context, generator);
}
TF_BUILTIN(AsyncGeneratorReturnRejectClosure, AsyncGeneratorBuiltinsAssembler) {
TF_BUILTIN(AsyncGeneratorReturnClosedRejectClosure,
AsyncGeneratorBuiltinsAssembler) {
Node* const context = Parameter(Descriptor::kContext);
Node* const value = Parameter(Descriptor::kValue);
Node* const generator =
......@@ -635,6 +695,8 @@ TF_BUILTIN(AsyncGeneratorReturnRejectClosure, AsyncGeneratorBuiltinsAssembler) {
CSA_SLOW_ASSERT(this, IsGeneratorSuspendedForAwait(generator));
ClearAwaitedPromise(generator);
// https://tc39.github.io/proposal-async-iteration/
// #async-generator-resume-next-return-processor-rejected step 2:
// Return ! AsyncGeneratorReject(_F_.[[Generator]], _reason_).
CallBuiltin(Builtins::kAsyncGeneratorReject, context, generator, value);
......
......@@ -1054,7 +1054,7 @@ namespace internal {
TFS(AsyncGeneratorResolve, kGenerator, kValue, kDone) \
TFS(AsyncGeneratorReject, kGenerator, kValue) \
TFS(AsyncGeneratorYield, kGenerator, kValue, kIsCaught) \
TFS(AsyncGeneratorReturnProcessor, kGenerator) \
TFS(AsyncGeneratorReturn, kGenerator, kValue, kIsCaught) \
TFS(AsyncGeneratorResumeNext, kGenerator) \
\
/* AsyncGeneratorFunction( p1, p2, ... pn, body ) */ \
......@@ -1080,8 +1080,9 @@ namespace internal {
TFJ(AsyncGeneratorAwaitResolveClosure, 1, kValue) \
TFJ(AsyncGeneratorAwaitRejectClosure, 1, kValue) \
TFJ(AsyncGeneratorYieldResolveClosure, 1, kValue) \
TFJ(AsyncGeneratorReturnClosedResolveClosure, 1, kValue) \
TFJ(AsyncGeneratorReturnClosedRejectClosure, 1, kValue) \
TFJ(AsyncGeneratorReturnResolveClosure, 1, kValue) \
TFJ(AsyncGeneratorReturnRejectClosure, 1, kValue) \
\
/* Async-from-Sync Iterator */ \
\
......
......@@ -221,8 +221,10 @@ enum ContextLookupFlags {
async_generator_yield_resolve_shared_fun) \
V(ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_resolve_shared_fun) \
V(ASYNC_GENERATOR_RETURN_REJECT_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_reject_shared_fun) \
V(ASYNC_GENERATOR_RETURN_CLOSED_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_closed_resolve_shared_fun) \
V(ASYNC_GENERATOR_RETURN_CLOSED_REJECT_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_closed_reject_shared_fun) \
V(ATOMICS_OBJECT, JSObject, atomics_object) \
V(BOOLEAN_FUNCTION_INDEX, JSFunction, boolean_function) \
V(BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX, Map, \
......
......@@ -2228,20 +2228,6 @@ void BytecodeGenerator::BuildReturn(int source_position) {
if (info()->literal()->feedback_vector_spec()->HasTypeProfileSlot()) {
builder()->CollectTypeProfile(info()->literal()->return_position());
}
if (IsAsyncGeneratorFunction(info()->literal()->kind())) {
// Mark the generator as closed if returning from an async generator
// function. Note that non-async generators are closed by the
// generator-resume builtin.
// TODO(jarin,caitp) Move the async generator closing to the resume
// builtin.
RegisterAllocationScope register_scope(this);
Register result = register_allocator()->NewRegister();
builder()
->StoreAccumulatorInRegister(result)
.CallRuntime(Runtime::kInlineGeneratorClose, generator_object_)
.LoadAccumulatorWithRegister(result);
}
builder()->SetReturnPosition(source_position, info()->literal());
builder()->Return();
}
......@@ -2251,19 +2237,11 @@ void BytecodeGenerator::BuildAsyncReturn(int source_position) {
if (IsAsyncGeneratorFunction(info()->literal()->kind())) {
RegisterList args = register_allocator()->NewRegisterList(3);
Register generator = args[0];
Register result = args[1];
Register done = args[2];
builder()->StoreAccumulatorInRegister(result);
Variable* var_generator_object = closure_scope()->generator_object_var();
DCHECK_NOT_NULL(var_generator_object);
BuildVariableLoad(var_generator_object, FeedbackSlot::Invalid(),
HoleCheckMode::kElided);
builder()
->StoreAccumulatorInRegister(generator)
->MoveRegister(generator_object_, args[0]) // generator
.StoreAccumulatorInRegister(args[1]) // value
.LoadTrue()
.StoreAccumulatorInRegister(done)
.StoreAccumulatorInRegister(args[2]) // done
.CallRuntime(Runtime::kInlineAsyncGeneratorResolve, args);
} else {
DCHECK(IsAsyncFunction(info()->literal()->kind()));
......@@ -2661,8 +2639,6 @@ void BytecodeGenerator::VisitYield(Yield* expr) {
builder()->Bind(jump_table, JSGeneratorObject::kReturn);
builder()->LoadAccumulatorWithRegister(input);
if (IsAsyncGeneratorFunction(function_kind())) {
// Async generator methods will produce the iter result object.
BuildAwait(expr->await_return_value_suspend_id());
execution_control()->AsyncReturnAccumulator();
} else {
execution_control()->ReturnAccumulator();
......
......@@ -109,5 +109,32 @@ RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) {
return Smi::FromInt(generator->source_position());
}
// Return true if {generator}'s PC has a catch handler. This allows
// catch prediction to happen from the AsyncGeneratorResumeNext stub.
RUNTIME_FUNCTION(Runtime_AsyncGeneratorHasCatchHandlerForPC) {
DisallowHeapAllocation no_allocation_scope;
DCHECK_EQ(1, args.length());
DCHECK(args[0]->IsJSAsyncGeneratorObject());
JSAsyncGeneratorObject* generator = JSAsyncGeneratorObject::cast(args[0]);
int state = generator->continuation();
DCHECK_NE(state, JSAsyncGeneratorObject::kGeneratorExecuting);
// If state is 0 ("suspendedStart"), there is guaranteed to be no catch
// handler. Otherwise, if state is below 0, the generator is closed and will
// not reach a catch handler.
if (state < 1) return isolate->heap()->false_value();
SharedFunctionInfo* shared = generator->function()->shared();
DCHECK(shared->HasBytecodeArray());
HandlerTable* handler_table =
HandlerTable::cast(shared->bytecode_array()->handler_table());
int pc = Smi::cast(generator->input_or_debug_pos())->value();
HandlerTable::CatchPrediction catch_prediction = HandlerTable::ASYNC_AWAIT;
handler_table->LookupRange(pc, nullptr, &catch_prediction);
return isolate->heap()->ToBoolean(catch_prediction == HandlerTable::CAUGHT);
}
} // namespace internal
} // namespace v8
......@@ -242,7 +242,8 @@ namespace internal {
F(AsyncGeneratorYield, 3, 1) \
F(GeneratorGetContinuation, 1, 1) \
F(GeneratorGetSourcePosition, 1, 1) \
F(GeneratorGetResumeMode, 1, 1)
F(GeneratorGetResumeMode, 1, 1) \
F(AsyncGeneratorHasCatchHandlerForPC, 1, 1)
#ifdef V8_INTL_SUPPORT
#define FOR_EACH_INTRINSIC_INTL(F) \
......
......@@ -14,7 +14,7 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 304
bytecode array length: 240
bytecodes: [
B(Mov), R(new_target), R(1),
B(Ldar), R(new_target),
......@@ -23,7 +23,7 @@ bytecodes: [
B(PushContext), R(3),
B(RestoreGeneratorState), R(1),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0),
B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0),
B(LdaSmi), I8(46),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1),
......@@ -46,35 +46,18 @@ bytecodes: [
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(7),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(3), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(7),
/* 17 E> */ B(Throw),
B(Mov), R(1), R(8),
B(Mov), R(7), R(9),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(8), U8(2),
B(SuspendGenerator), R(1), R(0), U8(8), U8(1),
/* 22 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(8),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(8),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(9),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfTrue), U8(5),
B(Ldar), R(8),
B(ReThrow),
B(LdaZero),
B(Star), R(3),
B(Mov), R(8), R(4),
B(Mov), R(7), R(4),
B(Jump), U8(105),
B(LdaUndefined),
B(Star), R(8),
B(Mov), R(1), R(7),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(7), U8(2),
B(SuspendGenerator), R(1), R(0), U8(7), U8(2),
B(SuspendGenerator), R(1), R(0), U8(7), U8(1),
/* 22 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(7),
B(LdaSmi), I8(-2),
......@@ -95,7 +78,7 @@ bytecodes: [
B(Jump), U8(39),
B(Star), R(7),
B(Ldar), R(closure),
B(CreateCatchContext), R(7), U8(5), U8(6),
B(CreateCatchContext), R(7), U8(4), U8(5),
B(Star), R(6),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -123,43 +106,35 @@ bytecodes: [
B(Ldar), R(5),
B(SetPendingMessage),
B(Ldar), R(3),
B(SwitchOnSmiNoFeedback), U8(7), U8(3), I8(0),
B(Jump), U8(34),
B(SwitchOnSmiNoFeedback), U8(6), U8(3), I8(0),
B(Jump), U8(22),
B(LdaTrue),
B(Star), R(8),
B(Mov), R(0), R(6),
B(Mov), R(1), R(6),
B(Mov), R(4), R(7),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(6), U8(3),
B(Star), R(9),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(1), U8(1),
B(Ldar), R(9),
/* 22 S> */ B(Return),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(1), U8(1),
B(Ldar), R(4),
/* 22 S> */ B(Return),
B(Ldar), R(4),
B(ReThrow),
B(LdaUndefined),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(1), U8(1),
B(Ldar), R(3),
/* 22 S> */ B(Return),
]
constant pool: [
Smi [46],
Smi [87],
Smi [139],
Smi [59],
Smi [95],
Smi [15],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"],
FIXED_ARRAY_TYPE,
Smi [6],
Smi [28],
Smi [35],
Smi [20],
Smi [23],
]
handlers: [
[52, 231, 237],
[55, 192, 194],
[52, 187, 193],
[55, 148, 150],
]
---
......@@ -169,7 +144,7 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 401
bytecode array length: 293
bytecodes: [
B(Mov), R(new_target), R(1),
B(Ldar), R(new_target),
......@@ -178,7 +153,7 @@ bytecodes: [
B(PushContext), R(3),
B(RestoreGeneratorState), R(1),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(5), I8(0),
B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0),
B(LdaSmi), I8(46),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1),
......@@ -201,37 +176,20 @@ bytecodes: [
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(7),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(3), U8(2), I8(0),
B(Ldar), R(7),
/* 17 E> */ B(Throw),
B(Mov), R(1), R(8),
B(Mov), R(7), R(9),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(8), U8(2),
B(SuspendGenerator), R(1), R(0), U8(8), U8(1),
/* 31 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(8),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(8),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(9),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfTrue), U8(5),
B(Ldar), R(8),
B(ReThrow),
B(LdaZero),
B(Star), R(3),
B(Mov), R(8), R(4),
B(Jump), U8(202),
B(Mov), R(7), R(4),
B(Jump), U8(158),
/* 22 S> */ B(LdaSmi), I8(42),
B(Star), R(8),
B(LdaFalse),
B(Star), R(9),
B(Mov), R(1), R(7),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(7), U8(3),
B(SuspendGenerator), R(1), R(0), U8(7), U8(2),
B(SuspendGenerator), R(1), R(0), U8(7), U8(1),
/* 31 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(7),
B(LdaSmi), I8(-2),
......@@ -239,35 +197,18 @@ bytecodes: [
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(7),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0),
B(Ldar), R(7),
/* 22 E> */ B(Throw),
B(Mov), R(1), R(8),
B(Mov), R(7), R(9),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(8), U8(2),
B(SuspendGenerator), R(1), R(0), U8(8), U8(3),
/* 31 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(8),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(8),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(9),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfTrue), U8(5),
B(Ldar), R(8),
B(ReThrow),
B(LdaZero),
B(Star), R(3),
B(Mov), R(8), R(4),
B(Mov), R(7), R(4),
B(Jump), U8(105),
B(LdaUndefined),
B(Star), R(8),
B(Mov), R(1), R(7),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(7), U8(2),
B(SuspendGenerator), R(1), R(0), U8(7), U8(4),
B(SuspendGenerator), R(1), R(0), U8(7), U8(2),
/* 31 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(7),
B(LdaSmi), I8(-2),
......@@ -288,7 +229,7 @@ bytecodes: [
B(Jump), U8(39),
B(Star), R(7),
B(Ldar), R(closure),
B(CreateCatchContext), R(7), U8(9), U8(10),
B(CreateCatchContext), R(7), U8(7), U8(8),
B(Star), R(6),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -316,47 +257,38 @@ bytecodes: [
B(Ldar), R(5),
B(SetPendingMessage),
B(Ldar), R(3),
B(SwitchOnSmiNoFeedback), U8(11), U8(3), I8(0),
B(Jump), U8(34),
B(SwitchOnSmiNoFeedback), U8(9), U8(3), I8(0),
B(Jump), U8(22),
B(LdaTrue),
B(Star), R(8),
B(Mov), R(0), R(6),
B(Mov), R(1), R(6),
B(Mov), R(4), R(7),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(6), U8(3),
B(Star), R(9),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(1), U8(1),
B(Ldar), R(9),
/* 31 S> */ B(Return),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(1), U8(1),
B(Ldar), R(4),
/* 31 S> */ B(Return),
B(Ldar), R(4),
B(ReThrow),
B(LdaUndefined),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(1), U8(1),
B(Ldar), R(3),
/* 31 S> */ B(Return),
]
constant pool: [
Smi [46],
Smi [87],
Smi [143],
Smi [184],
Smi [236],
Smi [59],
Smi [99],
Smi [148],
Smi [15],
Smi [7],
Smi [59],
Smi [15],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"],
FIXED_ARRAY_TYPE,
Smi [6],
Smi [28],
Smi [35],
Smi [20],
Smi [23],
]
handlers: [
[52, 328, 334],
[55, 289, 291],
[52, 240, 246],
[55, 201, 203],
]
---
......@@ -366,7 +298,7 @@ snippet: "
"
frame size: 23
parameter count: 1
bytecode array length: 694
bytecode array length: 586
bytecodes: [
B(Mov), R(new_target), R(10),
B(Ldar), R(new_target),
......@@ -375,7 +307,7 @@ bytecodes: [
B(PushContext), R(12),
B(RestoreGeneratorState), R(10),
B(Star), R(11),
B(SwitchOnSmiNoFeedback), U8(0), U8(5), I8(0),
B(SwitchOnSmiNoFeedback), U8(0), U8(3), I8(0),
B(LdaSmi), I8(46),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1),
......@@ -398,51 +330,34 @@ bytecodes: [
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(10), U8(1),
B(Star), R(16),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(10), U8(1),
B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(3), U8(2), I8(0),
B(Ldar), R(16),
/* 17 E> */ B(Throw),
B(Mov), R(10), R(17),
B(Mov), R(16), R(18),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(17), U8(2),
B(SuspendGenerator), R(10), R(0), U8(17), U8(1),
/* 50 S> */ B(Return),
B(RestoreGeneratorRegisters), R(10), R(0), U8(17),
B(LdaSmi), I8(-2),
B(Star), R(11),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(10), U8(1),
B(Star), R(17),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(10), U8(1),
B(Star), R(18),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(18),
B(JumpIfTrue), U8(5),
B(Ldar), R(17),
B(ReThrow),
B(LdaZero),
B(Star), R(12),
B(Mov), R(17), R(13),
B(JumpConstant), U8(24),
B(Mov), R(16), R(13),
B(JumpConstant), U8(21),
B(LdaZero),
B(Star), R(6),
B(Mov), R(context), R(18),
B(Mov), R(context), R(19),
/* 36 S> */ B(CreateArrayLiteral), U8(7), U8(0), U8(37),
/* 36 S> */ B(CreateArrayLiteral), U8(5), U8(0), U8(37),
B(Star), R(20),
B(LdaNamedProperty), R(20), U8(8), U8(1),
B(LdaNamedProperty), R(20), U8(6), U8(1),
B(Star), R(21),
B(CallProperty0), R(21), R(20), U8(3),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(4),
B(Ldar), R(11),
B(SwitchOnSmiNoFeedback), U8(9), U8(2), I8(2),
B(SwitchOnSmiNoFeedback), U8(7), U8(1), I8(1),
B(LdaSmi), I8(-2),
/* 36 E> */ B(TestEqualStrictNoFeedback), R(11),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(46),
B(Star), R(20),
B(CallRuntime), U16(Runtime::kAbort), R(20), U8(1),
/* 31 S> */ B(LdaNamedProperty), R(4), U8(11), U8(7),
/* 31 S> */ B(LdaNamedProperty), R(4), U8(8), U8(7),
B(Star), R(20),
B(CallProperty0), R(20), R(4), U8(5),
B(Star), R(5),
......@@ -450,9 +365,9 @@ bytecodes: [
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1),
B(LdaNamedProperty), R(5), U8(12), U8(9),
B(JumpIfToBooleanTrue), U8(121),
B(LdaNamedProperty), R(5), U8(13), U8(11),
B(LdaNamedProperty), R(5), U8(9), U8(9),
B(JumpIfToBooleanTrue), U8(77),
B(LdaNamedProperty), R(5), U8(10), U8(11),
B(Star), R(7),
B(LdaSmi), I8(2),
B(Star), R(6),
......@@ -464,7 +379,7 @@ bytecodes: [
B(Mov), R(10), R(20),
B(Mov), R(0), R(21),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(20), U8(3),
B(SuspendGenerator), R(10), R(0), U8(20), U8(2),
B(SuspendGenerator), R(10), R(0), U8(20), U8(1),
/* 50 S> */ B(Return),
B(RestoreGeneratorRegisters), R(10), R(0), U8(20),
B(LdaSmi), I8(-2),
......@@ -472,37 +387,20 @@ bytecodes: [
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(10), U8(1),
B(Star), R(20),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(10), U8(1),
B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(0),
B(Ldar), R(20),
/* 42 E> */ B(Throw),
B(Mov), R(10), R(21),
B(Mov), R(20), R(22),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(21), U8(2),
B(SuspendGenerator), R(10), R(0), U8(21), U8(3),
/* 50 S> */ B(Return),
B(RestoreGeneratorRegisters), R(10), R(0), U8(21),
B(LdaSmi), I8(-2),
B(Star), R(11),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(10), U8(1),
B(Star), R(21),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(10), U8(1),
B(Star), R(22),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(22),
B(JumpIfTrue), U8(5),
B(Ldar), R(21),
B(ReThrow),
B(LdaZero),
B(Star), R(16),
B(Mov), R(21), R(17),
B(Mov), R(20), R(17),
B(Jump), U8(60),
B(LdaZero),
B(Star), R(6),
B(JumpLoop), U8(167), I8(0),
B(JumpLoop), U8(123), I8(0),
B(Jump), U8(40),
B(Star), R(20),
B(Ldar), R(closure),
B(CreateCatchContext), R(20), U8(16), U8(17),
B(CreateCatchContext), R(20), U8(13), U8(14),
B(Star), R(19),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -529,7 +427,7 @@ bytecodes: [
B(LdaZero),
B(TestEqualStrict), R(6), U8(14),
B(JumpIfTrue), U8(104),
B(LdaNamedProperty), R(4), U8(18), U8(15),
B(LdaNamedProperty), R(4), U8(15), U8(15),
B(Star), R(8),
B(TestUndetectable),
B(JumpIfFalse), U8(4),
......@@ -543,7 +441,7 @@ bytecodes: [
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(134),
B(Star), R(19),
B(LdaConstant), U8(19),
B(LdaConstant), U8(16),
B(Star), R(20),
B(CallRuntime), U16(Runtime::kNewTypeError), R(19), U8(2),
B(Throw),
......@@ -554,7 +452,7 @@ bytecodes: [
B(Jump), U8(20),
B(Star), R(20),
B(Ldar), R(closure),
B(CreateCatchContext), R(20), U8(16), U8(20),
B(CreateCatchContext), R(20), U8(13), U8(17),
B(Star), R(19),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -573,7 +471,7 @@ bytecodes: [
B(Ldar), R(18),
B(SetPendingMessage),
B(Ldar), R(16),
B(SwitchOnSmiNoFeedback), U8(21), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(18), U8(2), I8(0),
B(Jump), U8(13),
B(LdaZero),
B(Star), R(12),
......@@ -585,7 +483,7 @@ bytecodes: [
B(Star), R(17),
B(Mov), R(10), R(16),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(10), R(0), U8(16), U8(4),
B(SuspendGenerator), R(10), R(0), U8(16), U8(2),
/* 50 S> */ B(Return),
B(RestoreGeneratorRegisters), R(10), R(0), U8(16),
B(LdaSmi), I8(-2),
......@@ -606,7 +504,7 @@ bytecodes: [
B(Jump), U8(39),
B(Star), R(16),
B(Ldar), R(closure),
B(CreateCatchContext), R(16), U8(16), U8(23),
B(CreateCatchContext), R(16), U8(13), U8(20),
B(Star), R(15),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -634,44 +532,34 @@ bytecodes: [
B(Ldar), R(14),
B(SetPendingMessage),
B(Ldar), R(12),
B(SwitchOnSmiNoFeedback), U8(25), U8(3), I8(0),
B(Jump), U8(34),
B(SwitchOnSmiNoFeedback), U8(22), U8(3), I8(0),
B(Jump), U8(22),
B(LdaTrue),
B(Star), R(17),
B(Mov), R(2), R(15),
B(Mov), R(10), R(15),
B(Mov), R(13), R(16),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(15), U8(3),
B(Star), R(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(10), U8(1),
B(Ldar), R(18),
/* 50 S> */ B(Return),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(10), U8(1),
B(Ldar), R(13),
/* 50 S> */ B(Return),
B(Ldar), R(13),
B(ReThrow),
B(LdaUndefined),
B(Star), R(12),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(10), U8(1),
B(Ldar), R(12),
/* 50 S> */ B(Return),
]
constant pool: [
Smi [46],
Smi [87],
Smi [157],
Smi [157],
Smi [529],
Smi [59],
Smi [113],
Smi [441],
Smi [15],
Smi [7],
TUPLE2_TYPE,
SYMBOL_TYPE,
Smi [85],
Smi [126],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
Smi [59],
Smi [15],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"],
FIXED_ARRAY_TYPE,
......@@ -681,17 +569,17 @@ constant pool: [
Smi [6],
Smi [14],
FIXED_ARRAY_TYPE,
Smi [495],
Smi [451],
Smi [6],
Smi [28],
Smi [35],
Smi [20],
Smi [23],
]
handlers: [
[52, 621, 627],
[55, 582, 584],
[146, 384, 390],
[149, 344, 346],
[451, 461, 463],
[52, 533, 539],
[55, 494, 496],
[102, 296, 302],
[105, 256, 258],
[363, 373, 375],
]
---
......@@ -702,7 +590,7 @@ snippet: "
"
frame size: 19
parameter count: 1
bytecode array length: 1084
bytecode array length: 1020
bytecodes: [
B(Mov), R(new_target), R(9),
B(Ldar), R(new_target),
......@@ -711,7 +599,7 @@ bytecodes: [
B(PushContext), R(11),
B(RestoreGeneratorState), R(9),
B(Star), R(10),
B(SwitchOnSmiNoFeedback), U8(0), U8(13), I8(0),
B(SwitchOnSmiNoFeedback), U8(0), U8(11), I8(0),
B(LdaSmi), I8(46),
B(Star), R(11),
B(CallRuntime), U16(Runtime::kAbort), R(11), U8(1),
......@@ -734,55 +622,38 @@ bytecodes: [
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(9), U8(1),
B(Star), R(15),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(9), U8(1),
B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(0),
B(Ldar), R(15),
/* 44 E> */ B(Throw),
B(Mov), R(9), R(16),
B(Mov), R(15), R(17),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(1),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(16),
B(LdaSmi), I8(-2),
B(Star), R(10),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(9), U8(1),
B(Star), R(16),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(9), U8(1),
B(Star), R(17),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(17),
B(JumpIfTrue), U8(5),
B(Ldar), R(16),
B(ReThrow),
B(LdaZero),
B(Star), R(11),
B(Mov), R(16), R(12),
B(JumpConstant), U8(39),
B(Mov), R(15), R(12),
B(JumpConstant), U8(36),
/* 49 S> */ B(LdaUndefined),
B(Star), R(1),
B(LdaZero),
B(Star), R(2),
B(LdaUndefined),
B(Star), R(3),
B(LdaGlobal), U8(15), U8(2),
B(LdaGlobal), U8(13), U8(2),
B(Star), R(17),
/* 56 E> */ B(CallUndefinedReceiver0), R(17), U8(0),
B(Star), R(15),
B(LdaNamedProperty), R(15), U8(16), U8(8),
B(LdaNamedProperty), R(15), U8(14), U8(8),
B(JumpIfUndefined), U8(17),
B(JumpIfNull), U8(15),
B(Star), R(16),
B(CallProperty0), R(16), R(15), U8(10),
B(JumpIfJSReceiver), U8(23),
B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0),
B(LdaNamedProperty), R(15), U8(17), U8(4),
B(LdaNamedProperty), R(15), U8(15), U8(4),
B(Star), R(16),
B(CallProperty0), R(16), R(15), U8(6),
B(Star), R(16),
B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(16), U8(1),
B(Star), R(4),
B(Ldar), R(10),
B(SwitchOnSmiNoFeedback), U8(18), U8(9), I8(2),
B(SwitchOnSmiNoFeedback), U8(16), U8(8), I8(1),
B(LdaSmi), I8(-2),
B(TestEqualStrictNoFeedback), R(10),
B(JumpIfTrue), U8(11),
......@@ -800,14 +671,14 @@ bytecodes: [
B(LdaSmi), I8(2),
B(TestEqualStrict), R(15), U8(29),
B(JumpIfTrue), U8(211),
B(JumpConstant), U8(33),
B(LdaNamedProperty), R(4), U8(27), U8(14),
B(JumpConstant), U8(30),
B(LdaNamedProperty), R(4), U8(24), U8(14),
B(Star), R(16),
B(CallProperty1), R(16), R(4), R(1), U8(12),
B(Star), R(17),
B(Mov), R(9), R(16),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(1),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(16),
B(LdaSmi), I8(-2),
......@@ -826,15 +697,15 @@ bytecodes: [
B(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
B(JumpConstant), U8(34),
B(LdaNamedProperty), R(4), U8(28), U8(17),
B(JumpConstant), U8(31),
B(LdaNamedProperty), R(4), U8(25), U8(17),
B(Star), R(3),
B(TestUndetectable),
B(JumpIfFalse), U8(54),
B(Mov), R(9), R(16),
B(Mov), R(1), R(17),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(3),
B(SuspendGenerator), R(9), R(0), U8(16), U8(2),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(16),
B(LdaSmi), I8(-2),
......@@ -851,7 +722,7 @@ bytecodes: [
B(LdaZero),
B(Star), R(11),
B(Mov), R(16), R(12),
B(JumpConstant), U8(40),
B(JumpConstant), U8(37),
B(Mov), R(3), R(16),
B(Mov), R(4), R(17),
B(Mov), R(1), R(18),
......@@ -859,7 +730,7 @@ bytecodes: [
B(Star), R(17),
B(Mov), R(9), R(16),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(4),
B(SuspendGenerator), R(9), R(0), U8(16), U8(3),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(16),
B(LdaSmi), I8(-2),
......@@ -878,12 +749,12 @@ bytecodes: [
B(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
B(JumpConstant), U8(35),
B(LdaNamedProperty), R(4), U8(29), U8(21),
B(JumpConstant), U8(32),
B(LdaNamedProperty), R(4), U8(26), U8(21),
B(Star), R(5),
B(TestUndetectable),
B(JumpIfFalse), U8(212),
B(LdaNamedProperty), R(4), U8(28), U8(24),
B(LdaNamedProperty), R(4), U8(25), U8(24),
B(Star), R(6),
B(TestUndetectable),
B(JumpIfFalse), U8(4),
......@@ -899,7 +770,7 @@ bytecodes: [
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(134),
B(Star), R(16),
B(LdaConstant), U8(30),
B(LdaConstant), U8(27),
B(Star), R(17),
B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2),
B(Throw),
......@@ -910,7 +781,7 @@ bytecodes: [
B(Star), R(18),
B(Mov), R(9), R(17),
B(CallJSRuntime), U8(%async_generator_await_caught), R(17), U8(2),
B(SuspendGenerator), R(9), R(0), U8(17), U8(5),
B(SuspendGenerator), R(9), R(0), U8(17), U8(4),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(17),
B(LdaSmi), I8(-2),
......@@ -928,7 +799,7 @@ bytecodes: [
B(Jump), U8(20),
B(Star), R(17),
B(Ldar), R(closure),
B(CreateCatchContext), R(17), U8(31), U8(32),
B(CreateCatchContext), R(17), U8(28), U8(29),
B(Star), R(16),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -942,7 +813,7 @@ bytecodes: [
B(Star), R(17),
B(Mov), R(9), R(16),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(6),
B(SuspendGenerator), R(9), R(0), U8(16), U8(5),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(16),
B(LdaSmi), I8(-2),
......@@ -963,7 +834,7 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(Wide), B(LdaSmi), I16(147),
B(Star), R(16),
B(LdaConstant), U8(30),
B(LdaConstant), U8(27),
B(Star), R(17),
B(CallRuntime), U16(Runtime::kNewTypeError), R(16), U8(2),
B(Throw),
......@@ -974,7 +845,7 @@ bytecodes: [
B(Star), R(17),
B(Mov), R(9), R(16),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(16), U8(2),
B(SuspendGenerator), R(9), R(0), U8(16), U8(7),
B(SuspendGenerator), R(9), R(0), U8(16), U8(6),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(16),
B(LdaSmi), I8(-2),
......@@ -994,14 +865,14 @@ bytecodes: [
B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
B(Jump), U8(2),
B(LdaNamedProperty), R(3), U8(36), U8(30),
B(LdaNamedProperty), R(3), U8(33), U8(30),
B(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(101),
B(LdaNamedProperty), R(3), U8(37), U8(32),
B(LdaNamedProperty), R(3), U8(34), U8(32),
B(Star), R(16),
B(Mov), R(9), R(15),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(15), U8(2),
B(SuspendGenerator), R(9), R(0), U8(15), U8(8),
B(SuspendGenerator), R(9), R(0), U8(15), U8(7),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(15),
B(LdaSmi), I8(-2),
......@@ -1021,7 +892,7 @@ bytecodes: [
B(Mov), R(9), R(15),
B(Mov), R(3), R(16),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(15), U8(3),
B(SuspendGenerator), R(9), R(0), U8(15), U8(9),
B(SuspendGenerator), R(9), R(0), U8(15), U8(8),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(15),
B(LdaSmi), I8(-2),
......@@ -1035,11 +906,11 @@ bytecodes: [
B(LdaSmi), I8(1),
B(TestEqualStrict), R(2), U8(34),
B(JumpIfFalse), U8(57),
B(LdaNamedProperty), R(3), U8(37), U8(35),
B(LdaNamedProperty), R(3), U8(34), U8(35),
B(Star), R(16),
B(Mov), R(9), R(15),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(15), U8(2),
B(SuspendGenerator), R(9), R(0), U8(15), U8(11),
B(SuspendGenerator), R(9), R(0), U8(15), U8(9),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(15),
B(LdaSmi), I8(-2),
......@@ -1057,13 +928,13 @@ bytecodes: [
B(Star), R(11),
B(Mov), R(15), R(12),
B(Jump), U8(111),
B(LdaNamedProperty), R(3), U8(37), U8(37),
B(LdaNamedProperty), R(3), U8(34), U8(37),
B(Star), R(8),
B(LdaUndefined),
B(Star), R(16),
B(Mov), R(9), R(15),
B(CallJSRuntime), U8(%async_generator_await_uncaught), R(15), U8(2),
B(SuspendGenerator), R(9), R(0), U8(15), U8(12),
B(SuspendGenerator), R(9), R(0), U8(15), U8(10),
/* 60 S> */ B(Return),
B(RestoreGeneratorRegisters), R(9), R(0), U8(15),
B(LdaSmi), I8(-2),
......@@ -1084,7 +955,7 @@ bytecodes: [
B(Jump), U8(39),
B(Star), R(15),
B(Ldar), R(closure),
B(CreateCatchContext), R(15), U8(31), U8(38),
B(CreateCatchContext), R(15), U8(28), U8(35),
B(Star), R(14),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -1112,43 +983,34 @@ bytecodes: [
B(Ldar), R(13),
B(SetPendingMessage),
B(Ldar), R(11),
B(SwitchOnSmiNoFeedback), U8(41), U8(3), I8(0),
B(Jump), U8(34),
B(SwitchOnSmiNoFeedback), U8(38), U8(3), I8(0),
B(Jump), U8(22),
B(LdaTrue),
B(Star), R(16),
B(Mov), R(0), R(14),
B(Mov), R(9), R(14),
B(Mov), R(12), R(15),
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(14), U8(3),
B(Star), R(17),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(9), U8(1),
B(Ldar), R(17),
/* 60 S> */ B(Return),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(9), U8(1),
B(Ldar), R(12),
/* 60 S> */ B(Return),
B(Ldar), R(12),
B(ReThrow),
B(LdaUndefined),
B(Star), R(11),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(9), U8(1),
B(Ldar), R(11),
/* 60 S> */ B(Return),
]
constant pool: [
Smi [46],
Smi [87],
Smi [181],
Smi [181],
Smi [181],
Smi [181],
Smi [181],
Smi [181],
Smi [181],
Smi [181],
Smi [181],
Smi [861],
Smi [919],
Smi [59],
Smi [137],
Smi [137],
Smi [137],
Smi [137],
Smi [137],
Smi [137],
Smi [137],
Smi [137],
Smi [817],
Smi [875],
Smi [15],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"],
SYMBOL_TYPE,
......@@ -1161,7 +1023,6 @@ constant pool: [
Smi [499],
Smi [572],
Smi [622],
ODDBALL_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["throw"],
......@@ -1177,12 +1038,12 @@ constant pool: [
Smi [885],
Smi [647],
Smi [6],
Smi [28],
Smi [35],
Smi [20],
Smi [23],
]
handlers: [
[52, 1011, 1017],
[55, 972, 974],
[509, 564, 566],
[52, 967, 973],
[55, 928, 930],
[465, 520, 522],
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment