Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: src/wasm/module-decoder.cc

Issue 2648223004: [wasm] Change the constant kV8MaxWasmTableSize to a command line flag. (Closed)
Patch Set: Use the wasm-limits.h values in flag-definitions.h Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/flags.cc ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 table.push_back(std::move(func_asm_offsets)); 1258 table.push_back(std::move(func_asm_offsets));
1258 } 1259 }
1259 if (decoder.more()) decoder.error("unexpected additional bytes"); 1260 if (decoder.more()) decoder.error("unexpected additional bytes");
1260 1261
1261 return decoder.toResult(std::move(table)); 1262 return decoder.toResult(std::move(table));
1262 } 1263 }
1263 1264
1264 } // namespace wasm 1265 } // namespace wasm
1265 } // namespace internal 1266 } // namespace internal
1266 } // namespace v8 1267 } // namespace v8
OLDNEW
« no previous file with comments | « src/flags.cc ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698