diff options
Diffstat (limited to 'js/src/jit-test/tests/TypedObject/jit-write-u16-into-u16-array.js')
-rw-r--r-- | js/src/jit-test/tests/TypedObject/jit-write-u16-into-u16-array.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/TypedObject/jit-write-u16-into-u16-array.js b/js/src/jit-test/tests/TypedObject/jit-write-u16-into-u16-array.js new file mode 100644 index 000000000..6c0fe0d78 --- /dev/null +++ b/js/src/jit-test/tests/TypedObject/jit-write-u16-into-u16-array.js @@ -0,0 +1,25 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +if (!this.hasOwnProperty("TypedObject")) + quit(); + +setJitCompilerOption("ion.warmup.trigger", 30); + +var Vec3u16Type = TypedObject.uint16.array(3); + +function foo_u16() { + for (var i = 0; i < 5000; i += 10) { + var vec = new Vec3u16Type(); + // making index non-trivially dependent on |i| to foil compiler optimization + vec[(i) % 3] = i; + vec[(i + 1) % 3] = i+1; + vec[(i + 2) % 3] = i+2; + var sum = vec[0] + vec[1] + vec[2]; + assertEq(sum, 3*i + 3); + } +} + +foo_u16(); |