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

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

Issue 2299873002: [wasm] consolidate wasm and asm.js module compilation sequence (Closed)
Patch Set: 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
« src/wasm/wasm-module.h ('K') | « src/wasm/wasm-module.h ('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 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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 Isolate* isolate, Handle<FixedArray> compiled_module) { 1633 Isolate* isolate, Handle<FixedArray> compiled_module) {
1634 Handle<JSFunction> module_cons( 1634 Handle<JSFunction> module_cons(
1635 isolate->native_context()->wasm_module_constructor()); 1635 isolate->native_context()->wasm_module_constructor());
1636 Handle<JSObject> module_obj = isolate->factory()->NewJSObject(module_cons); 1636 Handle<JSObject> module_obj = isolate->factory()->NewJSObject(module_cons);
1637 module_obj->SetInternalField(0, *compiled_module); 1637 module_obj->SetInternalField(0, *compiled_module);
1638 Handle<Symbol> module_sym(isolate->native_context()->wasm_module_sym()); 1638 Handle<Symbol> module_sym(isolate->native_context()->wasm_module_sym());
1639 Object::SetProperty(module_obj, module_sym, module_obj, STRICT).Check(); 1639 Object::SetProperty(module_obj, module_sym, module_obj, STRICT).Check();
1640 return module_obj; 1640 return module_obj;
1641 } 1641 }
1642 1642
1643 MaybeHandle<JSObject> CreateModuleObjectFromBytes(
1644 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower,
1645 bool verify, ModuleOrigin origin) {
1646 MaybeHandle<JSObject> nothing;
1647 Zone zone(isolate->allocator());
1648 ModuleResult result =
1649 DecodeWasmModule(isolate, &zone, start, end, verify, origin);
1650 std::unique_ptr<const WasmModule> decoded_module(result.val);
1651 if (result.failed()) {
1652 thrower->Failed("Wasm decoding failed", result);
1653 return nothing;
1654 }
1655 MaybeHandle<FixedArray> compiled_module =
1656 decoded_module->CompileFunctions(isolate, thrower);
1657 if (compiled_module.is_null()) return nothing;
1658
1659 return CreateCompiledModuleObject(isolate, compiled_module.ToHandleChecked());
1660 }
1661
1643 namespace testing { 1662 namespace testing {
1644 1663
1645 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, 1664 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
1646 const byte* module_end, bool asm_js) { 1665 const byte* module_end, bool asm_js) {
1647 HandleScope scope(isolate); 1666 HandleScope scope(isolate);
1648 Zone zone(isolate->allocator()); 1667 Zone zone(isolate->allocator());
1649 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); 1668 ErrorThrower thrower(isolate, "CompileAndRunWasmModule");
1650 1669
1651 // Decode the module, but don't verify function bodies, since we'll 1670 // Decode the module, but don't verify function bodies, since we'll
1652 // be compiling them anyway. 1671 // be compiling them anyway.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); 1740 return static_cast<int32_t>(HeapNumber::cast(*result)->value());
1722 } 1741 }
1723 thrower->Error("WASM.compileRun() failed: Return value should be number"); 1742 thrower->Error("WASM.compileRun() failed: Return value should be number");
1724 return -1; 1743 return -1;
1725 } 1744 }
1726 1745
1727 } // namespace testing 1746 } // namespace testing
1728 } // namespace wasm 1747 } // namespace wasm
1729 } // namespace internal 1748 } // namespace internal
1730 } // namespace v8 1749 } // namespace v8
OLDNEW
« src/wasm/wasm-module.h ('K') | « src/wasm/wasm-module.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698