[M3devel] frontend misses a few types

Jay K jay.krell at cornell.edu
Fri Apr 19 06:24:19 CEST 2013


Here is a smaller fix that fixes more cases, i.e. large sets and fixed sized arrays.


Index: values/Formal.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3front/src/values/Formal.m3,v
retrieving revision 1.18
diff -u -r1.18 Formal.m3
--- values/Formal.m3    26 Sep 2012 17:12:37 -0000    1.18
+++ values/Formal.m3    19 Apr 2013 04:19:55 -0000
@@ -470,6 +470,7 @@
       CG.Pop_param (CG.Type.Addr)
     ELSIF (is_struct) THEN
       EVAL Type.CheckInfo (t.tipe, info);
+      Type.Compile (t.tipe);
       CG.Pop_struct (Type.GlobalUID (t.tipe), info.size, info.alignment);
     ELSE (* by-value scalar *)
       CG.Pop_param (Type.CGType (t.tipe, in_memory := TRUE));


 - Jay


From: jay.krell at cornell.edu
To: m3devel at elegosoft.com
Date: Wed, 17 Apr 2013 16:24:51 +0000
Subject: Re: [M3devel] frontend misses a few types




ok, so this fixes it.
I still have to build everything to verify.
But which of the two lines is right? Both?
And what about the comment about the assert?
And what about other types like fixed size arrays? I'll try them.

===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3front/src/values/Formal.m3,v
retrieving revision 1.18
diff -u -r1.18 Formal.m3
--- Formal.m3    26 Sep 2012 17:12:37 -0000    1.18
+++ Formal.m3    17 Apr 2013 16:23:29 -0000
@@ -600,6 +600,8 @@
 PROCEDURE GenRecord (t: T;  actual: Expr.T) =
   BEGIN
     (* <* ASSERT Type.IsEqual (t.tipe, Expr.TypeOf (actual), NIL) *> *)
+    Type.Compile (t.tipe);
+    Type.Compile (Expr.TypeOf (actual));
     CASE t.mode OF
     | Mode.mVALUE =>
         Expr.Compile (actual);


PROCEDURE GenRecord (t: T;  actual: Expr.T) =
  BEGIN
    (* <* ASSERT Type.IsEqual (t.tipe, Expr.TypeOf (actual), NIL) *> *)
    Type.Compile (t.tipe);
    Type.Compile (Expr.TypeOf (actual));
    CASE t.mode OF
    | Mode.mVALUE =>
        Expr.Compile (actual);
    | Mode.mVAR =>
        Expr.CompileAddress (actual, traced := TRUE);
    | Mode.mCONST =>
        IF Expr.IsDesignator (actual) THEN
          Expr.CompileAddress (actual, traced := FALSE);
        ELSE
          Expr.Compile (actual);
          (* not needed because of the ASSERT above: GenCopy (t.tipe); *)
        END;
    END;
  END GenRecord;




From: jay.krell at cornell.edu
To: m3devel at elegosoft.com
Date: Wed, 17 Apr 2013 02:47:47 +0000
Subject: Re: [M3devel] frontend misses a few types




In the frontend, when pop_struct is called, is that too late to declare_record? To compile the type, is it?



#0  M3CG_MultiPass__pop_struct (self_L_1033=0x101551758 "", m3_typeid_L_1034=1557134085, byte_size_L_1035=8, alignment_L_1036=8) at M3CG_MultiPass.m3.c:38639
#1  0x000000010044718a in M3CG_Check__pop_struct (self_L_369=0x1015525b8, t_L_370=1557134085, s_L_371=8, a_L_372=8) at M3CG_Check.m3.c:34613
#2  0x000000010024a584 in CG__Pop_struct (t_L_578=1557134085, s_L_579=64, a_L_580=64) at CG.m3.c:83537
#3  0x00000001002ddcd7 in Formal__EmitArg (proc_L_215=0x10151e4c8 "??h", formal_L_216=0x10151c7a0 "?Bj", actual_L_217=0x10151c758 "??h") at Formal.m3.c:15818
#4  0x00000001002c3aa7 in UserProc (ce_L_148=0x10151e540 "@\034\020\001\001") at UserProc.m3.c:5026
#5  0x000000010019b893 in CallExpr (p_L_149=0x10151e540 "@\034\020\001\001") at CallExpr.m3.c:12276
#6  0x0000000100186765 in Expr (t_L_126=0x10151e540 "@\034\020\001\001") at Expr.m3.c:4085
#7  0x000000010025a70f in CallStmt__Compile (p_L_36=0x10151e598) at CallStmt.m3.c:1411
#8  0x0000000100252d32 in Stmt__Compile (t_L_43=0x10151e598 "??i") at Stmt.m3.c:2881
#9  0x0000000100259e79 in BlockStmt__Compile (p_L_69=0x10151e320) at BlockStmt.m3.c:4642
#10 0x0000000100252d32 in Stmt__Compile (t_L_43=0x10151e320 "إi") at Stmt.m3.c:2881
#11 0x00000001002f35b5 in Procedure__GenBody (p_L_318=0x10151e0b0 "?`j") at Procedure.m3.c:21223
#12 0x00000001002f38ec in Procedure__EmitBody (x_L_310=0x10151e268) at Procedure.m3.c:19937
#13 0x00000001002275b3 in ProcBody__EmitBody (t_L_64=0x10151e268 "?\030\020\001\001") at ProcBody.m3.c:6940
#14 0x000000010022794d in ProcBody__EmitAll (proc_info_L_56=0x7fff5fbfdeb8) at ProcBody.m3.c:2822
#15 0x00000001002e73d6 in Module__CompileModule (t_L_379=0x101512fe0 "?Xj") at Module.m3.c:25364
#16 0x00000001002eafe8 in Module__Compile (t_L_283=0x101512fe0 "?Xj") at Module.m3.c:23264
#17 0x00000001001f78df in M3Front__DoCompile () at M3Front.m3.c:7176
#18 0x00000001001f8391 in M3Front__Compile (input_L_88=0x7fff5fbfe150, env_L_89=0x1013910a8, options_L_90=0x101355840) at M3Front.m3.c:3827
#19 0x0000000100021886 in Builder__RunM3 (s_L_494=0x10136fdb0, u_L_495=0x1012df768, object_L_496=0x1013557a0 "??n") at Builder.m3.c:56168
#20 0x0000000100022bac in Builder__PushOneM3 (s_L_444=0x10136fdb0, u_L_445=0x1012df768) at Builder.m3.c:48299
#21 0x0000000100023cb5 in Builder__CompileM3 (s_L_423=0x10136fdb0, u_L_424=0x1012df768) at Builder.m3.c:45901
#22 0x000000010001ea71 in Builder__CompileOne (s_L_404=0x10136fdb0, u_L_405=0x1012df768) at Builder.m3.c



 - Jay



