[commit] r2235 - OSCogVM source as per VMMaker-oscog.23. Take alloca from stddef.h; malloc.h is

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] r2235 - OSCogVM source as per VMMaker-oscog.23. Take alloca from stddef.h; malloc.h is

commits-3
 
Author: eliot
Date: 2010-07-16 07:57:02 -0700 (Fri, 16 Jul 2010)
New Revision: 2235

Modified:
   branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
   branches/Cog/src/vm/cointerp.c
   branches/Cog/src/vm/cointerp.h
   branches/Cog/src/vm/gcc3x-cointerp.c
   branches/Cog/src/vm/interp.h
   branches/Cog/stacksrc/vm/gcc3x-interp.c
   branches/Cog/stacksrc/vm/interp.c
   branches/Cog/stacksrc/vm/interp.h
Log:
OSCogVM source as per VMMaker-oscog.23.  Take alloca from stddef.h; malloc.h is
an anachronism.  Safer long-running primitive method code.  FreeBSD-friendly
mutex initialization in the unix heartbeat (I hope).


Modified: branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c 2010-07-16 14:57:02 UTC (rev 2235)
@@ -375,13 +375,18 @@
  (void)nanosleep(&naptime, 0);
 }
 
-/* N.B. This is laziness.  If needed on other than linux one would have to
- * initializea mutexattr with PTHREAD_ERRORCHECK_MUTEX type.  We require
- * the errr check because we're lazy in preventing multiple attempts at
- * locking yield_mutex in yieldToHighPriorityTickerThread.
+/* We require the error check because we're lazy in preventing multiple
+ * attempts at locking yield_mutex in yieldToHighPriorityTickerThread.
  */
-static pthread_mutex_t yield_sync = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-static pthread_mutex_t yield_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+#if defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP)
+# define THE_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
+#elif defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
+# define THE_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
+#else
+# define THE_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+#endif
+static pthread_mutex_t yield_sync = THE_MUTEX_INITIALIZER;
+static pthread_mutex_t yield_mutex = THE_MUTEX_INITIALIZER;
 static pthread_cond_t yield_cond = PTHREAD_COND_INITIALIZER;
 
 /* Private to sqTicker.c ioSynchronousCheckForEvents */

Modified: branches/Cog/src/vm/cointerp.c
===================================================================
--- branches/Cog/src/vm/cointerp.c 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/src/vm/cointerp.c 2010-07-16 14:57:02 UTC (rev 2235)
@@ -1,9 +1,9 @@
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
    from
- CoInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CoInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
-static char __buildInfo[] = "CoInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -15,8 +15,9 @@
 #endif
 
 #include "sq.h"
-#include <malloc.h> /* for alloca under MSVC */
+#include <stddef.h> /* for e.g. alloca */
 #include <setjmp.h>
+#include "sqMemoryFence.h"
 #include "dispdbg.h"
 #include "sqCogStackAlignment.h"
 #include "cogmethod.h"
@@ -1097,11 +1098,10 @@
 _iss sqInt needGCFlag;
 _iss sqInt profileProcess;
 _iss usqInt scavengeThreshold;
-_iss sqInt longRunningPrimitiveCheckMethod;
 _iss sqInt numStackPages;
 _iss sqInt profileMethod;
-_iss usqInt fwdTableNext;
 _iss unsigned char primTraceLogIndex;
+_iss usqInt fwdTableNext;
 _iss sqInt jmpDepth;
 _iss sqInt longRunningPrimitiveCheckSemaphore;
 _iss usqInt compStart;
@@ -1114,8 +1114,10 @@
 _iss sqInt preemptionYields;
 _iss sqInt cogCompiledCodeCompactionCalledFor;
 _iss sqInt highestRunnableProcessPriority;
+_iss sqInt longRunningPrimitiveCheckMethod;
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
+_iss sqInt statCheckForEvents;
 _iss sqInt statGrowMemory;
 _iss sqInt statMarkCount;
 _iss sqInt lastCoggableInterpretedBlockMethod;
@@ -1131,7 +1133,6 @@
 _iss sqInt pendingFinalizationSignals;
 _iss sqInt shrinkThreshold;
 _iss char * stackBasePlus1;
-_iss sqInt statCheckForEvents;
 _iss sqInt statShrinkMemory;
 _iss sqInt bytesPerPage;
 _iss sqInt cogCodeSize;
@@ -1145,6 +1146,7 @@
 _iss sqInt edenBytes;
 _iss sqInt forceTenureFlag;
 _iss sqInt interruptPending;
+_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt signalLowSpace;
 _iss sqInt statForceInterruptCheck;
 _iss usqLong statFullGCUsecs;
@@ -1174,7 +1176,6 @@
 _iss sqInt gcBiasToGrowGCLimit;
 _iss sqInt gcSemaphoreIndex;
 _iss sqInt imageFloatsBigEndian;
-_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt longRunningPrimitiveSignalUndelivered;
 _iss usqLong nextPollUsecs;
 _iss StackPage * overflowedPage;
@@ -1815,7 +1816,7 @@
  /* 575 */ (void (*)(void))0,
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.20]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.23]";
 static volatile int sendTrace;
 sqInt suppressHeartbeatFlag;
 
