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_INTERPRETER_CODEGEN_H_ |
| 6 #define V8_COMPILER_INTERPRETER_CODEGEN_H_ |
| 7 |
| 8 #include "src/interpreter/bytecodes.h" |
| 9 #include "src/smart-pointers.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 class Isolate; |
| 15 class Zone; |
| 16 |
| 17 namespace compiler { |
| 18 |
| 19 class CallDescriptor; |
| 20 class CommonOperatorBuilder; |
| 21 class Graph; |
| 22 class MachineOperatorBuilder; |
| 23 class Node; |
| 24 class Operator; |
| 25 class RawMachineAssembler; |
| 26 class Schedule; |
| 27 |
| 28 class InterpreterAssembler { |
| 29 public: |
| 30 InterpreterAssembler(Isolate* isolate, Zone* zone, |
| 31 interpreter::Bytecode bytecode); |
| 32 virtual ~InterpreterAssembler(); |
| 33 |
| 34 Handle<Code> GenerateCode(); |
| 35 |
| 36 // Constants. |
| 37 Node* Int32Constant(int value); |
| 38 Node* NumberConstant(double value); |
| 39 |
| 40 // Returns the bytecode argument |index| for the current bytecode. |
| 41 Node* BytecodeArg(int index); |
| 42 |
| 43 // Loads from and stores to the interpreter register file. |
| 44 Node* LoadRegister(int index); |
| 45 Node* LoadRegister(Node* index); |
| 46 void StoreRegister(Node* value, int index); |
| 47 void StoreRegister(Node* value, Node* index); |
| 48 |
| 49 // Function return. |
| 50 void Return(Node* value); |
| 51 |
| 52 // Dispatch to the bytecode. |
| 53 void Dispatch(); |
| 54 |
| 55 // Specifies the parameter number used to thread fixed register data through |
| 56 // interpreter dispatches. |
| 57 static const int kBytecodePointerParameter = 0; |
| 58 static const int kDispatchTablePointerParameter = 1; |
| 59 |
| 60 private: |
| 61 // Returns the pointer to the current bytecode. |
| 62 Node* BytecodePointer(); |
| 63 // Returns the pointer to first entry in the interpreter dispatch table. |
| 64 Node* DispatchTablePointer(); |
| 65 // Returns the frame pointer for the current function. |
| 66 Node* FramePointer(); |
| 67 |
| 68 // Returns the offset of register |index|. |
| 69 Node* RegisterFrameOffset(int index); |
| 70 Node* RegisterFrameOffset(Node* index); |
| 71 |
| 72 // Returns BytecodePointer() advanced by delta bytecodes. Note: this does not |
| 73 // update BytecodePointer() itself. |
| 74 Node* Advance(int delta); |
| 75 |
| 76 // Returns the a call descriptor for interpreter dispatch. |
| 77 const CallDescriptor* GetCallDiscriptorForDispatch(); |
| 78 |
| 79 // Private helpers which delegate to RawMachineAssembler. |
| 80 Isolate* isolate(); |
| 81 Graph* graph(); |
| 82 Schedule* schedule(); |
| 83 MachineOperatorBuilder* machine(); |
| 84 CommonOperatorBuilder* common(); |
| 85 |
| 86 Zone* zone_; // Not owned. |
| 87 interpreter::Bytecode bytecode_; |
| 88 CallDescriptor* call_descriptor_; |
| 89 SmartPointer<RawMachineAssembler> raw_assembler_; |
| 90 bool code_generated_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); |
| 93 }; |
| 94 |
| 95 } // namespace interpreter |
| 96 } // namespace internal |
| 97 } // namespace v8 |
| 98 |
| 99 #endif // V8_COMPILER_INTERPRETER_CODEGEN_H_ |
OLD | NEW |