[M3commit] CVS Update: cm3

Jay K jay.krell at cornell.edu
Tue Mar 5 06:40:06 CET 2013


Doesn't quite work, but is disabled. I have to debug it and then enable it later..


Index: misc/Marker.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3front/src/misc/Marker.m3,v
retrieving revision 1.10
diff -u -r1.10 Marker.m3
--- misc/Marker.m3    11 Feb 2011 20:57:57 -0000    1.10
+++ misc/Marker.m3    5 Mar 2013 05:36:32 -0000
@@ -232,7 +232,9 @@
   END CallFinallyHandler;
 
 PROCEDURE CaptureState (frame: CG.Var;  handler: CG.Label) =
+  CONST Alloca_jmpbuf = FALSE;
   VAR new: BOOLEAN;
+      label_already_allocated: CG.Label;
   BEGIN
     (* int setjmp(void* ); *)
     IF (setjmp = NIL) THEN
@@ -246,8 +248,51 @@
                                f := CG.Never);
       END;
     END;
+    
+    IF Alloca_jmpbuf THEN
+      label_already_allocated := CG.Next_label ();
+
+      (* void* _alloca(size_t); *)
+      IF (alloca = NIL) THEN
+        alloca := CG.Import_procedure (M3ID.Add ("m3_alloca"), 1, CG.Type.Addr,
+                                       Target.DefaultCall, new);
+        IF (new) THEN
+          EVAL CG.Declare_param (M3ID.NoID, Target.Word.size, Target.Word.align,
+                                 Target.Word.cg_type, 0, in_memory := FALSE,
+                                 up_level := FALSE, f := CG.Never);
+        END;
+      END;
+      (* extern /*const*/ size_t Csetjmp__Jumpbuf_size/* = sizeof(jmp_buf)*/; *)
+      IF (Jumpbuf_size = NIL) THEN
+        Jumpbuf_size := CG.Import_global (M3ID.Add ("Csetjmp__Jumpbuf_size"),
+                                          Target.Word.size, Target.Word.align,
+                                          Target.Word.cg_type, 0);
+      END;
+    
+      (* if (!frame.jmpbuf)
+           frame.jmpbuf = alloca(Csetjmp__Jumpbuf_size);
+      *)
+      CG.Load_addr (frame, M3RT.EF1_jmpbuf);
+      CG.Load_nil ();
+      CG.If_compare (Target.Address.cg_type, CG.Cmp.NE, label_already_allocated, CG.Likely);
+
+      CG.Start_call_direct (alloca, 0, Target.Address.cg_type);
+      CG.Load_int (Target.Word.cg_type, Jumpbuf_size);
+      CG.Pop_param (Target.Word.cg_type);
+      CG.Call_direct (alloca, Target.Address.cg_type);
+      CG.Check_nil (CG.RuntimeError.BadMemoryReference);
+      CG.Store_addr (frame, M3RT.EF1_jmpbuf);
+
+      CG.Set_label (label_already_allocated);
+    END;
+
+    (* setjmp(frame.jmpbuf) or setjmp(&frame.jmpbuf) *)
     CG.Start_call_direct (setjmp, 0, Target.Integer.cg_type);
-    CG.Load_addr_of (frame, M3RT.EF1_jmpbuf, 64);
+    IF Alloca_jmpbuf THEN
+      CG.Load_addr (frame, M3RT.EF1_jmpbuf);
+    ELSE
+      CG.Load_addr_of (frame, M3RT.EF1_jmpbuf, 64);
+    END;
     CG.Pop_param (CG.Type.Addr);
     CG.Call_direct (setjmp, Target.Integer.cg_type);
     CG.If_true (handler, CG.Never);





> Date: Tue, 5 Mar 2013 06:37:33 +0000
> To: m3commit at elegosoft.com
> From: jkrell at elego.de
> Subject: [M3commit] CVS Update: cm3
> 
> CVSROOT:	/usr/cvs
> Changes by:	jkrell at birch.	13/03/05 06:37:33
> 
> Modified files:
> 	cm3/m3-sys/m3front/src/misc/: Marker.m3 
> 
> Log message:
> 	The change to remove knowledge of jmpbuf size from cm3.
> 	But as yet disabled with a const boolean enable_foo = false.
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20130305/ce780560/attachment-0002.html>


More information about the M3commit mailing list