| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 expect_u8("element type", kWasmAnyFunctionTypeForm); | 312 expect_u8("element type", kWasmAnyFunctionTypeForm); |
| 313 WasmIndirectFunctionTable* table = &module->function_tables.back(); | 313 WasmIndirectFunctionTable* table = &module->function_tables.back(); |
| 314 consume_resizable_limits("element count", "elements", | 314 consume_resizable_limits("element count", "elements", |
| 315 kV8MaxWasmTableSize, &table->min_size, | 315 kV8MaxWasmTableSize, &table->min_size, |
| 316 &table->has_max, kV8MaxWasmTableSize, | 316 &table->has_max, kV8MaxWasmTableSize, |
| 317 &table->max_size); | 317 &table->max_size); |
| 318 break; | 318 break; |
| 319 } | 319 } |
| 320 case kExternalMemory: { | 320 case kExternalMemory: { |
| 321 // ===== Imported memory ========================================= | 321 // ===== Imported memory ========================================= |
| 322 bool has_max = false; | 322 consume_resizable_limits( |
| 323 consume_resizable_limits("memory", "pages", kV8MaxWasmMemoryPages, | 323 "memory", "pages", kV8MaxWasmMemoryPages, |
| 324 &module->min_mem_pages, &has_max, | 324 &module->min_mem_pages, &module->has_max_mem, |
| 325 kSpecMaxWasmMemoryPages, | 325 kSpecMaxWasmMemoryPages, &module->max_mem_pages); |
| 326 &module->max_mem_pages); | |
| 327 SetHasMemory(module); | 326 SetHasMemory(module); |
| 328 break; | 327 break; |
| 329 } | 328 } |
| 330 case kExternalGlobal: { | 329 case kExternalGlobal: { |
| 331 // ===== Imported global ========================================= | 330 // ===== Imported global ========================================= |
| 332 import->index = static_cast<uint32_t>(module->globals.size()); | 331 import->index = static_cast<uint32_t>(module->globals.size()); |
| 333 module->globals.push_back( | 332 module->globals.push_back( |
| 334 {kWasmStmt, false, WasmInitExpr(), 0, true, false}); | 333 {kWasmStmt, false, WasmInitExpr(), 0, true, false}); |
| 335 WasmGlobal* global = &module->globals.back(); | 334 WasmGlobal* global = &module->globals.back(); |
| 336 global->type = consume_value_type(); | 335 global->type = consume_value_type(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 &table->has_max, kV8MaxWasmTableSize, &table->max_size); | 386 &table->has_max, kV8MaxWasmTableSize, &table->max_size); |
| 388 } | 387 } |
| 389 section_iter.advance(); | 388 section_iter.advance(); |
| 390 } | 389 } |
| 391 | 390 |
| 392 // ===== Memory section ================================================== | 391 // ===== Memory section ================================================== |
| 393 if (section_iter.section_code() == kMemorySectionCode) { | 392 if (section_iter.section_code() == kMemorySectionCode) { |
| 394 uint32_t memory_count = consume_count("memory count", kV8MaxWasmMemories); | 393 uint32_t memory_count = consume_count("memory count", kV8MaxWasmMemories); |
| 395 | 394 |
| 396 for (uint32_t i = 0; ok() && i < memory_count; i++) { | 395 for (uint32_t i = 0; ok() && i < memory_count; i++) { |
| 397 bool has_max = false; | 396 consume_resizable_limits("memory", "pages", kV8MaxWasmMemoryPages, |
| 398 consume_resizable_limits( | 397 &module->min_mem_pages, &module->has_max_mem, |
| 399 "memory", "pages", kV8MaxWasmMemoryPages, &module->min_mem_pages, | 398 kSpecMaxWasmMemoryPages, |
| 400 &has_max, kSpecMaxWasmMemoryPages, &module->max_mem_pages); | 399 &module->max_mem_pages); |
| 401 } | 400 } |
| 402 SetHasMemory(module); | 401 SetHasMemory(module); |
| 403 section_iter.advance(); | 402 section_iter.advance(); |
| 404 } | 403 } |
| 405 | 404 |
| 406 // ===== Global section ================================================== | 405 // ===== Global section ================================================== |
| 407 if (section_iter.section_code() == kGlobalSectionCode) { | 406 if (section_iter.section_code() == kGlobalSectionCode) { |
| 408 uint32_t globals_count = | 407 uint32_t globals_count = |
| 409 consume_count("globals count", kV8MaxWasmGlobals); | 408 consume_count("globals count", kV8MaxWasmGlobals); |
| 410 uint32_t imported_globals = static_cast<uint32_t>(module->globals.size()); | 409 uint32_t imported_globals = static_cast<uint32_t>(module->globals.size()); |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 table.push_back(std::move(func_asm_offsets)); | 1238 table.push_back(std::move(func_asm_offsets)); |
| 1240 } | 1239 } |
| 1241 if (decoder.more()) decoder.error("unexpected additional bytes"); | 1240 if (decoder.more()) decoder.error("unexpected additional bytes"); |
| 1242 | 1241 |
| 1243 return decoder.toResult(std::move(table)); | 1242 return decoder.toResult(std::move(table)); |
| 1244 } | 1243 } |
| 1245 | 1244 |
| 1246 } // namespace wasm | 1245 } // namespace wasm |
| 1247 } // namespace internal | 1246 } // namespace internal |
| 1248 } // namespace v8 | 1247 } // namespace v8 |
| OLD | NEW |