Commit ece4e54a authored by hablich's avatar hablich Committed by Commit bot

Revert of Thread maybe-assigned through the bytecodes. (patchset #5 id:80001...

Revert of Thread maybe-assigned through the bytecodes. (patchset #5 id:80001 of https://codereview.chromium.org/2655733003/ )

Reason for revert:
needed for properly reverting https://chromium.googlesource.com/v8/v8/+/f3ae5ccf57690d8c2d87c4fe1d10b103ad6a4ab3

Original issue's description:
> 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}
> Committed: https://chromium.googlesource.com/v8/v8/+/17c2dd388697da626224c371c8181d20d2016d82

TBR=rmcilroy@chromium.org,bmeurer@chromium.org,neis@chromium.org,jarin@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2680923003
Cr-Commit-Position: refs/heads/master@{#43011}
parent f3ae5ccf
......@@ -770,6 +770,9 @@ 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);
......@@ -780,31 +783,16 @@ 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,20 +477,12 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(
Register context, int slot_index, int depth,
ContextSlotMutability mutability) {
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context,
int slot_index,
int depth) {
if (context.is_current_context() && depth == 0) {
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,10 +92,8 @@ 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,
ContextSlotMutability immutable);
int depth);
// Stores the object in the accumulator into |slot_index| at |depth| in the
// context chain starting with |context|.
......
......@@ -1936,13 +1936,7 @@ void BytecodeGenerator::BuildVariableLoad(Variable* variable, FeedbackSlot slot,
context_reg = execution_context()->reg();
}
BytecodeArrayBuilder::ContextSlotMutability immutable =
(variable->maybe_assigned() == kNotAssigned)
? BytecodeArrayBuilder::kImmutableSlot
: BytecodeArrayBuilder::kMutableSlot;
builder()->LoadContextSlot(context_reg, variable->index(), depth,
immutable);
builder()->LoadContextSlot(context_reg, variable->index(), depth);
if (hole_check_mode == HoleCheckMode::kRequired) {
BuildThrowIfHole(variable->name());
}
......@@ -2106,8 +2100,7 @@ void BytecodeGenerator::BuildVariableAssignment(Variable* variable,
Register value_temp = register_allocator()->NewRegister();
builder()
->StoreAccumulatorInRegister(value_temp)
.LoadContextSlot(context_reg, variable->index(), depth,
BytecodeArrayBuilder::kMutableSlot);
.LoadContextSlot(context_reg, variable->index(), depth);
BuildHoleCheckForVariableAssignment(variable, op);
builder()->LoadAccumulatorWithRegister(value_temp);
......@@ -2737,11 +2730,9 @@ void BytecodeGenerator::VisitDelete(UnaryOperation* expr) {
Register global_object = register_allocator()->NewRegister();
builder()
->LoadContextSlot(execution_context()->reg(),
Context::NATIVE_CONTEXT_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot)
Context::NATIVE_CONTEXT_INDEX, 0)
.StoreAccumulatorInRegister(native_context)
.LoadContextSlot(native_context, Context::EXTENSION_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot)
.LoadContextSlot(native_context, Context::EXTENSION_INDEX, 0)
.StoreAccumulatorInRegister(global_object)
.LoadLiteral(variable->name())
.Delete(global_object, language_mode());
......@@ -3252,18 +3243,15 @@ void BytecodeGenerator::VisitFunctionClosureForContext() {
Register native_context = register_allocator()->NewRegister();
builder()
->LoadContextSlot(execution_context()->reg(),
Context::NATIVE_CONTEXT_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot)
Context::NATIVE_CONTEXT_INDEX, 0)
.StoreAccumulatorInRegister(native_context)
.LoadContextSlot(native_context, Context::CLOSURE_INDEX, 0,
BytecodeArrayBuilder::kMutableSlot);
.LoadContextSlot(native_context, Context::CLOSURE_INDEX, 0);
} 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,
BytecodeArrayBuilder::kMutableSlot);
Context::CLOSURE_INDEX, 0);
} else {
DCHECK(closure_scope->is_function_scope() ||
closure_scope->is_module_scope());
......
......@@ -51,10 +51,7 @@ namespace interpreter {
V(PopContext, AccumulatorUse::kNone, OperandType::kReg) \
V(LdaContextSlot, AccumulatorUse::kWrite, OperandType::kReg, \
OperandType::kIdx, OperandType::kUImm) \
V(LdaImmutableContextSlot, AccumulatorUse::kWrite, OperandType::kReg, \
OperandType::kIdx, OperandType::kUImm) \
V(LdaCurrentContextSlot, AccumulatorUse::kWrite, OperandType::kIdx) \
V(LdaImmutableCurrentContextSlot, AccumulatorUse::kWrite, OperandType::kIdx) \
V(StaContextSlot, AccumulatorUse::kRead, OperandType::kReg, \
OperandType::kIdx, OperandType::kUImm) \
V(StaCurrentContextSlot, AccumulatorUse::kRead, OperandType::kIdx) \
......@@ -513,9 +510,7 @@ class V8_EXPORT_PRIVATE Bytecodes final {
bytecode == Bytecode::kLdaTheHole ||
bytecode == Bytecode::kLdaConstant ||
bytecode == Bytecode::kLdaContextSlot ||
bytecode == Bytecode::kLdaCurrentContextSlot ||
bytecode == Bytecode::kLdaImmutableContextSlot ||
bytecode == Bytecode::kLdaImmutableCurrentContextSlot;
bytecode == Bytecode::kLdaCurrentContextSlot;
}
// Return true if |bytecode| is a register load without effects,
......
......@@ -557,15 +557,6 @@ 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.
......@@ -577,15 +568,6 @@ 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
/* 74 S> */ B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
/* 93 S> */ B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
/* 36 S> */ B(LdaCurrentContextSlot), 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(LdaImmutableContextSlot), R(1), U8(5), U8(0),
B(LdaContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
/* 72 S> */ B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(5),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(6),
/* 27 S> */ B(LdaCurrentContextSlot), U8(6),
B(Star), R(4),
/* 30 E> */ B(LdaNamedProperty), R(4), U8(1), U8(4),
B(Star), R(3),
B(LdaImmutableCurrentContextSlot), U8(6),
B(LdaCurrentContextSlot), U8(6),
B(Star), R(5),
B(LdaImmutableCurrentContextSlot), U8(6),
B(LdaCurrentContextSlot), 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(LdaImmutableContextSlot), R(context), U8(4), U8(1),
/* 102 S> */ B(LdaContextSlot), R(context), U8(4), U8(1),
B(Star), R(0),
B(LdaImmutableCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), 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(LdaImmutableCurrentContextSlot), U8(4),
/* 102 S> */ B(LdaCurrentContextSlot), 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,19 +86,12 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
// Emit context operations.
builder.PushContext(reg)
.PopContext(reg)
.LoadContextSlot(reg, 1, 0, BytecodeArrayBuilder::kMutableSlot)
.StoreContextSlot(reg, 1, 0)
.LoadContextSlot(reg, 2, 0, BytecodeArrayBuilder::kImmutableSlot)
.StoreContextSlot(reg, 3, 0);
.LoadContextSlot(reg, 1, 0)
.StoreContextSlot(reg, 1, 0);
// Emit context operations which operate on the local context.
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);
builder.LoadContextSlot(Register::current_context(), 1, 0)
.StoreContextSlot(Register::current_context(), 1, 0);
// Emit load / store property operations.
builder.LoadNamedProperty(reg, name, 0)
......@@ -334,8 +327,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
DataPropertyInLiteralFlag::kNoFlags, 0);
// Emit wide context operations.
builder.LoadContextSlot(reg, 1024, 0, BytecodeArrayBuilder::kMutableSlot)
.StoreContextSlot(reg, 1024, 0);
builder.LoadContextSlot(reg, 1024, 0).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