[wasm][anyref] Add more tests
These are some tests I thought were missing. I wrote another test which crashes because of missing safepoint maps. I will add it in a separate CL which includes also the implementation. R=herhut@chromium.org Bug: v8:7581 Change-Id: Ibcc3b9ddab0f95580eb31fe78c84a26186a74db5 Reviewed-on: https://chromium-review.googlesource.com/c/1370039 Reviewed-by: Stephan Herhut <herhut@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#58159}
This commit is contained in:
parent
a55803a15d
commit
8f406d4403
@ -45,6 +45,41 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
instance.exports.main({hello: 'world'});
|
||||
})();
|
||||
|
||||
(function testPassAnyRefWithGCWithLocals() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
const ref_sig = builder.addType(kSig_v_r);
|
||||
const void_sig = builder.addType(kSig_v_v);
|
||||
const imp_index = builder.addImport("q", "func", ref_sig);
|
||||
const gc_index = builder.addImport("q", "gc", void_sig);
|
||||
// First call the gc, then check if the object still exists.
|
||||
builder.addFunction('main', ref_sig)
|
||||
.addLocals({anyref_count: 10})
|
||||
.addBody([
|
||||
kExprGetLocal, 0, kExprSetLocal, 1, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 2, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 3, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 4, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 5, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 6, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 7, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 8, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 9, // Set local
|
||||
kExprGetLocal, 0, kExprSetLocal, 10, // Set local
|
||||
kExprCallFunction, gc_index, // call gc
|
||||
kExprGetLocal, 9, kExprCallFunction, imp_index // call import
|
||||
])
|
||||
.exportFunc();
|
||||
|
||||
function checkFunction(value) {
|
||||
assertEquals('world', value.hello);
|
||||
}
|
||||
|
||||
const instance = builder.instantiate({q: {func: checkFunction, gc: gc}});
|
||||
|
||||
instance.exports.main({hello: 'world'});
|
||||
})();
|
||||
|
||||
(function testPassAnyRefWithGC() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
@ -69,6 +104,28 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
instance.exports.main({hello: 'world'});
|
||||
})();
|
||||
|
||||
(function testPassAnyRefWithGCInWrapper() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
const kSig_r_iri = makeSig([kWasmI32, kWasmAnyRef, kWasmI32], [kWasmAnyRef]);
|
||||
const sig_index = builder.addType(kSig_r_iri);
|
||||
builder.addFunction('main', sig_index)
|
||||
.addBody([kExprGetLocal, 1])
|
||||
.exportFunc();
|
||||
|
||||
const instance = builder.instantiate();
|
||||
|
||||
const triggerGCParam = {
|
||||
valueOf: () => {
|
||||
gc();
|
||||
return 17;
|
||||
}
|
||||
};
|
||||
|
||||
const result = instance.exports.main(triggerGCParam, {hello: 'world'}, triggerGCParam);
|
||||
assertEquals('world', result.hello);
|
||||
})();
|
||||
|
||||
(function testAnyRefNull() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
@ -99,6 +156,19 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertEquals(0, instance.exports.main(print));
|
||||
})();
|
||||
|
||||
(function testAnyRefNullIsNull() {
|
||||
print(arguments.callee.name);
|
||||
|
||||
const builder = new WasmModuleBuilder();
|
||||
builder.addFunction('main', kSig_i_v)
|
||||
.addBody([kExprRefNull, kExprRefIsNull])
|
||||
.exportFunc();
|
||||
|
||||
const instance = builder.instantiate();
|
||||
|
||||
assertEquals(1, instance.exports.main());
|
||||
})();
|
||||
|
||||
(function testAnyRefLocalDefaultValue() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
|
Loading…
Reference in New Issue
Block a user