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

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

Issue 2633153002: [wasm] Catch attempt to export non-existent memory (Closed)
Patch Set: Added TODO 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 | « no previous file | test/mjsunit/wasm/instantiate-module-basic.js » ('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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 break; 450 break;
451 } 451 }
452 case kExternalTable: { 452 case kExternalTable: {
453 WasmIndirectFunctionTable* table = nullptr; 453 WasmIndirectFunctionTable* table = nullptr;
454 exp->index = consume_table_index(module, &table); 454 exp->index = consume_table_index(module, &table);
455 if (table) table->exported = true; 455 if (table) table->exported = true;
456 break; 456 break;
457 } 457 }
458 case kExternalMemory: { 458 case kExternalMemory: {
459 uint32_t index = consume_u32v("memory index"); 459 uint32_t index = consume_u32v("memory index");
460 if (index != 0) error("invalid memory index != 0"); 460 // TODO(titzer): This should become more regular
461 // once we support multiple memories.
462 if (!module->has_memory || index != 0) {
463 error("invalid memory index != 0");
464 }
461 module->mem_export = true; 465 module->mem_export = true;
462 break; 466 break;
463 } 467 }
464 case kExternalGlobal: { 468 case kExternalGlobal: {
465 WasmGlobal* global = nullptr; 469 WasmGlobal* global = nullptr;
466 exp->index = consume_global_index(module, &global); 470 exp->index = consume_global_index(module, &global);
467 if (global) { 471 if (global) {
468 if (global->mutability) { 472 if (global->mutability) {
469 error("mutable globals cannot be exported"); 473 error("mutable globals cannot be exported");
470 } 474 }
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 table.push_back(std::move(func_asm_offsets)); 1239 table.push_back(std::move(func_asm_offsets));
1236 } 1240 }
1237 if (decoder.more()) decoder.error("unexpected additional bytes"); 1241 if (decoder.more()) decoder.error("unexpected additional bytes");
1238 1242
1239 return decoder.toResult(std::move(table)); 1243 return decoder.toResult(std::move(table));
1240 } 1244 }
1241 1245
1242 } // namespace wasm 1246 } // namespace wasm
1243 } // namespace internal 1247 } // namespace internal
1244 } // namespace v8 1248 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698