OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/interpreter/interpreter-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, | 25 InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, |
26 Bytecode bytecode, | 26 Bytecode bytecode, |
27 OperandScale operand_scale) | 27 OperandScale operand_scale) |
28 : CodeStubAssembler(isolate, zone, InterpreterDispatchDescriptor(isolate), | 28 : CodeStubAssembler(isolate, zone, InterpreterDispatchDescriptor(isolate), |
29 Code::ComputeFlags(Code::BYTECODE_HANDLER), | 29 Code::ComputeFlags(Code::BYTECODE_HANDLER), |
30 Bytecodes::ToString(bytecode), | 30 Bytecodes::ToString(bytecode), |
31 Bytecodes::ReturnCount(bytecode)), | 31 Bytecodes::ReturnCount(bytecode)), |
32 bytecode_(bytecode), | 32 bytecode_(bytecode), |
33 operand_scale_(operand_scale), | 33 operand_scale_(operand_scale), |
| 34 interpreted_frame_pointer_(this, MachineType::PointerRepresentation()), |
34 accumulator_(this, MachineRepresentation::kTagged), | 35 accumulator_(this, MachineRepresentation::kTagged), |
35 accumulator_use_(AccumulatorUse::kNone), | 36 accumulator_use_(AccumulatorUse::kNone), |
36 made_call_(false), | 37 made_call_(false), |
37 disable_stack_check_across_call_(false), | 38 disable_stack_check_across_call_(false), |
38 stack_pointer_before_call_(nullptr) { | 39 stack_pointer_before_call_(nullptr) { |
39 accumulator_.Bind( | 40 accumulator_.Bind( |
40 Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); | 41 Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); |
41 if (FLAG_trace_ignition) { | 42 if (FLAG_trace_ignition) { |
42 TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); | 43 TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); |
43 } | 44 } |
44 } | 45 } |
45 | 46 |
46 InterpreterAssembler::~InterpreterAssembler() { | 47 InterpreterAssembler::~InterpreterAssembler() { |
47 // If the following check fails the handler does not use the | 48 // If the following check fails the handler does not use the |
48 // accumulator in the way described in the bytecode definitions in | 49 // accumulator in the way described in the bytecode definitions in |
49 // bytecodes.h. | 50 // bytecodes.h. |
50 DCHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); | 51 DCHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); |
51 } | 52 } |
52 | 53 |
| 54 Node* InterpreterAssembler::GetInterpretedFramePointer() { |
| 55 if (!interpreted_frame_pointer_.IsBound()) { |
| 56 interpreted_frame_pointer_.Bind(LoadParentFramePointer()); |
| 57 } |
| 58 return interpreted_frame_pointer_.value(); |
| 59 } |
| 60 |
53 Node* InterpreterAssembler::GetAccumulatorUnchecked() { | 61 Node* InterpreterAssembler::GetAccumulatorUnchecked() { |
54 return accumulator_.value(); | 62 return accumulator_.value(); |
55 } | 63 } |
56 | 64 |
57 Node* InterpreterAssembler::GetAccumulator() { | 65 Node* InterpreterAssembler::GetAccumulator() { |
58 DCHECK(Bytecodes::ReadsAccumulator(bytecode_)); | 66 DCHECK(Bytecodes::ReadsAccumulator(bytecode_)); |
59 accumulator_use_ = accumulator_use_ | AccumulatorUse::kRead; | 67 accumulator_use_ = accumulator_use_ | AccumulatorUse::kRead; |
60 return GetAccumulatorUnchecked(); | 68 return GetAccumulatorUnchecked(); |
61 } | 69 } |
62 | 70 |
(...skipping 23 matching lines...) Expand all Loading... |
86 } else { | 94 } else { |
87 return Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter); | 95 return Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter); |
88 } | 96 } |
89 } | 97 } |
90 | 98 |
91 Node* InterpreterAssembler::DispatchTableRawPointer() { | 99 Node* InterpreterAssembler::DispatchTableRawPointer() { |
92 return Parameter(InterpreterDispatchDescriptor::kDispatchTableParameter); | 100 return Parameter(InterpreterDispatchDescriptor::kDispatchTableParameter); |
93 } | 101 } |
94 | 102 |
95 Node* InterpreterAssembler::RegisterLocation(Node* reg_index) { | 103 Node* InterpreterAssembler::RegisterLocation(Node* reg_index) { |
96 return IntPtrAdd(LoadParentFramePointer(), RegisterFrameOffset(reg_index)); | 104 return IntPtrAdd(GetInterpretedFramePointer(), |
| 105 RegisterFrameOffset(reg_index)); |
97 } | 106 } |
98 | 107 |
99 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { | 108 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { |
100 return WordShl(index, kPointerSizeLog2); | 109 return WordShl(index, kPointerSizeLog2); |
101 } | 110 } |
102 | 111 |
103 Node* InterpreterAssembler::LoadRegister(Register reg) { | 112 Node* InterpreterAssembler::LoadRegister(Register reg) { |
104 return Load(MachineType::AnyTagged(), LoadParentFramePointer(), | 113 return Load(MachineType::AnyTagged(), GetInterpretedFramePointer(), |
105 IntPtrConstant(reg.ToOperand() << kPointerSizeLog2)); | 114 IntPtrConstant(reg.ToOperand() << kPointerSizeLog2)); |
106 } | 115 } |
107 | 116 |
108 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { | 117 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { |
109 return Load(MachineType::AnyTagged(), LoadParentFramePointer(), | 118 return Load(MachineType::AnyTagged(), GetInterpretedFramePointer(), |
110 RegisterFrameOffset(reg_index)); | 119 RegisterFrameOffset(reg_index)); |
111 } | 120 } |
112 | 121 |
113 Node* InterpreterAssembler::StoreRegister(Node* value, Register reg) { | 122 Node* InterpreterAssembler::StoreRegister(Node* value, Register reg) { |
114 return StoreNoWriteBarrier( | 123 return StoreNoWriteBarrier( |
115 MachineRepresentation::kTagged, LoadParentFramePointer(), | 124 MachineRepresentation::kTagged, GetInterpretedFramePointer(), |
116 IntPtrConstant(reg.ToOperand() << kPointerSizeLog2), value); | 125 IntPtrConstant(reg.ToOperand() << kPointerSizeLog2), value); |
117 } | 126 } |
118 | 127 |
119 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { | 128 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { |
120 return StoreNoWriteBarrier(MachineRepresentation::kTagged, | 129 return StoreNoWriteBarrier(MachineRepresentation::kTagged, |
121 LoadParentFramePointer(), | 130 GetInterpretedFramePointer(), |
122 RegisterFrameOffset(reg_index), value); | 131 RegisterFrameOffset(reg_index), value); |
123 } | 132 } |
124 | 133 |
125 Node* InterpreterAssembler::NextRegister(Node* reg_index) { | 134 Node* InterpreterAssembler::NextRegister(Node* reg_index) { |
126 // Register indexes are negative, so the next index is minus one. | 135 // Register indexes are negative, so the next index is minus one. |
127 return IntPtrAdd(reg_index, IntPtrConstant(-1)); | 136 return IntPtrAdd(reg_index, IntPtrConstant(-1)); |
128 } | 137 } |
129 | 138 |
130 Node* InterpreterAssembler::OperandOffset(int operand_index) { | 139 Node* InterpreterAssembler::OperandOffset(int operand_index) { |
131 return IntPtrConstant( | 140 return IntPtrConstant( |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 Goto(&loop); | 779 Goto(&loop); |
771 } | 780 } |
772 Bind(&done_loop); | 781 Bind(&done_loop); |
773 | 782 |
774 return array; | 783 return array; |
775 } | 784 } |
776 | 785 |
777 } // namespace interpreter | 786 } // namespace interpreter |
778 } // namespace internal | 787 } // namespace internal |
779 } // namespace v8 | 788 } // namespace v8 |
OLD | NEW |