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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // ===== Imported table ========================================== | 306 // ===== Imported table ========================================== |
307 if (!AddTable(module)) break; | 307 if (!AddTable(module)) break; |
308 import->index = | 308 import->index = |
309 static_cast<uint32_t>(module->function_tables.size()); | 309 static_cast<uint32_t>(module->function_tables.size()); |
310 module->function_tables.push_back({0, 0, false, | 310 module->function_tables.push_back({0, 0, false, |
311 std::vector<int32_t>(), true, | 311 std::vector<int32_t>(), true, |
312 false, SignatureMap()}); | 312 false, SignatureMap()}); |
313 expect_u8("element type", kWasmAnyFunctionTypeForm); | 313 expect_u8("element type", kWasmAnyFunctionTypeForm); |
314 WasmIndirectFunctionTable* table = &module->function_tables.back(); | 314 WasmIndirectFunctionTable* table = &module->function_tables.back(); |
315 consume_resizable_limits("element count", "elements", | 315 consume_resizable_limits("element count", "elements", |
316 kV8MaxWasmTableSize, &table->min_size, | 316 FLAG_wasm_max_table_size, &table->min_size, |
317 &table->has_max, kV8MaxWasmTableSize, | 317 &table->has_max, FLAG_wasm_max_table_size, |
318 &table->max_size); | 318 &table->max_size); |
319 break; | 319 break; |
320 } | 320 } |
321 case kExternalMemory: { | 321 case kExternalMemory: { |
322 // ===== Imported memory ========================================= | 322 // ===== Imported memory ========================================= |
323 if (!AddMemory(module)) break; | 323 if (!AddMemory(module)) break; |
324 consume_resizable_limits( | 324 consume_resizable_limits( |
325 "memory", "pages", FLAG_wasm_max_mem_pages, | 325 "memory", "pages", FLAG_wasm_max_mem_pages, |
326 &module->min_mem_pages, &module->has_max_mem, | 326 &module->min_mem_pages, &module->has_max_mem, |
327 kSpecMaxWasmMemoryPages, &module->max_mem_pages); | 327 kSpecMaxWasmMemoryPages, &module->max_mem_pages); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // ===== Table section =================================================== | 374 // ===== Table section =================================================== |
375 if (section_iter.section_code() == kTableSectionCode) { | 375 if (section_iter.section_code() == kTableSectionCode) { |
376 uint32_t table_count = consume_count("table count", kV8MaxWasmTables); | 376 uint32_t table_count = consume_count("table count", kV8MaxWasmTables); |
377 | 377 |
378 for (uint32_t i = 0; ok() && i < table_count; i++) { | 378 for (uint32_t i = 0; ok() && i < table_count; i++) { |
379 if (!AddTable(module)) break; | 379 if (!AddTable(module)) break; |
380 module->function_tables.push_back({0, 0, false, std::vector<int32_t>(), | 380 module->function_tables.push_back({0, 0, false, std::vector<int32_t>(), |
381 false, false, SignatureMap()}); | 381 false, false, SignatureMap()}); |
382 WasmIndirectFunctionTable* table = &module->function_tables.back(); | 382 WasmIndirectFunctionTable* table = &module->function_tables.back(); |
383 expect_u8("table type", kWasmAnyFunctionTypeForm); | 383 expect_u8("table type", kWasmAnyFunctionTypeForm); |
384 consume_resizable_limits( | 384 consume_resizable_limits("table elements", "elements", |
385 "table elements", "elements", kV8MaxWasmTableSize, &table->min_size, | 385 FLAG_wasm_max_table_size, &table->min_size, |
386 &table->has_max, kV8MaxWasmTableSize, &table->max_size); | 386 &table->has_max, FLAG_wasm_max_table_size, |
| 387 &table->max_size); |
387 } | 388 } |
388 section_iter.advance(); | 389 section_iter.advance(); |
389 } | 390 } |
390 | 391 |
391 // ===== Memory section ================================================== | 392 // ===== Memory section ================================================== |
392 if (section_iter.section_code() == kMemorySectionCode) { | 393 if (section_iter.section_code() == kMemorySectionCode) { |
393 uint32_t memory_count = consume_count("memory count", kV8MaxWasmMemories); | 394 uint32_t memory_count = consume_count("memory count", kV8MaxWasmMemories); |
394 | 395 |
395 for (uint32_t i = 0; ok() && i < memory_count; i++) { | 396 for (uint32_t i = 0; ok() && i < memory_count; i++) { |
396 if (!AddMemory(module)) break; | 397 if (!AddMemory(module)) break; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 (func->sig->parameter_count() > 0 || func->sig->return_count() > 0)) { | 520 (func->sig->parameter_count() > 0 || func->sig->return_count() > 0)) { |
520 error(pos, | 521 error(pos, |
521 "invalid start function: non-zero parameter or return count"); | 522 "invalid start function: non-zero parameter or return count"); |
522 } | 523 } |
523 section_iter.advance(); | 524 section_iter.advance(); |
524 } | 525 } |
525 | 526 |
526 // ===== Elements section ================================================ | 527 // ===== Elements section ================================================ |
527 if (section_iter.section_code() == kElementSectionCode) { | 528 if (section_iter.section_code() == kElementSectionCode) { |
528 uint32_t element_count = | 529 uint32_t element_count = |
529 consume_count("element count", kV8MaxWasmTableSize); | 530 consume_count("element count", FLAG_wasm_max_table_size); |
530 for (uint32_t i = 0; ok() && i < element_count; ++i) { | 531 for (uint32_t i = 0; ok() && i < element_count; ++i) { |
531 const byte* pos = pc(); | 532 const byte* pos = pc(); |
532 uint32_t table_index = consume_u32v("table index"); | 533 uint32_t table_index = consume_u32v("table index"); |
533 if (table_index != 0) { | 534 if (table_index != 0) { |
534 error(pos, pos, "illegal table index %u != 0", table_index); | 535 error(pos, pos, "illegal table index %u != 0", table_index); |
535 } | 536 } |
536 WasmIndirectFunctionTable* table = nullptr; | 537 WasmIndirectFunctionTable* table = nullptr; |
537 if (table_index >= module->function_tables.size()) { | 538 if (table_index >= module->function_tables.size()) { |
538 error(pos, pos, "out of bounds table index %u", table_index); | 539 error(pos, pos, "out of bounds table index %u", table_index); |
539 } else { | 540 } else { |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 table.push_back(std::move(func_asm_offsets)); | 1257 table.push_back(std::move(func_asm_offsets)); |
1257 } | 1258 } |
1258 if (decoder.more()) decoder.error("unexpected additional bytes"); | 1259 if (decoder.more()) decoder.error("unexpected additional bytes"); |
1259 | 1260 |
1260 return decoder.toResult(std::move(table)); | 1261 return decoder.toResult(std::move(table)); |
1261 } | 1262 } |
1262 | 1263 |
1263 } // namespace wasm | 1264 } // namespace wasm |
1264 } // namespace internal | 1265 } // namespace internal |
1265 } // namespace v8 | 1266 } // namespace v8 |
OLD | NEW |