DFG Is<Blah> versions of TypeOf should fold based on proven input type
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 17:36:26 +0000 (17:36 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 17:36:26 +0000 (17:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144409

Reviewed by Geoffrey Garen.
Source/JavaScriptCore:

We were missing some obvious folding opportunities here. I don't know how this affects real
code, but in general, we like to ensure that our constant folding is comprehensive. So this
is more about placating my static analysis OCD than anything else.

I added a bunch of speed/correctness tests for this in LayoutTests/js/regress.

* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

LayoutTests:

* js/regress/is-boolean-fold-expected.txt: Added.
* js/regress/is-boolean-fold-tricky-expected.txt: Added.
* js/regress/is-boolean-fold-tricky.html: Added.
* js/regress/is-boolean-fold.html: Added.
* js/regress/is-function-fold-expected.txt: Added.
* js/regress/is-function-fold-tricky-expected.txt: Added.
* js/regress/is-function-fold-tricky-internal-function-expected.txt: Added.
* js/regress/is-function-fold-tricky-internal-function.html: Added.
* js/regress/is-function-fold-tricky.html: Added.
* js/regress/is-function-fold.html: Added.
* js/regress/is-number-fold-expected.txt: Added.
* js/regress/is-number-fold-tricky-expected.txt: Added.
* js/regress/is-number-fold-tricky.html: Added.
* js/regress/is-number-fold.html: Added.
* js/regress/is-object-or-null-fold-expected.txt: Added.
* js/regress/is-object-or-null-fold-functions-expected.txt: Added.
* js/regress/is-object-or-null-fold-functions.html: Added.
* js/regress/is-object-or-null-fold-less-tricky-expected.txt: Added.
* js/regress/is-object-or-null-fold-less-tricky.html: Added.
* js/regress/is-object-or-null-fold-tricky-expected.txt: Added.
* js/regress/is-object-or-null-fold-tricky.html: Added.
* js/regress/is-object-or-null-fold.html: Added.
* js/regress/is-object-or-null-trickier-function-expected.txt: Added.
* js/regress/is-object-or-null-trickier-function.html: Added.
* js/regress/is-object-or-null-trickier-internal-function-expected.txt: Added.
* js/regress/is-object-or-null-trickier-internal-function.html: Added.
* js/regress/is-object-or-null-tricky-function-expected.txt: Added.
* js/regress/is-object-or-null-tricky-function.html: Added.
* js/regress/is-object-or-null-tricky-internal-function-expected.txt: Added.
* js/regress/is-object-or-null-tricky-internal-function.html: Added.
* js/regress/is-string-fold-expected.txt: Added.
* js/regress/is-string-fold-tricky-expected.txt: Added.
* js/regress/is-string-fold-tricky.html: Added.
* js/regress/is-string-fold.html: Added.
* js/regress/is-undefined-fold-expected.txt: Added.
* js/regress/is-undefined-fold-tricky-expected.txt: Added.
* js/regress/is-undefined-fold-tricky.html: Added.
* js/regress/is-undefined-fold.html: Added.
* js/regress/script-tests/is-boolean-fold-tricky.js: Added.
* js/regress/script-tests/is-boolean-fold.js: Added.
* js/regress/script-tests/is-function-fold-tricky-internal-function.js: Added.
* js/regress/script-tests/is-function-fold-tricky.js: Added.
(func):
(func2):
* js/regress/script-tests/is-function-fold.js: Added.
(value1):
* js/regress/script-tests/is-number-fold-tricky.js: Added.
* js/regress/script-tests/is-number-fold.js: Added.
* js/regress/script-tests/is-object-or-null-fold-functions.js: Added.
(value2):
* js/regress/script-tests/is-object-or-null-fold-less-tricky.js: Added.
* js/regress/script-tests/is-object-or-null-fold-tricky.js: Added.
* js/regress/script-tests/is-object-or-null-fold.js: Added.
* js/regress/script-tests/is-object-or-null-trickier-function.js: Added.
(func):
(func2):
* js/regress/script-tests/is-object-or-null-trickier-internal-function.js: Added.
* js/regress/script-tests/is-object-or-null-tricky-function.js: Added.
(func):
* js/regress/script-tests/is-object-or-null-tricky-internal-function.js: Added.
* js/regress/script-tests/is-string-fold-tricky.js: Added.
* js/regress/script-tests/is-string-fold.js: Added.
* js/regress/script-tests/is-undefined-fold-tricky.js: Added.
* js/regress/script-tests/is-undefined-fold.js: Added.
* js/regress/sink-function-expected.txt: Added.
* js/regress/sink-function.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183629 268f45cc-cd09-0410-ab3c-d52691b4dbfc

62 files changed:
LayoutTests/ChangeLog
LayoutTests/js/regress/is-boolean-fold-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-boolean-fold-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-boolean-fold-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-boolean-fold.html [new file with mode: 0644]
LayoutTests/js/regress/is-function-fold-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-function-fold-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-function-fold-tricky-internal-function-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-function-fold-tricky-internal-function.html [new file with mode: 0644]
LayoutTests/js/regress/is-function-fold-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-function-fold.html [new file with mode: 0644]
LayoutTests/js/regress/is-number-fold-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-number-fold-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-number-fold-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-number-fold.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-functions-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-functions.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-less-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-less-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-fold.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-trickier-function-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-trickier-function.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-trickier-internal-function-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-trickier-internal-function.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-tricky-function-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-tricky-function.html [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-tricky-internal-function-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-object-or-null-tricky-internal-function.html [new file with mode: 0644]
LayoutTests/js/regress/is-string-fold-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-string-fold-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-string-fold-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-string-fold.html [new file with mode: 0644]
LayoutTests/js/regress/is-undefined-fold-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-undefined-fold-tricky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/is-undefined-fold-tricky.html [new file with mode: 0644]
LayoutTests/js/regress/is-undefined-fold.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-boolean-fold-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-boolean-fold.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-function-fold-tricky-internal-function.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-function-fold-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-function-fold.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-number-fold-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-number-fold.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-fold-functions.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-fold-less-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-fold-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-fold.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-trickier-function.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-trickier-internal-function.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-tricky-function.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-object-or-null-tricky-internal-function.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-string-fold-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-string-fold.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-undefined-fold-tricky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/is-undefined-fold.js [new file with mode: 0644]
LayoutTests/js/regress/sink-function-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/sink-function.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

index 4327fec..826ec4b 100644 (file)
@@ -1,3 +1,77 @@
+2015-04-29  Filip Pizlo  <fpizlo@apple.com>
+
+        DFG Is<Blah> versions of TypeOf should fold based on proven input type
+        https://bugs.webkit.org/show_bug.cgi?id=144409
+
+        Reviewed by Geoffrey Garen.
+
+        * js/regress/is-boolean-fold-expected.txt: Added.
+        * js/regress/is-boolean-fold-tricky-expected.txt: Added.
+        * js/regress/is-boolean-fold-tricky.html: Added.
+        * js/regress/is-boolean-fold.html: Added.
+        * js/regress/is-function-fold-expected.txt: Added.
+        * js/regress/is-function-fold-tricky-expected.txt: Added.
+        * js/regress/is-function-fold-tricky-internal-function-expected.txt: Added.
+        * js/regress/is-function-fold-tricky-internal-function.html: Added.
+        * js/regress/is-function-fold-tricky.html: Added.
+        * js/regress/is-function-fold.html: Added.
+        * js/regress/is-number-fold-expected.txt: Added.
+        * js/regress/is-number-fold-tricky-expected.txt: Added.
+        * js/regress/is-number-fold-tricky.html: Added.
+        * js/regress/is-number-fold.html: Added.
+        * js/regress/is-object-or-null-fold-expected.txt: Added.
+        * js/regress/is-object-or-null-fold-functions-expected.txt: Added.
+        * js/regress/is-object-or-null-fold-functions.html: Added.
+        * js/regress/is-object-or-null-fold-less-tricky-expected.txt: Added.
+        * js/regress/is-object-or-null-fold-less-tricky.html: Added.
+        * js/regress/is-object-or-null-fold-tricky-expected.txt: Added.
+        * js/regress/is-object-or-null-fold-tricky.html: Added.
+        * js/regress/is-object-or-null-fold.html: Added.
+        * js/regress/is-object-or-null-trickier-function-expected.txt: Added.
+        * js/regress/is-object-or-null-trickier-function.html: Added.
+        * js/regress/is-object-or-null-trickier-internal-function-expected.txt: Added.
+        * js/regress/is-object-or-null-trickier-internal-function.html: Added.
+        * js/regress/is-object-or-null-tricky-function-expected.txt: Added.
+        * js/regress/is-object-or-null-tricky-function.html: Added.
+        * js/regress/is-object-or-null-tricky-internal-function-expected.txt: Added.
+        * js/regress/is-object-or-null-tricky-internal-function.html: Added.
+        * js/regress/is-string-fold-expected.txt: Added.
+        * js/regress/is-string-fold-tricky-expected.txt: Added.
+        * js/regress/is-string-fold-tricky.html: Added.
+        * js/regress/is-string-fold.html: Added.
+        * js/regress/is-undefined-fold-expected.txt: Added.
+        * js/regress/is-undefined-fold-tricky-expected.txt: Added.
+        * js/regress/is-undefined-fold-tricky.html: Added.
+        * js/regress/is-undefined-fold.html: Added.
+        * js/regress/script-tests/is-boolean-fold-tricky.js: Added.
+        * js/regress/script-tests/is-boolean-fold.js: Added.
+        * js/regress/script-tests/is-function-fold-tricky-internal-function.js: Added.
+        * js/regress/script-tests/is-function-fold-tricky.js: Added.
+        (func):
+        (func2):
+        * js/regress/script-tests/is-function-fold.js: Added.
+        (value1):
+        * js/regress/script-tests/is-number-fold-tricky.js: Added.
+        * js/regress/script-tests/is-number-fold.js: Added.
+        * js/regress/script-tests/is-object-or-null-fold-functions.js: Added.
+        (value2):
+        * js/regress/script-tests/is-object-or-null-fold-less-tricky.js: Added.
+        * js/regress/script-tests/is-object-or-null-fold-tricky.js: Added.
+        * js/regress/script-tests/is-object-or-null-fold.js: Added.
+        * js/regress/script-tests/is-object-or-null-trickier-function.js: Added.
+        (func):
+        (func2):
+        * js/regress/script-tests/is-object-or-null-trickier-internal-function.js: Added.
+        * js/regress/script-tests/is-object-or-null-tricky-function.js: Added.
+        (func):
+        * js/regress/script-tests/is-object-or-null-tricky-internal-function.js: Added.
+        * js/regress/script-tests/is-string-fold-tricky.js: Added.
+        * js/regress/script-tests/is-string-fold.js: Added.
+        * js/regress/script-tests/is-undefined-fold-tricky.js: Added.
+        * js/regress/script-tests/is-undefined-fold.js: Added.
+        * js/regress/sink-function-expected.txt: Added.
+        * js/regress/sink-function.html: Added.
+
 2015-04-30  Brent Fulgham  <bfulgham@apple.com>
 
         [Mac] Expand test infrastructure to support scrolling tests (Part 3)
diff --git a/LayoutTests/js/regress/is-boolean-fold-expected.txt b/LayoutTests/js/regress/is-boolean-fold-expected.txt
new file mode 100644 (file)
index 0000000..d93fe4d
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-boolean-fold
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-boolean-fold-tricky-expected.txt b/LayoutTests/js/regress/is-boolean-fold-tricky-expected.txt
new file mode 100644 (file)
index 0000000..b141c44
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-boolean-fold-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-boolean-fold-tricky.html b/LayoutTests/js/regress/is-boolean-fold-tricky.html
new file mode 100644 (file)
index 0000000..34ddd60
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-boolean-fold-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-boolean-fold.html b/LayoutTests/js/regress/is-boolean-fold.html
new file mode 100644 (file)
index 0000000..e722dde
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-boolean-fold.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-function-fold-expected.txt b/LayoutTests/js/regress/is-function-fold-expected.txt
new file mode 100644 (file)
index 0000000..9cd1ec2
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-function-fold
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-function-fold-tricky-expected.txt b/LayoutTests/js/regress/is-function-fold-tricky-expected.txt
new file mode 100644 (file)
index 0000000..4403c83
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-function-fold-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-function-fold-tricky-internal-function-expected.txt b/LayoutTests/js/regress/is-function-fold-tricky-internal-function-expected.txt
new file mode 100644 (file)
index 0000000..559653b
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-function-fold-tricky-internal-function
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-function-fold-tricky-internal-function.html b/LayoutTests/js/regress/is-function-fold-tricky-internal-function.html
new file mode 100644 (file)
index 0000000..18f86b7
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-function-fold-tricky-internal-function.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-function-fold-tricky.html b/LayoutTests/js/regress/is-function-fold-tricky.html
new file mode 100644 (file)
index 0000000..ece2a3f
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-function-fold-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-function-fold.html b/LayoutTests/js/regress/is-function-fold.html
new file mode 100644 (file)
index 0000000..3d4ce5e
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-function-fold.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-number-fold-expected.txt b/LayoutTests/js/regress/is-number-fold-expected.txt
new file mode 100644 (file)
index 0000000..3d519aa
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-number-fold
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-number-fold-tricky-expected.txt b/LayoutTests/js/regress/is-number-fold-tricky-expected.txt
new file mode 100644 (file)
index 0000000..7c84422
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-number-fold-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-number-fold-tricky.html b/LayoutTests/js/regress/is-number-fold-tricky.html
new file mode 100644 (file)
index 0000000..d6c2413
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-number-fold-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-number-fold.html b/LayoutTests/js/regress/is-number-fold.html
new file mode 100644 (file)
index 0000000..ef18dee
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-number-fold.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-expected.txt b/LayoutTests/js/regress/is-object-or-null-fold-expected.txt
new file mode 100644 (file)
index 0000000..ecf7560
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-fold
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-functions-expected.txt b/LayoutTests/js/regress/is-object-or-null-fold-functions-expected.txt
new file mode 100644 (file)
index 0000000..b4ab550
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-fold-functions
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-functions.html b/LayoutTests/js/regress/is-object-or-null-fold-functions.html
new file mode 100644 (file)
index 0000000..e0cb44e
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-fold-functions.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-less-tricky-expected.txt b/LayoutTests/js/regress/is-object-or-null-fold-less-tricky-expected.txt
new file mode 100644 (file)
index 0000000..d6ea65f
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-fold-less-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-less-tricky.html b/LayoutTests/js/regress/is-object-or-null-fold-less-tricky.html
new file mode 100644 (file)
index 0000000..f345055
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-fold-less-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-tricky-expected.txt b/LayoutTests/js/regress/is-object-or-null-fold-tricky-expected.txt
new file mode 100644 (file)
index 0000000..824e591
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-fold-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-fold-tricky.html b/LayoutTests/js/regress/is-object-or-null-fold-tricky.html
new file mode 100644 (file)
index 0000000..d9c3c21
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-fold-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-fold.html b/LayoutTests/js/regress/is-object-or-null-fold.html
new file mode 100644 (file)
index 0000000..cff5141
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-fold.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-trickier-function-expected.txt b/LayoutTests/js/regress/is-object-or-null-trickier-function-expected.txt
new file mode 100644 (file)
index 0000000..ab82ca6
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-trickier-function
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-trickier-function.html b/LayoutTests/js/regress/is-object-or-null-trickier-function.html
new file mode 100644 (file)
index 0000000..b9da618
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-trickier-function.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-trickier-internal-function-expected.txt b/LayoutTests/js/regress/is-object-or-null-trickier-internal-function-expected.txt
new file mode 100644 (file)
index 0000000..5bf8a11
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-trickier-internal-function
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-trickier-internal-function.html b/LayoutTests/js/regress/is-object-or-null-trickier-internal-function.html
new file mode 100644 (file)
index 0000000..280e059
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-trickier-internal-function.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-tricky-function-expected.txt b/LayoutTests/js/regress/is-object-or-null-tricky-function-expected.txt
new file mode 100644 (file)
index 0000000..ceea693
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-tricky-function
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-tricky-function.html b/LayoutTests/js/regress/is-object-or-null-tricky-function.html
new file mode 100644 (file)
index 0000000..13a60b2
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-tricky-function.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-object-or-null-tricky-internal-function-expected.txt b/LayoutTests/js/regress/is-object-or-null-tricky-internal-function-expected.txt
new file mode 100644 (file)
index 0000000..eb9bac6
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-object-or-null-tricky-internal-function
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-object-or-null-tricky-internal-function.html b/LayoutTests/js/regress/is-object-or-null-tricky-internal-function.html
new file mode 100644 (file)
index 0000000..253ea71
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-object-or-null-tricky-internal-function.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-string-fold-expected.txt b/LayoutTests/js/regress/is-string-fold-expected.txt
new file mode 100644 (file)
index 0000000..38ef9ae
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-string-fold
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-string-fold-tricky-expected.txt b/LayoutTests/js/regress/is-string-fold-tricky-expected.txt
new file mode 100644 (file)
index 0000000..4b30955
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-string-fold-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-string-fold-tricky.html b/LayoutTests/js/regress/is-string-fold-tricky.html
new file mode 100644 (file)
index 0000000..b24d14a
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-string-fold-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-string-fold.html b/LayoutTests/js/regress/is-string-fold.html
new file mode 100644 (file)
index 0000000..6763fd7
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-string-fold.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-undefined-fold-expected.txt b/LayoutTests/js/regress/is-undefined-fold-expected.txt
new file mode 100644 (file)
index 0000000..8d3c1c4
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-undefined-fold
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-undefined-fold-tricky-expected.txt b/LayoutTests/js/regress/is-undefined-fold-tricky-expected.txt
new file mode 100644 (file)
index 0000000..1fa9fc3
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/is-undefined-fold-tricky
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/is-undefined-fold-tricky.html b/LayoutTests/js/regress/is-undefined-fold-tricky.html
new file mode 100644 (file)
index 0000000..a5ef6a2
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-undefined-fold-tricky.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/is-undefined-fold.html b/LayoutTests/js/regress/is-undefined-fold.html
new file mode 100644 (file)
index 0000000..abb5639
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/is-undefined-fold.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/script-tests/is-boolean-fold-tricky.js b/LayoutTests/js/regress/script-tests/is-boolean-fold-tricky.js
new file mode 100644 (file)
index 0000000..29eaea6
--- /dev/null
@@ -0,0 +1,12 @@
+var object = {};
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? true : false;
+        var value2 = (i & 1) ? "hello" : object;
+        result += (typeof value1 == "boolean");
+        result += (typeof value2 == "boolean") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-boolean-fold.js b/LayoutTests/js/regress/script-tests/is-boolean-fold.js
new file mode 100644 (file)
index 0000000..c011b5d
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = true;
+var value2 = "hello";
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "boolean");
+        result += (typeof value2 == "boolean") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-function-fold-tricky-internal-function.js b/LayoutTests/js/regress/script-tests/is-function-fold-tricky-internal-function.js
new file mode 100644 (file)
index 0000000..d8937d0
--- /dev/null
@@ -0,0 +1,12 @@
+var object = {};
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? Map : Set;
+        var value2 = (i & 1) ? object : "hello";
+        result += (typeof value1 == "function");
+        result += (typeof value2 == "function") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-function-fold-tricky.js b/LayoutTests/js/regress/script-tests/is-function-fold-tricky.js
new file mode 100644 (file)
index 0000000..054ffb4
--- /dev/null
@@ -0,0 +1,14 @@
+var object = {};
+var func = function() { };
+var func2 = function() { return 42; };
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? func : func2;
+        var value2 = (i & 1) ? object : "hello";
+        result += (typeof value1 == "function");
+        result += (typeof value2 == "function") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-function-fold.js b/LayoutTests/js/regress/script-tests/is-function-fold.js
new file mode 100644 (file)
index 0000000..c9b455c
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = function() { };
+var value2 = 42;
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "function");
+        result += (typeof value2 == "function") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-number-fold-tricky.js b/LayoutTests/js/regress/script-tests/is-number-fold-tricky.js
new file mode 100644 (file)
index 0000000..7171ed4
--- /dev/null
@@ -0,0 +1,12 @@
+var object = {};
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? 42.5 : 42;
+        var value2 = (i & 1) ? "hello" : object;
+        result += (typeof value1 == "number");
+        result += (typeof value2 == "number") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-number-fold.js b/LayoutTests/js/regress/script-tests/is-number-fold.js
new file mode 100644 (file)
index 0000000..a286d0d
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = 42;
+var value2 = "hello";
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "number");
+        result += (typeof value2 == "number") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-fold-functions.js b/LayoutTests/js/regress/script-tests/is-object-or-null-fold-functions.js
new file mode 100644 (file)
index 0000000..58d718f
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = {};
+var value2 = function() { };
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-fold-less-tricky.js b/LayoutTests/js/regress/script-tests/is-object-or-null-fold-less-tricky.js
new file mode 100644 (file)
index 0000000..75d62c8
--- /dev/null
@@ -0,0 +1,13 @@
+var object = {};
+var array = [];
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? array : object;
+        var value2 = (i & 1) ? 42 : "hello";
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-fold-tricky.js b/LayoutTests/js/regress/script-tests/is-object-or-null-fold-tricky.js
new file mode 100644 (file)
index 0000000..9bb87fd
--- /dev/null
@@ -0,0 +1,12 @@
+var object = {};
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? null : object;
+        var value2 = (i & 1) ? 42 : "hello";
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-fold.js b/LayoutTests/js/regress/script-tests/is-object-or-null-fold.js
new file mode 100644 (file)
index 0000000..c84fab2
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = {};
+var value2 = 42;
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-trickier-function.js b/LayoutTests/js/regress/script-tests/is-object-or-null-trickier-function.js
new file mode 100644 (file)
index 0000000..1b4735d
--- /dev/null
@@ -0,0 +1,15 @@
+var object = {};
+var array = [];
+var func = function() { };
+var func2 = function() { return 32; };
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? array : object;
+        var value2 = (i & 1) ? func : func2;
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-trickier-internal-function.js b/LayoutTests/js/regress/script-tests/is-object-or-null-trickier-internal-function.js
new file mode 100644 (file)
index 0000000..36e5a29
--- /dev/null
@@ -0,0 +1,13 @@
+var object = {};
+var array = [];
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? array : object;
+        var value2 = (i & 1) ? Map : Set;
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-tricky-function.js b/LayoutTests/js/regress/script-tests/is-object-or-null-tricky-function.js
new file mode 100644 (file)
index 0000000..adc465a
--- /dev/null
@@ -0,0 +1,14 @@
+var object = {};
+var array = [];
+var func = function() { };
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? array : object;
+        var value2 = (i & 1) ? func : "hello";
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-object-or-null-tricky-internal-function.js b/LayoutTests/js/regress/script-tests/is-object-or-null-tricky-internal-function.js
new file mode 100644 (file)
index 0000000..d80cc94
--- /dev/null
@@ -0,0 +1,13 @@
+var object = {};
+var array = [];
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? array : object;
+        var value2 = (i & 1) ? Map : "hello";
+        result += (typeof value1 == "object");
+        result += (typeof value2 == "object") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-string-fold-tricky.js b/LayoutTests/js/regress/script-tests/is-string-fold-tricky.js
new file mode 100644 (file)
index 0000000..579198e
--- /dev/null
@@ -0,0 +1,12 @@
+var object = {};
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = (i & 1) ? "hello" : "world";
+        var value2 = (i & 1) ? 42 : object;
+        result += (typeof value1 == "string");
+        result += (typeof value2 == "string") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-string-fold.js b/LayoutTests/js/regress/script-tests/is-string-fold.js
new file mode 100644 (file)
index 0000000..7e996c0
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = "hello";
+var value2 = 42;
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "string");
+        result += (typeof value2 == "string") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-undefined-fold-tricky.js b/LayoutTests/js/regress/script-tests/is-undefined-fold-tricky.js
new file mode 100644 (file)
index 0000000..db3dc65
--- /dev/null
@@ -0,0 +1,12 @@
+var object = {};
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        var value1 = void 0;
+        var value2 = (i & 1) ? "hello" : object;
+        result += (typeof value1 == "undefined");
+        result += (typeof value2 == "undefined") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/script-tests/is-undefined-fold.js b/LayoutTests/js/regress/script-tests/is-undefined-fold.js
new file mode 100644 (file)
index 0000000..ae31f69
--- /dev/null
@@ -0,0 +1,11 @@
+var value1 = void 0;
+var value2 = "hello";
+(function() {
+    var result = 0;
+    for (var i = 0; i < 1000000; ++i) {
+        result += (typeof value1 == "undefined");
+        result += (typeof value2 == "undefined") << 1;
+    }
+    if (result != 1000000)
+        throw "Error: bad result: " + result;
+})();
diff --git a/LayoutTests/js/regress/sink-function-expected.txt b/LayoutTests/js/regress/sink-function-expected.txt
new file mode 100644 (file)
index 0000000..c6e944c
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/sink-function
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/sink-function.html b/LayoutTests/js/regress/sink-function.html
new file mode 100644 (file)
index 0000000..21a53ae
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/sink-function.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 2163ad0..6b4b496 100644 (file)
@@ -1,3 +1,19 @@
+2015-04-29  Filip Pizlo  <fpizlo@apple.com>
+
+        DFG Is<Blah> versions of TypeOf should fold based on proven input type
+        https://bugs.webkit.org/show_bug.cgi?id=144409
+
+        Reviewed by Geoffrey Garen.
+        
+        We were missing some obvious folding opportunities here. I don't know how this affects real
+        code, but in general, we like to ensure that our constant folding is comprehensive. So this
+        is more about placating my static analysis OCD than anything else.
+        
+        I added a bunch of speed/correctness tests for this in LayoutTests/js/regress.
+
+        * dfg/DFGAbstractInterpreterInlines.h:
+        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
+
 2015-04-30  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Use the default hash value for Symbolized StringImpl
