| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 private: | 472 private: |
| 473 Zone* module_zone; | 473 Zone* module_zone; |
| 474 ModuleResult result_; | 474 ModuleResult result_; |
| 475 ModuleOrigin origin_; | 475 ModuleOrigin origin_; |
| 476 | 476 |
| 477 uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); } | 477 uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); } |
| 478 | 478 |
| 479 // Decodes a single global entry inside a module starting at {pc_}. | 479 // Decodes a single global entry inside a module starting at {pc_}. |
| 480 void DecodeGlobalInModule(WasmGlobal* global) { | 480 void DecodeGlobalInModule(WasmGlobal* global) { |
| 481 global->name_offset = consume_string(&global->name_length, false); | 481 global->name_offset = consume_string(&global->name_length, false); |
| 482 DCHECK(unibrow::Utf8::Validate(start_ + global->name_offset, | 482 if(!unibrow::Utf8::Validate(start_ + global->name_offset, |
| 483 global->name_length)); | 483 global->name_length)) { |
| 484 error("global name is not valid utf8"); |
| 485 } |
| 484 global->type = mem_type(); | 486 global->type = mem_type(); |
| 485 global->offset = 0; | 487 global->offset = 0; |
| 486 global->exported = consume_u8("exported") != 0; | 488 global->exported = consume_u8("exported") != 0; |
| 487 } | 489 } |
| 488 | 490 |
| 489 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { | 491 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { |
| 490 if (offset > limit) return false; | 492 if (offset > limit) return false; |
| 491 if ((offset + size) < offset) return false; // overflow | 493 if ((offset + size) < offset) return false; // overflow |
| 492 return (offset + size) <= limit; | 494 return (offset + size) <= limit; |
| 493 } | 495 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 decoder.consume_bytes(size); | 841 decoder.consume_bytes(size); |
| 840 } | 842 } |
| 841 if (decoder.more()) decoder.error("unexpected additional bytes"); | 843 if (decoder.more()) decoder.error("unexpected additional bytes"); |
| 842 | 844 |
| 843 return decoder.toResult(std::move(table)); | 845 return decoder.toResult(std::move(table)); |
| 844 } | 846 } |
| 845 | 847 |
| 846 } // namespace wasm | 848 } // namespace wasm |
| 847 } // namespace internal | 849 } // namespace internal |
| 848 } // namespace v8 | 850 } // namespace v8 |
| OLD | NEW |