| 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/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 460 |
| 461 // Decodes a single global entry inside a module starting at {pc_}. | 461 // Decodes a single global entry inside a module starting at {pc_}. |
| 462 void DecodeGlobalInModule(WasmGlobal* global) { | 462 void DecodeGlobalInModule(WasmGlobal* global) { |
| 463 global->name_offset = consume_string(&global->name_length, false); | 463 global->name_offset = consume_string(&global->name_length, false); |
| 464 if (ok() && | 464 if (ok() && |
| 465 !unibrow::Utf8::Validate(start_ + global->name_offset, | 465 !unibrow::Utf8::Validate(start_ + global->name_offset, |
| 466 global->name_length)) { | 466 global->name_length)) { |
| 467 error("global name is not valid utf8"); | 467 error("global name is not valid utf8"); |
| 468 } | 468 } |
| 469 global->type = consume_local_type(); | 469 global->type = consume_local_type(); |
| 470 if (global->type == kAstStmt) { |
| 471 error("invalid global type"); |
| 472 } |
| 470 global->offset = 0; | 473 global->offset = 0; |
| 471 global->exported = consume_u8("exported") != 0; | 474 global->exported = consume_u8("exported") != 0; |
| 472 } | 475 } |
| 473 | 476 |
| 474 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { | 477 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { |
| 475 if (offset > limit) return false; | 478 if (offset > limit) return false; |
| 476 if ((offset + size) < offset) return false; // overflow | 479 if ((offset + size) < offset) return false; // overflow |
| 477 return (offset + size) <= limit; | 480 return (offset + size) <= limit; |
| 478 } | 481 } |
| 479 | 482 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 decoder.consume_bytes(size); | 820 decoder.consume_bytes(size); |
| 818 } | 821 } |
| 819 if (decoder.more()) decoder.error("unexpected additional bytes"); | 822 if (decoder.more()) decoder.error("unexpected additional bytes"); |
| 820 | 823 |
| 821 return decoder.toResult(std::move(table)); | 824 return decoder.toResult(std::move(table)); |
| 822 } | 825 } |
| 823 | 826 |
| 824 } // namespace wasm | 827 } // namespace wasm |
| 825 } // namespace internal | 828 } // namespace internal |
| 826 } // namespace v8 | 829 } // namespace v8 |
| OLD | NEW |