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" | |
6 #include "src/signature.h" | 5 #include "src/signature.h" |
7 | 6 |
8 #include "src/bit-vector.h" | 7 #include "src/bit-vector.h" |
9 #include "src/flags.h" | 8 #include "src/flags.h" |
10 #include "src/handles.h" | 9 #include "src/handles.h" |
11 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
12 | 11 |
13 #include "src/wasm/ast-decoder.h" | 12 #include "src/wasm/ast-decoder.h" |
14 #include "src/wasm/decoder.h" | 13 #include "src/wasm/decoder.h" |
15 #include "src/wasm/wasm-module.h" | 14 #include "src/wasm/wasm-module.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 base_(body.base), | 361 base_(body.base), |
363 local_type_vec_(zone), | 362 local_type_vec_(zone), |
364 trees_(zone), | 363 trees_(zone), |
365 stack_(zone), | 364 stack_(zone), |
366 blocks_(zone), | 365 blocks_(zone), |
367 ifs_(zone) { | 366 ifs_(zone) { |
368 local_types_ = &local_type_vec_; | 367 local_types_ = &local_type_vec_; |
369 } | 368 } |
370 | 369 |
371 TreeResult Decode() { | 370 TreeResult Decode() { |
372 base::ElapsedTimer decode_timer; | |
373 if (FLAG_trace_wasm_decode_time) { | |
374 decode_timer.Start(); | |
375 } | |
376 | |
377 if (end_ < pc_) { | 371 if (end_ < pc_) { |
378 error(pc_, "function body end < start"); | 372 error(pc_, "function body end < start"); |
379 return result_; | 373 return result_; |
380 } | 374 } |
381 | 375 |
382 DecodeLocalDecls(); | 376 DecodeLocalDecls(); |
383 InitSsaEnv(); | 377 InitSsaEnv(); |
384 DecodeFunctionBody(); | 378 DecodeFunctionBody(); |
385 | 379 |
386 Tree* tree = nullptr; | 380 Tree* tree = nullptr; |
(...skipping 11 matching lines...) Expand all Loading... |
398 } else { | 392 } else { |
399 tree = trees_[0]; | 393 tree = trees_[0]; |
400 } | 394 } |
401 } | 395 } |
402 | 396 |
403 if (ok()) { | 397 if (ok()) { |
404 if (FLAG_trace_wasm_ast) { | 398 if (FLAG_trace_wasm_ast) { |
405 FunctionBody body = {module_, sig_, base_, start_, end_}; | 399 FunctionBody body = {module_, sig_, base_, start_, end_}; |
406 PrintAst(body); | 400 PrintAst(body); |
407 } | 401 } |
408 if (FLAG_trace_wasm_decode_time) { | 402 TRACE("wasm-decode ok\n"); |
409 double ms = decode_timer.Elapsed().InMillisecondsF(); | |
410 PrintF("wasm-decode ok (%0.3f ms)\n\n", ms); | |
411 } else { | |
412 TRACE("wasm-decode ok\n\n"); | |
413 } | |
414 } else { | 403 } else { |
415 TRACE("wasm-error module+%-6d func+%d: %s\n\n", baserel(error_pc_), | 404 TRACE("wasm-error module+%-6d func+%d: %s\n\n", baserel(error_pc_), |
416 startrel(error_pc_), error_msg_.get()); | 405 startrel(error_pc_), error_msg_.get()); |
417 } | 406 } |
418 | 407 |
419 return toResult(tree); | 408 return toResult(tree); |
420 } | 409 } |
421 | 410 |
422 std::vector<LocalType>* DecodeLocalDeclsForTesting() { | 411 std::vector<LocalType>* DecodeLocalDeclsForTesting() { |
423 DecodeLocalDecls(); | 412 DecodeLocalDecls(); |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1698 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
1710 const byte* start, const byte* end) { | 1699 const byte* start, const byte* end) { |
1711 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1700 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
1712 SR_WasmDecoder decoder(zone, nullptr, body); | 1701 SR_WasmDecoder decoder(zone, nullptr, body); |
1713 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1702 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
1714 } | 1703 } |
1715 | 1704 |
1716 } // namespace wasm | 1705 } // namespace wasm |
1717 } // namespace internal | 1706 } // namespace internal |
1718 } // namespace v8 | 1707 } // namespace v8 |
OLD | NEW |