@@ -16556,9 +16557,10 @@
  goto l1;
  }
  if (GIV(longRunningPrimitiveStopUsecs) == 0) {
+ GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
  GIV(longRunningPrimitiveCheckMethod) = GIV(newMethod);
  GIV(longRunningPrimitiveStartUsecs) = ioUTCMicroseconds();
- GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
+ sqLowLevelMFence();
  }
  l1: /* end checkForLongRunningPrimitive */;
  if (GIV(deferSmash)) {
@@ -19866,7 +19868,6 @@
 mapPointersInObjectsFromto(sqInt memStart, sqInt memEnd) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt aMethodObj;
-    sqInt fwdBlock;
     sqInt i;
     sqInt i1;
     sqInt i2;
@@ -19874,7 +19875,6 @@
     sqInt oop;
     sqInt oop1;
     sqInt probe;
-    sqInt targetObj;
 
  /* begin mapInterpreterOops */
  VM_LABEL(0mapInterpreterOops);
@@ -19904,37 +19904,22 @@
  GIV(newMethod) = remap(GIV(newMethod));
  GIV(lkupClass) = remap(GIV(lkupClass));
  /* begin mapProfileState */
- VM_LABEL(0mapProfileState);
  GIV(profileProcess) = remap(GIV(profileProcess));
  GIV(profileMethod) = remap(GIV(profileMethod));
 
- /* Since the longRunningPrimitiveCheckMethod is sampled at interrupt time it may be invalid.
- Be very careful with it. */
+ /* The longRunningPrimitiveCheckMethod (LRPCM) is sampled in an interrupt.  Be very careful with it.
+  If longRunningPrimitiveCheckSequenceNumber (LRPCSN) = statCheckForEvents then LRPCM has
+  been recenty sampled and could be mapped or not, but it must be newMethod and we can simply
+  copy newMethod.  If LRPCSN ~= statCheckForEvents then LRPCM must be some extant object and
+  needs to be remapped. */
 
  GIV(profileSemaphore) = remap(GIV(profileSemaphore));
- if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && (((GIV(longRunningPrimitiveCheckMethod) & 1) == 0)
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & MarkBit) != 0))) {
-
- /* If it is invalid at this point we'd better nil it. */
-
- fwdBlock = ((longAt(GIV(longRunningPrimitiveCheckMethod))) & AllButMarkBitAndTypeMask) << 1;
- if (((((usqInt) fwdBlock)) > (((usqInt) GIV(endOfMemory))))
- && (((((usqInt) fwdBlock)) <= (((usqInt) GIV(fwdTableNext))))
- && ((fwdBlock & 3) == 0))) {
- targetObj = longAt(fwdBlock);
- if (((targetObj & 3) == 0)
- && (((((usqInt)targetObj)) >= heapBase)
- && ((((usqInt)targetObj)) < GIV(freeStart)))) {
- GIV(longRunningPrimitiveCheckMethod) = targetObj;
- }
- else {
- voidLongRunningPrimitive("bad *fwd");
- }
- }
- else {
- voidLongRunningPrimitive("bad fwd->");
- }
+ sqLowLevelMFence();
+ if (GIV(longRunningPrimitiveCheckMethod) != null) {
+ GIV(longRunningPrimitiveCheckMethod) = (GIV(longRunningPrimitiveCheckSequenceNumber) == GIV(statCheckForEvents)
+ ? GIV(newMethod)
+ : remap(GIV(longRunningPrimitiveCheckMethod)));
+ sqLowLevelMFence();
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
  GIV(longRunningPrimitiveCheckSemaphore) = remap(GIV(longRunningPrimitiveCheckSemaphore));
@@ -20243,9 +20228,9 @@
  markAndTrace(GIV(profileProcess));
  markAndTrace(GIV(profileMethod));
  markAndTrace(GIV(profileSemaphore));
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))) {
+ && (GIV(longRunningPrimitiveCheckSequenceNumber) != GIV(statCheckForEvents))) {
  markAndTrace(GIV(longRunningPrimitiveCheckMethod));
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
@@ -32040,6 +32025,7 @@
 primitiveLongRunningPrimitive(void) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt gcms;
+    sqInt lrpcm;
     sqInt primms;
     sqInt result;
     char *sp;
@@ -32051,22 +32037,23 @@
  }
  return;
  }
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveStopUsecs) > GIV(longRunningPrimitiveStartUsecs))
- && ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((((GIV(longRunningPrimitiveCheckMethod) & 3) == 0)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) >= heapBase)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) < GIV(freeStart))
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) != HeaderTypeGC))))
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))))) {
+ && ((((lrpcm = GIV(longRunningPrimitiveCheckMethod))) != null)
+ && ((((lrpcm & 3) == 0)
+ && (((((usqInt)lrpcm)) >= heapBase)
+ && (((((usqInt)lrpcm)) < GIV(freeStart))
+ && (((longAt(lrpcm)) & TypeMask) != HeaderTypeGC))))
+ && ((!(((longAt(lrpcm)) & TypeMask) == HeaderTypeFree))
+ && (((((usqInt) (longAt(lrpcm))) >> 8) & 15) >= 12))))) {
  result = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), 3);
  primms = ((GIV(longRunningPrimitiveStopUsecs) - GIV(longRunningPrimitiveStartUsecs)) + 500) / 1000;
  gcms = (GIV(longRunningPrimitiveGCUsecs) + 500) / 1000;
  /* begin storePointer:ofObject:withValue: */
  if ((((usqInt) result)) < (((usqInt) GIV(youngStart)))) {
- possibleRootStoreIntovalue(result, GIV(longRunningPrimitiveCheckMethod));
+ possibleRootStoreIntovalue(result, lrpcm);
  }
- longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), GIV(longRunningPrimitiveCheckMethod));
+ longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), lrpcm);
  longAtput((result + BaseHeaderSize) + (1 << ShiftForWord), ((primms << 1) | 1));
  longAtput((result + BaseHeaderSize) + (2 << ShiftForWord), ((gcms << 1) | 1));
  }
@@ -44144,6 +44131,7 @@
  GIV(longRunningPrimitiveCheckSequenceNumber) == 0;
  GIV(longRunningPrimitiveStartUsecs) = GIV(longRunningPrimitiveStopUsecs) = 0;
  GIV(longRunningPrimitiveSignalUndelivered) = 1;
+ sqLowLevelMFence();
 }
 
 

Modified: branches/Cog/src/vm/cointerp.h
===================================================================
--- branches/Cog/src/vm/cointerp.h 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/src/vm/cointerp.h 2010-07-16 14:57:02 UTC (rev 2235)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
 
 

Modified: branches/Cog/src/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/src/vm/gcc3x-cointerp.c 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/src/vm/gcc3x-cointerp.c 2010-07-16 14:57:02 UTC (rev 2235)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
    from
- CoInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CoInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
-static char __buildInfo[] = "CoInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -18,8 +18,9 @@
 #endif
 
 #include "sqGnu.h"
-#include <malloc.h> /* for alloca under MSVC */
+#include <stddef.h> /* for e.g. alloca */
 #include <setjmp.h>
+#include "sqMemoryFence.h"
 #include "dispdbg.h"
 #include "sqCogStackAlignment.h"
 #include "cogmethod.h"
@@ -1100,11 +1101,10 @@
 _iss sqInt needGCFlag;
 _iss sqInt profileProcess;
 _iss usqInt scavengeThreshold;
-_iss sqInt longRunningPrimitiveCheckMethod;
 _iss sqInt numStackPages;
 _iss sqInt profileMethod;
-_iss usqInt fwdTableNext;
 _iss unsigned char primTraceLogIndex;
+_iss usqInt fwdTableNext;
 _iss sqInt jmpDepth;
 _iss sqInt longRunningPrimitiveCheckSemaphore;
 _iss usqInt compStart;
@@ -1117,8 +1117,10 @@
 _iss sqInt preemptionYields;
 _iss sqInt cogCompiledCodeCompactionCalledFor;
 _iss sqInt highestRunnableProcessPriority;
+_iss sqInt longRunningPrimitiveCheckMethod;
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
+_iss sqInt statCheckForEvents;
 _iss sqInt statGrowMemory;
 _iss sqInt statMarkCount;
 _iss sqInt lastCoggableInterpretedBlockMethod;
@@ -1134,7 +1136,6 @@
 _iss sqInt pendingFinalizationSignals;
 _iss sqInt shrinkThreshold;
 _iss char * stackBasePlus1;
-_iss sqInt statCheckForEvents;
 _iss sqInt statShrinkMemory;
 _iss sqInt bytesPerPage;
 _iss sqInt cogCodeSize;
@@ -1148,6 +1149,7 @@
 _iss sqInt edenBytes;
 _iss sqInt forceTenureFlag;
 _iss sqInt interruptPending;
+_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt signalLowSpace;
 _iss sqInt statForceInterruptCheck;
 _iss usqLong statFullGCUsecs;
@@ -1177,7 +1179,6 @@
 _iss sqInt gcBiasToGrowGCLimit;
 _iss sqInt gcSemaphoreIndex;
 _iss sqInt imageFloatsBigEndian;
-_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt longRunningPrimitiveSignalUndelivered;
 _iss usqLong nextPollUsecs;
 _iss StackPage * overflowedPage;
@@ -1818,7 +1819,7 @@
  /* 575 */ (void (*)(void))0,
  0 };
 static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.20]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.23]";
 static volatile int sendTrace;
 sqInt suppressHeartbeatFlag;
 
