Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: src/compiler/interpreter-assembler.cc

Issue 1294133004: [Interpreter] Pass context to interpreter bytecode handlers and add LoadConstextSlot (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Node* InterpreterAssembler::GetAccumulator() { 65 Node* InterpreterAssembler::GetAccumulator() {
66 return accumulator_; 66 return accumulator_;
67 } 67 }
68 68
69 69
70 void InterpreterAssembler::SetAccumulator(Node* value) { 70 void InterpreterAssembler::SetAccumulator(Node* value) {
71 accumulator_ = value; 71 accumulator_ = value;
72 } 72 }
73 73
74 74
75 Node* InterpreterAssembler::ContextTaggedPointer() {
76 return raw_assembler_->Parameter(Linkage::kInterpreterContextParameter);
77 }
78
79
75 Node* InterpreterAssembler::RegisterFileRawPointer() { 80 Node* InterpreterAssembler::RegisterFileRawPointer() {
76 return raw_assembler_->Parameter(Linkage::kInterpreterRegisterFileParameter); 81 return raw_assembler_->Parameter(Linkage::kInterpreterRegisterFileParameter);
77 } 82 }
78 83
79 84
80 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { 85 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() {
81 return raw_assembler_->Parameter(Linkage::kInterpreterBytecodeArrayParameter); 86 return raw_assembler_->Parameter(Linkage::kInterpreterBytecodeArrayParameter);
82 } 87 }
83 88
84 89
85 Node* InterpreterAssembler::BytecodeOffset() { 90 Node* InterpreterAssembler::BytecodeOffset() {
86 return raw_assembler_->Parameter( 91 return raw_assembler_->Parameter(
87 Linkage::kInterpreterBytecodeOffsetParameter); 92 Linkage::kInterpreterBytecodeOffsetParameter);
88 } 93 }
89 94
90 95
91 Node* InterpreterAssembler::DispatchTableRawPointer() { 96 Node* InterpreterAssembler::DispatchTableRawPointer() {
92 return raw_assembler_->Parameter(Linkage::kInterpreterDispatchTableParameter); 97 return raw_assembler_->Parameter(Linkage::kInterpreterDispatchTableParameter);
93 } 98 }
94 99
95 100
96 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { 101 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) {
97 return raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2)); 102 return raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2));
98 } 103 }
99 104
100 105
101 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { 106 Node* InterpreterAssembler::LoadRegister(Node* reg_index) {
102 return raw_assembler_->Load(kMachPtr, RegisterFileRawPointer(), 107 return raw_assembler_->Load(kMachAnyTagged, RegisterFileRawPointer(),
103 RegisterFrameOffset(reg_index)); 108 RegisterFrameOffset(reg_index));
104 } 109 }
105 110
106 111
107 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { 112 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) {
108 return raw_assembler_->Store(kMachPtr, RegisterFileRawPointer(), 113 return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(),
109 RegisterFrameOffset(reg_index), value); 114 RegisterFrameOffset(reg_index), value);
110 } 115 }
111 116
112 117
113 Node* InterpreterAssembler::BytecodeOperand(int operand_index) { 118 Node* InterpreterAssembler::BytecodeOperand(int operand_index) {
114 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); 119 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
115 return raw_assembler_->Load( 120 return raw_assembler_->Load(
116 kMachUint8, BytecodeArrayTaggedPointer(), 121 kMachUint8, BytecodeArrayTaggedPointer(),
117 raw_assembler_->IntPtrAdd(BytecodeOffset(), 122 raw_assembler_->IntPtrAdd(BytecodeOffset(),
118 Int32Constant(1 + operand_index))); 123 Int32Constant(1 + operand_index)));
(...skipping 26 matching lines...) Expand all
145 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 150 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
146 return BytecodeOperandSignExtended(operand_index); 151 return BytecodeOperandSignExtended(operand_index);
147 } 152 }
148 153
149 154
150 Node* InterpreterAssembler::Int32Constant(int value) { 155 Node* InterpreterAssembler::Int32Constant(int value) {
151 return raw_assembler_->Int32Constant(value); 156 return raw_assembler_->Int32Constant(value);
152 } 157 }
153 158
154 159
160 Node* InterpreterAssembler::IntPtrConstant(intptr_t value) {
161 return raw_assembler_->IntPtrConstant(value);
162 }
163
164
155 Node* InterpreterAssembler::NumberConstant(double value) { 165 Node* InterpreterAssembler::NumberConstant(double value) {
156 return raw_assembler_->NumberConstant(value); 166 return raw_assembler_->NumberConstant(value);
157 } 167 }
158 168
159 169
160 Node* InterpreterAssembler::HeapConstant(Unique<HeapObject> object) { 170 Node* InterpreterAssembler::HeapConstant(Unique<HeapObject> object) {
161 return raw_assembler_->HeapConstant(object); 171 return raw_assembler_->HeapConstant(object);
162 } 172 }
163 173
164 174
165 Node* InterpreterAssembler::SmiShiftBitsConstant() { 175 Node* InterpreterAssembler::SmiShiftBitsConstant() {
166 return Int32Constant(kSmiShiftSize + kSmiTagSize); 176 return Int32Constant(kSmiShiftSize + kSmiTagSize);
167 } 177 }
168 178
169 179
170 Node* InterpreterAssembler::SmiTag(Node* value) { 180 Node* InterpreterAssembler::SmiTag(Node* value) {
171 return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); 181 return raw_assembler_->WordShl(value, SmiShiftBitsConstant());
172 } 182 }
173 183
174 184
175 Node* InterpreterAssembler::SmiUntag(Node* value) { 185 Node* InterpreterAssembler::SmiUntag(Node* value) {
176 return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); 186 return raw_assembler_->WordSar(value, SmiShiftBitsConstant());
177 } 187 }
178 188
179 189
190 Node* InterpreterAssembler::LoadContextSlot(int slot_index) {
191 return raw_assembler_->Load(kMachAnyTagged, ContextTaggedPointer(),
192 IntPtrConstant(Context::SlotOffset(slot_index)));
193 }
194
195
180 void InterpreterAssembler::Return() { 196 void InterpreterAssembler::Return() {
181 Node* exit_trampoline_code_object = 197 Node* exit_trampoline_code_object =
182 HeapConstant(Unique<HeapObject>::CreateImmovable( 198 HeapConstant(Unique<HeapObject>::CreateImmovable(
183 isolate()->builtins()->InterpreterExitTrampoline())); 199 isolate()->builtins()->InterpreterExitTrampoline()));
184 // If the order of the parameters you need to change the call signature below. 200 // If the order of the parameters you need to change the call signature below.
185 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); 201 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter);
186 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); 202 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter);
187 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); 203 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter);
188 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); 204 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter);
189 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); 205 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter);
206 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter);
190 Node* tail_call = raw_assembler_->TailCallInterpreterDispatch( 207 Node* tail_call = raw_assembler_->TailCallInterpreterDispatch(
191 call_descriptor(), exit_trampoline_code_object, GetAccumulator(), 208 call_descriptor(), exit_trampoline_code_object, GetAccumulator(),
192 RegisterFileRawPointer(), BytecodeOffset(), BytecodeArrayTaggedPointer(), 209 RegisterFileRawPointer(), BytecodeOffset(), BytecodeArrayTaggedPointer(),
193 DispatchTableRawPointer()); 210 DispatchTableRawPointer(), ContextTaggedPointer());
194 // This should always be the end node. 211 // This should always be the end node.
195 SetEndInput(tail_call); 212 SetEndInput(tail_call);
196 } 213 }
197 214
198 215
199 Node* InterpreterAssembler::Advance(int delta) { 216 Node* InterpreterAssembler::Advance(int delta) {
200 return raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); 217 return raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(delta));
201 } 218 }
202 219
203 220
204 void InterpreterAssembler::Dispatch() { 221 void InterpreterAssembler::Dispatch() {
205 Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_)); 222 Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_));
206 Node* target_bytecode = raw_assembler_->Load( 223 Node* target_bytecode = raw_assembler_->Load(
207 kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset); 224 kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset);
208 225
209 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion 226 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion
210 // from code object on every dispatch. 227 // from code object on every dispatch.
211 Node* target_code_object = raw_assembler_->Load( 228 Node* target_code_object = raw_assembler_->Load(
212 kMachPtr, DispatchTableRawPointer(), 229 kMachPtr, DispatchTableRawPointer(),
213 raw_assembler_->Word32Shl(target_bytecode, 230 raw_assembler_->Word32Shl(target_bytecode,
214 Int32Constant(kPointerSizeLog2))); 231 Int32Constant(kPointerSizeLog2)));
215 232
216 // If the order of the parameters you need to change the call signature below. 233 // If the order of the parameters you need to change the call signature below.
217 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); 234 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter);
218 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); 235 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter);
219 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); 236 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter);
220 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); 237 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter);
221 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); 238 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter);
239 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter);
222 Node* tail_call = raw_assembler_->TailCallInterpreterDispatch( 240 Node* tail_call = raw_assembler_->TailCallInterpreterDispatch(
223 call_descriptor(), target_code_object, GetAccumulator(), 241 call_descriptor(), target_code_object, GetAccumulator(),
224 RegisterFileRawPointer(), new_bytecode_offset, 242 RegisterFileRawPointer(), new_bytecode_offset,
225 BytecodeArrayTaggedPointer(), DispatchTableRawPointer()); 243 BytecodeArrayTaggedPointer(), DispatchTableRawPointer(),
244 ContextTaggedPointer());
226 // This should always be the end node. 245 // This should always be the end node.
227 SetEndInput(tail_call); 246 SetEndInput(tail_call);
228 } 247 }
229 248
230 249
231 void InterpreterAssembler::SetEndInput(Node* input) { 250 void InterpreterAssembler::SetEndInput(Node* input) {
232 DCHECK(!end_node_); 251 DCHECK(!end_node_);
233 end_node_ = input; 252 end_node_ = input;
234 } 253 }
235 254
(...skipping 20 matching lines...) Expand all
256 275
257 Schedule* InterpreterAssembler::schedule() { 276 Schedule* InterpreterAssembler::schedule() {
258 return raw_assembler_->schedule(); 277 return raw_assembler_->schedule();
259 } 278 }
260 279
261 280
262 281
263 } // namespace interpreter 282 } // namespace interpreter
264 } // namespace internal 283 } // namespace internal
265 } // namespace v8 284 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698