4cbc5a4dff
This Cl adds a type to {WasmTableObject}, and extends {WasmTableObject::Set} and {WasmTableObject::Get} to support anyref tables. I did it in one CL so that I can write tests. R=mstarzinger@chromium.org Bug: v8:7581 Change-Id: I6c6d78f84715a7805f7bb881a63d3c1174f6a6ab Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511332 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#60206}
32 lines
1013 B
JavaScript
32 lines
1013 B
JavaScript
// Copyright 2019 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: --experimental-wasm-anyref
|
|
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
(function TestAnyRefTableSetWithMultipleTypes() {
|
|
print(arguments.callee.name);
|
|
let table = new WebAssembly.Table({element: "anyref", initial: 10});
|
|
|
|
// Table should be initialized with null.
|
|
assertEquals(null, table.get(1));
|
|
let obj = {'hello' : 'world'};
|
|
table.set(2, obj);
|
|
assertSame(obj, table.get(2));
|
|
table.set(3, 1234);
|
|
assertEquals(1234, table.get(3));
|
|
table.set(4, 123.5);
|
|
assertEquals(123.5, table.get(4));
|
|
table.set(5, undefined);
|
|
assertEquals(undefined, table.get(5));
|
|
// Overwrite entry 4, because null would otherwise be the default value.
|
|
table.set(4, null);
|
|
assertEquals(null, table.get(4));
|
|
table.set(7, print);
|
|
assertEquals(print, table.get(7));
|
|
|
|
assertThrows(() => table.set(12), RangeError);
|
|
})();
|