@@ -16560,9 +16561,10 @@
  goto l1;
  }
  if (GIV(longRunningPrimitiveStopUsecs) == 0) {
+ GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
  GIV(longRunningPrimitiveCheckMethod) = GIV(newMethod);
  GIV(longRunningPrimitiveStartUsecs) = ioUTCMicroseconds();
- GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
+ sqLowLevelMFence();
  }
  l1: /* end checkForLongRunningPrimitive */;
  if (GIV(deferSmash)) {
@@ -19870,7 +19872,6 @@
 mapPointersInObjectsFromto(sqInt memStart, sqInt memEnd) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt aMethodObj;
-    sqInt fwdBlock;
     sqInt i;
     sqInt i1;
     sqInt i2;
@@ -19878,7 +19879,6 @@
     sqInt oop;
     sqInt oop1;
     sqInt probe;
-    sqInt targetObj;
 
  /* begin mapInterpreterOops */
  VM_LABEL(0mapInterpreterOops);
@@ -19908,37 +19908,22 @@
  GIV(newMethod) = remap(GIV(newMethod));
  GIV(lkupClass) = remap(GIV(lkupClass));
  /* begin mapProfileState */
- VM_LABEL(0mapProfileState);
  GIV(profileProcess) = remap(GIV(profileProcess));
  GIV(profileMethod) = remap(GIV(profileMethod));
 
- /* Since the longRunningPrimitiveCheckMethod is sampled at interrupt time it may be invalid.
- Be very careful with it. */
+ /* The longRunningPrimitiveCheckMethod (LRPCM) is sampled in an interrupt.  Be very careful with it.
+  If longRunningPrimitiveCheckSequenceNumber (LRPCSN) = statCheckForEvents then LRPCM has
+  been recenty sampled and could be mapped or not, but it must be newMethod and we can simply
+  copy newMethod.  If LRPCSN ~= statCheckForEvents then LRPCM must be some extant object and
+  needs to be remapped. */
 
  GIV(profileSemaphore) = remap(GIV(profileSemaphore));
- if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && (((GIV(longRunningPrimitiveCheckMethod) & 1) == 0)
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & MarkBit) != 0))) {
-
- /* If it is invalid at this point we'd better nil it. */
-
- fwdBlock = ((longAt(GIV(longRunningPrimitiveCheckMethod))) & AllButMarkBitAndTypeMask) << 1;
- if (((((usqInt) fwdBlock)) > (((usqInt) GIV(endOfMemory))))
- && (((((usqInt) fwdBlock)) <= (((usqInt) GIV(fwdTableNext))))
- && ((fwdBlock & 3) == 0))) {
- targetObj = longAt(fwdBlock);
- if (((targetObj & 3) == 0)
- && (((((usqInt)targetObj)) >= heapBase)
- && ((((usqInt)targetObj)) < GIV(freeStart)))) {
- GIV(longRunningPrimitiveCheckMethod) = targetObj;
- }
- else {
- voidLongRunningPrimitive("bad *fwd");
- }
- }
- else {
- voidLongRunningPrimitive("bad fwd->");
- }
+ sqLowLevelMFence();
+ if (GIV(longRunningPrimitiveCheckMethod) != null) {
+ GIV(longRunningPrimitiveCheckMethod) = (GIV(longRunningPrimitiveCheckSequenceNumber) == GIV(statCheckForEvents)
+ ? GIV(newMethod)
+ : remap(GIV(longRunningPrimitiveCheckMethod)));
+ sqLowLevelMFence();
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
  GIV(longRunningPrimitiveCheckSemaphore) = remap(GIV(longRunningPrimitiveCheckSemaphore));
@@ -20247,9 +20232,9 @@
  markAndTrace(GIV(profileProcess));
  markAndTrace(GIV(profileMethod));
  markAndTrace(GIV(profileSemaphore));
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))) {
+ && (GIV(longRunningPrimitiveCheckSequenceNumber) != GIV(statCheckForEvents))) {
  markAndTrace(GIV(longRunningPrimitiveCheckMethod));
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
@@ -32044,6 +32029,7 @@
 primitiveLongRunningPrimitive(void) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt gcms;
+    sqInt lrpcm;
     sqInt primms;
     sqInt result;
     char *sp;
@@ -32055,22 +32041,23 @@
  }
  return;
  }
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveStopUsecs) > GIV(longRunningPrimitiveStartUsecs))
- && ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((((GIV(longRunningPrimitiveCheckMethod) & 3) == 0)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) >= heapBase)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) < GIV(freeStart))
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) != HeaderTypeGC))))
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))))) {
+ && ((((lrpcm = GIV(longRunningPrimitiveCheckMethod))) != null)
+ && ((((lrpcm & 3) == 0)
+ && (((((usqInt)lrpcm)) >= heapBase)
+ && (((((usqInt)lrpcm)) < GIV(freeStart))
+ && (((longAt(lrpcm)) & TypeMask) != HeaderTypeGC))))
+ && ((!(((longAt(lrpcm)) & TypeMask) == HeaderTypeFree))
+ && (((((usqInt) (longAt(lrpcm))) >> 8) & 15) >= 12))))) {
  result = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), 3);
  primms = ((GIV(longRunningPrimitiveStopUsecs) - GIV(longRunningPrimitiveStartUsecs)) + 500) / 1000;
  gcms = (GIV(longRunningPrimitiveGCUsecs) + 500) / 1000;
  /* begin storePointer:ofObject:withValue: */
  if ((((usqInt) result)) < (((usqInt) GIV(youngStart)))) {
- possibleRootStoreIntovalue(result, GIV(longRunningPrimitiveCheckMethod));
+ possibleRootStoreIntovalue(result, lrpcm);
  }
- longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), GIV(longRunningPrimitiveCheckMethod));
+ longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), lrpcm);
  longAtput((result + BaseHeaderSize) + (1 << ShiftForWord), ((primms << 1) | 1));
  longAtput((result + BaseHeaderSize) + (2 << ShiftForWord), ((gcms << 1) | 1));
  }
@@ -44148,6 +44135,7 @@
  GIV(longRunningPrimitiveCheckSequenceNumber) == 0;
  GIV(longRunningPrimitiveStartUsecs) = GIV(longRunningPrimitiveStopUsecs) = 0;
  GIV(longRunningPrimitiveSignalUndelivered) = 1;
