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/compiler/interpreter-assembler.h" | 5 #include "src/compiler/interpreter-assembler.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/instruction-selector.h" | 10 #include "src/compiler/instruction-selector.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 | 83 |
84 Node* InterpreterAssembler::RegisterFrameOffset(int index) { | 84 Node* InterpreterAssembler::RegisterFrameOffset(int index) { |
85 DCHECK_LE(index, kMaxRegisterIndex); | 85 DCHECK_LE(index, kMaxRegisterIndex); |
86 return Int32Constant(kFirstRegisterOffsetFromFp - | 86 return Int32Constant(kFirstRegisterOffsetFromFp - |
87 (index << kPointerSizeLog2)); | 87 (index << kPointerSizeLog2)); |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { | 91 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { |
92 return raw_assembler_->Int32Sub( | 92 return raw_assembler_->IntPtrSub( |
93 Int32Constant(kFirstRegisterOffsetFromFp), | 93 Int32Constant(kFirstRegisterOffsetFromFp), |
94 raw_assembler_->Word32Shl(index, Int32Constant(kPointerSizeLog2))); | 94 raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2))); |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 Node* InterpreterAssembler::BytecodeArg(int delta) { | 98 Node* InterpreterAssembler::BytecodeArg(int delta) { |
99 DCHECK_LT(delta, interpreter::Bytecodes::NumberOfArguments(bytecode_)); | 99 DCHECK_LT(delta, interpreter::Bytecodes::NumberOfArguments(bytecode_)); |
100 return raw_assembler_->Load( | 100 return raw_assembler_->Load( |
101 kMachUint8, BytecodeArrayPointer(), | 101 kMachUint8, BytecodeArrayPointer(), |
102 raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(1 + delta))); | 102 raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(1 + delta))); |
103 } | 103 } |
104 | 104 |
(...skipping 15 matching lines...) Expand all Loading... |
120 RegisterFrameOffset(index), value); | 120 RegisterFrameOffset(index), value); |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 Node* InterpreterAssembler::StoreRegister(Node* value, Node* index) { | 124 Node* InterpreterAssembler::StoreRegister(Node* value, Node* index) { |
125 return raw_assembler_->Store(kMachPtr, FramePointer(), | 125 return raw_assembler_->Store(kMachPtr, FramePointer(), |
126 RegisterFrameOffset(index), value); | 126 RegisterFrameOffset(index), value); |
127 } | 127 } |
128 | 128 |
129 | 129 |
| 130 void InterpreterAssembler::Return() { |
| 131 Node* exit_trampoline_code_object = |
| 132 HeapConstant(Unique<HeapObject>::CreateImmovable( |
| 133 isolate()->builtins()->InterpreterExitTrampoline())); |
| 134 // If the order of the parameters you need to change the call signature below. |
| 135 STATIC_ASSERT(0 == Linkage::kInterpreterBytecodeOffsetParameter); |
| 136 STATIC_ASSERT(1 == Linkage::kInterpreterBytecodeArrayParameter); |
| 137 STATIC_ASSERT(2 == Linkage::kInterpreterDispatchTableParameter); |
| 138 Node* tail_call = graph()->NewNode( |
| 139 common()->TailCall(call_descriptor()), exit_trampoline_code_object, |
| 140 BytecodeOffset(), BytecodeArrayPointer(), DispatchTablePointer(), |
| 141 graph()->start(), graph()->start()); |
| 142 schedule()->AddTailCall(raw_assembler_->CurrentBlock(), tail_call); |
| 143 // This should always be the end node. |
| 144 SetEndInput(tail_call); |
| 145 } |
| 146 |
| 147 |
130 Node* InterpreterAssembler::Advance(int delta) { | 148 Node* InterpreterAssembler::Advance(int delta) { |
131 return raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); | 149 return raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); |
132 } | 150 } |
133 | 151 |
134 | 152 |
135 void InterpreterAssembler::Dispatch() { | 153 void InterpreterAssembler::Dispatch() { |
136 Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_)); | 154 Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_)); |
137 Node* target_bytecode = raw_assembler_->Load( | 155 Node* target_bytecode = raw_assembler_->Load( |
138 kMachUint8, BytecodeArrayPointer(), new_bytecode_offset); | 156 kMachUint8, BytecodeArrayPointer(), new_bytecode_offset); |
139 | 157 |
140 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion | 158 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion |
141 // from code object on every dispatch. | 159 // from code object on every dispatch. |
142 Node* target_code_object = raw_assembler_->Load( | 160 Node* target_code_object = raw_assembler_->Load( |
143 kMachPtr, DispatchTablePointer(), | 161 kMachPtr, DispatchTablePointer(), |
144 raw_assembler_->Word32Shl(target_bytecode, | 162 raw_assembler_->Word32Shl(target_bytecode, |
145 Int32Constant(kPointerSizeLog2))); | 163 Int32Constant(kPointerSizeLog2))); |
146 | 164 |
147 // If the order of the parameters you need to change the call signature below. | 165 // If the order of the parameters you need to change the call signature below. |
148 STATIC_ASSERT(0 == Linkage::kInterpreterBytecodeOffsetParameter); | 166 STATIC_ASSERT(0 == Linkage::kInterpreterBytecodeOffsetParameter); |
149 STATIC_ASSERT(1 == Linkage::kInterpreterBytecodeArrayParameter); | 167 STATIC_ASSERT(1 == Linkage::kInterpreterBytecodeArrayParameter); |
150 STATIC_ASSERT(2 == Linkage::kInterpreterDispatchTableParameter); | 168 STATIC_ASSERT(2 == Linkage::kInterpreterDispatchTableParameter); |
151 Node* tail_call = graph()->NewNode( | 169 Node* tail_call = graph()->NewNode( |
152 common()->TailCall(call_descriptor()), target_code_object, | 170 common()->TailCall(call_descriptor()), target_code_object, |
153 new_bytecode_offset, BytecodeArrayPointer(), DispatchTablePointer(), | 171 new_bytecode_offset, BytecodeArrayPointer(), DispatchTablePointer(), |
154 graph()->start(), graph()->start()); | 172 graph()->start(), graph()->start()); |
155 schedule()->AddTailCall(raw_assembler_->CurrentBlock(), tail_call); | 173 schedule()->AddTailCall(raw_assembler_->CurrentBlock(), tail_call); |
156 | |
157 // This should always be the end node. | 174 // This should always be the end node. |
158 SetEndInput(tail_call); | 175 SetEndInput(tail_call); |
159 } | 176 } |
160 | 177 |
161 | 178 |
162 void InterpreterAssembler::SetEndInput(Node* input) { | 179 void InterpreterAssembler::SetEndInput(Node* input) { |
163 DCHECK(!end_node_); | 180 DCHECK(!end_node_); |
164 end_node_ = input; | 181 end_node_ = input; |
165 } | 182 } |
166 | 183 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 Node* InterpreterAssembler::Int32Constant(int value) { | 220 Node* InterpreterAssembler::Int32Constant(int value) { |
204 return raw_assembler_->Int32Constant(value); | 221 return raw_assembler_->Int32Constant(value); |
205 } | 222 } |
206 | 223 |
207 | 224 |
208 Node* InterpreterAssembler::NumberConstant(double value) { | 225 Node* InterpreterAssembler::NumberConstant(double value) { |
209 return raw_assembler_->NumberConstant(value); | 226 return raw_assembler_->NumberConstant(value); |
210 } | 227 } |
211 | 228 |
212 | 229 |
| 230 Node* InterpreterAssembler::HeapConstant(Unique<HeapObject> object) { |
| 231 return raw_assembler_->HeapConstant(object); |
| 232 } |
| 233 |
| 234 |
213 } // namespace interpreter | 235 } // namespace interpreter |
214 } // namespace internal | 236 } // namespace internal |
215 } // namespace v8 | 237 } // namespace v8 |
OLD | NEW |