Bug 1281385 - Cache the needsCallObject bit in CompileInfo to fix a TSan race. r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 30 Jun 2016 08:32:39 +0200
changeset 303290 3edd30710d5e2b3f555d4b251b9ba0962eb4f25d
parent 303238 633d41ede644bf0fed6ca98328168d9c8f44c1de
child 303291 7a133276156418748a88108224886d00e471ae58
push id19839
push usercbook@mozilla.com
push dateFri, 01 Jul 2016 09:19:59 +0000
treeherderfx-team@499d8875de7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1281385
milestone50.0a1
Bug 1281385 - Cache the needsCallObject bit in CompileInfo to fix a TSan race. r=nbp
js/src/jit/CompileInfo.h
--- a/js/src/jit/CompileInfo.h
+++ b/js/src/jit/CompileInfo.h
@@ -220,22 +220,23 @@ class CompileInfo
         nimplicit_ = StartArgSlot(script)                   /* scope chain and argument obj */
                    + (fun ? 1 : 0);                         /* this */
         nargs_ = fun ? fun->nargs() : 0;
         nbodyfixed_ = script->nbodyfixed();
         nlocals_ = script->nfixed();
         fixedLexicalBegin_ = script->fixedLexicalBegin();
         nstack_ = Max<unsigned>(script->nslots() - script->nfixed(), MinJITStackSize);
         nslots_ = nimplicit_ + nargs_ + nlocals_ + nstack_;
+        needsCallObject_ = fun ? fun->needsCallObject() : false;
     }
 
     explicit CompileInfo(unsigned nlocals)
       : script_(nullptr), fun_(nullptr), osrPc_(nullptr), osrStaticScope_(nullptr),
-        constructing_(false), analysisMode_(Analysis_None), scriptNeedsArgsObj_(false),
-        mayReadFrameArgsDirectly_(false), inlineScriptTree_(nullptr)
+        constructing_(false), needsCallObject_(false), analysisMode_(Analysis_None),
+        scriptNeedsArgsObj_(false), mayReadFrameArgsDirectly_(false), inlineScriptTree_(nullptr)
     {
         nimplicit_ = 0;
         nargs_ = 0;
         nbodyfixed_ = 0;
         nlocals_ = nlocals;
         nstack_ = 1;  /* For FunctionCompiler::pushPhiInput/popPhiOutput */
         nslots_ = nlocals_ + nstack_;
         fixedLexicalBegin_ = nlocals;
@@ -324,16 +325,20 @@ class CompileInfo
     // maybe argumentsobject and this value.
     unsigned nimplicit() const {
         return nimplicit_;
     }
     // Number of arguments (without counting this value).
     unsigned nargs() const {
         return nargs_;
     }
+    bool needsCallObject() const {
+        MOZ_ASSERT(funMaybeLazy());
+        return needsCallObject_;
+    }
     // Number of slots needed for fixed body-level bindings.  Note that this
     // is only non-zero for function code.
     unsigned nbodyfixed() const {
         return nbodyfixed_;
     }
     // Number of slots needed for all local variables.  This includes "fixed
     // vars" (see above) and also block-scoped locals.
     unsigned nlocals() const {
@@ -494,17 +499,17 @@ class CompileInfo
     bool isObservableFrameSlot(uint32_t slot) const {
         if (!funMaybeLazy())
             return false;
 
         // The |this| value must always be observable.
         if (slot == thisSlot())
             return true;
 
-        if (funMaybeLazy()->needsCallObject() && slot == scopeChainSlot())
+        if (needsCallObject() && slot == scopeChainSlot())
             return true;
 
         // If the function may need an arguments object, then make sure to
         // preserve the scope chain, because it may be needed to construct the
         // arguments object during bailout. If we've already created an
         // arguments object (or got one via OSR), preserve that as well.
         if (hasArguments() && (slot == scopeChainSlot() || slot == argsObjSlot()))
             return true;
@@ -567,16 +572,17 @@ class CompileInfo
     unsigned nstack_;
     unsigned nslots_;
     unsigned fixedLexicalBegin_;
     JSScript* script_;
     JSFunction* fun_;
     jsbytecode* osrPc_;
     NestedStaticScope* osrStaticScope_;
     bool constructing_;
+    bool needsCallObject_;
     AnalysisMode analysisMode_;
 
     // Whether a script needs an arguments object is unstable over compilation
     // since the arguments optimization could be marked as failed on the main
     // thread, so cache a value here and use it throughout for consistency.
     bool scriptNeedsArgsObj_;
 
     // Record the state of previous bailouts in order to prevent compiling the