"" + x where x is not a string should be optimized by the DFG to some manner of ToStr...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 22:39:23 +0000 (22:39 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Mar 2013 22:39:23 +0000 (22:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112845

Reviewed by Mark Hahnenberg.

* fast/js/regress/empty-string-plus-int-expected.txt: Added.
* fast/js/regress/empty-string-plus-int.html: Added.
* fast/js/regress/script-tests/empty-string-plus-int.js: Added.
(foo):

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

LayoutTests/ChangeLog
LayoutTests/fast/js/regress/empty-string-plus-int-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/regress/empty-string-plus-int.html [new file with mode: 0644]
LayoutTests/fast/js/regress/script-tests/empty-string-plus-int.js [new file with mode: 0644]

index 70cccfa..47482f5 100644 (file)
@@ -1,3 +1,15 @@
+2013-03-20  Filip Pizlo  <fpizlo@apple.com>
+
+        "" + x where x is not a string should be optimized by the DFG to some manner of ToString conversion
+        https://bugs.webkit.org/show_bug.cgi?id=112845
+
+        Reviewed by Mark Hahnenberg.
+
+        * fast/js/regress/empty-string-plus-int-expected.txt: Added.
+        * fast/js/regress/empty-string-plus-int.html: Added.
+        * fast/js/regress/script-tests/empty-string-plus-int.js: Added.
+        (foo):
+
 2013-03-20  Tien-Ren Chen  <trchen@chromium.org>
 
         Correct coordinated scrolling for RTL iframe and overflow:scroll
diff --git a/LayoutTests/fast/js/regress/empty-string-plus-int-expected.txt b/LayoutTests/fast/js/regress/empty-string-plus-int-expected.txt
new file mode 100644 (file)
index 0000000..33ac272
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/empty-string-plus-int
+
+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/fast/js/regress/empty-string-plus-int.html b/LayoutTests/fast/js/regress/empty-string-plus-int.html
new file mode 100644 (file)
index 0000000..9a61953
--- /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/empty-string-plus-int.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/regress/script-tests/empty-string-plus-int.js b/LayoutTests/fast/js/regress/script-tests/empty-string-plus-int.js
new file mode 100644 (file)
index 0000000..af23b58
--- /dev/null
@@ -0,0 +1,11 @@
+function foo(x) {
+    return "" + x;
+}
+
+var result;
+var limit = 100000;
+for (var i = 0; i < limit; ++i)
+    result = foo(i);
+
+if (result != String(limit - 1))
+    throw "Error: bad result: " + result;