| 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/signature.h" | 5 #include "src/signature.h" |
| 6 | 6 |
| 7 #include "src/bit-vector.h" | 7 #include "src/bit-vector.h" |
| 8 #include "src/flags.h" | 8 #include "src/flags.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 DecodeFunctionBody(); | 502 DecodeFunctionBody(); |
| 503 | 503 |
| 504 if (failed()) return TraceFailed(); | 504 if (failed()) return TraceFailed(); |
| 505 | 505 |
| 506 if (!control_.empty()) { | 506 if (!control_.empty()) { |
| 507 error(pc_, control_.back().pc, "unterminated control structure"); | 507 error(pc_, control_.back().pc, "unterminated control structure"); |
| 508 return TraceFailed(); | 508 return TraceFailed(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 if (ssa_env_->go()) { | 511 if (ssa_env_->go()) { |
| 512 TRACE(" @%-6d #xx:%-20s|", startrel(pc_), "ImplicitReturn"); | 512 TRACE(" @%-8d #xx:%-20s|", startrel(pc_), "ImplicitReturn"); |
| 513 DoReturn(); | 513 DoReturn(); |
| 514 if (failed()) return TraceFailed(); | 514 if (failed()) return TraceFailed(); |
| 515 TRACE("\n"); | 515 TRACE("\n"); |
| 516 } | 516 } |
| 517 | 517 |
| 518 if (FLAG_trace_wasm_decode_time) { | 518 if (FLAG_trace_wasm_decode_time) { |
| 519 double ms = decode_timer.Elapsed().InMillisecondsF(); | 519 double ms = decode_timer.Elapsed().InMillisecondsF(); |
| 520 PrintF("wasm-decode ok (%0.3f ms)\n\n", ms); | 520 PrintF("wasm-decode ok (%0.3f ms)\n\n", ms); |
| 521 } else { | 521 } else { |
| 522 TRACE("wasm-decode ok\n\n"); | 522 TRACE("wasm-decode ok\n\n"); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 TRACE("wasm-decode %p...%p (module+%d, %d bytes) %s\n", | 700 TRACE("wasm-decode %p...%p (module+%d, %d bytes) %s\n", |
| 701 reinterpret_cast<const void*>(start_), | 701 reinterpret_cast<const void*>(start_), |
| 702 reinterpret_cast<const void*>(limit_), baserel(pc_), | 702 reinterpret_cast<const void*>(limit_), baserel(pc_), |
| 703 static_cast<int>(limit_ - start_), builder_ ? "graph building" : ""); | 703 static_cast<int>(limit_ - start_), builder_ ? "graph building" : ""); |
| 704 | 704 |
| 705 if (pc_ >= limit_) return; // Nothing to do. | 705 if (pc_ >= limit_) return; // Nothing to do. |
| 706 | 706 |
| 707 while (true) { // decoding loop. | 707 while (true) { // decoding loop. |
| 708 unsigned len = 1; | 708 unsigned len = 1; |
| 709 WasmOpcode opcode = static_cast<WasmOpcode>(*pc_); | 709 WasmOpcode opcode = static_cast<WasmOpcode>(*pc_); |
| 710 TRACE(" @%-6d #%02x:%-20s|", startrel(pc_), opcode, | 710 if (!WasmOpcodes::IsPrefixOpcode(opcode)) { |
| 711 WasmOpcodes::ShortOpcodeName(opcode)); | 711 TRACE(" @%-8d #%02x:%-20s|", startrel(pc_), opcode, |
| 712 WasmOpcodes::ShortOpcodeName(opcode)); |
| 713 } |
| 712 | 714 |
| 713 FunctionSig* sig = WasmOpcodes::Signature(opcode); | 715 FunctionSig* sig = WasmOpcodes::Signature(opcode); |
| 714 if (sig) { | 716 if (sig) { |
| 715 // Fast case of a simple operator. | 717 // Fast case of a simple operator. |
| 716 TFNode* node; | 718 TFNode* node; |
| 717 switch (sig->parameter_count()) { | 719 switch (sig->parameter_count()) { |
| 718 case 1: { | 720 case 1: { |
| 719 Value val = Pop(0, sig->GetParam(0)); | 721 Value val = Pop(0, sig->GetParam(0)); |
| 720 node = BUILD(Unop, opcode, val.node, position()); | 722 node = BUILD(Unop, opcode, val.node, position()); |
| 721 break; | 723 break; |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 Push(GetReturnType(operand.sig), call); | 1266 Push(GetReturnType(operand.sig), call); |
| 1265 } | 1267 } |
| 1266 len = 1 + operand.length; | 1268 len = 1 + operand.length; |
| 1267 break; | 1269 break; |
| 1268 } | 1270 } |
| 1269 case kSimdPrefix: { | 1271 case kSimdPrefix: { |
| 1270 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); | 1272 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); |
| 1271 len++; | 1273 len++; |
| 1272 byte simd_index = *(pc_ + 1); | 1274 byte simd_index = *(pc_ + 1); |
| 1273 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); | 1275 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); |
| 1276 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, |
| 1277 simd_index, WasmOpcodes::ShortOpcodeName(opcode)); |
| 1274 DecodeSimdOpcode(opcode); | 1278 DecodeSimdOpcode(opcode); |
| 1275 break; | 1279 break; |
| 1276 } | 1280 } |
| 1277 default: | 1281 default: |
| 1278 error("Invalid opcode"); | 1282 error("Invalid opcode"); |
| 1279 return; | 1283 return; |
| 1280 } | 1284 } |
| 1281 } // end complex bytecode | 1285 } // end complex bytecode |
| 1282 | 1286 |
| 1283 #if DEBUG | 1287 #if DEBUG |
| 1284 if (FLAG_trace_wasm_decoder) { | 1288 if (FLAG_trace_wasm_decoder) { |
| 1285 for (size_t i = 0; i < stack_.size(); ++i) { | 1289 for (size_t i = 0; i < stack_.size(); ++i) { |
| 1286 Value& val = stack_[i]; | 1290 Value& val = stack_[i]; |
| 1287 WasmOpcode opcode = static_cast<WasmOpcode>(*val.pc); | 1291 WasmOpcode opcode = static_cast<WasmOpcode>(*val.pc); |
| 1292 if (WasmOpcodes::IsPrefixOpcode(opcode)) { |
| 1293 opcode = static_cast<WasmOpcode>(opcode << 8 | *(val.pc + 1)); |
| 1294 } |
| 1288 PrintF(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type), | 1295 PrintF(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type), |
| 1289 static_cast<int>(val.pc - start_), | 1296 static_cast<int>(val.pc - start_), |
| 1290 WasmOpcodes::ShortOpcodeName(opcode)); | 1297 WasmOpcodes::ShortOpcodeName(opcode)); |
| 1291 switch (opcode) { | 1298 switch (opcode) { |
| 1292 case kExprI32Const: { | 1299 case kExprI32Const: { |
| 1293 ImmI32Operand operand(this, val.pc); | 1300 ImmI32Operand operand(this, val.pc); |
| 1294 PrintF("[%d]", operand.value); | 1301 PrintF("[%d]", operand.value); |
| 1295 break; | 1302 break; |
| 1296 } | 1303 } |
| 1297 case kExprGetLocal: { | 1304 case kExprGetLocal: { |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 2071 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
| 2065 const byte* start, const byte* end) { | 2072 const byte* start, const byte* end) { |
| 2066 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 2073 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
| 2067 WasmFullDecoder decoder(zone, nullptr, body); | 2074 WasmFullDecoder decoder(zone, nullptr, body); |
| 2068 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 2075 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
| 2069 } | 2076 } |
| 2070 | 2077 |
| 2071 } // namespace wasm | 2078 } // namespace wasm |
| 2072 } // namespace internal | 2079 } // namespace internal |
| 2073 } // namespace v8 | 2080 } // namespace v8 |
| OLD | NEW |