-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1135039: Apply swizzle type policy changes in Ion too
- Loading branch information
Showing
5 changed files
with
106 additions
and
23 deletions.
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,71 @@ | ||
if (!this.hasOwnProperty("SIMD")) | ||
quit(); | ||
|
||
load(libdir + 'simd.js'); | ||
|
||
setJitCompilerOption("ion.warmup.trigger", 50); | ||
|
||
function f() { | ||
var i4 = SIMD.int32x4(1, 2, 3, 4); | ||
|
||
var leet = Math.fround(13.37); | ||
var f4 = SIMD.float32x4(-.5, -0, Infinity, leet); | ||
|
||
var compI = [ | ||
[1,2,3,4], | ||
[2,3,4,1], | ||
[3,4,1,2], | ||
[4,1,2,3] | ||
]; | ||
|
||
var compF = [ | ||
[-.5, -0, Infinity, leet], | ||
[-0, Infinity, leet, -.5], | ||
[Infinity, leet, -.5, -0], | ||
[leet, -.5, -0, Infinity] | ||
]; | ||
|
||
for (var i = 0; i < 150; i++) { | ||
// Variable lanes | ||
var r = SIMD.float32x4.swizzle(f4, i % 4, (i + 1) % 4, (i + 2) % 4, (i + 3) % 4); | ||
assertEqX4(r, compF[i % 4]); | ||
|
||
// Constant lanes | ||
assertEqX4(SIMD.float32x4.swizzle(f4, 3, 2, 1, 0), [leet, Infinity, -0, -.5]); | ||
|
||
// Variable lanes | ||
var r = SIMD.int32x4.swizzle(i4, i % 4, (i + 1) % 4, (i + 2) % 4, (i + 3) % 4); | ||
assertEqX4(r, compI[i % 4]); | ||
|
||
// Constant lanes | ||
assertEqX4(SIMD.int32x4.swizzle(i4, 3, 2, 1, 0), [4, 3, 2, 1]); | ||
} | ||
} | ||
|
||
function testBailouts(uglyDuckling) { | ||
var i4 = SIMD.int32x4(1, 2, 3, 4); | ||
for (var i = 0; i < 150; i++) { | ||
// Test bailouts | ||
var value = i == 149 ? uglyDuckling : 0; | ||
var caught = false; | ||
try { | ||
assertEqX4(SIMD.int32x4.swizzle(i4, value, 3, 2, 0), [1, 4, 3, 1]); | ||
} catch(e) { | ||
print(e); | ||
caught = true; | ||
assertEq(i, 149); | ||
assertEq(e instanceof TypeError, true); | ||
} | ||
assertEq(i < 149 || caught, true); | ||
} | ||
} | ||
|
||
f(); | ||
testBailouts(-1); | ||
testBailouts(4); | ||
testBailouts(2.5); | ||
testBailouts(undefined); | ||
testBailouts(null); | ||
testBailouts({}); | ||
testBailouts('one'); | ||
testBailouts(true); |
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
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
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
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