Commit c3bd741e authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Fix "this" value in lazily-parsed module functions.

When preparsing top-level functions in a module, we didn't track
unresolved variables. Consequently, "this" ended up referencing
the global "this", which has the wrong value (in a module "this"
is supposed to be the undefined value).

This patch fixes that. This also lets us stop forcing context
allocation of all variables in module scopes, which the patch
takes care of as well.

Bug: chromium:791334
Change-Id: Ifac1f1adc033f3facfb3d29dd4bca32ee27bffcf
Reviewed-on: https://chromium-review.googlesource.com/808938Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50025}
parent ccd15eaf
......@@ -147,8 +147,6 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type)
DCHECK_NE(SCRIPT_SCOPE, scope_type);
SetDefaults();
set_language_mode(outer_scope->language_mode());
force_context_allocation_ =
!is_function_scope() && outer_scope->has_forced_context_allocation();
outer_scope_->AddInnerScope(this);
}
......@@ -1370,12 +1368,8 @@ bool Scope::AllowsLazyParsingWithoutUnresolvedVariables(
if (s->is_catch_scope()) continue;
// With scopes do not introduce variables that need allocation.
if (s->is_with_scope()) continue;
// Module scopes context-allocate all variables, and have no
// {this} or {arguments} variables whose existence depends on
// references to them.
if (s->is_module_scope()) continue;
// Only block scopes and function scopes should disallow preparsing.
DCHECK(s->is_block_scope() || s->is_function_scope());
DCHECK(s->is_module_scope() || s->is_block_scope() ||
s->is_function_scope());
return false;
}
return true;
......@@ -1734,9 +1728,6 @@ void Scope::Print(int n) {
if (scope->was_lazily_parsed()) Indent(n1, "// lazily parsed\n");
if (scope->ShouldEagerCompile()) Indent(n1, "// will be compiled\n");
}
if (has_forced_context_allocation()) {
Indent(n1, "// forces context allocation\n");
}
if (num_stack_slots_ > 0) {
Indent(n1, "// ");
PrintF("%d stack slots\n", num_stack_slots_);
......@@ -2111,11 +2102,8 @@ bool Scope::MustAllocateInContext(Variable* var) {
// an eval() call or a runtime with lookup), it must be allocated in the
// context.
//
// Exceptions: If the scope as a whole has forced context allocation, all
// variables will have context allocation, even temporaries. Otherwise
// temporary variables are always stack-allocated. Catch-bound variables are
// Temporary variables are always stack-allocated. Catch-bound variables are
// always context-allocated.
if (has_forced_context_allocation()) return true;
if (var->mode() == TEMPORARY) return false;
if (is_catch_scope()) return true;
if ((is_script_scope() || is_eval_scope()) &&
......
......@@ -334,14 +334,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
bool is_hidden() const { return is_hidden_; }
void set_is_hidden() { is_hidden_ = true; }
// In some cases we want to force context allocation for a whole scope.
void ForceContextAllocation() {
DCHECK(!already_resolved_);
force_context_allocation_ = true;
}
bool has_forced_context_allocation() const {
return force_context_allocation_;
}
void ForceContextAllocationForParameters() {
DCHECK(!already_resolved_);
force_context_allocation_for_parameters_ = true;
......
......@@ -690,7 +690,6 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
var->AllocateTo(VariableLocation::PARAMETER, 0);
PrepareGeneratorVariables();
scope->ForceContextAllocation();
Expression* initial_yield =
BuildInitialYield(kNoSourcePosition, kGeneratorFunction);
body->Add(
......
......@@ -11,52 +11,49 @@ top level: yes
snippet: "
import \"bar\";
"
frame size: 5
frame size: 6
parameter count: 2
bytecode array length: 96
bytecode array length: 91
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(0),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(2),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(arg0), R(3),
B(Mov), R(closure), R(4),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(3), U8(3),
B(PushContext), R(3),
B(Mov), R(this), R(5),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
B(Star), R(0),
/* 0 E> */ B(StackCheck),
B(Star), R(1),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(0),
/* 13 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(4),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(4),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(4),
/* 13 S> */ B(Return),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), U8(5),
B(Mov), R(4), R(1),
B(Ldar), R(1),
/* 13 S> */ B(Return),
]
constant pool: [
Smi [47],
Smi [43],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......@@ -68,52 +65,49 @@ handlers: [
snippet: "
import {foo} from \"bar\";
"
frame size: 5
frame size: 6
parameter count: 2
bytecode array length: 96
bytecode array length: 91
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(0),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(2),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(arg0), R(3),
B(Mov), R(closure), R(4),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(3), U8(3),
B(PushContext), R(3),
B(Mov), R(this), R(5),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
B(Star), R(0),
/* 0 E> */ B(StackCheck),
B(Star), R(1),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(0),
/* 24 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(4),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(4),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(4),
/* 24 S> */ B(Return),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), U8(5),
B(Mov), R(4), R(1),
B(Ldar), R(1),
/* 24 S> */ B(Return),
]
constant pool: [
Smi [47],
Smi [43],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......@@ -127,76 +121,66 @@ snippet: "
goo(42);
{ let x; { goo(42) } };
"
frame size: 6
frame size: 7
parameter count: 2
bytecode array length: 140
bytecode array length: 121
bytecodes: [
B(Ldar), R(1),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(PushContext), R(4),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(Star), R(3),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(3),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(Star), R(6),
B(Mov), R(arg0), R(4),
B(Mov), R(closure), R(5),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(4), U8(3),
B(PushContext), R(4),
B(Mov), R(this), R(6),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(5), U8(2),
B(Star), R(1),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 0 E> */ B(StackCheck),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(5), U8(0),
/* 64 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(1), R(0), U8(5),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(5),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(5),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(5),
/* 64 S> */ B(Return),
/* 32 S> */ B(LdaModuleVariable), I8(-1), U8(0),
B(ThrowReferenceErrorIfHole), U8(4),
B(Star), R(3),
B(Star), R(5),
B(LdaSmi), I8(42),
B(Star), R(4),
/* 32 E> */ B(CallUndefinedReceiver1), R(3), R(4), U8(0),
B(Ldar), R(closure),
B(CreateBlockContext), U8(5),
B(PushContext), R(3),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
B(Star), R(6),
/* 32 E> */ B(CallUndefinedReceiver1), R(5), R(6), U8(0),
/* 47 S> */ B(LdaUndefined),
/* 47 E> */ B(StaCurrentContextSlot), U8(4),
/* 52 S> */ B(LdaModuleVariable), I8(-1), U8(1),
B(Star), R(0),
/* 52 S> */ B(LdaModuleVariable), I8(-1), U8(0),
B(ThrowReferenceErrorIfHole), U8(4),
B(Star), R(4),
B(LdaSmi), I8(42),
B(Star), R(5),
/* 52 E> */ B(CallUndefinedReceiver1), R(4), R(5), U8(2),
B(StaContextSlot), R(3), U8(5), U8(0),
B(PopContext), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaSmi), I8(42),
B(Star), R(6),
/* 52 E> */ B(CallUndefinedReceiver1), R(5), R(6), U8(2),
B(Star), R(2),
/* 64 S> */ B(Return),
]
constant pool: [
Smi [47],
Smi [43],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["goo"],
FIXED_ARRAY_TYPE,
]
handlers: [
]
......@@ -207,74 +191,64 @@ snippet: "
foo++;
{ let x; { foo++ } };
"
frame size: 5
frame size: 7
parameter count: 2
bytecode array length: 137
bytecode array length: 119
bytecodes: [
B(Ldar), R(1),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(PushContext), R(4),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(Star), R(3),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(3),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(Star), R(6),
B(Mov), R(arg0), R(4),
B(Mov), R(closure), R(5),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(4), U8(3),
B(PushContext), R(4),
B(Mov), R(this), R(6),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(5), U8(2),
B(Star), R(1),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 0 E> */ B(StackCheck),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(5), U8(0),
/* 49 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(1), R(0), U8(5),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(5),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(5),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(5),
/* 49 S> */ B(Return),
/* 17 S> */ B(LdaSmi), I8(42),
/* 17 E> */ B(StaModuleVariable), I8(1), U8(0),
/* 21 S> */ B(LdaModuleVariable), I8(1), U8(0),
B(Inc), U8(0),
/* 24 E> */ B(StaModuleVariable), I8(1), U8(0),
B(Ldar), R(closure),
B(CreateBlockContext), U8(4),
B(PushContext), R(3),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
/* 34 S> */ B(LdaUndefined),
/* 34 E> */ B(StaCurrentContextSlot), U8(4),
/* 39 S> */ B(LdaModuleVariable), I8(1), U8(1),
B(Star), R(0),
/* 39 S> */ B(LdaModuleVariable), I8(1), U8(0),
B(ToNumeric), U8(1),
B(Star), R(4),
B(Star), R(5),
B(Inc), U8(1),
/* 42 E> */ B(StaModuleVariable), I8(1), U8(1),
B(Ldar), R(4),
B(StaContextSlot), R(3), U8(5), U8(0),
B(PopContext), R(3),
B(LdaCurrentContextSlot), U8(5),
/* 42 E> */ B(StaModuleVariable), I8(1), U8(0),
B(Mov), R(5), R(2),
B(Ldar), R(2),
/* 49 S> */ B(Return),
]
constant pool: [
Smi [47],
Smi [43],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
FIXED_ARRAY_TYPE,
]
handlers: [
]
......@@ -285,76 +259,67 @@ snippet: "
foo++;
{ let x; { foo++ } };
"
frame size: 5
frame size: 7
parameter count: 2
bytecode array length: 141
bytecode array length: 125
bytecodes: [
B(Ldar), R(1),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(PushContext), R(4),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(Star), R(3),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(3),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(6),
B(Mov), R(arg0), R(4),
B(Mov), R(closure), R(5),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(4), U8(3),
B(PushContext), R(4),
B(Mov), R(this), R(6),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(5), U8(2),
B(Star), R(1),
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
B(Ldar), R(1),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(5), U8(0),
/* 49 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(1), R(0), U8(5),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(5),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(5),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(5),
/* 49 S> */ B(Return),
/* 17 S> */ B(LdaSmi), I8(42),
/* 17 E> */ B(StaModuleVariable), I8(1), U8(0),
/* 21 S> */ B(LdaModuleVariable), I8(1), U8(0),
B(Inc), U8(0),
/* 24 E> */ B(StaModuleVariable), I8(1), U8(0),
B(Ldar), R(closure),
B(CreateBlockContext), U8(4),
B(PushContext), R(3),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
/* 34 S> */ B(LdaUndefined),
/* 34 E> */ B(StaCurrentContextSlot), U8(4),
/* 39 S> */ B(LdaModuleVariable), I8(1), U8(1),
B(Star), R(0),
/* 39 S> */ B(LdaModuleVariable), I8(1), U8(0),
B(ToNumeric), U8(1),
B(Star), R(4),
B(Star), R(5),
B(Inc), U8(1),
/* 42 E> */ B(StaModuleVariable), I8(1), U8(1),
B(Ldar), R(4),
B(StaContextSlot), R(3), U8(5), U8(0),
B(PopContext), R(3),
B(LdaCurrentContextSlot), U8(5),
/* 42 E> */ B(StaModuleVariable), I8(1), U8(0),
B(Mov), R(5), R(2),
B(Ldar), R(2),
/* 49 S> */ B(Return),
]
constant pool: [
Smi [51],
Smi [49],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
FIXED_ARRAY_TYPE,
]
handlers: [
]
......@@ -365,76 +330,67 @@ snippet: "
foo++;
{ let x; { foo++ } };
"
frame size: 5
frame size: 7
parameter count: 2
bytecode array length: 145
bytecode array length: 129
bytecodes: [
B(Ldar), R(1),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(PushContext), R(4),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(Star), R(3),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(3),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(6),
B(Mov), R(arg0), R(4),
B(Mov), R(closure), R(5),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(4), U8(3),
B(PushContext), R(4),
B(Mov), R(this), R(6),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(5), U8(2),
B(Star), R(1),
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
B(Ldar), R(1),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(5), U8(0),
/* 51 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(1), R(0), U8(5),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(5),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(5),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(5),
/* 51 S> */ B(Return),
/* 19 S> */ B(LdaSmi), I8(42),
/* 19 E> */ B(StaModuleVariable), I8(1), U8(0),
/* 23 S> */ B(LdaModuleVariable), I8(1), U8(0),
B(Inc), U8(0),
/* 26 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0),
B(Ldar), R(closure),
B(CreateBlockContext), U8(4),
B(PushContext), R(3),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
/* 36 S> */ B(LdaUndefined),
/* 36 E> */ B(StaCurrentContextSlot), U8(4),
/* 41 S> */ B(LdaModuleVariable), I8(1), U8(1),
B(Star), R(0),
/* 41 S> */ B(LdaModuleVariable), I8(1), U8(0),
B(ToNumeric), U8(1),
B(Star), R(4),
B(Star), R(5),
B(Inc), U8(1),
/* 44 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0),
B(Ldar), R(4),
B(StaContextSlot), R(3), U8(5), U8(0),
B(PopContext), R(3),
B(LdaCurrentContextSlot), U8(5),
B(Mov), R(5), R(2),
B(Ldar), R(2),
/* 51 S> */ B(Return),
]
constant pool: [
Smi [51],
Smi [49],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
FIXED_ARRAY_TYPE,
]
handlers: [
]
......@@ -443,56 +399,54 @@ handlers: [
snippet: "
export default (function () {});
"
frame size: 5
frame size: 6
parameter count: 2
bytecode array length: 107
bytecode array length: 104
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(0),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(2),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(1),
B(Star), R(5),
B(Mov), R(arg0), R(3),
B(Mov), R(closure), R(4),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(3), U8(3),
B(PushContext), R(3),
B(Mov), R(this), R(5),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
B(Star), R(0),
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
B(Ldar), R(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(0),
/* 32 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(4),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(4),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(4),
/* 32 S> */ B(Return),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
B(Mov), R(4), R(1),
B(CreateClosure), U8(4), U8(0), U8(0),
B(StaModuleVariable), I8(1), U8(0),
B(LdaCurrentContextSlot), U8(5),
B(Ldar), R(1),
/* 32 S> */ B(Return),
]
constant pool: [
Smi [51],
Smi [49],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......@@ -505,65 +459,63 @@ handlers: [
snippet: "
export default (class {});
"
frame size: 7
frame size: 8
parameter count: 2
bytecode array length: 128
bytecode array length: 125
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(0),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(2),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(1),
B(Star), R(5),
B(Mov), R(arg0), R(3),
B(Mov), R(closure), R(4),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(3), U8(3),
B(PushContext), R(3),
B(Mov), R(this), R(5),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
B(Star), R(0),
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
B(Ldar), R(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(0),
/* 26 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(4),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(4),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(4),
/* 26 S> */ B(Return),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
B(Mov), R(4), R(1),
B(LdaTheHole),
B(Star), R(6),
B(Star), R(7),
B(CreateClosure), U8(5), U8(0), U8(0),
B(Star), R(3),
B(LdaConstant), U8(4),
B(Star), R(4),
B(Mov), R(3), R(5),
B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(3),
B(Star), R(4),
B(Ldar), R(5),
B(LdaConstant), U8(4),
B(Star), R(5),
B(Mov), R(4), R(6),
B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(3),
B(Star), R(5),
B(Ldar), R(6),
B(StaModuleVariable), I8(1), U8(0),
B(LdaCurrentContextSlot), U8(5),
B(Ldar), R(1),
/* 26 S> */ B(Return),
]
constant pool: [
Smi [51],
Smi [49],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......@@ -577,52 +529,49 @@ handlers: [
snippet: "
export {foo as goo} from \"bar\"
"
frame size: 5
frame size: 6
parameter count: 2
bytecode array length: 96
bytecode array length: 91
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(0),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(2),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(arg0), R(3),
B(Mov), R(closure), R(4),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(3), U8(3),
B(PushContext), R(3),
B(Mov), R(this), R(5),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
B(Star), R(0),
/* 0 E> */ B(StackCheck),
B(Star), R(1),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(0),
/* 30 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(4),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(4),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(4),
/* 30 S> */ B(Return),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), U8(5),
B(Mov), R(4), R(1),
B(Ldar), R(1),
/* 30 S> */ B(Return),
]
constant pool: [
Smi [47],
Smi [43],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......@@ -634,52 +583,49 @@ handlers: [
snippet: "
export * from \"bar\"
"
frame size: 5
frame size: 6
parameter count: 2
bytecode array length: 96
bytecode array length: 91
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(0),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(2),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(arg0), R(3),
B(Mov), R(closure), R(4),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(3), U8(3),
B(PushContext), R(3),
B(Mov), R(this), R(5),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
B(Star), R(0),
/* 0 E> */ B(StackCheck),
B(Star), R(1),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(0),
/* 19 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(4),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(4),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(4),
/* 19 S> */ B(Return),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), U8(5),
B(Mov), R(4), R(1),
B(Ldar), R(1),
/* 19 S> */ B(Return),
]
constant pool: [
Smi [47],
Smi [43],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......@@ -692,66 +638,58 @@ snippet: "
import * as foo from \"bar\"
foo.f(foo, foo.x);
"
frame size: 7
frame size: 9
parameter count: 2
bytecode array length: 134
bytecode array length: 118
bytecodes: [
B(Ldar), R(1),
B(Ldar), R(0),
B(JumpIfUndefined), U8(18),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(2),
B(RestoreGeneratorState), R(1),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(0), U8(1),
B(PushContext), R(4),
B(RestoreGeneratorState), R(0),
B(Star), R(3),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Abort), U8(42),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(Star), R(3),
B(LdaConstant), U8(1),
B(Star), R(4),
B(Mov), R(arg0), R(2),
B(Mov), R(closure), R(3),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(2), U8(3),
B(PushContext), R(2),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(4),
B(Star), R(1),
B(Star), R(6),
B(Mov), R(arg0), R(4),
B(Mov), R(closure), R(5),
B(CallRuntime), U16(Runtime::kPushModuleContext), R(4), U8(3),
B(PushContext), R(4),
B(Mov), R(this), R(6),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(5), U8(2),
B(Star), R(0),
B(LdaZero),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kGetModuleNamespace), R(3), U8(1),
B(StaCurrentContextSlot), U8(5),
B(Star), R(5),
B(CallRuntime), U16(Runtime::kGetModuleNamespace), R(5), U8(1),
B(Star), R(1),
/* 0 E> */ B(StackCheck),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 0 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
B(Ldar), R(0),
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(5), U8(0),
/* 45 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(RestoreGeneratorRegisters), R(0), R(0), U8(5),
B(LdaSmi), I8(-2),
B(Star), R(0),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(0), U8(1),
B(Star), R(5),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
B(Ldar), R(5),
/* 0 E> */ B(Throw),
B(Ldar), R(3),
B(Ldar), R(5),
/* 45 S> */ B(Return),
/* 27 S> */ B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
/* 31 E> */ B(LdaNamedProperty), R(4), U8(4), U8(0),
B(Star), R(3),
B(LdaImmutableCurrentContextSlot), U8(5),
/* 31 S> */ B(LdaNamedProperty), R(1), U8(4), U8(0),
B(Star), R(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(6),
/* 42 E> */ B(LdaNamedProperty), R(6), U8(5), U8(2),
B(Star), R(6),
/* 31 E> */ B(CallProperty2), R(3), R(4), R(5), R(6), U8(4),
B(StaCurrentContextSlot), U8(6),
B(LdaCurrentContextSlot), U8(6),
/* 42 E> */ B(LdaNamedProperty), R(1), U8(5), U8(2),
B(Star), R(8),
/* 31 E> */ B(CallProperty2), R(5), R(1), R(1), R(8), U8(4),
B(Star), R(2),
/* 45 S> */ B(Return),
]
constant pool: [
Smi [57],
Smi [55],
FIXED_ARRAY_TYPE,
Smi [10],
Smi [7],
......
......@@ -6224,9 +6224,9 @@ TEST(ModuleParsingInternals) {
CHECK(declarations->AtForTest(8)->proxy()->raw_name()->IsOneByteEqualTo(
"nonexport"));
CHECK(declarations->AtForTest(8)->proxy()->var()->binding_needs_init());
CHECK(declarations->AtForTest(8)->proxy()->var()->location() !=
i::VariableLocation::MODULE);
CHECK(!declarations->AtForTest(8)->proxy()->var()->binding_needs_init());
CHECK(declarations->AtForTest(8)->proxy()->var()->location() ==
i::VariableLocation::LOCAL);
CHECK(
declarations->AtForTest(9)->proxy()->raw_name()->IsOneByteEqualTo("mm"));
......
......@@ -271,7 +271,7 @@ let salad = 12;
function listener(event, exec_state) {
if (event == Debug.DebugEvent.Break) {
let scope_count = exec_state.frame().scopeCount();
let module_scope = exec_state.frame().scope(2);
let module_scope = exec_state.frame().scope(1);
assertEquals(debug.ScopeType.Module, module_scope.scopeType());
module_scope.setVariableValue('salad', 42);
}
......@@ -311,7 +311,7 @@ export let ham = 1;
function listener(event, exec_state) {
if (event == Debug.DebugEvent.Break) {
let scope_count = exec_state.frame().scopeCount();
let module_scope = exec_state.frame().scope(2);
let module_scope = exec_state.frame().scope(1);
assertEquals(debug.ScopeType.Module, module_scope.scopeType());
module_scope.setVariableValue('ham', 2);
}
......
......@@ -139,10 +139,10 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent(
{local_var: undefined, exported_var: undefined, imported_var: undefined},
{exported_var: undefined, imported_var: undefined},
0, exec_state);
CheckScopeDoesNotHave(
["doesnotexist", "local_let", "exported_let", "imported_let"],
["local_var", "doesntexist", "local_let", "exported_let", "imported_let"],
0, exec_state);
};
debugger;
......@@ -161,8 +161,9 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent(
{local_let: 1, local_var: 2, exported_let: 3, exported_var: 4,
{exported_let: 3, exported_var: 4,
imported_let: 3, imported_var: 4}, 0, exec_state);
CheckScopeDoesNotHave(["local_var", "local_let"], 0, exec_state);
};
debugger;
EndTest();
......@@ -178,8 +179,9 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent(
{local_let: 11, local_var: 12, exported_let: 13, exported_var: 14,
{exported_let: 13, exported_var: 14,
imported_let: 13, imported_var: 14}, 0, exec_state);
CheckScopeDoesNotHave(["local_var", "local_let"], 0, exec_state);
};
debugger;
EndTest();
......@@ -12,9 +12,8 @@ local:foo1
module
[
[0] : a1 = 10
[1] : g1 = 1
[2] : b1 = 11
[3] : foo1 = function foo1() { let c1 = 12; let g1 = 2; debugger; return a1 + b1 + c1 + g1; }
[1] : b1 = 11
[2] : foo1 = function foo1() { let c1 = 12; let g1 = 2; debugger; return a1 + b1 + c1 + g1; }
]
global
[
......@@ -180,9 +179,8 @@ foo2 =
}
module
[
[0] : a3 = 30
[1] : foo2 = function foo2() { let c2 = 22; return foo1() + a2 + b2 + c2; }
[2] : b3 = 31
[0] : foo2 = function foo2() { let c2 = 22; return foo1() + a2 + b2 + c2; }
[1] : b3 = 31
]
global
[
......@@ -200,20 +198,6 @@ Array =
objectId : <objectId>
type : function
}
a3 =
{
description : 30
type : number
value : 30
}
Evaluating: ++a3
updated a3 =
{
description : 31
type : number
value : 31
}
Evaluating: --a3
foo2 =
{
className : Function
......@@ -247,12 +231,6 @@ closure:bar
[
[0] : a = 0
]
module
[
[0] : a = 1
[1] : b = 2
[2] : bar = function bar() { let a = 0; (() => {a; debugger;})(); }
]
global
[
...
......@@ -283,37 +261,10 @@ updated a =
value : 1
}
Evaluating: --a
b =
{
description : 2
type : number
value : 2
}
Evaluating: ++b
updated b =
{
description : 3
type : number
value : 3
}
Evaluating: --b
bar =
{
className : Function
description : function bar() { let a = 0; (() => {a; debugger;})(); }
objectId : <objectId>
type : function
}
local:bar
[
[0] : a = 0
]
module
[
[0] : a = 1
[1] : b = 2
[2] : bar = function bar() { let a = 0; (() => {a; debugger;})(); }
]
global
[
...
......@@ -344,33 +295,6 @@ updated a =
value : 1
}
Evaluating: --a
b =
{
description : 2
type : number
value : 2
}
Evaluating: ++b
updated b =
{
description : 3
type : number
value : 3
}
Evaluating: --b
bar =
{
className : Function
description : function bar() { let a = 0; (() => {a; debugger;})(); }
objectId : <objectId>
type : function
}
module
[
[0] : a = 1
[1] : b = 2
[2] : bar = function bar() { let a = 0; (() => {a; debugger;})(); }
]
global
[
...
......@@ -386,41 +310,6 @@ Array =
objectId : <objectId>
type : function
}
a =
{
description : 1
type : number
value : 1
}
Evaluating: ++a
updated a =
{
description : 2
type : number
value : 2
}
Evaluating: --a
b =
{
description : 2
type : number
value : 2
}
Evaluating: ++b
updated b =
{
description : 3
type : number
value : 3
}
Evaluating: --b
bar =
{
className : Function
description : function bar() { let a = 0; (() => {a; debugger;})(); }
objectId : <objectId>
type : function
}
Running test: testDifferentModuleVariables
(anonymous) (module5:5:0)
......@@ -503,3 +392,112 @@ updated c =
value : 1
}
Evaluating: --c
Running test: testCapturedLocalVariable
(anonymous) (module6:2:25)
(anonymous) (module6:2:37)
local
[
[0] : y = 5
]
module
[
[0] : x = 5
]
global
[
...
]
Check variables in frame#0
let x = 5;
(function() { let y = x; #debugger; })()
Array =
{
className : Function
description : function Array() { [native code] }
objectId : <objectId>
type : function
}
y =
{
description : 5
type : number
value : 5
}
Evaluating: ++y
updated y =
{
description : 6
type : number
value : 6
}
Evaluating: --y
x =
{
description : 5
type : number
value : 5
}
Evaluating: ++x
updated x =
{
description : 6
type : number
value : 6
}
Evaluating: --x
module
[
[0] : x = 5
]
global
[
...
]
Check variables in frame#1
let x = 5;
(function() { let y = x; debugger; })#()
Array =
{
className : Function
description : function Array() { [native code] }
objectId : <objectId>
type : function
}
x =
{
description : 5
type : number
value : 5
}
Evaluating: ++x
updated x =
{
description : 6
type : number
value : 6
}
Evaluating: --x
Running test: testLocalVariableToplevel
(anonymous) (module7:2:0)
global
[
...
]
Check variables in frame#0
let x = 5;
#debugger;
Array =
{
className : Function
description : function Array() { [native code] }
objectId : <objectId>
type : function
}
......@@ -49,6 +49,16 @@ export var c = 0;
debugger;
`;
var module6 = `
let x = 5;
(function() { let y = x; debugger; })()
`;
var module7 = `
let x = 5;
debugger;
`;
InspectorTest.runAsyncTestSuite([
async function testTotal() {
session.setupScriptMap();
......@@ -82,6 +92,26 @@ InspectorTest.runAsyncTestSuite([
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
},
async function testCapturedLocalVariable() {
contextGroup.addModule(module6, 'module6');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
},
async function testLocalVariableToplevel() {
contextGroup.addModule(module7, 'module7');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
}
]);
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// MODULE
let foo = () => { return this };
assertEquals(undefined, foo());
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