[INFER] Fix merge botch, only warn once for each script accessing undefined properties in contexts with the strict option set, bug 662393.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 06 Jun 2011 17:12:49 -0700
changeset 75148 58be28e45a2695b1872413bc404b750f27ef584a
parent 75147 09d3a39c186a098ab626e21c2c94abf5c037e673
child 75149 877522d92ad4437de14804f21368b15ce3ca52dc
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs662393
milestone7.0a1
[INFER] Fix merge botch, only warn once for each script accessing undefined properties in contexts with the strict option set, bug 662393.
dom/base/nsJSEnvironment.cpp
js/src/jsobj.cpp
js/src/jsscript.h
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -941,17 +941,17 @@ nsJSContext::JSOptionChangedCallback(con
                                               js_tracejit_content_str);
   PRBool useMethodJIT = Preferences::GetBool(chromeWindow ?
                                                js_methodjit_chrome_str :
                                                js_methodjit_content_str);
   PRBool useProfiling = Preferences::GetBool(chromeWindow ?
                                                js_profiling_chrome_str :
                                                js_profiling_content_str);
   PRBool useMethodJITAlways = Preferences::GetBool(js_methodjit_always_str);
-  PRBool useTypeInference = !chromeWindow && nsContentUtils::GetBoolPref(js_typeinfer_str);
+  PRBool useTypeInference = !chromeWindow && Preferences::GetBool(js_typeinfer_str);
   nsCOMPtr<nsIXULRuntime> xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
   if (xr) {
     PRBool safeMode = PR_FALSE;
     xr->GetInSafeMode(&safeMode);
     if (safeMode) {
       useTraceJIT = PR_FALSE;
       useMethodJIT = PR_FALSE;
       useProfiling = PR_FALSE;
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -5783,16 +5783,17 @@ js_GetPropertyHelperWithShapeInline(JSCo
             if (op == JSOP_TRAP) {
                 JS_ASSERT_NOT_ON_TRACE(cx);
                 op = JS_GetTrapOpcode(cx, cx->fp()->script(), pc);
             }
             if (op == JSOP_GETXPROP) {
                 flags = JSREPORT_ERROR;
             } else {
                 if (!cx->hasStrictOption() ||
+                    cx->stack.currentScript()->warnedAboutUndefinedProp ||
                     (op != JSOP_GETPROP && op != JSOP_GETELEM) ||
                     js_CurrentPCIsInImacro(cx)) {
                     return JS_TRUE;
                 }
 
                 /*
                  * XXX do not warn about missing __iterator__ as the function
                  * may be called from JS_GetMethodById. See bug 355145.
@@ -5806,16 +5807,17 @@ js_GetPropertyHelperWithShapeInline(JSCo
                     pc += js_CodeSpec[op].length;
                     if (Detecting(cx, pc))
                         return JS_TRUE;
                 } else if (cx->resolveFlags & JSRESOLVE_DETECTING) {
                     return JS_TRUE;
                 }
 
                 flags = JSREPORT_WARNING | JSREPORT_STRICT;
+                cx->stack.currentScript()->warnedAboutUndefinedProp = true;
             }
 
             /* Ok, bad undefined property reference: whine about it. */
             if (!js_ReportValueErrorFlags(cx, flags, JSMSG_UNDEFINED_PROP,
                                           JSDVG_IGNORE_STACK, IdToValue(id),
                                           NULL, NULL, NULL)) {
                 return JS_FALSE;
             }
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -455,16 +455,19 @@ struct JSScript {
     bool            hasSharps:1;      /* script uses sharp variables */
     bool            strictModeCode:1; /* code is in strict mode */
     bool            compileAndGo:1;   /* script was compiled with TCF_COMPILE_N_GO */
     bool            usesEval:1;       /* script uses eval() */
     bool            usesArguments:1;  /* script uses arguments */
     bool            warnedAboutTwoArgumentEval:1; /* have warned about use of
                                                      obsolete eval(s, o) in
                                                      this script */
+    bool            warnedAboutUndefinedProp:1; /* have warned about uses of
+                                                   undefined properties in this
+                                                   script */
     bool            hasSingletons:1;  /* script has singleton objects */
     bool            isActiveEval:1;   /* script came from eval(), and is still active */
     bool            isCachedEval:1;   /* script came from eval(), and is in eval cache */
     bool            isUncachedEval:1; /* script came from EvaluateScript */
     bool            calledWithNew:1;  /* script has been called using 'new' */
     bool            usedLazyArgs:1;   /* script has used lazy arguments at some point */
     bool            ranInference:1;   /* script has been analyzed by type inference */
 #ifdef JS_METHODJIT