index 22f9ccc..690b28f 100644 (file)
@@ -834,34 +834,57 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
     case IsObject:
     case IsObjectOrNull:
     case IsFunction: {
-        JSValue child = forNode(node->child1()).value();
-        if (child) {
+        AbstractValue child = forNode(node->child1());
+        if (child.value()) {
             bool constantWasSet = true;
             switch (node->op()) {
             case IsUndefined:
                 setConstant(node, jsBoolean(
-                    child.isCell()
-                    ? child.asCell()->structure()->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))
-                    : child.isUndefined()));
+                    child.value().isCell()
+                    ? child.value().asCell()->structure()->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))
+                    : child.value().isUndefined()));
                 break;
             case IsBoolean:
-                setConstant(node, jsBoolean(child.isBoolean()));
+                setConstant(node, jsBoolean(child.value().isBoolean()));
                 break;
             case IsNumber:
-                setConstant(node, jsBoolean(child.isNumber()));
+                setConstant(node, jsBoolean(child.value().isNumber()));
                 break;
             case IsString:
-                setConstant(node, jsBoolean(isJSString(child)));
+                setConstant(node, jsBoolean(isJSString(child.value())));
                 break;
             case IsObject:
-                setConstant(node, jsBoolean(child.isObject()));
+                setConstant(node, jsBoolean(child.value().isObject()));
                 break;
             case IsObjectOrNull:
