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/wasm/module-decoder.h" | 5 #include "src/wasm/module-decoder.h" |
6 | 6 |
7 #include "src/base/functional.h" | 7 #include "src/base/functional.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/flags.h" | 9 #include "src/flags.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 // TODO(titzer): find a way to report name errors as warnings. | 613 // TODO(titzer): find a way to report name errors as warnings. |
614 // Use an inner decoder so that errors don't fail the outer decoder. | 614 // Use an inner decoder so that errors don't fail the outer decoder. |
615 Decoder inner(start_, pc_, end_); | 615 Decoder inner(start_, pc_, end_); |
616 uint32_t functions_count = inner.consume_u32v("functions count"); | 616 uint32_t functions_count = inner.consume_u32v("functions count"); |
617 | 617 |
618 for (uint32_t i = 0; inner.ok() && i < functions_count; ++i) { | 618 for (uint32_t i = 0; inner.ok() && i < functions_count; ++i) { |
619 uint32_t function_name_length = 0; | 619 uint32_t function_name_length = 0; |
620 uint32_t name_offset = | 620 uint32_t name_offset = |
621 consume_string(inner, &function_name_length, false); | 621 consume_string(inner, &function_name_length, false); |
622 uint32_t func_index = i; | 622 uint32_t func_index = i; |
623 if (func_index < module->functions.size()) { | 623 if (inner.ok() && func_index < module->functions.size()) { |
bradn
2017/01/25 11:18:05
Ah I see.
Kind of goofy how this section is speced
titzer
2017/01/25 11:53:29
I'm OK with "best effort" if we just leave the nam
Mircea Trofin
2017/01/25 15:58:51
We should take a stance though and propose a PR on
Mircea Trofin
2017/01/25 16:42:00
Followed up with this PR, please take a look (incl
| |
624 module->functions[func_index].name_offset = name_offset; | 624 module->functions[func_index].name_offset = name_offset; |
625 module->functions[func_index].name_length = function_name_length; | 625 module->functions[func_index].name_length = function_name_length; |
626 } | 626 } |
627 | 627 |
628 uint32_t local_names_count = inner.consume_u32v("local names count"); | 628 uint32_t local_names_count = inner.consume_u32v("local names count"); |
629 for (uint32_t j = 0; ok() && j < local_names_count; j++) { | 629 for (uint32_t j = 0; ok() && j < local_names_count; j++) { |
630 uint32_t length = inner.consume_u32v("string length"); | 630 uint32_t length = inner.consume_u32v("string length"); |
631 inner.consume_bytes(length, "string"); | 631 inner.consume_bytes(length, "string"); |
632 } | 632 } |
633 } | 633 } |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1294 result.push_back({section_start, name_offset, name_length, payload_offset, | 1294 result.push_back({section_start, name_offset, name_length, payload_offset, |
1295 payload_length, section_length}); | 1295 payload_length, section_length}); |
1296 } | 1296 } |
1297 | 1297 |
1298 return result; | 1298 return result; |
1299 } | 1299 } |
1300 | 1300 |
1301 } // namespace wasm | 1301 } // namespace wasm |
1302 } // namespace internal | 1302 } // namespace internal |
1303 } // namespace v8 | 1303 } // namespace v8 |
OLD | NEW |