Commit 17c2dd38 authored by jarin's avatar jarin Committed by Commit bot

Thread maybe-assigned through the bytecodes.

This introduces LoadImmutableContextSlot and LoadImmutableCurrentContextSlot
bytecodes, which are emitted when reading from never-assigned context slot.

There is a subtlety here: the slot are not immutable, the meaning is
actually undefined-or-hole-or-immutable.

Review-Url: https://codereview.chromium.org/2655733003
Cr-Commit-Position: refs/heads/master@{#43000}
parent 32971301
......@@ -770,9 +770,6 @@ void BytecodeGraphBuilder::VisitStaDataPropertyInLiteral() {
}
void BytecodeGraphBuilder::VisitLdaContextSlot() {
// TODO(mythria): immutable flag is also set to false. This information is not
// available in bytecode array. update this code when the implementation
// changes.
const Operator* op = javascript()->LoadContext(
bytecode_iterator().GetUnsignedImmediateOperand(2),
bytecode_iterator().GetIndexOperand(1), false);
......@@ -783,16 +780,31 @@ void BytecodeGraphBuilder::VisitLdaContextSlot() {
environment()->BindAccumulator(node);
}
void BytecodeGraphBuilder::VisitLdaImmutableContextSlot() {
const Operator* op = javascript()->LoadContext(
bytecode_iterator().GetUnsignedImmediateOperand(2),
bytecode_iterator().GetIndexOperand(1), true);
Node* node = NewNode(op);
Node* context =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
NodeProperties::ReplaceContextInput(node, context);
environment()->BindAccumulator(node);
}
void BytecodeGraphBuilder::VisitLdaCurrentContextSlot() {
// TODO(mythria): immutable flag is also set to false. This information is not
// available in bytecode array. update this code when the implementation
// changes.
const Operator* op = javascript()->LoadContext(
0, bytecode_iterator().GetIndexOperand(0), false);
Node* node = NewNode(op);
environment()->BindAccumulator(node);
}
void BytecodeGraphBuilder::VisitLdaImmutableCurrentContextSlot() {
const Operator* op = javascript()->LoadContext(
0, bytecode_iterator().GetIndexOperand(0), true);
Node* node = NewNode(op);
environment()->BindAccumulator(node);
}
void BytecodeGraphBuilder::VisitStaContextSlot() {
const Operator* op = javascript()->StoreContext(
bytecode_iterator().GetUnsignedImmediateOperand(2),
......
......@@ -477,12 +477,20 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context,
int slot_index,
int depth) {
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(
Register context, int slot_index, int depth,
ContextSlotMutability mutability) {
if (context.is_current_context() && depth == 0) {
OutputLdaCurrentContextSlot(slot_index);
if (mutability == kImmutableSlot) {
OutputLdaImmutableCurrentContextSlot(slot_index);
} else {
DCHECK_EQ(kMutableSlot, mutability);
OutputLdaCurrentContextSlot(slot_index);
}
} else if (mutability == kImmutableSlot) {
OutputLdaImmutableContextSlot(context, slot_index, depth);
} else {
DCHECK_EQ(mutability, kMutableSlot);
OutputLdaContextSlot(context, slot_index, depth);
}
return *this;
......
......@@ -92,8 +92,10 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final
// Load the object at |slot_index| at |depth| in the context chain starting
// with |context| into the accumulator.
enum ContextSlotMutability { kImmutableSlot, kMutableSlot };
BytecodeArrayBuilder& LoadContextSlot(Register context, int slot_index,
int depth);
int depth,
ContextSlotMutability immutable);
// Stores the object in the accumulator into |slot_index| at |depth| in the
// context chain starting with |context|.
......
......@@ -1942,7 +1942,13 @@ void BytecodeGenerator::BuildVariableLoad(Variable* variable,
context_reg = execution_context()->reg();
}
builder()->LoadContextSlot(context_reg, variable->index(), depth);
BytecodeArrayBuilder::ContextSlotMutability immutable =
(variable->maybe_assigned() == kNotAssigned)
? BytecodeArrayBuilder::kImmutableSlot
: BytecodeArrayBuilder::kMutableSlot;
builder()->LoadContextSlot(context_reg, variable->index(), depth,
immutable);
if (hole_check_mode == HoleCheckMode::kRequired) {
BuildThrowIfHole(variable->name());
}
......@@ -2106,7 +2112,8 @@ void BytecodeGenerator::BuildVariableAssignment(Variable* variable,
Register value_temp = register_allocator()->NewRegister();
builder()
->StoreAccumulatorInRegister(value_temp)
.LoadContextSlot(context_reg, variable->index(), depth);
.LoadContextSlot(context_reg, variable->index(), depth,
BytecodeArrayBuilder::kMutableSlot);
BuildHoleCheckForVariableAssignment(variable, op);
builder()->LoadAccumulatorWithRegister(value_temp);
......@@ -2737,9 +2744,11 @@ void BytecodeGenerator::VisitDelete(UnaryOperation* expr) {
Register global_object = register_allocator()->NewRegister();
builder()
->LoadContextSlot(execution_context()->reg(),
Context::NATIVE_CONTEXT_INDEX, 0)
Context::NATIVE_CONTEXT_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot)
.StoreAccumulatorInRegister(native_context)
.LoadContextSlot(native_context, Context::EXTENSION_INDEX, 0)
.LoadContextSlot(native_context, Context::EXTENSION_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot)
.StoreAccumulatorInRegister(global_object)
.LoadLiteral(variable->name())
.Delete(global_object, language_mode());
......@@ -3251,15 +3260,18 @@ void BytecodeGenerator::VisitFunctionClosureForContext() {
Register native_context = register_allocator()->NewRegister();
builder()
->LoadContextSlot(execution_context()->reg(),
Context::NATIVE_CONTEXT_INDEX, 0)
Context::NATIVE_CONTEXT_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot)
.StoreAccumulatorInRegister(native_context)
.LoadContextSlot(native_context, Context::CLOSURE_INDEX, 0);
.LoadContextSlot(native_context, Context::CLOSURE_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot);
} else if (closure_scope->is_eval_scope()) {
// Contexts created by a call to eval have the same closure as the
// context calling eval, not the anonymous closure containing the eval
// code. Fetch it from the context.
builder()->LoadContextSlot(execution_context()->reg(),
Context::CLOSURE_INDEX, 0);
Context::CLOSURE_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot);
} else {
DCHECK(closure_scope->is_function_scope() ||
closure_scope->is_module_scope());
......
This diff is collapsed.
......@@ -556,6 +556,15 @@ void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) {
__ Dispatch();
}
// LdaImmutableContextSlot <context> <slot_index> <depth>
//
// Load the object in |slot_index| of the context at |depth| in the context
// chain starting at |context| into the accumulator.
void Interpreter::DoLdaImmutableContextSlot(InterpreterAssembler* assembler) {
// TODO(danno) Share the actual code object rather creating a duplicate one.
DoLdaContextSlot(assembler);
}
// LdaCurrentContextSlot <slot_index>
//
// Load the object in |slot_index| of the current context into the accumulator.
......@@ -567,6 +576,15 @@ void Interpreter::DoLdaCurrentContextSlot(InterpreterAssembler* assembler) {
__ Dispatch();
}
// LdaImmutableCurrentContextSlot <slot_index>
//
// Load the object in |slot_index| of the current context into the accumulator.
void Interpreter::DoLdaImmutableCurrentContextSlot(
InterpreterAssembler* assembler) {
// TODO(danno) Share the actual code object rather creating a duplicate one.
DoLdaCurrentContextSlot(assembler);
}
// StaContextSlot <context> <slot_index> <depth>
//
// Stores the object in the accumulator into |slot_index| of the context at
......
......@@ -142,7 +142,7 @@ bytecodes: [
B(Mov), R(4), R(6),
B(CallRuntime), U16(Runtime::kDefineClass), R(5), U8(4),
B(Star), R(5),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 75 E> */ B(ToName), R(7),
B(CreateClosure), U8(3), U8(3), U8(2),
B(Star), R(8),
......@@ -150,7 +150,7 @@ bytecodes: [
B(Star), R(9),
B(Ldar), R(8),
B(StaDataPropertyInLiteral), R(5), R(7), U8(3), U8(5),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
/* 106 E> */ B(ToName), R(7),
B(LdaConstant), U8(4),
B(TestEqualStrict), R(7), U8(0),
......
......@@ -48,7 +48,7 @@ bytecodes: [
/* 30 E> */ B(StackCheck),
/* 44 S> */ B(LdaSmi), I8(10),
/* 44 E> */ B(StaCurrentContextSlot), U8(4),
/* 74 S> */ B(LdaCurrentContextSlot), U8(4),
/* 74 S> */ B(LdaImmutableCurrentContextSlot), U8(4),
/* 84 S> */ B(Return),
]
constant pool: [
......
......@@ -107,7 +107,7 @@ bytecodes: [
B(Ldar), R(1),
/* 56 E> */ B(StaCurrentContextSlot), U8(4),
/* 64 S> */ B(CreateClosure), U8(1), U8(3), U8(2),
/* 93 S> */ B(LdaCurrentContextSlot), U8(4),
/* 93 S> */ B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(1),
B(LdaSmi), I8(1),
B(DeletePropertyStrict), R(1),
......
......@@ -57,7 +57,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), I8(1),
B(Star), R(4),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1),
B(PopContext), R(8),
......@@ -202,7 +202,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), I8(1),
B(Star), R(5),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(14),
B(CallRuntime), U16(Runtime::kReThrow), R(14), U8(1),
B(PopContext), R(9),
......@@ -360,7 +360,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), I8(1),
B(Star), R(4),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1),
B(PopContext), R(8),
......@@ -508,7 +508,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), I8(1),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kReThrow), R(12), U8(1),
B(PopContext), R(7),
......
......@@ -35,13 +35,13 @@ bytecodes: [
B(StaCurrentContextSlot), U8(4),
/* 11 E> */ B(StackCheck),
B(Mov), R(context), R(5),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(7),
B(Mov), R(closure), R(6),
/* 11 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(6), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(6),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(7),
B(LdaZero),
B(SuspendGenerator), R(7),
......@@ -88,7 +88,7 @@ bytecodes: [
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(5),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(6),
B(CallRuntime), U16(Runtime::k_GeneratorClose), R(6), U8(1),
B(Ldar), R(5),
......@@ -150,13 +150,13 @@ bytecodes: [
B(StaCurrentContextSlot), U8(4),
/* 11 E> */ B(StackCheck),
B(Mov), R(context), R(5),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(7),
B(Mov), R(closure), R(6),
/* 11 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(6), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(6),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(7),
B(LdaZero),
B(SuspendGenerator), R(7),
......@@ -191,7 +191,7 @@ bytecodes: [
B(Star), R(7),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(6), U8(2),
B(Star), R(6),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(7),
B(LdaSmi), I8(1),
B(SuspendGenerator), R(7),
......@@ -238,7 +238,7 @@ bytecodes: [
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(5),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(6),
B(CallRuntime), U16(Runtime::k_GeneratorClose), R(6), U8(1),
B(Ldar), R(5),
......@@ -305,13 +305,13 @@ bytecodes: [
B(StaCurrentContextSlot), U8(4),
/* 11 E> */ B(StackCheck),
B(Mov), R(context), R(7),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(9),
B(Mov), R(closure), R(8),
/* 11 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(8), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(8),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(9),
B(LdaZero),
B(SuspendGenerator), R(9),
......@@ -399,13 +399,13 @@ bytecodes: [
B(StaCurrentContextSlot), U8(4),
B(LdaContextSlot), R(1), U8(6), U8(0),
B(StaCurrentContextSlot), U8(4),
/* 36 S> */ B(LdaCurrentContextSlot), U8(4),
/* 36 S> */ B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(12),
B(LdaFalse),
B(Star), R(13),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(12), U8(2),
B(Star), R(12),
B(LdaContextSlot), R(1), U8(5), U8(0),
B(LdaImmutableContextSlot), R(1), U8(5), U8(0),
B(Star), R(13),
B(LdaSmi), I8(1),
B(SuspendGenerator), R(13),
......@@ -457,7 +457,7 @@ bytecodes: [
B(JumpIfFalse), U8(8),
B(LdaSmi), I8(1),
B(StaContextSlot), R(1), U8(9), U8(0),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kReThrow), R(12), U8(1),
B(PopContext), R(2),
......@@ -573,7 +573,7 @@ bytecodes: [
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(7),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(8),
B(CallRuntime), U16(Runtime::k_GeneratorClose), R(8), U8(1),
B(Ldar), R(7),
......
......@@ -48,7 +48,7 @@ bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), I8(10),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
/* 72 S> */ B(LdaCurrentContextSlot), U8(4),
/* 72 S> */ B(LdaImmutableCurrentContextSlot), U8(4),
/* 82 S> */ B(Return),
]
constant pool: [
......
......@@ -38,13 +38,13 @@ bytecodes: [
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -110,13 +110,13 @@ bytecodes: [
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -184,13 +184,13 @@ bytecodes: [
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(closure), R(4),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(5),
B(LdaZero),
B(SuspendGenerator), R(5),
......@@ -290,13 +290,13 @@ bytecodes: [
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(closure), R(4),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(5),
B(LdaZero),
B(SuspendGenerator), R(5),
......@@ -383,13 +383,13 @@ bytecodes: [
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(closure), R(4),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(5),
B(LdaZero),
B(SuspendGenerator), R(5),
......@@ -476,13 +476,13 @@ bytecodes: [
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(5),
B(Mov), R(closure), R(4),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(4), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(5),
B(LdaZero),
B(SuspendGenerator), R(5),
......@@ -567,13 +567,13 @@ bytecodes: [
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -644,13 +644,13 @@ bytecodes: [
B(LdaTheHole),
B(StaModuleVariable), I8(1), U8(0),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -733,13 +733,13 @@ bytecodes: [
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -805,13 +805,13 @@ bytecodes: [
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -882,13 +882,13 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kGetModuleNamespace), R(3), U8(1),
B(StaCurrentContextSlot), U8(6),
/* 0 E> */ B(StackCheck),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(4),
B(Mov), R(closure), R(3),
/* 0 E> */ B(CallRuntime), U16(Runtime::kCreateJSGeneratorObject), R(3), U8(2),
B(StaCurrentContextSlot), U8(5),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(5),
B(LdaImmutableCurrentContextSlot), U8(5),
B(Star), R(4),
B(LdaZero),
B(SuspendGenerator), R(4),
......@@ -914,13 +914,13 @@ bytecodes: [
/* 45 S> */ B(Return),
B(Ldar), R(5),
/* 0 E> */ B(Throw),
/* 27 S> */ B(LdaCurrentContextSlot), U8(6),
/* 27 S> */ B(LdaImmutableCurrentContextSlot), U8(6),
B(Star), R(4),
/* 30 E> */ B(LdaNamedProperty), R(4), U8(1), U8(4),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(6),
B(LdaImmutableCurrentContextSlot), U8(6),
B(Star), R(5),
B(LdaCurrentContextSlot), U8(6),
B(LdaImmutableCurrentContextSlot), U8(6),
B(Star), R(6),
/* 41 E> */ B(LdaNamedProperty), R(6), U8(2), U8(6),
B(Star), R(6),
......
......@@ -23,9 +23,9 @@ parameter count: 1
bytecode array length: 13
bytecodes: [
/* 97 E> */ B(StackCheck),
/* 102 S> */ B(LdaContextSlot), R(context), U8(4), U8(1),
/* 102 S> */ B(LdaImmutableContextSlot), R(context), U8(4), U8(1),
B(Star), R(0),
B(LdaCurrentContextSlot), U8(4),
B(LdaImmutableCurrentContextSlot), U8(4),
/* 118 E> */ B(Mul), R(0), U8(2),
/* 130 S> */ B(Return),
]
......@@ -51,7 +51,7 @@ parameter count: 1
bytecode array length: 9
bytecodes: [
/* 97 E> */ B(StackCheck),
/* 102 S> */ B(LdaCurrentContextSlot), U8(4),
/* 102 S> */ B(LdaImmutableCurrentContextSlot), U8(4),
/* 111 E> */ B(StaContextSlot), R(context), U8(4), U8(1),
B(LdaUndefined),
/* 123 S> */ B(Return),
......
// 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.
// Flags: --allow-natives-syntax
function h(g) {
return g();
}
function f() {
var g;
for (var i = 0; i < 10; i++) {
var y = i;
if (i === 5) {
g = function() {
return y;
};
assertEquals(5, h(g));
assertEquals(5, h(g));
%OptimizeFunctionOnNextCall(h);
assertEquals(5, h(g));
}
}
return g;
}
var myg = f();
assertEquals(9, h(myg));
......@@ -86,12 +86,19 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
// Emit context operations.
builder.PushContext(reg)
.PopContext(reg)
.LoadContextSlot(reg, 1, 0)
.StoreContextSlot(reg, 1, 0);
.LoadContextSlot(reg, 1, 0, BytecodeArrayBuilder::kMutableSlot)
.StoreContextSlot(reg, 1, 0)
.LoadContextSlot(reg, 2, 0, BytecodeArrayBuilder::kImmutableSlot)
.StoreContextSlot(reg, 3, 0);
// Emit context operations which operate on the local context.
builder.LoadContextSlot(Register::current_context(), 1, 0)
.StoreContextSlot(Register::current_context(), 1, 0);
builder
.LoadContextSlot(Register::current_context(), 1, 0,
BytecodeArrayBuilder::kMutableSlot)
.StoreContextSlot(Register::current_context(), 1, 0)
.LoadContextSlot(Register::current_context(), 2, 0,
BytecodeArrayBuilder::kImmutableSlot)
.StoreContextSlot(Register::current_context(), 3, 0);
// Emit load / store property operations.
builder.LoadNamedProperty(reg, name, 0)
......@@ -327,7 +334,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
DataPropertyInLiteralFlag::kNoFlags, 0);
// Emit wide context operations.
builder.LoadContextSlot(reg, 1024, 0).StoreContextSlot(reg, 1024, 0);
builder.LoadContextSlot(reg, 1024, 0, BytecodeArrayBuilder::kMutableSlot)
.StoreContextSlot(reg, 1024, 0);
// Emit wide load / store lookup slots.
builder.LoadLookupSlot(wide_name, TypeofMode::NOT_INSIDE_TYPEOF)
......
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