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

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

Issue 1323463005: [Interpreter] Add support for JS calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 Linkage::kInterpreterBytecodeOffsetParameter); 95 Linkage::kInterpreterBytecodeOffsetParameter);
96 } 96 }
97 97
98 98
99 Node* InterpreterAssembler::DispatchTableRawPointer() { 99 Node* InterpreterAssembler::DispatchTableRawPointer() {
100 return raw_assembler_->Parameter(Linkage::kInterpreterDispatchTableParameter); 100 return raw_assembler_->Parameter(Linkage::kInterpreterDispatchTableParameter);
101 } 101 }
102 102
103 103
104 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { 104 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) {
105 return raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2)); 105 return WordShl(index, kPointerSizeLog2);
106 } 106 }
107 107
108 108
109 Node* InterpreterAssembler::RegisterLocation(Node* reg_index) {
110 return IntPtrAdd(RegisterFileRawPointer(), RegisterFrameOffset(reg_index));
111 }
112
113
109 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { 114 Node* InterpreterAssembler::LoadRegister(Node* reg_index) {
110 return raw_assembler_->Load(kMachAnyTagged, RegisterFileRawPointer(), 115 return raw_assembler_->Load(kMachAnyTagged, RegisterFileRawPointer(),
111 RegisterFrameOffset(reg_index)); 116 RegisterFrameOffset(reg_index));
112 } 117 }
113 118
114 119
115 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { 120 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) {
116 return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(), 121 return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(),
117 RegisterFrameOffset(reg_index), value); 122 RegisterFrameOffset(reg_index), value);
118 } 123 }
119 124
120 125
121 Node* InterpreterAssembler::BytecodeOperand(int operand_index) { 126 Node* InterpreterAssembler::BytecodeOperand(int operand_index) {
122 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); 127 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
123 return raw_assembler_->Load( 128 return raw_assembler_->Load(
124 kMachUint8, BytecodeArrayTaggedPointer(), 129 kMachUint8, BytecodeArrayTaggedPointer(),
125 raw_assembler_->IntPtrAdd(BytecodeOffset(), 130 IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index)));
126 Int32Constant(1 + operand_index)));
127 } 131 }
128 132
129 133
130 Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { 134 Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) {
131 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); 135 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
132 Node* load = raw_assembler_->Load( 136 Node* load = raw_assembler_->Load(
133 kMachInt8, BytecodeArrayTaggedPointer(), 137 kMachInt8, BytecodeArrayTaggedPointer(),
134 raw_assembler_->IntPtrAdd(BytecodeOffset(), 138 IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index)));
135 Int32Constant(1 + operand_index)));
136 // Ensure that we sign extend to full pointer size 139 // Ensure that we sign extend to full pointer size
137 if (kPointerSize == 8) { 140 if (kPointerSize == 8) {
138 load = raw_assembler_->ChangeInt32ToInt64(load); 141 load = raw_assembler_->ChangeInt32ToInt64(load);
139 } 142 }
140 return load; 143 return load;
141 } 144 }
142 145
143 146
147 Node* InterpreterAssembler::BytecodeOperandCount(int operand_index) {
148 DCHECK_EQ(interpreter::OperandType::kCount,
149 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
150 return BytecodeOperand(operand_index);
151 }
152
153
144 Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) { 154 Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) {
145 DCHECK_EQ(interpreter::OperandType::kImm8, 155 DCHECK_EQ(interpreter::OperandType::kImm8,
146 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 156 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
147 return BytecodeOperandSignExtended(operand_index); 157 return BytecodeOperandSignExtended(operand_index);
148 } 158 }
149 159
150 160
151 Node* InterpreterAssembler::BytecodeOperandIdx(int operand_index) { 161 Node* InterpreterAssembler::BytecodeOperandIdx(int operand_index) {
152 DCHECK_EQ(interpreter::OperandType::kIdx, 162 DCHECK_EQ(interpreter::OperandType::kIdx,
153 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); 163 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Node* InterpreterAssembler::SmiTag(Node* value) { 200 Node* InterpreterAssembler::SmiTag(Node* value) {
191 return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); 201 return raw_assembler_->WordShl(value, SmiShiftBitsConstant());
192 } 202 }
193 203
194 204
195 Node* InterpreterAssembler::SmiUntag(Node* value) { 205 Node* InterpreterAssembler::SmiUntag(Node* value) {
196 return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); 206 return raw_assembler_->WordSar(value, SmiShiftBitsConstant());
197 } 207 }
198 208
199 209
210 Node* InterpreterAssembler::IntPtrAdd(Node* a, Node* b) {
211 return raw_assembler_->IntPtrAdd(a, b);
212 }
213
214
215 Node* InterpreterAssembler::IntPtrSub(Node* a, Node* b) {
216 return raw_assembler_->IntPtrSub(a, b);
217 }
218
219
220 Node* InterpreterAssembler::WordShl(Node* value, int shift) {
221 return raw_assembler_->WordShl(value, Int32Constant(shift));
222 }
223
224
200 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { 225 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) {
201 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), 226 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(),
202 BytecodeArray::kConstantPoolOffset); 227 BytecodeArray::kConstantPoolOffset);
203 Node* entry_offset = raw_assembler_->IntPtrAdd( 228 Node* entry_offset =
204 IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), 229 IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag),
205 raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2))); 230 WordShl(index, kPointerSizeLog2));
206 return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset); 231 return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset);
207 } 232 }
208 233
209 234
210 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { 235 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) {
211 return raw_assembler_->Load(kMachAnyTagged, object, 236 return raw_assembler_->Load(kMachAnyTagged, object,
212 IntPtrConstant(offset - kHeapObjectTag)); 237 IntPtrConstant(offset - kHeapObjectTag));
213 } 238 }
214 239
215 240
(...skipping 13 matching lines...) Expand all
229 kMachAnyTagged, RegisterFileRawPointer(), 254 kMachAnyTagged, RegisterFileRawPointer(),
230 IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); 255 IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer));
231 Node* shared_info = 256 Node* shared_info =
232 LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); 257 LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset);
233 Node* vector = 258 Node* vector =
234 LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset); 259 LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset);
235 return vector; 260 return vector;
236 } 261 }
237 262
238 263
264 Node* InterpreterAssembler::CallJS(Node* function, Node* first_var_arg,
265 Node* last_var_arg) {
266 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(
267 zone(), false, 0, CallDescriptor::kHasVarArgs);
268 Node* context = LoadObjectField(function, JSFunction::kContextOffset);
269 return raw_assembler_->CallVarArgs(descriptor, function, &context,
270 first_var_arg, last_var_arg);
271 }
272
273
239 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, 274 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor,
240 Node* target, Node* arg1, Node* arg2, 275 Node* target, Node* arg1, Node* arg2,
241 Node* arg3, Node* arg4) { 276 Node* arg3, Node* arg4) {
242 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 277 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
243 isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags); 278 isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags);
244 279
245 Node** args = zone()->NewArray<Node*>(5); 280 Node** args = zone()->NewArray<Node*>(5);
246 args[0] = arg1; 281 args[0] = arg1;
247 args[1] = arg2; 282 args[1] = arg2;
248 args[2] = arg3; 283 args[2] = arg3;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 DispatchTableRawPointer(), 338 DispatchTableRawPointer(),
304 ContextTaggedPointer() }; 339 ContextTaggedPointer() };
305 Node* tail_call = raw_assembler_->TailCallN( 340 Node* tail_call = raw_assembler_->TailCallN(
306 call_descriptor(), exit_trampoline_code_object, args); 341 call_descriptor(), exit_trampoline_code_object, args);
307 // This should always be the end node. 342 // This should always be the end node.
308 SetEndInput(tail_call); 343 SetEndInput(tail_call);
309 } 344 }
310 345
311 346
312 Node* InterpreterAssembler::Advance(int delta) { 347 Node* InterpreterAssembler::Advance(int delta) {
313 return raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); 348 return IntPtrAdd(BytecodeOffset(), Int32Constant(delta));
314 } 349 }
315 350
316 351
317 void InterpreterAssembler::Dispatch() { 352 void InterpreterAssembler::Dispatch() {
318 Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_)); 353 Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_));
319 Node* target_bytecode = raw_assembler_->Load( 354 Node* target_bytecode = raw_assembler_->Load(
320 kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset); 355 kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset);
321 356
322 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion 357 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion
323 // from code object on every dispatch. 358 // from code object on every dispatch.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return raw_assembler_->schedule(); 411 return raw_assembler_->schedule();
377 } 412 }
378 413
379 414
380 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } 415 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); }
381 416
382 417
383 } // namespace interpreter 418 } // namespace interpreter
384 } // namespace internal 419 } // namespace internal
385 } // namespace v8 420 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698