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

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

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