Reviewers: Michael Starzinger,

Description:
Fix minifier to distinguish regexps from divisions (to some extent).

Rrraaa, I have to say, doing program rewriting via regexp rules is an inherently
broken idea...

[email protected]
BUG=
TEST=


Please review this at https://chromiumcodereview.appspot.com/9644001/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/v8natives.js
  M test/mjsunit/object-is.js
  M tools/jsmin.py


Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 76022f9843eec835e7f45e21e92932c509fde5f5..f1e8084a53038dff8d8c33a888d2e1bf41311af4 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1261,7 +1261,7 @@ function ObjectIsExtensible(obj) {
 // Harmony egal.
 function ObjectIs(obj1, obj2) {
   if (obj1 === obj2) {
-    return (obj1 !== 0) || ((1 / obj1) === (1 / obj2));
+    return (obj1 !== 0) || (1 / obj1 === 1 / obj2);
   } else {
     return (obj1 !== obj1) && (obj2 !== obj2);
   }
Index: test/mjsunit/object-is.js
diff --git a/test/mjsunit/object-is.js b/test/mjsunit/object-is.js
index 6a90fcd320d525bf4e3cc45a4d79a2140e1534ce..b9fdc8442068b4d7c50c06cb0eb8a134b8e9a7f3 100644
--- a/test/mjsunit/object-is.js
+++ b/test/mjsunit/object-is.js
@@ -32,7 +32,7 @@ function TestEgal(expected, x, y) {
   assertSame(expected, Object.is(x, y));
 }

-var test_set = [ {}, [], 1/0, -1/0, "s", 0, 1/(-1/0), null, undefined ];
+var test_set = [ {}, [], 1/0, -1/0, "s", 0, 0/-1, null, undefined ];
 print(test_set);
 for (var i = 0; i < test_set.length; i++) {
   for (var j = 0; j < test_set.length; j++) {
Index: tools/jsmin.py
diff --git a/tools/jsmin.py b/tools/jsmin.py
index 646bf143a5aae1c6182f8554829a72e01629c349..e82f3d031e884c92767e2714c6a191e7c25b526e 100644
--- a/tools/jsmin.py
+++ b/tools/jsmin.py
@@ -232,7 +232,9 @@ class JavaScriptMinifier(object):
       # A regexp that matches a regexp literal surrounded by /slashes/.
       # Don't allow a regexp to have a ) before the first ( since that's a
       # syntax error and it's probably just two unrelated slashes.
- slash_quoted_regexp = r"/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\([^/\\]| \\.)*/"
+      # Also don't allow it to come after anything that can only be the
+      # end of a primary expression.
+ slash_quoted_regexp = r"(?<![\w$'\")\]])/(?:(?=\()|(?:[^()/\\]| \\.)+)(?:\([^/\\]|\\.)*/"
       # Replace multiple spaces with a single space.
       line = re.sub("|".join([double_quoted_string,
                               single_quoted_string,


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to