| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
| 6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
| 7 | 7 |
| 8 #include <setjmp.h> | 8 #include <setjmp.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 {type, true, WasmInitExpr(), global_offset, false, false}); | 324 {type, true, WasmInitExpr(), global_offset, false, false}); |
| 325 global_offset += size; | 325 global_offset += size; |
| 326 // limit number of globals. | 326 // limit number of globals. |
| 327 CHECK_LT(global_offset, kMaxGlobalsSize); | 327 CHECK_LT(global_offset, kMaxGlobalsSize); |
| 328 return &module->globals.back(); | 328 return &module->globals.back(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 Handle<WasmInstanceObject> InitInstanceObject() { | 331 Handle<WasmInstanceObject> InitInstanceObject() { |
| 332 Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast( | 332 Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast( |
| 333 isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked()); | 333 isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked()); |
| 334 Handle<Managed<wasm::WasmModule>> module_wrapper = | 334 // The lifetime of the wasm module is tied to this object's, and we cannot |
| 335 Managed<wasm::WasmModule>::New(isolate_, &module_, false); | 335 // rely on the mechanics of Managed<T>. |
| 336 Handle<Foreign> module_wrapper = |
| 337 isolate_->factory()->NewForeign(reinterpret_cast<Address>(&module)); |
| 336 Handle<Script> script = | 338 Handle<Script> script = |
| 337 isolate_->factory()->NewScript(isolate_->factory()->empty_string()); | 339 isolate_->factory()->NewScript(isolate_->factory()->empty_string()); |
| 338 script->set_type(Script::TYPE_WASM); | 340 script->set_type(Script::TYPE_WASM); |
| 339 Handle<WasmSharedModuleData> shared_module_data = | 341 Handle<WasmSharedModuleData> shared_module_data = |
| 340 WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, | 342 WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, |
| 341 script, Handle<ByteArray>::null()); | 343 script, Handle<ByteArray>::null()); |
| 342 Handle<WasmCompiledModule> compiled_module = | 344 Handle<WasmCompiledModule> compiled_module = |
| 343 WasmCompiledModule::New(isolate_, shared_module_data); | 345 WasmCompiledModule::New(isolate_, shared_module_data); |
| 344 // Minimally initialize the compiled module such that IsWasmCompiledModule | 346 // Minimally initialize the compiled module such that IsWasmCompiledModule |
| 345 // passes. | 347 // passes. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 void RunWasm_##name(WasmExecutionMode execution_mode) | 828 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 827 | 829 |
| 828 #define WASM_EXEC_COMPILED_TEST(name) \ | 830 #define WASM_EXEC_COMPILED_TEST(name) \ |
| 829 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 831 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 830 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 832 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 831 void RunWasm_##name(WasmExecutionMode execution_mode) | 833 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 832 | 834 |
| 833 } // namespace | 835 } // namespace |
| 834 | 836 |
| 835 #endif | 837 #endif |
| OLD | NEW |