diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/cacheir/unaryarith-string.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/cacheir/unaryarith-string.js')
-rw-r--r-- | js/src/jit-test/tests/cacheir/unaryarith-string.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/unaryarith-string.js b/js/src/jit-test/tests/cacheir/unaryarith-string.js new file mode 100644 index 0000000000..853d8f7464 --- /dev/null +++ b/js/src/jit-test/tests/cacheir/unaryarith-string.js @@ -0,0 +1,58 @@ +setJitCompilerOption('ion.forceinlineCaches', 1); + +function warmup(fun, input_array, output_array) { + assertEq(output_array.length, input_array.length); + for (var index = 0; index < input_array.length; index++) { + input = input_array[index]; + output = output_array[index]; + for (var i = 0; i < 30; i++) { + var y = fun(input); + assertEq(y, output) + } + } +} + +// Unary - operator with transition between string representations of int32 and double. +var fun_neg_int32_double = (x) => { return -x; } +var fun_neg_double_int32 = (x) => { return -x; } + +// Unary ~ operator using string representations of either int32 or double. +var fun_bitnot_int32 = (x) => { return ~x; } +var fun_bitnot_double = (x) => { return ~x; } + +// Unary ++ operator using string representations of either int32 or double. +var fun_inc_int32 = (x) => { return ++x; } +var fun_inc_double = (x) => { return ++x; } + +// Unary -- operator using string representations of either int32 or double. +var fun_dec_int32 = (x) => { return --x; } +var fun_dec_double = (x) => { return --x; } + +// Unary + operator using string representations of either int32 or double. +var fun_pos_int32 = (x) => { return +x; } +var fun_pos_double = (x) => { return +x; } + +// JSOp::ToNumeric using string representations of either int32 or double. +var fun_tonumeric_int32 = (x) => { return x++; } +var fun_tonumeric_double = (x) => { return x++; } + +warmup(fun_neg_int32_double, ["1", "2", "-3"], [-1, -2, 3]); +warmup(fun_neg_double_int32, ["0"], [-0]); + +warmup(fun_neg_double_int32, ["3", "4", "-5"], [-3, -4, 5]); +warmup(fun_neg_int32_double, ["1.2", "1.4"], [-1.2, -1.4]); + +warmup(fun_bitnot_int32, ["-1", "0"], [0, -1]); +warmup(fun_bitnot_double, ["-1.0", "0.0", "1.2", "3"], [0, -1, -2, -4]); + +warmup(fun_inc_int32, ["-1", "0"], [0, 1]); +warmup(fun_inc_double, ["-1.0", "0.0", "1.2", "3"], [0, 1, 2.2, 4]); + +warmup(fun_dec_int32, ["-1", "0"], [-2, -1]); +warmup(fun_dec_double, ["-1.0", "0.0", "1.5", "3"], [-2, -1, 0.5, 2]); + +warmup(fun_pos_int32, ["-1", "0"], [-1, 0]); +warmup(fun_pos_double, ["-1.0", "0.0", "1.2", "3"], [-1.0, 0.0, 1.2, 3]); + +warmup(fun_tonumeric_int32, ["-1", "0"], [-1, 0]); +warmup(fun_tonumeric_double, ["-1.0", "0.0", "1.2", "3"], [-1.0, 0.0, 1.2, 3]); |