Commit d2caa302 authored by leszeks's avatar leszeks Committed by Commit bot

[ignition] Add bytecodes for loads/stores in the current context

The majority of context slot accesses are to the local context (current context
register and depth 0), so this adds bytecodes to optimise for that case.

This cuts down bytecode size by roughly 1% (measured on Octane and Top25).

Review-Url: https://codereview.chromium.org/2459513002
Cr-Commit-Position: refs/heads/master@{#40641}
parent 3c2e3797
......@@ -809,16 +809,36 @@ Node* BytecodeGraphBuilder::BuildLoadContextSlot() {
return NewNode(op, context);
}
Node* BytecodeGraphBuilder::BuildLoadCurrentContextSlot() {
// 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* context = environment()->Context();
return NewNode(op, context);
}
void BytecodeGraphBuilder::VisitLdaContextSlot() {
Node* node = BuildLoadContextSlot();
environment()->BindAccumulator(node);
}
void BytecodeGraphBuilder::VisitLdaCurrentContextSlot() {
Node* node = BuildLoadCurrentContextSlot();
environment()->BindAccumulator(node);
}
void BytecodeGraphBuilder::VisitLdrContextSlot() {
Node* node = BuildLoadContextSlot();
environment()->BindRegister(bytecode_iterator().GetRegisterOperand(3), node);
}
void BytecodeGraphBuilder::VisitLdrCurrentContextSlot() {
Node* node = BuildLoadCurrentContextSlot();
environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), node);
}
void BytecodeGraphBuilder::VisitStaContextSlot() {
const Operator* op = javascript()->StoreContext(
bytecode_iterator().GetUnsignedImmediateOperand(2),
......@@ -829,6 +849,14 @@ void BytecodeGraphBuilder::VisitStaContextSlot() {
NewNode(op, context, value);
}
void BytecodeGraphBuilder::VisitStaCurrentContextSlot() {
const Operator* op =
javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(0));
Node* context = environment()->Context();
Node* value = environment()->LookupAccumulator();
NewNode(op, context, value);
}
void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) {
PrepareEagerCheckpoint();
Node* name =
......
......@@ -135,6 +135,7 @@ class BytecodeGraphBuilder {
void BuildCreateArguments(CreateArgumentsType type);
Node* BuildLoadContextSlot();
Node* BuildLoadCurrentContextSlot();
Node* BuildLoadGlobal(uint32_t feedback_slot_index, TypeofMode typeof_mode);
void BuildStoreGlobal(LanguageMode language_mode);
Node* BuildNamedLoad();
......
......@@ -461,14 +461,22 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context,
int slot_index,
int depth) {
if (context.is_current_context() && depth == 0) {
OutputLdaCurrentContextSlot(slot_index);
} else {
OutputLdaContextSlot(context, slot_index, depth);
}
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::StoreContextSlot(Register context,
int slot_index,
int depth) {
if (context.is_current_context() && depth == 0) {
OutputStaCurrentContextSlot(slot_index);
} else {
OutputStaContextSlot(context, slot_index, depth);
}
return *this;
}
......
......@@ -54,10 +54,14 @@ namespace interpreter {
V(PopContext, AccumulatorUse::kNone, OperandType::kReg) \
V(LdaContextSlot, AccumulatorUse::kWrite, OperandType::kReg, \
OperandType::kIdx, OperandType::kUImm) \
V(LdaCurrentContextSlot, AccumulatorUse::kWrite, OperandType::kIdx) \
V(LdrContextSlot, AccumulatorUse::kNone, OperandType::kReg, \
OperandType::kIdx, OperandType::kUImm, OperandType::kRegOut) \
V(LdrCurrentContextSlot, AccumulatorUse::kNone, OperandType::kIdx, \
OperandType::kRegOut) \
V(StaContextSlot, AccumulatorUse::kRead, OperandType::kReg, \
OperandType::kIdx, OperandType::kUImm) \
V(StaCurrentContextSlot, AccumulatorUse::kRead, OperandType::kIdx) \
\
/* Load-Store lookup slots */ \
V(LdaLookupSlot, AccumulatorUse::kWrite, OperandType::kIdx) \
......
......@@ -544,6 +544,13 @@ compiler::Node* Interpreter::BuildLoadContextSlot(
return __ LoadContextSlot(slot_context, slot_index);
}
compiler::Node* Interpreter::BuildLoadCurrentContextSlot(
InterpreterAssembler* assembler) {
Node* slot_index = __ BytecodeOperandIdx(0);
Node* slot_context = __ GetContext();
return __ LoadContextSlot(slot_context, slot_index);
}
// LdaContextSlot <context> <slot_index> <depth>
//
// Load the object in |slot_index| of the context at |depth| in the context
......@@ -554,6 +561,15 @@ void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) {
__ Dispatch();
}
// LdaCurrentContextSlot <slot_index>
//
// Load the object in |slot_index| of the current context into the accumulator.
void Interpreter::DoLdaCurrentContextSlot(InterpreterAssembler* assembler) {
Node* result = BuildLoadCurrentContextSlot(assembler);
__ SetAccumulator(result);
__ Dispatch();
}
// LdrContextSlot <context> <slot_index> <depth> <reg>
//
// Load the object in |slot_index| of the context at |depth| in the context
......@@ -565,6 +581,16 @@ void Interpreter::DoLdrContextSlot(InterpreterAssembler* assembler) {
__ Dispatch();
}
// LdrCurrentContextSlot <slot_index> <reg>
//
// Load the object in |slot_index| of the current context into register |reg|.
void Interpreter::DoLdrCurrentContextSlot(InterpreterAssembler* assembler) {
Node* result = BuildLoadCurrentContextSlot(assembler);
Node* destination = __ BytecodeOperandReg(1);
__ StoreRegister(result, destination);
__ Dispatch();
}
// StaContextSlot <context> <slot_index> <depth>
//
// Stores the object in the accumulator into |slot_index| of the context at
......@@ -580,6 +606,18 @@ void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) {
__ Dispatch();
}
// StaCurrentContextSlot <slot_index>
//
// Stores the object in the accumulator into |slot_index| of the current
// context.
void Interpreter::DoStaCurrentContextSlot(InterpreterAssembler* assembler) {
Node* value = __ GetAccumulator();
Node* slot_index = __ BytecodeOperandIdx(0);
Node* slot_context = __ GetContext();
__ StoreContextSlot(slot_context, slot_index, value);
__ Dispatch();
}
void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id,
InterpreterAssembler* assembler) {
Node* name_index = __ BytecodeOperandIdx(0);
......
......@@ -142,6 +142,9 @@ class Interpreter {
// Generates code to load a context slot.
compiler::Node* BuildLoadContextSlot(InterpreterAssembler* assembler);
// Generates code to load a slot in the current context.
compiler::Node* BuildLoadCurrentContextSlot(InterpreterAssembler* assembler);
// Generates code to load a global.
compiler::Node* BuildLoadGlobal(Callable ic, compiler::Node* context,
compiler::Node* feedback_slot,
......
......@@ -98,6 +98,9 @@ PeepholeActionAndData PeepholeActionTableWriter::LookupActionAndData(
case Bytecode::kLdaContextSlot:
return {PeepholeAction::kTransformLdaStarToLdrLdarAction,
Bytecode::kLdrContextSlot};
case Bytecode::kLdaCurrentContextSlot:
return {PeepholeAction::kTransformLdaStarToLdrLdarAction,
Bytecode::kLdrCurrentContextSlot};
case Bytecode::kLdaUndefined:
return {PeepholeAction::kTransformLdaStarToLdrLdarAction,
Bytecode::kLdrUndefined};
......
......@@ -679,34 +679,34 @@ snippet: "
"
frame size: 4
parameter count: 1
bytecode array length: 63
bytecode array length: 53
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaZero),
B(Star), R(1),
/* 52 S> */ B(Ldar), R(1),
B(JumpIfToBooleanFalse), U8(55),
B(JumpIfToBooleanFalse), U8(45),
/* 45 E> */ B(StackCheck),
B(Ldar), R(closure),
B(CreateBlockContext), U8(0),
B(PushContext), R(3),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(1), U8(2),
B(Star), R(0),
/* 73 S> */ B(LdaSmi), U8(1),
/* 73 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 73 E> */ B(StaCurrentContextSlot), U8(4),
B(Mov), R(0), R(2),
/* 106 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 106 S> */ B(LdaCurrentContextSlot), U8(4),
B(JumpIfToBooleanFalse), U8(8),
/* 113 S> */ B(PopContext), R(3),
B(PopContext), R(3),
B(Jump), U8(14),
/* 126 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
B(Jump), U8(10),
/* 126 S> */ B(LdaCurrentContextSlot), U8(4),
B(Inc), U8(2),
/* 127 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 127 E> */ B(StaCurrentContextSlot), U8(4),
B(PopContext), R(3),
B(JumpLoop), U8(-54), U8(0),
B(JumpLoop), U8(-44), U8(0),
B(LdaUndefined),
/* 137 S> */ B(Return),
]
......
......@@ -101,18 +101,18 @@ snippet: "
"
frame size: 3
parameter count: 1
bytecode array length: 34
bytecode array length: 30
bytecodes: [
/* 30 E> */ B(StackCheck),
B(Ldar), R(closure),
B(CreateBlockContext), U8(0),
B(PushContext), R(2),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(1), U8(2),
B(Star), R(0),
/* 53 S> */ B(LdaSmi), U8(10),
/* 53 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 53 E> */ B(StaCurrentContextSlot), U8(4),
B(Mov), R(0), R(1),
B(Ldar), R(0),
/* 88 S> */ B(Jump), U8(2),
......@@ -142,34 +142,34 @@ snippet: "
"
frame size: 4
parameter count: 1
bytecode array length: 67
bytecode array length: 53
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(2),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(1),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
B(Ldar), R(closure),
B(CreateBlockContext), U8(0),
B(PushContext), R(3),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(1), U8(2),
B(Star), R(0),
/* 76 S> */ B(LdaSmi), U8(2),
/* 76 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 76 E> */ B(StaCurrentContextSlot), U8(4),
B(Mov), R(0), R(1),
/* 118 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 118 S> */ B(LdaCurrentContextSlot), U8(4),
B(JumpIfToBooleanFalse), U8(6),
/* 125 S> */ B(PopContext), R(3),
B(Jump), U8(10),
B(Jump), U8(8),
/* 142 S> */ B(LdaSmi), U8(3),
/* 144 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 144 E> */ B(StaCurrentContextSlot), U8(4),
B(PopContext), R(3),
/* 155 S> */ B(LdaSmi), U8(4),
/* 157 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 157 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 162 S> */ B(Return),
]
......
......@@ -11,16 +11,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 89
bytecode array length: 83
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 30 E> */ B(StackCheck),
/* 34 S> */ B(CreateClosure), U8(0), U8(2),
/* 36 E> */ B(StaLookupSlotSloppy), U8(1),
......
......@@ -122,7 +122,7 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 128
bytecode array length: 120
bytecodes: [
B(CreateFunctionContext), U8(2),
B(PushContext), R(3),
......@@ -130,9 +130,9 @@ bytecodes: [
B(Star), R(2),
/* 30 E> */ B(StackCheck),
/* 43 S> */ B(LdaConstant), U8(0),
/* 43 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 43 E> */ B(StaCurrentContextSlot), U8(4),
/* 57 S> */ B(LdaConstant), U8(1),
/* 57 E> */ B(StaContextSlot), R(context), U8(5), U8(0),
/* 57 E> */ B(StaCurrentContextSlot), U8(5),
B(LdaTheHole),
B(Star), R(0),
/* 62 S> */ B(LdaTheHole),
......@@ -146,7 +146,7 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kDefineClass), R(4), U8(4),
B(Star), R(4),
B(LdrNamedProperty), R(4), U8(3), U8(2), R(5),
/* 75 E> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 75 E> */ B(LdaCurrentContextSlot), U8(4),
B(ToName), R(7),
B(CreateClosure), U8(4), U8(2),
B(Star), R(8),
......@@ -156,7 +156,7 @@ bytecodes: [
B(Star), R(10),
B(Mov), R(5), R(6),
B(CallRuntime), U16(Runtime::kDefineDataPropertyInLiteral), R(6), U8(5),
/* 106 E> */ B(LdaContextSlot), R(context), U8(5), U8(0),
/* 106 E> */ B(LdaCurrentContextSlot), U8(5),
B(ToName), R(7),
B(LdaConstant), U8(3),
B(TestEqualStrict), R(7), U8(0),
......@@ -194,7 +194,7 @@ snippet: "
"
frame size: 8
parameter count: 1
bytecode array length: 62
bytecode array length: 60
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(3),
......@@ -202,7 +202,7 @@ bytecodes: [
B(Star), R(2),
/* 30 E> */ B(StackCheck),
/* 46 S> */ B(LdaZero),
/* 46 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 46 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaTheHole),
B(Star), R(0),
/* 49 S> */ B(LdaTheHole),
......
......@@ -107,17 +107,17 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 29
bytecode array length: 23
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(0),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(1),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
/* 45 S> */ B(CreateClosure), U8(0), U8(2),
/* 75 S> */ B(LdrContextSlot), R(context), U8(4), U8(0), R(1),
/* 75 S> */ B(LdrCurrentContextSlot), U8(4), R(1),
B(BitwiseOrSmi), U8(24), R(1), U8(2),
/* 77 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 77 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 84 S> */ B(Return),
]
......
......@@ -11,17 +11,17 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 23
bytecode array length: 19
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 44 S> */ B(LdaSmi), U8(10),
/* 44 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 44 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 74 S> */ B(Return),
]
......@@ -37,18 +37,18 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 26
bytecode array length: 20
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 44 S> */ B(LdaSmi), U8(10),
/* 44 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 74 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 44 E> */ B(StaCurrentContextSlot), U8(4),
/* 74 S> */ B(LdaCurrentContextSlot), U8(4),
/* 84 S> */ B(Return),
]
constant pool: [
......@@ -63,24 +63,24 @@ snippet: "
"
frame size: 4
parameter count: 1
bytecode array length: 45
bytecode array length: 39
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 47 S> */ B(LdaSmi), U8(20),
B(Star), R(2),
/* 47 E> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 47 E> */ B(LdaCurrentContextSlot), U8(4),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(1),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0),
/* 47 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 47 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 80 S> */ B(Return),
]
......@@ -97,17 +97,17 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 30
bytecode array length: 26
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 44 S> */ B(LdaSmi), U8(10),
/* 44 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 44 E> */ B(StaCurrentContextSlot), U8(4),
/* 48 S> */ B(LdaSmi), U8(20),
/* 50 E> */ B(CallRuntime), U16(Runtime::kThrowConstAssignError), R(0), U8(0),
B(LdaUndefined),
......
......@@ -13,12 +13,12 @@ snippet: "
"
frame size: 1
parameter count: 2
bytecode array length: 15
bytecode array length: 13
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(0),
B(Ldar), R(arg0),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
/* 10 E> */ B(StackCheck),
/* 19 S> */ B(CreateClosure), U8(0), U8(2),
/* 52 S> */ B(Return),
......@@ -36,16 +36,16 @@ snippet: "
"
frame size: 2
parameter count: 2
bytecode array length: 21
bytecode array length: 17
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(Ldar), R(arg0),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
/* 10 E> */ B(StackCheck),
/* 27 S> */ B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 53 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 53 S> */ B(LdaCurrentContextSlot), U8(4),
/* 66 S> */ B(Return),
]
constant pool: [
......@@ -61,14 +61,14 @@ snippet: "
"
frame size: 1
parameter count: 5
bytecode array length: 21
bytecode array length: 17
bytecodes: [
B(CreateFunctionContext), U8(2),
B(PushContext), R(0),
B(Ldar), R(arg0),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
B(Ldar), R(arg2),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
/* 10 E> */ B(StackCheck),
/* 29 S> */ B(CreateClosure), U8(0), U8(2),
/* 61 S> */ B(Return),
......@@ -86,13 +86,13 @@ snippet: "
"
frame size: 1
parameter count: 1
bytecode array length: 15
bytecode array length: 13
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(0),
/* 10 E> */ B(StackCheck),
/* 26 S> */ B(Ldar), R(this),
/* 26 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 26 E> */ B(StaCurrentContextSlot), U8(4),
/* 32 S> */ B(CreateClosure), U8(0), U8(2),
/* 65 S> */ B(Return),
]
......
......@@ -197,18 +197,18 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 27
bytecode array length: 21
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(1),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
/* 53 S> */ B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 78 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 78 S> */ B(LdaCurrentContextSlot), U8(4),
B(Inc), U8(2),
/* 87 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 87 E> */ B(StaCurrentContextSlot), U8(4),
/* 90 S> */ B(Return),
]
constant pool: [
......@@ -223,19 +223,19 @@ snippet: "
"
frame size: 3
parameter count: 1
bytecode array length: 31
bytecode array length: 25
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(1),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
/* 53 S> */ B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 78 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 78 S> */ B(LdaCurrentContextSlot), U8(4),
B(ToNumber), R(2),
B(Dec), U8(2),
/* 86 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 86 E> */ B(StaCurrentContextSlot), U8(4),
B(Ldar), R(2),
/* 90 S> */ B(Return),
]
......
......@@ -74,12 +74,12 @@ snippet: "
"
frame size: 2
parameter count: 2
bytecode array length: 19
bytecode array length: 17
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(Ldar), R(arg0),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(Star), R(0),
/* 10 E> */ B(StackCheck),
......@@ -99,16 +99,16 @@ snippet: "
"
frame size: 2
parameter count: 4
bytecode array length: 28
bytecode array length: 22
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(1),
B(Ldar), R(arg0),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(arg1),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
B(Ldar), R(arg2),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(Star), R(0),
/* 10 E> */ B(StackCheck),
......
......@@ -98,16 +98,16 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 29
bytecode array length: 25
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(0),
/* 30 E> */ B(StackCheck),
/* 56 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(1),
B(Ldar), R(1),
/* 56 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 56 E> */ B(StaCurrentContextSlot), U8(4),
/* 64 S> */ B(CreateClosure), U8(1), U8(2),
/* 93 S> */ B(LdrContextSlot), R(context), U8(4), U8(0), R(1),
/* 93 S> */ B(LdrCurrentContextSlot), U8(4), R(1),
B(LdaSmi), U8(1),
B(DeletePropertyStrict), R(1),
/* 113 S> */ B(Return),
......
......@@ -11,16 +11,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 69
bytecode array length: 63
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 30 E> */ B(StackCheck),
/* 34 S> */ B(LdaConstant), U8(0),
B(Star), R(4),
......
......@@ -11,7 +11,7 @@ snippet: "
"
frame size: 15
parameter count: 1
bytecode array length: 279
bytecode array length: 277
bytecodes: [
/* 30 E> */ B(StackCheck),
B(LdaZero),
......@@ -42,7 +42,7 @@ bytecodes: [
B(LdaZero),
B(Star), R(4),
B(JumpLoop), U8(-49), U8(0),
B(Jump), U8(37),
B(Jump), U8(35),
B(Star), R(13),
B(Ldar), R(closure),
B(CreateCatchContext), R(13), U8(5), U8(6),
......@@ -53,7 +53,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), U8(1),
B(Star), R(4),
B(LdrContextSlot), R(context), U8(4), U8(0), R(13),
B(LdrCurrentContextSlot), U8(4), R(13),
B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1),
B(PopContext), R(8),
B(LdaSmi), U8(-1),
......@@ -137,9 +137,9 @@ constant pool: [
FIXED_ARRAY_TYPE,
]
handlers: [
[7, 118, 124],
[7, 116, 122],
[10, 81, 83],
[201, 211, 213],
[199, 209, 211],
]
---
......@@ -149,7 +149,7 @@ snippet: "
"
frame size: 16
parameter count: 1
bytecode array length: 290
bytecode array length: 288
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaConstant), U8(0),
......@@ -180,8 +180,8 @@ bytecodes: [
/* 73 S> */ B(LdaZero),
B(Star), R(10),
B(Mov), R(1), R(11),
B(Jump), U8(51),
B(Jump), U8(37),
B(Jump), U8(49),
B(Jump), U8(35),
B(Star), R(14),
B(Ldar), R(closure),
B(CreateCatchContext), R(14), U8(5), U8(6),
......@@ -192,7 +192,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), U8(1),
B(Star), R(5),
B(LdrContextSlot), R(context), U8(4), U8(0), R(14),
B(LdrCurrentContextSlot), U8(4), R(14),
B(CallRuntime), U16(Runtime::kReThrow), R(14), U8(1),
B(PopContext), R(9),
B(LdaSmi), U8(-1),
......@@ -281,9 +281,9 @@ constant pool: [
FIXED_ARRAY_TYPE,
]
handlers: [
[11, 118, 124],
[11, 116, 122],
[14, 81, 83],
[202, 212, 214],
[200, 210, 212],
]
---
......@@ -295,7 +295,7 @@ snippet: "
"
frame size: 15
parameter count: 1
bytecode array length: 297
bytecode array length: 295
bytecodes: [
/* 30 E> */ B(StackCheck),
B(LdaZero),
......@@ -334,7 +334,7 @@ bytecodes: [
B(LdaZero),
B(Star), R(4),
B(JumpLoop), U8(-67), U8(0),
B(Jump), U8(37),
B(Jump), U8(35),
B(Star), R(13),
B(Ldar), R(closure),
B(CreateCatchContext), R(13), U8(5), U8(6),
......@@ -345,7 +345,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), U8(1),
B(Star), R(4),
B(LdrContextSlot), R(context), U8(4), U8(0), R(13),
B(LdrCurrentContextSlot), U8(4), R(13),
B(CallRuntime), U16(Runtime::kReThrow), R(13), U8(1),
B(PopContext), R(8),
B(LdaSmi), U8(-1),
......@@ -429,9 +429,9 @@ constant pool: [
FIXED_ARRAY_TYPE,
]
handlers: [
[7, 136, 142],
[7, 134, 140],
[10, 99, 101],
[219, 229, 231],
[217, 227, 229],
]
---
......@@ -441,7 +441,7 @@ snippet: "
"
frame size: 14
parameter count: 1
bytecode array length: 303
bytecode array length: 301
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), R(8),
......@@ -475,8 +475,8 @@ bytecodes: [
/* 96 E> */ B(LdrNamedProperty), R(0), U8(6), U8(16), R(9),
B(LdaZero),
B(Star), R(8),
B(Jump), U8(51),
B(Jump), U8(37),
B(Jump), U8(49),
B(Jump), U8(35),
B(Star), R(12),
B(Ldar), R(closure),
B(CreateCatchContext), R(12), U8(7), U8(8),
......@@ -487,7 +487,7 @@ bytecodes: [
B(JumpIfFalse), U8(6),
B(LdaSmi), U8(1),
B(Star), R(3),
B(LdrContextSlot), R(context), U8(4), U8(0), R(12),
B(LdrCurrentContextSlot), U8(4), R(12),
B(CallRuntime), U16(Runtime::kReThrow), R(12), U8(1),
B(PopContext), R(7),
B(LdaSmi), U8(-1),
......@@ -578,8 +578,8 @@ constant pool: [
FIXED_ARRAY_TYPE,
]
handlers: [
[15, 131, 137],
[15, 129, 135],
[18, 94, 96],
[215, 225, 227],
[213, 223, 225],
]
......@@ -64,10 +64,10 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 16
bytecode array length: 14
bytecodes: [
/* 32 E> */ B(StackCheck),
/* 39 S> */ B(LdrContextSlot), R(context), U8(3), U8(0), R(0),
/* 39 S> */ B(LdrCurrentContextSlot), U8(3), R(0),
B(LdrContextSlot), R(0), U8(2), U8(0), R(1),
B(LdaConstant), U8(0),
B(DeletePropertySloppy), R(1),
......@@ -89,10 +89,10 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 16
bytecode array length: 14
bytecodes: [
/* 18 E> */ B(StackCheck),
/* 25 S> */ B(LdrContextSlot), R(context), U8(3), U8(0), R(0),
/* 25 S> */ B(LdrCurrentContextSlot), U8(3), R(0),
B(LdrContextSlot), R(0), U8(2), U8(0), R(1),
B(LdaConstant), U8(0),
B(DeletePropertySloppy), R(1),
......
......@@ -11,17 +11,17 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 23
bytecode array length: 19
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(10),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 72 S> */ B(Return),
]
......@@ -37,18 +37,18 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 26
bytecode array length: 20
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(10),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 72 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
/* 72 S> */ B(LdaCurrentContextSlot), U8(4),
/* 82 S> */ B(Return),
]
constant pool: [
......@@ -63,25 +63,25 @@ snippet: "
"
frame size: 4
parameter count: 1
bytecode array length: 46
bytecode array length: 38
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 45 S> */ B(LdaSmi), U8(20),
B(Star), R(2),
/* 45 E> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 45 E> */ B(LdaCurrentContextSlot), U8(4),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(1),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(Ldar), R(2),
B(StaContextSlot), R(context), U8(4), U8(0),
/* 45 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
/* 45 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 78 S> */ B(Return),
]
......@@ -98,19 +98,19 @@ snippet: "
"
frame size: 2
parameter count: 1
bytecode array length: 29
bytecode array length: 23
bytecodes: [
B(CreateFunctionContext), U8(1),
B(PushContext), R(1),
B(LdaTheHole),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateClosure), U8(0), U8(2),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(10),
/* 42 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 42 E> */ B(StaCurrentContextSlot), U8(4),
/* 46 S> */ B(LdaSmi), U8(20),
/* 48 E> */ B(StaContextSlot), R(context), U8(4), U8(0),
/* 48 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaUndefined),
/* 80 S> */ B(Return),
]
......
......@@ -12,16 +12,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 73
bytecode array length: 67
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 10 E> */ B(StackCheck),
/* 14 S> */ B(LdaConstant), U8(0),
B(Star), R(4),
......@@ -57,16 +57,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 74
bytecode array length: 68
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 10 E> */ B(StackCheck),
/* 14 S> */ B(LdaConstant), U8(0),
B(Star), R(4),
......@@ -103,16 +103,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 73
bytecode array length: 67
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 10 E> */ B(StackCheck),
/* 14 S> */ B(LdaSmi), U8(20),
/* 16 E> */ B(StaLookupSlotSloppy), U8(0),
......@@ -154,16 +154,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 73
bytecode array length: 67
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 38 E> */ B(StackCheck),
/* 44 S> */ B(LdaConstant), U8(0),
B(Star), R(4),
......@@ -204,16 +204,16 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 73
bytecode array length: 67
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
B(Ldar), R(this),
B(StaContextSlot), R(context), U8(4), U8(0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaContextSlot), R(context), U8(6), U8(0),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(new_target),
B(StaContextSlot), R(context), U8(5), U8(0),
B(StaCurrentContextSlot), U8(5),
/* 34 E> */ B(StackCheck),
/* 40 S> */ B(LdaConstant), U8(0),
B(Star), R(4),
......
......@@ -20,11 +20,11 @@ snippet: "
"
frame size: 1
parameter count: 1
bytecode array length: 14
bytecode array length: 12
bytecodes: [
/* 97 E> */ B(StackCheck),
/* 102 S> */ B(LdrContextSlot), R(context), U8(4), U8(1), R(0),
/* 120 E> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 120 E> */ B(LdaCurrentContextSlot), U8(4),
B(Mul), R(0), U8(2),
/* 130 S> */ B(Return),
]
......@@ -47,10 +47,10 @@ snippet: "
"
frame size: 0
parameter count: 1
bytecode array length: 11
bytecode array length: 9
bytecodes: [
/* 97 E> */ B(StackCheck),
/* 102 S> */ B(LdaContextSlot), R(context), U8(4), U8(0),
/* 102 S> */ B(LdaCurrentContextSlot), U8(4),
/* 111 E> */ B(StaContextSlot), R(context), U8(4), U8(1),
B(LdaUndefined),
/* 123 S> */ B(Return),
......
......@@ -88,6 +88,10 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.LoadContextSlot(reg, 1, 0)
.StoreContextSlot(reg, 1, 0);
// Emit context operations which operate on the local context.
builder.LoadContextSlot(Register::current_context(), 1, 0)
.StoreContextSlot(Register::current_context(), 1, 0);
// Emit load / store property operations.
builder.LoadNamedProperty(reg, name, 0)
.LoadKeyedProperty(reg, 0)
......@@ -312,6 +316,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.StoreAccumulatorInRegister(reg)
.LoadContextSlot(reg, 1, 0)
.StoreAccumulatorInRegister(reg)
.LoadContextSlot(Register::current_context(), 1, 0)
.StoreAccumulatorInRegister(reg)
.LoadGlobal(0, TypeofMode::NOT_INSIDE_TYPEOF)
.StoreAccumulatorInRegister(reg)
.LoadUndefined()
......@@ -386,6 +392,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
scorecard[Bytecodes::ToByte(Bytecode::kLdrKeyedProperty)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kLdrGlobal)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kLdrContextSlot)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kLdrCurrentContextSlot)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kLdrUndefined)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kLogicalNot)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kJump)] = 1;
......
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