Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: src/compiler/interpreter-assembler.h

Issue 1673333004: [Interpreter] Make InterpreterAssembler a subclass of CodeStubAssembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address review comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/code-stub-assembler.cc ('k') | src/compiler/interpreter-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_ASSEMBLER_H_
6 #define V8_COMPILER_INTERPRETER_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/base/smart-pointers.h"
12 #include "src/builtins.h"
13 #include "src/frames.h"
14 #include "src/interpreter/bytecodes.h"
15 #include "src/runtime/runtime.h"
16
17 namespace v8 {
18 namespace internal {
19
20 class CallInterfaceDescriptor;
21 class Isolate;
22 class Zone;
23
24 namespace compiler {
25
26 class CallDescriptor;
27 class Graph;
28 class Node;
29 class Operator;
30 class RawMachineAssembler;
31 class Schedule;
32
33 class InterpreterAssembler {
34 public:
35 InterpreterAssembler(Isolate* isolate, Zone* zone,
36 interpreter::Bytecode bytecode);
37 virtual ~InterpreterAssembler();
38
39 Handle<Code> GenerateCode();
40
41 // Returns the count immediate for bytecode operand |operand_index| in the
42 // current bytecode.
43 Node* BytecodeOperandCount(int operand_index);
44 // Returns the index immediate for bytecode operand |operand_index| in the
45 // current bytecode.
46 Node* BytecodeOperandIdx(int operand_index);
47 // Returns the Imm8 immediate for bytecode operand |operand_index| in the
48 // current bytecode.
49 Node* BytecodeOperandImm(int operand_index);
50 // Returns the register index for bytecode operand |operand_index| in the
51 // current bytecode.
52 Node* BytecodeOperandReg(int operand_index);
53
54 // Accumulator.
55 Node* GetAccumulator();
56 void SetAccumulator(Node* value);
57
58 // Context.
59 Node* GetContext();
60 void SetContext(Node* value);
61
62 // Loads from and stores to the interpreter register file.
63 Node* LoadRegister(int offset);
64 Node* LoadRegister(interpreter::Register reg);
65 Node* LoadRegister(Node* reg_index);
66 Node* StoreRegister(Node* value, int offset);
67 Node* StoreRegister(Node* value, interpreter::Register reg);
68 Node* StoreRegister(Node* value, Node* reg_index);
69
70 // Returns the next consecutive register.
71 Node* NextRegister(Node* reg_index);
72
73 // Returns the location in memory of the register |reg_index| in the
74 // interpreter register file.
75 Node* RegisterLocation(Node* reg_index);
76
77 // Constants.
78 Node* Int32Constant(int value);
79 Node* IntPtrConstant(intptr_t value);
80 Node* NumberConstant(double value);
81 Node* HeapConstant(Handle<HeapObject> object);
82 Node* BooleanConstant(bool value);
83
84 // Tag and untag Smi values.
85 Node* SmiTag(Node* value);
86 Node* SmiUntag(Node* value);
87
88 // Basic arithmetic operations.
89 Node* IntPtrAdd(Node* a, Node* b);
90 Node* IntPtrSub(Node* a, Node* b);
91 Node* Int32Sub(Node* a, Node* b);
92 Node* WordShl(Node* value, int shift);
93
94 // Load constant at |index| in the constant pool.
95 Node* LoadConstantPoolEntry(Node* index);
96
97 // Load an element from a fixed array on the heap.
98 Node* LoadFixedArrayElement(Node* fixed_array, int index);
99
100 // Load a field from an object on the heap.
101 Node* LoadObjectField(Node* object, int offset);
102
103 // Load |slot_index| from |context|.
104 Node* LoadContextSlot(Node* context, int slot_index);
105 Node* LoadContextSlot(Node* context, Node* slot_index);
106 // Stores |value| into |slot_index| of |context|.
107 Node* StoreContextSlot(Node* context, Node* slot_index, Node* value);
108
109 // Load the TypeFeedbackVector for the current function.
110 Node* LoadTypeFeedbackVector();
111
112 // Project the output value at index |index|
113 Node* Projection(int index, Node* node);
114
115 // Call constructor |constructor| with |arg_count| arguments (not
116 // including receiver) and the first argument located at
117 // |first_arg|. The |new_target| is the same as the
118 // |constructor| for the new keyword, but differs for the super
119 // keyword.
120 Node* CallConstruct(Node* new_target, Node* constructor, Node* first_arg,
121 Node* arg_count);
122
123 // Call JSFunction or Callable |function| with |arg_count|
124 // arguments (not including receiver) and the first argument
125 // located at |first_arg|.
126 Node* CallJS(Node* function, Node* first_arg, Node* arg_count);
127
128 // Call an IC code stub.
129 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1,
130 Node* arg2, Node* arg3);
131 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1,
132 Node* arg2, Node* arg3, Node* arg4);
133 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node* arg1,
134 Node* arg2, Node* arg3, Node* arg4, Node* arg5);
135
136 // Call runtime function.
137 Node* CallRuntime(Node* function_id, Node* first_arg, Node* arg_count,
138 int return_size = 1);
139 Node* CallRuntime(Runtime::FunctionId function_id);
140 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1);
141 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2);
142 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2,
143 Node* arg3);
144 Node* CallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2,
145 Node* arg3, Node* arg4);
146
147 // Jump relative to the current bytecode by |jump_offset|.
148 void Jump(Node* jump_offset);
149
150 // Jump relative to the current bytecode by |jump_offset| if the
151 // |condition| is true. Helper function for JumpIfWordEqual and
152 // JumpIfWordNotEqual.
153 void JumpConditional(Node* condition, Node* jump_offset);
154
155 // Jump relative to the current bytecode by |jump_offset| if the
156 // word values |lhs| and |rhs| are equal.
157 void JumpIfWordEqual(Node* lhs, Node* rhs, Node* jump_offset);
158
159 // Jump relative to the current bytecode by |jump_offset| if the
160 // word values |lhs| and |rhs| are not equal.
161 void JumpIfWordNotEqual(Node* lhs, Node* rhs, Node* jump_offset);
162
163 // Perform a stack guard check.
164 void StackCheck();
165
166 // Returns from the function.
167 void Return();
168
169 // Dispatch to the bytecode.
170 void Dispatch();
171
172 // Abort with the given bailout reason.
173 void Abort(BailoutReason bailout_reason);
174
175 protected:
176 static bool TargetSupportsUnalignedAccess();
177
178 // Protected helpers (for testing) which delegate to RawMachineAssembler.
179 CallDescriptor* call_descriptor() const;
180 Graph* graph();
181
182 private:
183 // Returns a raw pointer to start of the register file on the stack.
184 Node* RegisterFileRawPointer();
185 // Returns a tagged pointer to the current function's BytecodeArray object.
186 Node* BytecodeArrayTaggedPointer();
187 // Returns the offset from the BytecodeArrayPointer of the current bytecode.
188 Node* BytecodeOffset();
189 // Returns a raw pointer to first entry in the interpreter dispatch table.
190 Node* DispatchTableRawPointer();
191
192 // Saves and restores interpreter bytecode offset to the interpreter stack
193 // frame when performing a call.
194 void CallPrologue();
195
196 // Traces the current bytecode by calling |function_id|.
197 void TraceBytecode(Runtime::FunctionId function_id);
198
199 // Returns the offset of register |index| relative to RegisterFilePointer().
200 Node* RegisterFrameOffset(Node* index);
201
202 Node* SmiShiftBitsConstant();
203 Node* BytecodeOperand(int operand_index);
204 Node* BytecodeOperandSignExtended(int operand_index);
205 Node* BytecodeOperandShort(int operand_index);
206 Node* BytecodeOperandShortSignExtended(int operand_index);
207
208 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args);
209 Node* CallIC(CallInterfaceDescriptor descriptor, Node* target, Node** args);
210
211 // Returns BytecodeOffset() advanced by delta bytecodes. Note: this does not
212 // update BytecodeOffset() itself.
213 Node* Advance(int delta);
214 Node* Advance(Node* delta);
215
216 // Starts next instruction dispatch at |new_bytecode_offset|.
217 void DispatchTo(Node* new_bytecode_offset);
218
219 // Abort operations for debug code.
220 void AbortIfWordNotEqual(Node* lhs, Node* rhs, BailoutReason bailout_reason);
221
222 // Private helpers which delegate to RawMachineAssembler.
223 Isolate* isolate();
224 Zone* zone();
225
226 interpreter::Bytecode bytecode_;
227 base::SmartPointer<RawMachineAssembler> raw_assembler_;
228
229 Node* accumulator_;
230 Node* context_;
231
232 bool code_generated_;
233
234 DISALLOW_COPY_AND_ASSIGN(InterpreterAssembler);
235 };
236
237 } // namespace compiler
238 } // namespace internal
239 } // namespace v8
240
241 #endif // V8_COMPILER_INTERPRETER_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/compiler/code-stub-assembler.cc ('k') | src/compiler/interpreter-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698