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

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

Issue 2433273002: [wasm] Avoid double-serializing the wire bytes (Closed)
Patch Set: 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
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);
764 MaybeHandle<FixedArray> maybe_compiled_module = 767 MaybeHandle<FixedArray> maybe_compiled_module =
765 WasmCompiledModuleSerializer::DeserializeWasmModule(isolate, &sc); 768 WasmCompiledModuleSerializer::DeserializeWasmModule(
769 isolate, &sc,
770 {reinterpret_cast<uint8_t*>(wire_bytes->backing_store()),
Yang 2016/10/20 06:46:17 I think it helps with readability if you use the V
Mircea Trofin 2016/10/20 07:22:30 Done.
771 static_cast<int>(wire_bytes->byte_length()->Number())});
772
766 Handle<FixedArray> compiled_module; 773 Handle<FixedArray> compiled_module;
767 if (!maybe_compiled_module.ToHandle(&compiled_module)) { 774 if (!maybe_compiled_module.ToHandle(&compiled_module)) {
768 return isolate->heap()->undefined_value(); 775 return isolate->heap()->undefined_value();
769 } 776 }
770 return *wasm::CreateWasmModuleObject( 777 return *wasm::CreateWasmModuleObject(
771 isolate, Handle<wasm::WasmCompiledModule>::cast(compiled_module), 778 isolate, Handle<wasm::WasmCompiledModule>::cast(compiled_module),
772 wasm::kWasmOrigin); 779 wasm::kWasmOrigin);
773 } 780 }
774 781
775 RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) { 782 RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) {
(...skipping 17 matching lines...) Expand all
793 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { 800 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) {
794 HandleScope shs(isolate); 801 HandleScope shs(isolate);
795 DCHECK(args.length() == 1); 802 DCHECK(args.length() == 1);
796 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); 803 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0);
797 wasm::testing::ValidateOrphanedInstance(isolate, instance_obj); 804 wasm::testing::ValidateOrphanedInstance(isolate, instance_obj);
798 return isolate->heap()->ToBoolean(true); 805 return isolate->heap()->ToBoolean(true);
799 } 806 }
800 807
801 } // namespace internal 808 } // namespace internal
802 } // namespace v8 809 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698