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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 break; | 330 break; |
331 } | 331 } |
332 case kExternalGlobal: { | 332 case kExternalGlobal: { |
333 // ===== Imported global ========================================= | 333 // ===== Imported global ========================================= |
334 import->index = static_cast<uint32_t>(module->globals.size()); | 334 import->index = static_cast<uint32_t>(module->globals.size()); |
335 module->globals.push_back( | 335 module->globals.push_back( |
336 {kAstStmt, false, WasmInitExpr(), 0, true, false}); | 336 {kAstStmt, false, WasmInitExpr(), 0, true, false}); |
337 WasmGlobal* global = &module->globals.back(); | 337 WasmGlobal* global = &module->globals.back(); |
338 global->type = consume_value_type(); | 338 global->type = consume_value_type(); |
339 global->mutability = consume_u8("mutability") != 0; | 339 global->mutability = consume_u8("mutability") != 0; |
| 340 if (global->mutability) { |
| 341 error("mutable globals cannot be imported"); |
| 342 } |
340 break; | 343 break; |
341 } | 344 } |
342 default: | 345 default: |
343 error(pos, pos, "unknown import kind 0x%02x", import->kind); | 346 error(pos, pos, "unknown import kind 0x%02x", import->kind); |
344 break; | 347 break; |
345 } | 348 } |
346 } | 349 } |
347 section_iter.advance(); | 350 section_iter.advance(); |
348 } | 351 } |
349 | 352 |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 table.push_back(std::move(func_asm_offsets)); | 1203 table.push_back(std::move(func_asm_offsets)); |
1201 } | 1204 } |
1202 if (decoder.more()) decoder.error("unexpected additional bytes"); | 1205 if (decoder.more()) decoder.error("unexpected additional bytes"); |
1203 | 1206 |
1204 return decoder.toResult(std::move(table)); | 1207 return decoder.toResult(std::move(table)); |
1205 } | 1208 } |
1206 | 1209 |
1207 } // namespace wasm | 1210 } // namespace wasm |
1208 } // namespace internal | 1211 } // namespace internal |
1209 } // namespace v8 | 1212 } // namespace v8 |
OLD | NEW |