| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 error(start, "segment out of bounds of memory"); | 500 error(start, "segment out of bounds of memory"); |
| 501 } | 501 } |
| 502 | 502 |
| 503 consume_bytes(segment->source_size); | 503 consume_bytes(segment->source_size); |
| 504 } | 504 } |
| 505 | 505 |
| 506 // Decodes a single function table inside a module starting at {pc_}. | 506 // Decodes a single function table inside a module starting at {pc_}. |
| 507 void DecodeFunctionTableInModule(WasmModule* module, | 507 void DecodeFunctionTableInModule(WasmModule* module, |
| 508 WasmIndirectFunctionTable* table) { | 508 WasmIndirectFunctionTable* table) { |
| 509 table->size = consume_u32v("function table entry count"); | 509 table->size = consume_u32v("function table entry count"); |
| 510 table->max_size = FLAG_wasm_jit_prototype ? consume_u32v() : table->size; | 510 table->max_size = table->size; |
| 511 | 511 |
| 512 if ((!FLAG_wasm_jit_prototype && table->max_size != table->size) || | 512 if (table->max_size != table->size) { |
| 513 (FLAG_wasm_jit_prototype && table->max_size < table->size)) { | |
| 514 error("invalid table maximum size"); | 513 error("invalid table maximum size"); |
| 515 } | 514 } |
| 516 | 515 |
| 517 for (uint32_t i = 0; i < table->size; ++i) { | 516 for (uint32_t i = 0; i < table->size; ++i) { |
| 518 uint16_t index = consume_u32v(); | 517 uint16_t index = consume_u32v(); |
| 519 if (index >= module->functions.size()) { | 518 if (index >= module->functions.size()) { |
| 520 error(pc_ - sizeof(index), "invalid function index"); | 519 error(pc_ - sizeof(index), "invalid function index"); |
| 521 break; | 520 break; |
| 522 } | 521 } |
| 523 table->values.push_back(index); | 522 table->values.push_back(index); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 decoder.consume_bytes(size); | 811 decoder.consume_bytes(size); |
| 813 } | 812 } |
| 814 if (decoder.more()) decoder.error("unexpected additional bytes"); | 813 if (decoder.more()) decoder.error("unexpected additional bytes"); |
| 815 | 814 |
| 816 return decoder.toResult(std::move(table)); | 815 return decoder.toResult(std::move(table)); |
| 817 } | 816 } |
| 818 | 817 |
| 819 } // namespace wasm | 818 } // namespace wasm |
| 820 } // namespace internal | 819 } // namespace internal |
| 821 } // namespace v8 | 820 } // namespace v8 |
| OLD | NEW |