-                if (child.isNull() || !child.isObject()) {
-                    setConstant(node, jsBoolean(child.isNull()));
-                    break;
-                }
-                constantWasSet = false;
+                if (child.value().isObject()) {
+                    JSObject* object = asObject(child.value());
+                    if (object->type() == JSFunctionType)
+                        setConstant(node, jsBoolean(false));
+                    else if (!(object->inlineTypeFlags() & TypeOfShouldCallGetCallData))
+                        setConstant(node, jsBoolean(!child.value().asCell()->structure()->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))));
+                    else {
+                        // FIXME: This could just call getCallData.
+                        // https://bugs.webkit.org/show_bug.cgi?id=144457
+                        constantWasSet = false;
+                    }
+                } else
+                    setConstant(node, jsBoolean(child.value().isNull()));
+                break;
+            case IsFunction:
+                if (child.value().isObject()) {
+                    JSObject* object = asObject(child.value());
+                    if (object->type() == JSFunctionType)
+                        setConstant(node, jsBoolean(true));
+                    else if (!(object->inlineTypeFlags() & TypeOfShouldCallGetCallData))
+                        setConstant(node, jsBoolean(false));
+                    else {
+                        // FIXME: This could just call getCallData.
+                        // https://bugs.webkit.org/show_bug.cgi?id=144457
+                        constantWasSet = false;
+                    }
+                } else
+                    setConstant(node, jsBoolean(false));
                 break;
             default:
                 constantWasSet = false;
