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 // Clients of this interface shouldn't depend on lots of compiler internals. |
| 9 // Do not include anything from src/compiler here! |
| 10 #include "src/frames.h" |
| 11 #include "src/interpreter/bytecodes.h" |
| 12 #include "src/smart-pointers.h" |
| 13 |
| 14 namespace v8 { |
| 15 namespace internal { |
| 16 |
| 17 class Isolate; |
| 18 class Zone; |
| 19 |
| 20 namespace compiler { |
| 21 |
| 22 class CallDescriptor; |
| 23 class CommonOperatorBuilder; |
| 24 class Graph; |
| 25 class MachineOperatorBuilder; |
| 26 class Node; |
| 27 class Operator; |
| 28 class RawMachineAssembler; |
| 29 class Schedule; |
| 30 |
| 31 class InterpreterAssembler { |
| 32 public: |
| 33 InterpreterAssembler(Isolate* isolate, Zone* zone, |
| 34 interpreter::Bytecode bytecode); |
| 35 virtual ~InterpreterAssembler(); |
| 36 |
| 37 Handle<Code> GenerateCode(); |
| 38 |
| 39 // Constants. |
| 40 Node* Int32Constant(int value); |
| 41 Node* NumberConstant(double value); |
| 42 |
| 43 // Returns the bytecode argument |index| for the current bytecode. |
| 44 Node* BytecodeArg(int index); |
| 45 |
| 46 // Loads from and stores to the interpreter register file. |
| 47 Node* LoadRegister(int index); |
| 48 Node* LoadRegister(Node* index); |
| 49 Node* StoreRegister(Node* value, int index); |
| 50 Node* StoreRegister(Node* value, Node* index); |
| 51 |
| 52 // Dispatch to the bytecode. |
| 53 void Dispatch(); |
| 54 |
| 55 protected: |
| 56 static const int kFirstRegsterOffsetFromFp = |
| 57 -kPointerSize - StandardFrameConstants::kFixedFrameSizeFromFp; |
| 58 |
| 59 // TODO(rmcilroy): Increase this when required. |
| 60 static const int kMaxRegisterIndex = 255; |
| 61 |
| 62 // Close the graph. |
| 63 void End(); |
| 64 |
| 65 // Protected helpers (for testing) which delegate to RawMachineAssembler. |
| 66 CallDescriptor* call_descriptor() const; |
| 67 Graph* graph(); |
| 68 |
| 69 private: |
| 70 // Returns the pointer to the current bytecode. |
| 71 Node* BytecodePointer(); |
| 72 // Returns the pointer to first entry in the interpreter dispatch table. |
| 73 Node* DispatchTablePointer(); |
| 74 // Returns the frame pointer for the current function. |
| 75 Node* FramePointer(); |
| 76 |
| 77 // Returns the offset of register |index|. |
| 78 Node* RegisterFrameOffset(int index); |
| 79 Node* RegisterFrameOffset(Node* index); |
| 80 |
| 81 // Returns BytecodePointer() advanced by delta bytecodes. Note: this does not |
| 82 // update BytecodePointer() itself. |
| 83 Node* Advance(int delta); |
| 84 |
| 85 // Sets the end node of the graph. |
| 86 void SetEndInput(Node* input); |
| 87 |
| 88 // Private helpers which delegate to RawMachineAssembler. |
| 89 Isolate* isolate(); |
| 90 Schedule* schedule(); |
| 91 MachineOperatorBuilder* machine(); |
| 92 CommonOperatorBuilder* common(); |
| 93 |
| 94 interpreter::Bytecode bytecode_; |
| 95 SmartPointer<RawMachineAssembler> raw_assembler_; |
| 96 Node* end_node_; |
| 97 bool code_generated_; |
| 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler); |
| 100 }; |
| 101 |
| 102 } // namespace interpreter |
| 103 } // namespace internal |
| 104 } // namespace v8 |
| 105 |
| 106 #endif // V8_COMPILER_INTERPRETER_CODEGEN_H_ |
OLD | NEW |