+ sqLowLevelMFence();
 }
 
 

Modified: branches/Cog/src/vm/interp.h
===================================================================
--- branches/Cog/src/vm/interp.h 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/src/vm/interp.h 2010-07-16 14:57:02 UTC (rev 2235)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
 
 #define COGVM 1

Modified: branches/Cog/stacksrc/vm/gcc3x-interp.c
===================================================================
--- branches/Cog/stacksrc/vm/gcc3x-interp.c 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/stacksrc/vm/gcc3x-interp.c 2010-07-16 14:57:02 UTC (rev 2235)
@@ -2,11 +2,11 @@
 
 
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
    from
- StackInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ StackInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
-static char __buildInfo[] = "StackInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d " __DATE__ ;
+static char __buildInfo[] = "StackInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -18,8 +18,9 @@
 #endif
 
 #include "sqGnu.h"
-#include <malloc.h> /* for alloca under MSVC */
+#include <stddef.h> /* for e.g. alloca */
 #include <setjmp.h>
+#include "sqMemoryFence.h"
 #include "dispdbg.h"
 
 #include "sqMemoryAccess.h"
@@ -916,7 +917,6 @@
 _iss usqInt memoryLimit;
 _iss StackPage * mostRecentlyUsedPage;
 _iss sqInt needGCFlag;
-_iss sqInt longRunningPrimitiveCheckMethod;
 _iss usqInt scavengeThreshold;
 _iss usqInt fwdTableNext;
 _iss sqInt jmpDepth;
@@ -933,8 +933,10 @@
 _iss sqInt preemptionYields;
 _iss sqInt profileMethod;
 _iss sqInt highestRunnableProcessPriority;
+_iss sqInt longRunningPrimitiveCheckMethod;
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
+_iss sqInt statCheckForEvents;
 _iss sqInt statGrowMemory;
 _iss sqInt statMarkCount;
 _iss sqInt lastMethodCacheProbeWrite;
@@ -946,7 +948,6 @@
 _iss sqInt metaclassSizeBytes;
 _iss sqInt pendingFinalizationSignals;
 _iss sqInt shrinkThreshold;
-_iss sqInt statCheckForEvents;
 _iss sqInt statShrinkMemory;
 _iss usqInt fwdTableLast;
 _iss usqLong gcStartUsecs;
@@ -956,6 +957,7 @@
 _iss sqInt edenBytes;
 _iss sqInt forceTenureFlag;
 _iss sqInt interruptPending;
+_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt signalLowSpace;
 _iss sqInt statForceInterruptCheck;
 _iss usqLong statFullGCUsecs;
@@ -983,7 +985,6 @@
 _iss sqInt gcBiasToGrowGCLimit;
 _iss sqInt gcSemaphoreIndex;
 _iss sqInt imageFloatsBigEndian;
-_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt longRunningPrimitiveSignalUndelivered;
 _iss usqLong nextPollUsecs;
 _iss StackPage * overflowedPage;
@@ -1614,7 +1615,7 @@
  0 };
 char * breakSelector;
 sqInt breakSelectorLength = -1;
-const char *interpreterVersion = "Croquet Closure Stack VM [StackInterpreter VMMaker-oscog.20]";
+const char *interpreterVersion = "Croquet Closure Stack VM [StackInterpreter VMMaker-oscog.23]";
 static volatile int sendTrace;
 sqInt suppressHeartbeatFlag;
 
@@ -13501,9 +13502,10 @@
  goto l1;
  }
  if (GIV(longRunningPrimitiveStopUsecs) == 0) {
+ GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
  GIV(longRunningPrimitiveCheckMethod) = GIV(newMethod);
  GIV(longRunningPrimitiveStartUsecs) = ioUTCMicroseconds();
- GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
+ sqLowLevelMFence();
  }
  l1: /* end checkForLongRunningPrimitive */;
  forceInterruptCheck();
@@ -16275,14 +16277,12 @@
 mapPointersInObjectsFromto(sqInt memStart, sqInt memEnd) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt aMethodObj;
-    sqInt fwdBlock;
     sqInt i;
     sqInt i1;
     sqInt i2;
     sqInt oop;
     sqInt oop1;
     sqInt probe;
-    sqInt targetObj;
 
  /* begin mapInterpreterOops */
  VM_LABEL(0mapInterpreterOops);
@@ -16309,37 +16309,22 @@
  GIV(newMethod) = remap(GIV(newMethod));
  GIV(lkupClass) = remap(GIV(lkupClass));
  /* begin mapProfileState */
- VM_LABEL(0mapProfileState);
  GIV(profileProcess) = remap(GIV(profileProcess));
  GIV(profileMethod) = remap(GIV(profileMethod));
 
- /* Since the longRunningPrimitiveCheckMethod is sampled at interrupt time it may be invalid.
- Be very careful with it. */
+ /* The longRunningPrimitiveCheckMethod (LRPCM) is sampled in an interrupt.  Be very careful with it.
+  If longRunningPrimitiveCheckSequenceNumber (LRPCSN) = statCheckForEvents then LRPCM has
+  been recenty sampled and could be mapped or not, but it must be newMethod and we can simply
+  copy newMethod.  If LRPCSN ~= statCheckForEvents then LRPCM must be some extant object and
+  needs to be remapped. */
 
  GIV(profileSemaphore) = remap(GIV(profileSemaphore));
