Bug 623362 - nanojit: avoid harmless race on nHints[]. r=jseward.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 17 Mar 2011 19:54:29 -0700
changeset 6225 5b8d188e84a26673b41a382adc02d44c2283ac62
parent 6224 60f2e1775c0ec3b81f9483c93291f5734570fc8d
child 6226 7eb817653fb59bede1696d1629cf29386bf94976
push id3609
push userstejohns@adobe.com
push dateWed, 27 Apr 2011 17:21:13 +0000
reviewersjseward
bugs623362
Bug 623362 - nanojit: avoid harmless race on nHints[]. r=jseward.
nanojit/Assembler.cpp
nanojit/Assembler.h
--- a/nanojit/Assembler.cpp
+++ b/nanojit/Assembler.cpp
@@ -87,37 +87,31 @@ namespace nanojit
     #if PEDANTIC
         , pedanticTop(NULL)
     #endif
     #ifdef VMCFG_VTUNE
         , vtuneHandle(NULL)
     #endif
         , _config(config)
     {
+        // Per-opcode register hint table.  Defaults to no hints for all
+        // instructions (it's zeroed in the constructor).  Must be zeroed
+        // before calling nInit().
+        for (int i = 0; i < LIR_sentinel+1; i++)
+            nHints[i] = 0;
         nInit();
         (void)logc;
         verbose_only( _logc = logc; )
         verbose_only( _outputCache = 0; )
         verbose_only( outline[0] = '\0'; )
         verbose_only( outlineEOL[0] = '\0'; )
 
         reset();
     }
 
-    // Per-opcode register hint table.  Default to no hints for all
-    // instructions.  It's not marked const because individual back-ends can
-    // install hint values for opcodes of interest in nInit().
-    RegisterMask Assembler::nHints[LIR_sentinel+1] = {
-#define OP___(op, number, repKind, retType, isCse) \
-        0,
-#include "LIRopcode.tbl"
-#undef OP___
-        0
-    };
-
 #ifdef _DEBUG
 
     /*static*/ LIns* const AR::BAD_ENTRY = (LIns*)0xdeadbeef;
 
     void AR::validateQuick()
     {
         NanoAssert(_highWaterMark < NJ_MAX_STACK_ENTRY);
         NanoAssert(_entries[0] == NULL);
--- a/nanojit/Assembler.h
+++ b/nanojit/Assembler.h
@@ -493,17 +493,17 @@ namespace nanojit
             // platform specific implementation (see NativeXXX.cpp file)
             void        nInit();
             void        nBeginAssembly();
             Register    nRegisterAllocFromSet(RegisterMask set);
             void        nRegisterResetAll(RegAlloc& a);
             void        nPatchBranch(NIns* branch, NIns* location);
             void        nFragExit(LIns* guard);
 
-            static RegisterMask nHints[LIR_sentinel+1];
+            RegisterMask nHints[LIR_sentinel+1];
             RegisterMask nHint(LIns* ins);
 
             // A special entry for hints[];  if an opcode has this value, we call
             // nHint() in the back-end.  Used for cases where you need to look at more
             // than just the opcode to decide.
             static const RegisterMask PREFER_SPECIAL = 0xffffffff;
 
             // platform specific methods