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

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

Issue 2424623002: [wasm] Use a Managed<WasmModule> to hold metadata about modules. (Closed)
Patch Set: [wasm] Use a Managed<WasmModule> to hold metadata about modules. 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/wasm/wasm-module.cc ('k') | test/cctest/wasm/wasm-run-utils.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 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/snapshot/code-serializer.h" 8 #include "src/snapshot/code-serializer.h"
9 #include "src/version.h" 9 #include "src/version.h"
10 #include "src/wasm/module-decoder.h" 10 #include "src/wasm/module-decoder.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 Isolate* serialization_isolate = CcTest::InitIsolateOnce(); 271 Isolate* serialization_isolate = CcTest::InitIsolateOnce();
272 ErrorThrower thrower(serialization_isolate, ""); 272 ErrorThrower thrower(serialization_isolate, "");
273 uint8_t* bytes = nullptr; 273 uint8_t* bytes = nullptr;
274 size_t bytes_size = 0; 274 size_t bytes_size = 0;
275 { 275 {
276 HandleScope scope(serialization_isolate); 276 HandleScope scope(serialization_isolate);
277 testing::SetupIsolateForWasmModule(serialization_isolate); 277 testing::SetupIsolateForWasmModule(serialization_isolate);
278 278
279 ModuleResult decoding_result = 279 ModuleResult decoding_result =
280 DecodeWasmModule(serialization_isolate, zone(), buffer.begin(), 280 DecodeWasmModule(serialization_isolate, buffer.begin(), buffer.end(),
281 buffer.end(), false, kWasmOrigin); 281 false, kWasmOrigin);
282 std::unique_ptr<const WasmModule> module(decoding_result.val);
283 CHECK(!decoding_result.failed()); 282 CHECK(!decoding_result.failed());
284 283
284 Handle<WasmModuleWrapper> module_wrapper = WasmModuleWrapper::New(
285 serialization_isolate, const_cast<WasmModule*>(decoding_result.val));
286
285 MaybeHandle<WasmCompiledModule> compiled_module = 287 MaybeHandle<WasmCompiledModule> compiled_module =
286 module->CompileFunctions(serialization_isolate, &thrower); 288 decoding_result.val->CompileFunctions(serialization_isolate,
289 module_wrapper, &thrower);
287 CHECK(!compiled_module.is_null()); 290 CHECK(!compiled_module.is_null());
288 Handle<JSObject> module_obj = CreateCompiledModuleObject( 291 Handle<JSObject> module_obj = CreateWasmModuleObject(
289 serialization_isolate, compiled_module.ToHandleChecked(), 292 serialization_isolate, compiled_module.ToHandleChecked(),
290 ModuleOrigin::kWasmOrigin); 293 ModuleOrigin::kWasmOrigin);
291 v8::Local<v8::Object> v8_module_obj = v8::Utils::ToLocal(module_obj); 294 v8::Local<v8::Object> v8_module_obj = v8::Utils::ToLocal(module_obj);
292 CHECK(v8_module_obj->IsWebAssemblyCompiledModule()); 295 CHECK(v8_module_obj->IsWebAssemblyCompiledModule());
293 296
294 v8::Local<v8::WasmCompiledModule> v8_compiled_module = 297 v8::Local<v8::WasmCompiledModule> v8_compiled_module =
295 v8_module_obj.As<v8::WasmCompiledModule>(); 298 v8_module_obj.As<v8::WasmCompiledModule>();
296 v8::Local<v8::String> uncompiled_bytes = 299 v8::Local<v8::String> uncompiled_bytes =
297 v8_compiled_module->GetWasmWireBytes(); 300 v8_compiled_module->GetWasmWireBytes();
298 bytes_size = static_cast<size_t>(uncompiled_bytes->Length()); 301 bytes_size = static_cast<size_t>(uncompiled_bytes->Length());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 WASM_I32V(121)}; 466 WASM_I32V(121)};
464 f->EmitCode(code, sizeof(code)); 467 f->EmitCode(code, sizeof(code));
465 ZoneBuffer buffer(&zone); 468 ZoneBuffer buffer(&zone);
466 builder->WriteTo(buffer); 469 builder->WriteTo(buffer);
467 470
468 HandleScope scope(isolate); 471 HandleScope scope(isolate);
469 testing::SetupIsolateForWasmModule(isolate); 472 testing::SetupIsolateForWasmModule(isolate);
470 ErrorThrower thrower(isolate, "Test"); 473 ErrorThrower thrower(isolate, "Test");
471 const Handle<JSObject> instance = 474 const Handle<JSObject> instance =
472 testing::CompileInstantiateWasmModuleForTesting( 475 testing::CompileInstantiateWasmModuleForTesting(
473 isolate, &thrower, &zone, buffer.begin(), buffer.end(), 476 isolate, &thrower, buffer.begin(), buffer.end(),
474 ModuleOrigin::kWasmOrigin); 477 ModuleOrigin::kWasmOrigin);
475 CHECK(!instance.is_null()); 478 CHECK(!instance.is_null());
476 479
477 MaybeHandle<JSArrayBuffer> maybe_memory = 480 MaybeHandle<JSArrayBuffer> maybe_memory =
478 GetInstanceMemory(isolate, instance); 481 GetInstanceMemory(isolate, instance);
479 Handle<JSArrayBuffer> memory = maybe_memory.ToHandleChecked(); 482 Handle<JSArrayBuffer> memory = maybe_memory.ToHandleChecked();
480 int32_t* memory_array = reinterpret_cast<int32_t*>(memory->backing_store()); 483 int32_t* memory_array = reinterpret_cast<int32_t*>(memory->backing_store());
481 484
482 InterruptThread thread(isolate, memory_array); 485 InterruptThread thread(isolate, memory_array);
483 thread.Start(); 486 thread.Start();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))}; 540 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))};
538 f->EmitCode(code, sizeof(code)); 541 f->EmitCode(code, sizeof(code));
539 542
540 HandleScope scope(isolate); 543 HandleScope scope(isolate);
541 ZoneBuffer buffer(&zone); 544 ZoneBuffer buffer(&zone);
542 builder->WriteTo(buffer); 545 builder->WriteTo(buffer);
543 testing::SetupIsolateForWasmModule(isolate); 546 testing::SetupIsolateForWasmModule(isolate);
544 547
545 ErrorThrower thrower(isolate, "Test"); 548 ErrorThrower thrower(isolate, "Test");
546 Handle<JSObject> instance = testing::CompileInstantiateWasmModuleForTesting( 549 Handle<JSObject> instance = testing::CompileInstantiateWasmModuleForTesting(
547 isolate, &thrower, &zone, buffer.begin(), buffer.end(), 550 isolate, &thrower, buffer.begin(), buffer.end(),
548 ModuleOrigin::kWasmOrigin); 551 ModuleOrigin::kWasmOrigin);
549 CHECK(!instance.is_null()); 552 CHECK(!instance.is_null());
550 553
551 // Initial memory size is 16 pages, should trap till index > MemSize on 554 // Initial memory size is 16 pages, should trap till index > MemSize on
552 // consecutive GrowMem calls 555 // consecutive GrowMem calls
553 for (uint32_t i = 1; i < 5; i++) { 556 for (uint32_t i = 1; i < 5; i++) {
554 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(i), isolate)}; 557 Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(i), isolate)};
555 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 558 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
556 testing::RunWasmModuleForTesting(isolate, instance, 1, params, 559 testing::RunWasmModuleForTesting(isolate, instance, 1, params,
557 ModuleOrigin::kWasmOrigin); 560 ModuleOrigin::kWasmOrigin);
(...skipping 24 matching lines...) Expand all
582 WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))}; 585 WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))};
583 f->EmitCode(code, sizeof(code)); 586 f->EmitCode(code, sizeof(code));
584 587
585 HandleScope scope(isolate); 588 HandleScope scope(isolate);
586 ZoneBuffer buffer(&zone); 589 ZoneBuffer buffer(&zone);
587 builder->WriteTo(buffer); 590 builder->WriteTo(buffer);
588 testing::SetupIsolateForWasmModule(isolate); 591 testing::SetupIsolateForWasmModule(isolate);
589 592
590 ErrorThrower thrower(isolate, "Test"); 593 ErrorThrower thrower(isolate, "Test");
591 Handle<JSObject> instance = testing::CompileInstantiateWasmModuleForTesting( 594 Handle<JSObject> instance = testing::CompileInstantiateWasmModuleForTesting(
592 isolate, &thrower, &zone, buffer.begin(), buffer.end(), 595 isolate, &thrower, buffer.begin(), buffer.end(),
593 ModuleOrigin::kWasmOrigin); 596 ModuleOrigin::kWasmOrigin);
594 597
595 CHECK(!instance.is_null()); 598 CHECK(!instance.is_null());
596 599
597 // Initial memory size is 16 pages, should trap till index > MemSize on 600 // Initial memory size is 16 pages, should trap till index > MemSize on
598 // consecutive GrowMem calls 601 // consecutive GrowMem calls
599 for (int i = 1; i < 5; i++) { 602 for (int i = 1; i < 5; i++) {
600 Handle<Object> params[1] = { 603 Handle<Object> params[1] = {
601 Handle<Object>(Smi::FromInt((16 + i) * kPageSize - 3), isolate)}; 604 Handle<Object>(Smi::FromInt((16 + i) * kPageSize - 3), isolate)};
602 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 605 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 709
707 TEST(Run_WasmModule_Global_f32) { 710 TEST(Run_WasmModule_Global_f32) {
708 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f); 711 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f);
709 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f); 712 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f);
710 } 713 }
711 714
712 TEST(Run_WasmModule_Global_f64) { 715 TEST(Run_WasmModule_Global_f64) {
713 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9); 716 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9);
714 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25); 717 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25);
715 } 718 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698