| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 private: | 454 private: |
| 455 Zone* module_zone; | 455 Zone* module_zone; |
| 456 ModuleResult result_; | 456 ModuleResult result_; |
| 457 ModuleOrigin origin_; | 457 ModuleOrigin origin_; |
| 458 | 458 |
| 459 uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); } | 459 uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); } |
| 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 DCHECK(unibrow::Utf8::Validate(start_ + global->name_offset, | 464 if (!unibrow::Utf8::Validate(start_ + global->name_offset, |
| 465 global->name_length)); | 465 global->name_length)) { |
| 466 error("global name is not valid utf8"); |
| 467 } |
| 466 global->type = consume_local_type(); | 468 global->type = consume_local_type(); |
| 467 global->offset = 0; | 469 global->offset = 0; |
| 468 global->exported = consume_u8("exported") != 0; | 470 global->exported = consume_u8("exported") != 0; |
| 469 } | 471 } |
| 470 | 472 |
| 471 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { | 473 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { |
| 472 if (offset > limit) return false; | 474 if (offset > limit) return false; |
| 473 if ((offset + size) < offset) return false; // overflow | 475 if ((offset + size) < offset) return false; // overflow |
| 474 return (offset + size) <= limit; | 476 return (offset + size) <= limit; |
| 475 } | 477 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 decoder.consume_bytes(size); | 812 decoder.consume_bytes(size); |
| 811 } | 813 } |
| 812 if (decoder.more()) decoder.error("unexpected additional bytes"); | 814 if (decoder.more()) decoder.error("unexpected additional bytes"); |
| 813 | 815 |
| 814 return decoder.toResult(std::move(table)); | 816 return decoder.toResult(std::move(table)); |
| 815 } | 817 } |
| 816 | 818 |
| 817 } // namespace wasm | 819 } // namespace wasm |
| 818 } // namespace internal | 820 } // namespace internal |
| 819 } // namespace v8 | 821 } // namespace v8 |
| OLD | NEW |