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

Side by Side Diff: src/runtime/runtime-test.cc

Issue 2433273002: [wasm] Avoid double-serializing the wire bytes (Closed)
Patch Set: removed unrelated changes Created 4 years, 2 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/runtime/runtime.h ('k') | src/snapshot/code-serializer.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" 10 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer(); 747 Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer();
748 JSArrayBuffer::Setup(ret, isolate, false, buff, data->length()); 748 JSArrayBuffer::Setup(ret, isolate, false, buff, data->length());
749 memcpy(buff, data->data(), data->length()); 749 memcpy(buff, data->data(), data->length());
750 return *ret; 750 return *ret;
751 } 751 }
752 752
753 // Take an array buffer and attempt to reconstruct a compiled wasm module. 753 // Take an array buffer and attempt to reconstruct a compiled wasm module.
754 // Return undefined if unsuccessful. 754 // Return undefined if unsuccessful.
755 RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) { 755 RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) {
756 HandleScope shs(isolate); 756 HandleScope shs(isolate);
757 DCHECK(args.length() == 1); 757 DCHECK(args.length() == 2);
758 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 0); 758 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 0);
759 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, wire_bytes, 1);
759 760
760 Address mem_start = static_cast<Address>(buffer->backing_store()); 761 Address mem_start = static_cast<Address>(buffer->backing_store());
761 int mem_size = static_cast<int>(buffer->byte_length()->Number()); 762 int mem_size = static_cast<int>(buffer->byte_length()->Number());
762 763
764 // DeserializeWasmModule will allocate. We assume JSArrayBuffer doesn't
765 // get relocated.
763 ScriptData sc(mem_start, mem_size); 766 ScriptData sc(mem_start, mem_size);
767 bool already_external = wire_bytes->is_external();
768 if (!already_external) {
769 wire_bytes->set_is_external(true);
770 isolate->heap()->UnregisterArrayBuffer(*wire_bytes);
771 }
764 MaybeHandle<FixedArray> maybe_compiled_module = 772 MaybeHandle<FixedArray> maybe_compiled_module =
765 WasmCompiledModuleSerializer::DeserializeWasmModule(isolate, &sc); 773 WasmCompiledModuleSerializer::DeserializeWasmModule(
774 isolate, &sc,
775 Vector<const uint8_t>(
776 reinterpret_cast<uint8_t*>(wire_bytes->backing_store()),
777 static_cast<int>(wire_bytes->byte_length()->Number())));
778 if (!already_external) {
779 wire_bytes->set_is_external(false);
780 isolate->heap()->RegisterNewArrayBuffer(*wire_bytes);
781 }
766 Handle<FixedArray> compiled_module; 782 Handle<FixedArray> compiled_module;
767 if (!maybe_compiled_module.ToHandle(&compiled_module)) { 783 if (!maybe_compiled_module.ToHandle(&compiled_module)) {
768 return isolate->heap()->undefined_value(); 784 return isolate->heap()->undefined_value();
769 } 785 }
770 return *wasm::CreateWasmModuleObject( 786 return *wasm::CreateWasmModuleObject(
771 isolate, Handle<wasm::WasmCompiledModule>::cast(compiled_module), 787 isolate, Handle<wasm::WasmCompiledModule>::cast(compiled_module),
772 wasm::kWasmOrigin); 788 wasm::kWasmOrigin);
773 } 789 }
774 790
775 RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) { 791 RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) {
(...skipping 17 matching lines...) Expand all
793 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { 809 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) {
794 HandleScope shs(isolate); 810 HandleScope shs(isolate);
795 DCHECK(args.length() == 1); 811 DCHECK(args.length() == 1);
796 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); 812 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0);
797 wasm::testing::ValidateOrphanedInstance(isolate, instance_obj); 813 wasm::testing::ValidateOrphanedInstance(isolate, instance_obj);
798 return isolate->heap()->ToBoolean(true); 814 return isolate->heap()->ToBoolean(true);
799 } 815 }
800 816
801 } // namespace internal 817 } // namespace internal
802 } // namespace v8 818 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/snapshot/code-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698