From jkrell at elego.de Sat Mar 2 04:12:57 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 2 Mar 2013 4:12:57 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130302031258.0290A5DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/02 04:12:57 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: work in progress -- properly declare structs/records When done, this will provide excellent debugability esp. on systems that don't support m3gdb (NT, Darwin, HP-UX). From jkrell at elego.de Sat Mar 2 04:15:13 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 2 Mar 2013 4:15:13 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130302031513.877FF5DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/02 04:15:13 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: remove whitespace from ends of linese From jkrell at elego.de Mon Mar 4 19:16:30 2013 From: jkrell at elego.de (Jay Krell) Date: Mon, 4 Mar 2013 19:16:30 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130304181630.EFC295DEAB1@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/04 19:16:30 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: work in progress, significantly along enums, typenames, records problems still: the output is out of order, types are referenced before being defined; we need to detect that and reorder as needed I'm not yet handling everything e.g. indirect, packed, object, method. some issues with TypeUID vs. INTEGER From jkrell at elego.de Tue Mar 5 06:37:33 2013 From: jkrell at elego.de (Jay Krell) Date: Tue, 5 Mar 2013 6:37:33 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130305053733.A76E35DEA96@birch.elegosoft.com> 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. From jay.krell at cornell.edu Tue Mar 5 06:40:06 2013 From: jay.krell at cornell.edu (Jay K) Date: Tue, 5 Mar 2013 05:40:06 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130305053733.A76E35DEA96@birch.elegosoft.com> References: <20130305053733.A76E35DEA96@birch.elegosoft.com> Message-ID: 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: From jkrell at elego.de Thu Mar 14 06:01:23 2013 From: jkrell at elego.de (Jay Krell) Date: Thu, 14 Mar 2013 6:01:23 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130314050123.408455DEB73@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/14 06:01:23 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: reversse-duplicate the logic of the frontend in determining cg_type for subranges because it fails to pass it down itself..lame.. From jay.krell at cornell.edu Thu Mar 14 06:00:40 2013 From: jay.krell at cornell.edu (Jay K) Date: Thu, 14 Mar 2013 05:00:40 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130314050123.408455DEB73@birch.elegosoft.com> References: <20130314050123.408455DEB73@birch.elegosoft.com> Message-ID: backends shouldn't have to do this.. +PROCEDURE SubrangeCGType(READONLY min, max: Target.Int; bit_size: BitSize): M3CG.Type = +(* duplicate the logic of m3front/src/types/SubrangeType; + m3front should pass us down cg_type directly, and not + bother with bit_size, domain *) +BEGIN + IF TInt.EQ(min, TInt.Zero) AND TInt.EQ(max, TInt.MOne) THEN + RETURN BitsToCGInt[bit_size]; + END; + IF TInt.LE(TInt.Zero, min) THEN + RETURN BitsToCGUInt[bit_size]; + END; + RETURN BitsToCGInt[bit_size]; +END SubrangeCGType; > Date: Thu, 14 Mar 2013 06:01:23 +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/14 06:01:23 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > reversse-duplicate the logic of the frontend in determining cg_type > for subranges because it fails to pass it down itself..lame.. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkrell at elego.de Fri Mar 15 10:17:49 2013 From: jkrell at elego.de (Jay Krell) Date: Fri, 15 Mar 2013 10:17:49 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130315091749.8C7375DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/15 10:17:49 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: more work on declaring types, esp. records We really just need to finish -- handle packed, opaque, pointer, indirect, so that every field of a record is known. for now -- disabled From jay.krell at cornell.edu Fri Mar 15 16:52:38 2013 From: jay.krell at cornell.edu (Jay) Date: Fri, 15 Mar 2013 08:52:38 -0700 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130315091749.8C7375DEA93@birch.elegosoft.com> References: <20130315091749.8C7375DEA93@birch.elegosoft.com> Message-ID: <25A6807A-24A0-4C2F-BF95-284E4425B9CA@gmail.com> Sorry, this crashes, if using C backend. I'll fix soon.. - Jay On Mar 15, 2013, at 3:17 AM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/15 10:17:49 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > more work on declaring types, esp. records > We really just need to finish -- handle packed, opaque, pointer, indirect, > so that every field of a record is known. > for now -- disabled > From jkrell at elego.de Sat Mar 16 22:04:05 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 16 Mar 2013 22:04:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130316210405.C61C75DEA9C@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/16 22:04:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: restructure all the type declaration stuff into "DeclareTypes" fix crash -- replay just once, using separate array indices From jkrell at elego.de Sat Mar 16 22:51:42 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 16 Mar 2013 22:51:42 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130316215142.397155DEA9C@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/16 22:51:42 Modified files: cm3/m3-libs/m3core/src/thread/Common/: ThreadEvent.i3 Log message: shrink ThreadEvent.T from: T = RECORD kind: Kind; id: ThreadF.Id := 0; state := ThreadF.State.dead; END; struct _MM1D26D90B{ UINT8 kind; UINT8 L_0[7]; INT64 id; UINT8 state; UINT8 L_1[7]; }; 24 bytes to: T = RECORD id: ThreadF.Id := 0; kind: Kind; state := ThreadF.State.dead; END; struct _M3F7FCE84{ INT64 id; UINT8 kind; UINT8 state; UINT8 L_0[6]; }; 16 bytes on 32bit systems it will be reduced from probably 12 bytes to 8 Consider compiler options to help programmers do this. From jkrell at elego.de Sun Mar 17 08:01:04 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 8:01:04 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317070107.1104C5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 08:01:04 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: rework type declaration Types are objects with methods: CanBeDefined() Define() ForwardDeclare() all type declarations are defered until CanBeDefined() which they define in type-specific ways All types are put in a pending queue and removed one at a time, if they can be defined, they are, else they are put at the end of the queue. Records are forward declared.. This doesn't quite hold together. I need to be able to declare pointers to structs after they are forward declared but before they are defined. There should be another state to enable that. But the current changes are a very good step forward. at this point we have started to fill in actual record/struct declarations, and fixed array declarations I still have to fill in more e.g. packed and opaque and open arrays and indirect. also change the linear search/replace of reserved words to be a table lookup also replace field names so e.g. "new" doesn't cause problems (it occurs) From jkrell at elego.de Sun Mar 17 10:46:05 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:46:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317094605.CEF3F5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:46:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: change types from defined: BOOLEAN to state: {none, forwardDeclared, Defined} "more", infrastructurally define integer, word_t, char, widechar, text, mutex, proc1, etc., instead of a "more" special case, but still special cases move SET and SET_GRAIN to helperfunctions (i.e. if set stuff used) i.e. later than where word_t moved to From jkrell at elego.de Sun Mar 17 10:47:03 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:47:03 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317094703.EB9135DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:47:03 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: shorten some print outs From jkrell at elego.de Sun Mar 17 10:51:22 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:51:22 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317095122.4AFDF5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:51:22 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: initialization From jkrell at elego.de Sun Mar 17 10:54:29 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:54:29 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317095429.EA31F5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:54:29 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: minor cleanups From jkrell at elego.de Tue Mar 19 05:30:14 2013 From: jkrell at elego.de (Jay Krell) Date: Tue, 19 Mar 2013 5:30:14 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130319043014.95C479C6006@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/19 05:30:14 Modified files: cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 Log message: extend TInt to 72 bits, so that TWord isn't really needed, as TInt can represent the full range of 64 bit signed and unsigned values add constant "Two" From jay.krell at cornell.edu Tue Mar 19 16:53:45 2013 From: jay.krell at cornell.edu (Jay) Date: Tue, 19 Mar 2013 08:53:45 -0700 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130319043014.95C479C6006@birch.elegosoft.com> References: <20130319043014.95C479C6006@birch.elegosoft.com> Message-ID: <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> Wondering later: maybe code depends on the range being limited? - Jay On Mar 18, 2013, at 10:30 PM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/19 05:30:14 > > Modified files: > cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 > > Log message: > extend TInt to 72 bits, so that TWord isn't really needed, > as TInt can represent the full range of 64 bit signed and unsigned values > > add constant "Two" > From hosking at cs.purdue.edu Tue Mar 19 19:58:40 2013 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 19 Mar 2013 13:58:40 -0500 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> References: <20130319043014.95C479C6006@birch.elegosoft.com> <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> Message-ID: <2A3E5E3E-5192-4F34-A491-74572E8D270D@cs.purdue.edu> Probably ok, but I'm not totally sure. Need to audit all the uses. Sent from my iPad On Mar 19, 2013, at 10:53 AM, Jay wrote: > Wondering later: maybe code depends on the range being limited? > > > - Jay > > On Mar 18, 2013, at 10:30 PM, Jay Krell wrote: > >> CVSROOT: /usr/cvs >> Changes by: jkrell at birch. 13/03/19 05:30:14 >> >> Modified files: >> cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 >> >> Log message: >> extend TInt to 72 bits, so that TWord isn't really needed, >> as TInt can represent the full range of 64 bit signed and unsigned values >> >> add constant "Two" >> From jkrell at elego.de Fri Mar 22 05:48:05 2013 From: jkrell at elego.de (Jay Krell) Date: Fri, 22 Mar 2013 5:48:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130322044805.082749D6001@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/22 05:48:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: type declaration moving along nicely We now declare almost everything. The following needs work though: - opaque is just address; really not good, we should either typedef upon reveal, or forward declare as a struct and duplicate upon reveal; first option is smaller, second option might be needed specifically: typedefs cannot be forward declared, but, also, these might always be pointers, AND we should be able to "scan ahead" to the reveal and thus: pass 1) not necessarily in this order declare_opaque foo: do nothing reveal opaque foo=bar: do nothing declare_object bar: struct bar; typedef struct bar bar; pass 2) declare_opaque foo: do nothing reveal opaque foo=bar: typedef bar foo; - typenames -- we could use them to make the code more readable - proctypes -- currently just typedef ADDRESS typeuid; This will be really nice to do well, and then maybe remove all function pointer casts (but for problems to do with static link) - actually use the types! (this will be a late step, and one of the points) - enums still C compatible and don't take advantage of gcc/msvc extensions - possibly should simplify: currently we define types totally in an on-demand/as-possible basis What we should really do is fairly statically declare and forward declare most things: forward declare records and arrays (arrays are structs) declare enums declare pointers declare typenames that are to pointers/enums declare subranges and then use the same on-demand/as-possible scheme for records/objects, i.e. because records/objects can contain records/objects, and declare_record/object occur in arbitrary order Also TODO is layout objects properly -- I need to read through the code to learn the layout..probably like single inheritance C++..but reading through m3front, it reall wasn't obvious From jkrell at elego.de Sun Mar 31 08:22:54 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 31 Mar 2013 8:22:54 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130331062254.87EDF5DEA96@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/31 08:22:54 Added files: cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 Public.i3 Public.m3 c.c m3makefile Log message: small test case to understand opaque types The error about missing a compile-time type can be had by not importint "Private" in Main.m3. From rodney_bates at lcwb.coop Sun Mar 31 19:46:04 2013 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 31 Mar 2013 12:46:04 -0500 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130331062254.87EDF5DEA96@birch.elegosoft.com> References: <20130331062254.87EDF5DEA96@birch.elegosoft.com> Message-ID: <5158765C.4030005@lcwb.coop> I couldn't get this to compile at all in the CVS tree (that pesky missing .M3EXPORTS problem, which I have never understood.) When I put it in another place, altered the m3makefile with an added import("libm3") and program("main") and removed the Test.common, it compiled and ran for me, with output: Public.F1.a 0x1d9a158 Public.F1.a.a 0x1d9a168 Private.F2:a 0x1d9a158 Private.F2:a.a 0x1d9a168 Private.F2:a.b 0x1d9a160 On 03/31/2013 08:22 AM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/31 08:22:54 > > Added files: > cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 > Public.i3 Public.m3 c.c > m3makefile > > Log message: > small test case to understand opaque types > The error about missing a compile-time type can be had by > not importint "Private" in Main.m3. > > From jay.krell at cornell.edu Sun Mar 31 21:44:59 2013 From: jay.krell at cornell.edu (Jay K) Date: Sun, 31 Mar 2013 19:44:59 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <5158765C.4030005@lcwb.coop> References: <20130331062254.87EDF5DEA96@birch.elegosoft.com>, <5158765C.4030005@lcwb.coop> Message-ID: I solved the problem and checked in a working version. If you don't import Private in Main.m3, then at startup you get an error about a missing type. - Jay > Date: Sun, 31 Mar 2013 12:46:04 -0500 > From: rodney_bates at lcwb.coop > To: m3commit at elegosoft.com > Subject: Re: [M3commit] CVS Update: cm3 > > I couldn't get this to compile at all in the CVS tree (that pesky missing .M3EXPORTS problem, > which I have never understood.) > > When I put it in another place, altered the m3makefile with an added import("libm3") and program("main") > and removed the Test.common, it compiled and ran for me, with output: > > Public.F1.a 0x1d9a158 > Public.F1.a.a 0x1d9a168 > Private.F2:a 0x1d9a158 > Private.F2:a.a 0x1d9a168 > Private.F2:a.b 0x1d9a160 > > > > On 03/31/2013 08:22 AM, Jay Krell wrote: > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 13/03/31 08:22:54 > > > > Added files: > > cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 > > Public.i3 Public.m3 c.c > > m3makefile > > > > Log message: > > small test case to understand opaque types > > The error about missing a compile-time type can be had by > > not importint "Private" in Main.m3. > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkrell at elego.de Sat Mar 2 04:12:57 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 2 Mar 2013 4:12:57 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130302031258.0290A5DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/02 04:12:57 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: work in progress -- properly declare structs/records When done, this will provide excellent debugability esp. on systems that don't support m3gdb (NT, Darwin, HP-UX). From jkrell at elego.de Sat Mar 2 04:15:13 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 2 Mar 2013 4:15:13 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130302031513.877FF5DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/02 04:15:13 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: remove whitespace from ends of linese From jkrell at elego.de Mon Mar 4 19:16:30 2013 From: jkrell at elego.de (Jay Krell) Date: Mon, 4 Mar 2013 19:16:30 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130304181630.EFC295DEAB1@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/04 19:16:30 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: work in progress, significantly along enums, typenames, records problems still: the output is out of order, types are referenced before being defined; we need to detect that and reorder as needed I'm not yet handling everything e.g. indirect, packed, object, method. some issues with TypeUID vs. INTEGER From jkrell at elego.de Tue Mar 5 06:37:33 2013 From: jkrell at elego.de (Jay Krell) Date: Tue, 5 Mar 2013 6:37:33 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130305053733.A76E35DEA96@birch.elegosoft.com> 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. From jay.krell at cornell.edu Tue Mar 5 06:40:06 2013 From: jay.krell at cornell.edu (Jay K) Date: Tue, 5 Mar 2013 05:40:06 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130305053733.A76E35DEA96@birch.elegosoft.com> References: <20130305053733.A76E35DEA96@birch.elegosoft.com> Message-ID: 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: From jkrell at elego.de Thu Mar 14 06:01:23 2013 From: jkrell at elego.de (Jay Krell) Date: Thu, 14 Mar 2013 6:01:23 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130314050123.408455DEB73@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/14 06:01:23 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: reversse-duplicate the logic of the frontend in determining cg_type for subranges because it fails to pass it down itself..lame.. From jay.krell at cornell.edu Thu Mar 14 06:00:40 2013 From: jay.krell at cornell.edu (Jay K) Date: Thu, 14 Mar 2013 05:00:40 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130314050123.408455DEB73@birch.elegosoft.com> References: <20130314050123.408455DEB73@birch.elegosoft.com> Message-ID: backends shouldn't have to do this.. +PROCEDURE SubrangeCGType(READONLY min, max: Target.Int; bit_size: BitSize): M3CG.Type = +(* duplicate the logic of m3front/src/types/SubrangeType; + m3front should pass us down cg_type directly, and not + bother with bit_size, domain *) +BEGIN + IF TInt.EQ(min, TInt.Zero) AND TInt.EQ(max, TInt.MOne) THEN + RETURN BitsToCGInt[bit_size]; + END; + IF TInt.LE(TInt.Zero, min) THEN + RETURN BitsToCGUInt[bit_size]; + END; + RETURN BitsToCGInt[bit_size]; +END SubrangeCGType; > Date: Thu, 14 Mar 2013 06:01:23 +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/14 06:01:23 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > reversse-duplicate the logic of the frontend in determining cg_type > for subranges because it fails to pass it down itself..lame.. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkrell at elego.de Fri Mar 15 10:17:49 2013 From: jkrell at elego.de (Jay Krell) Date: Fri, 15 Mar 2013 10:17:49 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130315091749.8C7375DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/15 10:17:49 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: more work on declaring types, esp. records We really just need to finish -- handle packed, opaque, pointer, indirect, so that every field of a record is known. for now -- disabled From jay.krell at cornell.edu Fri Mar 15 16:52:38 2013 From: jay.krell at cornell.edu (Jay) Date: Fri, 15 Mar 2013 08:52:38 -0700 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130315091749.8C7375DEA93@birch.elegosoft.com> References: <20130315091749.8C7375DEA93@birch.elegosoft.com> Message-ID: <25A6807A-24A0-4C2F-BF95-284E4425B9CA@gmail.com> Sorry, this crashes, if using C backend. I'll fix soon.. - Jay On Mar 15, 2013, at 3:17 AM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/15 10:17:49 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > more work on declaring types, esp. records > We really just need to finish -- handle packed, opaque, pointer, indirect, > so that every field of a record is known. > for now -- disabled > From jkrell at elego.de Sat Mar 16 22:04:05 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 16 Mar 2013 22:04:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130316210405.C61C75DEA9C@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/16 22:04:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: restructure all the type declaration stuff into "DeclareTypes" fix crash -- replay just once, using separate array indices From jkrell at elego.de Sat Mar 16 22:51:42 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 16 Mar 2013 22:51:42 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130316215142.397155DEA9C@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/16 22:51:42 Modified files: cm3/m3-libs/m3core/src/thread/Common/: ThreadEvent.i3 Log message: shrink ThreadEvent.T from: T = RECORD kind: Kind; id: ThreadF.Id := 0; state := ThreadF.State.dead; END; struct _MM1D26D90B{ UINT8 kind; UINT8 L_0[7]; INT64 id; UINT8 state; UINT8 L_1[7]; }; 24 bytes to: T = RECORD id: ThreadF.Id := 0; kind: Kind; state := ThreadF.State.dead; END; struct _M3F7FCE84{ INT64 id; UINT8 kind; UINT8 state; UINT8 L_0[6]; }; 16 bytes on 32bit systems it will be reduced from probably 12 bytes to 8 Consider compiler options to help programmers do this. From jkrell at elego.de Sun Mar 17 08:01:04 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 8:01:04 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317070107.1104C5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 08:01:04 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: rework type declaration Types are objects with methods: CanBeDefined() Define() ForwardDeclare() all type declarations are defered until CanBeDefined() which they define in type-specific ways All types are put in a pending queue and removed one at a time, if they can be defined, they are, else they are put at the end of the queue. Records are forward declared.. This doesn't quite hold together. I need to be able to declare pointers to structs after they are forward declared but before they are defined. There should be another state to enable that. But the current changes are a very good step forward. at this point we have started to fill in actual record/struct declarations, and fixed array declarations I still have to fill in more e.g. packed and opaque and open arrays and indirect. also change the linear search/replace of reserved words to be a table lookup also replace field names so e.g. "new" doesn't cause problems (it occurs) From jkrell at elego.de Sun Mar 17 10:46:05 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:46:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317094605.CEF3F5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:46:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: change types from defined: BOOLEAN to state: {none, forwardDeclared, Defined} "more", infrastructurally define integer, word_t, char, widechar, text, mutex, proc1, etc., instead of a "more" special case, but still special cases move SET and SET_GRAIN to helperfunctions (i.e. if set stuff used) i.e. later than where word_t moved to From jkrell at elego.de Sun Mar 17 10:47:03 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:47:03 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317094703.EB9135DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:47:03 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: shorten some print outs From jkrell at elego.de Sun Mar 17 10:51:22 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:51:22 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317095122.4AFDF5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:51:22 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: initialization From jkrell at elego.de Sun Mar 17 10:54:29 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:54:29 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317095429.EA31F5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:54:29 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: minor cleanups From jkrell at elego.de Tue Mar 19 05:30:14 2013 From: jkrell at elego.de (Jay Krell) Date: Tue, 19 Mar 2013 5:30:14 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130319043014.95C479C6006@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/19 05:30:14 Modified files: cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 Log message: extend TInt to 72 bits, so that TWord isn't really needed, as TInt can represent the full range of 64 bit signed and unsigned values add constant "Two" From jay.krell at cornell.edu Tue Mar 19 16:53:45 2013 From: jay.krell at cornell.edu (Jay) Date: Tue, 19 Mar 2013 08:53:45 -0700 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130319043014.95C479C6006@birch.elegosoft.com> References: <20130319043014.95C479C6006@birch.elegosoft.com> Message-ID: <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> Wondering later: maybe code depends on the range being limited? - Jay On Mar 18, 2013, at 10:30 PM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/19 05:30:14 > > Modified files: > cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 > > Log message: > extend TInt to 72 bits, so that TWord isn't really needed, > as TInt can represent the full range of 64 bit signed and unsigned values > > add constant "Two" > From hosking at cs.purdue.edu Tue Mar 19 19:58:40 2013 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 19 Mar 2013 13:58:40 -0500 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> References: <20130319043014.95C479C6006@birch.elegosoft.com> <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> Message-ID: <2A3E5E3E-5192-4F34-A491-74572E8D270D@cs.purdue.edu> Probably ok, but I'm not totally sure. Need to audit all the uses. Sent from my iPad On Mar 19, 2013, at 10:53 AM, Jay wrote: > Wondering later: maybe code depends on the range being limited? > > > - Jay > > On Mar 18, 2013, at 10:30 PM, Jay Krell wrote: > >> CVSROOT: /usr/cvs >> Changes by: jkrell at birch. 13/03/19 05:30:14 >> >> Modified files: >> cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 >> >> Log message: >> extend TInt to 72 bits, so that TWord isn't really needed, >> as TInt can represent the full range of 64 bit signed and unsigned values >> >> add constant "Two" >> From jkrell at elego.de Fri Mar 22 05:48:05 2013 From: jkrell at elego.de (Jay Krell) Date: Fri, 22 Mar 2013 5:48:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130322044805.082749D6001@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/22 05:48:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: type declaration moving along nicely We now declare almost everything. The following needs work though: - opaque is just address; really not good, we should either typedef upon reveal, or forward declare as a struct and duplicate upon reveal; first option is smaller, second option might be needed specifically: typedefs cannot be forward declared, but, also, these might always be pointers, AND we should be able to "scan ahead" to the reveal and thus: pass 1) not necessarily in this order declare_opaque foo: do nothing reveal opaque foo=bar: do nothing declare_object bar: struct bar; typedef struct bar bar; pass 2) declare_opaque foo: do nothing reveal opaque foo=bar: typedef bar foo; - typenames -- we could use them to make the code more readable - proctypes -- currently just typedef ADDRESS typeuid; This will be really nice to do well, and then maybe remove all function pointer casts (but for problems to do with static link) - actually use the types! (this will be a late step, and one of the points) - enums still C compatible and don't take advantage of gcc/msvc extensions - possibly should simplify: currently we define types totally in an on-demand/as-possible basis What we should really do is fairly statically declare and forward declare most things: forward declare records and arrays (arrays are structs) declare enums declare pointers declare typenames that are to pointers/enums declare subranges and then use the same on-demand/as-possible scheme for records/objects, i.e. because records/objects can contain records/objects, and declare_record/object occur in arbitrary order Also TODO is layout objects properly -- I need to read through the code to learn the layout..probably like single inheritance C++..but reading through m3front, it reall wasn't obvious From jkrell at elego.de Sun Mar 31 08:22:54 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 31 Mar 2013 8:22:54 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130331062254.87EDF5DEA96@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/31 08:22:54 Added files: cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 Public.i3 Public.m3 c.c m3makefile Log message: small test case to understand opaque types The error about missing a compile-time type can be had by not importint "Private" in Main.m3. From rodney_bates at lcwb.coop Sun Mar 31 19:46:04 2013 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 31 Mar 2013 12:46:04 -0500 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130331062254.87EDF5DEA96@birch.elegosoft.com> References: <20130331062254.87EDF5DEA96@birch.elegosoft.com> Message-ID: <5158765C.4030005@lcwb.coop> I couldn't get this to compile at all in the CVS tree (that pesky missing .M3EXPORTS problem, which I have never understood.) When I put it in another place, altered the m3makefile with an added import("libm3") and program("main") and removed the Test.common, it compiled and ran for me, with output: Public.F1.a 0x1d9a158 Public.F1.a.a 0x1d9a168 Private.F2:a 0x1d9a158 Private.F2:a.a 0x1d9a168 Private.F2:a.b 0x1d9a160 On 03/31/2013 08:22 AM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/31 08:22:54 > > Added files: > cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 > Public.i3 Public.m3 c.c > m3makefile > > Log message: > small test case to understand opaque types > The error about missing a compile-time type can be had by > not importint "Private" in Main.m3. > > From jay.krell at cornell.edu Sun Mar 31 21:44:59 2013 From: jay.krell at cornell.edu (Jay K) Date: Sun, 31 Mar 2013 19:44:59 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <5158765C.4030005@lcwb.coop> References: <20130331062254.87EDF5DEA96@birch.elegosoft.com>, <5158765C.4030005@lcwb.coop> Message-ID: I solved the problem and checked in a working version. If you don't import Private in Main.m3, then at startup you get an error about a missing type. - Jay > Date: Sun, 31 Mar 2013 12:46:04 -0500 > From: rodney_bates at lcwb.coop > To: m3commit at elegosoft.com > Subject: Re: [M3commit] CVS Update: cm3 > > I couldn't get this to compile at all in the CVS tree (that pesky missing .M3EXPORTS problem, > which I have never understood.) > > When I put it in another place, altered the m3makefile with an added import("libm3") and program("main") > and removed the Test.common, it compiled and ran for me, with output: > > Public.F1.a 0x1d9a158 > Public.F1.a.a 0x1d9a168 > Private.F2:a 0x1d9a158 > Private.F2:a.a 0x1d9a168 > Private.F2:a.b 0x1d9a160 > > > > On 03/31/2013 08:22 AM, Jay Krell wrote: > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 13/03/31 08:22:54 > > > > Added files: > > cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 > > Public.i3 Public.m3 c.c > > m3makefile > > > > Log message: > > small test case to understand opaque types > > The error about missing a compile-time type can be had by > > not importint "Private" in Main.m3. > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkrell at elego.de Sat Mar 2 04:12:57 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 2 Mar 2013 4:12:57 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130302031258.0290A5DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/02 04:12:57 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: work in progress -- properly declare structs/records When done, this will provide excellent debugability esp. on systems that don't support m3gdb (NT, Darwin, HP-UX). From jkrell at elego.de Sat Mar 2 04:15:13 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 2 Mar 2013 4:15:13 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130302031513.877FF5DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/02 04:15:13 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: remove whitespace from ends of linese From jkrell at elego.de Mon Mar 4 19:16:30 2013 From: jkrell at elego.de (Jay Krell) Date: Mon, 4 Mar 2013 19:16:30 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130304181630.EFC295DEAB1@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/04 19:16:30 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: work in progress, significantly along enums, typenames, records problems still: the output is out of order, types are referenced before being defined; we need to detect that and reorder as needed I'm not yet handling everything e.g. indirect, packed, object, method. some issues with TypeUID vs. INTEGER From jkrell at elego.de Tue Mar 5 06:37:33 2013 From: jkrell at elego.de (Jay Krell) Date: Tue, 5 Mar 2013 6:37:33 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130305053733.A76E35DEA96@birch.elegosoft.com> 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. From jay.krell at cornell.edu Tue Mar 5 06:40:06 2013 From: jay.krell at cornell.edu (Jay K) Date: Tue, 5 Mar 2013 05:40:06 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130305053733.A76E35DEA96@birch.elegosoft.com> References: <20130305053733.A76E35DEA96@birch.elegosoft.com> Message-ID: 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: From jkrell at elego.de Thu Mar 14 06:01:23 2013 From: jkrell at elego.de (Jay Krell) Date: Thu, 14 Mar 2013 6:01:23 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130314050123.408455DEB73@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/14 06:01:23 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: reversse-duplicate the logic of the frontend in determining cg_type for subranges because it fails to pass it down itself..lame.. From jay.krell at cornell.edu Thu Mar 14 06:00:40 2013 From: jay.krell at cornell.edu (Jay K) Date: Thu, 14 Mar 2013 05:00:40 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130314050123.408455DEB73@birch.elegosoft.com> References: <20130314050123.408455DEB73@birch.elegosoft.com> Message-ID: backends shouldn't have to do this.. +PROCEDURE SubrangeCGType(READONLY min, max: Target.Int; bit_size: BitSize): M3CG.Type = +(* duplicate the logic of m3front/src/types/SubrangeType; + m3front should pass us down cg_type directly, and not + bother with bit_size, domain *) +BEGIN + IF TInt.EQ(min, TInt.Zero) AND TInt.EQ(max, TInt.MOne) THEN + RETURN BitsToCGInt[bit_size]; + END; + IF TInt.LE(TInt.Zero, min) THEN + RETURN BitsToCGUInt[bit_size]; + END; + RETURN BitsToCGInt[bit_size]; +END SubrangeCGType; > Date: Thu, 14 Mar 2013 06:01:23 +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/14 06:01:23 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > reversse-duplicate the logic of the frontend in determining cg_type > for subranges because it fails to pass it down itself..lame.. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkrell at elego.de Fri Mar 15 10:17:49 2013 From: jkrell at elego.de (Jay Krell) Date: Fri, 15 Mar 2013 10:17:49 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130315091749.8C7375DEA93@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/15 10:17:49 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: more work on declaring types, esp. records We really just need to finish -- handle packed, opaque, pointer, indirect, so that every field of a record is known. for now -- disabled From jay.krell at cornell.edu Fri Mar 15 16:52:38 2013 From: jay.krell at cornell.edu (Jay) Date: Fri, 15 Mar 2013 08:52:38 -0700 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130315091749.8C7375DEA93@birch.elegosoft.com> References: <20130315091749.8C7375DEA93@birch.elegosoft.com> Message-ID: <25A6807A-24A0-4C2F-BF95-284E4425B9CA@gmail.com> Sorry, this crashes, if using C backend. I'll fix soon.. - Jay On Mar 15, 2013, at 3:17 AM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/15 10:17:49 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > more work on declaring types, esp. records > We really just need to finish -- handle packed, opaque, pointer, indirect, > so that every field of a record is known. > for now -- disabled > From jkrell at elego.de Sat Mar 16 22:04:05 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 16 Mar 2013 22:04:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130316210405.C61C75DEA9C@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/16 22:04:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: restructure all the type declaration stuff into "DeclareTypes" fix crash -- replay just once, using separate array indices From jkrell at elego.de Sat Mar 16 22:51:42 2013 From: jkrell at elego.de (Jay Krell) Date: Sat, 16 Mar 2013 22:51:42 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130316215142.397155DEA9C@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/16 22:51:42 Modified files: cm3/m3-libs/m3core/src/thread/Common/: ThreadEvent.i3 Log message: shrink ThreadEvent.T from: T = RECORD kind: Kind; id: ThreadF.Id := 0; state := ThreadF.State.dead; END; struct _MM1D26D90B{ UINT8 kind; UINT8 L_0[7]; INT64 id; UINT8 state; UINT8 L_1[7]; }; 24 bytes to: T = RECORD id: ThreadF.Id := 0; kind: Kind; state := ThreadF.State.dead; END; struct _M3F7FCE84{ INT64 id; UINT8 kind; UINT8 state; UINT8 L_0[6]; }; 16 bytes on 32bit systems it will be reduced from probably 12 bytes to 8 Consider compiler options to help programmers do this. From jkrell at elego.de Sun Mar 17 08:01:04 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 8:01:04 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317070107.1104C5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 08:01:04 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: rework type declaration Types are objects with methods: CanBeDefined() Define() ForwardDeclare() all type declarations are defered until CanBeDefined() which they define in type-specific ways All types are put in a pending queue and removed one at a time, if they can be defined, they are, else they are put at the end of the queue. Records are forward declared.. This doesn't quite hold together. I need to be able to declare pointers to structs after they are forward declared but before they are defined. There should be another state to enable that. But the current changes are a very good step forward. at this point we have started to fill in actual record/struct declarations, and fixed array declarations I still have to fill in more e.g. packed and opaque and open arrays and indirect. also change the linear search/replace of reserved words to be a table lookup also replace field names so e.g. "new" doesn't cause problems (it occurs) From jkrell at elego.de Sun Mar 17 10:46:05 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:46:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317094605.CEF3F5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:46:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: change types from defined: BOOLEAN to state: {none, forwardDeclared, Defined} "more", infrastructurally define integer, word_t, char, widechar, text, mutex, proc1, etc., instead of a "more" special case, but still special cases move SET and SET_GRAIN to helperfunctions (i.e. if set stuff used) i.e. later than where word_t moved to From jkrell at elego.de Sun Mar 17 10:47:03 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:47:03 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317094703.EB9135DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:47:03 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: shorten some print outs From jkrell at elego.de Sun Mar 17 10:51:22 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:51:22 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317095122.4AFDF5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:51:22 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: initialization From jkrell at elego.de Sun Mar 17 10:54:29 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 17 Mar 2013 10:54:29 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130317095429.EA31F5DEA8F@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/17 10:54:29 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: minor cleanups From jkrell at elego.de Tue Mar 19 05:30:14 2013 From: jkrell at elego.de (Jay Krell) Date: Tue, 19 Mar 2013 5:30:14 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130319043014.95C479C6006@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/19 05:30:14 Modified files: cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 Log message: extend TInt to 72 bits, so that TWord isn't really needed, as TInt can represent the full range of 64 bit signed and unsigned values add constant "Two" From jay.krell at cornell.edu Tue Mar 19 16:53:45 2013 From: jay.krell at cornell.edu (Jay) Date: Tue, 19 Mar 2013 08:53:45 -0700 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130319043014.95C479C6006@birch.elegosoft.com> References: <20130319043014.95C479C6006@birch.elegosoft.com> Message-ID: <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> Wondering later: maybe code depends on the range being limited? - Jay On Mar 18, 2013, at 10:30 PM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/19 05:30:14 > > Modified files: > cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 > > Log message: > extend TInt to 72 bits, so that TWord isn't really needed, > as TInt can represent the full range of 64 bit signed and unsigned values > > add constant "Two" > From hosking at cs.purdue.edu Tue Mar 19 19:58:40 2013 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 19 Mar 2013 13:58:40 -0500 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> References: <20130319043014.95C479C6006@birch.elegosoft.com> <6EBA93AC-491C-40F1-9150-8E68ECE3D5A9@gmail.com> Message-ID: <2A3E5E3E-5192-4F34-A491-74572E8D270D@cs.purdue.edu> Probably ok, but I'm not totally sure. Need to audit all the uses. Sent from my iPad On Mar 19, 2013, at 10:53 AM, Jay wrote: > Wondering later: maybe code depends on the range being limited? > > > - Jay > > On Mar 18, 2013, at 10:30 PM, Jay Krell wrote: > >> CVSROOT: /usr/cvs >> Changes by: jkrell at birch. 13/03/19 05:30:14 >> >> Modified files: >> cm3/m3-sys/m3middle/src/: TInt.i3 TWord.i3 >> >> Log message: >> extend TInt to 72 bits, so that TWord isn't really needed, >> as TInt can represent the full range of 64 bit signed and unsigned values >> >> add constant "Two" >> From jkrell at elego.de Fri Mar 22 05:48:05 2013 From: jkrell at elego.de (Jay Krell) Date: Fri, 22 Mar 2013 5:48:05 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130322044805.082749D6001@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/22 05:48:05 Modified files: cm3/m3-sys/m3back/src/: M3C.m3 Log message: type declaration moving along nicely We now declare almost everything. The following needs work though: - opaque is just address; really not good, we should either typedef upon reveal, or forward declare as a struct and duplicate upon reveal; first option is smaller, second option might be needed specifically: typedefs cannot be forward declared, but, also, these might always be pointers, AND we should be able to "scan ahead" to the reveal and thus: pass 1) not necessarily in this order declare_opaque foo: do nothing reveal opaque foo=bar: do nothing declare_object bar: struct bar; typedef struct bar bar; pass 2) declare_opaque foo: do nothing reveal opaque foo=bar: typedef bar foo; - typenames -- we could use them to make the code more readable - proctypes -- currently just typedef ADDRESS typeuid; This will be really nice to do well, and then maybe remove all function pointer casts (but for problems to do with static link) - actually use the types! (this will be a late step, and one of the points) - enums still C compatible and don't take advantage of gcc/msvc extensions - possibly should simplify: currently we define types totally in an on-demand/as-possible basis What we should really do is fairly statically declare and forward declare most things: forward declare records and arrays (arrays are structs) declare enums declare pointers declare typenames that are to pointers/enums declare subranges and then use the same on-demand/as-possible scheme for records/objects, i.e. because records/objects can contain records/objects, and declare_record/object occur in arbitrary order Also TODO is layout objects properly -- I need to read through the code to learn the layout..probably like single inheritance C++..but reading through m3front, it reall wasn't obvious From jkrell at elego.de Sun Mar 31 08:22:54 2013 From: jkrell at elego.de (Jay Krell) Date: Sun, 31 Mar 2013 8:22:54 () Subject: [M3commit] CVS Update: cm3 Message-ID: <20130331062254.87EDF5DEA96@birch.elegosoft.com> CVSROOT: /usr/cvs Changes by: jkrell at birch. 13/03/31 08:22:54 Added files: cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 Public.i3 Public.m3 c.c m3makefile Log message: small test case to understand opaque types The error about missing a compile-time type can be had by not importint "Private" in Main.m3. From rodney_bates at lcwb.coop Sun Mar 31 19:46:04 2013 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 31 Mar 2013 12:46:04 -0500 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <20130331062254.87EDF5DEA96@birch.elegosoft.com> References: <20130331062254.87EDF5DEA96@birch.elegosoft.com> Message-ID: <5158765C.4030005@lcwb.coop> I couldn't get this to compile at all in the CVS tree (that pesky missing .M3EXPORTS problem, which I have never understood.) When I put it in another place, altered the m3makefile with an added import("libm3") and program("main") and removed the Test.common, it compiled and ran for me, with output: Public.F1.a 0x1d9a158 Public.F1.a.a 0x1d9a168 Private.F2:a 0x1d9a158 Private.F2:a.a 0x1d9a168 Private.F2:a.b 0x1d9a160 On 03/31/2013 08:22 AM, Jay Krell wrote: > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 13/03/31 08:22:54 > > Added files: > cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 > Public.i3 Public.m3 c.c > m3makefile > > Log message: > small test case to understand opaque types > The error about missing a compile-time type can be had by > not importint "Private" in Main.m3. > > From jay.krell at cornell.edu Sun Mar 31 21:44:59 2013 From: jay.krell at cornell.edu (Jay K) Date: Sun, 31 Mar 2013 19:44:59 +0000 Subject: [M3commit] CVS Update: cm3 In-Reply-To: <5158765C.4030005@lcwb.coop> References: <20130331062254.87EDF5DEA96@birch.elegosoft.com>, <5158765C.4030005@lcwb.coop> Message-ID: I solved the problem and checked in a working version. If you don't import Private in Main.m3, then at startup you get an error about a missing type. - Jay > Date: Sun, 31 Mar 2013 12:46:04 -0500 > From: rodney_bates at lcwb.coop > To: m3commit at elegosoft.com > Subject: Re: [M3commit] CVS Update: cm3 > > I couldn't get this to compile at all in the CVS tree (that pesky missing .M3EXPORTS problem, > which I have never understood.) > > When I put it in another place, altered the m3makefile with an added import("libm3") and program("main") > and removed the Test.common, it compiled and ran for me, with output: > > Public.F1.a 0x1d9a158 > Public.F1.a.a 0x1d9a168 > Private.F2:a 0x1d9a158 > Private.F2:a.a 0x1d9a168 > Private.F2:a.b 0x1d9a160 > > > > On 03/31/2013 08:22 AM, Jay Krell wrote: > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 13/03/31 08:22:54 > > > > Added files: > > cm3/m3-sys/m3tests/src/p2/p253/: Main.m3 Private.i3 Private.m3 > > Public.i3 Public.m3 c.c > > m3makefile > > > > Log message: > > small test case to understand opaque types > > The error about missing a compile-time type can be had by > > not importint "Private" in Main.m3. > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: