OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| 6 #define V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| 7 |
| 8 // Clients of this interface shouldn't depend on lots of compiler internals. |
| 9 // Do not include anything from src/compiler here! |
| 10 #include "src/allocation.h" |
| 11 #include "src/builtins.h" |
| 12 #include "src/runtime/runtime.h" |
| 13 #include "src/zone-containers.h" |
| 14 |
| 15 namespace v8 { |
| 16 namespace internal { |
| 17 |
| 18 class CallInterfaceDescriptor; |
| 19 class Isolate; |
| 20 class Zone; |
| 21 |
| 22 namespace compiler { |
| 23 |
| 24 class CallDescriptor; |
| 25 class Graph; |
| 26 class Node; |
| 27 class Operator; |
| 28 class RawMachineAssembler; |
| 29 class Schedule; |
| 30 |
| 31 class CodeStubAssembler { |
| 32 public: |
| 33 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 34 const CallInterfaceDescriptor& descriptor, Code::Kind kind, |
| 35 const char* name); |
| 36 virtual ~CodeStubAssembler(); |
| 37 |
| 38 Handle<Code> GenerateCode(); |
| 39 |
| 40 // Constants. |
| 41 Node* Int32Constant(int value); |
| 42 Node* IntPtrConstant(intptr_t value); |
| 43 Node* NumberConstant(double value); |
| 44 Node* HeapConstant(Handle<HeapObject> object); |
| 45 Node* BooleanConstant(bool value); |
| 46 |
| 47 Node* Parameter(int value); |
| 48 void Return(Node* value); |
| 49 |
| 50 // Tag and untag Smi values. |
| 51 Node* SmiTag(Node* value); |
| 52 Node* SmiUntag(Node* value); |
| 53 |
| 54 // Basic arithmetic operations. |
| 55 Node* IntPtrAdd(Node* a, Node* b); |
| 56 Node* IntPtrSub(Node* a, Node* b); |
| 57 Node* WordShl(Node* value, int shift); |
| 58 |
| 59 // Load a field from an object on the heap. |
| 60 Node* LoadObjectField(Node* object, int offset); |
| 61 |
| 62 // Call runtime function. |
| 63 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); |
| 64 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 65 Node* arg2); |
| 66 |
| 67 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 68 Node* arg1); |
| 69 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 70 Node* arg1, Node* arg2); |
| 71 |
| 72 private: |
| 73 friend class CodeStubAssemblerTester; |
| 74 // Close the graph. |
| 75 void End(); |
| 76 |
| 77 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 78 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 79 |
| 80 Node* SmiShiftBitsConstant(); |
| 81 |
| 82 // Adds an end node of the graph. |
| 83 void AddEndInput(Node* input); |
| 84 |
| 85 // Private helpers which delegate to RawMachineAssembler. |
| 86 Graph* graph(); |
| 87 Isolate* isolate(); |
| 88 Zone* zone(); |
| 89 |
| 90 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
| 91 ZoneVector<Node*> end_nodes_; |
| 92 Code::Kind kind_; |
| 93 const char* name_; |
| 94 bool code_generated_; |
| 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); |
| 97 }; |
| 98 |
| 99 } // namespace compiler |
| 100 } // namespace internal |
| 101 } // namespace v8 |
| 102 |
| 103 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |