no bug: concurrency fixes, other minor bug fixes (p=jasowill,p=dtomack,p=brbaker,p=veresov)
authorDan Schaffer <Dan.Schaffer@adobe.com>
Mon, 28 Jan 2013 08:27:24 -0800
changeset 7584 ae7348551cffe7b3d3b89a3a16698882ac333562
parent 7583 8d37a994952c2cbd7f8721696e83865a934ab6b7
child 7585 1366af27b87ec3b55c467b5d2d969f9db5434b73
push id4262
push userdschaffe@adobe.com
push dateWed, 30 Jan 2013 19:01:31 +0000
bugs1143169, 1140327, 1159082
no bug: concurrency fixes, other minor bug fixes (p=jasowill,p=dtomack,p=brbaker,p=veresov) Integrate FR Main up to @CL 1143169 starting at last FR-Main to FR-Avm integration point (1140327). CL@1159082
core/CodegenLIR.cpp
halfmoon/hm-liremitter.cpp
nanojit/Nativei386.cpp
vmbase/VMThread-inlines.h
--- a/core/CodegenLIR.cpp
+++ b/core/CodegenLIR.cpp
@@ -2556,17 +2556,17 @@ FLOAT_ONLY(           !(v.sst_mask == (1
         emitSetPc(state->abc_pc);
 
 #ifdef DEBUG
         memset(jit_sst, 0, framesize * sizeof(uint16_t));
 #endif
 
         // If this is the target of a backwards branch, generate an interrupt check.
 
-#ifdef VMCFG_INTERRUPT_SAFEPOINT_POLL
+#if defined (VMCFG_INTERRUPT_SAFEPOINT_POLL) && defined (NJ_SAFEPOINT_POLLING_SUPPORTED)
         // Always poll for safepoints, regardless of config settings.
 		if (state->targetOfBackwardsBranch) {
 			AvmAssert(AvmCore::NotInterrupted == 0);
             LIns* interrupted = loadIns(LIR_ldi, offsetof(AvmCore,interrupted), coreAddr, ACCSET_OTHER, LOAD_VOLATILE);
 
 			branchAndSavePC(interrupted, interrupt_label);
         }
 #else
@@ -7746,22 +7746,22 @@ FLOAT_ONLY(           !(v.sst_mask == (1
         if (call_error_label.unpatchedEdges) {
             emitLabel(call_error_label);
             Ins(LIR_regfence);
             callIns(FUNCTIONID(op_call_error), 1, env_param);
         }
 
         if (interrupt_label.unpatchedEdges) {
             emitLabel(interrupt_label);
-#ifdef VMCFG_INTERRUPT_SAFEPOINT_POLL
+#if defined (VMCFG_INTERRUPT_SAFEPOINT_POLL) && defined (NJ_SAFEPOINT_POLLING_SUPPORTED)
             Ins(LIR_pushstate);
 #endif 
             Ins(LIR_regfence);
             callIns(FUNCTIONID(handleInterruptMethodEnv), 1, env_param);
-#ifdef VMCFG_INTERRUPT_SAFEPOINT_POLL
+#if defined (VMCFG_INTERRUPT_SAFEPOINT_POLL) && defined (NJ_SAFEPOINT_POLLING_SUPPORTED)
             Ins(LIR_popstate);
             Ins(LIR_restorepc);
 #endif
         }
 
         if (driver->hasReachableExceptions()) {
             // exception case
             emitLabel(catch_label);
--- a/halfmoon/hm-liremitter.cpp
+++ b/halfmoon/hm-liremitter.cpp
@@ -2063,25 +2063,18 @@ LIns* LirEmitter::emitUpeHandler() {
 }
 
 /** Generate one handler for all timeout interrupts */
 LIns* LirEmitter::emitInterruptHandler() {
   if (interrupt_label == NULL) {
     LIns* args[] = { env_param };
     interrupt_label = traps_lir->ins0(LIR_label);
     
-#ifdef VMCFG_INTERRUPT_SAFEPOINT_POLL
-    traps_lir->ins0(LIR_pushstate);
-#endif 
     traps_lir->ins0(LIR_regfence);
     traps_lir->insCall(&ci_handleInterruptMethodEnv, args);
-#ifdef VMCFG_INTERRUPT_SAFEPOINT_POLL
-    traps_lir->ins0(LIR_popstate);
-    traps_lir->ins0(LIR_restorepc);
-#endif
     
   }
   return interrupt_label;
 }
 
 void LirEmitter::do_cknull(UnaryStmt* instr) {
   const Use& value_in = instr->value_in();
   LIns* ptr = def_ins(value_in);
@@ -2097,28 +2090,22 @@ void LirEmitter::do_cknullobject(UnarySt
   lirout->insBranch(LIR_jt, eqp0(ptr), emitNpeHandler());
   set_def_ins(instr->value_out(), ptr);
 }
 
 void LirEmitter::do_cktimeout(UnaryStmt* instr) {
   // Omit timeout checks if they are turned off.  We don't do this further
   // upstream, because it can cause the graph to have no endpoints, if there
   // is an infinite loop.
-#ifdef VMCFG_INTERRUPT_SAFEPOINT_POLL
-  bool check_interrupt = true;
-#else
   bool check_interrupt = core->config.interrupts;
-#endif
   if (check_interrupt) {
-    lirout->ins0(LIR_savepc);
     LIns* interrupted = ldi(coreAddr, JitFriend::core_interrupted_offset,
                             ACCSET_OTHER, LOAD_VOLATILE);
     LIns* cond = eqi(interrupted, AvmCore::NotInterrupted);
     lirout->insBranch(LIR_jf, cond, emitInterruptHandler());
-    lirout->ins0(LIR_discardpc);
   }
   set_def_ins(instr->value_out(), InsConst(0)); // always return false.
 }
 
 void LirEmitter::do_doubletoint32(UnaryExpr* instr) {
   LIns* arg = def_ins(instr->value_in());
 
   LIns* result;
--- a/nanojit/Nativei386.cpp
+++ b/nanojit/Nativei386.cpp
@@ -3522,60 +3522,49 @@ namespace nanojit
     }
     
     void Assembler::asm_popstate()
     {
         underrunProtect(1);
         OPCODE(0x61);
     }
 
-	void Assembler::asm_brsavpc_impl(LIns* flag, NIns* target)
-	{
-        Register r = findRegFor(flag, GpRegs);
-		underrunProtect(20);
-
-		// discard pc
+    void Assembler::asm_brsavpc_impl(LIns* flag, NIns* target)
+    {
+	Register r = findRegFor(flag, GpRegs);
+	underrunProtect(15);
+
+        NIns* skipTarget = _nIns;
+
+	// discard pc
         ADDi(rESP, 16);
 
-		/// branch
+	// save pc &  branch
         const intptr_t tt = (intptr_t)target - (intptr_t)_nIns;
-
-		// JNE(tt) long form. -- generates 6 bytes of instr.
-        count_jcc();
         IMM32(tt);
-        OPCODE(0x80 | 0x05);
-        OPCODE(JCC32);
-
-		// save pc
-        IMM32(0);
-        OPCODE(0xE8);		// CALL 0
-
-		TEST(r, r);
-
-		SUBi(rESP, 12);		// maintain 16 byte alignment for ABI
-	}
+        OPCODE(0xE8);		// CALL tt
+
+	SUBi(rESP, 12);		// maintain 16 byte alignment for ABI
+        JE(skipTarget);		// always short distance
+	TEST(r,r);
+    }
 
     void Assembler::asm_restorepc()
     {
-		underrunProtect(7);
+	underrunProtect(3);
 	// jmp dword ptr [esp]
         OPCODE(0x24);
         OPCODE(0x24);
         OPCODE(0xff);
-	// add dword ptr [esp],6
-        OPCODE(0x06);
-        OPCODE(0x24);
-        OPCODE(0x04);
-        OPCODE(0x83);
     }
 
-	void Assembler::asm_memfence()
-	{
-		// no fencing necessary on i386
-	}
+    void Assembler::asm_memfence()
+    {
+	    // no fencing necessary on i386
+    }
 
     // WARNING: This function cannot generate any code that will affect the
     // condition codes prior to the generation of the
     // ucomisd/fcompp/fcmop/fcom.  See asm_cmpi() for more details.
     void Assembler::asm_cmpf4(LIns *cond) {
         NanoAssert((cond->opcode()==LIR_eqf4) );
 
         LIns* a = cond->oprnd1();
--- a/vmbase/VMThread-inlines.h
+++ b/vmbase/VMThread-inlines.h
@@ -229,17 +229,17 @@ namespace vmbase {
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
         uint32_t val;
         __asm__ __volatile__("lock; cmpxchg %1, (%2);"
                              :"=a"(val)
                              :"r"(next), "r"(wordptr), "a"(expected)
                              :"memory", "cc");
         return val;
 #elif defined(_MSC_VER) 
-        // we know that we are dealing with only 32 bit word here and a 32 bit compiler option
+        // we know that we are dealing with only 32 bit word here
         return ::InterlockedCompareExchange(reinterpret_cast<volatile LONG*>(wordptr), next, expected);
 #else
         //  THIS IS WRONG!!!!
         //  the "val" needs to be atomically obtained from "compareAndSwap32WithBuffer"
         int32_t val = *wordptr;
         if (!compareAndSwap32WithBarrier(expected, next, wordptr))
         {
             return val;