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/macro-assembler.h" | 5 #include "src/macro-assembler.h" |
6 #include "src/objects.h" | 6 #include "src/objects.h" |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/wasm/decoder.h" | 9 #include "src/wasm/decoder.h" |
10 #include "src/wasm/module-decoder.h" | 10 #include "src/wasm/module-decoder.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 WasmImport* import = &module->import_table.back(); | 244 WasmImport* import = &module->import_table.back(); |
245 | 245 |
246 const byte* sigpos = pc_; | 246 const byte* sigpos = pc_; |
247 import->sig_index = consume_u16("signature index"); | 247 import->sig_index = consume_u16("signature index"); |
248 | 248 |
249 if (import->sig_index >= module->signatures.size()) { | 249 if (import->sig_index >= module->signatures.size()) { |
250 error(sigpos, "invalid signature index"); | 250 error(sigpos, "invalid signature index"); |
251 } else { | 251 } else { |
252 import->sig = module->signatures[import->sig_index]; | 252 import->sig = module->signatures[import->sig_index]; |
253 } | 253 } |
| 254 const byte* pos = pc_; |
254 import->module_name_offset = consume_string("import module name"); | 255 import->module_name_offset = consume_string("import module name"); |
| 256 if (import->module_name_offset == 0) { |
| 257 error(pos, "import module name cannot be NULL"); |
| 258 } |
255 import->function_name_offset = | 259 import->function_name_offset = |
256 consume_string("import function name"); | 260 consume_string("import function name"); |
257 } | 261 } |
258 break; | 262 break; |
259 } | 263 } |
260 case kDeclExportTable: { | 264 case kDeclExportTable: { |
261 // Declares an export table. | 265 // Declares an export table. |
262 CheckForPreviousSection(sections, kDeclFunctions, true); | 266 CheckForPreviousSection(sections, kDeclFunctions, true); |
263 int length; | 267 int length; |
264 uint32_t export_table_count = | 268 uint32_t export_table_count = |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 if (function_start > function_end) return FunctionError("start > end"); | 635 if (function_start > function_end) return FunctionError("start > end"); |
632 if (size > kMaxFunctionSize) | 636 if (size > kMaxFunctionSize) |
633 return FunctionError("size > maximum function size"); | 637 return FunctionError("size > maximum function size"); |
634 WasmFunction* function = new WasmFunction(); | 638 WasmFunction* function = new WasmFunction(); |
635 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); | 639 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); |
636 return decoder.DecodeSingleFunction(module_env, function); | 640 return decoder.DecodeSingleFunction(module_env, function); |
637 } | 641 } |
638 } // namespace wasm | 642 } // namespace wasm |
639 } // namespace internal | 643 } // namespace internal |
640 } // namespace v8 | 644 } // namespace v8 |
OLD | NEW |