[INFER] Workaround for GCC 4.2 bug.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 07 Dec 2010 09:42:43 -0800
changeset 74639 da4218029a5cdcc6b6d923108b04fdc05c651961
parent 74638 136d6a93418ed9b3396d8e30eaf5972cde3f3516
child 74640 1ef66ceff8d5a81491e7bee3ae3b4df881e55c7f
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone2.0b8pre
[INFER] Workaround for GCC 4.2 bug.
js/src/methodjit/MachineRegs.h
--- a/js/src/methodjit/MachineRegs.h
+++ b/js/src/methodjit/MachineRegs.h
@@ -49,39 +49,49 @@ namespace mjit {
 
 /* Common handling for both general purpose and floating point registers. */
 
 struct AnyRegisterID {
     unsigned reg_;
 
     AnyRegisterID()
         : reg_((unsigned)-1)
-    {}
+    { pin(); }
 
     AnyRegisterID(const AnyRegisterID &o)
         : reg_(o.reg_)
-    {}
+    { pin(); }
 
     AnyRegisterID(JSC::MacroAssembler::RegisterID reg)
         : reg_((unsigned)reg)
-    {}
+    { pin(); }
 
     AnyRegisterID(JSC::MacroAssembler::FPRegisterID reg)
         : reg_(JSC::MacroAssembler::TotalRegisters + (unsigned)reg)
-    {}
+    { pin(); }
 
     static inline AnyRegisterID fromRaw(unsigned reg);
 
     inline JSC::MacroAssembler::RegisterID reg();
     inline JSC::MacroAssembler::FPRegisterID fpreg();
 
     bool isReg() { return reg_ < JSC::MacroAssembler::TotalRegisters; }
     bool isSet() { return reg_ != unsigned(-1); }
 
     inline const char * name();
+
+  private:
+    void pin() {
+        /*
+         * Workaround for apparent compiler bug in GCC 4.2. If GCC thinks that reg_
+         * cannot escape then it compiles isReg() and other accesses to reg_ incorrectly.
+         */
+        static unsigned *v;
+        v = &reg_;
+    }
 };
 
 struct Registers {
 
     /* General purpose registers. */
 
     static const uint32 TotalRegisters = JSC::MacroAssembler::TotalRegisters;