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

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

Issue 2205973003: [wasm] Serialization/Deserialization of compiled module (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix silly bug Created 4 years, 4 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
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 "src/api-natives.h" 5 #include "src/api-natives.h"
6 #include "src/api.h" 6 #include "src/api.h"
7 #include "src/asmjs/asm-typer.h" 7 #include "src/asmjs/asm-typer.h"
8 #include "src/asmjs/asm-wasm-builder.h" 8 #include "src/asmjs/asm-wasm-builder.h"
9 #include "src/assert-scope.h" 9 #include "src/assert-scope.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 i::wasm::ModuleResult result = i::wasm::DecodeWasmModule( 311 i::wasm::ModuleResult result = i::wasm::DecodeWasmModule(
312 i_isolate, &zone, buffer.start, buffer.end, false, i::wasm::kWasmOrigin); 312 i_isolate, &zone, buffer.start, buffer.end, false, i::wasm::kWasmOrigin);
313 std::unique_ptr<const i::wasm::WasmModule> decoded_module(result.val); 313 std::unique_ptr<const i::wasm::WasmModule> decoded_module(result.val);
314 if (result.failed()) { 314 if (result.failed()) {
315 thrower->Failed("", result); 315 thrower->Failed("", result);
316 return nothing; 316 return nothing;
317 } 317 }
318 i::MaybeHandle<i::FixedArray> compiled_module = 318 i::MaybeHandle<i::FixedArray> compiled_module =
319 decoded_module->CompileFunctions(i_isolate, thrower); 319 decoded_module->CompileFunctions(i_isolate, thrower);
320 if (compiled_module.is_null()) return nothing; 320 if (compiled_module.is_null()) return nothing;
321 Local<Context> context = isolate->GetCurrentContext();
322 i::Handle<i::Context> i_context = Utils::OpenHandle(*context);
323 i::Handle<i::JSFunction> module_cons(i_context->wasm_module_constructor());
324 i::Handle<i::JSObject> module_obj =
325 i_isolate->factory()->NewJSObject(module_cons);
326 module_obj->SetInternalField(0, *compiled_module.ToHandleChecked());
327 i::Handle<i::Object> module_ref = Utils::OpenHandle(*source);
328 i::Handle<i::Symbol> module_sym(i_context->wasm_module_sym());
329 i::Object::SetProperty(module_obj, module_sym, module_ref, i::STRICT).Check();
330 321
331 return module_obj; 322 return i::wasm::CreateCompiledModuleObject(i_isolate,
323 compiled_module.ToHandleChecked());
332 } 324 }
333 325
334 void WebAssemblyCompile(const v8::FunctionCallbackInfo<v8::Value>& args) { 326 void WebAssemblyCompile(const v8::FunctionCallbackInfo<v8::Value>& args) {
335 v8::Isolate* isolate = args.GetIsolate(); 327 v8::Isolate* isolate = args.GetIsolate();
336 HandleScope scope(isolate); 328 HandleScope scope(isolate);
337 ErrorThrower thrower(reinterpret_cast<i::Isolate*>(isolate), 329 ErrorThrower thrower(reinterpret_cast<i::Isolate*>(isolate),
338 "WebAssembly.compile()"); 330 "WebAssembly.compile()");
339 331
340 if (args.Length() < 1) { 332 if (args.Length() < 1) {
341 thrower.Error("Argument 0 must be a buffer source"); 333 thrower.Error("Argument 0 must be a buffer source");
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 int unused_property_fields = in_object_properties - pre_allocated; 547 int unused_property_fields = in_object_properties - pre_allocated;
556 Handle<Map> map = Map::CopyInitialMap( 548 Handle<Map> map = Map::CopyInitialMap(
557 prev_map, instance_size, in_object_properties, unused_property_fields); 549 prev_map, instance_size, in_object_properties, unused_property_fields);
558 550
559 context->set_wasm_function_map(*map); 551 context->set_wasm_function_map(*map);
560 } 552 }
561 } 553 }
562 554
563 } // namespace internal 555 } // namespace internal
564 } // namespace v8 556 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698