From: jay.krell at cornell.edu
To: m3devel at elegosoft.com
Date: Wed, 17 Apr 2013 02:32:15 +0000
Subject: Re: [M3devel] frontend misses a few types




Here is what it looks like:


INTERFACE VBT;

TYPE VBT_T = OBJECT METHODS
init(op: PaintOp_T := PaintOp_TransparentSwap;
     txt: Pixmap_T := Pixmap_Gray;
     READONLY delta := Point_T{0});
END;

TYPE Pixmap_T = RECORD Pixmap_T_field: INTEGER END;
CONST Pixmap_Gray = Pixmap_T{1};

TYPE PaintOp_T = RECORD PaintOp_T_field:INTEGER END;
CONST PaintOp_Swap = PaintOp_T{2};
CONST PaintOp_TransparentSwap = PaintOp_T{3};

TYPE Point_T = RECORD Point_T_field: INTEGER END;

END VBT.



INTERFACE HighlightVBT;

IMPORT VBT;
TYPE HighlightVBT_T <: VBT.VBT_T;

END HighlightVBT.



MODULE Main;
IMPORT HighlightVBT;

PROCEDURE Main() =
BEGIN
    NEW(HighlightVBT.HighlightVBT_T).init();
    NEW(HighlightVBT.HighlightVBT_T).init();
END Main;


BEGIN
    Main();
END Main.



unit Main does not receive declare_record for 
  PaintOp_T
  Pixmap_T
  and maybe Point_T

It is somewhat obvious why.
VBT is not directly imported by Main.


Point_T is passed by reference, so the backend can inject
a simple forward declaration:
struct T123; typedef struct T123 T123;


But PaintOp_T and Pixmap_T are passed by value
and it is desirable to have them fully defined, so I can use C's pass by struct by value feature.



Furthermore, multiple calls to init() generate multiple
instances of Point_T{0}.


Anyone interested in fixing it? I'll debug it probably..


 - Jay




From: jay.krell at cornell.edu
To: m3devel at elegosoft.com
Date: Tue, 16 Apr 2013 01:28:16 +0000
Subject: [M3devel] frontend misses a few types




It'd be great to fix this in the frontend.


jbook2:p255 jay$ rm -rf AMD64_DARWIN && /dev2/cm3/m3-sys/cm3/AMD64_DARWIN/cm3 -keep
--- building in AMD64_DARWIN ---

ReadWish /cm3/pkg/libm3/AMD64_DARWIN/libm3.a ffffffffe90634a6
new source -> compiling VBT.i3
new source -> compiling HighlightVBT.i3
new source -> compiling HighlightVBT.m3
new source -> compiling Main.m3
warning: pop_struct: unknown typeid:T79A5AEBB
warning: pop_struct: unknown typeid:T23E73F69
 -> linking pgm
./pgm >stdout.pgm.raw 2>stderr.pgm.raw
jbook2:p255 jay$ pwd
/dev2/cm3/m3-sys/m3tests/src/p2/p255


Also, in this example, each call creates another copy of the default parameter in the module globals.
That should be optimized in the frontend.
The test case here is really small.


 - Jay


> Date: Tue, 16 Apr 2013 03:21:25 +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/04/16 03:21:25
> 
> Added files:
> 	cm3/m3-sys/m3tests/src/p2/p255/: HighlightVBT.i3 HighlightVBT.m3 
> 	                                 Main.m3 VBT.i3 m3makefile 
> 
> Log message:
> 	This test case demonstrates a problem
> 	where the frontend doesn't describe all the types
> 	to the backend. And also where it doesn't single-instance
> 	constants that it could/should.
> 	
> 	It is adapted from Trestle and a little of libm3.
> 	It is reduced very much.
> 
 		 	   		   		 	   		   		 	   		   		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130419/a09492f0/attachment-0002.html>


More information about the M3devel mailing list