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 #ifndef V8_COMPILER_CODE_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_CODE_ASSEMBLER_H_ |
6 #define V8_COMPILER_CODE_ASSEMBLER_H_ | 6 #define V8_COMPILER_CODE_ASSEMBLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 332 matching lines...) Loading... |
343 Node* target, TArgs... args); | 343 Node* target, TArgs... args); |
344 | 344 |
345 template <class... TArgs> | 345 template <class... TArgs> |
346 Node* CallJS(Callable const& callable, Node* context, Node* function, | 346 Node* CallJS(Callable const& callable, Node* context, Node* function, |
347 Node* receiver, TArgs... args) { | 347 Node* receiver, TArgs... args) { |
348 int argc = static_cast<int>(sizeof...(args)); | 348 int argc = static_cast<int>(sizeof...(args)); |
349 Node* arity = Int32Constant(argc); | 349 Node* arity = Int32Constant(argc); |
350 return CallStub(callable, context, function, arity, receiver, args...); | 350 return CallStub(callable, context, function, arity, receiver, args...); |
351 } | 351 } |
352 | 352 |
| 353 template <class... TArgs> |
| 354 Node* ConstructJS(Callable const& callable, Node* context, Node* new_target, |
| 355 TArgs... args) { |
| 356 int argc = static_cast<int>(sizeof...(args)); |
| 357 Node* arity = Int32Constant(argc); |
| 358 Node* receiver = LoadRoot(Heap::kUndefinedValueRootIndex); |
| 359 |
| 360 // Construct(target, new_target, arity, receiver, arguments...) |
| 361 return CallStub(callable, context, new_target, new_target, arity, receiver, |
| 362 args...); |
| 363 } |
| 364 |
353 // Call to a C function with two arguments. | 365 // Call to a C function with two arguments. |
354 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, | 366 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, |
355 MachineType arg1_type, Node* function, Node* arg0, | 367 MachineType arg1_type, Node* function, Node* arg0, |
356 Node* arg1); | 368 Node* arg1); |
357 | 369 |
358 // Call to a C function with three arguments. | 370 // Call to a C function with three arguments. |
359 Node* CallCFunction3(MachineType return_type, MachineType arg0_type, | 371 Node* CallCFunction3(MachineType return_type, MachineType arg0_type, |
360 MachineType arg1_type, MachineType arg2_type, | 372 MachineType arg1_type, MachineType arg2_type, |
361 Node* function, Node* arg0, Node* arg1, Node* arg2); | 373 Node* function, Node* arg0, Node* arg1, Node* arg2); |
362 | 374 |
(...skipping 92 matching lines...) Loading... |
455 Code::Flags flags, const char* name, | 467 Code::Flags flags, const char* name, |
456 size_t result_size = 1); | 468 size_t result_size = 1); |
457 | 469 |
458 // Create with JSCall linkage. | 470 // Create with JSCall linkage. |
459 CodeAssemblerState(Isolate* isolate, Zone* zone, int parameter_count, | 471 CodeAssemblerState(Isolate* isolate, Zone* zone, int parameter_count, |
460 Code::Flags flags, const char* name); | 472 Code::Flags flags, const char* name); |
461 | 473 |
462 ~CodeAssemblerState(); | 474 ~CodeAssemblerState(); |
463 | 475 |
464 const char* name() const { return name_; } | 476 const char* name() const { return name_; } |
| 477 int parameter_count() const; |
465 | 478 |
466 private: | 479 private: |
467 friend class CodeAssembler; | 480 friend class CodeAssembler; |
468 friend class CodeAssemblerLabel; | 481 friend class CodeAssemblerLabel; |
469 friend class CodeAssemblerVariable; | 482 friend class CodeAssemblerVariable; |
470 | 483 |
471 CodeAssemblerState(Isolate* isolate, Zone* zone, | 484 CodeAssemblerState(Isolate* isolate, Zone* zone, |
472 CallDescriptor* call_descriptor, Code::Flags flags, | 485 CallDescriptor* call_descriptor, Code::Flags flags, |
473 const char* name); | 486 const char* name); |
474 | 487 |
475 std::unique_ptr<RawMachineAssembler> raw_assembler_; | 488 std::unique_ptr<RawMachineAssembler> raw_assembler_; |
476 Code::Flags flags_; | 489 Code::Flags flags_; |
477 const char* name_; | 490 const char* name_; |
478 bool code_generated_; | 491 bool code_generated_; |
479 ZoneSet<CodeAssemblerVariable::Impl*> variables_; | 492 ZoneSet<CodeAssemblerVariable::Impl*> variables_; |
480 | 493 |
481 DISALLOW_COPY_AND_ASSIGN(CodeAssemblerState); | 494 DISALLOW_COPY_AND_ASSIGN(CodeAssemblerState); |
482 }; | 495 }; |
483 | 496 |
484 } // namespace compiler | 497 } // namespace compiler |
485 } // namespace internal | 498 } // namespace internal |
486 } // namespace v8 | 499 } // namespace v8 |
487 | 500 |
488 #endif // V8_COMPILER_CODE_ASSEMBLER_H_ | 501 #endif // V8_COMPILER_CODE_ASSEMBLER_H_ |
OLD | NEW |