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 #include "src/base/platform/elapsed-timer.h" | 5 #include "src/base/platform/elapsed-timer.h" |
6 #include "src/signature.h" | 6 #include "src/signature.h" |
7 | 7 |
8 #include "src/bit-vector.h" | 8 #include "src/bit-vector.h" |
9 #include "src/flags.h" | 9 #include "src/flags.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
11 #include "src/zone-containers.h" | 11 #include "src/zone-containers.h" |
12 | 12 |
13 #include "src/wasm/ast-decoder.h" | 13 #include "src/wasm/ast-decoder.h" |
14 #include "src/wasm/decoder.h" | 14 #include "src/wasm/decoder.h" |
15 #include "src/wasm/wasm-module.h" | 15 #include "src/wasm/wasm-module.h" |
16 #include "src/wasm/wasm-opcodes.h" | 16 #include "src/wasm/wasm-opcodes.h" |
17 | 17 |
18 #include "src/compiler/wasm-compiler.h" | 18 #include "src/compiler/wasm-compiler.h" |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 namespace wasm { | 22 namespace wasm { |
23 | 23 |
24 #if DEBUG | |
25 #define TRACE(...) \ | 24 #define TRACE(...) \ |
26 do { \ | 25 do { \ |
27 if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ | 26 if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ |
28 } while (false) | 27 } while (false) |
29 #else | |
30 #define TRACE(...) | |
31 #endif | |
32 | 28 |
33 // The root of a decoded tree. | 29 // The root of a decoded tree. |
34 struct Tree { | 30 struct Tree { |
35 LocalType type; // tree type. | 31 LocalType type; // tree type. |
36 uint32_t count; // number of children. | 32 uint32_t count; // number of children. |
37 const byte* pc; // start of the syntax tree. | 33 const byte* pc; // start of the syntax tree. |
38 TFNode* node; // node in the TurboFan graph. | 34 TFNode* node; // node in the TurboFan graph. |
39 Tree* children[1]; // pointers to children. | 35 Tree* children[1]; // pointers to children. |
40 | 36 |
41 WasmOpcode opcode() const { return static_cast<WasmOpcode>(*pc); } | 37 WasmOpcode opcode() const { return static_cast<WasmOpcode>(*pc); } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 case kExprSetLocal: | 232 case kExprSetLocal: |
237 return 1; | 233 return 1; |
238 | 234 |
239 case kExprIf: | 235 case kExprIf: |
240 case kExprBrIf: | 236 case kExprBrIf: |
241 return 2; | 237 return 2; |
242 case kExprIfElse: | 238 case kExprIfElse: |
243 case kExprSelect: | 239 case kExprSelect: |
244 return 3; | 240 return 3; |
245 | 241 |
246 case kExprBlock: | 242 case kExprBlock: { |
| 243 BlockCountOperand operand(this, pc); |
| 244 return operand.count; |
| 245 } |
247 case kExprLoop: { | 246 case kExprLoop: { |
248 BlockCountOperand operand(this, pc); | 247 LoopCountOperand operand(this, pc); |
249 return operand.count; | 248 return operand.count; |
250 } | 249 } |
251 | 250 |
252 case kExprCallFunction: { | 251 case kExprCallFunction: { |
253 FunctionIndexOperand operand(this, pc); | 252 FunctionIndexOperand operand(this, pc); |
254 return static_cast<int>( | 253 return static_cast<int>( |
255 function_env_->module->GetFunctionSignature(operand.index) | 254 function_env_->module->GetFunctionSignature(operand.index) |
256 ->parameter_count()); | 255 ->parameter_count()); |
257 } | 256 } |
258 case kExprCallIndirect: { | 257 case kExprCallIndirect: { |
(...skipping 27 matching lines...) Expand all Loading... |
286 int OpcodeLength(const byte* pc) { | 285 int OpcodeLength(const byte* pc) { |
287 switch (static_cast<WasmOpcode>(*pc)) { | 286 switch (static_cast<WasmOpcode>(*pc)) { |
288 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: | 287 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: |
289 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) | 288 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) |
290 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) | 289 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) |
291 #undef DECLARE_OPCODE_CASE | 290 #undef DECLARE_OPCODE_CASE |
292 { | 291 { |
293 MemoryAccessOperand operand(this, pc); | 292 MemoryAccessOperand operand(this, pc); |
294 return 1 + operand.length; | 293 return 1 + operand.length; |
295 } | 294 } |
296 case kExprBlock: | 295 case kExprBlock: { |
| 296 BlockCountOperand operand(this, pc); |
| 297 return 1 + operand.length; |
| 298 } |
297 case kExprLoop: { | 299 case kExprLoop: { |
298 BlockCountOperand operand(this, pc); | 300 LoopCountOperand operand(this, pc); |
299 return 1 + operand.length; | 301 return 1 + operand.length; |
300 } | 302 } |
301 case kExprBr: | 303 case kExprBr: |
302 case kExprBrIf: { | 304 case kExprBrIf: { |
303 BreakDepthOperand operand(this, pc); | 305 BreakDepthOperand operand(this, pc); |
304 return 1 + operand.length; | 306 return 1 + operand.length; |
305 } | 307 } |
306 case kExprStoreGlobal: | 308 case kExprStoreGlobal: |
307 case kExprLoadGlobal: { | 309 case kExprLoadGlobal: { |
308 GlobalIndexOperand operand(this, pc); | 310 GlobalIndexOperand operand(this, pc); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 Shift(kAstEnd, operand.count); | 586 Shift(kAstEnd, operand.count); |
585 // The break environment is the outer environment. | 587 // The break environment is the outer environment. |
586 SsaEnv* break_env = ssa_env_; | 588 SsaEnv* break_env = ssa_env_; |
587 PushBlock(break_env); | 589 PushBlock(break_env); |
588 SetEnv("block:start", Steal(break_env)); | 590 SetEnv("block:start", Steal(break_env)); |
589 } | 591 } |
590 len = 1 + operand.length; | 592 len = 1 + operand.length; |
591 break; | 593 break; |
592 } | 594 } |
593 case kExprLoop: { | 595 case kExprLoop: { |
594 BlockCountOperand operand(this, pc_); | 596 LoopCountOperand operand(this, pc_); |
595 if (operand.count < 1) { | 597 if (operand.count < 1) { |
596 Leaf(kAstStmt); | 598 Leaf(kAstStmt); |
597 } else { | 599 } else { |
598 Shift(kAstEnd, operand.count); | 600 Shift(kAstEnd, operand.count); |
599 // The break environment is the outer environment. | 601 // The break environment is the outer environment. |
600 SsaEnv* break_env = ssa_env_; | 602 SsaEnv* break_env = ssa_env_; |
601 PushBlock(break_env); | 603 PushBlock(break_env); |
602 SsaEnv* cont_env = Steal(break_env); | 604 SsaEnv* cont_env = Steal(break_env); |
603 // The continue environment is the inner environment. | 605 // The continue environment is the inner environment. |
604 PrepareForLoop(cont_env); | 606 PrepareForLoop(cont_env); |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 | 1656 |
1655 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, FunctionEnv* env, | 1657 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, FunctionEnv* env, |
1656 const byte* start, const byte* end) { | 1658 const byte* start, const byte* end) { |
1657 LoopAssignmentAnalyzer analyzer(zone, env); | 1659 LoopAssignmentAnalyzer analyzer(zone, env); |
1658 return analyzer.Analyze(start, end); | 1660 return analyzer.Analyze(start, end); |
1659 } | 1661 } |
1660 | 1662 |
1661 } // namespace wasm | 1663 } // namespace wasm |
1662 } // namespace internal | 1664 } // namespace internal |
1663 } // namespace v8 | 1665 } // namespace v8 |
OLD | NEW |