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