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

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: Cleanup 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
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"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // from JavaScript. 87 // from JavaScript.
88 Handle<JSFunction> CompileJSToWasmWrapper(Isolate* isolate, 88 Handle<JSFunction> CompileJSToWasmWrapper(Isolate* isolate,
89 wasm::ModuleEnv* module, 89 wasm::ModuleEnv* module,
90 Handle<String> name, 90 Handle<String> name,
91 Handle<Code> wasm_code, 91 Handle<Code> wasm_code,
92 uint32_t index); 92 uint32_t index);
93 93
94 // Abstracts details of building TurboFan graph nodes for WASM to separate 94 // Abstracts details of building TurboFan graph nodes for WASM to separate
95 // the WASM decoder from the internal details of TurboFan. 95 // the WASM decoder from the internal details of TurboFan.
96 class WasmTrapHelper; 96 class WasmTrapHelper;
97 enum class Conversion { kNone, kOpaque, kInt32, kFloat32, kFloat64 };
97 class WasmGraphBuilder { 98 class WasmGraphBuilder {
98 public: 99 public:
99 WasmGraphBuilder( 100 WasmGraphBuilder(
100 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature, 101 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature,
101 compiler::SourcePositionTable* source_position_table = nullptr); 102 compiler::SourcePositionTable* source_position_table = nullptr);
102 103
103 Node** Buffer(size_t count) { 104 Node** Buffer(size_t count) {
104 if (count > cur_bufsize_) { 105 if (count > cur_bufsize_) {
105 size_t new_size = count + cur_bufsize_ + 5; 106 size_t new_size = count + cur_bufsize_ + 5;
106 cur_buffer_ = 107 cur_buffer_ =
(...skipping 13 matching lines...) Expand all
120 Node* Terminate(Node* effect, Node* control); 121 Node* Terminate(Node* effect, Node* control);
121 Node* Merge(unsigned count, Node** controls); 122 Node* Merge(unsigned count, Node** controls);
122 Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control); 123 Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control);
123 Node* EffectPhi(unsigned count, Node** effects, Node* control); 124 Node* EffectPhi(unsigned count, Node** effects, Node* control);
124 Node* NumberConstant(int32_t value); 125 Node* NumberConstant(int32_t value);
125 Node* Int32Constant(int32_t value); 126 Node* Int32Constant(int32_t value);
126 Node* Int64Constant(int64_t value); 127 Node* Int64Constant(int64_t value);
127 Node* Float32Constant(float value); 128 Node* Float32Constant(float value);
128 Node* Float64Constant(double value); 129 Node* Float64Constant(double value);
129 Node* HeapConstant(Handle<HeapObject> value); 130 Node* HeapConstant(Handle<HeapObject> value);
131 Node* DefaultS128Value();
130 Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right, 132 Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
131 wasm::WasmCodePosition position = wasm::kNoCodePosition); 133 wasm::WasmCodePosition position = wasm::kNoCodePosition);
132 Node* Unop(wasm::WasmOpcode opcode, Node* input, 134 Node* Unop(wasm::WasmOpcode opcode, Node* input,
133 wasm::WasmCodePosition position = wasm::kNoCodePosition); 135 wasm::WasmCodePosition position = wasm::kNoCodePosition);
134 unsigned InputCount(Node* node); 136 unsigned InputCount(Node* node);
135 bool IsPhiWithMerge(Node* phi, Node* merge); 137 bool IsPhiWithMerge(Node* phi, Node* merge);
136 void AppendToMerge(Node* merge, Node* from); 138 void AppendToMerge(Node* merge, Node* from);
137 void AppendToPhi(Node* phi, Node* from); 139 void AppendToPhi(Node* phi, Node* from);
138 140
139 //----------------------------------------------------------------------- 141 //-----------------------------------------------------------------------
(...skipping 14 matching lines...) Expand all
154 Node* CallIndirect(uint32_t index, Node** args, 156 Node* CallIndirect(uint32_t index, Node** args,
155 wasm::WasmCodePosition position); 157 wasm::WasmCodePosition position);
156 void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig); 158 void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig);
157 void BuildWasmToJSWrapper(Handle<JSFunction> function, 159 void BuildWasmToJSWrapper(Handle<JSFunction> function,
158 wasm::FunctionSig* sig); 160 wasm::FunctionSig* sig);
159 161
160 Node* ToJS(Node* node, Node* context, wasm::LocalType type); 162 Node* ToJS(Node* node, Node* context, wasm::LocalType type);
161 Node* FromJS(Node* node, Node* context, wasm::LocalType type); 163 Node* FromJS(Node* node, Node* context, wasm::LocalType type);
162 Node* Invert(Node* node); 164 Node* Invert(Node* node);
163 Node* FunctionTable(); 165 Node* FunctionTable();
166 Node* ChangeToRuntimeCall(Node* node, Runtime::FunctionId function_id,
167 const Conversion* signature);
titzer 2016/07/08 14:16:03 Can we make this a Signature<Conversion>, or bette
gdeepti 2016/07/11 09:50:34 Refactored this function and simd-lowering.cc to u
164 168
165 //----------------------------------------------------------------------- 169 //-----------------------------------------------------------------------
166 // Operations that concern the linear memory. 170 // Operations that concern the linear memory.
167 //----------------------------------------------------------------------- 171 //-----------------------------------------------------------------------
168 Node* MemSize(uint32_t offset); 172 Node* MemSize(uint32_t offset);
169 Node* LoadGlobal(uint32_t index); 173 Node* LoadGlobal(uint32_t index);
170 Node* StoreGlobal(uint32_t index, Node* val); 174 Node* StoreGlobal(uint32_t index, Node* val);
171 Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index, 175 Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index,
172 uint32_t offset, uint32_t alignment, 176 uint32_t offset, uint32_t alignment,
173 wasm::WasmCodePosition position); 177 wasm::WasmCodePosition position);
(...skipping 11 matching lines...) Expand all
185 void set_control_ptr(Node** control) { this->control_ = control; } 189 void set_control_ptr(Node** control) { this->control_ = control; }
186 190
187 void set_effect_ptr(Node** effect) { this->effect_ = effect; } 191 void set_effect_ptr(Node** effect) { this->effect_ = effect; }
188 192
189 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; } 193 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; }
190 194
191 void Int64LoweringForTesting(); 195 void Int64LoweringForTesting();
192 196
193 void SetSourcePosition(Node* node, wasm::WasmCodePosition position); 197 void SetSourcePosition(Node* node, wasm::WasmCodePosition position);
194 198
199 bool has_simd_ops() { return has_simd_ops_; }
200
195 private: 201 private:
196 static const int kDefaultBufferSize = 16; 202 static const int kDefaultBufferSize = 16;
197 friend class WasmTrapHelper; 203 friend class WasmTrapHelper;
198 204
199 Zone* zone_; 205 Zone* zone_;
200 JSGraph* jsgraph_; 206 JSGraph* jsgraph_;
201 wasm::ModuleEnv* module_; 207 wasm::ModuleEnv* module_;
202 Node* mem_buffer_; 208 Node* mem_buffer_;
203 Node* mem_size_; 209 Node* mem_size_;
204 Node* function_table_; 210 Node* function_table_;
205 Node** control_; 211 Node** control_;
206 Node** effect_; 212 Node** effect_;
207 Node** cur_buffer_; 213 Node** cur_buffer_;
208 size_t cur_bufsize_; 214 size_t cur_bufsize_;
209 Node* def_buffer_[kDefaultBufferSize]; 215 Node* def_buffer_[kDefaultBufferSize];
210 216
211 WasmTrapHelper* trap_; 217 WasmTrapHelper* trap_;
212 wasm::FunctionSig* function_signature_; 218 wasm::FunctionSig* function_signature_;
213 SetOncePointer<const Operator> allocate_heap_number_operator_; 219 SetOncePointer<const Operator> allocate_heap_number_operator_;
214 220
215 compiler::SourcePositionTable* source_position_table_ = nullptr; 221 compiler::SourcePositionTable* source_position_table_ = nullptr;
222 bool has_simd_ops_;
216 223
217 // Internal helper methods. 224 // Internal helper methods.
218 JSGraph* jsgraph() { return jsgraph_; } 225 JSGraph* jsgraph() { return jsgraph_; }
219 Graph* graph(); 226 Graph* graph();
220 227
221 Node* String(const char* string); 228 Node* String(const char* string);
222 Node* MemBuffer(uint32_t offset); 229 Node* MemBuffer(uint32_t offset);
223 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset, 230 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset,
224 wasm::WasmCodePosition position); 231 wasm::WasmCodePosition position);
225 232
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 Node* BuildI64RemS(Node* left, Node* right, wasm::WasmCodePosition position); 316 Node* BuildI64RemS(Node* left, Node* right, wasm::WasmCodePosition position);
310 Node* BuildI64DivU(Node* left, Node* right, wasm::WasmCodePosition position); 317 Node* BuildI64DivU(Node* left, Node* right, wasm::WasmCodePosition position);
311 Node* BuildI64RemU(Node* left, Node* right, wasm::WasmCodePosition position); 318 Node* BuildI64RemU(Node* left, Node* right, wasm::WasmCodePosition position);
312 Node* BuildDiv64Call(Node* left, Node* right, ExternalReference ref, 319 Node* BuildDiv64Call(Node* left, Node* right, ExternalReference ref,
313 MachineType result_type, int trap_zero, 320 MachineType result_type, int trap_zero,
314 wasm::WasmCodePosition position); 321 wasm::WasmCodePosition position);
315 322
316 Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect, 323 Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect,
317 Node* control); 324 Node* control);
318 Node* BuildChangeInt32ToTagged(Node* value); 325 Node* BuildChangeInt32ToTagged(Node* value);
326 Node* BuildChangeTaggedToInt32(Node* value);
319 Node* BuildChangeFloat64ToTagged(Node* value); 327 Node* BuildChangeFloat64ToTagged(Node* value);
320 Node* BuildChangeTaggedToFloat64(Node* value); 328 Node* BuildChangeTaggedToFloat64(Node* value);
321 329
322 Node* BuildChangeInt32ToSmi(Node* value); 330 Node* BuildChangeInt32ToSmi(Node* value);
323 Node* BuildChangeSmiToInt32(Node* value); 331 Node* BuildChangeSmiToInt32(Node* value);
324 Node* BuildChangeUint32ToSmi(Node* value); 332 Node* BuildChangeUint32ToSmi(Node* value);
325 Node* BuildChangeSmiToFloat64(Node* value); 333 Node* BuildChangeSmiToFloat64(Node* value);
326 Node* BuildTestNotSmi(Node* value); 334 Node* BuildTestNotSmi(Node* value);
327 Node* BuildSmiShiftBitsConstant(); 335 Node* BuildSmiShiftBitsConstant();
328 336
(...skipping 12 matching lines...) Expand all
341 Node* BuildI32AsmjsDivU(Node* left, Node* right); 349 Node* BuildI32AsmjsDivU(Node* left, Node* right);
342 Node* BuildI32AsmjsRemU(Node* left, Node* right); 350 Node* BuildI32AsmjsRemU(Node* left, Node* right);
343 Node* BuildAsmjsLoadMem(MachineType type, Node* index); 351 Node* BuildAsmjsLoadMem(MachineType type, Node* index);
344 Node* BuildAsmjsStoreMem(MachineType type, Node* index, Node* val); 352 Node* BuildAsmjsStoreMem(MachineType type, Node* index, Node* val);
345 353
346 Node** Realloc(Node** buffer, size_t old_count, size_t new_count) { 354 Node** Realloc(Node** buffer, size_t old_count, size_t new_count) {
347 Node** buf = Buffer(new_count); 355 Node** buf = Buffer(new_count);
348 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); 356 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*));
349 return buf; 357 return buf;
350 } 358 }
359
360 // Simd helper functions
361 void set_has_simd_ops(bool has_simd_ops) { has_simd_ops_ = has_simd_ops; }
bbudge 2016/07/08 17:17:29 Forgot to comment here. I can't think of a use cas
gdeepti 2016/07/11 09:50:34 Replaced setter with simd() method that sets this
351 }; 362 };
352 } // namespace compiler 363 } // namespace compiler
353 } // namespace internal 364 } // namespace internal
354 } // namespace v8 365 } // namespace v8
355 366
356 #endif // V8_COMPILER_WASM_COMPILER_H_ 367 #endif // V8_COMPILER_WASM_COMPILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698