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

Side by Side Diff: src/compiler/wasm-compiler.h

Issue 1991143002: Convert SIMD wasm ops to runtime function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bot fails Created 4 years, 5 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/simd-lowering.cc ('k') | src/compiler/wasm-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler.h" 10 #include "src/compiler.h"
11 #include "src/wasm/wasm-opcodes.h" 11 #include "src/wasm/wasm-opcodes.h"
12 #include "src/wasm/wasm-result.h" 12 #include "src/wasm/wasm-result.h"
13 #include "src/zone.h" 13 #include "src/zone.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 namespace compiler { 18 namespace compiler {
19 // Forward declarations for some compiler data structures. 19 // Forward declarations for some compiler data structures.
20 class Node; 20 class Node;
21 class JSGraph; 21 class JSGraph;
22 class Graph; 22 class Graph;
23 class Operator; 23 class Operator;
24 class SourcePositionTable; 24 class SourcePositionTable;
25 class MachineOperatorBuilder;
25 } // namespace compiler 26 } // namespace compiler
26 27
27 namespace wasm { 28 namespace wasm {
28 // Forward declarations for some WASM data structures. 29 // Forward declarations for some WASM data structures.
29 struct ModuleEnv; 30 struct ModuleEnv;
30 struct WasmFunction; 31 struct WasmFunction;
31 class ErrorThrower; 32 class ErrorThrower;
32 struct DecodeStruct; 33 struct DecodeStruct;
33 34
34 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. 35 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Handle<String> import_module, 84 Handle<String> import_module,
84 MaybeHandle<String> import_function); 85 MaybeHandle<String> import_function);
85 86
86 // Wraps a given wasm code object, producing a code object. 87 // Wraps a given wasm code object, producing a code object.
87 Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::ModuleEnv* module, 88 Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::ModuleEnv* module,
88 Handle<Code> wasm_code, uint32_t index); 89 Handle<Code> wasm_code, uint32_t index);
89 90
90 // Abstracts details of building TurboFan graph nodes for WASM to separate 91 // Abstracts details of building TurboFan graph nodes for WASM to separate
91 // the WASM decoder from the internal details of TurboFan. 92 // the WASM decoder from the internal details of TurboFan.
92 class WasmTrapHelper; 93 class WasmTrapHelper;
94 enum class Conversion { kNone, kOpaque, kInt32, kFloat32, kFloat64 };
95 typedef ZoneVector<Node*> NodeVector;
93 class WasmGraphBuilder { 96 class WasmGraphBuilder {
94 public: 97 public:
95 WasmGraphBuilder( 98 WasmGraphBuilder(
96 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature, 99 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature,
97 compiler::SourcePositionTable* source_position_table = nullptr); 100 compiler::SourcePositionTable* source_position_table = nullptr);
98 101
99 Node** Buffer(size_t count) { 102 Node** Buffer(size_t count) {
100 if (count > cur_bufsize_) { 103 if (count > cur_bufsize_) {
101 size_t new_size = count + cur_bufsize_ + 5; 104 size_t new_size = count + cur_bufsize_ + 5;
102 cur_buffer_ = 105 cur_buffer_ =
(...skipping 14 matching lines...) Expand all
117 Node* Merge(unsigned count, Node** controls); 120 Node* Merge(unsigned count, Node** controls);
118 Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control); 121 Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control);
119 Node* EffectPhi(unsigned count, Node** effects, Node* control); 122 Node* EffectPhi(unsigned count, Node** effects, Node* control);
120 Node* NumberConstant(int32_t value); 123 Node* NumberConstant(int32_t value);
121 Node* Uint32Constant(uint32_t value); 124 Node* Uint32Constant(uint32_t value);
122 Node* Int32Constant(int32_t value); 125 Node* Int32Constant(int32_t value);
123 Node* Int64Constant(int64_t value); 126 Node* Int64Constant(int64_t value);
124 Node* Float32Constant(float value); 127 Node* Float32Constant(float value);
125 Node* Float64Constant(double value); 128 Node* Float64Constant(double value);
126 Node* HeapConstant(Handle<HeapObject> value); 129 Node* HeapConstant(Handle<HeapObject> value);
130 Node* DefaultS128Value();
127 Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right, 131 Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
128 wasm::WasmCodePosition position = wasm::kNoCodePosition); 132 wasm::WasmCodePosition position = wasm::kNoCodePosition);
129 Node* Unop(wasm::WasmOpcode opcode, Node* input, 133 Node* Unop(wasm::WasmOpcode opcode, Node* input,
130 wasm::WasmCodePosition position = wasm::kNoCodePosition); 134 wasm::WasmCodePosition position = wasm::kNoCodePosition);
131 unsigned InputCount(Node* node); 135 unsigned InputCount(Node* node);
132 bool IsPhiWithMerge(Node* phi, Node* merge); 136 bool IsPhiWithMerge(Node* phi, Node* merge);
133 void AppendToMerge(Node* merge, Node* from); 137 void AppendToMerge(Node* merge, Node* from);
134 void AppendToPhi(Node* phi, Node* from); 138 void AppendToPhi(Node* phi, Node* from);
135 139
136 //----------------------------------------------------------------------- 140 //-----------------------------------------------------------------------
(...skipping 17 matching lines...) Expand all
154 uint32_t sig_index, wasm::FunctionSig* sig, 158 uint32_t sig_index, wasm::FunctionSig* sig,
155 wasm::WasmCodePosition position); 159 wasm::WasmCodePosition position);
156 void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig); 160 void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig);
157 void BuildWasmToJSWrapper(Handle<JSFunction> function, 161 void BuildWasmToJSWrapper(Handle<JSFunction> function,
158 wasm::FunctionSig* sig); 162 wasm::FunctionSig* sig);
159 163
160 Node* ToJS(Node* node, Node* context, wasm::LocalType type); 164 Node* ToJS(Node* node, Node* context, wasm::LocalType type);
161 Node* FromJS(Node* node, Node* context, wasm::LocalType type); 165 Node* FromJS(Node* node, Node* context, wasm::LocalType type);
162 Node* Invert(Node* node); 166 Node* Invert(Node* node);
163 Node* FunctionTable(); 167 Node* FunctionTable();
168 Node* ChangeToRuntimeCall(Node* node, Runtime::FunctionId function_id,
169 Signature<Conversion>* signature);
164 170
165 //----------------------------------------------------------------------- 171 //-----------------------------------------------------------------------
166 // Operations that concern the linear memory. 172 // Operations that concern the linear memory.
167 //----------------------------------------------------------------------- 173 //-----------------------------------------------------------------------
168 Node* MemSize(uint32_t offset); 174 Node* MemSize(uint32_t offset);
169 Node* LoadGlobal(uint32_t index); 175 Node* LoadGlobal(uint32_t index);
170 Node* StoreGlobal(uint32_t index, Node* val); 176 Node* StoreGlobal(uint32_t index, Node* val);
171 Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index, 177 Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index,
172 uint32_t offset, uint32_t alignment, 178 uint32_t offset, uint32_t alignment,
173 wasm::WasmCodePosition position); 179 wasm::WasmCodePosition position);
(...skipping 11 matching lines...) Expand all
185 void set_control_ptr(Node** control) { this->control_ = control; } 191 void set_control_ptr(Node** control) { this->control_ = control; }
186 192
187 void set_effect_ptr(Node** effect) { this->effect_ = effect; } 193 void set_effect_ptr(Node** effect) { this->effect_ = effect; }
188 194
189 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; } 195 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; }
190 196
191 void Int64LoweringForTesting(); 197 void Int64LoweringForTesting();
192 198
193 void SetSourcePosition(Node* node, wasm::WasmCodePosition position); 199 void SetSourcePosition(Node* node, wasm::WasmCodePosition position);
194 200
201 Node* SimdOp(wasm::WasmOpcode opcode, const NodeVector& inputs);
202
203 bool has_simd_ops() { return has_simd_ops_; }
204
195 private: 205 private:
196 static const int kDefaultBufferSize = 16; 206 static const int kDefaultBufferSize = 16;
197 friend class WasmTrapHelper; 207 friend class WasmTrapHelper;
198 208
199 Zone* zone_; 209 Zone* zone_;
200 JSGraph* jsgraph_; 210 JSGraph* jsgraph_;
201 wasm::ModuleEnv* module_; 211 wasm::ModuleEnv* module_;
202 Node* mem_buffer_; 212 Node* mem_buffer_;
203 Node* mem_size_; 213 Node* mem_size_;
204 Node* function_table_; 214 Node* function_table_;
205 Node** control_; 215 Node** control_;
206 Node** effect_; 216 Node** effect_;
207 Node** cur_buffer_; 217 Node** cur_buffer_;
208 size_t cur_bufsize_; 218 size_t cur_bufsize_;
209 Node* def_buffer_[kDefaultBufferSize]; 219 Node* def_buffer_[kDefaultBufferSize];
210 220
211 WasmTrapHelper* trap_; 221 WasmTrapHelper* trap_;
212 wasm::FunctionSig* function_signature_; 222 wasm::FunctionSig* function_signature_;
213 SetOncePointer<const Operator> allocate_heap_number_operator_; 223 SetOncePointer<const Operator> allocate_heap_number_operator_;
214 224
215 compiler::SourcePositionTable* source_position_table_ = nullptr; 225 compiler::SourcePositionTable* source_position_table_ = nullptr;
226 bool has_simd_ops_ = false;
216 227
217 // Internal helper methods. 228 // Internal helper methods.
218 JSGraph* jsgraph() { return jsgraph_; } 229 JSGraph* jsgraph() { return jsgraph_; }
219 Graph* graph(); 230 Graph* graph();
220 231
221 Node* String(const char* string); 232 Node* String(const char* string);
222 Node* MemBuffer(uint32_t offset); 233 Node* MemBuffer(uint32_t offset);
223 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset, 234 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset,
224 wasm::WasmCodePosition position); 235 wasm::WasmCodePosition position);
225 236
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 Node* BuildI64RemS(Node* left, Node* right, wasm::WasmCodePosition position); 320 Node* BuildI64RemS(Node* left, Node* right, wasm::WasmCodePosition position);
310 Node* BuildI64DivU(Node* left, Node* right, wasm::WasmCodePosition position); 321 Node* BuildI64DivU(Node* left, Node* right, wasm::WasmCodePosition position);
311 Node* BuildI64RemU(Node* left, Node* right, wasm::WasmCodePosition position); 322 Node* BuildI64RemU(Node* left, Node* right, wasm::WasmCodePosition position);
312 Node* BuildDiv64Call(Node* left, Node* right, ExternalReference ref, 323 Node* BuildDiv64Call(Node* left, Node* right, ExternalReference ref,
313 MachineType result_type, int trap_zero, 324 MachineType result_type, int trap_zero,
314 wasm::WasmCodePosition position); 325 wasm::WasmCodePosition position);
315 326
316 Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect, 327 Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect,
317 Node* control); 328 Node* control);
318 Node* BuildChangeInt32ToTagged(Node* value); 329 Node* BuildChangeInt32ToTagged(Node* value);
330 Node* BuildChangeTaggedToInt32(Node* value);
319 Node* BuildChangeFloat64ToTagged(Node* value); 331 Node* BuildChangeFloat64ToTagged(Node* value);
320 Node* BuildChangeTaggedToFloat64(Node* value); 332 Node* BuildChangeTaggedToFloat64(Node* value);
321 333
322 Node* BuildChangeInt32ToSmi(Node* value); 334 Node* BuildChangeInt32ToSmi(Node* value);
323 Node* BuildChangeSmiToInt32(Node* value); 335 Node* BuildChangeSmiToInt32(Node* value);
324 Node* BuildChangeUint32ToSmi(Node* value); 336 Node* BuildChangeUint32ToSmi(Node* value);
325 Node* BuildChangeSmiToFloat64(Node* value); 337 Node* BuildChangeSmiToFloat64(Node* value);
326 Node* BuildTestNotSmi(Node* value); 338 Node* BuildTestNotSmi(Node* value);
327 Node* BuildSmiShiftBitsConstant(); 339 Node* BuildSmiShiftBitsConstant();
328 340
(...skipping 12 matching lines...) Expand all
341 Node* BuildI32AsmjsDivU(Node* left, Node* right); 353 Node* BuildI32AsmjsDivU(Node* left, Node* right);
342 Node* BuildI32AsmjsRemU(Node* left, Node* right); 354 Node* BuildI32AsmjsRemU(Node* left, Node* right);
343 Node* BuildAsmjsLoadMem(MachineType type, Node* index); 355 Node* BuildAsmjsLoadMem(MachineType type, Node* index);
344 Node* BuildAsmjsStoreMem(MachineType type, Node* index, Node* val); 356 Node* BuildAsmjsStoreMem(MachineType type, Node* index, Node* val);
345 357
346 Node** Realloc(Node** buffer, size_t old_count, size_t new_count) { 358 Node** Realloc(Node** buffer, size_t old_count, size_t new_count) {
347 Node** buf = Buffer(new_count); 359 Node** buf = Buffer(new_count);
348 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); 360 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*));
349 return buf; 361 return buf;
350 } 362 }
363
364 // Simd helper functions
365 MachineOperatorBuilder* simd();
351 }; 366 };
352 } // namespace compiler 367 } // namespace compiler
353 } // namespace internal 368 } // namespace internal
354 } // namespace v8 369 } // namespace v8
355 370
356 #endif // V8_COMPILER_WASM_COMPILER_H_ 371 #endif // V8_COMPILER_WASM_COMPILER_H_
OLDNEW
« no previous file with comments | « src/compiler/simd-lowering.cc ('k') | src/compiler/wasm-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698