[INFER] Avoid constructing unnecessary FreezeObjectKind constraints, bug 643249.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 20 Mar 2011 10:47:47 -0700
changeset 74825 507c4273633ada1a092e62469b7d04f899f78108
parent 74824 a0052afaf27fe2c345ee2ee3228f67fce47f6b11
child 74826 2326e700c7857d0cf88cbffd81adb1bd42f7d8dd
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs643249
milestone2.0b13pre
[INFER] Avoid constructing unnecessary FreezeObjectKind constraints, bug 643249.
js/src/jit-test/tests/basic/bug643249.js
js/src/jsinfer.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug643249.js
@@ -0,0 +1,13 @@
+{
+    function x() {}
+}
+for (i = 0; i < 10; i++) {
+    _someglobal_ = /a/;
+    (function() {
+        return function() {
+            return _someglobal_
+        } ()
+    } () == /a/);
+    gc();
+    _someglobal_ = new Function.__lookupSetter__;
+}
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -1460,26 +1460,28 @@ public:
         }
 
         if (type == TYPE_UNKNOWN) {
             kind = OBJECT_UNKNOWN;
         } else if (TypeIsObject(type)) {
             TypeObject *object = (TypeObject *) type;
             ObjectKind nkind = CombineObjectKind(object, kind);
 
-            /*
-             * Add a constraint on the element type of the object to pick up
-             * changes in the object's array-ness or any unknown properties.
-             */
-            TypeSet *elementTypes = object->getProperty(cx, JSID_VOID, false);
-            if (!elementTypes)
-                return;
-            elementTypes->add(cx,
-                ArenaNew<TypeConstraintFreezeObjectKind>(cx->compartment->types.pool,
-                                                         object, &kind, script), false);
+            if (nkind != OBJECT_UNKNOWN) {
+                /*
+                 * Add a constraint on the element type of the object to pick up
+                 * changes in the object's array-ness or any unknown properties.
+                 */
+                TypeSet *elementTypes = object->getProperty(cx, JSID_VOID, false);
+                if (!elementTypes)
+                    return;
+                elementTypes->add(cx,
+                    ArenaNew<TypeConstraintFreezeObjectKind>(cx->compartment->types.pool,
+                                                             object, &kind, script), false);
+            }
 
             if (nkind == kind) {
                 /* New object with the same kind we are interested in. */
                 return;
             }
             kind = nkind;
         } else {
             return;