Index: src/interpreter/interpreter-assembler.cc |
diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc |
index ee5f8be27981f19b63ddf8eb3029729cb147a7fa..9b127319abed29f5e7e1ec1e420964897b44e4d6 100644 |
--- a/src/interpreter/interpreter-assembler.cc |
+++ b/src/interpreter/interpreter-assembler.cc |
@@ -30,6 +30,7 @@ InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, |
Bytecodes::ToString(bytecode), |
Bytecodes::ReturnCount(bytecode)), |
bytecode_(bytecode), |
+ bytecode_offset_(this, MachineRepresentation::kTagged), |
operand_scale_(operand_scale), |
interpreted_frame_pointer_(this, MachineType::PointerRepresentation()), |
accumulator_(this, MachineRepresentation::kTagged), |
@@ -39,6 +40,8 @@ InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, |
stack_pointer_before_call_(nullptr) { |
accumulator_.Bind( |
Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); |
+ bytecode_offset_.Bind( |
+ Parameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter)); |
if (FLAG_trace_ignition) { |
TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); |
} |
@@ -83,7 +86,7 @@ void InterpreterAssembler::SetContext(Node* value) { |
} |
Node* InterpreterAssembler::BytecodeOffset() { |
- return Parameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter); |
+ return bytecode_offset_.value(); |
} |
Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { |
@@ -131,6 +134,13 @@ Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { |
RegisterFrameOffset(reg_index), value); |
} |
+Node* InterpreterAssembler::StoreAccumulatorToRegister() { |
+ DCHECK_EQ(bytecode_, Bytecode::kStar); |
+ Node* reg_index = BytecodeOperandReg(0); |
+ Node* accumulator = GetAccumulator(); |
+ return StoreRegister(accumulator, reg_index); |
+} |
+ |
Node* InterpreterAssembler::NextRegister(Node* reg_index) { |
// Register indexes are negative, so the next index is minus one. |
return IntPtrAdd(reg_index, IntPtrConstant(-1)); |
@@ -506,8 +516,12 @@ void InterpreterAssembler::UpdateInterruptBudget(Node* weight) { |
new_budget.value()); |
} |
+Node* InterpreterAssembler::Advance() { |
+ return Advance(Bytecodes::Size(bytecode_, operand_scale_)); |
+} |
+ |
Node* InterpreterAssembler::Advance(int delta) { |
- return IntPtrAdd(BytecodeOffset(), IntPtrConstant(delta)); |
+ return Advance(IntPtrConstant(delta)); |
} |
Node* InterpreterAssembler::Advance(Node* delta) { |
@@ -538,17 +552,65 @@ void InterpreterAssembler::JumpIfWordNotEqual(Node* lhs, Node* rhs, |
JumpConditional(WordNotEqual(lhs, rhs), delta); |
} |
+Node* InterpreterAssembler::LoadBytecode(compiler::Node* bytecode_offset) { |
+ return Load(MachineType::Uint8(), BytecodeArrayTaggedPointer(), |
+ bytecode_offset); |
+} |
+ |
Node* InterpreterAssembler::Dispatch() { |
- return DispatchTo(Advance(Bytecodes::Size(bytecode_, operand_scale_))); |
+ Node* target_offset = Advance(); |
+ Node* target_bytecode = LoadBytecode(target_offset); |
+ Variable var_offset(this, MachineRepresentation::kTagged); |
rmcilroy
2016/07/18 11:07:51
The offset is not a tagged value, it is just a raw
klaasb
2016/07/18 15:15:29
Done.
|
+ Variable var_bytecode(this, MachineRepresentation::kWord32); |
rmcilroy
2016/07/18 11:07:51
kWord8, no?
klaasb
2016/07/18 15:15:29
Done.
|
+ var_offset.Bind(target_offset); |
+ var_bytecode.Bind(target_bytecode); |
+ |
+ if (Bytecodes::IsStarLookahead(bytecode_, operand_scale_)) { |
+ InlineDispatchToStar(var_bytecode, var_offset); |
+ } |
+ return DispatchToLoaded(var_bytecode.value(), var_offset.value()); |
+} |
+ |
+void InterpreterAssembler::InlineDispatchToStar(Variable& target_bytecode, |
rmcilroy
2016/07/18 11:07:51
nit - StarDispatchLookahead
klaasb
2016/07/18 15:15:29
Done.
|
+ Variable& target_offset) { |
+ if (FLAG_trace_ignition) { |
+ TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); |
rmcilroy
2016/07/18 11:07:51
You are now doing this twice for the same dispatch
klaasb
2016/07/18 15:15:29
Done.
|
+ } |
+ DCHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); |
+ bytecode_ = Bytecode::kStar; |
rmcilroy
2016/07/18 11:07:51
Could you split up the code which does the check f
klaasb
2016/07/18 15:15:29
Yes, this assumed that a single Dispatch call was
rmcilroy
2016/07/19 10:03:55
Let's not do this in this CL (see other comments).
|
+ bytecode_offset_.Bind(target_offset.value()); |
rmcilroy
2016/07/18 11:07:51
Not sure why this is needed?
klaasb
2016/07/18 15:15:29
For BytecodeOffset() to have the correct value whe
|
+ accumulator_use_ = AccumulatorUse::kNone; |
+ if (FLAG_trace_ignition) { |
+ TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); |
rmcilroy
2016/07/18 11:07:51
ditto
klaasb
2016/07/18 15:15:29
Done.
|
+ } |
+ |
+ Variable* merged_vars[2] = {&target_offset, &target_bytecode}; |
rmcilroy
2016/07/18 11:07:51
I don't think you need these to list the merged va
klaasb
2016/07/18 15:15:29
Done.
|
+ Label store(this), done(this, 2, merged_vars); |
+ |
+ Node* star_bytecode = Int32Constant(static_cast<int>(Bytecode::kStar)); |
+ Node* is_star = WordEqual(target_bytecode.value(), star_bytecode); |
+ BranchIf(is_star, &store, &done); |
+ Bind(&store); |
+ { |
+ StoreAccumulatorToRegister(); |
+ Node* next_bytecode_offset = Advance(); |
+ target_offset.Bind(next_bytecode_offset); |
+ target_bytecode.Bind(LoadBytecode(next_bytecode_offset)); |
+ Goto(&done); |
+ } |
+ Bind(&done); |
} |
Node* InterpreterAssembler::DispatchTo(Node* new_bytecode_offset) { |
- Node* target_bytecode = Load( |
- MachineType::Uint8(), BytecodeArrayTaggedPointer(), new_bytecode_offset); |
+ Node* target_bytecode = LoadBytecode(new_bytecode_offset); |
+ return DispatchToLoaded(target_bytecode, new_bytecode_offset); |
+} |
+ |
+Node* InterpreterAssembler::DispatchToLoaded(Node* target_bytecode, |
rmcilroy
2016/07/18 11:07:51
nit - DispatchToBytecode
klaasb
2016/07/18 15:15:29
Done.
|
+ Node* new_bytecode_offset) { |
if (kPointerSize == 8) { |
target_bytecode = ChangeUint32ToUint64(target_bytecode); |
} |
- |
if (FLAG_trace_ignition_dispatches) { |
TraceBytecodeDispatch(target_bytecode); |
} |
@@ -588,8 +650,7 @@ void InterpreterAssembler::DispatchWide(OperandScale operand_scale) { |
// Indices 256-511 correspond to bytecodes with operand_scale == 1 |
// Indices 512-767 correspond to bytecodes with operand_scale == 2 |
Node* next_bytecode_offset = Advance(1); |
- Node* next_bytecode = Load(MachineType::Uint8(), BytecodeArrayTaggedPointer(), |
- next_bytecode_offset); |
+ Node* next_bytecode = LoadBytecode(next_bytecode_offset); |
if (kPointerSize == 8) { |
next_bytecode = ChangeUint32ToUint64(next_bytecode); |
} |