Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=249562 rdar://103498866 Reviewed by Nobody. Import and add the v8 mjsunit Wasm tests. This includes adding some new resource .js files and adding those resource files to run-jsc-stress-tests. Created a script, Tools/Scripts/convert-imported-v8-tests.py, to automate much of the process. This script searches for calls to v8 internal '%' functions, calls to print, load directives and either converts them to JSC equivalents or flags the tests with "skip" directives. Of the 200+ files, over 165 have been skipped for various issues. In all of these skipped tests, comments haave been added to the top of the test file with the reason they were skipped. Canonical link: https://commits.webkit.org/258088@main
- Loading branch information
1 parent
ba43a12
commit f25b969
Showing
250 changed files
with
44,431 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,320 @@ | ||
//@ requireOptions("--useBBQJIT=1", "--useWasmLLInt=1", "--wasmLLIntTiersUpToBBQ=1") | ||
// Copyright 2015 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 | ||
|
||
load("wasm-module-builder.js"); | ||
|
||
const JS = false; // for testing the tests. | ||
const WRONG1 = 0x0DEDFACE; | ||
const WRONG2 = 0x0DEDBABE; | ||
const WRONG3 = 0x0DEDD011 | ||
|
||
function makeSelect(type, args, which) { | ||
if (JS) { | ||
// For testing the tests. | ||
return function() { | ||
var val = +arguments[which]; | ||
// print(" " + val); | ||
if (type == kWasmI32) return val | 0; | ||
if (type == kWasmF32) return Math.fround(val); | ||
if (type == kWasmF64) return val; | ||
return undefined; | ||
} | ||
} | ||
|
||
var builder = new WasmModuleBuilder(); | ||
var params = []; | ||
for (var i = 0; i < args; i++) params.push(type); | ||
builder.addFunction("select", makeSig(params, [type])) | ||
.addBody([kExprLocalGet, which]) | ||
.exportFunc(); | ||
|
||
return builder.instantiate().exports.select; | ||
} | ||
|
||
const inputs = [ | ||
-1, 0, 2.2, 3.3, 3000.11, Infinity, -Infinity, NaN | ||
]; | ||
|
||
(function TestInt1() { | ||
// print("i32 1(0)..."); | ||
var C = function(v) { return v | 0; } | ||
var select1 = makeSelect(kWasmI32, 1, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select1(val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select1()); | ||
// over args | ||
assertEquals(C(val), select1(val, WRONG1)); | ||
assertEquals(C(val), select1(val, WRONG1, WRONG2)); | ||
} | ||
})(); | ||
|
||
(function TestInt2() { | ||
// print("i32 2(0)..."); | ||
var C = function(v) { return v | 0; } | ||
var select = makeSelect(kWasmI32, 2, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(val, WRONG1)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(val), select(val)); | ||
// over args | ||
assertEquals(C(val), select(val, WRONG1, WRONG2)); | ||
assertEquals(C(val), select(val, WRONG1, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("i32 2(1)..."); | ||
var select = makeSelect(kWasmI32, 2, 1); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(val)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, val)); | ||
assertEquals(C(val), select(WRONG1, val, WRONG2)); | ||
assertEquals(C(val), select(WRONG1, val, WRONG2, WRONG3)); | ||
} | ||
})(); | ||
|
||
(function TestInt3() { | ||
// print("i32 3(0)..."); | ||
var C = function(v) { return v | 0; } | ||
var select = makeSelect(kWasmI32, 3, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(val, WRONG1, WRONG2)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(val), select(val)); | ||
assertEquals(C(val), select(val, WRONG1)); | ||
// over args | ||
assertEquals(C(val), select(val, WRONG1, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("i32 3(1)..."); | ||
var select = makeSelect(kWasmI32, 3, 1); | ||
|
||
for (val of inputs) { | ||
assertEquals(val | 0, select(WRONG1, val, WRONG2)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(0xDEDFACE)); | ||
assertEquals(C(val), select(WRONG1, val)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, val, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("i32 3(2)..."); | ||
var select = makeSelect(kWasmI32, 3, 2); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, WRONG2, val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(0xDEDFACE)); | ||
assertEquals(C(undefined), select(WRONG1, WRONG2)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, WRONG2, val, WRONG3)); | ||
} | ||
})(); | ||
|
||
(function TestFloat32_1() { | ||
// print("f32 1(0)..."); | ||
var C = function(v) { return Math.fround(v); } | ||
var select1 = makeSelect(kWasmF32, 1, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select1(val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select1()); | ||
// over args | ||
assertEquals(C(val), select1(val, WRONG1)); | ||
assertEquals(C(val), select1(val, WRONG1, WRONG2)); | ||
} | ||
})(); | ||
|
||
(function TestFloat32_2() { | ||
// print("f32 2(0)..."); | ||
var C = function(v) { return Math.fround(v); } | ||
var select = makeSelect(kWasmF32, 2, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(val, WRONG1)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(val), select(val)); | ||
// over args | ||
assertEquals(C(val), select(val, WRONG1, WRONG2)); | ||
assertEquals(C(val), select(val, WRONG1, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("f32 2(1)..."); | ||
var select = makeSelect(kWasmF32, 2, 1); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(val)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, val)); | ||
assertEquals(C(val), select(WRONG1, val, WRONG2)); | ||
assertEquals(C(val), select(WRONG1, val, WRONG2, WRONG3)); | ||
} | ||
})(); | ||
|
||
(function TestFloat32_2() { | ||
// print("f32 3(0)..."); | ||
var C = function(v) { return Math.fround(v); } | ||
var select = makeSelect(kWasmF32, 3, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(val, WRONG1, WRONG2)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(val), select(val)); | ||
assertEquals(C(val), select(val, WRONG1)); | ||
// over args | ||
assertEquals(C(val), select(val, WRONG1, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("f32 3(1)..."); | ||
var select = makeSelect(kWasmF32, 3, 1); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, val, WRONG2)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(0xDEDFACE)); | ||
assertEquals(C(val), select(WRONG1, val)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, val, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("f32 3(2)..."); | ||
var select = makeSelect(kWasmF32, 3, 2); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, WRONG2, val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(0xDEDFACE)); | ||
assertEquals(C(undefined), select(WRONG1, WRONG2)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, WRONG2, val, WRONG3)); | ||
} | ||
})(); | ||
|
||
|
||
(function TestFloat64_1() { | ||
// print("f64 1(0)..."); | ||
var C = function(v) { return +v; } | ||
var select1 = makeSelect(kWasmF64, 1, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select1(val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select1()); | ||
// over args | ||
assertEquals(C(val), select1(val, WRONG1)); | ||
assertEquals(C(val), select1(val, WRONG1, WRONG2)); | ||
} | ||
})(); | ||
|
||
(function TestFloat64_2() { | ||
// print("f64 2(0)..."); | ||
var C = function(v) { return +v; } | ||
var select = makeSelect(kWasmF64, 2, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(val, WRONG1)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(val), select(val)); | ||
// over args | ||
assertEquals(C(val), select(val, WRONG1, WRONG2)); | ||
assertEquals(C(val), select(val, WRONG1, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("f64 2(1)..."); | ||
var select = makeSelect(kWasmF64, 2, 1); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(val)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, val)); | ||
assertEquals(C(val), select(WRONG1, val, WRONG2)); | ||
assertEquals(C(val), select(WRONG1, val, WRONG2, WRONG3)); | ||
} | ||
})(); | ||
|
||
(function TestFloat64_2() { | ||
// print("f64 3(0)..."); | ||
var C = function(v) { return +v; } | ||
var select = makeSelect(kWasmF64, 3, 0); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(val, WRONG1, WRONG2)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(val), select(val)); | ||
assertEquals(C(val), select(val, WRONG1)); | ||
// over args | ||
assertEquals(C(val), select(val, WRONG1, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("f64 3(1)..."); | ||
var select = makeSelect(kWasmF64, 3, 1); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, val, WRONG2)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(0xDEDFACE)); | ||
assertEquals(C(val), select(WRONG1, val)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, val, WRONG2, WRONG3)); | ||
} | ||
|
||
// print("f64 3(2)..."); | ||
var select = makeSelect(kWasmF64, 3, 2); | ||
|
||
for (val of inputs) { | ||
assertEquals(C(val), select(WRONG1, WRONG2, val)); | ||
|
||
// under args | ||
assertEquals(C(undefined), select()); | ||
assertEquals(C(undefined), select(0xDEDFACE)); | ||
assertEquals(C(undefined), select(WRONG1, WRONG2)); | ||
// over args | ||
assertEquals(C(val), select(WRONG1, WRONG2, val, WRONG3)); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//@ requireOptions("--useBBQJIT=1", "--useWasmLLInt=1", "--wasmLLIntTiersUpToBBQ=1") | ||
// 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 | ||
|
||
load("wasm-module-builder.js"); | ||
|
||
function testAddGetter(object, name, val) { | ||
Object.defineProperty(object, name, { get: function() { return val; } }); | ||
assertSame(val, object[name]); | ||
} | ||
|
||
function testAddGetterFails(object, name, val) { | ||
function assign() { | ||
Object.defineProperty(object, name, { get: function() { return val; } }); | ||
} | ||
assertThrows(assign, TypeError); | ||
} | ||
|
||
function testAddGetterBothWays(object, name, val) { | ||
// print("Object.defineProperty"); | ||
Object.defineProperty(object, name, { get: function() { return val; } }); | ||
// print("object.__defineGetter__"); | ||
object.__defineGetter__(name, () => val); | ||
assertSame(val, object[name]); | ||
} | ||
|
||
function testFailToAddGetter(object, name, val) { | ||
assertThrows(() => Object.defineProperty(object, name, { get: function() { return val; } })); | ||
} | ||
|
||
testAddGetter(testAddGetter, "name", 11); | ||
|
||
function makeBuilder() { | ||
var builder = new WasmModuleBuilder(); | ||
|
||
builder.addFunction("f", kSig_v_v) | ||
.addBody([]) | ||
.exportFunc(); | ||
return builder; | ||
} | ||
|
||
(function TestAddGetterToFunction() { | ||
// print("TestAddGetterToFunction..."); | ||
var builder = makeBuilder(); | ||
var f = builder.instantiate().exports.f; | ||
testAddGetterBothWays(f, "name", "foo"); | ||
testAddGetter(f, "blam", "baz"); | ||
})(); | ||
|
||
(function TestAddGetterToModule() { | ||
// print("TestAddGetterToModule..."); | ||
var builder = makeBuilder(); | ||
var module = new WebAssembly.Module(builder.toBuffer()); | ||
testAddGetter(module, "exports", 290); | ||
testAddGetter(module, "xyz", new Object()); | ||
})(); | ||
|
||
(function TestAddGetterToInstance() { | ||
// print("TestAddGetterToInstance..."); | ||
var builder = makeBuilder(); | ||
var instance = builder.instantiate(); | ||
testAddGetter(instance, "exports", 290); | ||
testAddGetter(instance, "xyz", new Object()); | ||
})(); | ||
|
||
(function TestAddGetterToExports() { | ||
// print("TestAddGetterToExports..."); | ||
var builder = makeBuilder(); | ||
var exports = builder.instantiate().exports; | ||
testFailToAddGetter(exports, "f", 9834); | ||
testAddGetterFails(exports, "nag", new Number(2)); | ||
})(); |
Oops, something went wrong.