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_WASM_COMPILER_H_ | 5 #ifndef V8_COMPILER_WASM_COMPILER_H_ |
6 #define V8_COMPILER_WASM_COMPILER_H_ | 6 #define V8_COMPILER_WASM_COMPILER_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/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 Node* Terminate(Node* effect, Node* control); | 81 Node* Terminate(Node* effect, Node* control); |
82 Node* Merge(unsigned count, Node** controls); | 82 Node* Merge(unsigned count, Node** controls); |
83 Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control); | 83 Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control); |
84 Node* EffectPhi(unsigned count, Node** effects, Node* control); | 84 Node* EffectPhi(unsigned count, Node** effects, Node* control); |
85 Node* NumberConstant(int32_t value); | 85 Node* NumberConstant(int32_t value); |
86 Node* Int32Constant(int32_t value); | 86 Node* Int32Constant(int32_t value); |
87 Node* Int64Constant(int64_t value); | 87 Node* Int64Constant(int64_t value); |
88 Node* Float32Constant(float value); | 88 Node* Float32Constant(float value); |
89 Node* Float64Constant(double value); | 89 Node* Float64Constant(double value); |
90 Node* Constant(Handle<Object> value); | 90 Node* Constant(Handle<Object> value); |
91 Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right); | 91 Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right, |
92 Node* Unop(wasm::WasmOpcode opcode, Node* input); | 92 int position = -1); |
titzer
2016/04/28 11:27:00
Let's introduce a typedef to separate normal ints
Clemens Hammacher
2016/04/28 12:43:28
Done.
| |
93 Node* Unop(wasm::WasmOpcode opcode, Node* input, int position = -1); | |
93 unsigned InputCount(Node* node); | 94 unsigned InputCount(Node* node); |
94 bool IsPhiWithMerge(Node* phi, Node* merge); | 95 bool IsPhiWithMerge(Node* phi, Node* merge); |
95 void AppendToMerge(Node* merge, Node* from); | 96 void AppendToMerge(Node* merge, Node* from); |
96 void AppendToPhi(Node* merge, Node* phi, Node* from); | 97 void AppendToPhi(Node* phi, Node* from); |
97 | 98 |
98 //----------------------------------------------------------------------- | 99 //----------------------------------------------------------------------- |
99 // Operations that read and/or write {control} and {effect}. | 100 // Operations that read and/or write {control} and {effect}. |
100 //----------------------------------------------------------------------- | 101 //----------------------------------------------------------------------- |
101 Node* Branch(Node* cond, Node** true_node, Node** false_node); | 102 Node* Branch(Node* cond, Node** true_node, Node** false_node); |
102 Node* Switch(unsigned count, Node* key); | 103 Node* Switch(unsigned count, Node* key); |
103 Node* IfValue(int32_t value, Node* sw); | 104 Node* IfValue(int32_t value, Node* sw); |
104 Node* IfDefault(Node* sw); | 105 Node* IfDefault(Node* sw); |
105 Node* Return(unsigned count, Node** vals); | 106 Node* Return(unsigned count, Node** vals); |
106 Node* ReturnVoid(); | 107 Node* ReturnVoid(); |
107 Node* Unreachable(); | 108 Node* Unreachable(int position); |
108 | 109 |
109 Node* CallDirect(uint32_t index, Node** args); | 110 Node* CallDirect(uint32_t index, Node** args); |
110 Node* CallImport(uint32_t index, Node** args); | 111 Node* CallImport(uint32_t index, Node** args); |
111 Node* CallIndirect(uint32_t index, Node** args); | 112 Node* CallIndirect(uint32_t index, Node** args, int position); |
112 void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig); | 113 void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig); |
113 void BuildWasmToJSWrapper(Handle<JSFunction> function, | 114 void BuildWasmToJSWrapper(Handle<JSFunction> function, |
114 wasm::FunctionSig* sig); | 115 wasm::FunctionSig* sig); |
115 | 116 |
116 Node* ToJS(Node* node, Node* context, wasm::LocalType type); | 117 Node* ToJS(Node* node, Node* context, wasm::LocalType type); |
117 Node* FromJS(Node* node, Node* context, wasm::LocalType type); | 118 Node* FromJS(Node* node, Node* context, wasm::LocalType type); |
118 Node* Invert(Node* node); | 119 Node* Invert(Node* node); |
119 Node* FunctionTable(); | 120 Node* FunctionTable(); |
120 | 121 |
121 //----------------------------------------------------------------------- | 122 //----------------------------------------------------------------------- |
122 // Operations that concern the linear memory. | 123 // Operations that concern the linear memory. |
123 //----------------------------------------------------------------------- | 124 //----------------------------------------------------------------------- |
124 Node* MemSize(uint32_t offset); | 125 Node* MemSize(uint32_t offset); |
125 Node* LoadGlobal(uint32_t index); | 126 Node* LoadGlobal(uint32_t index); |
126 Node* StoreGlobal(uint32_t index, Node* val); | 127 Node* StoreGlobal(uint32_t index, Node* val); |
127 Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index, | 128 Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index, |
128 uint32_t offset); | 129 uint32_t offset, int position); |
129 Node* StoreMem(MachineType type, Node* index, uint32_t offset, Node* val); | 130 Node* StoreMem(MachineType type, Node* index, uint32_t offset, Node* val, |
131 int position); | |
130 | 132 |
131 static void PrintDebugName(Node* node); | 133 static void PrintDebugName(Node* node); |
132 | 134 |
133 Node* Control() { return *control_; } | 135 Node* Control() { return *control_; } |
134 Node* Effect() { return *effect_; } | 136 Node* Effect() { return *effect_; } |
135 | 137 |
136 void set_module(wasm::ModuleEnv* module) { this->module_ = module; } | 138 void set_module(wasm::ModuleEnv* module) { this->module_ = module; } |
137 | 139 |
138 void set_control_ptr(Node** control) { this->control_ = control; } | 140 void set_control_ptr(Node** control) { this->control_ = control; } |
139 | 141 |
(...skipping 26 matching lines...) Expand all Loading... | |
166 SetOncePointer<const Operator> allocate_heap_number_operator_; | 168 SetOncePointer<const Operator> allocate_heap_number_operator_; |
167 | 169 |
168 compiler::SourcePositionTable* source_position_table_ = nullptr; | 170 compiler::SourcePositionTable* source_position_table_ = nullptr; |
169 | 171 |
170 // Internal helper methods. | 172 // Internal helper methods. |
171 JSGraph* jsgraph() { return jsgraph_; } | 173 JSGraph* jsgraph() { return jsgraph_; } |
172 Graph* graph(); | 174 Graph* graph(); |
173 | 175 |
174 Node* String(const char* string); | 176 Node* String(const char* string); |
175 Node* MemBuffer(uint32_t offset); | 177 Node* MemBuffer(uint32_t offset); |
176 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset); | 178 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset, |
179 int position); | |
177 | 180 |
178 Node* MaskShiftCount32(Node* node); | 181 Node* MaskShiftCount32(Node* node); |
179 Node* MaskShiftCount64(Node* node); | 182 Node* MaskShiftCount64(Node* node); |
180 | 183 |
181 Node* BuildCCall(MachineSignature* sig, Node** args); | 184 Node* BuildCCall(MachineSignature* sig, Node** args); |
182 Node* BuildWasmCall(wasm::FunctionSig* sig, Node** args); | 185 Node* BuildWasmCall(wasm::FunctionSig* sig, Node** args); |
183 | 186 |
184 Node* BuildF32Neg(Node* input); | 187 Node* BuildF32Neg(Node* input); |
185 Node* BuildF64Neg(Node* input); | 188 Node* BuildF64Neg(Node* input); |
186 Node* BuildF32CopySign(Node* left, Node* right); | 189 Node* BuildF32CopySign(Node* left, Node* right); |
187 Node* BuildF64CopySign(Node* left, Node* right); | 190 Node* BuildF64CopySign(Node* left, Node* right); |
188 Node* BuildF32Min(Node* left, Node* right); | 191 Node* BuildF32Min(Node* left, Node* right); |
189 Node* BuildF32Max(Node* left, Node* right); | 192 Node* BuildF32Max(Node* left, Node* right); |
190 Node* BuildF64Min(Node* left, Node* right); | 193 Node* BuildF64Min(Node* left, Node* right); |
191 Node* BuildF64Max(Node* left, Node* right); | 194 Node* BuildF64Max(Node* left, Node* right); |
192 Node* BuildI32SConvertF32(Node* input); | 195 Node* BuildI32SConvertF32(Node* input, int position); |
193 Node* BuildI32SConvertF64(Node* input); | 196 Node* BuildI32SConvertF64(Node* input, int position); |
194 Node* BuildI32UConvertF32(Node* input); | 197 Node* BuildI32UConvertF32(Node* input, int position); |
195 Node* BuildI32UConvertF64(Node* input); | 198 Node* BuildI32UConvertF64(Node* input, int position); |
196 Node* BuildI32Ctz(Node* input); | 199 Node* BuildI32Ctz(Node* input); |
197 Node* BuildI32Popcnt(Node* input); | 200 Node* BuildI32Popcnt(Node* input); |
198 Node* BuildI64Ctz(Node* input); | 201 Node* BuildI64Ctz(Node* input); |
199 Node* BuildI64Popcnt(Node* input); | 202 Node* BuildI64Popcnt(Node* input); |
200 Node* BuildBitCountingCall(Node* input, ExternalReference ref, | 203 Node* BuildBitCountingCall(Node* input, ExternalReference ref, |
201 MachineRepresentation input_type); | 204 MachineRepresentation input_type); |
202 | 205 |
203 Node* BuildCFuncInstruction(ExternalReference ref, MachineType type, | 206 Node* BuildCFuncInstruction(ExternalReference ref, MachineType type, |
204 Node* input0, Node* input1 = nullptr); | 207 Node* input0, Node* input1 = nullptr); |
205 Node* BuildF32Trunc(Node* input); | 208 Node* BuildF32Trunc(Node* input); |
(...skipping 24 matching lines...) Expand all Loading... | |
230 MachineRepresentation parameter_representation, | 233 MachineRepresentation parameter_representation, |
231 const MachineType result_type); | 234 const MachineType result_type); |
232 Node* BuildF32SConvertI64(Node* input); | 235 Node* BuildF32SConvertI64(Node* input); |
233 Node* BuildF32UConvertI64(Node* input); | 236 Node* BuildF32UConvertI64(Node* input); |
234 Node* BuildF64SConvertI64(Node* input); | 237 Node* BuildF64SConvertI64(Node* input); |
235 Node* BuildF64UConvertI64(Node* input); | 238 Node* BuildF64UConvertI64(Node* input); |
236 | 239 |
237 Node* BuildFloatToIntConversionInstruction( | 240 Node* BuildFloatToIntConversionInstruction( |
238 Node* input, ExternalReference ref, | 241 Node* input, ExternalReference ref, |
239 MachineRepresentation parameter_representation, | 242 MachineRepresentation parameter_representation, |
240 const MachineType result_type); | 243 const MachineType result_type, int position); |
241 Node* BuildI64SConvertF32(Node* input); | 244 Node* BuildI64SConvertF32(Node* input, int position); |
242 Node* BuildI64UConvertF32(Node* input); | 245 Node* BuildI64UConvertF32(Node* input, int position); |
243 Node* BuildI64SConvertF64(Node* input); | 246 Node* BuildI64SConvertF64(Node* input, int position); |
244 Node* BuildI64UConvertF64(Node* input); | 247 Node* BuildI64UConvertF64(Node* input, int position); |
245 | 248 |
246 Node* BuildI32DivS(Node* left, Node* right); | 249 Node* BuildI32DivS(Node* left, Node* right, int position); |
247 Node* BuildI32RemS(Node* left, Node* right); | 250 Node* BuildI32RemS(Node* left, Node* right, int position); |
248 Node* BuildI32DivU(Node* left, Node* right); | 251 Node* BuildI32DivU(Node* left, Node* right, int position); |
249 Node* BuildI32RemU(Node* left, Node* right); | 252 Node* BuildI32RemU(Node* left, Node* right, int position); |
250 | 253 |
251 Node* BuildI64DivS(Node* left, Node* right); | 254 Node* BuildI64DivS(Node* left, Node* right, int position); |
252 Node* BuildI64RemS(Node* left, Node* right); | 255 Node* BuildI64RemS(Node* left, Node* right, int position); |
253 Node* BuildI64DivU(Node* left, Node* right); | 256 Node* BuildI64DivU(Node* left, Node* right, int position); |
254 Node* BuildI64RemU(Node* left, Node* right); | 257 Node* BuildI64RemU(Node* left, Node* right, int position); |
255 Node* BuildDiv64Call(Node* left, Node* right, ExternalReference ref, | 258 Node* BuildDiv64Call(Node* left, Node* right, ExternalReference ref, |
256 MachineType result_type, int trap_zero); | 259 MachineType result_type, int trap_zero, int position); |
257 | 260 |
258 Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect, | 261 Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect, |
259 Node* control); | 262 Node* control); |
260 Node* BuildChangeInt32ToTagged(Node* value); | 263 Node* BuildChangeInt32ToTagged(Node* value); |
261 Node* BuildChangeFloat64ToTagged(Node* value); | 264 Node* BuildChangeFloat64ToTagged(Node* value); |
262 Node* BuildChangeTaggedToFloat64(Node* value); | 265 Node* BuildChangeTaggedToFloat64(Node* value); |
263 | 266 |
264 Node* BuildChangeInt32ToSmi(Node* value); | 267 Node* BuildChangeInt32ToSmi(Node* value); |
265 Node* BuildChangeSmiToInt32(Node* value); | 268 Node* BuildChangeSmiToInt32(Node* value); |
266 Node* BuildChangeSmiToFloat64(Node* value); | 269 Node* BuildChangeSmiToFloat64(Node* value); |
267 Node* BuildTestNotSmi(Node* value); | 270 Node* BuildTestNotSmi(Node* value); |
268 Node* BuildSmiShiftBitsConstant(); | 271 Node* BuildSmiShiftBitsConstant(); |
269 | 272 |
270 Node* BuildAllocateHeapNumberWithValue(Node* value, Node* control); | 273 Node* BuildAllocateHeapNumberWithValue(Node* value, Node* control); |
271 Node* BuildLoadHeapNumberValue(Node* value, Node* control); | 274 Node* BuildLoadHeapNumberValue(Node* value, Node* control); |
272 Node* BuildHeapNumberValueIndexConstant(); | 275 Node* BuildHeapNumberValueIndexConstant(); |
273 | 276 |
274 Node** Realloc(Node** buffer, size_t old_count, size_t new_count) { | 277 Node** Realloc(Node** buffer, size_t old_count, size_t new_count) { |
275 Node** buf = Buffer(new_count); | 278 Node** buf = Buffer(new_count); |
276 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); | 279 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); |
277 return buf; | 280 return buf; |
278 } | 281 } |
279 }; | 282 }; |
280 } // namespace compiler | 283 } // namespace compiler |
281 } // namespace internal | 284 } // namespace internal |
282 } // namespace v8 | 285 } // namespace v8 |
283 | 286 |
284 #endif // V8_COMPILER_WASM_COMPILER_H_ | 287 #endif // V8_COMPILER_WASM_COMPILER_H_ |
OLD | NEW |