Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: test/common/wasm/wasm-module-runner.cc

Issue 2695813005: [wasm] Split the compilation and instantiation API into sync and async methods. (Closed)
Patch Set: [wasm] Split the compilation and instantiation API into sync and async methods. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/wasm/test-run-wasm-module.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "test/common/wasm/wasm-module-runner.h" 5 #include "test/common/wasm/wasm-module-runner.h"
6 6
7 #include "src/handles.h" 7 #include "src/handles.h"
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DCHECK_NOT_NULL(module); 52 DCHECK_NOT_NULL(module);
53 if (module->import_table.size() > 0) { 53 if (module->import_table.size() > 0) {
54 thrower->CompileError("Not supported: module has imports."); 54 thrower->CompileError("Not supported: module has imports.");
55 } 55 }
56 56
57 if (thrower->error()) return Handle<WasmInstanceObject>::null(); 57 if (thrower->error()) return Handle<WasmInstanceObject>::null();
58 58
59 // Although we decoded the module for some pre-validation, run the bytes 59 // Although we decoded the module for some pre-validation, run the bytes
60 // again through the normal pipeline. 60 // again through the normal pipeline.
61 // TODO(wasm): Use {module} instead of decoding the module bytes again. 61 // TODO(wasm): Use {module} instead of decoding the module bytes again.
62 MaybeHandle<WasmModuleObject> module_object = CreateModuleObjectFromBytes( 62 MaybeHandle<WasmModuleObject> module_object =
63 isolate, wire_bytes.start(), wire_bytes.end(), thrower, 63 SyncCompile(isolate, thrower, wire_bytes);
64 ModuleOrigin::kWasmOrigin, Handle<Script>::null(),
65 Vector<const byte>::empty());
66 if (module_object.is_null()) { 64 if (module_object.is_null()) {
67 thrower->CompileError("Module pre-validation failed."); 65 thrower->CompileError("Module pre-validation failed.");
68 return Handle<WasmInstanceObject>::null(); 66 return Handle<WasmInstanceObject>::null();
69 } 67 }
70 MaybeHandle<WasmInstanceObject> maybe_instance = 68 MaybeHandle<WasmInstanceObject> maybe_instance =
71 WasmModule::Instantiate(isolate, thrower, module_object.ToHandleChecked(), 69 SyncInstantiate(isolate, thrower, module_object.ToHandleChecked(),
72 Handle<JSReceiver>::null()); 70 Handle<JSReceiver>::null(), MaybeHandle<JSArrayBuffer>());
73 Handle<WasmInstanceObject> instance; 71 Handle<WasmInstanceObject> instance;
74 if (!maybe_instance.ToHandle(&instance)) { 72 if (!maybe_instance.ToHandle(&instance)) {
75 return Handle<WasmInstanceObject>::null(); 73 return Handle<WasmInstanceObject>::null();
76 } 74 }
77 return instance; 75 return instance;
78 } 76 }
79 77
80 const Handle<WasmInstanceObject> CompileInstantiateWasmModuleForTesting( 78 const Handle<WasmInstanceObject> CompileInstantiateWasmModuleForTesting(
81 Isolate* isolate, ErrorThrower* thrower, const byte* module_start, 79 Isolate* isolate, ErrorThrower* thrower, const byte* module_start,
82 const byte* module_end, ModuleOrigin origin) { 80 const byte* module_end, ModuleOrigin origin) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return -1; 203 return -1;
206 } 204 }
207 205
208 void SetupIsolateForWasmModule(Isolate* isolate) { 206 void SetupIsolateForWasmModule(Isolate* isolate) {
209 WasmJs::Install(isolate); 207 WasmJs::Install(isolate);
210 } 208 }
211 } // namespace testing 209 } // namespace testing
212 } // namespace wasm 210 } // namespace wasm
213 } // namespace internal 211 } // namespace internal
214 } // namespace v8 212 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698