v8/test/mjsunit/wasm/compiled-module-management.js

88 lines
2.5 KiB
JavaScript
Raw Normal View History

// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm --expose-gc --allow-natives-syntax
load("test/mjsunit/wasm/wasm-module-builder.js");
// Use global variables for all values where the test wants to maintain strict
// control over value lifetime. Using local variables would not give sufficient
// guarantees of the value lifetime.
var module;
var instance1;
var instance2;
var instance3;
var instance4;
(function CompiledModuleInstancesInitialize1to3() {
var builder = new WasmModuleBuilder();
builder.addMemory(1,1, true);
builder.addImport("", "getValue", kSig_i_v);
builder.addFunction("f", kSig_i_v)
.addBody([
kExprCallFunction, 0
]).exportFunc();
module = new WebAssembly.Module(builder.toBuffer());
print("Initial instances=0");
assertEquals(0, %WasmGetNumberOfInstances(module));
instance1 = new WebAssembly.Instance(module, {"": {getValue: () => 1}});
print("Initial instances=1");
assertEquals(1, %WasmGetNumberOfInstances(module));
instance2 = new WebAssembly.Instance(module, {"": {getValue: () => 2}});
print("Initial instances=2");
assertEquals(2, %WasmGetNumberOfInstances(module));
instance3 = new WebAssembly.Instance(module, {"": {getValue: () => 3}});
print("Initial instances=3");
assertEquals(3, %WasmGetNumberOfInstances(module));
})();
(function CompiledModuleInstancesClear1() {
assertEquals(1, instance1.exports.f());
instance1 = null;
})();
// Note that two GC's are required because weak slots clearing is deferred.
gc();
gc();
print("After gc instances=2");
assertEquals(2, %WasmGetNumberOfInstances(module));
(function CompiledModuleInstancesClear3() {
assertEquals(3, instance3.exports.f());
instance3 = null;
})();
// Note that two GC's are required because weak slots clearing is deferred.
gc();
gc();
print("After gc instances=1");
assertEquals(1, %WasmGetNumberOfInstances(module));
(function CompiledModuleInstancesClear2() {
assertEquals(2, instance2.exports.f());
instance2 = null;
})();
// Note that two GC's are required because weak slots clearing is deferred.
gc();
gc();
print("After gc instances=0");
assertEquals(0, %WasmGetNumberOfInstances(module));
(function CompiledModuleInstancesInitialize4AndClearModule() {
instance4 = new WebAssembly.Instance(module, {"": {getValue: () => 4}});
assertEquals(4, instance4.exports.f());
module = null;
})();
// Note that two GC's are required because weak slots clearing is deferred.
Revert "Revert "[wasm] Reference indirect tables as addresses of global handles"" This reverts commit af37f6b970e58254088b7cd58c3583e55b79e044. Reason for revert: Reverted dependency fixed. Original change's description: > Revert "[wasm] Reference indirect tables as addresses of global handles" > > This reverts commit 186099d49f57b3eea23412acff2366891b96c144. > > Reason for revert: Need to revert: > https://chromium-review.googlesource.com/c/613880 > > Original change's description: > > [wasm] Reference indirect tables as addresses of global handles > > > > This sets us up for getting the wasm code generation off the GC heap. > > We reference tables as global handles, which have a stable address. This > > requires an extra instruction when attempting to make an indirect call, > > per table (i.e. one for the signature table and one for the function > > table). > > > > Bug: > > Change-Id: I83743ba0f1dfdeba9aee5d27232f8823981288f8 > > Reviewed-on: https://chromium-review.googlesource.com/612322 > > Commit-Queue: Mircea Trofin <mtrofin@chromium.org> > > Reviewed-by: Brad Nelson <bradnelson@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#47444} > > TBR=bradnelson@chromium.org,titzer@chromium.org,mtrofin@chromium.org > > Change-Id: Ic3dff87410a51a2072ddc16cfc83a230526d4c56 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://chromium-review.googlesource.com/622568 > Reviewed-by: Michael Achenbach <machenbach@chromium.org> > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > Cr-Commit-Position: refs/heads/master@{#47450} TBR=bradnelson@chromium.org,machenbach@chromium.org,titzer@chromium.org,mtrofin@chromium.org Change-Id: I3dc5dc8be26b5462703edac954cbedbb8f504c1e No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/622035 Reviewed-by: Mircea Trofin <mtrofin@chromium.org> Commit-Queue: Mircea Trofin <mtrofin@chromium.org> Cr-Commit-Position: refs/heads/master@{#47455}
2017-08-19 16:35:05 +00:00
gc();
gc();