Chromium Code Reviews| Index: src/interpreter/interpreter-assembler.cc |
| diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc |
| index ee5f8be27981f19b63ddf8eb3029729cb147a7fa..c75a203d02d9ce2838afaa18dc4bf3671bcb5f0a 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); |
| + Variable var_bytecode(this, MachineRepresentation::kWord32); |
| + 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, |
| + Variable& target_offset) { |
| + if (FLAG_trace_ignition) { |
| + TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); |
| + } |
| + DCHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); |
| + bytecode_ = Bytecode::kStar; |
| + bytecode_offset_.Bind(target_offset.value()); |
| + accumulator_use_ = AccumulatorUse::kNone; |
| + if (FLAG_trace_ignition) { |
| + TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); |
| + } |
| + |
| + Variable* merged_vars[2] = {&target_offset, &target_bytecode}; |
| + Label store_register(this), dispatch(this, 2, merged_vars); |
|
oth
2016/07/15 15:30:51
Naming here might be better as store and store_don
klaasb
2016/07/15 18:01:24
Done.
|
| + |
| + Node* star_bytecode = Int32Constant(static_cast<int>(Bytecode::kStar)); |
| + Node* is_star = WordEqual(target_bytecode.value(), star_bytecode); |
| + BranchIf(is_star, &store_register, &dispatch); |
| + Bind(&store_register); |
| + { |
| + StoreAccumulatorToRegister(); |
| + Node* next_bytecode_offset = Advance(); |
| + target_offset.Bind(next_bytecode_offset); |
| + target_bytecode.Bind(LoadBytecode(next_bytecode_offset)); |
| + Goto(&dispatch); |
| + } |
| + Bind(&dispatch); |
| } |
| 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, |
| + 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); |
| } |