- if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && (((GIV(longRunningPrimitiveCheckMethod) & 1) == 0)
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & MarkBit) != 0))) {
-
- /* If it is invalid at this point we'd better nil it. */
-
- fwdBlock = ((longAt(GIV(longRunningPrimitiveCheckMethod))) & AllButMarkBitAndTypeMask) << 1;
- if (((((usqInt) fwdBlock)) > (((usqInt) GIV(endOfMemory))))
- && (((((usqInt) fwdBlock)) <= (((usqInt) GIV(fwdTableNext))))
- && ((fwdBlock & 3) == 0))) {
- targetObj = longAt(fwdBlock);
- if (((targetObj & 3) == 0)
- && (((((usqInt)targetObj)) >= memory)
- && ((((usqInt)targetObj)) < GIV(freeStart)))) {
- GIV(longRunningPrimitiveCheckMethod) = targetObj;
- }
- else {
- voidLongRunningPrimitive("bad *fwd");
- }
- }
- else {
- voidLongRunningPrimitive("bad fwd->");
- }
+ sqLowLevelMFence();
+ if (GIV(longRunningPrimitiveCheckMethod) != null) {
+ GIV(longRunningPrimitiveCheckMethod) = (GIV(longRunningPrimitiveCheckSequenceNumber) == GIV(statCheckForEvents)
+ ? GIV(newMethod)
+ : remap(GIV(longRunningPrimitiveCheckMethod)));
+ sqLowLevelMFence();
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
  GIV(longRunningPrimitiveCheckSemaphore) = remap(GIV(longRunningPrimitiveCheckSemaphore));
@@ -16552,9 +16537,9 @@
  markAndTrace(GIV(profileProcess));
  markAndTrace(GIV(profileMethod));
  markAndTrace(GIV(profileSemaphore));
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))) {
+ && (GIV(longRunningPrimitiveCheckSequenceNumber) != GIV(statCheckForEvents))) {
  markAndTrace(GIV(longRunningPrimitiveCheckMethod));
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
@@ -27870,6 +27855,7 @@
 primitiveLongRunningPrimitive(void) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt gcms;
+    sqInt lrpcm;
     sqInt primms;
     sqInt result;
     char *sp;
@@ -27881,22 +27867,23 @@
  }
  return;
  }
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveStopUsecs) > GIV(longRunningPrimitiveStartUsecs))
- && ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((((GIV(longRunningPrimitiveCheckMethod) & 3) == 0)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) >= memory)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) < GIV(freeStart))
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) != HeaderTypeGC))))
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))))) {
+ && ((((lrpcm = GIV(longRunningPrimitiveCheckMethod))) != null)
+ && ((((lrpcm & 3) == 0)
+ && (((((usqInt)lrpcm)) >= memory)
+ && (((((usqInt)lrpcm)) < GIV(freeStart))
+ && (((longAt(lrpcm)) & TypeMask) != HeaderTypeGC))))
+ && ((!(((longAt(lrpcm)) & TypeMask) == HeaderTypeFree))
+ && (((((usqInt) (longAt(lrpcm))) >> 8) & 15) >= 12))))) {
  result = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), 3);
  primms = ((GIV(longRunningPrimitiveStopUsecs) - GIV(longRunningPrimitiveStartUsecs)) + 500) / 1000;
  gcms = (GIV(longRunningPrimitiveGCUsecs) + 500) / 1000;
  /* begin storePointer:ofObject:withValue: */
  if ((((usqInt) result)) < (((usqInt) GIV(youngStart)))) {
- possibleRootStoreIntovalue(result, GIV(longRunningPrimitiveCheckMethod));
+ possibleRootStoreIntovalue(result, lrpcm);
  }
- longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), GIV(longRunningPrimitiveCheckMethod));
+ longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), lrpcm);
  longAtput((result + BaseHeaderSize) + (1 << ShiftForWord), ((primms << 1) | 1));
  longAtput((result + BaseHeaderSize) + (2 << ShiftForWord), ((gcms << 1) | 1));
  }
@@ -38779,6 +38766,7 @@
  GIV(longRunningPrimitiveCheckSequenceNumber) == 0;
  GIV(longRunningPrimitiveStartUsecs) = GIV(longRunningPrimitiveStopUsecs) = 0;
  GIV(longRunningPrimitiveSignalUndelivered) = 1;
+ sqLowLevelMFence();
 }
 
 

Modified: branches/Cog/stacksrc/vm/interp.c
===================================================================
--- branches/Cog/stacksrc/vm/interp.c 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/stacksrc/vm/interp.c 2010-07-16 14:57:02 UTC (rev 2235)
@@ -1,9 +1,9 @@
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
    from
- StackInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ StackInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
-static char __buildInfo[] = "StackInterpreter VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d " __DATE__ ;
+static char __buildInfo[] = "StackInterpreter VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4 " __DATE__ ;
 char *__interpBuildInfo = __buildInfo;
 
 
@@ -15,8 +15,9 @@
 #endif
 
 #include "sq.h"
