Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (194332 => 194333)
--- trunk/Source/_javascript_Core/ChangeLog 2015-12-21 18:20:58 UTC (rev 194332)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-12-21 18:40:10 UTC (rev 194333)
@@ -1,3 +1,33 @@
+2015-12-18 Mark Lam <[email protected]>
+
+ Add unary operator tests to compare JIT and LLINT results.
+ https://bugs.webkit.org/show_bug.cgi?id=152453
+
+ Reviewed by Benjamin Poulain.
+
+ Also fixed a few things in the binary-op-test.js.
+
+ * tests/stress/op_negate.js: Added.
+ (o1.valueOf):
+ * tests/stress/op_postdec.js: Added.
+ (o1.valueOf):
+ * tests/stress/op_postinc.js: Added.
+ (o1.valueOf):
+ * tests/stress/op_predec.js: Added.
+ (o1.valueOf):
+ * tests/stress/op_preinc.js: Added.
+ (o1.valueOf):
+ * tests/stress/resources/binary-op-test.js:
+ (stringifyIfNeeded):
+ (isIdentical):
+ (run):
+ * tests/stress/resources/unary-op-test.js: Added.
+ (stringifyIfNeeded):
+ (generateBinaryTests):
+ (isIdentical):
+ (runTest):
+ (run):
+
2015-12-21 Ryan Haddad <[email protected]>
Unreviewed, rolling out r194328.
Added: trunk/Source/_javascript_Core/tests/stress/op_negate.js (0 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/op_negate.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/op_negate.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -0,0 +1,75 @@
+//@ runFTLNoCJIT
+
+// If all goes well, this test module will terminate silently. If not, it will print
+// errors. See unary-op-test.js for debugging options if needed.
+
+load("./resources/unary-op-test.js");
+
+//============================================================================
+// Test configuration data:
+
+var opName = "negate";
+var op = "-";
+var operatorType = "Prefix";
+
+var o1 = {
+ valueOf: function() { return 10; }
+};
+
+var posInfinity = 1 / 0;
+var negInfinity = -1 / 0;
+
+var values = [
+ 'o1',
+ 'null',
+ 'undefined',
+ 'true',
+ 'false',
+
+ 'NaN',
+ 'posInfinity',
+ 'negInfinity',
+ '100.2', // Some random small double value.
+ '-100.2',
+ '54294967296.2923', // Some random large double value.
+ '-54294967296.2923',
+
+ '0',
+ '-0',
+ '1',
+ '-1',
+ '0x3fff',
+ '-0x3fff',
+ '0x7fff',
+ '-0x7fff',
+ '0x10000',
+ '-0x10000',
+ '0x7ffffff',
+ '-0x7ffffff',
+ '0x80000000',
+ '-0x80000000',
+ '0x100000000',
+ '-0x100000000',
+
+ '"abc"',
+ '"0"',
+ '"-0"',
+ '"1"',
+ '"-1"',
+ '"0x3fff"',
+ '"-0x3fff"',
+ '"0x7fff"',
+ '"-0x7fff"',
+ '"0x10000"',
+ '"-0x10000"',
+ '"0x7ffffff"',
+ '"-0x7ffffff"',
+ '"0x100000000"',
+ '"-0x100000000"',
+];
+
+tests = [];
+generateBinaryTests(tests, opName, operatorType, "ImmediateResult", op, values);
+generateBinaryTests(tests, opName, operatorType, "PostResult", op, values);
+
+run();
Added: trunk/Source/_javascript_Core/tests/stress/op_postdec.js (0 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/op_postdec.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/op_postdec.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -0,0 +1,75 @@
+//@ runFTLNoCJIT
+
+// If all goes well, this test module will terminate silently. If not, it will print
+// errors. See unary-op-test.js for debugging options if needed.
+
+load("./resources/unary-op-test.js");
+
+//============================================================================
+// Test configuration data:
+
+var opName = "postdec";
+var op = "--";
+var operatorType = "Postfix";
+
+var o1 = {
+ valueOf: function() { return 10; }
+};
+
+var posInfinity = 1 / 0;
+var negInfinity = -1 / 0;
+
+var values = [
+ 'o1',
+ 'null',
+ 'undefined',
+ 'true',
+ 'false',
+
+ 'NaN',
+ 'posInfinity',
+ 'negInfinity',
+ '100.2', // Some random small double value.
+ '-100.2',
+ '54294967296.2923', // Some random large double value.
+ '-54294967296.2923',
+
+ '0',
+ '-0',
+ '1',
+ '-1',
+ '0x3fff',
+ '-0x3fff',
+ '0x7fff',
+ '-0x7fff',
+ '0x10000',
+ '-0x10000',
+ '0x7ffffff',
+ '-0x7ffffff',
+ '0x80000000',
+ '-0x80000000',
+ '0x100000000',
+ '-0x100000000',
+
+ '"abc"',
+ '"0"',
+ '"-0"',
+ '"1"',
+ '"-1"',
+ '"0x3fff"',
+ '"-0x3fff"',
+ '"0x7fff"',
+ '"-0x7fff"',
+ '"0x10000"',
+ '"-0x10000"',
+ '"0x7ffffff"',
+ '"-0x7ffffff"',
+ '"0x100000000"',
+ '"-0x100000000"',
+];
+
+tests = [];
+generateBinaryTests(tests, opName, operatorType, "ImmediateResult", op, values);
+generateBinaryTests(tests, opName, operatorType, "PostResult", op, values);
+
+run();
Added: trunk/Source/_javascript_Core/tests/stress/op_postinc.js (0 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/op_postinc.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/op_postinc.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -0,0 +1,75 @@
+//@ runFTLNoCJIT
+
+// If all goes well, this test module will terminate silently. If not, it will print
+// errors. See unary-op-test.js for debugging options if needed.
+
+load("./resources/unary-op-test.js");
+
+//============================================================================
+// Test configuration data:
+
+var opName = "postinc";
+var op = "++";
+var operatorType = "Postfix";
+
+var o1 = {
+ valueOf: function() { return 10; }
+};
+
+var posInfinity = 1 / 0;
+var negInfinity = -1 / 0;
+
+var values = [
+ 'o1',
+ 'null',
+ 'undefined',
+ 'true',
+ 'false',
+
+ 'NaN',
+ 'posInfinity',
+ 'negInfinity',
+ '100.2', // Some random small double value.
+ '-100.2',
+ '54294967296.2923', // Some random large double value.
+ '-54294967296.2923',
+
+ '0',
+ '-0',
+ '1',
+ '-1',
+ '0x3fff',
+ '-0x3fff',
+ '0x7fff',
+ '-0x7fff',
+ '0x10000',
+ '-0x10000',
+ '0x7ffffff',
+ '-0x7ffffff',
+ '0x80000000',
+ '-0x80000000',
+ '0x100000000',
+ '-0x100000000',
+
+ '"abc"',
+ '"0"',
+ '"-0"',
+ '"1"',
+ '"-1"',
+ '"0x3fff"',
+ '"-0x3fff"',
+ '"0x7fff"',
+ '"-0x7fff"',
+ '"0x10000"',
+ '"-0x10000"',
+ '"0x7ffffff"',
+ '"-0x7ffffff"',
+ '"0x100000000"',
+ '"-0x100000000"',
+];
+
+tests = [];
+generateBinaryTests(tests, opName, operatorType, "ImmediateResult", op, values);
+generateBinaryTests(tests, opName, operatorType, "PostResult", op, values);
+
+run();
Added: trunk/Source/_javascript_Core/tests/stress/op_predec.js (0 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/op_predec.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/op_predec.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -0,0 +1,75 @@
+//@ runFTLNoCJIT
+
+// If all goes well, this test module will terminate silently. If not, it will print
+// errors. See unary-op-test.js for debugging options if needed.
+
+load("./resources/unary-op-test.js");
+
+//============================================================================
+// Test configuration data:
+
+var opName = "predec";
+var op = "--";
+var operatorType = "Prefix";
+
+var o1 = {
+ valueOf: function() { return 10; }
+};
+
+var posInfinity = 1 / 0;
+var negInfinity = -1 / 0;
+
+var values = [
+ 'o1',
+ 'null',
+ 'undefined',
+ 'true',
+ 'false',
+
+ 'NaN',
+ 'posInfinity',
+ 'negInfinity',
+ '100.2', // Some random small double value.
+ '-100.2',
+ '54294967296.2923', // Some random large double value.
+ '-54294967296.2923',
+
+ '0',
+ '-0',
+ '1',
+ '-1',
+ '0x3fff',
+ '-0x3fff',
+ '0x7fff',
+ '-0x7fff',
+ '0x10000',
+ '-0x10000',
+ '0x7ffffff',
+ '-0x7ffffff',
+ '0x80000000',
+ '-0x80000000',
+ '0x100000000',
+ '-0x100000000',
+
+ '"abc"',
+ '"0"',
+ '"-0"',
+ '"1"',
+ '"-1"',
+ '"0x3fff"',
+ '"-0x3fff"',
+ '"0x7fff"',
+ '"-0x7fff"',
+ '"0x10000"',
+ '"-0x10000"',
+ '"0x7ffffff"',
+ '"-0x7ffffff"',
+ '"0x100000000"',
+ '"-0x100000000"',
+];
+
+tests = [];
+generateBinaryTests(tests, opName, operatorType, "ImmediateResult", op, values);
+generateBinaryTests(tests, opName, operatorType, "PostResult", op, values);
+
+run();
Added: trunk/Source/_javascript_Core/tests/stress/op_preinc.js (0 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/op_preinc.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/op_preinc.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -0,0 +1,75 @@
+//@ runFTLNoCJIT
+
+// If all goes well, this test module will terminate silently. If not, it will print
+// errors. See unary-op-test.js for debugging options if needed.
+
+load("./resources/unary-op-test.js");
+
+//============================================================================
+// Test configuration data:
+
+var opName = "preinc";
+var op = "++";
+var operatorType = "Prefix";
+
+var o1 = {
+ valueOf: function() { return 10; }
+};
+
+var posInfinity = 1 / 0;
+var negInfinity = -1 / 0;
+
+var values = [
+ 'o1',
+ 'null',
+ 'undefined',
+ 'true',
+ 'false',
+
+ 'NaN',
+ 'posInfinity',
+ 'negInfinity',
+ '100.2', // Some random small double value.
+ '-100.2',
+ '54294967296.2923', // Some random large double value.
+ '-54294967296.2923',
+
+ '0',
+ '-0',
+ '1',
+ '-1',
+ '0x3fff',
+ '-0x3fff',
+ '0x7fff',
+ '-0x7fff',
+ '0x10000',
+ '-0x10000',
+ '0x7ffffff',
+ '-0x7ffffff',
+ '0x80000000',
+ '-0x80000000',
+ '0x100000000',
+ '-0x100000000',
+
+ '"abc"',
+ '"0"',
+ '"-0"',
+ '"1"',
+ '"-1"',
+ '"0x3fff"',
+ '"-0x3fff"',
+ '"0x7fff"',
+ '"-0x7fff"',
+ '"0x10000"',
+ '"-0x10000"',
+ '"0x7ffffff"',
+ '"-0x7ffffff"',
+ '"0x100000000"',
+ '"-0x100000000"',
+];
+
+tests = [];
+generateBinaryTests(tests, opName, operatorType, "ImmediateResult", op, values);
+generateBinaryTests(tests, opName, operatorType, "PostResult", op, values);
+
+run();
Modified: trunk/Source/_javascript_Core/tests/stress/resources/binary-op-test.js (194332 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/resources/binary-op-test.js 2015-12-21 18:20:58 UTC (rev 194332)
+++ trunk/Source/_javascript_Core/tests/stress/resources/binary-op-test.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -30,6 +30,8 @@
function stringifyIfNeeded(x) {
if (typeof x == "string")
return '"' + x + '"';
+ if (typeof x == "object")
+ return 'objWithVal:' + x;
return x;
}
@@ -76,6 +78,8 @@
var errorReport = "";
function isIdentical(x, y) {
+ if (typeof x == "undefined" && typeof y == "undefined")
+ return true;
if (typeof x != typeof y)
return false;
if (x == y) {
@@ -122,8 +126,6 @@
for (var test of tests)
runTest(test);
- // for (var i = 0; i < tests.length; i++)
- // runTest(tests[i]);
if (errorReport !== "")
throw "Found failures:\n" + errorReport;
Added: trunk/Source/_javascript_Core/tests/stress/resources/unary-op-test.js (0 => 194333)
--- trunk/Source/_javascript_Core/tests/stress/resources/unary-op-test.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/resources/unary-op-test.js 2015-12-21 18:40:10 UTC (rev 194333)
@@ -0,0 +1,134 @@
+// This test module provides infrastructure for generating and running tests on a unary
+// operator.
+//
+// It works by generating test functions to exercise the specified operator on operand
+// values in a provided set. For each test, it computes the expected result by exercising
+// the test function once (using the LLINT) at test generation time.
+// The test runner later compares the result produced by the function (as it tiers up)
+// against the expected result.
+//
+// The generated tests will exercise the operator on a variable.
+//
+// If all goes well, this test module will terminate silently. If not, it will print
+// errors.
+
+//============================================================================
+// Debugging options:
+
+var verbose = false;
+var abortOnFirstFail = false;
+var testFilterStr = undefined; // Define a filter string to filter tests to run.
+
+var verboseTestGeneration = false;
+
+//============================================================================
+// Test generation:
+
+function stringifyIfNeeded(x) {
+ if (typeof x == "string")
+ return '"' + x + '"';
+ if (typeof x == "object")
+ return 'objWithVal:' + x;
+ return x;
+}
+
+// operatorTypes can be "Prefix" or "Postfix".
+// resultTypes can be "ImmediateResult" or "PostResult". PostResult is mainly for
+// checking the value of a variable on subsequent inspection, so we can confirm that the
+// postfix operator did do its job.
+var funcIndex = 0;
+function generateBinaryTests(tests, opName, operatorType, resultType, op, inValues) {
+ var funcNamePrefix = opName + resultType;
+ for (var i = 0; i < inValues.length; i++) {
+ var test = { };
+ xStr = inValues[i];
+ test.x = eval(xStr);
+
+ var funcName = funcNamePrefix + funcIndex++;
+ if (operatorType == "Prefix") {
+ if (resultType == "ImmediateResult")
+ test.signature = funcName + "(x) { return " + op + "x }";
+ else if (resultType == "PostResult")
+ test.signature = funcName + "(x) { " + op + "x; return x; }";
+ } else if (operatorType == "Postfix") {
+ if (resultType == "ImmediateResult")
+ test.signature = funcName + "(x) { return x" + op + " }";
+ else if (resultType == "PostResult")
+ test.signature = funcName + "(x) { x" + op + "; return x; }";
+ }
+
+ test.name = test.signature + " with x:" + xStr;
+
+ test.func = eval("(function " + test.signature + ")");
+ noInline(test.func);
+
+ test.expectedResult = test.func(test.x);
+ test.name += ", expected:" + stringifyIfNeeded(test.expectedResult);
+
+ tests.push(test);
+ if (verboseTestGeneration)
+ print("Generated " + test.name);
+ }
+}
+
+//============================================================================
+// Test running and reporting:
+
+var errorReport = "";
+
+function isIdentical(x, y) {
+ if (typeof x == "undefined" && typeof y == "undefined")
+ return true;
+ if (typeof x != typeof y)
+ return false;
+ if (x == y) {
+ if (x)
+ return true;
+ // Distinguish between 0 and negative 0.
+ if (1 / x == 1 / y)
+ return true;
+ } else if (Number.isNaN(x) && Number.isNaN(y))
+ return true;
+ return false;
+}
+
+function runTest(test) {
+ if (testFilterStr && !test.name.includes(testFilterStr))
+ return;
+
+ var firstFailed = -1;
+ try {
+ if (verbose)
+ print(test.name);
+ for (var i = 0; i < 10000; i++) {
+ var result = test.func(test.x);
+ if (isIdentical(result, test.expectedResult))
+ continue;
+ if (firstFailed < 0) {
+ errorReport += "FAILED: " + test.name + " started failing on iteration " + i
+ + ": actual " + stringifyIfNeeded(result) + "\n";
+ if (abortOnFirstFail)
+ throw errorReport;
+ firstFailed = i;
+ }
+ }
+ } catch(e) {
+ if (abortOnFirstFail)
+ throw e; // Negate the catch by re-throwing.
+ errorReport += "FAILED: Unexpected exception: " + e + "\n";
+ }
+}
+
+function run() {
+ if (verbose)
+ print("Start testing");
+
+ for (var test of tests)
+ runTest(test);
+
+ if (errorReport !== "")
+ throw "Found failures:\n" + errorReport;
+
+ if (verbose)
+ print("Done testing");
+}