[INFER] Restore code looking up lazily loaded global properties during inference, bug 613221.
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 02 Mar 2011 10:52:10 -0800
changeset 74703 ae7853f805293ed47e9edc189105f9e6449d6f23
parent 74702 5bbdcbbb05e063819dc99ce512799b587b4e1aa6
child 74704 386e9cffdcd7fb0233611a3904d38b89c9517a1b
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs613221
milestone2.0b12pre
[INFER] Restore code looking up lazily loaded global properties during inference, bug 613221.
js/src/jsinfer.cpp
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -2152,16 +2152,30 @@ AnalyzeBytecode(JSContext *cx, AnalyzeSt
       case JSOP_GETGNAME:
       case JSOP_CALLGNAME: {
         jsid id;
         if (op == JSOP_GETGLOBAL || op == JSOP_CALLGLOBAL)
             id = GetGlobalId(cx, script, pc);
         else
             id = GetAtomId(cx, script, pc, 0);
 
+        /*
+         * This might be a lazily loaded property of the global object. Resolve
+         * it now. Subtract this from the total analysis time. This is
+         * generally not needed if we ran the interpreter on this code first,
+         * but avoids recompilation if we are using JSOPTION_METHODJIT_ALWAYS.
+         */
+        uint64_t startTime = cx->compartment->types.currentTime();
+        JSObject *obj;
+        JSProperty *prop;
+        js_LookupPropertyWithFlags(cx, script->getGlobal(), id,
+                                   JSRESOLVE_QUALIFIED, &obj, &prop);
+        uint64_t endTime = cx->compartment->types.currentTime();
+        cx->compartment->types.analysisTime -= (endTime - startTime);
+
         /* Handle as a property access. */
         PropertyAccess(cx, script, pc, script->getGlobalType(),
                        false, &pushed[0], id);
 
         if (op == JSOP_CALLGLOBAL || op == JSOP_CALLGNAME)
             pushed[1].addType(cx, TYPE_UNKNOWN);
 
         if (CheckNextTest(pc))