-#include <malloc.h> /* for alloca under MSVC */
+#include <stddef.h> /* for e.g. alloca */
 #include <setjmp.h>
+#include "sqMemoryFence.h"
 #include "dispdbg.h"
 
 #include "sqMemoryAccess.h"
@@ -913,7 +914,6 @@
 _iss usqInt memoryLimit;
 _iss StackPage * mostRecentlyUsedPage;
 _iss sqInt needGCFlag;
-_iss sqInt longRunningPrimitiveCheckMethod;
 _iss usqInt scavengeThreshold;
 _iss usqInt fwdTableNext;
 _iss sqInt jmpDepth;
@@ -930,8 +930,10 @@
 _iss sqInt preemptionYields;
 _iss sqInt profileMethod;
 _iss sqInt highestRunnableProcessPriority;
+_iss sqInt longRunningPrimitiveCheckMethod;
 _iss usqLong longRunningPrimitiveStartUsecs;
 _iss usqLong longRunningPrimitiveStopUsecs;
+_iss sqInt statCheckForEvents;
 _iss sqInt statGrowMemory;
 _iss sqInt statMarkCount;
 _iss sqInt lastMethodCacheProbeWrite;
@@ -943,7 +945,6 @@
 _iss sqInt metaclassSizeBytes;
 _iss sqInt pendingFinalizationSignals;
 _iss sqInt shrinkThreshold;
-_iss sqInt statCheckForEvents;
 _iss sqInt statShrinkMemory;
 _iss usqInt fwdTableLast;
 _iss usqLong gcStartUsecs;
@@ -953,6 +954,7 @@
 _iss sqInt edenBytes;
 _iss sqInt forceTenureFlag;
 _iss sqInt interruptPending;
+_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt signalLowSpace;
 _iss sqInt statForceInterruptCheck;
 _iss usqLong statFullGCUsecs;
@@ -980,7 +982,6 @@
 _iss sqInt gcBiasToGrowGCLimit;
 _iss sqInt gcSemaphoreIndex;
 _iss sqInt imageFloatsBigEndian;
-_iss sqInt longRunningPrimitiveCheckSequenceNumber;
 _iss sqInt longRunningPrimitiveSignalUndelivered;
 _iss usqLong nextPollUsecs;
 _iss StackPage * overflowedPage;
@@ -1611,7 +1612,7 @@
  0 };
 char * breakSelector;
 sqInt breakSelectorLength = -1;
-const char *interpreterVersion = "Croquet Closure Stack VM [StackInterpreter VMMaker-oscog.20]";
+const char *interpreterVersion = "Croquet Closure Stack VM [StackInterpreter VMMaker-oscog.23]";
 static volatile int sendTrace;
 sqInt suppressHeartbeatFlag;
 
@@ -13497,9 +13498,10 @@
  goto l1;
  }
  if (GIV(longRunningPrimitiveStopUsecs) == 0) {
+ GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
  GIV(longRunningPrimitiveCheckMethod) = GIV(newMethod);
  GIV(longRunningPrimitiveStartUsecs) = ioUTCMicroseconds();
- GIV(longRunningPrimitiveCheckSequenceNumber) = GIV(statCheckForEvents);
+ sqLowLevelMFence();
  }
  l1: /* end checkForLongRunningPrimitive */;
  forceInterruptCheck();
@@ -16271,14 +16273,12 @@
 mapPointersInObjectsFromto(sqInt memStart, sqInt memEnd) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt aMethodObj;
-    sqInt fwdBlock;
     sqInt i;
     sqInt i1;
     sqInt i2;
     sqInt oop;
     sqInt oop1;
     sqInt probe;
-    sqInt targetObj;
 
  /* begin mapInterpreterOops */
  VM_LABEL(0mapInterpreterOops);
@@ -16305,37 +16305,22 @@
  GIV(newMethod) = remap(GIV(newMethod));
  GIV(lkupClass) = remap(GIV(lkupClass));
  /* begin mapProfileState */
- VM_LABEL(0mapProfileState);
  GIV(profileProcess) = remap(GIV(profileProcess));
  GIV(profileMethod) = remap(GIV(profileMethod));
 
- /* Since the longRunningPrimitiveCheckMethod is sampled at interrupt time it may be invalid.
- Be very careful with it. */
+ /* The longRunningPrimitiveCheckMethod (LRPCM) is sampled in an interrupt.  Be very careful with it.
+  If longRunningPrimitiveCheckSequenceNumber (LRPCSN) = statCheckForEvents then LRPCM has
+  been recenty sampled and could be mapped or not, but it must be newMethod and we can simply
+  copy newMethod.  If LRPCSN ~= statCheckForEvents then LRPCM must be some extant object and
+  needs to be remapped. */
 
  GIV(profileSemaphore) = remap(GIV(profileSemaphore));
