| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void InterpreterAssembler::SetAccumulator(Node* value) { | 73 void InterpreterAssembler::SetAccumulator(Node* value) { |
| 74 accumulator_ = value; | 74 accumulator_ = value; |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 Node* InterpreterAssembler::ContextTaggedPointer() { | 78 Node* InterpreterAssembler::ContextTaggedPointer() { |
| 79 return raw_assembler_->Parameter(Linkage::kInterpreterContextParameter); | 79 return raw_assembler_->Parameter(Linkage::kInterpreterContextParameter); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 Node* InterpreterAssembler::EmptyFrameState() { |
| 84 Node* state_values = raw_assembler_->graph()->NewNode( |
| 85 raw_assembler_->common()->StateValues(0)); |
| 86 return raw_assembler_->graph()->NewNode( |
| 87 raw_assembler_->common()->FrameState( |
| 88 BailoutId::None(), OutputFrameStateCombine::Ignore(), nullptr), |
| 89 state_values, state_values, state_values, ContextTaggedPointer(), |
| 90 HeapConstant(isolate()->factory()->undefined_string()), |
| 91 raw_assembler_->graph()->start()); |
| 92 } |
| 93 |
| 94 |
| 83 Node* InterpreterAssembler::RegisterFileRawPointer() { | 95 Node* InterpreterAssembler::RegisterFileRawPointer() { |
| 84 return raw_assembler_->Parameter(Linkage::kInterpreterRegisterFileParameter); | 96 return raw_assembler_->Parameter(Linkage::kInterpreterRegisterFileParameter); |
| 85 } | 97 } |
| 86 | 98 |
| 87 | 99 |
| 88 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { | 100 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { |
| 89 return raw_assembler_->Parameter(Linkage::kInterpreterBytecodeArrayParameter); | 101 return raw_assembler_->Parameter(Linkage::kInterpreterBytecodeArrayParameter); |
| 90 } | 102 } |
| 91 | 103 |
| 92 | 104 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 args[0] = arg1; | 276 args[0] = arg1; |
| 265 args[1] = arg2; | 277 args[1] = arg2; |
| 266 args[2] = arg3; | 278 args[2] = arg3; |
| 267 args[3] = arg4; | 279 args[3] = arg4; |
| 268 args[4] = arg5; | 280 args[4] = arg5; |
| 269 args[5] = ContextTaggedPointer(); | 281 args[5] = ContextTaggedPointer(); |
| 270 return CallIC(descriptor, target, args); | 282 return CallIC(descriptor, target, args); |
| 271 } | 283 } |
| 272 | 284 |
| 273 | 285 |
| 274 Node* InterpreterAssembler::CallJSBuiltin(int context_index, Node* receiver, | 286 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, |
| 275 Node** js_args, int js_arg_count) { | 287 Node* arg1, Node* arg2) { |
| 276 Node* global_object = LoadContextSlot(Context::GLOBAL_OBJECT_INDEX); | 288 return raw_assembler_->CallRuntime2( |
| 277 Node* native_context = | 289 function_id, arg1, arg2, ContextTaggedPointer(), EmptyFrameState()); |
| 278 LoadObjectField(global_object, GlobalObject::kNativeContextOffset); | |
| 279 Node* function = LoadContextSlot(native_context, context_index); | |
| 280 Node* context = LoadObjectField(function, JSFunction::kContextOffset); | |
| 281 | |
| 282 int index = 0; | |
| 283 Node** args = zone()->NewArray<Node*>(js_arg_count + 2); | |
| 284 args[index++] = receiver; | |
| 285 for (int i = 0; i < js_arg_count; i++) { | |
| 286 args[index++] = js_args[i]; | |
| 287 } | |
| 288 args[index++] = context; | |
| 289 | |
| 290 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | |
| 291 zone(), false, js_arg_count + 1, CallDescriptor::kNoFlags); | |
| 292 return raw_assembler_->CallN(descriptor, function, args); | |
| 293 } | 290 } |
| 294 | 291 |
| 295 | 292 |
| 296 Node* InterpreterAssembler::CallJSBuiltin(int context_index, Node* receiver) { | |
| 297 return CallJSBuiltin(context_index, receiver, nullptr, 0); | |
| 298 } | |
| 299 | |
| 300 | |
| 301 Node* InterpreterAssembler::CallJSBuiltin(int context_index, Node* receiver, | |
| 302 Node* arg1) { | |
| 303 return CallJSBuiltin(context_index, receiver, &arg1, 1); | |
| 304 } | |
| 305 | |
| 306 | |
| 307 void InterpreterAssembler::Return() { | 293 void InterpreterAssembler::Return() { |
| 308 Node* exit_trampoline_code_object = | 294 Node* exit_trampoline_code_object = |
| 309 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); | 295 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); |
| 310 // If the order of the parameters you need to change the call signature below. | 296 // If the order of the parameters you need to change the call signature below. |
| 311 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); | 297 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); |
| 312 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); | 298 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); |
| 313 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); | 299 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); |
| 314 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); | 300 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); |
| 315 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); | 301 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); |
| 316 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter); | 302 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 return raw_assembler_->schedule(); | 380 return raw_assembler_->schedule(); |
| 395 } | 381 } |
| 396 | 382 |
| 397 | 383 |
| 398 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } | 384 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } |
| 399 | 385 |
| 400 | 386 |
| 401 } // namespace interpreter | 387 } // namespace interpreter |
| 402 } // namespace internal | 388 } // namespace internal |
| 403 } // namespace v8 | 389 } // namespace v8 |
| OLD | NEW |