On 25/06/11 00:50, Khint Enco wrote:
Misfire! No, that 'patch' does nothing ..

I've added a -nosync flag to the compiler (v2.053) that removes all the effects of synchronized. It has been tested and I ran all unittests, or at least I think I did .. it took less than half a second ..

It's a small patch, but does anyone mind checking it?
diff --git a/func.c b/func.c
--- a/func.c
+++ b/func.c
@@ -183,8 +183,8 @@
             stc |= STCimmutable;
         if (type->isConst())
             stc |= STCconst;
-        if (type->isShared() || storage_class & STCsynchronized)
-            stc |= STCshared;
+        if (type->isShared() || (!global.params.nosync && (storage_class & STCsynchronized)))
+           stc |= STCshared;
         if (type->isWild())
             stc |= STCwild;
         switch (stc & STC_TYPECTOR)
diff --git a/mars.c b/mars.c
--- a/mars.c
+++ b/mars.c
@@ -285,6 +285,7 @@
   -map           generate linker .map file\n\
   -noboundscheck turns off array bounds checking for all functions\n\
   -nofloat       do not emit reference to floating point\n\
+  -nosync        disable the effects of synchronized statements\n\
   -O             optimize\n\
   -o-            do not write object file\n\
   -odobjdir      write object & library files to directory objdir\n\
@@ -694,6 +695,10 @@
                 setdebuglib = 1;
                 global.params.debuglibname = p + 1 + 9;
             }
+            else if (memcmp(p + 1, "nosync", 7) == 0)
+            {
+                global.params.nosync = 1;
+            }
             else if (memcmp(p + 1, "deps=", 5) == 0)
             {
                 global.params.moduleDepsFile = p + 1 + 5;
diff --git a/mars.h b/mars.h
--- a/mars.h
+++ b/mars.h
@@ -163,6 +163,7 @@
     char pic;           // generate position-independent-code for shared libs
     char cov;           // generate code coverage data
     char nofloat;       // code should not pull in floating point support
+    char nosync;        // code should remove effects of synchronized
     char Dversion;      // D version number
     char ignoreUnsupportedPragmas;      // rather than error on them
 
diff --git a/s2ir.c b/s2ir.c
--- a/s2ir.c
+++ b/s2ir.c
@@ -1595,7 +1595,7 @@
 
 void SynchronizedStatement::toIR(IRState *irs)
 {
-    assert(0);
+    assert(global.params.nosync);
 }
 
 
diff --git a/statement.c b/statement.c
--- a/statement.c
+++ b/statement.c
@@ -3855,9 +3855,10 @@
     return s;
 }
 
+
 Statement *SynchronizedStatement::semantic(Scope *sc)
 {
-    if (exp)
+    if (!global.params.nosync && exp)
     {
         exp = exp->semantic(sc);
         exp = resolveProperties(sc, exp);
@@ -3905,7 +3906,7 @@
 #endif
     }
 #if 1
-    else
+    else if(!global.params.nosync)
     {   /* Generate our own critical section, then rewrite as:
          *  __gshared byte[CriticalSection.sizeof] critsec;
          *  _d_criticalenter(critsec.ptr);

Reply via email to