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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } | 468 } |
469 case kExternalMemory: { | 469 case kExternalMemory: { |
470 uint32_t index = consume_u32v("memory index"); | 470 uint32_t index = consume_u32v("memory index"); |
471 if (index != 0) error("invalid memory index != 0"); | 471 if (index != 0) error("invalid memory index != 0"); |
472 module->mem_export = true; | 472 module->mem_export = true; |
473 break; | 473 break; |
474 } | 474 } |
475 case kExternalGlobal: { | 475 case kExternalGlobal: { |
476 WasmGlobal* global = nullptr; | 476 WasmGlobal* global = nullptr; |
477 exp->index = consume_global_index(module, &global); | 477 exp->index = consume_global_index(module, &global); |
478 if (global) global->exported = true; | 478 if (global) { |
| 479 if (global->mutability) { |
| 480 error("mutable globals cannot be exported"); |
| 481 } |
| 482 global->exported = true; |
| 483 } |
479 break; | 484 break; |
480 } | 485 } |
481 default: | 486 default: |
482 error(pos, pos, "invalid export kind 0x%02x", exp->kind); | 487 error(pos, pos, "invalid export kind 0x%02x", exp->kind); |
483 break; | 488 break; |
484 } | 489 } |
485 } | 490 } |
486 // Check for duplicate exports. | 491 // Check for duplicate exports. |
487 if (ok() && module->export_table.size() > 1) { | 492 if (ok() && module->export_table.size() > 1) { |
488 std::vector<WasmExport> sorted_exports(module->export_table); | 493 std::vector<WasmExport> sorted_exports(module->export_table); |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 table.push_back(std::move(func_asm_offsets)); | 1205 table.push_back(std::move(func_asm_offsets)); |
1201 } | 1206 } |
1202 if (decoder.more()) decoder.error("unexpected additional bytes"); | 1207 if (decoder.more()) decoder.error("unexpected additional bytes"); |
1203 | 1208 |
1204 return decoder.toResult(std::move(table)); | 1209 return decoder.toResult(std::move(table)); |
1205 } | 1210 } |
1206 | 1211 |
1207 } // namespace wasm | 1212 } // namespace wasm |
1208 } // namespace internal | 1213 } // namespace internal |
1209 } // namespace v8 | 1214 } // namespace v8 |
OLD | NEW |