- if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && (((GIV(longRunningPrimitiveCheckMethod) & 1) == 0)
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & MarkBit) != 0))) {
-
- /* If it is invalid at this point we'd better nil it. */
-
- fwdBlock = ((longAt(GIV(longRunningPrimitiveCheckMethod))) & AllButMarkBitAndTypeMask) << 1;
- if (((((usqInt) fwdBlock)) > (((usqInt) GIV(endOfMemory))))
- && (((((usqInt) fwdBlock)) <= (((usqInt) GIV(fwdTableNext))))
- && ((fwdBlock & 3) == 0))) {
- targetObj = longAt(fwdBlock);
- if (((targetObj & 3) == 0)
- && (((((usqInt)targetObj)) >= memory)
- && ((((usqInt)targetObj)) < GIV(freeStart)))) {
- GIV(longRunningPrimitiveCheckMethod) = targetObj;
- }
- else {
- voidLongRunningPrimitive("bad *fwd");
- }
- }
- else {
- voidLongRunningPrimitive("bad fwd->");
- }
+ sqLowLevelMFence();
+ if (GIV(longRunningPrimitiveCheckMethod) != null) {
+ GIV(longRunningPrimitiveCheckMethod) = (GIV(longRunningPrimitiveCheckSequenceNumber) == GIV(statCheckForEvents)
+ ? GIV(newMethod)
+ : remap(GIV(longRunningPrimitiveCheckMethod)));
+ sqLowLevelMFence();
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
  GIV(longRunningPrimitiveCheckSemaphore) = remap(GIV(longRunningPrimitiveCheckSemaphore));
@@ -16548,9 +16533,9 @@
  markAndTrace(GIV(profileProcess));
  markAndTrace(GIV(profileMethod));
  markAndTrace(GIV(profileSemaphore));
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))) {
+ && (GIV(longRunningPrimitiveCheckSequenceNumber) != GIV(statCheckForEvents))) {
  markAndTrace(GIV(longRunningPrimitiveCheckMethod));
  }
  if (GIV(longRunningPrimitiveCheckSemaphore) != null) {
@@ -27866,6 +27851,7 @@
 primitiveLongRunningPrimitive(void) {
 DECL_MAYBE_SQ_GLOBAL_STRUCT
     sqInt gcms;
+    sqInt lrpcm;
     sqInt primms;
     sqInt result;
     char *sp;
@@ -27877,22 +27863,23 @@
  }
  return;
  }
+ sqLowLevelMFence();
  if ((GIV(longRunningPrimitiveStopUsecs) > GIV(longRunningPrimitiveStartUsecs))
- && ((GIV(longRunningPrimitiveCheckMethod) != null)
- && ((((GIV(longRunningPrimitiveCheckMethod) & 3) == 0)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) >= memory)
- && (((((usqInt)GIV(longRunningPrimitiveCheckMethod))) < GIV(freeStart))
- && (((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) != HeaderTypeGC))))
- && ((!(((longAt(GIV(longRunningPrimitiveCheckMethod))) & TypeMask) == HeaderTypeFree))
- && (((((usqInt) (longAt(GIV(longRunningPrimitiveCheckMethod)))) >> 8) & 15) >= 12))))) {
+ && ((((lrpcm = GIV(longRunningPrimitiveCheckMethod))) != null)
+ && ((((lrpcm & 3) == 0)
+ && (((((usqInt)lrpcm)) >= memory)
+ && (((((usqInt)lrpcm)) < GIV(freeStart))
+ && (((longAt(lrpcm)) & TypeMask) != HeaderTypeGC))))
+ && ((!(((longAt(lrpcm)) & TypeMask) == HeaderTypeFree))
+ && (((((usqInt) (longAt(lrpcm))) >> 8) & 15) >= 12))))) {
  result = instantiateClassindexableSize(longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (ClassArray << ShiftForWord)), 3);
  primms = ((GIV(longRunningPrimitiveStopUsecs) - GIV(longRunningPrimitiveStartUsecs)) + 500) / 1000;
  gcms = (GIV(longRunningPrimitiveGCUsecs) + 500) / 1000;
  /* begin storePointer:ofObject:withValue: */
  if ((((usqInt) result)) < (((usqInt) GIV(youngStart)))) {
- possibleRootStoreIntovalue(result, GIV(longRunningPrimitiveCheckMethod));
+ possibleRootStoreIntovalue(result, lrpcm);
  }
- longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), GIV(longRunningPrimitiveCheckMethod));
+ longAtput((result + BaseHeaderSize) + (0 << ShiftForWord), lrpcm);
  longAtput((result + BaseHeaderSize) + (1 << ShiftForWord), ((primms << 1) | 1));
  longAtput((result + BaseHeaderSize) + (2 << ShiftForWord), ((gcms << 1) | 1));
  }
@@ -38775,6 +38762,7 @@
  GIV(longRunningPrimitiveCheckSequenceNumber) == 0;
  GIV(longRunningPrimitiveStartUsecs) = GIV(longRunningPrimitiveStopUsecs) = 0;
  GIV(longRunningPrimitiveSignalUndelivered) = 1;
+ sqLowLevelMFence();
 }
 
 

Modified: branches/Cog/stacksrc/vm/interp.h
===================================================================
--- branches/Cog/stacksrc/vm/interp.h 2010-07-14 01:10:33 UTC (rev 2234)
+++ branches/Cog/stacksrc/vm/interp.h 2010-07-16 14:57:02 UTC (rev 2235)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker-oscog.20 uuid: 528a9b5e-293c-4fac-9430-1eabdb0d278d
+ CCodeGeneratorGlobalStructure VMMaker-oscog.23 uuid: 1a50a139-43f0-421d-bc43-590dd9343bc4
  */
 
 #define STACKVM 1