| 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/base/atomic-utils.h" | 5 #include "src/base/atomic-utils.h" |
| 6 #include "src/macro-assembler.h" | 6 #include "src/macro-assembler.h" |
| 7 #include "src/objects.h" | 7 #include "src/objects.h" |
| 8 #include "src/property-descriptor.h" | 8 #include "src/property-descriptor.h" |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 const byte* module_end, bool asm_js) { | 1032 const byte* module_end, bool asm_js) { |
| 1033 HandleScope scope(isolate); | 1033 HandleScope scope(isolate); |
| 1034 Zone zone(isolate->allocator()); | 1034 Zone zone(isolate->allocator()); |
| 1035 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); | 1035 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); |
| 1036 | 1036 |
| 1037 // Decode the module, but don't verify function bodies, since we'll | 1037 // Decode the module, but don't verify function bodies, since we'll |
| 1038 // be compiling them anyway. | 1038 // be compiling them anyway. |
| 1039 ModuleResult decoding_result = | 1039 ModuleResult decoding_result = |
| 1040 DecodeWasmModule(isolate, &zone, module_start, module_end, false, | 1040 DecodeWasmModule(isolate, &zone, module_start, module_end, false, |
| 1041 asm_js ? kAsmJsOrigin : kWasmOrigin); | 1041 asm_js ? kAsmJsOrigin : kWasmOrigin); |
| 1042 |
| 1043 std::unique_ptr<const WasmModule> module(decoding_result.val); |
| 1042 if (decoding_result.failed()) { | 1044 if (decoding_result.failed()) { |
| 1043 // Module verification failed. throw. | 1045 // Module verification failed. throw. |
| 1044 thrower.Error("WASM.compileRun() failed: %s", | 1046 thrower.Error("WASM.compileRun() failed: %s", |
| 1045 decoding_result.error_msg.get()); | 1047 decoding_result.error_msg.get()); |
| 1048 return -1; |
| 1046 } | 1049 } |
| 1047 std::unique_ptr<const WasmModule> module(decoding_result.val); | |
| 1048 | 1050 |
| 1049 if (module->import_table.size() > 0) { | 1051 if (module->import_table.size() > 0) { |
| 1050 thrower.Error("Not supported: module has imports."); | 1052 thrower.Error("Not supported: module has imports."); |
| 1051 } | 1053 } |
| 1052 if (module->export_table.size() == 0) { | 1054 if (module->export_table.size() == 0) { |
| 1053 thrower.Error("Not supported: module has no exports."); | 1055 thrower.Error("Not supported: module has no exports."); |
| 1054 } | 1056 } |
| 1055 | 1057 |
| 1056 if (thrower.error()) return -1; | 1058 if (thrower.error()) return -1; |
| 1057 | 1059 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1092 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
| 1091 } | 1093 } |
| 1092 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 1094 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
| 1093 return -1; | 1095 return -1; |
| 1094 } | 1096 } |
| 1095 | 1097 |
| 1096 } // namespace testing | 1098 } // namespace testing |
| 1097 } // namespace wasm | 1099 } // namespace wasm |
| 1098 } // namespace internal | 1100 } // namespace internal |
| 1099 } // namespace v8 | 1101 } // namespace v8 |
| OLD | NEW |