Disable emit{Enable,Disable}GC for x86.
authorPat Gavlin <pagavlin@microsoft.com>
Tue, 11 Oct 2016 00:09:29 +0000 (17:09 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Tue, 11 Oct 2016 01:03:51 +0000 (18:03 -0700)
The GC info encoding for this platform does not permit marking
arbitrary regions of generated code as non-interruptible.

Commit migrated from https://github.com/dotnet/coreclr/commit/5864690cc8411e4d512a7a14eb95a9bdaa4ccca6

src/coreclr/src/jit/codegenxarch.cpp
src/coreclr/src/jit/emit.h
src/coreclr/src/jit/morph.cpp

index a4b846d..be1b455 100644 (file)
@@ -1227,9 +1227,11 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
 
     switch (treeNode->gtOper)
     {
+#ifndef JIT32_GCENCODER
         case GT_START_NONGC:
             getEmitter()->emitDisableGC();
             break;
+#endif // !defined(JIT32_GCENCODER)
 
         case GT_PROF_HOOK:
 #ifdef PROFILING_SUPPORTED
@@ -2686,10 +2688,15 @@ BAILOUT:
 
 void CodeGen::genCodeForStoreBlk(GenTreeBlk* storeBlkNode)
 {
+#ifdef JIT32_GCENCODER
+    assert(!storeBlkNode->gtBlkOpGcUnsafe);
+#else
     if (storeBlkNode->gtBlkOpGcUnsafe)
     {
         getEmitter()->emitDisableGC();
     }
+#endif // JIT32_GCENCODER
+
     bool isCopyBlk = storeBlkNode->OperIsCopyBlkOp();
 
     switch (storeBlkNode->gtBlkOpKind)
@@ -2729,10 +2736,13 @@ void CodeGen::genCodeForStoreBlk(GenTreeBlk* storeBlkNode)
         default:
             unreached();
     }
+
+#ifndef JIT32_GCENCODER
     if (storeBlkNode->gtBlkOpGcUnsafe)
     {
         getEmitter()->emitEnableGC();
     }
+#endif // !defined(JIT32_GCENCODER)
 }
 
 // Generate code for InitBlk using rep stos.
index add3403..9ef5933 100644 (file)
@@ -1822,8 +1822,12 @@ private:
     void emitInsertIGAfter(insGroup* insertAfterIG, insGroup* ig);
 
     void emitNewIG();
+
+#if !defined(JIT32_GCENCODER)
     void emitDisableGC();
     void emitEnableGC();
+#endif // !defined(JIT32_GCENCODER)
+
     void emitGenIG(insGroup* ig);
     insGroup* emitSavIG(bool emitAdd = false);
     void emitNxtIG(bool emitAdd = false);
@@ -2707,6 +2711,7 @@ inline void emitter::emitNewIG()
     emitGenIG(ig);
 }
 
+#if !defined(JIT32_GCENCODER)
 // Start a new instruction group that is not interruptable
 inline void emitter::emitDisableGC()
 {
@@ -2736,6 +2741,7 @@ inline void emitter::emitEnableGC()
     // instruction groups.
     emitForceNewIG = true;
 }
+#endif // !defined(JIT32_GCENCODER)
 
 /*****************************************************************************/
 #endif // _EMIT_H_
index d7a3e73..0eaa1a0 100644 (file)
@@ -9645,9 +9645,12 @@ GenTreePtr Compiler::fgMorphCopyBlock(GenTreePtr tree)
             asg->gtOp.gtOp1   = dest;
             hasGCPtrs         = ((dest->OperGet() == GT_OBJ) && (dest->AsObj()->gtGcPtrCount != 0));
 
-#ifdef CPBLK_UNROLL_LIMIT
+#if defined(CPBLK_UNROLL_LIMIT) && !defined(JIT32_GCENCODER)
             // Note that the unrolling of CopyBlk is only implemented on some platforms.
-            // Currently that includes x64 and Arm64 but not x64 or Arm32.
+            // Currently that includes x64 and ARM but not x86: the code generation for this
+            // construct requires the ability to mark certain regions of the generated code
+            // as non-interruptible, and the GC encoding for the latter platform does not
+            // have this capability.
 
             // If we have a CopyObj with a dest on the stack
             // we will convert it into an GC Unsafe CopyBlk that is non-interruptible
@@ -9670,7 +9673,8 @@ GenTreePtr Compiler::fgMorphCopyBlock(GenTreePtr tree)
                     tree->gtOp.gtOp1               = dest;
                 }
             }
-#endif
+#endif // defined(CPBLK_UNROLL_LIMIT) && !defined(JIT32_GCENCODER)
+
             // Eliminate the "OBJ or BLK" node on the rhs.
             rhs             = fgMorphBlockOperand(rhs, asgType, blockWidth, false /*!isDest*/);
             asg->gtOp.gtOp2 = rhs;