@@ -870,7 +893,112 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
             if (constantWasSet)
                 break;
         }
-
+        
+        bool constantWasSet = false;
+        switch (node->op()) {
+        case IsUndefined:
+            // FIXME: Use the masquerades-as-undefined watchpoint thingy.
+            // https://bugs.webkit.org/show_bug.cgi?id=144456
+            
+            if (!(child.m_type & (SpecOther | SpecObjectOther))) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            
+            break;
+        case IsBoolean:
+            if (!(child.m_type & ~SpecBoolean)) {
+                setConstant(node, jsBoolean(true));
+                constantWasSet = true;
+                break;
+            }
+            
+            if (!(child.m_type & SpecBoolean)) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            
+            break;
+        case IsNumber:
+            if (!(child.m_type & ~SpecFullNumber)) {
+                setConstant(node, jsBoolean(true));
+                constantWasSet = true;
+                break;
+            }
+            
+            if (!(child.m_type & SpecFullNumber)) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            
+            break;
+        case IsString:
+            if (!(child.m_type & ~SpecString)) {
+                setConstant(node, jsBoolean(true));
+                constantWasSet = true;
+                break;
+            }
+            
+            if (!(child.m_type & SpecString)) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            
+            break;
+        case IsObject:
+            if (!(child.m_type & ~SpecObject)) {
+                setConstant(node, jsBoolean(true));
+                constantWasSet = true;
+                break;
+            }
+            
+            if (!(child.m_type & SpecObject)) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            
+            break;
+        case IsObjectOrNull:
+            // FIXME: Use the masquerades-as-undefined watchpoint thingy.
+            // https://bugs.webkit.org/show_bug.cgi?id=144456
+            
+            if (!(child.m_type & ~(SpecObject - SpecObjectOther - SpecFunction))) {
+                setConstant(node, jsBoolean(true));
+                constantWasSet = true;
+                break;
+            }
+            
+            if (!(child.m_type & (SpecObject - SpecFunction))) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            
+            break;
+        case IsFunction:
+            if (!(child.m_type & ~SpecFunction)) {
+                setConstant(node, jsBoolean(true));
+                constantWasSet = true;
+                break;
+            }
+            
+            if (!(child.m_type & (SpecFunction | SpecObjectOther))) {
+                setConstant(node, jsBoolean(false));
+                constantWasSet = true;
+                break;
+            }
+            break;
+        default:
+            break;
+        }
+        if (constantWasSet)
+            break;
+        
         forNode(node).setType(SpecBoolean);
         break;
     }
@@ -894,8 +1022,10 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
             setConstant(node, *m_graph.freeze(vm->smallStrings.stringString()));
             break;
         }
-        
-        if (isFinalObjectSpeculation(abstractChild.m_type) || isArraySpeculation(abstractChild.m_type) || isDirectArgumentsSpeculation(abstractChild.m_type) || isScopedArgumentsSpeculation(abstractChild.m_type)) {
+
+        // FIXME: We could use the masquerades-as-undefined watchpoint here.
+        // https://bugs.webkit.org/show_bug.cgi?id=144456
+        if (!(abstractChild.m_type & ~(SpecObject - SpecObjectOther))) {
             setConstant(node, *m_graph.freeze(vm->smallStrings.objectString()));
             break;
         }