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

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2320723005: [wasm] Compilation/Instantiation pipeline works off module object (Closed)
Patch Set: rebase Created 4 years, 3 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 | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 5 #include <memory>
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 PatchJSWrapper(isolate, startup_fct_clone, new_target); 1364 PatchJSWrapper(isolate, startup_fct_clone, new_target);
1365 } 1365 }
1366 return clone; 1366 return clone;
1367 } 1367 }
1368 1368
1369 // Instantiates a wasm module as a JSObject. 1369 // Instantiates a wasm module as a JSObject.
1370 // * allocates a backing store of {mem_size} bytes. 1370 // * allocates a backing store of {mem_size} bytes.
1371 // * installs a named property "memory" for that buffer if exported 1371 // * installs a named property "memory" for that buffer if exported
1372 // * installs named properties on the object for exported functions 1372 // * installs named properties on the object for exported functions
1373 // * compiles wasm code to machine code 1373 // * compiles wasm code to machine code
1374 MaybeHandle<JSObject> WasmModule::Instantiate( 1374 MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
1375 Isolate* isolate, Handle<FixedArray> compiled_module, 1375 Handle<JSObject> module_object,
1376 Handle<JSReceiver> ffi, Handle<JSArrayBuffer> memory) { 1376 Handle<JSReceiver> ffi,
1377 Handle<JSArrayBuffer> memory) {
1377 HistogramTimerScope wasm_instantiate_module_time_scope( 1378 HistogramTimerScope wasm_instantiate_module_time_scope(
1378 isolate->counters()->wasm_instantiate_module_time()); 1379 isolate->counters()->wasm_instantiate_module_time());
1379 ErrorThrower thrower(isolate, "WasmModule::Instantiate()"); 1380 ErrorThrower thrower(isolate, "WasmModule::Instantiate()");
1380 Factory* factory = isolate->factory(); 1381 Factory* factory = isolate->factory();
1381 1382
1383 Handle<FixedArray> compiled_module =
1384 handle(FixedArray::cast(module_object->GetInternalField(0)));
1382 compiled_module = CloneModuleForInstance(isolate, compiled_module); 1385 compiled_module = CloneModuleForInstance(isolate, compiled_module);
1383 1386
1384 // These fields are compulsory. 1387 // These fields are compulsory.
1385 Handle<FixedArray> code_table = 1388 Handle<FixedArray> code_table =
1386 compiled_module->GetValueChecked<FixedArray>(isolate, kFunctions); 1389 compiled_module->GetValueChecked<FixedArray>(isolate, kFunctions);
1387 1390
1388 std::vector<Handle<Code>> functions( 1391 std::vector<Handle<Code>> functions(
1389 static_cast<size_t>(code_table->length())); 1392 static_cast<size_t>(code_table->length()));
1390 for (int i = 0; i < code_table->length(); ++i) { 1393 for (int i = 0; i < code_table->length(); ++i) {
1391 functions[static_cast<size_t>(i)] = 1394 functions[static_cast<size_t>(i)] =
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 MaybeHandle<FixedArray> compiled_module = 1671 MaybeHandle<FixedArray> compiled_module =
1669 decoded_module->CompileFunctions(isolate, thrower); 1672 decoded_module->CompileFunctions(isolate, thrower);
1670 if (compiled_module.is_null()) return nothing; 1673 if (compiled_module.is_null()) return nothing;
1671 1674
1672 return CreateCompiledModuleObject(isolate, compiled_module.ToHandleChecked(), 1675 return CreateCompiledModuleObject(isolate, compiled_module.ToHandleChecked(),
1673 origin); 1676 origin);
1674 } 1677 }
1675 } // namespace wasm 1678 } // namespace wasm
1676 } // namespace internal 1679 } // namespace internal
1677 } // namespace v8 1680 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698