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

Side by Side Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 2748473004: [wasm] Transferrable modules (Closed)
Patch Set: feedback Created 3 years, 9 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/value-serializer.cc ('k') | test/unittests/value-serializer-unittest.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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 #include "src/snapshot/code-serializer.h" 9 #include "src/snapshot/code-serializer.h"
10 #include "src/version.h" 10 #include "src/version.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 { 462 {
463 HandleScope scope(test.current_isolate()); 463 HandleScope scope(test.current_isolate());
464 test.current_isolate_v8()->SetAllowCodeGenerationFromStringsCallback(False); 464 test.current_isolate_v8()->SetAllowCodeGenerationFromStringsCallback(False);
465 v8::MaybeLocal<v8::WasmCompiledModule> nothing = test.Deserialize(); 465 v8::MaybeLocal<v8::WasmCompiledModule> nothing = test.Deserialize();
466 CHECK(nothing.IsEmpty()); 466 CHECK(nothing.IsEmpty());
467 } 467 }
468 Cleanup(test.current_isolate()); 468 Cleanup(test.current_isolate());
469 Cleanup(); 469 Cleanup();
470 } 470 }
471 471
472 TEST(TransferrableWasmModules) {
473 v8::internal::AccountingAllocator allocator;
474 Zone zone(&allocator, ZONE_NAME);
475
476 ZoneBuffer buffer(&zone);
477 WasmSerializationTest::BuildWireBytes(&zone, &buffer);
478
479 Isolate* from_isolate = CcTest::InitIsolateOnce();
480 ErrorThrower thrower(from_isolate, "");
481 std::vector<v8::WasmCompiledModule::TransferrableModule> store;
482 {
483 HandleScope scope(from_isolate);
484 testing::SetupIsolateForWasmModule(from_isolate);
485
486 MaybeHandle<WasmModuleObject> module_object = SyncCompile(
487 from_isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end()));
488 v8::Local<v8::WasmCompiledModule> v8_module =
489 v8::Local<v8::WasmCompiledModule>::Cast(v8::Utils::ToLocal(
490 Handle<JSObject>::cast(module_object.ToHandleChecked())));
491 store.push_back(v8_module->GetTransferrableModule());
492 }
493
494 {
495 v8::Isolate::CreateParams create_params;
496 create_params.array_buffer_allocator =
497 from_isolate->array_buffer_allocator();
498 v8::Isolate* to_isolate = v8::Isolate::New(create_params);
499 v8::HandleScope new_scope(to_isolate);
500 v8::Local<v8::Context> deserialization_context =
501 v8::Context::New(to_isolate);
502 deserialization_context->Enter();
503 v8::MaybeLocal<v8::WasmCompiledModule> mod =
504 v8::WasmCompiledModule::FromTransferrableModule(to_isolate, store[0]);
505 CHECK(!mod.IsEmpty());
506 }
507 }
508
472 TEST(MemorySize) { 509 TEST(MemorySize) {
473 { 510 {
474 // Initial memory size is 16, see wasm-module-builder.cc 511 // Initial memory size is 16, see wasm-module-builder.cc
475 static const int kExpectedValue = 16; 512 static const int kExpectedValue = 16;
476 TestSignatures sigs; 513 TestSignatures sigs;
477 v8::internal::AccountingAllocator allocator; 514 v8::internal::AccountingAllocator allocator;
478 Zone zone(&allocator, ZONE_NAME); 515 Zone zone(&allocator, ZONE_NAME);
479 516
480 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 517 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
481 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); 518 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 ModuleOrigin::kWasmOrigin); 1069 ModuleOrigin::kWasmOrigin);
1033 CHECK_EQ(kExpectedValue, result); 1070 CHECK_EQ(kExpectedValue, result);
1034 // Free the buffer as the tracker does not know about it. 1071 // Free the buffer as the tracker does not know about it.
1035 if (!memory->has_guard_region()) { 1072 if (!memory->has_guard_region()) {
1036 isolate->array_buffer_allocator()->Free( 1073 isolate->array_buffer_allocator()->Free(
1037 memory->backing_store(), NumberToSize(memory->byte_length())); 1074 memory->backing_store(), NumberToSize(memory->byte_length()));
1038 } 1075 }
1039 } 1076 }
1040 Cleanup(); 1077 Cleanup();
1041 } 1078 }
OLDNEW
« no previous file with comments | « src/value-serializer.cc ('k') | test/unittests/value-serializer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698