From hendrik at topoi.pooq.com Mon Oct 1 15:14:17 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Mon, 1 Oct 2012 09:14:17 -0400 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <5068B362.90304@lcwb.coop> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <5068B362.90304@lcwb.coop> Message-ID: <20121001131417.GA13426@topoi.pooq.com> On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > > > On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >Well that depends on how you maintain the vector, no? > > > >SortedTable uses "treaps" which are supposed to be good data structures. > >Too new to have made it into Knuth, last I checked. The amortized cost > >of your operations shouldn't be much worse than with your method, with > >the additional benefit that the sorted order is maintained dynamically. > > > >The separation of algorithms from containers sounds a bit like a bug. > >You have to be careful so you don't shoot yourself in the foot there! > >(Sorting a list using an algorithm that randomly accesses elements, > >say...) > > > >The Modula-3 approach is that you figure out what you want to do, pick > >the ADT you want that provides the minimal set of operations, import > >that interface, then instantiate a more carefully chosen implementation > >of the ADT. The language itself obviously can be coaxed into supporting the > >algorithm/data structure separation but no one uses it that way as > >far as I know. (Modula-3 generics are not that well explored, actually. > >I suspect there are many things you can do with them that no one has > >tried.) > > > > Mika > > > > > > I do think the ability to easily and inadvertently create mashups with > horrible asymptotic efficiency problems is a fundamental problem with > abstractions of any kind. Just plain old-fashioned procedural abstractions > give plenty of opportunity. Write one loop and call your code O(n). > Call something inside the loop. That guy did the same. Quickly, you > can O(n^3) etc., and nobody realizes it. > > Functional style abstractions are often just oh-so-easy to use, but > they can hide a lot. Even Modula-3 Text operations, immeasurably > more versatile and easy than when you have to worry about allocation, > have created some unpleasant surprises. Documenting the performance > characteristics in comments seems to be only solution. This has been > done in some places by both C++ and Modula-3 library writers. It might be interesting to speculate on language features that coul track performance problems the way type-checking checks types. Not tht I expect a practical solution today or tomorrow. -- hendrik From rodney_bates at lcwb.coop Mon Oct 1 18:18:50 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Mon, 01 Oct 2012 11:18:50 -0500 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <20121001131417.GA13426@topoi.pooq.com> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <5068B362.90304@lcwb.coop> <20121001131417.GA13426@topoi.pooq.com> Message-ID: <5069C26A.6030604@lcwb.coop> On 10/01/2012 08:14 AM, Hendrik Boom wrote: > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: >> >> >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: >>> Well that depends on how you maintain the vector, no? >>> >>> SortedTable uses "treaps" which are supposed to be good data structures. >>> Too new to have made it into Knuth, last I checked. The amortized cost >>> of your operations shouldn't be much worse than with your method, with >>> the additional benefit that the sorted order is maintained dynamically. >>> >>> The separation of algorithms from containers sounds a bit like a bug. >>> You have to be careful so you don't shoot yourself in the foot there! >>> (Sorting a list using an algorithm that randomly accesses elements, >>> say...) >>> >>> The Modula-3 approach is that you figure out what you want to do, pick >>> the ADT you want that provides the minimal set of operations, import >>> that interface, then instantiate a more carefully chosen implementation >>> of the ADT. The language itself obviously can be coaxed into supporting the >>> algorithm/data structure separation but no one uses it that way as >>> far as I know. (Modula-3 generics are not that well explored, actually. >>> I suspect there are many things you can do with them that no one has >>> tried.) >>> >>> Mika >>> >>> >> >> I do think the ability to easily and inadvertently create mashups with >> horrible asymptotic efficiency problems is a fundamental problem with >> abstractions of any kind. Just plain old-fashioned procedural abstractions >> give plenty of opportunity. Write one loop and call your code O(n). >> Call something inside the loop. That guy did the same. Quickly, you >> can O(n^3) etc., and nobody realizes it. >> >> Functional style abstractions are often just oh-so-easy to use, but >> they can hide a lot. Even Modula-3 Text operations, immeasurably >> more versatile and easy than when you have to worry about allocation, >> have created some unpleasant surprises. Documenting the performance >> characteristics in comments seems to be only solution. This has been >> done in some places by both C++ and Modula-3 library writers. > > It might be interesting to speculate on language features that coul > track performance problems the way type-checking checks types. > Yes, I agree. > Not tht I expect a practical solution today or tomorrow. > Yes, I agree here too. > -- hendrik > From jay.krell at cornell.edu Mon Oct 1 19:29:48 2012 From: jay.krell at cornell.edu (Jay K) Date: Mon, 1 Oct 2012 17:29:48 +0000 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <5069C26A.6030604@lcwb.coop> References: , <20120928075656.751E21A2082@async.async.caltech.edu>, <20120928080448.C80DD1A2082@async.async.caltech.edu>, , <20120929182948.6589C1A2082@async.async.caltech.edu>, <5068B362.90304@lcwb.coop> <20121001131417.GA13426@topoi.pooq.com>,<5069C26A.6030604@lcwb.coop> Message-ID: C++ already has this to some extent and has for a long time. You can't actually request to qsort a std::list. The type system doesn't allow it. They don't come up with random access that is ridiculously slow. They come up with none at all, and it is a compilation error. But if you are just writing loops over loops over loops over random access to large working sets and network I/O, talking to a server, that does more of the same..yeah.... What you want though is, I guess, "more composition", more flowing of data.A lot more.Tough problem...order of runtime is a factor of so many things, size of a file, or lines in the file, or tokens in a file, or number of heap allocations, or number of network I/O, or number of memory reads, or memory writes, etc.... - Jay > Date: Mon, 1 Oct 2012 11:18:50 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 10/01/2012 08:14 AM, Hendrik Boom wrote: > > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > >> > >> > >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >>> Well that depends on how you maintain the vector, no? > >>> > >>> SortedTable uses "treaps" which are supposed to be good data structures. > >>> Too new to have made it into Knuth, last I checked. The amortized cost > >>> of your operations shouldn't be much worse than with your method, with > >>> the additional benefit that the sorted order is maintained dynamically. > >>> > >>> The separation of algorithms from containers sounds a bit like a bug. > >>> You have to be careful so you don't shoot yourself in the foot there! > >>> (Sorting a list using an algorithm that randomly accesses elements, > >>> say...) > >>> > >>> The Modula-3 approach is that you figure out what you want to do, pick > >>> the ADT you want that provides the minimal set of operations, import > >>> that interface, then instantiate a more carefully chosen implementation > >>> of the ADT. The language itself obviously can be coaxed into supporting the > >>> algorithm/data structure separation but no one uses it that way as > >>> far as I know. (Modula-3 generics are not that well explored, actually. > >>> I suspect there are many things you can do with them that no one has > >>> tried.) > >>> > >>> Mika > >>> > >>> > >> > >> I do think the ability to easily and inadvertently create mashups with > >> horrible asymptotic efficiency problems is a fundamental problem with > >> abstractions of any kind. Just plain old-fashioned procedural abstractions > >> give plenty of opportunity. Write one loop and call your code O(n). > >> Call something inside the loop. That guy did the same. Quickly, you > >> can O(n^3) etc., and nobody realizes it. > >> > >> Functional style abstractions are often just oh-so-easy to use, but > >> they can hide a lot. Even Modula-3 Text operations, immeasurably > >> more versatile and easy than when you have to worry about allocation, > >> have created some unpleasant surprises. Documenting the performance > >> characteristics in comments seems to be only solution. This has been > >> done in some places by both C++ and Modula-3 library writers. > > > > It might be interesting to speculate on language features that coul > > track performance problems the way type-checking checks types. > > > > Yes, I agree. > > > Not tht I expect a practical solution today or tomorrow. > > > > Yes, I agree here too. > > > -- hendrik > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Mon Oct 1 21:07:26 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Mon, 1 Oct 2012 20:07:26 +0100 (BST) Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: Message-ID: <1349118446.66982.YahooMailClassic@web29702.mail.ird.yahoo.com> Hi all: None of this languages of today can predict anything about unbounded termination less they provide a clear solution for the problem of finding compile? time solutions for programs of bigger classes of complexity than what it takes to type check a given program if you consider both at each time is very hard problem probably to give a model itself. The only way seems to analyze execution traces and make prediction models. However I don't think this is more important than to make more efficient computer models. And current advances are not encouraging. Thanks in advance --- El lun, 1/10/12, Jay K escribi?: De: Jay K Asunto: Re: [M3devel] STL algorithms? sort/unique? Para: "Rodney M. Bates" , "m3devel" Fecha: lunes, 1 de octubre, 2012 12:29 C++ already has this to some extent and has for a long time.? You can't actually request to qsort a std::list. The type system doesn't allow it. They don't come up with random access that is ridiculously slow. They come up with none at all, and it is a compilation error. But if you are just writing loops over?loops over loops over random access to large working sets and network I/O, talking to a server, that does more of the same..yeah.... What you want though is, I guess, "more composition", more flowing of data.A lot more.Tough problem...order of runtime is a factor of so many things, size of a file, or lines in the file, or tokens in a file, or number of heap allocations, or number of network I/O, or number of memory reads, or memory writes, etc.... ?- Jay > Date: Mon, 1 Oct 2012 11:18:50 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 10/01/2012 08:14 AM, Hendrik Boom wrote: > > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > >> > >> > >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >>> Well that depends on how you maintain the vector, no? > >>> > >>> SortedTable uses "treaps" which are supposed to be good data structures. > >>> Too new to have made it into Knuth, last I checked. The amortized cost > >>> of your operations shouldn't be much worse than with your method, with > >>> the additional benefit that the sorted order is maintained dynamically. > >>> > >>> The separation of algorithms from containers sounds a bit like a bug. > >>> You have to be careful so you don't shoot yourself in the foot there! > >>> (Sorting a list using an algorithm that randomly accesses elements, > >>> say...) > >>> > >>> The Modula-3 approach is that you figure out what you want to do, pick > >>> the ADT you want that provides the minimal set of operations, import > >>> that interface, then instantiate a more carefully chosen implementation > >>> of the ADT. The language itself obviously can be coaxed into supporting the > >>> algorithm/data structure separation but no one uses it that way as > >>> far as I know. (Modula-3 generics are not that well explored, actually. > >>> I suspect there are many things you can do with them that no one has > >>> tried.) > >>> > >>> Mika > >>> > >>> > >> > >> I do think the ability to easily and inadvertently create mashups with > >> horrible asymptotic efficiency problems is a fundamental problem with > >> abstractions of any kind. Just plain old-fashioned procedural abstractions > >> give plenty of opportunity. Write one loop and call your code O(n). > >> Call something inside the loop. That guy did the same. Quickly, you > >> can O(n^3) etc., and nobody realizes it. > >> > >> Functional style abstractions are often just oh-so-easy to use, but > >> they can hide a lot. Even Modula-3 Text operations, immeasurably > >> more versatile and easy than when you have to worry about allocation, > >> have created some unpleasant surprises. Documenting the performance > >> characteristics in comments seems to be only solution. This has been > >> done in some places by both C++ and Modula-3 library writers. > > > > It might be interesting to speculate on language features that coul > > track performance problems the way type-checking checks types. > > > > Yes, I agree. > > > Not tht I expect a practical solution today or tomorrow. > > > > Yes, I agree here too. > > > -- hendrik > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Tue Oct 2 21:53:04 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Tue, 2 Oct 2012 21:53:04 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> Message-ID: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> I don't need stack allocated object. I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. As Anthony said. At this time and age? I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. I think we just need even better collector that we currently have. One passing Mika's thread test :). dd On Sep 30, 2012, at 8:06 AM, Jay K wrote: > I don't just want UNTRACED OBJECT. > I also want stack allocated objects. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Tue Oct 2 22:43:24 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Tue, 2 Oct 2012 21:43:24 +0100 (BST) Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> Message-ID: <1349210604.21624.YahooMailClassic@web29706.mail.ird.yahoo.com> Hi all: to make a proposal we could consider several options, for grow able stacks and fine grained heaps, my approach is pure Baby Modula-3, for the former and Obliq-like objects for the latter. But I'm no selling the idea to you guys! Just if someone could manage to make a proposal I support it. Thanks in advance --- El mar, 2/10/12, Dragi?a Duri? escribi?: De: Dragi?a Duri? Asunto: Re: [M3devel] STL algorithms? sort/unique? Para: "Jay K" CC: "m3devel" Fecha: martes, 2 de octubre, 2012 14:53 I don't need stack allocated object.? I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. As Anthony said. At this time and age? ? I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. I think we just need even better collector that we currently have. One passing Mika's thread test :). dd On Sep 30, 2012, at 8:06 AM, Jay K wrote: I don't just want UNTRACED OBJECT.I also want stack allocated objects. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 3 16:39:53 2012 From: jay.krell at cornell.edu (Jay) Date: Wed, 3 Oct 2012 07:39:53 -0700 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> Message-ID: <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> Growable stack is basically nonsense. True that stack allocation has large downside that picking a stack size is impossible. But it is super fast. Once we have NT/C backend that doesn't use a thread local, & we have cooperative suspend, I'd like to try writing an NT driver with Modula-3.. limited stack space there. :) (hm...what if we can't wrap the thread entry? Maybe ok.) Right, C++ is the answer, once I have my own compiler. :) - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 2, 2012, at 12:53 PM, Dragi?a Duri? wrote: > I don't need stack allocated object. > > I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? > > I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. > > As Anthony said. At this time and age? > > I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. > > I think we just need even better collector that we currently have. One passing Mika's thread test :). > > dd > > On Sep 30, 2012, at 8:06 AM, Jay K wrote: > >> I don't just want UNTRACED OBJECT. >> I also want stack allocated objects. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Wed Oct 3 20:24:06 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Wed, 3 Oct 2012 20:24:06 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> Message-ID: <300C8C70-BF12-4B78-B1B5-15A514360AD7@m3w.org> Current heap allocation (thanks to Anthony) is much much faster than it used to be, as each thread has it's own "current page to alloc from". Not like stack alloc, but also not limited as stack alloc. Your C++ compiler will cull those 60% of C++ standard? I can't wait to see it! :) -- Divided by a common language Dragi?a Duri? dragisha at m3w.org On Oct 3, 2012, at 4:39 PM, Jay wrote: > Growable stack is basically nonsense. > > > True that stack allocation has large downside that picking a stack size is impossible. But it is super fast. > > > Once we have NT/C backend that doesn't use a thread local, & we have cooperative suspend, I'd like to try writing an NT driver with Modula-3.. limited stack space there. :) > (hm...what if we can't wrap the thread entry? Maybe ok.) > > > Right, C++ is the answer, once I have my own compiler. :) > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 2, 2012, at 12:53 PM, Dragi?a Duri? wrote: > >> I don't need stack allocated object. >> >> I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? >> >> I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. >> >> As Anthony said. At this time and age? >> >> I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. >> >> I think we just need even better collector that we currently have. One passing Mika's thread test :). >> >> dd >> >> On Sep 30, 2012, at 8:06 AM, Jay K wrote: >> >>> I don't just want UNTRACED OBJECT. >>> I also want stack allocated objects. >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Thu Oct 4 03:40:57 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 03 Oct 2012 20:40:57 -0500 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> Message-ID: <506CE929.3000008@lcwb.coop> On 09/30/2012 01:06 AM, Jay K wrote: > I believe opinion remains strongly mixed on garbage collection / "managed" > etc. There is a lot of "managed" code. There is a lot of "native" code. > We all use a lot of both every day. > > > Modula-3 is actually pretty unusual in being native code and having garbage collection. > It is pretty unusual in having optional garbage collection. > It is pretty unusual in having optional safety. > C# allows some safety relaxation within "unsafe" blocks. > Like pointer manipulation. > > It pains me slightly in Modula-3 to write e.g. > > RTIO.PutText("foo " & Fmt.Int(123) & "bar"); > I've created at least two pieces of garbage. > In C++ any temporary strings would be cleaned up > right away at a deterministic time. > > > I'm really torn. > C# seems to be a highly "productive" "environment" (the language, > the libraries, possibly the IDEs). Perhaps far more than any C++ or Modula-3. > I know people who work on kernel drivers. They still use C. > > > I don't just want UNTRACED OBJECT. > I also want stack allocated objects. > C++ has them. > This idea has never made any sense to me at all: 1) No OOP advocate would let you get away with calling it OOP without having dispatching methods. (This despite the fact that the great majority of OO examples don't actually use them, and thus are really ADT programming.) 2) You can't actually use dispatching unless your variable can dynamically be assigned values of different subclasses at different times. Degenerately using a linguistic mechanism that dispatches, but the algorithm ensures it is always to the same place, does not count. 3) If a stack object is to be dynamically assignable to values of different subclasses, the compiler is going to have to allocate space for the largest of these. That can be declared anywhere, in a place unknown to exist, at the point where the variable is declared. I think I can see a way this could be implemented with whole-program techniques, but it still won't work with dynamically linked libraries, which rules out a major part of what the staunch OOP advocates advocate. And it creates a new kind of space waste. 4) Alternatively, a compiler could actually hiddenly allocate the objects in the heap and put a pointer on the stack. But now any real or imagined performance gains from on-stack objects are gone. Moreover, there will be reference assignment vs. value assignment semantic distinctions that violate what local variables are expected to do, with sometimes big bugs as consequence. 5) A compiler could fix this by simulating the correct value assignment semantics, making heap copies whenever necessary. This makes it effectively a functional language, which certainly would require a GC and greatly increases the volume of allocated and collected heap objects. 6) Or, a programmer could explicitly take pointers to stack objects of various subclasses and assign them to the same variable at different times. I guess this is what is done in C++. This amounts to enticing the naive to try dancing on a tight-wire over Dangling Pointer Abyss. Which would justify Stroustrup's comment. 7) Finally, a programmer diligent and skillful enough to pull this off would be extremely hard pressed to find an application where the actual stack lifetimes of the different subclass objects had any significant correlation to the real lifetimes of their usefulness to the program. > class C > { > void F1(); > virtual void F2(); > }; > > void F3() > { > C c; > } > > > I think the nearest equivalent in Modula-3 is a stack allocated RECORD > with function pointers. > > > - Jay > > > From jay.krell at cornell.edu Thu Oct 4 03:59:29 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 01:59:29 +0000 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <506CE929.3000008@lcwb.coop> References: , ,,<20120928075656.751E21A2082@async.async.caltech.edu>, , ,,<20120928080448.C80DD1A2082@async.async.caltech.edu>, ,,, , ,,<20120929182948.6589C1A2082@async.async.caltech.edu>, ,,, , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , , , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu>, , <506CE929.3000008@lcwb.coop> Message-ID: std::vector vi; vi.push_back(1); vi.push_back(2); vi.push_back(3); vs. VAR s := NEW(IntSeq.T).init(); s.addhi(1); s.addhi(2); s.addhi(3); vector is small, contains 3 pointers. And one level of indirection for accessing the data. printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. IntSeq.T is one pointer, and probably contains also approximately 3 pointers. The Modula-3 has an extra level of indirection. Not every function should be "virtual". "object.method" is useful syntax for statically typed "object". s.get(0) probably involves like 3 pointer derefences. Somewhat this is a "standard library" matter. But I think the language is probably slightly lacking too. I understand that if the "virtual-ness" is part of the interface..you could have: si: IntSeq.T; IntSeq.push_back(si, 1); (* static non-virtual dispatch *) IntSeq.push_back(si, 2); IntSeq.push_back(si, 3); si.data[0]; (* public data *) This is good and bad. It is both better and worse to have the "virtual-ness" affect the public interface. Exposing data like that, well, that's kind of a quality of implementation matter. I could have it be. IntSeq.get(si, 0); and leave it up to the compiler to inline.. I have to go... - Jay > Date: Wed, 3 Oct 2012 20:40:57 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 09/30/2012 01:06 AM, Jay K wrote: > > I believe opinion remains strongly mixed on garbage collection / "managed" > > etc. There is a lot of "managed" code. There is a lot of "native" code. > > We all use a lot of both every day. > > > > > > Modula-3 is actually pretty unusual in being native code and having garbage collection. > > It is pretty unusual in having optional garbage collection. > > It is pretty unusual in having optional safety. > > C# allows some safety relaxation within "unsafe" blocks. > > Like pointer manipulation. > > > > It pains me slightly in Modula-3 to write e.g. > > > > RTIO.PutText("foo " & Fmt.Int(123) & "bar"); > > I've created at least two pieces of garbage. > > In C++ any temporary strings would be cleaned up > > right away at a deterministic time. > > > > > > I'm really torn. > > C# seems to be a highly "productive" "environment" (the language, > > the libraries, possibly the IDEs). Perhaps far more than any C++ or Modula-3. > > I know people who work on kernel drivers. They still use C. > > > > > > I don't just want UNTRACED OBJECT. > > I also want stack allocated objects. > > C++ has them. > > > > This idea has never made any sense to me at all: > > 1) No OOP advocate would let you get away with calling it OOP without > having dispatching methods. (This despite the fact that the great > majority of OO examples don't actually use them, and thus are really > ADT programming.) > > 2) You can't actually use dispatching unless your variable can dynamically > be assigned values of different subclasses at different times. Degenerately > using a linguistic mechanism that dispatches, but the algorithm ensures it > is always to the same place, does not count. > > 3) If a stack object is to be dynamically assignable to values of different > subclasses, the compiler is going to have to allocate space for the > largest of these. That can be declared anywhere, in a place unknown > to exist, at the point where the variable is declared. I think I can > see a way this could be implemented with whole-program techniques, but > it still won't work with dynamically linked libraries, which rules out > a major part of what the staunch OOP advocates advocate. And it creates > a new kind of space waste. > > 4) Alternatively, a compiler could actually hiddenly allocate the > objects in the heap and put a pointer on the stack. But now any real > or imagined performance gains from on-stack objects are gone. Moreover, > there will be reference assignment vs. value assignment semantic > distinctions that violate what local variables are expected to do, > with sometimes big bugs as consequence. > > 5) A compiler could fix this by simulating the correct value assignment > semantics, making heap copies whenever necessary. This makes it > effectively a functional language, which certainly would require a GC > and greatly increases the volume of allocated and collected heap > objects. > > 6) Or, a programmer could explicitly take pointers to stack objects of > various subclasses and assign them to the same variable at different > times. I guess this is what is done in C++. This amounts to enticing > the naive to try dancing on a tight-wire over Dangling Pointer Abyss. > Which would justify Stroustrup's comment. > > 7) Finally, a programmer diligent and skillful enough to pull this off > would be extremely hard pressed to find an application where the > actual stack lifetimes of the different subclass objects had any > significant correlation to the real lifetimes of their usefulness > to the program. > > > class C > > { > > void F1(); > > virtual void F2(); > > }; > > > > void F3() > > { > > C c; > > } > > > > > > I think the nearest equivalent in Modula-3 is a stack allocated RECORD > > with function pointers. > > > > > > - Jay > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 07:45:10 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 05:45:10 +0000 Subject: [M3devel] another reminder -- jmpbuf size independence? Message-ID: Along with cooperative suspend, it'd be great if jmpbuf size was not known to cm3.We know roughly how to fix this -- use alloca(Csetjmp_jmpbuf_size).At function entry. Not in any loop.Or possibly in loop, but with a null check.VAR jmpbuf: ADDRESS := NIL;LOOP IF jmpbuf = NIL THEN jmpbuf := alloca(Csetjmp_jmpbuf_size); END; :) Granted, I want all layout optionally out of the frontend, and this is only part of the problem. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 08:13:28 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Message-ID: Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 08:25:53 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 06:25:53 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: References: Message-ID: declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 and here is some relevant M3x86 code: IF u.in_proc THEN v := get_temp_var (u, type, s, a, n); ELSE v := create_temp_var (u, type, s, a, n); END; PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name := M3ID.NoID): x86Var = BEGIN (* round size and alignment up to 4 *) IF s < 4 THEN s := 4; END; IF a < 4 THEN a := 4; END; PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name): x86Var = VAR v := NewVar(u, type, 0, s, a, n); BEGIN v.loc := VLoc.temp; v.parent := u.current_proc; u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, Alignmask[a]); INC(u.current_proc.framesize, s); v.offset := -u.current_proc.framesize; RETURN v; END create_temp_var; which isn't clear by inspection...it actually looks likezero size is allowed through commonly...in_proc is rare,so create is common...assuming the frame is already aligned,the size remains unchanged... Relevant aside: I have been ignoring alignment.I'm inclined to go with something like: <* ASSERT (size MOD alignment) = 0 *> If that ever fails, then I will change it to: FUNCTION RoundUp(a, b: INTEGER): INTEGER =BEGIN WITH c = a MOD b DO IF c # 0 THEN RETURN a + b - c; END; END; RETURN a;END; size := RoundUp(size, alignment); and then, more to the point, I'll go with: IF size = 0 THEN size = 1;END; I haven't dug into what the gcc backend would do here, too muchto dig through. :) Thoughts? I guess I should try both m3x86 and m3cc, and print the addressof these things???? - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 09:00:40 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 07:00:40 +0000 Subject: [M3devel] FW: entire system compiled with C backend In-Reply-To: <20121004065855.7FB082474003@birch.elegosoft.com> References: <20121004065855.7FB082474003@birch.elegosoft.com> Message-ID: entire system compiled with C backend: > Date: Thu, 4 Oct 2012 08:58:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/04 08:58:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > assert that alignments are all ok > If that fails, we'll round up in the backend. > assert that size >= 0 (and not merely > 0) > size := MAX(size, 1) (convert 0 to 1 -- 0 occurs) > perhaps it should be size := MAX(size, aligment) > > Should alignment be rounded up to 4 or 8 for variables like M3x86 does? > > I have now compiled the entire system using the C backend > targeting AMD64_DARWIN. This is a very big milestone. > > This last change has only been tested on a small part of the tree. > (i.e. that which has zero-sized variables, and everything "after" it) > > I can bring up and interact with various gui apps -- tetris, BadBricks (somewhat), > Juno, mentor (at least somehow). > > Juno doesn't come up centered, and I recall it always did before. > That might be something to look into. > > As well, the compiler has long been compiling itself. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 15:08:12 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 06:08:12 -0700 Subject: [M3devel] FW: entire system compiled with C backend In-Reply-To: References: <20121004065855.7FB082474003@birch.elegosoft.com> Message-ID: <20121004130812.B4AA11A207D@async.async.caltech.edu> This is very cool!!! Jay K writes: >--_333b0016-47c7-43b4-813e-76fd02b5ee50_ >Content-Type: text/plain; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > >entire system compiled with C backend: > > >> Date: Thu=2C 4 Oct 2012 08:58:55 +0000 >> To: m3commit at elegosoft.com >> From: jkrell at elego.de >> Subject: [M3commit] CVS Update: cm3 >>=20 >> CVSROOT: /usr/cvs >> Changes by: jkrell at birch. 12/10/04 08:58:55 >>=20 >> Modified files: >> cm3/m3-sys/m3back/src/: M3C.m3=20 >>=20 >> Log message: >> assert that alignments are all ok >> If that fails=2C we'll round up in the backend. >> assert that size >=3D 0 (and not merely > 0) >> size :=3D MAX(size=2C 1) (convert 0 to 1 -- 0 occurs) >> perhaps it should be size :=3D MAX(size=2C aligment) >> =09 >> Should alignment be rounded up to 4 or 8 for variables like M3x86 does? >> =09 >> I have now compiled the entire system using the C backend >> targeting AMD64_DARWIN. This is a very big milestone. >> =09 >> This last change has only been tested on a small part of the tree. >> (i.e. that which has zero-sized variables=2C and everything "after" it) >> =09 >> I can bring up and interact with various gui apps -- tetris=2C BadBricks= > (somewhat)=2C >> Juno=2C mentor (at least somehow). >> =09 >> Juno doesn't come up centered=2C and I recall it always did before. >> That might be something to look into. >> =09 >> As well=2C the compiler has long been compiling itself. >>=20 > = > >--_333b0016-47c7-43b4-813e-76fd02b5ee50_ >Content-Type: text/html; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > >
rif">entire system compiled with C backend:
i=2C sans-serif">


ans-serif=3B font-size: 12pt=3B ">
>= >=3B Date: Thu=2C 4 Oct 2012 08:58:55 +0000
>=3B To: m3commit at elegosoft= >.com
>=3B From: jkrell at elego.de
>=3B Subject: [M3commit] CVS Upda= >te: cm3
>=3B
>=3B CVSROOT: /usr/cvs
>=3B Changes by: jkrell= >@birch. 12/10/04 08:58:55
>=3B
>=3B Modified files:
>=3B c= >m3/m3-sys/m3back/src/: M3C.m3
>=3B
>=3B Log message:
>=3B = > assert that alignments are all ok
>=3B If that fails=2C we'll round = >up in the backend.
>=3B assert that size >=3B=3D 0 (and not merely = >>=3B 0)
>=3B size :=3D MAX(size=2C 1) (convert 0 to 1 -- 0 occurs)<= >br>>=3B perhaps it should be size :=3D MAX(size=2C aligment)
>=3B = >
>=3B Should alignment be rounded up to 4 or 8 for variables like M3x= >86 does?
>=3B
>=3B I have now compiled the entire system using= > the C backend
>=3B targeting AMD64_DARWIN. This is a very big milest= >one.
>=3B
>=3B This last change has only been tested on a smal= >l part of the tree.
>=3B (i.e. that which has zero-sized variables=2C= > and everything "after" it)
>=3B
>=3B I can bring up and inter= >act with various gui apps -- tetris=2C BadBricks (somewhat)=2C
>=3B J= >uno=2C mentor (at least somehow).
>=3B
>=3B Juno doesn't come = >up centered=2C and I recall it always did before.
>=3B That might be = >something to look into.
>=3B
>=3B As well=2C the compiler has = >long been compiling itself.
>=3B
ody> >= > >--_333b0016-47c7-43b4-813e-76fd02b5ee50_-- From jay.krell at cornell.edu Thu Oct 4 18:16:00 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 16:16:00 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: Yes..the assertions all passes..but granted, maybe we don't have full coverage. I can look at the frontend, or just make it so in the backend. On further thought..by quick read..this M3x86.m3 code is questionable.While in_proc is usually false for declare_local, I think it really goes both ways.So it looks like size is sometimes rounded up to 4, sometimes left as zero. But what does it mean?Does a zero sized array get any storage?In C and C++, two objects can't be at the same address, so, for example:struct foo { } bar; is not legal C. It is legal C++, however: struct foo { } a,b;assert(&a != &b); will pass. andvoid* a = malloc(0);void* b = malloc(0);assert(a != b) will also pass in C and C++. That is, size 0 struct is invalid in C. In C++ it is rounded up to at least 1.malloc(0) is rounded up to at least 1.No two "objects" can have the same address. What is the meaning Modula-3?Rounding up to 1 or alignment seems easy/decent.Certainly these zero sized things are rare in our tree. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] zero sized structs? Date: Thu, 4 Oct 2012 09:21:28 -0400 To: jay.krell at cornell.edu Try to respect alignment. Sent from my iPad On Oct 4, 2012, at 2:25 AM, Jay K wrote: declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 and here is some relevant M3x86 code: IF u.in_proc THEN v := get_temp_var (u, type, s, a, n); ELSE v := create_temp_var (u, type, s, a, n); END; PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name := M3ID.NoID): x86Var = BEGIN (* round size and alignment up to 4 *) IF s < 4 THEN s := 4; END; IF a < 4 THEN a := 4; END; PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name): x86Var = VAR v := NewVar(u, type, 0, s, a, n); BEGIN v.loc := VLoc.temp; v.parent := u.current_proc; u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, Alignmask[a]); INC(u.current_proc.framesize, s); v.offset := -u.current_proc.framesize; RETURN v; END create_temp_var; which isn't clear by inspection...it actually looks likezero size is allowed through commonly...in_proc is rare,so create is common...assuming the frame is already aligned,the size remains unchanged... Relevant aside: I have been ignoring alignment.I'm inclined to go with something like: <* ASSERT (size MOD alignment) = 0 *> If that ever fails, then I will change it to: FUNCTION RoundUp(a, b: INTEGER): INTEGER =BEGIN WITH c = a MOD b DO IF c # 0 THEN RETURN a + b - c; END; END; RETURN a;END; size := RoundUp(size, alignment); and then, more to the point, I'll go with: IF size = 0 THEN size = 1;END; I haven't dug into what the gcc backend would do here, too muchto dig through. :) Thoughts? I guess I should try both m3x86 and m3cc, and print the addressof these things???? - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 18:17:37 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 16:17:37 +0000 Subject: [M3devel] another reminder -- jmpbuf size independence? In-Reply-To: <1C9D3D9A-57A8-45EE-8185-0ABD3341A6C7@gmail.com> References: , <1C9D3D9A-57A8-45EE-8185-0ABD3341A6C7@gmail.com> Message-ID: Agreed. TRY FOR i := 1 TO 100 DO TRY FOR j := 1 TO 100 DO END; FINALLYENDFINALLY should have two variables, allocate 2 * sizeof(jmpbuf), call alloca twice (most likely -- obviously it could be optimized), not 200 times. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] another reminder -- jmpbuf size independence? Date: Thu, 4 Oct 2012 09:25:14 -0400 To: jay.krell at cornell.edu Don't you need separate jmpbuf per exception scope? Sent from my iPad On Oct 4, 2012, at 1:45 AM, Jay K wrote: Along with cooperative suspend, it'd be great if jmpbuf size was not known to cm3.We know roughly how to fix this -- use alloca(Csetjmp_jmpbuf_size).At function entry. Not in any loop.Or possibly in loop, but with a null check.VAR jmpbuf: ADDRESS := NIL;LOOP IF jmpbuf = NIL THEN jmpbuf := alloca(Csetjmp_jmpbuf_size); END; :) Granted, I want all layout optionally out of the frontend, and this is only part of the problem. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 20:13:21 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 11:13:21 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> References: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> Message-ID: <2193F183-F903-44AA-BD13-D1354739FF7D@gmail.com> > No storage. That has been thought through and all ramifications are ok? And gcc backend does what is expected? -- multiple variables have same address. I'll answer some of the questions later -- try out gcc backend and NT/x86. NT/x86 looks "inconsistent" between variable at top of procedure vs sub blocks. The C/C++ design feels more conservative and safe and also reasonable and cheap enough. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 10:22 AM, Antony Hosking wrote: > No storage. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 20:15:47 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 11:15:47 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> References: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> Message-ID: <7C06CF62-3526-4E9C-BD84-2130CAD5CF0C@gmail.com> > But you can have zero-length arrays in C. Not in ANSI C 1989. Maybe C9X variable length ("open") arrays can be zero? But I bet maybe alloca(0) rounds up, like malloca(0). C really avoids zero sized things.. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 10:22 AM, Antony Hosking wrote: > But you can have zero-length arrays in C. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 20:23:39 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 11:23:39 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: <20121004182339.3ECEC1A207D@async.async.caltech.edu> It seems that CM3 puts them at the "same address".... UNSAFE MODULE Main; IMPORT IO, Fmt; TYPE T = ARRAY [1..-1] OF INTEGER; VAR t := NEW(REF T); u := NEW(REF T); v : T; w : T; BEGIN IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n"); END Main. (114)async:~/ttt/src>../AMD64_LINUX/prog 2269030 2269040 602218 602218 I don't see a problem with it. Whoever thinks he needs to check whether ADR(v) equals ADR(w) should be using a different programming language... Mika From hosking at cs.purdue.edu Thu Oct 4 19:22:04 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 4 Oct 2012 13:22:04 -0400 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> On Oct 4, 2012, at 12:16 PM, Jay K wrote: > Yes..the assertions all passes..but granted, maybe we don't have full coverage. I can look at the frontend, or just make it so in the backend. > > > On further thought..by quick read..this M3x86.m3 code is questionable. > While in_proc is usually false for declare_local, I think it really goes both ways. > So it looks like size is sometimes rounded up to 4, sometimes left as zero. > > > But what does it mean? > Does a zero sized array get any storage? No storage. > In C and C++, two objects can't be at the same address, so, for example: > struct foo { } bar; is not legal C. It is legal C++, however: But you can have zero-length arrays in C. > > > struct foo { } a,b; > assert(&a != &b); will pass. > > > and > void* a = malloc(0); > void* b = malloc(0); > assert(a != b) will also pass in C and C++. > > > That is, size 0 struct is invalid in C. In C++ it is rounded up to at least 1. > malloc(0) is rounded up to at least 1. > No two "objects" can have the same address. > > > What is the meaning Modula-3? > Rounding up to 1 or alignment seems easy/decent. > Certainly these zero sized things are rare in our tree. > > > - Jay > > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] zero sized structs? > Date: Thu, 4 Oct 2012 09:21:28 -0400 > To: jay.krell at cornell.edu > > Try to respect alignment. > > Sent from my iPad > > On Oct 4, 2012, at 2:25 AM, Jay K wrote: > > > declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 > > > and here is some relevant M3x86 code: > > IF u.in_proc THEN > v := get_temp_var (u, type, s, a, n); > ELSE > v := create_temp_var (u, type, s, a, n); > END; > > > PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; > n: Name := M3ID.NoID): x86Var = > BEGIN > > (* round size and alignment up to 4 *) > > IF s < 4 THEN > s := 4; > END; > > IF a < 4 THEN > a := 4; > END; > > > PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; > n: Name): x86Var = > VAR v := NewVar(u, type, 0, s, a, n); > BEGIN > v.loc := VLoc.temp; > v.parent := u.current_proc; > > u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, > Alignmask[a]); > > INC(u.current_proc.framesize, s); > > v.offset := -u.current_proc.framesize; > > RETURN v; > END create_temp_var; > > > which isn't clear by inspection...it actually looks like > zero size is allowed through commonly...in_proc is rare, > so create is common...assuming the frame is already aligned, > the size remains unchanged... > > > Relevant aside: I have been ignoring alignment. > I'm inclined to go with something like: > > <* ASSERT (size MOD alignment) = 0 *> > > > If that ever fails, then I will change it to: > > > FUNCTION RoundUp(a, b: INTEGER): INTEGER = > BEGIN > WITH c = a MOD b DO > IF c # 0 THEN > RETURN a + b - c; > END; > END; > RETURN a; > END; > > size := RoundUp(size, alignment); > > > and then, more to the point, I'll go with: > > IF size = 0 THEN > size = 1; > END; > > > I haven't dug into what the gcc backend would do here, too much > to dig through. :) > > > Thoughts? > > > I guess I should try both m3x86 and m3cc, and print the address > of these things???? > > > - Jay > > > > From: jay.krell at cornell.edu > To: m3devel at elegosoft.com > Date: Thu, 4 Oct 2012 06:13:28 +0000 > Subject: [M3devel] zero sized structs? > > Building obliqrt I get: > > > *** > *** runtime error: > *** <*ASSERT*> failed. > *** file "../src/M3C.m3", line 1768 > *** > > > > PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var = > BEGIN > IF type = Type.Struct THEN > <* ASSERT byte_size > 0 *> > self.sizes[self.count] := byte_size; > INC(self.count); > END; > RETURN NIL; > END GetStructSizes_Declare; > > > due to presumably: > > > PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = > VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; > > > ... > > PROCEDURE HandleWork (self: ObliqWork) = > VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; > > .. > PROCEDURE EvalThread ( self : PackageThread; > ... > noArgs : ARRAY [0 .. -1] OF ObValue.Val; > > > What is the meaning of this? > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Thu Oct 4 20:30:40 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Thu, 4 Oct 2012 20:30:40 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , , , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu>, , <506CE929.3000008@lcwb.coop> Message-ID: On Oct 4, 2012, at 3:59 AM, Jay K wrote: > vector is small, contains 3 pointers. > And one level of indirection for accessing the data. > printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. Probably because preprocessor is in this equation? > > > > IntSeq.T is one pointer, and probably contains also approximately 3 pointers. > The Modula-3 has an extra level of indirection. And what is vector if not pointer to some collection of pointers? IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :). In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need. > > > Not every function should be "virtual". > "object.method" is useful syntax for statically typed "object". > s.get(0) probably involves like 3 pointer derefences. As opossed to C++'s two dereferences? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 21:33:33 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 12:33:33 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <20121004182339.3ECEC1A207D@async.async.caltech.edu> References: <20121004182339.3ECEC1A207D@async.async.caltech.edu> Message-ID: Same address & same size implies same object & same type. But the types can vary. Please check also variables in sub-blocks. I think NT/x86 backend doesn't always put them at same place. Then again, that is probably ok too -- in general not all zero sized objects can be located -- they could be locals in different functions or globals in different modules. You say use a different language, but 1) they are exceedingly rare so ok to waste space 2) as small & simple Modula-3 is, it is still really isn't small or simple, there are surprising number & level of detail to understand and deal with. Adding a notion of a zero sized thing isn't necessarily so obviously simple and free of complexity down the line. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 11:23 AM, wrote: > It seems that CM3 puts them at the "same address".... > > UNSAFE MODULE Main; > IMPORT IO, Fmt; > > TYPE > T = ARRAY [1..-1] OF INTEGER; > > VAR t := NEW(REF T); u := NEW(REF T); > v : T; > w : T; > BEGIN > IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n"); > END Main. > > (114)async:~/ttt/src>../AMD64_LINUX/prog > 2269030 > 2269040 > 602218 > 602218 > > I don't see a problem with it. Whoever thinks he needs to check whether > ADR(v) equals ADR(w) should be using a different programming language... > > Mika > From jay.krell at cornell.edu Thu Oct 4 21:44:19 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 12:44:19 -0700 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <506CE929.3000008@lcwb.coop> Message-ID: Preprocessor does historically help -- makes inlining easier, including making sizes visible. > And what is vector if not pointer to some collection of pointers? No. Pointers to ints. The three pointers are start, just past end, just past end of allocation. Maybe easier to see as a pointer and 2 integers -- size and allocated size. But they are size_t and not 32bit int. I'll present object code later... - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 11:30 AM, Dragi?a Duri? wrote: > > > On Oct 4, 2012, at 3:59 AM, Jay K wrote: > >> vector is small, contains 3 pointers. >> And one level of indirection for accessing the data. >> printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. > > Probably because preprocessor is in this equation? > >> >> >> >> IntSeq.T is one pointer, and probably contains also approximately 3 pointers. >> The Modula-3 has an extra level of indirection. > > And what is vector if not pointer to some collection of pointers? > > IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :). > > In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need. > >> >> >> Not every function should be "virtual". >> "object.method" is useful syntax for statically typed "object". >> s.get(0) probably involves like 3 pointer derefences. > > As opossed to C++'s two dereferences? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 22:37:33 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 13:37:33 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: <20121004182339.3ECEC1A207D@async.async.caltech.edu> Message-ID: <20121004203733.0E95A1A207D@async.async.caltech.edu> Well as a user I'm quite happy to see the two objects have different addresses, if it makes your life easier as a compiler writer. However it's certainly not documented---so I'd better not depend on it! You're not supposed to be taking the ADR of stuff on the stack. It's UNSAFE, caveat emptor, etc... I'm just saying that if you are doing that you're not writing programs that Modula-3 was intended for. If you want to pass something by reference, use VAR! I find that when you have trouble with zero-sized anything, you've usually used the wrong abstraction.... In any case the fact that the language allows certain things to be zero sized is very helpful when you are writing programs that have to generate Modula-3 code. You don't have to keep track and insert dummies in various places. But sure I can't think of any reason the compiler couldn't implement zero-sized things as being one-sized or four-sized, or whatever it/you want/s. It looks like they take 16 bytes when you NEW them... (of course the report also says that "The reference returned by NEW is distinct from all existing references") Mika Jay writes: >Same address & same size implies same object & same type. But the types can v= >ary. Please check also variables in sub-blocks. I think NT/x86 backend doesn= >'t always put them at same place. Then again, that is probably ok too -- in g= >eneral not all zero sized objects can be located -- they could be locals in d= >ifferent functions or globals in different modules. > > >You say use a different language, but 1) they are exceedingly rare so ok to w= >aste space 2) as small & simple Modula-3 is, it is still really isn't small o= >r simple, there are surprising number & level of detail to understand and de= >al with. Adding a notion of a zero sized thing isn't necessarily so obviousl= >y simple and free of complexity down the line.=20 > > > > - Jay (briefly/pocket-sized-computer-aka-phone) > >On Oct 4, 2012, at 11:23 AM, wrote: > >> It seems that CM3 puts them at the "same address".... >>=20 >> UNSAFE MODULE Main; >> IMPORT IO, Fmt; >>=20 >> TYPE >> T =3D ARRAY [1..-1] OF INTEGER; >>=20 >> VAR t :=3D NEW(REF T); u :=3D NEW(REF T); >> v : T; >> w : T; >> BEGIN >> IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base :=3D 16) & "\n"); >> END Main. >>=20 >> (114)async:~/ttt/src>../AMD64_LINUX/prog >> 2269030 >> 2269040 >> 602218 >> 602218 >>=20 >> I don't see a problem with it. Whoever thinks he needs to check whether >> ADR(v) equals ADR(w) should be using a different programming language... >>=20 >> Mika >>=20 From jay.krell at cornell.edu Thu Oct 4 23:27:55 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 21:27:55 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: <20121004203733.0E95A1A207D@async.async.caltech.edu> References: , , , , <20121004182339.3ECEC1A207D@async.async.caltech.edu>, , <20121004203733.0E95A1A207D@async.async.caltech.edu> Message-ID: > (of course the report also says that "The reference returned by NEW is distinct from all existing references") Aha. Good.And doesn't it seem kind of nice and correct if that same sort of thing applied to locals and globals?More consistent that way? Really I wouldn't mind if ARRAY [0..0] or ARRAY [0..-1] was just plain illegal.The following are not legal standard C/89/90:int a[-1];int a[0]; Though int a[0] may be a popular extension -- in both gcc and Visual C++ -- and many other compilers are forced to follow their lead. I know we don't in general "do what C does" but C is not really a set of all bad decisions that should all be avoided, and in fact, Modula-3 is almost trivially isomorphic to C. The main differences are 1) it disallows some operations 2) it adds optional garbage collection via inserted barrier checks 3) generics and vtables which are a fairly simple layering 4) strict interface separation which is just enforcing what people can do do in C, but it is important that it is strict, since it allows for faster compilation.) In the face of my own ignorance, I think considering what C and C++ do is not a bad option. They avoid the existance of zero sized things. On the other hand, C++ compilers then do work hard to "reoptimize" because of this. By "reoptimize" I mean, removal of zero sized things can actually be a significant deoptimization, that you then have to be pretty clever to optimize..when..if only zero size was ok in the first place, it would have been easy to keep optimal.In particular: struct A { }; struct B : A { }; struct C : B { }; struct D : C { }; struct E : D { }; what is the sizeof(E)? If zero size was ok, then the sizeof(A) and B and C and D and E would all be zero and the compiler's job would be easy. In reality keeping the sizeof(E) "small" isn't trivial. Perhaps perhaps multiple inheritance is needed to make the point. Let's see..hm..I need to research this..the "empty base optimization"..the problem doesn't seem that bad..without multiple inherirtance, the size was only 1. struct A1 { }; struct A2 { }; struct B1 : A1, A2 { }; struct B2 : A1, A2 { }; struct C1 : B1, B2 { }; struct C2 : B1, B2 { }; struct D : C1, C2 { }; struct E : D { }; extern int a = sizeof(E); Only with a "mess" could I blow it up e.g. 7: F:\>type 1.cpp && cl -c -FAsc 1.cpp && more 1.cod struct A1 { }; struct A2 { }; struct B1 : A1, A2 { }; struct B2 : A1, A2 { }; struct C1 : B1, B2 { }; struct C2 : B1, B2 { }; struct D : C1, C2 { }; struct E : D { }; extern int a = sizeof(E); Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.278 for x64 Copyright (C) Microsoft Corporation. All rights reserved.1.cpp ; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.278 include listing.incINCLUDELIB LIBCMT INCLUDELIB OLDNAMESPUBLIC ?a@@3HA ; a _DATA SEGMENT ?a@@3HA DD 07H ; a _DATA ENDS END - Jay > To: jay.krell at cornell.edu > Date: Thu, 4 Oct 2012 13:37:33 -0700 > From: mika at async.caltech.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] zero sized structs? > > > Well as a user I'm quite happy to see the two objects have different > addresses, if it makes your life easier as a compiler writer. However > it's certainly not documented---so I'd better not depend on it! > You're not supposed to be taking the ADR of stuff on the stack. > It's UNSAFE, caveat emptor, etc... I'm just saying that if you are > doing that you're not writing programs that Modula-3 was intended for. > If you want to pass something by reference, use VAR! > > I find that when you have trouble with zero-sized anything, you've usually > used the wrong abstraction.... In any case the fact that the language > allows certain things to be zero sized is very helpful when you are writing > programs that have to generate Modula-3 code. You don't have to keep > track and insert dummies in various places. But sure I can't think of any > reason the compiler couldn't implement zero-sized things as being one-sized > or four-sized, or whatever it/you want/s. It looks like they take 16 bytes > when you NEW them... (of course the report also says that "The reference > returned by NEW is distinct from all existing references") > > Mika > > > Jay writes: > >Same address & same size implies same object & same type. But the types can v= > >ary. Please check also variables in sub-blocks. I think NT/x86 backend doesn= > >'t always put them at same place. Then again, that is probably ok too -- in g= > >eneral not all zero sized objects can be located -- they could be locals in d= > >ifferent functions or globals in different modules. > > > > > >You say use a different language, but 1) they are exceedingly rare so ok to w= > >aste space 2) as small & simple Modula-3 is, it is still really isn't small o= > >r simple, there are surprising number & level of detail to understand and de= > >al with. Adding a notion of a zero sized thing isn't necessarily so obviousl= > >y simple and free of complexity down the line.=20 > > > > > > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > > >On Oct 4, 2012, at 11:23 AM, wrote: > > > >> It seems that CM3 puts them at the "same address".... > >>=20 > >> UNSAFE MODULE Main; > >> IMPORT IO, Fmt; > >>=20 > >> TYPE > >> T =3D ARRAY [1..-1] OF INTEGER; > >>=20 > >> VAR t :=3D NEW(REF T); u :=3D NEW(REF T); > >> v : T; > >> w : T; > >> BEGIN > >> IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base :=3D 16) & "\n"); > >> END Main. > >>=20 > >> (114)async:~/ttt/src>../AMD64_LINUX/prog > >> 2269030 > >> 2269040 > >> 602218 > >> 602218 > >>=20 > >> I don't see a problem with it. Whoever thinks he needs to check whether > >> ADR(v) equals ADR(w) should be using a different programming language... > >>=20 > >> Mika > >>=20 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 23:51:02 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 14:51:02 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: , , , , <20121004182339.3ECEC1A207D@async.async.caltech.edu>, , <20121004203733.0E95A1A207D@async.async.caltech.edu> Message-ID: <20121004215102.450531A207D@async.async.caltech.edu> > > (of course the report also says that "The reference returned by NEW is d= >istinct from all existing references") Aha. Good.And doesn't it seem kind o= >f nice and correct if that same sort of thing applied to locals and globals= >?More consistent that way? Well either way it's just not visible from the safe subset of the language... >Really I wouldn't mind if ARRAY [0..0] or ARRAY = >[0..-1] was just plain illegal.The following are not legal standard C/89/90= Sure but C doesn't have a type [0..-1] either... and I don't think you can get away without those sorts of types (called "empty types" in the report). HOWEVER, declaring a variable of an empty type or NEWing an empty type is a static error... There's a little section in the report about "making non-empty types out of empty types". The example is x : [0..-1]; (* illegal *) y := NEW(REF [0..-1]); (* illegal *) s : SET OF [0..-1]; (* legal *) s is legal because the type isn't empty; it contains the empty set. Likewise I suppose ARRAY OF [0..-1] also is legal because it contains the empty array. But sure there's a stronger argument for ruling the latter illegal than the former. The problem is, though, that that leaves you no way of statically declaring an array of size zero, which is certainly a useful concept. E.g., x : REF ARRAY OF INTEGER := NEW(REF ARRAY OF INTEGER, 0); ... WITH new = NEW(REF ARRAY OF INTEGER, NUMBER(x^) + 1) DO SUBARRAY(new^, 0, NUMBER(x^)) := x^; new[LAST(new^)] := newElement; END ... So I don't use [0..-1] here but you could certainly see xx : ARRAY [0..-1] OF INTEGER as being compatible with the initial value of x. Mika From hosking at cs.purdue.edu Fri Oct 5 15:31:02 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 5 Oct 2012 09:31:02 -0400 Subject: [M3devel] Output from "cron" command In-Reply-To: References: <201210041115.q94BFkUE006378@niagara.cs.purdue.edu>, , , Message-ID: <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> Jay, is there any chance we can put your M3C backend stuff in a separate library. I don?t understand why we are adding clutter to m3middle. Similarly, your hacks to m3cgcat to run your C backend should be duplicated in the C backend space rather than in m3cgcat. I?d prefer to keep m3middle as pristine as it was previously if only to avoid confusion for others. From jay.krell at cornell.edu Fri Oct 5 15:42:39 2012 From: jay.krell at cornell.edu (Jay) Date: Fri, 5 Oct 2012 06:42:39 -0700 Subject: [M3devel] Output from "cron" command In-Reply-To: <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> References: <201210041115.q94BFkUE006378@niagara.cs.purdue.edu> <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> Message-ID: On the 2nd point I'll soon have m3c interface to quake. For performance w/o adding another "mode". But having a separate executable going via .mc files is great for development and testing. On the 1st point..I added files, didn't change, as I recall. No difference if they are in m3back or m3middle. I found that decision unclear -- m3back vs m3middle. What I added is likely useful to other backend writers. Very generic. I really think this is about the right design. But code can be split up and moved fairly arbitrarily, cluttering the tree with more directories & libraries... The m3cgcat change is elegant and not a hack imo & very few people know about or understand this stuff, there shouldn't be much chance for confusion, but whatever.... - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 5, 2012, at 6:31 AM, Antony Hosking wrote: > Jay, is there any chance we can put your M3C backend stuff in a separate library. > I don?t understand why we are adding clutter to m3middle. > > Similarly, your hacks to m3cgcat to run your C backend should be duplicated in the C backend space rather than in m3cgcat. > > I?d prefer to keep m3middle as pristine as it was previously if only to avoid confusion for others. > From jay.krell at cornell.edu Wed Oct 10 06:08:52 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 04:08:52 +0000 Subject: [M3devel] completing M3CG_Binary.Op? Message-ID: M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 06:36:36 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 00:36:36 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote: > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 06:52:18 2012 From: jay.krell at cornell.edu (Jay) Date: Tue, 9 Oct 2012 21:52:18 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > >> M3CG_Binary.Op currently represents >> what we write to ".mc" files for the gcc >> backend to read in. This is very very close >> to what you'd want to fully represent M3CG.T. >> >> >> It missing an operation that takes a function pointer -- can't >> be stored in a file. It is missing operations that get converted >> to different operations by M3CG_Wr. There is no real >> value in the transform but it doesn't hurt either. >> >> >> I'd like to add the missing operations. >> It seems like a very sensible reasonable change to me. >> >> >> >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >> retrieving revision 1.19 >> diff -u -r1.19 M3CG_BinRd.m3 >> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >> @@ -37,7 +37,7 @@ >> END; >> >> CONST >> - CmdMap = ARRAY Bop OF Cmd { >> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >> Cmd {Bop.begin_unit, begin_unit}, >> Cmd {Bop.end_unit, end_unit}, >> Cmd {Bop.import_unit, import_unit}, >> Index: M3CG_Binary.i3 >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >> retrieving revision 1.6 >> diff -u -r1.6 M3CG_Binary.i3 >> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >> @@ -38,7 +38,17 @@ >> call_indirect, pop_param, pop_struct, pop_static_link, >> load_procedure, load_static_link, comment, >> store_ordered, load_ordered, exchange, compare_exchange, fence, >> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >> + >> + (* These only occur in memory, not in files. >> + Conversely, what they are converted to only occur in files, >> + not in memory. *) >> + set_error_handler, (* disk: contains a pointer, silently skipped *) >> + compare (* converted to eq/ne/etc. *) >> + cvt_int, (* converted to trunc/ceiling/etc. *) >> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >> + if_compare, (* converted to if_eq/if_ne/etc. *) >> + set_compare, (* converted to set_eq/set_ne/etc. *) >> }; >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 07:35:58 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 01:35:58 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Why? On Oct 10, 2012, at 12:52 AM, Jay wrote: > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > >> Forgive me, but I don?t understand the purpose of this change. >> >> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >> >>> M3CG_Binary.Op currently represents >>> what we write to ".mc" files for the gcc >>> backend to read in. This is very very close >>> to what you'd want to fully represent M3CG.T. >>> >>> >>> It missing an operation that takes a function pointer -- can't >>> be stored in a file. It is missing operations that get converted >>> to different operations by M3CG_Wr. There is no real >>> value in the transform but it doesn't hurt either. >>> >>> >>> I'd like to add the missing operations. >>> It seems like a very sensible reasonable change to me. >>> >>> >>> >>> =================================================================== >>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>> retrieving revision 1.19 >>> diff -u -r1.19 M3CG_BinRd.m3 >>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>> @@ -37,7 +37,7 @@ >>> END; >>> >>> CONST >>> - CmdMap = ARRAY Bop OF Cmd { >>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>> Cmd {Bop.begin_unit, begin_unit}, >>> Cmd {Bop.end_unit, end_unit}, >>> Cmd {Bop.import_unit, import_unit}, >>> Index: M3CG_Binary.i3 >>> =================================================================== >>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>> retrieving revision 1.6 >>> diff -u -r1.6 M3CG_Binary.i3 >>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>> @@ -38,7 +38,17 @@ >>> call_indirect, pop_param, pop_struct, pop_static_link, >>> load_procedure, load_static_link, comment, >>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>> + >>> + (* These only occur in memory, not in files. >>> + Conversely, what they are converted to only occur in files, >>> + not in memory. *) >>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>> + compare (* converted to eq/ne/etc. *) >>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>> }; >>> >>> >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 07:59:34 2012 From: jay.krell at cornell.edu (Jay) Date: Tue, 9 Oct 2012 22:59:34 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Message-ID: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > >> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >> >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >> >>> Forgive me, but I don?t understand the purpose of this change. >>> >>> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >>> >>>> M3CG_Binary.Op currently represents >>>> what we write to ".mc" files for the gcc >>>> backend to read in. This is very very close >>>> to what you'd want to fully represent M3CG.T. >>>> >>>> >>>> It missing an operation that takes a function pointer -- can't >>>> be stored in a file. It is missing operations that get converted >>>> to different operations by M3CG_Wr. There is no real >>>> value in the transform but it doesn't hurt either. >>>> >>>> >>>> I'd like to add the missing operations. >>>> It seems like a very sensible reasonable change to me. >>>> >>>> >>>> >>>> =================================================================== >>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>>> retrieving revision 1.19 >>>> diff -u -r1.19 M3CG_BinRd.m3 >>>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>>> @@ -37,7 +37,7 @@ >>>> END; >>>> >>>> CONST >>>> - CmdMap = ARRAY Bop OF Cmd { >>>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>>> Cmd {Bop.begin_unit, begin_unit}, >>>> Cmd {Bop.end_unit, end_unit}, >>>> Cmd {Bop.import_unit, import_unit}, >>>> Index: M3CG_Binary.i3 >>>> =================================================================== >>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>>> retrieving revision 1.6 >>>> diff -u -r1.6 M3CG_Binary.i3 >>>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>>> @@ -38,7 +38,17 @@ >>>> call_indirect, pop_param, pop_struct, pop_static_link, >>>> load_procedure, load_static_link, comment, >>>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>>> + >>>> + (* These only occur in memory, not in files. >>>> + Conversely, what they are converted to only occur in files, >>>> + not in memory. *) >>>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>>> + compare (* converted to eq/ne/etc. *) >>>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>>> }; >>>> >>>> >>>> >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 08:33:13 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 02:33:13 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Message-ID: Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > >> Why? >> >> On Oct 10, 2012, at 12:52 AM, Jay wrote: >> >>> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >>> >>> >>> - Jay (briefly/pocket-sized-computer-aka-phone) >>> >>> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >>> >>>> Forgive me, but I don?t understand the purpose of this change. >>>> >>>> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >>>> >>>>> M3CG_Binary.Op currently represents >>>>> what we write to ".mc" files for the gcc >>>>> backend to read in. This is very very close >>>>> to what you'd want to fully represent M3CG.T. >>>>> >>>>> >>>>> It missing an operation that takes a function pointer -- can't >>>>> be stored in a file. It is missing operations that get converted >>>>> to different operations by M3CG_Wr. There is no real >>>>> value in the transform but it doesn't hurt either. >>>>> >>>>> >>>>> I'd like to add the missing operations. >>>>> It seems like a very sensible reasonable change to me. >>>>> >>>>> >>>>> >>>>> =================================================================== >>>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>>>> retrieving revision 1.19 >>>>> diff -u -r1.19 M3CG_BinRd.m3 >>>>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>>>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>>>> @@ -37,7 +37,7 @@ >>>>> END; >>>>> >>>>> CONST >>>>> - CmdMap = ARRAY Bop OF Cmd { >>>>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>>>> Cmd {Bop.begin_unit, begin_unit}, >>>>> Cmd {Bop.end_unit, end_unit}, >>>>> Cmd {Bop.import_unit, import_unit}, >>>>> Index: M3CG_Binary.i3 >>>>> =================================================================== >>>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>>>> retrieving revision 1.6 >>>>> diff -u -r1.6 M3CG_Binary.i3 >>>>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>>>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>>>> @@ -38,7 +38,17 @@ >>>>> call_indirect, pop_param, pop_struct, pop_static_link, >>>>> load_procedure, load_static_link, comment, >>>>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>>>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>>>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>>>> + >>>>> + (* These only occur in memory, not in files. >>>>> + Conversely, what they are converted to only occur in files, >>>>> + not in memory. *) >>>>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>>>> + compare (* converted to eq/ne/etc. *) >>>>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>>>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>>>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>>>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>>>> }; >>>>> >>>>> >>>>> >>>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 17:53:50 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 15:53:50 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , Message-ID: M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 18:13:51 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 12:13:51 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , Message-ID: <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote: > M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. > > - Jay > > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 02:33:13 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] completing M3CG_Binary.Op? > > Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? > > On Oct 10, 2012, at 1:59 AM, Jay wrote: > > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 01:33:35 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 23:33:35 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> Message-ID: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 11 02:18:03 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 20:18:03 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> Message-ID: <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: > > Look at M3CG_MultiPass. > > For each function, it creates a record to hold the parameters. > So they can be later be looped over in a different order and/or multiple times. > The record includes an enum. > I need an enum that looks almost exactly like M3CG_Binary.Op, > except that I need those few missing elements. > > M3CG_MultiPass already has most of this, except > 1) I somehow forgot got to handle a bunch of them > 2) I need the below diff for it to be complete, or some other nearly identical enum instead. > > - Jay > > Subject: Re: [M3devel] completing M3CG_Binary.Op? > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 12:13:51 -0400 > CC: m3devel at elegosoft.com > To: jay.krell at cornell.edu > > I still don?t understand why the change is needed. > > On Oct 10, 2012, at 11:53 AM, Jay K wrote: > > M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. > > - Jay > > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 02:33:13 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] completing M3CG_Binary.Op? > > Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? > > On Oct 10, 2012, at 1:59 AM, Jay wrote: > > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 05:08:41 2012 From: jay.krell at cornell.edu (Jay) Date: Wed, 10 Oct 2012 20:08:41 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> Message-ID: <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: > Why not simply capture the state of the existing ops? e.g,, cvt_int. > > On Oct 10, 2012, at 7:33 PM, Jay K wrote: > >> >> Look at M3CG_MultiPass. >> >> For each function, it creates a record to hold the parameters. >> So they can be later be looped over in a different order and/or multiple times. >> The record includes an enum. >> I need an enum that looks almost exactly like M3CG_Binary.Op, >> except that I need those few missing elements. >> >> M3CG_MultiPass already has most of this, except >> 1) I somehow forgot got to handle a bunch of them >> 2) I need the below diff for it to be complete, or some other nearly identical enum instead. >> >> - Jay >> >> Subject: Re: [M3devel] completing M3CG_Binary.Op? >> From: hosking at cs.purdue.edu >> Date: Wed, 10 Oct 2012 12:13:51 -0400 >> CC: m3devel at elegosoft.com >> To: jay.krell at cornell.edu >> >> I still don?t understand why the change is needed. >> >> On Oct 10, 2012, at 11:53 AM, Jay K wrote: >> >> M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. >> >> - Jay >> >> From: hosking at cs.purdue.edu >> Date: Wed, 10 Oct 2012 02:33:13 -0400 >> To: jay.krell at cornell.edu >> CC: m3devel at elegosoft.com >> Subject: Re: [M3devel] completing M3CG_Binary.Op? >> >> Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? >> >> On Oct 10, 2012, at 1:59 AM, Jay wrote: >> >> I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: >> >> Why? >> >> On Oct 10, 2012, at 12:52 AM, Jay wrote: >> >> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >> >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >> >> Forgive me, but I don?t understand the purpose of this change. >> >> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >> >> M3CG_Binary.Op currently represents >> what we write to ".mc" files for the gcc >> backend to read in. This is very very close >> to what you'd want to fully represent M3CG.T. >> >> >> It missing an operation that takes a function pointer -- can't >> be stored in a file. It is missing operations that get converted >> to different operations by M3CG_Wr. There is no real >> value in the transform but it doesn't hurt either. >> >> >> I'd like to add the missing operations. >> It seems like a very sensible reasonable change to me. >> >> >> >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >> retrieving revision 1.19 >> diff -u -r1.19 M3CG_BinRd.m3 >> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >> @@ -37,7 +37,7 @@ >> END; >> >> CONST >> - CmdMap = ARRAY Bop OF Cmd { >> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >> Cmd {Bop.begin_unit, begin_unit}, >> Cmd {Bop.end_unit, end_unit}, >> Cmd {Bop.import_unit, import_unit}, >> Index: M3CG_Binary.i3 >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >> retrieving revision 1.6 >> diff -u -r1.6 M3CG_Binary.i3 >> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >> @@ -38,7 +38,17 @@ >> call_indirect, pop_param, pop_struct, pop_static_link, >> load_procedure, load_static_link, comment, >> store_ordered, load_ordered, exchange, compare_exchange, fence, >> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >> + >> + (* These only occur in memory, not in files. >> + Conversely, what they are converted to only occur in files, >> + not in memory. *) >> + set_error_handler, (* disk: contains a pointer, silently skipped *) >> + compare (* converted to eq/ne/etc. *) >> + cvt_int, (* converted to trunc/ceiling/etc. *) >> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >> + if_compare, (* converted to if_eq/if_ne/etc. *) >> + set_compare, (* converted to set_eq/set_ne/etc. *) >> }; > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 07:46:07 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 11 Oct 2012 05:46:07 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu>, , <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu>, <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> Message-ID: Tony, I think you might not understand, or have it backwards. In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory. For example, M3CG_Wr.m3: PROCEDURE set_compare (u: U; s: ByteSize; op: CompareOp; t: IType) = (* s1.t := (s1.B op s0.B) ; pop *) CONST OpName = ARRAY CompareOp OF TEXT { "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" }; BEGIN Cmd (u, OpName [op]); Int (u, s); TName (u, t); NL (u); END set_compare; but in my M3CG_MultiPass.m3 (not necessarily the commited version!) PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare; so -- ok with my change? Thank you, - Jay From: jay.krell at cornell.edu Date: Wed, 10 Oct 2012 20:08:41 -0700 To: hosking at cs.purdue.edu CC: m3devel at elegosoft.com; jay.krell at cornell.edu Subject: Re: [M3devel] completing M3CG_Binary.Op? I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 08:23:34 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 11 Oct 2012 06:23:34 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , , , , , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu>, , , , <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu>, , <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com>, Message-ID: Here is a more heavily commented diff.Again, notice that the existing code does a small translation in writing files. My desire is to represent M3CG call sequence more directly. Granted, it might be reasonable, really, to change one or the other -- either make M3CG.T more closely resemble M3CG_Wr, or the other way around -- remove the transform and adjust one backend(s) or other.I'd also be putting in more newlines, either to separate every enum element here, or to separate all the newly-commented ones, and put the comment on each one. Index: m3-sys/m3cggen/src/Main.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3cggen/src/Main.m3,vretrieving revision 1.6diff -u -r1.6 Main.m3--- m3-sys/m3cggen/src/Main.m3 1 Nov 2010 09:59:44 -0000 1.6+++ m3-sys/m3cggen/src/Main.m3 11 Oct 2012 06:18:42 -0000@@ -9,7 +9,7 @@ Desc = RECORD name: TEXT; op: Op; END; CONST- Map = ARRAY Op OF Desc {+ Map = ARRAY [Op.begin_unit..Op.fetch_and_xor] OF Desc { Desc { "begin_unit", Op.begin_unit }, Desc { "end_unit", Op.end_unit }, Desc { "import_unit", Op.import_unit }, Index: m3-sys/m3middle/src/M3CG_BinRd.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- m3-sys/m3middle/src/M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ m3-sys/m3middle/src/M3CG_BinRd.m3 11 Oct 2012 06:18:42 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: m3-sys/m3middle/src/M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- m3-sys/m3middle/src/M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ m3-sys/m3middle/src/M3CG_Binary.i3 11 Oct 2012 06:18:42 -0000@@ -21,14 +21,19 @@ end_init, init_int, init_proc, init_label, init_var, init_offset, init_chars, init_float, import_procedure, declare_procedure, begin_procedure, end_procedure, begin_block, end_block,- note_procedure_origin, set_label, jump, if_true, if_false, if_eq,- if_ne, if_gt, if_ge, if_lt, if_le, case_jump, exit_proc, load,+ note_procedure_origin, set_label, jump, if_true, if_false,+ if_eq, if_ne, if_gt, if_ge, if_lt, if_le, (* file only; in-memory uses if_compare *)+ case_jump, exit_proc, load, load_address, load_indirect, store, store_indirect,- load_nil, load_integer, load_float, eq, ne,- gt, ge, lt, le, add, subtract, multiply, divide, negate, abs, max,- min, round, trunc, floor, ceiling, cvt_float, div, mod, set_union,+ load_nil, load_integer, load_float,+ eq, ne, gt, ge, lt, le, (* file only; in-memory uses compare *)+ add, subtract, multiply, divide, negate, abs, max,+ min,+ round, trunc, floor, ceiling, (* file only; in-memory uses cvt_int *)+ cvt_float, div, mod, set_union, set_difference, set_intersection, set_sym_difference, set_member,- set_eq, set_ne, set_lt, set_le, set_gt, set_ge, set_range,+ set_eq, set_ne, set_lt, set_le, set_gt, set_ge, (* file only; in-memory uses set_compare *)+ set_range, set_singleton, not, and, or, xor, shift, shift_left, shift_right, rotate, rotate_left, rotate_right, widen, chop, extract, extract_n, extract_mn, insert, insert_n, insert_mn, swap, pop, copy_n, copy,@@ -38,7 +43,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, (* file only; in-memory uses fetch_and_op *)+ fetch_and_sub, (* file only; in-memory uses fetch_and_op *)+ fetch_and_or, (* file only; in-memory uses fetch_and_op *)+ fetch_and_and, (* file only; in-memory uses fetch_and_op *)+ fetch_and_xor, (* file only; in-memory uses fetch_and_op *)+ set_error_handler, (* in-memory only; contains a pointer, so silently skipped in files *)+ compare, (* in-memory only; file converts to eq/ne/etc. *)+ cvt_int, (* in-memory only; file converts to trunc/ceiling/etc. *)+ fetch_and_op, (* in-memory only; file converts to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* in-memory only; file converts to if_eq/if_ne/etc. *)+ set_compare (* in-memory only; file converts to set_eq/set_ne/etc. *) }; (* Integers are encoded as sequences of unsigned bytes, [0..255]. - Jay From: jay.krell at cornell.edu To: hosking at cs.purdue.edu Date: Thu, 11 Oct 2012 05:46:07 +0000 CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Tony, I think you might not understand, or have it backwards. In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory. For example, M3CG_Wr.m3: PROCEDURE set_compare (u: U; s: ByteSize; op: CompareOp; t: IType) = (* s1.t := (s1.B op s0.B) ; pop *) CONST OpName = ARRAY CompareOp OF TEXT { "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" }; BEGIN Cmd (u, OpName [op]); Int (u, s); TName (u, t); NL (u); END set_compare; but in my M3CG_MultiPass.m3 (not necessarily the commited version!) PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare; so -- ok with my change? Thank you, - Jay From: jay.krell at cornell.edu Date: Wed, 10 Oct 2012 20:08:41 -0700 To: hosking at cs.purdue.edu CC: m3devel at elegosoft.com; jay.krell at cornell.edu Subject: Re: [M3devel] completing M3CG_Binary.Op? I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 1.txt URL: From jay.krell at cornell.edu Fri Oct 12 06:43:58 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 04:43:58 +0000 Subject: [M3devel] C backend -- mode or call quake? Message-ID: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 12 18:50:46 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 16:50:46 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Oct 12 19:23:59 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 12 Oct 2012 13:23:59 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote: > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Oct 12 19:23:59 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 12 Oct 2012 13:23:59 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote: > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 12 19:46:42 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 17:46:42 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: Emulating the gcc-based approach is not good. We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. "External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake. OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). It shouldn't be a big deal either way. cm3/Builder still has to new up a different backend. For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. - Jay From: hosking at cs.purdue.edu Date: Fri, 12 Oct 2012 13:23:59 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Sat Oct 13 06:25:11 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Sat, 13 Oct 2012 00:25:11 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> On Oct 12, 2012, at 1:46 PM, Jay K wrote: > Emulating the gcc-based approach is not good. > > > We have four modes currently: > ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject > (They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) > > > NT/x86 uses IntegratedObject > gcc/m3cg uses ExternalAssembly > "External" means "produce .mc files and run the quake function m3back()" > "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. > > > currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. > > > "External" anything is convenient for development and testing, bad for performance. > It writes and reads the .mc files. > Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. > > > "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". > > > So that leaves us with IntegratedObject. > M3C.m3 will have to interact with quake. Yuck! > OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). Yes! > It shouldn't be a big deal either way. > > > cm3/Builder still has to new up a different backend. > > > For LLVM you'll likely follow a similar course. > "External" is convenient for development and testing, but slower. > "Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly". > You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. Agreed, but that is not so difficult. > > > > - Jay > > > From: hosking at cs.purdue.edu > Date: Fri, 12 Oct 2012 13:23:59 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com; antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > > Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. > > On Oct 12, 2012, at 12:50 PM, Jay K wrote: > > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 13 06:44:57 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 13 Oct 2012 04:44:57 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> References: , , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , , , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu>, , <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> Message-ID: Aha, you like a new mode, IntegratedC? A bit more of a change in cm3/Builder, but leaves M3C.m3 ignorant of quake? Ok. I like it too. I had it working. I sent the diff. The only perhaps controversial part is I changed an error to be "more fatal" (stop right away, I think). I can bring that back. - Jay From: hosking at cs.purdue.edu Date: Sat, 13 Oct 2012 00:25:11 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? On Oct 12, 2012, at 1:46 PM, Jay K wrote:Emulating the gcc-based approach is not good. We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. "External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake. Yuck! OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). Yes! It shouldn't be a big deal either way. cm3/Builder still has to new up a different backend. For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. Agreed, but that is not so difficult. - Jay From: hosking at cs.purdue.edu Date: Fri, 12 Oct 2012 13:23:59 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Mon Oct 15 20:35:01 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Mon, 15 Oct 2012 11:35:01 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: <20121015183501.4A7AB1A2082@async.async.caltech.edu> Jay K writes: ... >"External" anything is convenient for development and testing=2C bad for pe= >rformance. It writes and reads the .mc files. Besides development/testin= >g=2C it also is used for licensing reasons -- communication through files i= >nstead of "linking" code. ... Jay you keep coming back to this issue of the performance of the compiler. Do you use Modula-3 for some large projects I'm not aware of? I compile quite a bit of code with it, and sure it would be cool (always is) if it were faster but it's not like the lack of speed has ever bothered me (not since the silly 0.1-second delay was removed from Process.Wait). I also implemented a parallelized back-end mode a while ago (it's in the tree). The speed of the compiler is mainly an issue when recompiling the world, which is something that happens mainly during "development/testing", and then not by regular users, normally... Mika From jay.krell at cornell.edu Tue Oct 16 02:21:23 2012 From: jay.krell at cornell.edu (Jay) Date: Mon, 15 Oct 2012 17:21:23 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <20121015183501.4A7AB1A2082@async.async.caltech.edu> References: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: The current usage of C backend is noticeably much slower than cm3cg. I really don't like it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 15, 2012, at 11:35 AM, wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance. It writes and reads the .mc files. Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait). I also > implemented a parallelized back-end mode a while ago (it's in the tree). > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > > Mika From rodney_bates at lcwb.coop Tue Oct 16 18:36:35 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Tue, 16 Oct 2012 11:36:35 -0500 Subject: [M3devel] M3CG_Ops.Public vs. M3CG.T Message-ID: <507D8D13.80603@lcwb.coop> I'm finally getting around to responding to this. On 09/27/2012 02:00 PM, Jay K wrote:> One thing I missed is that > > > IMPORT M3CG; > > > Give you an M3CG.T that you can only pass around. > > Add IMPORT M3CG_Ops I think it was > and then you can make all the method calls on an M3CG.T. > > I don't see that the first intermediate step is useful, but oh well. > Everyone might as well just IMPORT M3CG_Ops. > > > It is kind of interesting that "private" and "protected" are kind of available in Modula-3, or at least one clump therein, by moving part of the interface into a separate file. Modula-3's hiding mechanism, while a lot simpler to define, is *much* more flexible than C++'s. In fact, the flexibility is, in a sense, unbounded. The fields and methods of an object type can have a different, arbitrary subset of them made visible in every interface or module. Just make a chain of opaque subtypes for each clump of fields/methods whose visibility you want to be able to control independently. Then provide a revelation for each clump. The one limitation is that each of the revelations has to be in a separate interface, because you want to be able to import any subset of the revelations, but you can't directly import a revelation, only an interface, which brings in all the revelations in that interface. This makes it syntactically a bit ponderous. But this cost brings a big benefit in language simplicity. A few sentences of language definition suffice, instead of a few pages. > > I say one clump, because I don't think you can do this: > > > FooRoot.i3: > TYPE Foo <: ROOT; > > Foo1.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F1(); > END; > > Foo2.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F2(); > END; > > Foo.m3: > REVEAL Foo = OBJECT METHODS > PROCEDURE F1(); > PROCEDURE F2(); > END; > You can write something like this, but Foo1.Foo and Foo2.Foo are distinct types not related to each other, nor to FooRoot.Foo. All three are side-by-side inheritance children of ROOT. Also, Foo1.Foo and Foo2.Foo will have to have full revelations somewhere. I'm not sure what you meant here, but I doubt this was it. > I think you can only have just: > > FooRoot.i3: > TYPE Foo <: ROOT; > > Foo1.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F1(); > END; > > Foo.m3: > REVEAL Foo = OBJECT METHODS > PROCEDURE F1(); > PROCEDURE F2(); > END; > Which is the same, apart from the nonexistence of Foo2 and Foo2.Foo. > > It'd also be useful if you could do like this: > > Stream.i3: > > Reader = OBJECT METHODS PROCEDURE Read(); END; > Writer = OBJECT METHODS PROCEDURE Write(); END; > TYPE Stream <: Reader; > TYPE Stream <: Writer; > > Stream.m3: > REVEAL Stream = OBJECT METHODS > PROCEDURE Read(); > PROCEDURE Write(); > END; > > i.e. -- multiple inheritance. > > I realize you can reveal in multiple linear steps though...which I'm not going to give an example of right now.. so it isn't just "one clump", but if you reveal "multiple clumps", they need to form a linear chain, right? You can't "mix" as I showed for read/write. ? > > I think not requiring linearizing fields/methods would inevitably suck you into the tar pit of multiple inheritance. Multiple inheritance has been debated to death many times. The most charitable thing you can say is the price in semantic complexity outweighs, by orders of magnitude, the useful benefits. Here is an example showing visibility of arbitrary subsets of 3 fields: INTERFACE Opaque ; TYPE HideA <: ROOT ; TYPE HideB <: HideA ; TYPE HideC <: HideB ; TYPE T <: HideC ; END Opaque . INTERFACE ShowA ; IMPORT Opaque ; REVEAL Opaque . HideA = BRANDED OBJECT A : INTEGER := 1 END ; END ShowA . INTERFACE ShowB ; IMPORT Opaque ; REVEAL Opaque . HideB = Opaque . HideA BRANDED OBJECT B : INTEGER := 1 END ; END ShowB . INTERFACE ShowC ; IMPORT Opaque ; REVEAL Opaque . HideC = Opaque . HideB BRANDED OBJECT C : INTEGER := 1 END ; END ShowC . MODULE Opaque ; REVEAL T = HideC BRANDED OBJECT END ; BEGIN END Opaque . MODULE Client EXPORTS Main ; IMPORT Opaque ; IMPORT ShowA ; IMPORT ShowB ; IMPORT ShowC ; VAR O := NEW ( Opaque . T ) ; BEGIN O . A := 4 (* Legal iff ShowA is imported. *) ; O . B := 5 (* Legal iff ShowB is imported. *) ; O . C := 6 (* Legal iff ShowC is imported. *) ; EVAL O END Client . > - Jay From jay.krell at cornell.edu Wed Oct 17 03:08:01 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 17 Oct 2012 01:08:01 +0000 Subject: [M3devel] in defense of ternary operator (Ada has it now) Message-ID: In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: e.g. sign := if a >= 0 then 1 else -1 They'd rather people NOT do like: sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Wed Oct 17 18:05:07 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 17 Oct 2012 11:05:07 -0500 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: <507ED733.7020602@lcwb.coop> On 10/15/2012 07:21 PM, Jay wrote: > The current usage of C backend is noticeably much slower than cm3cg. I really don't like it. > At first thought, this didn't surprise me. Leaving out combinatorially heavy back-end optimizations, the usual primary speed bottleneck in compilers has always been lexical scanning. Not because it is fundamentally an inefficient task, but because of fundamentally high iteration count. It has to look at files one character at a time, for every character. In contrast, parsing, which is not a lot different in algorithmic efficiency (perhaps slower), only has to process lexical tokens, minus comments and white space. This gives iteration counts lower by a factor of several. Mostly ditto for the rest of the phases. So, for a back-end that generates source code in some character-encoded language, an every-character-one-at-a-time process has to happen twice, once in generating the source code, and again in scanning it. The cm3cg approach skips both these. This difference is fundamental to the two approaches, and not a lot can be done about it. But on second thought, if I understand correctly, both gcc reading text file input and cm3cg do the same at a later stage by generating assembly source code, then passing it to an assembler. And I would expect equivalent assembly code to have higher character count than C code, by a factor of a few. (In a quick look, I see one case giving a 3-to-1 expansion from Modula-2 source to assembly code.) I would expect this to dilute the extra time spent generating/scanning the C code. But maybe slowdowns in the neighborhood of 10% to 20% might be explainable this way. > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 15, 2012, at 11:35 AM, wrote: > >> Jay K writes: >> ... >>> "External" anything is convenient for development and testing=2C bad for pe= >>> rformance. It writes and reads the .mc files. Besides development/testin= >>> g=2C it also is used for licensing reasons -- communication through files i= >>> nstead of "linking" code. >> ... >> >> Jay you keep coming back to this issue of the performance of the compiler. >> Do you use Modula-3 for some large projects I'm not aware of? I compile >> quite a bit of code with it, and sure it would be cool (always is) if it >> were faster but it's not like the lack of speed has ever bothered me (not >> since the silly 0.1-second delay was removed from Process.Wait). I also >> implemented a parallelized back-end mode a while ago (it's in the tree). >> The speed of the compiler is mainly an issue when recompiling the world, >> which is something that happens mainly during "development/testing", >> and then not by regular users, normally... >> >> Mika > From rodney_bates at lcwb.coop Wed Oct 17 18:11:22 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 17 Oct 2012 11:11:22 -0500 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <20121015183501.4A7AB1A2082@async.async.caltech.edu> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: <507ED8AA.6090105@lcwb.coop> On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance. It writes and reads the .mc files. Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait). I also > implemented a parallelized back-end mode a while ago (it's in the tree). I didn't know that. Any experience on how stable it is? Time compiling isn't a huge issue for me either, but now that we all have n cores on a chip, for growing n, and little way to utilize them, that would indeed be cool. > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > > Mika > From mika at async.caltech.edu Wed Oct 17 20:23:59 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Wed, 17 Oct 2012 11:23:59 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <507ED8AA.6090105@lcwb.coop> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> <507ED8AA.6090105@lcwb.coop> Message-ID: <20121017182359.5F8641A2082@async.async.caltech.edu> It was a little difficult to find, but here it is... https://mail.elegosoft.com/pipermail/m3commit/2011-February/009784.html Note I don't know how good pthreads are nowadays. It works fine with user threads... last time I tried it with pthreads my compiler hung, but I know there have been fixes since then. Mika "Rodney M. Bates" writes: > > >On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: >> Jay K writes: >> ... >>> "External" anything is convenient for development and testing=2C bad for pe= >>> rformance. It writes and reads the .mc files. Besides development/testin= >>> g=2C it also is used for licensing reasons -- communication through files i= >>> nstead of "linking" code. >> ... >> >> Jay you keep coming back to this issue of the performance of the compiler. >> Do you use Modula-3 for some large projects I'm not aware of? I compile >> quite a bit of code with it, and sure it would be cool (always is) if it >> were faster but it's not like the lack of speed has ever bothered me (not >> since the silly 0.1-second delay was removed from Process.Wait). I also >> implemented a parallelized back-end mode a while ago (it's in the tree). > >I didn't know that. Any experience on how stable it is? Time compiling >isn't a huge issue for me either, but now that we all have n cores on a >chip, for growing n, and little way to utilize them, that would indeed >be cool. > >> The speed of the compiler is mainly an issue when recompiling the world, >> which is something that happens mainly during "development/testing", >> and then not by regular users, normally... >> >> Mika >> From hendrik at topoi.pooq.com Thu Oct 18 02:11:47 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Wed, 17 Oct 2012 20:11:47 -0400 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: References: Message-ID: <20121018001147.GA2937@topoi.pooq.com> On Wed, Oct 17, 2012 at 01:08:01AM +0000, Jay K wrote: > In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: > e.g. > sign := if a >= 0 then 1 else -1 > They'd rather people NOT do like: > sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 > http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf > "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. > None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay This syntax originated a long time ago, with Algol 60. It wasn't a problem there, even though empty statements were invisible there, too. These, howerver, are expressions, and there are no empty expressions in either Algol 60 or Modula 3. The only problemm was the dangling "else" as in if ... then if ... then ... else ... But that's only a problem with statements, singe expressions always have to have their else's. For consistency of notation, IF expressions in Modula 3 should probably have explicit ENDs, as in Algol 68. -- hendrik From dabenavidesd at yahoo.es Thu Oct 18 17:08:46 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Thu, 18 Oct 2012 16:08:46 +0100 (BST) Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <507ED8AA.6090105@lcwb.coop> Message-ID: <1350572926.52530.YahooMailClassic@web29703.mail.ird.yahoo.com> Hi all: Some parallelized RT environments gave in DEC-SRC times degradation when N ~ 3 of processors than when it was > 10 in any particular program not only compilers. SO, I'm not so optimistic in general about that N growing too much. This is about what SPWM3 said succinctly I don't remember the quote. Hopefully research in other architectures like Message Passing could make the case for better compiler technology. I don't know what else you could make with those extra N < 10 cores, I believe there should be something but in those architectures, not emulating DEC architectures like currently amd tries to do, but other new approaches, but DEC is over Thanks in advance --- El mi?, 17/10/12, Rodney M. Bates escribi?: De: Rodney M. Bates Asunto: Re: [M3devel] C backend -- mode or call quake? Para: m3devel at elegosoft.com Fecha: mi?rcoles, 17 de octubre, 2012 11:11 On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance.? It writes and reads the .mc files.???Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of?? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait).? I also > implemented a parallelized back-end mode a while ago (it's in the tree). I didn't know that.? Any experience on how stable it is?? Time compiling isn't a huge issue for me either, but now that we all have n cores on a chip, for growing n, and little way to utilize them, that would indeed be cool. > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > >? ? ? Mika > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Thu Oct 18 17:28:57 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Thu, 18 Oct 2012 10:28:57 -0500 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: <20121018001147.GA2937@topoi.pooq.com> References: <20121018001147.GA2937@topoi.pooq.com> Message-ID: <50802039.6010102@lcwb.coop> On 10/17/2012 07:11 PM, Hendrik Boom wrote: > On Wed, Oct 17, 2012 at 01:08:01AM +0000, Jay K wrote: >> In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: >> e.g. >> sign := if a >= 0 then 1 else -1 >> They'd rather people NOT do like: >> sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 >> http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf >> "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. >> None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay > > This syntax originated a long time ago, with Algol 60. It wasn't a > problem there, even though empty statements were invisible there, too. > These, howerver, are expressions, and there are no empty expressions in > either Algol 60 or Modula 3. > > The only problemm was the dangling "else" as in > if ... then if ... then ... else ... > But that's only a problem with statements, singe expressions always have > to have their else's. > > For consistency of notation, IF expressions in Modula 3 should probably > have explicit ENDs, as in Algol 68. Yes. There is a somewhat different syntax problem here. Would: IF B THEN T ELSE IF C THEN U ELSE IF D THEN V ELSE F Mean: IF B THEN T ELSE (IF C THEN U ELSE IF D THEN V ELSE F) (* IF is right-associative. *) Or: IF B THEN T ELSE IF C THEN U ELSE (IF D THEN V ELSE F) (* IF is left-associative. *) Would: IF B THEN T ELSE E OR F Mean: IF B THEN T ELSE (E OR F) (* OR has higher precedence than IF. *) Or: (IF B THEN T ELSE E) OR F (* OR has lower precedence than IF. *) Precedence and associativity rules for the IF-expression would resolve these, and all the existing expression operators have these properties. But somehow, the IF-expression intuitively seems to me to be a lot harder to follow than for more traditional infix operators. And for associativity there is an unusual asymmetry about it. At first, I wanted to write (IF B THEN T ELSE IF C THEN U ELSE) IF D THEN V ELSE F (* IF is left-associative. *) But that's really wierd, and would make IF B THEN T ELSE IF C THEN U ELSE (* Nothing here *) an expression, which breaks everything. Giving it a closing END seems a lot easier to fix the syntax and easier to read. > > -- hendrik > > From hendrik at topoi.pooq.com Thu Oct 18 23:04:54 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Thu, 18 Oct 2012 17:04:54 -0400 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: <50802039.6010102@lcwb.coop> References: <20121018001147.GA2937@topoi.pooq.com> <50802039.6010102@lcwb.coop> Message-ID: <20121018210454.GA2496@topoi.pooq.com> On Thu, Oct 18, 2012 at 10:28:57AM -0500, Rodney M. Bates wrote: > > > On 10/17/2012 07:11 PM, Hendrik Boom wrote: > >For consistency of notation, IF expressions in Modula 3 should probably > >have explicit ENDs, as in Algol 68. > > Yes. There is a somewhat different syntax problem here. > > Would: > IF B THEN T ELSE IF C THEN U ELSE IF D THEN V ELSE F > Mean: > IF B THEN T ELSE (IF C THEN U ELSE IF D THEN V ELSE F) (* IF is right-associative. *) > Or: > IF B THEN T ELSE IF C THEN U ELSE (IF D THEN V ELSE F) (* IF is left-associative. *) Can't see how this would happen if IF is left-associative. It looks more ike right-associative to me. In fact, right-associative should look like this: IF B THEN T ELSE (IF C THEN U ELSE (IF D THEN V ELSE F)) And what could left-associative even mean if IF has no left argument? > > Would: > IF B THEN T ELSE E OR F > Mean: > IF B THEN T ELSE (E OR F) (* OR has higher precedence than IF. *) > Or: > (IF B THEN T ELSE E) OR F (* OR has lower precedence than IF. *) > > Precedence and associativity rules for the IF-expression would resolve > these, It would. > and all the existing expression operators have these properties. > But somehow, the IF-expression intuitively seems to me to be a lot harder > to follow than for more traditional infix operators. > > And for associativity there is an unusual asymmetry about it. At first, > I wanted to write > (IF B THEN T ELSE IF C THEN U ELSE) IF D THEN V ELSE F (* IF is left-associative. *) > But that's really wierd, Yes, it is, because IF doesn't take a left argument,so it's syntactic nonsense. > and would make > IF B THEN T ELSE IF C THEN U ELSE (* Nothing here *) > an expression, which breaks everything. Also syntactic nonsense for ane expression. > > Giving it a closing END seems a lot easier to fix the syntax and > easier to read. Yup, that's the right answer for IF. As discovered in Algol 68 long ago. ONly they spelled it FI instead of END. -- hendrik From hosking at cs.purdue.edu Fri Oct 19 15:56:11 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 19 Oct 2012 09:56:11 -0400 Subject: [M3devel] Windows issue Message-ID: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 19 17:51:27 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 19 Oct 2012 15:51:27 +0000 Subject: [M3devel] Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative.There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks.We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe.I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this:call c:\program files\...vcvars32.bat -- user editable line%~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts?Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10.cm3 does not find the Windows linker. I work with vim and have configured themake macro to call cm3/bin/cm3.exe and the error happens when quake tries toinvoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent.It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University305 N. University Street | West Lafayette | IN 47907 | USAMobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Fri Oct 19 17:53:18 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Fri, 19 Oct 2012 16:53:18 +0100 (BST) Subject: [M3devel] Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: <1350661998.61721.YahooMailClassic@web29705.mail.ird.yahoo.com> Hi all: why do you need vim to sep up the compiler, it seems odd, all you need is an installation with cminstall and you 'll be ready. If you want to use CM3IDE with vim you can build from CM3IDE with no problems, otherwise please give more details on your side so other can help you more (i.e are you building cm3 with what commands within vim, etc). I haven't used msi installers, are you trying to use those? I heard of someone having trouble with that, but I can't give you more details than that. Thanks in advance --- El vie, 19/10/12, Antony Hosking escribi?: De: Antony Hosking Asunto: [M3devel] Windows issue Para: "m3devel developers" Fecha: viernes, 19 de octubre, 2012 08:56 I have had a query from a user of CM3 regarding Windows installation. ?I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10.cm3 does not find the Windows linker. I work with vim and have configured themake macro to call cm3/bin/cm3.exe and the error happens when quake tries toinvoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent.It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking?|?Associate Professor?| Computer Science | Purdue University305 N. University Street | West Lafayette | IN 47907 | USAMobile?+1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rcolebur at SCIRES.COM Fri Oct 19 22:18:55 2012 From: rcolebur at SCIRES.COM (Coleburn, Randy) Date: Fri, 19 Oct 2012 16:18:55 -0400 Subject: [M3devel] EXT: Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: My post back on 9/20/2012 describes what I do for using CM3 on Windows. I can resend again if needed. My scripts will take care of calling vcvars.bat when setting up the command prompt window for using CM3. The script can be tailored easily to account for differences in location of vcvars.bat among the various Visual Studio releases, including VS 10. --Randy Coleburn From: Antony Hosking [mailto:hosking at cs.purdue.edu] Sent: Friday, October 19, 2012 9:56 AM To: m3devel developers Subject: EXT:[M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmuysers at hotmail.com Sat Oct 20 16:33:40 2012 From: dmuysers at hotmail.com (Dirk Muysers) Date: Sat, 20 Oct 2012 16:33:40 +0200 Subject: [M3devel] Windows issue In-Reply-To: References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A brute force approach such as copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). Now, the the interest of calling cm3 from within VIM resides in the fact that it leads one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative. There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay -------------------------------------------------------------------------------- From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Sat Oct 20 20:34:15 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Sat, 20 Oct 2012 19:34:15 +0100 (BST) Subject: [M3devel] Windows issue In-Reply-To: Message-ID: <1350758055.17350.YahooMailClassic@web29702.mail.ird.yahoo.com> Hi all: CM3IDE reloads packages each upon a time concurrently across clients whether browser tabs or all in one like Deckscape decks like functionality: http://www.ibiblio.org/openvideo/video/chi/chi96_17_m1.mpg IMHO if you combine both of them you can get a better distributed environment for programming than most people are used to. It's just like Modula-3 too ahead of its time if you like simplicity. The other approach for Modula-3 is M3clipse, a Eclipse Plugin that builds upon AST, needs more to work autocompletion, if we could make that work with extra functionalities in an Applet we could get the best framework IMHO for distributed programming, Thanks in advance --- El s?b, 20/10/12, Dirk Muysers escribi?: De: Dirk Muysers Asunto: Re: [M3devel] Windows issue Para: "Jay K" , "Tony" , "m3devel" Fecha: s?bado, 20 de octubre, 2012 09:33 Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second?solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A?brute force approach such as?copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). ? Now, the the interest of calling cm3 from within?VIM resides in the fact that it leads?one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a? pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. ? And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue ?> I?know there exists vcvars32.bat, but its effect is not permanent. ? Sure it is. If you use it right. Permance is relative. There are two easy ways. ? ? 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 ? ? 2.?somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). ? ? ?> It should be invoked somewhere by cm3/bin/config/NT386.common etc. ? ? Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. ? ? Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. ? ? Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: ? ? We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. ? ? On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com?that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. ? ? The lesson is "users should run foo" and "creative environments" should introduce "foo.com". ? ? But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. ? ? whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. ? ? Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. ? ? ?-?Jay ? From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. ?I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking?|?Associate Professor?| Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile?+1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 20 21:05:08 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 20 Oct 2012 19:05:08 +0000 Subject: [M3devel] comparisons and subranges Message-ID: Typecode = [0 .. 16_FFFFF]; (* can fit in 20 bits *)tc: Typecode. IF (tc # RTType.NoSuchType) AND (0 <= tc) AND (tc < n) THEN if(((INT64)(((INT64)(M3_INT64(0)))))>((INT64)(((INT64)(*(UINT32*)(&tc_L_68))))))goto L4F; gcc:../src/runtime/common/RTutils.m3:233: warning: comparison is always false due to limited range of data type I'd like to be warning-free.I think this is the only class of warning I have now. Thoughts? Could the frontend eliminate some of this stuff? Otherwise I might do constant-folding in the C backend. I had offered a patch months ago that would do some simple stuff in the frontendinvolving comparisons and subranges.Try that again?(i.e. see how many warnings it removes, see if it suffices?) I might just try hiding constants inside functions for now, at least zero since it is the biggest offender:.static int Zero(void) { return 0; } Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 20 21:09:17 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 20 Oct 2012 19:09:17 +0000 Subject: [M3devel] Windows issue In-Reply-To: References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu>, , Message-ID: > And Microsoft's command shell is a pain in the backside to say the least. I live in cmd every day and find it vastly preferable to e.g. Mac OS X Terminal.It's output is much faster. It's command line editing is much better, including history.The feature invoked by the F8 key -- command line completion against history -- I use all the time and have yet to find anywhere else. > A brute force approach such as copying "link.exe" to cm3/bin doesn't work either >because Agreed. A \cm3\bin\link.cmd that first runs vcvars32.bat would work. > it doesn't allow copy-paste etc etc Sure it does! I use it all the timeBy default you have to use the menu in the upper left, but you can enable "quickedit" and then it is more convenient. You should definitely try it. > And also, sorry to say so, cm3ide is far from being an elegant development tool, you caninspect only one file at a time and using VIM from cm3ide brings you back to the abovedilemma. Agreed. cm3ide is kind of worthless and not an "IDE" by anyone's expectation. - Jay From: dmuysers at hotmail.com To: jay.krell at cornell.edu; hosking at cs.purdue.edu; m3devel at elegosoft.com Date: Sat, 20 Oct 2012 16:33:40 +0200 Subject: Re: [M3devel] Windows issue Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A brute force approach such as copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). Now, the the interest of calling cm3 from within VIM resides in the fact that it leads one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative. There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 07:42:16 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 05:42:16 +0000 Subject: [M3devel] suspicious order of evaluation? Message-ID: m3tohtml/src/Main.m3: sources is global PROCEDURE Add() = BEGIN sources := NEW (Source, next := sources, from := Pathname.Join(pkgpath, file, NIL), to := Pathname.Join(pkg, FixDerived (file), NIL), kind := kind); It APPEARS this compiles to like: temp = RTHooks__AllocateTracedRef(...); sources = temp if temp == NULL raise exception sources->from = ... sources->to = ... To me this seems a bit suspicious. First, the null check should be against the temp. Sources should not be assigned and then checked. Second, probably, the fields of sources should be filled in before the global. So, it should be more like: temp = RTHooks__AllocateTracedRef(); if temp == NULL raise exception temp->from = ... temp->to = ... sources = temp ... Just as efficient, but "safer". Now, I realize, without a lock or barrier, the compiler is free to reorder like this.Maybe ideally temp would be gone but the original order used? C++ would implement it more like how I showed. Thoughts? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 07:57:37 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 05:57:37 +0000 Subject: [M3devel] suspicious order of evaluation? In-Reply-To: References: Message-ID: correction: temp = RTHooks__AllocateTracedRef(...); sources = temp if sources == NULL raise exception - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 25 Oct 2012 05:42:16 +0000 Subject: [M3devel] suspicious order of evaluation? m3tohtml/src/Main.m3: sources is global PROCEDURE Add() = BEGIN sources := NEW (Source, next := sources, from := Pathname.Join(pkgpath, file, NIL), to := Pathname.Join(pkg, FixDerived (file), NIL), kind := kind); It APPEARS this compiles to like: temp = RTHooks__AllocateTracedRef(...); sources = temp if temp == NULL raise exception sources->from = ... sources->to = ... To me this seems a bit suspicious. First, the null check should be against the temp. Sources should not be assigned and then checked. Second, probably, the fields of sources should be filled in before the global. So, it should be more like: temp = RTHooks__AllocateTracedRef(); if temp == NULL raise exception temp->from = ... temp->to = ... sources = temp ... Just as efficient, but "safer". Now, I realize, without a lock or barrier, the compiler is free to reorder like this.Maybe ideally temp would be gone but the original order used? C++ would implement it more like how I showed. Thoughts? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 10:12:41 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 08:12:41 +0000 Subject: [M3devel] what is wrong with TIntN? Message-ID: When faced with VAR a := FIRST(INTEGER) + 1;VAR b := LAST(INTEGER) + 1;VAR c := LAST(INTEGER) + 1 - 1;VAR d := (a > 0); I would like backends to optimize initialization a,not optimize initialization of b,and probably not optimize initialization of c,and hopefully optimize initialization of d, but that is moredifficult in the C backend. Fold constants when it is obviously safe.Do not fold constants when there is a chance of overflow -- evenat intermediate points of the expression. This is why I believe TIntN is useful. I bring this up because I'm about to add constant folding to M3C.m3.And to introduce use of TIntN.Which Tony has insisted is wrong, i.e. use in M3x86.m3. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 25 16:37:57 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 25 Oct 2012 10:37:57 -0400 Subject: [M3devel] what is wrong with TIntN? In-Reply-To: References: Message-ID: The problem is that you are trying to bring front-end mechanisms into the backend. If you want to perform optimizations in your backend they should be standalone and independent of the front end. For example, the llvm backend can perform a whole bunch of optimizations in its own IR. TInt is a service provided by m3middle to the front-end. Feel free to add whatever you like to your backend. I just don?t want to see unnecessary stuff introduced into m3middle. On Oct 25, 2012, at 4:12 AM, Jay K wrote: > When faced with > > > VAR a := FIRST(INTEGER) + 1; > VAR b := LAST(INTEGER) + 1; > VAR c := LAST(INTEGER) + 1 - 1; > VAR d := (a > 0); > > > I would like backends to optimize initialization a, > not optimize initialization of b, > and probably not optimize initialization of c, > and hopefully optimize initialization of d, but that is more > difficult in the C backend. > > > Fold constants when it is obviously safe. > Do not fold constants when there is a chance of overflow -- even > at intermediate points of the expression. > > > This is why I believe TIntN is useful. > > > I bring this up because I'm about to add constant folding to M3C.m3. > And to introduce use of TIntN. > Which Tony has insisted is wrong, i.e. use in M3x86.m3. > > > > Thanks, > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 25 16:43:27 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 25 Oct 2012 10:43:27 -0400 Subject: [M3devel] suspicious order of evaluation? In-Reply-To: References: Message-ID: I?m not sure that Modula-3 defines any order of initialization (unlike Java constructors and the JMM), so implementations are free to choose. So, programmers that care must be careful not to expose uninitialized objects by assigning them to globals only after the initializer has run. And of course in a multi-core setting you?d need to enforce fences accordingly. I agree that it might make sense to implement they way you suggest. Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 On Oct 25, 2012, at 1:42 AM, Jay K wrote: > m3tohtml/src/Main.m3: > > sources is global > > > PROCEDURE Add() = > BEGIN > sources := NEW (Source, next := sources, > from := Pathname.Join(pkgpath, file, NIL), > to := Pathname.Join(pkg, FixDerived (file), NIL), > kind := kind); > > > It APPEARS this compiles to like: > > > temp = RTHooks__AllocateTracedRef(...); > sources = temp > if temp == NULL > raise exception > sources->from = ... > sources->to = ... > > > To me this seems a bit suspicious. > > > First, the null check should be against the temp. > Sources should not be assigned and then checked. > > > Second, probably, the fields of sources should be filled in before > the global. > > > So, it should be more like: > > > temp = RTHooks__AllocateTracedRef(); > if temp == NULL > raise exception > temp->from = ... > temp->to = ... > sources = temp > ... > > > Just as efficient, but "safer". > > > Now, I realize, without a lock or barrier, the compiler is free to reorder like this. > Maybe ideally temp would be gone but the original order used? > > > C++ would implement it more like how I showed. > > > Thoughts? > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 21:44:44 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 19:44:44 +0000 Subject: [M3devel] what is wrong with TIntN? In-Reply-To: References: , Message-ID: So, if I just move the code to m3back, you are ok?Clearly m3middle is for front and backends though. i.e. at least Target, TInt, TFloat is needed by both/all.How does m3front get away w/o having similar functionality? What is the meaning of: CONST a = 16_7FFFFFFF + 1; CONST b = 16_7FFFFFFF + 1 - 1; for a 32bit target? or CONST c = 16_7FFFFFFFFFFFFFFFL + 1; CONST d = 16_7FFFFFFFFFFFFFFFL + 1 - 1; (I should try them and see and read code, granted.I should read more of m3front in general.) Restated, clearly larger-than-host-integer precisionarithemetic is needed by the frontend. But I don't seethat it is sufficient to have fixed-64-bit-precision arithmetic.It seems to me you would want to further "type" or restrictthe precision, depending on context, to one of INT8, UINT8, INT16,UINT16, INT32, UINT32, INT64, UINT64.(where "unsigned" is perhaps "half interval", 0 to the maximum signednumber of that precision...though this half interval stuff stillmakes me uneasy..but I grant that TInt does not implement full range64bit unsigned math, it is really a portable INT64). What I can't immediately guess with high confidence is if the "typing"is appropriate for intermediate results, or only final results.i.e. range checking all along, or only upon some conversion at the end. I guess, again, I should read m3front and the language spec more. Also, regarding m3middle..M3CG_Ops.i3 does lend itself to an intermediaterepresentation. In-memory that can be processed in multiple passes.I realize using it as such isn't very creative and ultimatelyone would want to augment it further. But it is useful. And so there is the idea that m3middle is code of use to multiple backends,even if not to the frontend at all. As well, the idea of actual "shared middle ends" or shared passes.i.e. in M3C I eliminate unused local variables.(not through sophisticated analysis like eliminating locals thatare only ever written to..though I could do that...but locals thatare neither written to nor read from. If M3CG were in-memory "in an array"and that was a common interface to multiple backends, this trasnformcould be shared among backends, or heck, always applied as a matter of course. It kind of seems to me that backends should have some characteristicsdescribed about them, communicated to the frontend, like requestingthe frontend interface with them in one of two or three ways, andrequesting certain passes be applied before them. Or, look how gcc is structured, as a series of passes.We could do that.passes: m3front m3cg function calls to in-memory format eliminate unused locals compute operations x types -- i.e. discover if extract is applied to int32 and/or int64, for backends that want to output helper functions; not all targets care compute or estimate maximum compile-time stack depth -- I've been tempted to add this, but so far haven't done it; it is easy to estimate; my motivation isn't good -- it is that I don't like the Modula-3 generic mechanism and how it steers me toward "RefSeq" and lots of NARROW() operations -- slower than needed. I'd rather use an open array if I can compute the right size early. move imports ahead of everything compute frames, maybe These can all be done reasonably well with the "obvious" internalrepresentation, plus just a little extra data. I guess what I'm saying is there could/should be more shared code forbackends. Given the two in existance today, that isn't really true, theyare too different.But it is perhaps true if we had some other mix of backend implementations. Granted, LLVM does "everything" itself anyway, all those passesare trivial for it, most likely. It doesn't need any help. - Jay From: hosking at cs.purdue.edu Date: Thu, 25 Oct 2012 10:37:57 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] what is wrong with TIntN? The problem is that you are trying to bring front-end mechanisms into the backend.If you want to perform optimizations in your backend they should be standalone and independent of the front end.For example, the llvm backend can perform a whole bunch of optimizations in its own IR.TInt is a service provided by m3middle to the front-end.Feel free to add whatever you like to your backend. I just don?t want to see unnecessary stuff introduced into m3middle. On Oct 25, 2012, at 4:12 AM, Jay K wrote:When faced with VAR a := FIRST(INTEGER) + 1;VAR b := LAST(INTEGER) + 1;VAR c := LAST(INTEGER) + 1 - 1;VAR d := (a > 0); I would like backends to optimize initialization a,not optimize initialization of b,and probably not optimize initialization of c,and hopefully optimize initialization of d, but that is moredifficult in the C backend. Fold constants when it is obviously safe.Do not fold constants when there is a chance of overflow -- evenat intermediate points of the expression. This is why I believe TIntN is useful. I bring this up because I'm about to add constant folding to M3C.m3.And to introduce use of TIntN.Which Tony has insisted is wrong, i.e. use in M3x86.m3. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 26 11:27:36 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 26 Oct 2012 09:27:36 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: <20121026092255.C9A94CC99F@birch.elegosoft.com> References: <20121026092255.C9A94CC99F@birch.elegosoft.com> Message-ID: I still really don't like how M3CG.TypeUID is defined. Asserting that a type fits in 32bitsshould not preclude putting it into a RECORD. Currently you cannot put M3CG.TypeUID into a record. The following does not work: RECORD whatever = typeid: M3CG.TypeUID; END; That seems really absurd to me. - Jay > Date: Fri, 26 Oct 2012 11:22:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/26 11:22:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > continue to hack around bogus packing of M3CG.TypeUID > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 26 11:31:30 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 26 Oct 2012 09:31:30 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, Message-ID: This is one reasonable way to fix it: Index: M3CG.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,vretrieving revision 1.10diff -u -r1.10 M3CG.i3--- M3CG.i3 6 Sep 2012 02:03:06 -0000 1.10+++ M3CG.i3 26 Oct 2012 09:30:31 -0000@@ -98,9 +98,9 @@ Always : Frequency = LAST (Frequency); TYPE- Int32 = [-16_7fffffff-1 .. 16_7fffffff];- TypeUID = BITS 32 FOR Int32;+ TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; (* a 32-bit unique id (fingerprint) for each type. *)+ assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; TYPE Label = INTEGER;Index: M3CG_MultiPass.i3 - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Fri, 26 Oct 2012 09:27:36 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record I still really don't like how M3CG.TypeUID is defined. Asserting that a type fits in 32bitsshould not preclude putting it into a RECORD. Currently you cannot put M3CG.TypeUID into a record. The following does not work: RECORD whatever = typeid: M3CG.TypeUID; END; That seems really absurd to me. - Jay > Date: Fri, 26 Oct 2012 11:22:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/26 11:22:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > continue to hack around bogus packing of M3CG.TypeUID > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Sun Oct 28 16:28:12 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 28 Oct 2012 10:28:12 -0500 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com> Message-ID: <508D4F0C.3080607@lcwb.coop> On 10/26/2012 04:27 AM, Jay K wrote: > I still really don't like how M3CG.TypeUID is defined. > > Asserting that a type fits in 32bits > should not preclude putting it into a RECORD. > > Currently you cannot put M3CG.TypeUID into a record. > > The following does not work: > > RECORD whatever = typeid: M3CG.TypeUID; END; I don't understand what the problem with this is. I expected it to work fine, which I confirmed by trying it, on both a 32-bit and a 64-bit compile. There is nothing here that would put the TypeUID at a place where it would have cross a word boundary or have problematic starting bit number. Did you perhaps mean in some other record type that has field(s) before the TypeUID that would leave it wrongly aligned? > > That seems really absurd to me. > > - Jay > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > To: m3commit at elegosoft.com > > From: jkrell at elego.de > > Subject: [M3commit] CVS Update: cm3 > > > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > Modified files: > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > Log message: > > continue to hack around bogus packing of M3CG.TypeUID > > From rodney_bates at lcwb.coop Sun Oct 28 17:00:26 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 28 Oct 2012 11:00:26 -0500 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, Message-ID: <508D569A.90609@lcwb.coop> I do like this idea. It took me a while to catch on to the rule that a field of packed type not only must occupy exactly the stated bit count, but also must not have any compiler-added padding ahead of it. While this is just what is needed for programmer-control of record layout, it seems that almost everyone keeps missing it and getting tripped up by it. After having trouble with record layouts that became illegal after changes in non-packed fields, I have made it a convention not to put BITS--FOR in a type declaration, but only use it as an anonymous type expression for a record field or array element. The named type in the type declaration will likely be used in several contexts, with differing packing contexts. The packing really needs to be independently thought about for each record field and array element. On 10/26/2012 04:31 AM, Jay K wrote: > This is one reasonable way to fix it: > > Index: M3CG.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,v > retrieving revision 1.10 > diff -u -r1.10 M3CG.i3 > --- M3CG.i36 Sep 2012 02:03:06 -00001.10 > +++ M3CG.i326 Oct 2012 09:30:31 -0000 > @@ -98,9 +98,9 @@ > Always : Frequency = LAST (Frequency); > TYPE > - Int32 = [-16_7fffffff-1 .. 16_7fffffff]; > - TypeUID = BITS 32 FOR Int32; > + TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; > (* a 32-bit unique id (fingerprint) for each type. *) > + assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; > TYPE > Label = INTEGER; > Index: M3CG_MultiPass.i3 > > > - Jay > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- > From: jay.krell at cornell.edu > To: m3devel at elegosoft.com > Date: Fri, 26 Oct 2012 09:27:36 +0000 > Subject: [M3devel] unable to put M3CG.TypeUID into a record > > I still really don't like how M3CG.TypeUID is defined. > > Asserting that a type fits in 32bits > should not preclude putting it into a RECORD. > > Currently you cannot put M3CG.TypeUID into a record. > > The following does not work: > > RECORD whatever = typeid: M3CG.TypeUID; END; > > That seems really absurd to me. > > - Jay > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > To: m3commit at elegosoft.com > > From: jkrell at elego.de > > Subject: [M3commit] CVS Update: cm3 > > > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > Modified files: > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > Log message: > > continue to hack around bogus packing of M3CG.TypeUID > > From jay.krell at cornell.edu Mon Oct 29 07:26:22 2012 From: jay.krell at cornell.edu (Jay K) Date: Mon, 29 Oct 2012 06:26:22 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: <508D569A.90609@lcwb.coop> References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, , , , <508D569A.90609@lcwb.coop> Message-ID: Thank you. > Date: Sun, 28 Oct 2012 11:00:26 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] unable to put M3CG.TypeUID into a record > > I do like this idea. It took me a while to catch on to the rule that > a field of packed type not only must occupy exactly the stated bit > count, but also must not have any compiler-added padding ahead of it. > While this is just what is needed for programmer-control of record > layout, it seems that almost everyone keeps missing it and getting > tripped up by it. > > After having trouble with record layouts that became illegal after > changes in non-packed fields, I have made it a convention not to > put BITS--FOR in a type declaration, but only use it as an anonymous > type expression for a record field or array element. The named type in > the type declaration will likely be used in several contexts, with differing > packing contexts. The packing really needs to be independently thought > about for each record field and array element. > > On 10/26/2012 04:31 AM, Jay K wrote: > > This is one reasonable way to fix it: > > > > Index: M3CG.i3 > > =================================================================== > > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,v > > retrieving revision 1.10 > > diff -u -r1.10 M3CG.i3 > > --- M3CG.i36 Sep 2012 02:03:06 -00001.10 > > +++ M3CG.i326 Oct 2012 09:30:31 -0000 > > @@ -98,9 +98,9 @@ > > Always : Frequency = LAST (Frequency); > > TYPE > > - Int32 = [-16_7fffffff-1 .. 16_7fffffff]; > > - TypeUID = BITS 32 FOR Int32; > > + TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; > > (* a 32-bit unique id (fingerprint) for each type. *) > > + assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; > > TYPE > > Label = INTEGER; > > Index: M3CG_MultiPass.i3 > > > > > > - Jay > > > > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > -- > > From: jay.krell at cornell.edu > > To: m3devel at elegosoft.com > > Date: Fri, 26 Oct 2012 09:27:36 +0000 > > Subject: [M3devel] unable to put M3CG.TypeUID into a record > > > > I still really don't like how M3CG.TypeUID is defined. > > > > Asserting that a type fits in 32bits > > should not preclude putting it into a RECORD. > > > > Currently you cannot put M3CG.TypeUID into a record. > > > > The following does not work: > > > > RECORD whatever = typeid: M3CG.TypeUID; END; > > > > That seems really absurd to me. > > > > - Jay > > > > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > > To: m3commit at elegosoft.com > > > From: jkrell at elego.de > > > Subject: [M3commit] CVS Update: cm3 > > > > > > CVSROOT: /usr/cvs > > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > > > Modified files: > > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > > > Log message: > > > continue to hack around bogus packing of M3CG.TypeUID > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hendrik at topoi.pooq.com Mon Oct 1 15:14:17 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Mon, 1 Oct 2012 09:14:17 -0400 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <5068B362.90304@lcwb.coop> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <5068B362.90304@lcwb.coop> Message-ID: <20121001131417.GA13426@topoi.pooq.com> On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > > > On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >Well that depends on how you maintain the vector, no? > > > >SortedTable uses "treaps" which are supposed to be good data structures. > >Too new to have made it into Knuth, last I checked. The amortized cost > >of your operations shouldn't be much worse than with your method, with > >the additional benefit that the sorted order is maintained dynamically. > > > >The separation of algorithms from containers sounds a bit like a bug. > >You have to be careful so you don't shoot yourself in the foot there! > >(Sorting a list using an algorithm that randomly accesses elements, > >say...) > > > >The Modula-3 approach is that you figure out what you want to do, pick > >the ADT you want that provides the minimal set of operations, import > >that interface, then instantiate a more carefully chosen implementation > >of the ADT. The language itself obviously can be coaxed into supporting the > >algorithm/data structure separation but no one uses it that way as > >far as I know. (Modula-3 generics are not that well explored, actually. > >I suspect there are many things you can do with them that no one has > >tried.) > > > > Mika > > > > > > I do think the ability to easily and inadvertently create mashups with > horrible asymptotic efficiency problems is a fundamental problem with > abstractions of any kind. Just plain old-fashioned procedural abstractions > give plenty of opportunity. Write one loop and call your code O(n). > Call something inside the loop. That guy did the same. Quickly, you > can O(n^3) etc., and nobody realizes it. > > Functional style abstractions are often just oh-so-easy to use, but > they can hide a lot. Even Modula-3 Text operations, immeasurably > more versatile and easy than when you have to worry about allocation, > have created some unpleasant surprises. Documenting the performance > characteristics in comments seems to be only solution. This has been > done in some places by both C++ and Modula-3 library writers. It might be interesting to speculate on language features that coul track performance problems the way type-checking checks types. Not tht I expect a practical solution today or tomorrow. -- hendrik From rodney_bates at lcwb.coop Mon Oct 1 18:18:50 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Mon, 01 Oct 2012 11:18:50 -0500 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <20121001131417.GA13426@topoi.pooq.com> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <5068B362.90304@lcwb.coop> <20121001131417.GA13426@topoi.pooq.com> Message-ID: <5069C26A.6030604@lcwb.coop> On 10/01/2012 08:14 AM, Hendrik Boom wrote: > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: >> >> >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: >>> Well that depends on how you maintain the vector, no? >>> >>> SortedTable uses "treaps" which are supposed to be good data structures. >>> Too new to have made it into Knuth, last I checked. The amortized cost >>> of your operations shouldn't be much worse than with your method, with >>> the additional benefit that the sorted order is maintained dynamically. >>> >>> The separation of algorithms from containers sounds a bit like a bug. >>> You have to be careful so you don't shoot yourself in the foot there! >>> (Sorting a list using an algorithm that randomly accesses elements, >>> say...) >>> >>> The Modula-3 approach is that you figure out what you want to do, pick >>> the ADT you want that provides the minimal set of operations, import >>> that interface, then instantiate a more carefully chosen implementation >>> of the ADT. The language itself obviously can be coaxed into supporting the >>> algorithm/data structure separation but no one uses it that way as >>> far as I know. (Modula-3 generics are not that well explored, actually. >>> I suspect there are many things you can do with them that no one has >>> tried.) >>> >>> Mika >>> >>> >> >> I do think the ability to easily and inadvertently create mashups with >> horrible asymptotic efficiency problems is a fundamental problem with >> abstractions of any kind. Just plain old-fashioned procedural abstractions >> give plenty of opportunity. Write one loop and call your code O(n). >> Call something inside the loop. That guy did the same. Quickly, you >> can O(n^3) etc., and nobody realizes it. >> >> Functional style abstractions are often just oh-so-easy to use, but >> they can hide a lot. Even Modula-3 Text operations, immeasurably >> more versatile and easy than when you have to worry about allocation, >> have created some unpleasant surprises. Documenting the performance >> characteristics in comments seems to be only solution. This has been >> done in some places by both C++ and Modula-3 library writers. > > It might be interesting to speculate on language features that coul > track performance problems the way type-checking checks types. > Yes, I agree. > Not tht I expect a practical solution today or tomorrow. > Yes, I agree here too. > -- hendrik > From jay.krell at cornell.edu Mon Oct 1 19:29:48 2012 From: jay.krell at cornell.edu (Jay K) Date: Mon, 1 Oct 2012 17:29:48 +0000 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <5069C26A.6030604@lcwb.coop> References: , <20120928075656.751E21A2082@async.async.caltech.edu>, <20120928080448.C80DD1A2082@async.async.caltech.edu>, , <20120929182948.6589C1A2082@async.async.caltech.edu>, <5068B362.90304@lcwb.coop> <20121001131417.GA13426@topoi.pooq.com>,<5069C26A.6030604@lcwb.coop> Message-ID: C++ already has this to some extent and has for a long time. You can't actually request to qsort a std::list. The type system doesn't allow it. They don't come up with random access that is ridiculously slow. They come up with none at all, and it is a compilation error. But if you are just writing loops over loops over loops over random access to large working sets and network I/O, talking to a server, that does more of the same..yeah.... What you want though is, I guess, "more composition", more flowing of data.A lot more.Tough problem...order of runtime is a factor of so many things, size of a file, or lines in the file, or tokens in a file, or number of heap allocations, or number of network I/O, or number of memory reads, or memory writes, etc.... - Jay > Date: Mon, 1 Oct 2012 11:18:50 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 10/01/2012 08:14 AM, Hendrik Boom wrote: > > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > >> > >> > >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >>> Well that depends on how you maintain the vector, no? > >>> > >>> SortedTable uses "treaps" which are supposed to be good data structures. > >>> Too new to have made it into Knuth, last I checked. The amortized cost > >>> of your operations shouldn't be much worse than with your method, with > >>> the additional benefit that the sorted order is maintained dynamically. > >>> > >>> The separation of algorithms from containers sounds a bit like a bug. > >>> You have to be careful so you don't shoot yourself in the foot there! > >>> (Sorting a list using an algorithm that randomly accesses elements, > >>> say...) > >>> > >>> The Modula-3 approach is that you figure out what you want to do, pick > >>> the ADT you want that provides the minimal set of operations, import > >>> that interface, then instantiate a more carefully chosen implementation > >>> of the ADT. The language itself obviously can be coaxed into supporting the > >>> algorithm/data structure separation but no one uses it that way as > >>> far as I know. (Modula-3 generics are not that well explored, actually. > >>> I suspect there are many things you can do with them that no one has > >>> tried.) > >>> > >>> Mika > >>> > >>> > >> > >> I do think the ability to easily and inadvertently create mashups with > >> horrible asymptotic efficiency problems is a fundamental problem with > >> abstractions of any kind. Just plain old-fashioned procedural abstractions > >> give plenty of opportunity. Write one loop and call your code O(n). > >> Call something inside the loop. That guy did the same. Quickly, you > >> can O(n^3) etc., and nobody realizes it. > >> > >> Functional style abstractions are often just oh-so-easy to use, but > >> they can hide a lot. Even Modula-3 Text operations, immeasurably > >> more versatile and easy than when you have to worry about allocation, > >> have created some unpleasant surprises. Documenting the performance > >> characteristics in comments seems to be only solution. This has been > >> done in some places by both C++ and Modula-3 library writers. > > > > It might be interesting to speculate on language features that coul > > track performance problems the way type-checking checks types. > > > > Yes, I agree. > > > Not tht I expect a practical solution today or tomorrow. > > > > Yes, I agree here too. > > > -- hendrik > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Mon Oct 1 21:07:26 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Mon, 1 Oct 2012 20:07:26 +0100 (BST) Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: Message-ID: <1349118446.66982.YahooMailClassic@web29702.mail.ird.yahoo.com> Hi all: None of this languages of today can predict anything about unbounded termination less they provide a clear solution for the problem of finding compile? time solutions for programs of bigger classes of complexity than what it takes to type check a given program if you consider both at each time is very hard problem probably to give a model itself. The only way seems to analyze execution traces and make prediction models. However I don't think this is more important than to make more efficient computer models. And current advances are not encouraging. Thanks in advance --- El lun, 1/10/12, Jay K escribi?: De: Jay K Asunto: Re: [M3devel] STL algorithms? sort/unique? Para: "Rodney M. Bates" , "m3devel" Fecha: lunes, 1 de octubre, 2012 12:29 C++ already has this to some extent and has for a long time.? You can't actually request to qsort a std::list. The type system doesn't allow it. They don't come up with random access that is ridiculously slow. They come up with none at all, and it is a compilation error. But if you are just writing loops over?loops over loops over random access to large working sets and network I/O, talking to a server, that does more of the same..yeah.... What you want though is, I guess, "more composition", more flowing of data.A lot more.Tough problem...order of runtime is a factor of so many things, size of a file, or lines in the file, or tokens in a file, or number of heap allocations, or number of network I/O, or number of memory reads, or memory writes, etc.... ?- Jay > Date: Mon, 1 Oct 2012 11:18:50 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 10/01/2012 08:14 AM, Hendrik Boom wrote: > > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > >> > >> > >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >>> Well that depends on how you maintain the vector, no? > >>> > >>> SortedTable uses "treaps" which are supposed to be good data structures. > >>> Too new to have made it into Knuth, last I checked. The amortized cost > >>> of your operations shouldn't be much worse than with your method, with > >>> the additional benefit that the sorted order is maintained dynamically. > >>> > >>> The separation of algorithms from containers sounds a bit like a bug. > >>> You have to be careful so you don't shoot yourself in the foot there! > >>> (Sorting a list using an algorithm that randomly accesses elements, > >>> say...) > >>> > >>> The Modula-3 approach is that you figure out what you want to do, pick > >>> the ADT you want that provides the minimal set of operations, import > >>> that interface, then instantiate a more carefully chosen implementation > >>> of the ADT. The language itself obviously can be coaxed into supporting the > >>> algorithm/data structure separation but no one uses it that way as > >>> far as I know. (Modula-3 generics are not that well explored, actually. > >>> I suspect there are many things you can do with them that no one has > >>> tried.) > >>> > >>> Mika > >>> > >>> > >> > >> I do think the ability to easily and inadvertently create mashups with > >> horrible asymptotic efficiency problems is a fundamental problem with > >> abstractions of any kind. Just plain old-fashioned procedural abstractions > >> give plenty of opportunity. Write one loop and call your code O(n). > >> Call something inside the loop. That guy did the same. Quickly, you > >> can O(n^3) etc., and nobody realizes it. > >> > >> Functional style abstractions are often just oh-so-easy to use, but > >> they can hide a lot. Even Modula-3 Text operations, immeasurably > >> more versatile and easy than when you have to worry about allocation, > >> have created some unpleasant surprises. Documenting the performance > >> characteristics in comments seems to be only solution. This has been > >> done in some places by both C++ and Modula-3 library writers. > > > > It might be interesting to speculate on language features that coul > > track performance problems the way type-checking checks types. > > > > Yes, I agree. > > > Not tht I expect a practical solution today or tomorrow. > > > > Yes, I agree here too. > > > -- hendrik > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Tue Oct 2 21:53:04 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Tue, 2 Oct 2012 21:53:04 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> Message-ID: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> I don't need stack allocated object. I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. As Anthony said. At this time and age? I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. I think we just need even better collector that we currently have. One passing Mika's thread test :). dd On Sep 30, 2012, at 8:06 AM, Jay K wrote: > I don't just want UNTRACED OBJECT. > I also want stack allocated objects. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Tue Oct 2 22:43:24 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Tue, 2 Oct 2012 21:43:24 +0100 (BST) Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> Message-ID: <1349210604.21624.YahooMailClassic@web29706.mail.ird.yahoo.com> Hi all: to make a proposal we could consider several options, for grow able stacks and fine grained heaps, my approach is pure Baby Modula-3, for the former and Obliq-like objects for the latter. But I'm no selling the idea to you guys! Just if someone could manage to make a proposal I support it. Thanks in advance --- El mar, 2/10/12, Dragi?a Duri? escribi?: De: Dragi?a Duri? Asunto: Re: [M3devel] STL algorithms? sort/unique? Para: "Jay K" CC: "m3devel" Fecha: martes, 2 de octubre, 2012 14:53 I don't need stack allocated object.? I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. As Anthony said. At this time and age? ? I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. I think we just need even better collector that we currently have. One passing Mika's thread test :). dd On Sep 30, 2012, at 8:06 AM, Jay K wrote: I don't just want UNTRACED OBJECT.I also want stack allocated objects. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 3 16:39:53 2012 From: jay.krell at cornell.edu (Jay) Date: Wed, 3 Oct 2012 07:39:53 -0700 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> Message-ID: <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> Growable stack is basically nonsense. True that stack allocation has large downside that picking a stack size is impossible. But it is super fast. Once we have NT/C backend that doesn't use a thread local, & we have cooperative suspend, I'd like to try writing an NT driver with Modula-3.. limited stack space there. :) (hm...what if we can't wrap the thread entry? Maybe ok.) Right, C++ is the answer, once I have my own compiler. :) - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 2, 2012, at 12:53 PM, Dragi?a Duri? wrote: > I don't need stack allocated object. > > I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? > > I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. > > As Anthony said. At this time and age? > > I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. > > I think we just need even better collector that we currently have. One passing Mika's thread test :). > > dd > > On Sep 30, 2012, at 8:06 AM, Jay K wrote: > >> I don't just want UNTRACED OBJECT. >> I also want stack allocated objects. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Wed Oct 3 20:24:06 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Wed, 3 Oct 2012 20:24:06 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> Message-ID: <300C8C70-BF12-4B78-B1B5-15A514360AD7@m3w.org> Current heap allocation (thanks to Anthony) is much much faster than it used to be, as each thread has it's own "current page to alloc from". Not like stack alloc, but also not limited as stack alloc. Your C++ compiler will cull those 60% of C++ standard? I can't wait to see it! :) -- Divided by a common language Dragi?a Duri? dragisha at m3w.org On Oct 3, 2012, at 4:39 PM, Jay wrote: > Growable stack is basically nonsense. > > > True that stack allocation has large downside that picking a stack size is impossible. But it is super fast. > > > Once we have NT/C backend that doesn't use a thread local, & we have cooperative suspend, I'd like to try writing an NT driver with Modula-3.. limited stack space there. :) > (hm...what if we can't wrap the thread entry? Maybe ok.) > > > Right, C++ is the answer, once I have my own compiler. :) > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 2, 2012, at 12:53 PM, Dragi?a Duri? wrote: > >> I don't need stack allocated object. >> >> I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? >> >> I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. >> >> As Anthony said. At this time and age? >> >> I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. >> >> I think we just need even better collector that we currently have. One passing Mika's thread test :). >> >> dd >> >> On Sep 30, 2012, at 8:06 AM, Jay K wrote: >> >>> I don't just want UNTRACED OBJECT. >>> I also want stack allocated objects. >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Thu Oct 4 03:40:57 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 03 Oct 2012 20:40:57 -0500 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> Message-ID: <506CE929.3000008@lcwb.coop> On 09/30/2012 01:06 AM, Jay K wrote: > I believe opinion remains strongly mixed on garbage collection / "managed" > etc. There is a lot of "managed" code. There is a lot of "native" code. > We all use a lot of both every day. > > > Modula-3 is actually pretty unusual in being native code and having garbage collection. > It is pretty unusual in having optional garbage collection. > It is pretty unusual in having optional safety. > C# allows some safety relaxation within "unsafe" blocks. > Like pointer manipulation. > > It pains me slightly in Modula-3 to write e.g. > > RTIO.PutText("foo " & Fmt.Int(123) & "bar"); > I've created at least two pieces of garbage. > In C++ any temporary strings would be cleaned up > right away at a deterministic time. > > > I'm really torn. > C# seems to be a highly "productive" "environment" (the language, > the libraries, possibly the IDEs). Perhaps far more than any C++ or Modula-3. > I know people who work on kernel drivers. They still use C. > > > I don't just want UNTRACED OBJECT. > I also want stack allocated objects. > C++ has them. > This idea has never made any sense to me at all: 1) No OOP advocate would let you get away with calling it OOP without having dispatching methods. (This despite the fact that the great majority of OO examples don't actually use them, and thus are really ADT programming.) 2) You can't actually use dispatching unless your variable can dynamically be assigned values of different subclasses at different times. Degenerately using a linguistic mechanism that dispatches, but the algorithm ensures it is always to the same place, does not count. 3) If a stack object is to be dynamically assignable to values of different subclasses, the compiler is going to have to allocate space for the largest of these. That can be declared anywhere, in a place unknown to exist, at the point where the variable is declared. I think I can see a way this could be implemented with whole-program techniques, but it still won't work with dynamically linked libraries, which rules out a major part of what the staunch OOP advocates advocate. And it creates a new kind of space waste. 4) Alternatively, a compiler could actually hiddenly allocate the objects in the heap and put a pointer on the stack. But now any real or imagined performance gains from on-stack objects are gone. Moreover, there will be reference assignment vs. value assignment semantic distinctions that violate what local variables are expected to do, with sometimes big bugs as consequence. 5) A compiler could fix this by simulating the correct value assignment semantics, making heap copies whenever necessary. This makes it effectively a functional language, which certainly would require a GC and greatly increases the volume of allocated and collected heap objects. 6) Or, a programmer could explicitly take pointers to stack objects of various subclasses and assign them to the same variable at different times. I guess this is what is done in C++. This amounts to enticing the naive to try dancing on a tight-wire over Dangling Pointer Abyss. Which would justify Stroustrup's comment. 7) Finally, a programmer diligent and skillful enough to pull this off would be extremely hard pressed to find an application where the actual stack lifetimes of the different subclass objects had any significant correlation to the real lifetimes of their usefulness to the program. > class C > { > void F1(); > virtual void F2(); > }; > > void F3() > { > C c; > } > > > I think the nearest equivalent in Modula-3 is a stack allocated RECORD > with function pointers. > > > - Jay > > > From jay.krell at cornell.edu Thu Oct 4 03:59:29 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 01:59:29 +0000 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <506CE929.3000008@lcwb.coop> References: , ,,<20120928075656.751E21A2082@async.async.caltech.edu>, , ,,<20120928080448.C80DD1A2082@async.async.caltech.edu>, ,,, , ,,<20120929182948.6589C1A2082@async.async.caltech.edu>, ,,, , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , , , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu>, , <506CE929.3000008@lcwb.coop> Message-ID: std::vector vi; vi.push_back(1); vi.push_back(2); vi.push_back(3); vs. VAR s := NEW(IntSeq.T).init(); s.addhi(1); s.addhi(2); s.addhi(3); vector is small, contains 3 pointers. And one level of indirection for accessing the data. printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. IntSeq.T is one pointer, and probably contains also approximately 3 pointers. The Modula-3 has an extra level of indirection. Not every function should be "virtual". "object.method" is useful syntax for statically typed "object". s.get(0) probably involves like 3 pointer derefences. Somewhat this is a "standard library" matter. But I think the language is probably slightly lacking too. I understand that if the "virtual-ness" is part of the interface..you could have: si: IntSeq.T; IntSeq.push_back(si, 1); (* static non-virtual dispatch *) IntSeq.push_back(si, 2); IntSeq.push_back(si, 3); si.data[0]; (* public data *) This is good and bad. It is both better and worse to have the "virtual-ness" affect the public interface. Exposing data like that, well, that's kind of a quality of implementation matter. I could have it be. IntSeq.get(si, 0); and leave it up to the compiler to inline.. I have to go... - Jay > Date: Wed, 3 Oct 2012 20:40:57 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 09/30/2012 01:06 AM, Jay K wrote: > > I believe opinion remains strongly mixed on garbage collection / "managed" > > etc. There is a lot of "managed" code. There is a lot of "native" code. > > We all use a lot of both every day. > > > > > > Modula-3 is actually pretty unusual in being native code and having garbage collection. > > It is pretty unusual in having optional garbage collection. > > It is pretty unusual in having optional safety. > > C# allows some safety relaxation within "unsafe" blocks. > > Like pointer manipulation. > > > > It pains me slightly in Modula-3 to write e.g. > > > > RTIO.PutText("foo " & Fmt.Int(123) & "bar"); > > I've created at least two pieces of garbage. > > In C++ any temporary strings would be cleaned up > > right away at a deterministic time. > > > > > > I'm really torn. > > C# seems to be a highly "productive" "environment" (the language, > > the libraries, possibly the IDEs). Perhaps far more than any C++ or Modula-3. > > I know people who work on kernel drivers. They still use C. > > > > > > I don't just want UNTRACED OBJECT. > > I also want stack allocated objects. > > C++ has them. > > > > This idea has never made any sense to me at all: > > 1) No OOP advocate would let you get away with calling it OOP without > having dispatching methods. (This despite the fact that the great > majority of OO examples don't actually use them, and thus are really > ADT programming.) > > 2) You can't actually use dispatching unless your variable can dynamically > be assigned values of different subclasses at different times. Degenerately > using a linguistic mechanism that dispatches, but the algorithm ensures it > is always to the same place, does not count. > > 3) If a stack object is to be dynamically assignable to values of different > subclasses, the compiler is going to have to allocate space for the > largest of these. That can be declared anywhere, in a place unknown > to exist, at the point where the variable is declared. I think I can > see a way this could be implemented with whole-program techniques, but > it still won't work with dynamically linked libraries, which rules out > a major part of what the staunch OOP advocates advocate. And it creates > a new kind of space waste. > > 4) Alternatively, a compiler could actually hiddenly allocate the > objects in the heap and put a pointer on the stack. But now any real > or imagined performance gains from on-stack objects are gone. Moreover, > there will be reference assignment vs. value assignment semantic > distinctions that violate what local variables are expected to do, > with sometimes big bugs as consequence. > > 5) A compiler could fix this by simulating the correct value assignment > semantics, making heap copies whenever necessary. This makes it > effectively a functional language, which certainly would require a GC > and greatly increases the volume of allocated and collected heap > objects. > > 6) Or, a programmer could explicitly take pointers to stack objects of > various subclasses and assign them to the same variable at different > times. I guess this is what is done in C++. This amounts to enticing > the naive to try dancing on a tight-wire over Dangling Pointer Abyss. > Which would justify Stroustrup's comment. > > 7) Finally, a programmer diligent and skillful enough to pull this off > would be extremely hard pressed to find an application where the > actual stack lifetimes of the different subclass objects had any > significant correlation to the real lifetimes of their usefulness > to the program. > > > class C > > { > > void F1(); > > virtual void F2(); > > }; > > > > void F3() > > { > > C c; > > } > > > > > > I think the nearest equivalent in Modula-3 is a stack allocated RECORD > > with function pointers. > > > > > > - Jay > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 07:45:10 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 05:45:10 +0000 Subject: [M3devel] another reminder -- jmpbuf size independence? Message-ID: Along with cooperative suspend, it'd be great if jmpbuf size was not known to cm3.We know roughly how to fix this -- use alloca(Csetjmp_jmpbuf_size).At function entry. Not in any loop.Or possibly in loop, but with a null check.VAR jmpbuf: ADDRESS := NIL;LOOP IF jmpbuf = NIL THEN jmpbuf := alloca(Csetjmp_jmpbuf_size); END; :) Granted, I want all layout optionally out of the frontend, and this is only part of the problem. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 08:13:28 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Message-ID: Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 08:25:53 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 06:25:53 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: References: Message-ID: declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 and here is some relevant M3x86 code: IF u.in_proc THEN v := get_temp_var (u, type, s, a, n); ELSE v := create_temp_var (u, type, s, a, n); END; PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name := M3ID.NoID): x86Var = BEGIN (* round size and alignment up to 4 *) IF s < 4 THEN s := 4; END; IF a < 4 THEN a := 4; END; PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name): x86Var = VAR v := NewVar(u, type, 0, s, a, n); BEGIN v.loc := VLoc.temp; v.parent := u.current_proc; u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, Alignmask[a]); INC(u.current_proc.framesize, s); v.offset := -u.current_proc.framesize; RETURN v; END create_temp_var; which isn't clear by inspection...it actually looks likezero size is allowed through commonly...in_proc is rare,so create is common...assuming the frame is already aligned,the size remains unchanged... Relevant aside: I have been ignoring alignment.I'm inclined to go with something like: <* ASSERT (size MOD alignment) = 0 *> If that ever fails, then I will change it to: FUNCTION RoundUp(a, b: INTEGER): INTEGER =BEGIN WITH c = a MOD b DO IF c # 0 THEN RETURN a + b - c; END; END; RETURN a;END; size := RoundUp(size, alignment); and then, more to the point, I'll go with: IF size = 0 THEN size = 1;END; I haven't dug into what the gcc backend would do here, too muchto dig through. :) Thoughts? I guess I should try both m3x86 and m3cc, and print the addressof these things???? - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 09:00:40 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 07:00:40 +0000 Subject: [M3devel] FW: entire system compiled with C backend In-Reply-To: <20121004065855.7FB082474003@birch.elegosoft.com> References: <20121004065855.7FB082474003@birch.elegosoft.com> Message-ID: entire system compiled with C backend: > Date: Thu, 4 Oct 2012 08:58:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/04 08:58:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > assert that alignments are all ok > If that fails, we'll round up in the backend. > assert that size >= 0 (and not merely > 0) > size := MAX(size, 1) (convert 0 to 1 -- 0 occurs) > perhaps it should be size := MAX(size, aligment) > > Should alignment be rounded up to 4 or 8 for variables like M3x86 does? > > I have now compiled the entire system using the C backend > targeting AMD64_DARWIN. This is a very big milestone. > > This last change has only been tested on a small part of the tree. > (i.e. that which has zero-sized variables, and everything "after" it) > > I can bring up and interact with various gui apps -- tetris, BadBricks (somewhat), > Juno, mentor (at least somehow). > > Juno doesn't come up centered, and I recall it always did before. > That might be something to look into. > > As well, the compiler has long been compiling itself. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 15:08:12 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 06:08:12 -0700 Subject: [M3devel] FW: entire system compiled with C backend In-Reply-To: References: <20121004065855.7FB082474003@birch.elegosoft.com> Message-ID: <20121004130812.B4AA11A207D@async.async.caltech.edu> This is very cool!!! Jay K writes: >--_333b0016-47c7-43b4-813e-76fd02b5ee50_ >Content-Type: text/plain; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > >entire system compiled with C backend: > > >> Date: Thu=2C 4 Oct 2012 08:58:55 +0000 >> To: m3commit at elegosoft.com >> From: jkrell at elego.de >> Subject: [M3commit] CVS Update: cm3 >>=20 >> CVSROOT: /usr/cvs >> Changes by: jkrell at birch. 12/10/04 08:58:55 >>=20 >> Modified files: >> cm3/m3-sys/m3back/src/: M3C.m3=20 >>=20 >> Log message: >> assert that alignments are all ok >> If that fails=2C we'll round up in the backend. >> assert that size >=3D 0 (and not merely > 0) >> size :=3D MAX(size=2C 1) (convert 0 to 1 -- 0 occurs) >> perhaps it should be size :=3D MAX(size=2C aligment) >> =09 >> Should alignment be rounded up to 4 or 8 for variables like M3x86 does? >> =09 >> I have now compiled the entire system using the C backend >> targeting AMD64_DARWIN. This is a very big milestone. >> =09 >> This last change has only been tested on a small part of the tree. >> (i.e. that which has zero-sized variables=2C and everything "after" it) >> =09 >> I can bring up and interact with various gui apps -- tetris=2C BadBricks= > (somewhat)=2C >> Juno=2C mentor (at least somehow). >> =09 >> Juno doesn't come up centered=2C and I recall it always did before. >> That might be something to look into. >> =09 >> As well=2C the compiler has long been compiling itself. >>=20 > = > >--_333b0016-47c7-43b4-813e-76fd02b5ee50_ >Content-Type: text/html; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > >
rif">entire system compiled with C backend:
i=2C sans-serif">


ans-serif=3B font-size: 12pt=3B ">
>= >=3B Date: Thu=2C 4 Oct 2012 08:58:55 +0000
>=3B To: m3commit at elegosoft= >.com
>=3B From: jkrell at elego.de
>=3B Subject: [M3commit] CVS Upda= >te: cm3
>=3B
>=3B CVSROOT: /usr/cvs
>=3B Changes by: jkrell= >@birch. 12/10/04 08:58:55
>=3B
>=3B Modified files:
>=3B c= >m3/m3-sys/m3back/src/: M3C.m3
>=3B
>=3B Log message:
>=3B = > assert that alignments are all ok
>=3B If that fails=2C we'll round = >up in the backend.
>=3B assert that size >=3B=3D 0 (and not merely = >>=3B 0)
>=3B size :=3D MAX(size=2C 1) (convert 0 to 1 -- 0 occurs)<= >br>>=3B perhaps it should be size :=3D MAX(size=2C aligment)
>=3B = >
>=3B Should alignment be rounded up to 4 or 8 for variables like M3x= >86 does?
>=3B
>=3B I have now compiled the entire system using= > the C backend
>=3B targeting AMD64_DARWIN. This is a very big milest= >one.
>=3B
>=3B This last change has only been tested on a smal= >l part of the tree.
>=3B (i.e. that which has zero-sized variables=2C= > and everything "after" it)
>=3B
>=3B I can bring up and inter= >act with various gui apps -- tetris=2C BadBricks (somewhat)=2C
>=3B J= >uno=2C mentor (at least somehow).
>=3B
>=3B Juno doesn't come = >up centered=2C and I recall it always did before.
>=3B That might be = >something to look into.
>=3B
>=3B As well=2C the compiler has = >long been compiling itself.
>=3B
ody> >= > >--_333b0016-47c7-43b4-813e-76fd02b5ee50_-- From jay.krell at cornell.edu Thu Oct 4 18:16:00 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 16:16:00 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: Yes..the assertions all passes..but granted, maybe we don't have full coverage. I can look at the frontend, or just make it so in the backend. On further thought..by quick read..this M3x86.m3 code is questionable.While in_proc is usually false for declare_local, I think it really goes both ways.So it looks like size is sometimes rounded up to 4, sometimes left as zero. But what does it mean?Does a zero sized array get any storage?In C and C++, two objects can't be at the same address, so, for example:struct foo { } bar; is not legal C. It is legal C++, however: struct foo { } a,b;assert(&a != &b); will pass. andvoid* a = malloc(0);void* b = malloc(0);assert(a != b) will also pass in C and C++. That is, size 0 struct is invalid in C. In C++ it is rounded up to at least 1.malloc(0) is rounded up to at least 1.No two "objects" can have the same address. What is the meaning Modula-3?Rounding up to 1 or alignment seems easy/decent.Certainly these zero sized things are rare in our tree. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] zero sized structs? Date: Thu, 4 Oct 2012 09:21:28 -0400 To: jay.krell at cornell.edu Try to respect alignment. Sent from my iPad On Oct 4, 2012, at 2:25 AM, Jay K wrote: declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 and here is some relevant M3x86 code: IF u.in_proc THEN v := get_temp_var (u, type, s, a, n); ELSE v := create_temp_var (u, type, s, a, n); END; PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name := M3ID.NoID): x86Var = BEGIN (* round size and alignment up to 4 *) IF s < 4 THEN s := 4; END; IF a < 4 THEN a := 4; END; PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name): x86Var = VAR v := NewVar(u, type, 0, s, a, n); BEGIN v.loc := VLoc.temp; v.parent := u.current_proc; u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, Alignmask[a]); INC(u.current_proc.framesize, s); v.offset := -u.current_proc.framesize; RETURN v; END create_temp_var; which isn't clear by inspection...it actually looks likezero size is allowed through commonly...in_proc is rare,so create is common...assuming the frame is already aligned,the size remains unchanged... Relevant aside: I have been ignoring alignment.I'm inclined to go with something like: <* ASSERT (size MOD alignment) = 0 *> If that ever fails, then I will change it to: FUNCTION RoundUp(a, b: INTEGER): INTEGER =BEGIN WITH c = a MOD b DO IF c # 0 THEN RETURN a + b - c; END; END; RETURN a;END; size := RoundUp(size, alignment); and then, more to the point, I'll go with: IF size = 0 THEN size = 1;END; I haven't dug into what the gcc backend would do here, too muchto dig through. :) Thoughts? I guess I should try both m3x86 and m3cc, and print the addressof these things???? - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 18:17:37 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 16:17:37 +0000 Subject: [M3devel] another reminder -- jmpbuf size independence? In-Reply-To: <1C9D3D9A-57A8-45EE-8185-0ABD3341A6C7@gmail.com> References: , <1C9D3D9A-57A8-45EE-8185-0ABD3341A6C7@gmail.com> Message-ID: Agreed. TRY FOR i := 1 TO 100 DO TRY FOR j := 1 TO 100 DO END; FINALLYENDFINALLY should have two variables, allocate 2 * sizeof(jmpbuf), call alloca twice (most likely -- obviously it could be optimized), not 200 times. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] another reminder -- jmpbuf size independence? Date: Thu, 4 Oct 2012 09:25:14 -0400 To: jay.krell at cornell.edu Don't you need separate jmpbuf per exception scope? Sent from my iPad On Oct 4, 2012, at 1:45 AM, Jay K wrote: Along with cooperative suspend, it'd be great if jmpbuf size was not known to cm3.We know roughly how to fix this -- use alloca(Csetjmp_jmpbuf_size).At function entry. Not in any loop.Or possibly in loop, but with a null check.VAR jmpbuf: ADDRESS := NIL;LOOP IF jmpbuf = NIL THEN jmpbuf := alloca(Csetjmp_jmpbuf_size); END; :) Granted, I want all layout optionally out of the frontend, and this is only part of the problem. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 20:13:21 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 11:13:21 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> References: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> Message-ID: <2193F183-F903-44AA-BD13-D1354739FF7D@gmail.com> > No storage. That has been thought through and all ramifications are ok? And gcc backend does what is expected? -- multiple variables have same address. I'll answer some of the questions later -- try out gcc backend and NT/x86. NT/x86 looks "inconsistent" between variable at top of procedure vs sub blocks. The C/C++ design feels more conservative and safe and also reasonable and cheap enough. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 10:22 AM, Antony Hosking wrote: > No storage. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 20:15:47 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 11:15:47 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> References: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> Message-ID: <7C06CF62-3526-4E9C-BD84-2130CAD5CF0C@gmail.com> > But you can have zero-length arrays in C. Not in ANSI C 1989. Maybe C9X variable length ("open") arrays can be zero? But I bet maybe alloca(0) rounds up, like malloca(0). C really avoids zero sized things.. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 10:22 AM, Antony Hosking wrote: > But you can have zero-length arrays in C. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 20:23:39 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 11:23:39 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: <20121004182339.3ECEC1A207D@async.async.caltech.edu> It seems that CM3 puts them at the "same address".... UNSAFE MODULE Main; IMPORT IO, Fmt; TYPE T = ARRAY [1..-1] OF INTEGER; VAR t := NEW(REF T); u := NEW(REF T); v : T; w : T; BEGIN IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n"); END Main. (114)async:~/ttt/src>../AMD64_LINUX/prog 2269030 2269040 602218 602218 I don't see a problem with it. Whoever thinks he needs to check whether ADR(v) equals ADR(w) should be using a different programming language... Mika From hosking at cs.purdue.edu Thu Oct 4 19:22:04 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 4 Oct 2012 13:22:04 -0400 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> On Oct 4, 2012, at 12:16 PM, Jay K wrote: > Yes..the assertions all passes..but granted, maybe we don't have full coverage. I can look at the frontend, or just make it so in the backend. > > > On further thought..by quick read..this M3x86.m3 code is questionable. > While in_proc is usually false for declare_local, I think it really goes both ways. > So it looks like size is sometimes rounded up to 4, sometimes left as zero. > > > But what does it mean? > Does a zero sized array get any storage? No storage. > In C and C++, two objects can't be at the same address, so, for example: > struct foo { } bar; is not legal C. It is legal C++, however: But you can have zero-length arrays in C. > > > struct foo { } a,b; > assert(&a != &b); will pass. > > > and > void* a = malloc(0); > void* b = malloc(0); > assert(a != b) will also pass in C and C++. > > > That is, size 0 struct is invalid in C. In C++ it is rounded up to at least 1. > malloc(0) is rounded up to at least 1. > No two "objects" can have the same address. > > > What is the meaning Modula-3? > Rounding up to 1 or alignment seems easy/decent. > Certainly these zero sized things are rare in our tree. > > > - Jay > > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] zero sized structs? > Date: Thu, 4 Oct 2012 09:21:28 -0400 > To: jay.krell at cornell.edu > > Try to respect alignment. > > Sent from my iPad > > On Oct 4, 2012, at 2:25 AM, Jay K wrote: > > > declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 > > > and here is some relevant M3x86 code: > > IF u.in_proc THEN > v := get_temp_var (u, type, s, a, n); > ELSE > v := create_temp_var (u, type, s, a, n); > END; > > > PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; > n: Name := M3ID.NoID): x86Var = > BEGIN > > (* round size and alignment up to 4 *) > > IF s < 4 THEN > s := 4; > END; > > IF a < 4 THEN > a := 4; > END; > > > PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; > n: Name): x86Var = > VAR v := NewVar(u, type, 0, s, a, n); > BEGIN > v.loc := VLoc.temp; > v.parent := u.current_proc; > > u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, > Alignmask[a]); > > INC(u.current_proc.framesize, s); > > v.offset := -u.current_proc.framesize; > > RETURN v; > END create_temp_var; > > > which isn't clear by inspection...it actually looks like > zero size is allowed through commonly...in_proc is rare, > so create is common...assuming the frame is already aligned, > the size remains unchanged... > > > Relevant aside: I have been ignoring alignment. > I'm inclined to go with something like: > > <* ASSERT (size MOD alignment) = 0 *> > > > If that ever fails, then I will change it to: > > > FUNCTION RoundUp(a, b: INTEGER): INTEGER = > BEGIN > WITH c = a MOD b DO > IF c # 0 THEN > RETURN a + b - c; > END; > END; > RETURN a; > END; > > size := RoundUp(size, alignment); > > > and then, more to the point, I'll go with: > > IF size = 0 THEN > size = 1; > END; > > > I haven't dug into what the gcc backend would do here, too much > to dig through. :) > > > Thoughts? > > > I guess I should try both m3x86 and m3cc, and print the address > of these things???? > > > - Jay > > > > From: jay.krell at cornell.edu > To: m3devel at elegosoft.com > Date: Thu, 4 Oct 2012 06:13:28 +0000 > Subject: [M3devel] zero sized structs? > > Building obliqrt I get: > > > *** > *** runtime error: > *** <*ASSERT*> failed. > *** file "../src/M3C.m3", line 1768 > *** > > > > PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var = > BEGIN > IF type = Type.Struct THEN > <* ASSERT byte_size > 0 *> > self.sizes[self.count] := byte_size; > INC(self.count); > END; > RETURN NIL; > END GetStructSizes_Declare; > > > due to presumably: > > > PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = > VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; > > > ... > > PROCEDURE HandleWork (self: ObliqWork) = > VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; > > .. > PROCEDURE EvalThread ( self : PackageThread; > ... > noArgs : ARRAY [0 .. -1] OF ObValue.Val; > > > What is the meaning of this? > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Thu Oct 4 20:30:40 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Thu, 4 Oct 2012 20:30:40 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , , , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu>, , <506CE929.3000008@lcwb.coop> Message-ID: On Oct 4, 2012, at 3:59 AM, Jay K wrote: > vector is small, contains 3 pointers. > And one level of indirection for accessing the data. > printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. Probably because preprocessor is in this equation? > > > > IntSeq.T is one pointer, and probably contains also approximately 3 pointers. > The Modula-3 has an extra level of indirection. And what is vector if not pointer to some collection of pointers? IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :). In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need. > > > Not every function should be "virtual". > "object.method" is useful syntax for statically typed "object". > s.get(0) probably involves like 3 pointer derefences. As opossed to C++'s two dereferences? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 21:33:33 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 12:33:33 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <20121004182339.3ECEC1A207D@async.async.caltech.edu> References: <20121004182339.3ECEC1A207D@async.async.caltech.edu> Message-ID: Same address & same size implies same object & same type. But the types can vary. Please check also variables in sub-blocks. I think NT/x86 backend doesn't always put them at same place. Then again, that is probably ok too -- in general not all zero sized objects can be located -- they could be locals in different functions or globals in different modules. You say use a different language, but 1) they are exceedingly rare so ok to waste space 2) as small & simple Modula-3 is, it is still really isn't small or simple, there are surprising number & level of detail to understand and deal with. Adding a notion of a zero sized thing isn't necessarily so obviously simple and free of complexity down the line. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 11:23 AM, wrote: > It seems that CM3 puts them at the "same address".... > > UNSAFE MODULE Main; > IMPORT IO, Fmt; > > TYPE > T = ARRAY [1..-1] OF INTEGER; > > VAR t := NEW(REF T); u := NEW(REF T); > v : T; > w : T; > BEGIN > IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n"); > END Main. > > (114)async:~/ttt/src>../AMD64_LINUX/prog > 2269030 > 2269040 > 602218 > 602218 > > I don't see a problem with it. Whoever thinks he needs to check whether > ADR(v) equals ADR(w) should be using a different programming language... > > Mika > From jay.krell at cornell.edu Thu Oct 4 21:44:19 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 12:44:19 -0700 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <506CE929.3000008@lcwb.coop> Message-ID: Preprocessor does historically help -- makes inlining easier, including making sizes visible. > And what is vector if not pointer to some collection of pointers? No. Pointers to ints. The three pointers are start, just past end, just past end of allocation. Maybe easier to see as a pointer and 2 integers -- size and allocated size. But they are size_t and not 32bit int. I'll present object code later... - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 11:30 AM, Dragi?a Duri? wrote: > > > On Oct 4, 2012, at 3:59 AM, Jay K wrote: > >> vector is small, contains 3 pointers. >> And one level of indirection for accessing the data. >> printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. > > Probably because preprocessor is in this equation? > >> >> >> >> IntSeq.T is one pointer, and probably contains also approximately 3 pointers. >> The Modula-3 has an extra level of indirection. > > And what is vector if not pointer to some collection of pointers? > > IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :). > > In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need. > >> >> >> Not every function should be "virtual". >> "object.method" is useful syntax for statically typed "object". >> s.get(0) probably involves like 3 pointer derefences. > > As opossed to C++'s two dereferences? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 22:37:33 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 13:37:33 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: <20121004182339.3ECEC1A207D@async.async.caltech.edu> Message-ID: <20121004203733.0E95A1A207D@async.async.caltech.edu> Well as a user I'm quite happy to see the two objects have different addresses, if it makes your life easier as a compiler writer. However it's certainly not documented---so I'd better not depend on it! You're not supposed to be taking the ADR of stuff on the stack. It's UNSAFE, caveat emptor, etc... I'm just saying that if you are doing that you're not writing programs that Modula-3 was intended for. If you want to pass something by reference, use VAR! I find that when you have trouble with zero-sized anything, you've usually used the wrong abstraction.... In any case the fact that the language allows certain things to be zero sized is very helpful when you are writing programs that have to generate Modula-3 code. You don't have to keep track and insert dummies in various places. But sure I can't think of any reason the compiler couldn't implement zero-sized things as being one-sized or four-sized, or whatever it/you want/s. It looks like they take 16 bytes when you NEW them... (of course the report also says that "The reference returned by NEW is distinct from all existing references") Mika Jay writes: >Same address & same size implies same object & same type. But the types can v= >ary. Please check also variables in sub-blocks. I think NT/x86 backend doesn= >'t always put them at same place. Then again, that is probably ok too -- in g= >eneral not all zero sized objects can be located -- they could be locals in d= >ifferent functions or globals in different modules. > > >You say use a different language, but 1) they are exceedingly rare so ok to w= >aste space 2) as small & simple Modula-3 is, it is still really isn't small o= >r simple, there are surprising number & level of detail to understand and de= >al with. Adding a notion of a zero sized thing isn't necessarily so obviousl= >y simple and free of complexity down the line.=20 > > > > - Jay (briefly/pocket-sized-computer-aka-phone) > >On Oct 4, 2012, at 11:23 AM, wrote: > >> It seems that CM3 puts them at the "same address".... >>=20 >> UNSAFE MODULE Main; >> IMPORT IO, Fmt; >>=20 >> TYPE >> T =3D ARRAY [1..-1] OF INTEGER; >>=20 >> VAR t :=3D NEW(REF T); u :=3D NEW(REF T); >> v : T; >> w : T; >> BEGIN >> IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base :=3D 16) & "\n"); >> END Main. >>=20 >> (114)async:~/ttt/src>../AMD64_LINUX/prog >> 2269030 >> 2269040 >> 602218 >> 602218 >>=20 >> I don't see a problem with it. Whoever thinks he needs to check whether >> ADR(v) equals ADR(w) should be using a different programming language... >>=20 >> Mika >>=20 From jay.krell at cornell.edu Thu Oct 4 23:27:55 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 21:27:55 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: <20121004203733.0E95A1A207D@async.async.caltech.edu> References: , , , , <20121004182339.3ECEC1A207D@async.async.caltech.edu>, , <20121004203733.0E95A1A207D@async.async.caltech.edu> Message-ID: > (of course the report also says that "The reference returned by NEW is distinct from all existing references") Aha. Good.And doesn't it seem kind of nice and correct if that same sort of thing applied to locals and globals?More consistent that way? Really I wouldn't mind if ARRAY [0..0] or ARRAY [0..-1] was just plain illegal.The following are not legal standard C/89/90:int a[-1];int a[0]; Though int a[0] may be a popular extension -- in both gcc and Visual C++ -- and many other compilers are forced to follow their lead. I know we don't in general "do what C does" but C is not really a set of all bad decisions that should all be avoided, and in fact, Modula-3 is almost trivially isomorphic to C. The main differences are 1) it disallows some operations 2) it adds optional garbage collection via inserted barrier checks 3) generics and vtables which are a fairly simple layering 4) strict interface separation which is just enforcing what people can do do in C, but it is important that it is strict, since it allows for faster compilation.) In the face of my own ignorance, I think considering what C and C++ do is not a bad option. They avoid the existance of zero sized things. On the other hand, C++ compilers then do work hard to "reoptimize" because of this. By "reoptimize" I mean, removal of zero sized things can actually be a significant deoptimization, that you then have to be pretty clever to optimize..when..if only zero size was ok in the first place, it would have been easy to keep optimal.In particular: struct A { }; struct B : A { }; struct C : B { }; struct D : C { }; struct E : D { }; what is the sizeof(E)? If zero size was ok, then the sizeof(A) and B and C and D and E would all be zero and the compiler's job would be easy. In reality keeping the sizeof(E) "small" isn't trivial. Perhaps perhaps multiple inheritance is needed to make the point. Let's see..hm..I need to research this..the "empty base optimization"..the problem doesn't seem that bad..without multiple inherirtance, the size was only 1. struct A1 { }; struct A2 { }; struct B1 : A1, A2 { }; struct B2 : A1, A2 { }; struct C1 : B1, B2 { }; struct C2 : B1, B2 { }; struct D : C1, C2 { }; struct E : D { }; extern int a = sizeof(E); Only with a "mess" could I blow it up e.g. 7: F:\>type 1.cpp && cl -c -FAsc 1.cpp && more 1.cod struct A1 { }; struct A2 { }; struct B1 : A1, A2 { }; struct B2 : A1, A2 { }; struct C1 : B1, B2 { }; struct C2 : B1, B2 { }; struct D : C1, C2 { }; struct E : D { }; extern int a = sizeof(E); Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.278 for x64 Copyright (C) Microsoft Corporation. All rights reserved.1.cpp ; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.278 include listing.incINCLUDELIB LIBCMT INCLUDELIB OLDNAMESPUBLIC ?a@@3HA ; a _DATA SEGMENT ?a@@3HA DD 07H ; a _DATA ENDS END - Jay > To: jay.krell at cornell.edu > Date: Thu, 4 Oct 2012 13:37:33 -0700 > From: mika at async.caltech.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] zero sized structs? > > > Well as a user I'm quite happy to see the two objects have different > addresses, if it makes your life easier as a compiler writer. However > it's certainly not documented---so I'd better not depend on it! > You're not supposed to be taking the ADR of stuff on the stack. > It's UNSAFE, caveat emptor, etc... I'm just saying that if you are > doing that you're not writing programs that Modula-3 was intended for. > If you want to pass something by reference, use VAR! > > I find that when you have trouble with zero-sized anything, you've usually > used the wrong abstraction.... In any case the fact that the language > allows certain things to be zero sized is very helpful when you are writing > programs that have to generate Modula-3 code. You don't have to keep > track and insert dummies in various places. But sure I can't think of any > reason the compiler couldn't implement zero-sized things as being one-sized > or four-sized, or whatever it/you want/s. It looks like they take 16 bytes > when you NEW them... (of course the report also says that "The reference > returned by NEW is distinct from all existing references") > > Mika > > > Jay writes: > >Same address & same size implies same object & same type. But the types can v= > >ary. Please check also variables in sub-blocks. I think NT/x86 backend doesn= > >'t always put them at same place. Then again, that is probably ok too -- in g= > >eneral not all zero sized objects can be located -- they could be locals in d= > >ifferent functions or globals in different modules. > > > > > >You say use a different language, but 1) they are exceedingly rare so ok to w= > >aste space 2) as small & simple Modula-3 is, it is still really isn't small o= > >r simple, there are surprising number & level of detail to understand and de= > >al with. Adding a notion of a zero sized thing isn't necessarily so obviousl= > >y simple and free of complexity down the line.=20 > > > > > > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > > >On Oct 4, 2012, at 11:23 AM, wrote: > > > >> It seems that CM3 puts them at the "same address".... > >>=20 > >> UNSAFE MODULE Main; > >> IMPORT IO, Fmt; > >>=20 > >> TYPE > >> T =3D ARRAY [1..-1] OF INTEGER; > >>=20 > >> VAR t :=3D NEW(REF T); u :=3D NEW(REF T); > >> v : T; > >> w : T; > >> BEGIN > >> IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base :=3D 16) & "\n"); > >> END Main. > >>=20 > >> (114)async:~/ttt/src>../AMD64_LINUX/prog > >> 2269030 > >> 2269040 > >> 602218 > >> 602218 > >>=20 > >> I don't see a problem with it. Whoever thinks he needs to check whether > >> ADR(v) equals ADR(w) should be using a different programming language... > >>=20 > >> Mika > >>=20 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 23:51:02 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 14:51:02 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: , , , , <20121004182339.3ECEC1A207D@async.async.caltech.edu>, , <20121004203733.0E95A1A207D@async.async.caltech.edu> Message-ID: <20121004215102.450531A207D@async.async.caltech.edu> > > (of course the report also says that "The reference returned by NEW is d= >istinct from all existing references") Aha. Good.And doesn't it seem kind o= >f nice and correct if that same sort of thing applied to locals and globals= >?More consistent that way? Well either way it's just not visible from the safe subset of the language... >Really I wouldn't mind if ARRAY [0..0] or ARRAY = >[0..-1] was just plain illegal.The following are not legal standard C/89/90= Sure but C doesn't have a type [0..-1] either... and I don't think you can get away without those sorts of types (called "empty types" in the report). HOWEVER, declaring a variable of an empty type or NEWing an empty type is a static error... There's a little section in the report about "making non-empty types out of empty types". The example is x : [0..-1]; (* illegal *) y := NEW(REF [0..-1]); (* illegal *) s : SET OF [0..-1]; (* legal *) s is legal because the type isn't empty; it contains the empty set. Likewise I suppose ARRAY OF [0..-1] also is legal because it contains the empty array. But sure there's a stronger argument for ruling the latter illegal than the former. The problem is, though, that that leaves you no way of statically declaring an array of size zero, which is certainly a useful concept. E.g., x : REF ARRAY OF INTEGER := NEW(REF ARRAY OF INTEGER, 0); ... WITH new = NEW(REF ARRAY OF INTEGER, NUMBER(x^) + 1) DO SUBARRAY(new^, 0, NUMBER(x^)) := x^; new[LAST(new^)] := newElement; END ... So I don't use [0..-1] here but you could certainly see xx : ARRAY [0..-1] OF INTEGER as being compatible with the initial value of x. Mika From hosking at cs.purdue.edu Fri Oct 5 15:31:02 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 5 Oct 2012 09:31:02 -0400 Subject: [M3devel] Output from "cron" command In-Reply-To: References: <201210041115.q94BFkUE006378@niagara.cs.purdue.edu>, , , Message-ID: <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> Jay, is there any chance we can put your M3C backend stuff in a separate library. I don?t understand why we are adding clutter to m3middle. Similarly, your hacks to m3cgcat to run your C backend should be duplicated in the C backend space rather than in m3cgcat. I?d prefer to keep m3middle as pristine as it was previously if only to avoid confusion for others. From jay.krell at cornell.edu Fri Oct 5 15:42:39 2012 From: jay.krell at cornell.edu (Jay) Date: Fri, 5 Oct 2012 06:42:39 -0700 Subject: [M3devel] Output from "cron" command In-Reply-To: <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> References: <201210041115.q94BFkUE006378@niagara.cs.purdue.edu> <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> Message-ID: On the 2nd point I'll soon have m3c interface to quake. For performance w/o adding another "mode". But having a separate executable going via .mc files is great for development and testing. On the 1st point..I added files, didn't change, as I recall. No difference if they are in m3back or m3middle. I found that decision unclear -- m3back vs m3middle. What I added is likely useful to other backend writers. Very generic. I really think this is about the right design. But code can be split up and moved fairly arbitrarily, cluttering the tree with more directories & libraries... The m3cgcat change is elegant and not a hack imo & very few people know about or understand this stuff, there shouldn't be much chance for confusion, but whatever.... - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 5, 2012, at 6:31 AM, Antony Hosking wrote: > Jay, is there any chance we can put your M3C backend stuff in a separate library. > I don?t understand why we are adding clutter to m3middle. > > Similarly, your hacks to m3cgcat to run your C backend should be duplicated in the C backend space rather than in m3cgcat. > > I?d prefer to keep m3middle as pristine as it was previously if only to avoid confusion for others. > From jay.krell at cornell.edu Wed Oct 10 06:08:52 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 04:08:52 +0000 Subject: [M3devel] completing M3CG_Binary.Op? Message-ID: M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 06:36:36 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 00:36:36 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote: > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 06:52:18 2012 From: jay.krell at cornell.edu (Jay) Date: Tue, 9 Oct 2012 21:52:18 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > >> M3CG_Binary.Op currently represents >> what we write to ".mc" files for the gcc >> backend to read in. This is very very close >> to what you'd want to fully represent M3CG.T. >> >> >> It missing an operation that takes a function pointer -- can't >> be stored in a file. It is missing operations that get converted >> to different operations by M3CG_Wr. There is no real >> value in the transform but it doesn't hurt either. >> >> >> I'd like to add the missing operations. >> It seems like a very sensible reasonable change to me. >> >> >> >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >> retrieving revision 1.19 >> diff -u -r1.19 M3CG_BinRd.m3 >> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >> @@ -37,7 +37,7 @@ >> END; >> >> CONST >> - CmdMap = ARRAY Bop OF Cmd { >> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >> Cmd {Bop.begin_unit, begin_unit}, >> Cmd {Bop.end_unit, end_unit}, >> Cmd {Bop.import_unit, import_unit}, >> Index: M3CG_Binary.i3 >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >> retrieving revision 1.6 >> diff -u -r1.6 M3CG_Binary.i3 >> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >> @@ -38,7 +38,17 @@ >> call_indirect, pop_param, pop_struct, pop_static_link, >> load_procedure, load_static_link, comment, >> store_ordered, load_ordered, exchange, compare_exchange, fence, >> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >> + >> + (* These only occur in memory, not in files. >> + Conversely, what they are converted to only occur in files, >> + not in memory. *) >> + set_error_handler, (* disk: contains a pointer, silently skipped *) >> + compare (* converted to eq/ne/etc. *) >> + cvt_int, (* converted to trunc/ceiling/etc. *) >> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >> + if_compare, (* converted to if_eq/if_ne/etc. *) >> + set_compare, (* converted to set_eq/set_ne/etc. *) >> }; >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 07:35:58 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 01:35:58 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Why? On Oct 10, 2012, at 12:52 AM, Jay wrote: > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > >> Forgive me, but I don?t understand the purpose of this change. >> >> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >> >>> M3CG_Binary.Op currently represents >>> what we write to ".mc" files for the gcc >>> backend to read in. This is very very close >>> to what you'd want to fully represent M3CG.T. >>> >>> >>> It missing an operation that takes a function pointer -- can't >>> be stored in a file. It is missing operations that get converted >>> to different operations by M3CG_Wr. There is no real >>> value in the transform but it doesn't hurt either. >>> >>> >>> I'd like to add the missing operations. >>> It seems like a very sensible reasonable change to me. >>> >>> >>> >>> =================================================================== >>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>> retrieving revision 1.19 >>> diff -u -r1.19 M3CG_BinRd.m3 >>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>> @@ -37,7 +37,7 @@ >>> END; >>> >>> CONST >>> - CmdMap = ARRAY Bop OF Cmd { >>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>> Cmd {Bop.begin_unit, begin_unit}, >>> Cmd {Bop.end_unit, end_unit}, >>> Cmd {Bop.import_unit, import_unit}, >>> Index: M3CG_Binary.i3 >>> =================================================================== >>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>> retrieving revision 1.6 >>> diff -u -r1.6 M3CG_Binary.i3 >>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>> @@ -38,7 +38,17 @@ >>> call_indirect, pop_param, pop_struct, pop_static_link, >>> load_procedure, load_static_link, comment, >>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>> + >>> + (* These only occur in memory, not in files. >>> + Conversely, what they are converted to only occur in files, >>> + not in memory. *) >>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>> + compare (* converted to eq/ne/etc. *) >>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>> }; >>> >>> >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 07:59:34 2012 From: jay.krell at cornell.edu (Jay) Date: Tue, 9 Oct 2012 22:59:34 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Message-ID: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > >> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >> >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >> >>> Forgive me, but I don?t understand the purpose of this change. >>> >>> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >>> >>>> M3CG_Binary.Op currently represents >>>> what we write to ".mc" files for the gcc >>>> backend to read in. This is very very close >>>> to what you'd want to fully represent M3CG.T. >>>> >>>> >>>> It missing an operation that takes a function pointer -- can't >>>> be stored in a file. It is missing operations that get converted >>>> to different operations by M3CG_Wr. There is no real >>>> value in the transform but it doesn't hurt either. >>>> >>>> >>>> I'd like to add the missing operations. >>>> It seems like a very sensible reasonable change to me. >>>> >>>> >>>> >>>> =================================================================== >>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>>> retrieving revision 1.19 >>>> diff -u -r1.19 M3CG_BinRd.m3 >>>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>>> @@ -37,7 +37,7 @@ >>>> END; >>>> >>>> CONST >>>> - CmdMap = ARRAY Bop OF Cmd { >>>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>>> Cmd {Bop.begin_unit, begin_unit}, >>>> Cmd {Bop.end_unit, end_unit}, >>>> Cmd {Bop.import_unit, import_unit}, >>>> Index: M3CG_Binary.i3 >>>> =================================================================== >>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>>> retrieving revision 1.6 >>>> diff -u -r1.6 M3CG_Binary.i3 >>>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>>> @@ -38,7 +38,17 @@ >>>> call_indirect, pop_param, pop_struct, pop_static_link, >>>> load_procedure, load_static_link, comment, >>>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>>> + >>>> + (* These only occur in memory, not in files. >>>> + Conversely, what they are converted to only occur in files, >>>> + not in memory. *) >>>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>>> + compare (* converted to eq/ne/etc. *) >>>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>>> }; >>>> >>>> >>>> >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 08:33:13 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 02:33:13 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Message-ID: Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > >> Why? >> >> On Oct 10, 2012, at 12:52 AM, Jay wrote: >> >>> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >>> >>> >>> - Jay (briefly/pocket-sized-computer-aka-phone) >>> >>> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >>> >>>> Forgive me, but I don?t understand the purpose of this change. >>>> >>>> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >>>> >>>>> M3CG_Binary.Op currently represents >>>>> what we write to ".mc" files for the gcc >>>>> backend to read in. This is very very close >>>>> to what you'd want to fully represent M3CG.T. >>>>> >>>>> >>>>> It missing an operation that takes a function pointer -- can't >>>>> be stored in a file. It is missing operations that get converted >>>>> to different operations by M3CG_Wr. There is no real >>>>> value in the transform but it doesn't hurt either. >>>>> >>>>> >>>>> I'd like to add the missing operations. >>>>> It seems like a very sensible reasonable change to me. >>>>> >>>>> >>>>> >>>>> =================================================================== >>>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>>>> retrieving revision 1.19 >>>>> diff -u -r1.19 M3CG_BinRd.m3 >>>>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>>>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>>>> @@ -37,7 +37,7 @@ >>>>> END; >>>>> >>>>> CONST >>>>> - CmdMap = ARRAY Bop OF Cmd { >>>>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>>>> Cmd {Bop.begin_unit, begin_unit}, >>>>> Cmd {Bop.end_unit, end_unit}, >>>>> Cmd {Bop.import_unit, import_unit}, >>>>> Index: M3CG_Binary.i3 >>>>> =================================================================== >>>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>>>> retrieving revision 1.6 >>>>> diff -u -r1.6 M3CG_Binary.i3 >>>>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>>>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>>>> @@ -38,7 +38,17 @@ >>>>> call_indirect, pop_param, pop_struct, pop_static_link, >>>>> load_procedure, load_static_link, comment, >>>>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>>>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>>>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>>>> + >>>>> + (* These only occur in memory, not in files. >>>>> + Conversely, what they are converted to only occur in files, >>>>> + not in memory. *) >>>>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>>>> + compare (* converted to eq/ne/etc. *) >>>>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>>>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>>>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>>>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>>>> }; >>>>> >>>>> >>>>> >>>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 17:53:50 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 15:53:50 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , Message-ID: M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 18:13:51 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 12:13:51 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , Message-ID: <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote: > M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. > > - Jay > > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 02:33:13 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] completing M3CG_Binary.Op? > > Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? > > On Oct 10, 2012, at 1:59 AM, Jay wrote: > > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 01:33:35 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 23:33:35 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> Message-ID: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 11 02:18:03 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 20:18:03 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> Message-ID: <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: > > Look at M3CG_MultiPass. > > For each function, it creates a record to hold the parameters. > So they can be later be looped over in a different order and/or multiple times. > The record includes an enum. > I need an enum that looks almost exactly like M3CG_Binary.Op, > except that I need those few missing elements. > > M3CG_MultiPass already has most of this, except > 1) I somehow forgot got to handle a bunch of them > 2) I need the below diff for it to be complete, or some other nearly identical enum instead. > > - Jay > > Subject: Re: [M3devel] completing M3CG_Binary.Op? > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 12:13:51 -0400 > CC: m3devel at elegosoft.com > To: jay.krell at cornell.edu > > I still don?t understand why the change is needed. > > On Oct 10, 2012, at 11:53 AM, Jay K wrote: > > M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. > > - Jay > > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 02:33:13 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] completing M3CG_Binary.Op? > > Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? > > On Oct 10, 2012, at 1:59 AM, Jay wrote: > > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 05:08:41 2012 From: jay.krell at cornell.edu (Jay) Date: Wed, 10 Oct 2012 20:08:41 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> Message-ID: <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: > Why not simply capture the state of the existing ops? e.g,, cvt_int. > > On Oct 10, 2012, at 7:33 PM, Jay K wrote: > >> >> Look at M3CG_MultiPass. >> >> For each function, it creates a record to hold the parameters. >> So they can be later be looped over in a different order and/or multiple times. >> The record includes an enum. >> I need an enum that looks almost exactly like M3CG_Binary.Op, >> except that I need those few missing elements. >> >> M3CG_MultiPass already has most of this, except >> 1) I somehow forgot got to handle a bunch of them >> 2) I need the below diff for it to be complete, or some other nearly identical enum instead. >> >> - Jay >> >> Subject: Re: [M3devel] completing M3CG_Binary.Op? >> From: hosking at cs.purdue.edu >> Date: Wed, 10 Oct 2012 12:13:51 -0400 >> CC: m3devel at elegosoft.com >> To: jay.krell at cornell.edu >> >> I still don?t understand why the change is needed. >> >> On Oct 10, 2012, at 11:53 AM, Jay K wrote: >> >> M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. >> >> - Jay >> >> From: hosking at cs.purdue.edu >> Date: Wed, 10 Oct 2012 02:33:13 -0400 >> To: jay.krell at cornell.edu >> CC: m3devel at elegosoft.com >> Subject: Re: [M3devel] completing M3CG_Binary.Op? >> >> Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? >> >> On Oct 10, 2012, at 1:59 AM, Jay wrote: >> >> I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: >> >> Why? >> >> On Oct 10, 2012, at 12:52 AM, Jay wrote: >> >> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >> >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >> >> Forgive me, but I don?t understand the purpose of this change. >> >> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >> >> M3CG_Binary.Op currently represents >> what we write to ".mc" files for the gcc >> backend to read in. This is very very close >> to what you'd want to fully represent M3CG.T. >> >> >> It missing an operation that takes a function pointer -- can't >> be stored in a file. It is missing operations that get converted >> to different operations by M3CG_Wr. There is no real >> value in the transform but it doesn't hurt either. >> >> >> I'd like to add the missing operations. >> It seems like a very sensible reasonable change to me. >> >> >> >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >> retrieving revision 1.19 >> diff -u -r1.19 M3CG_BinRd.m3 >> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >> @@ -37,7 +37,7 @@ >> END; >> >> CONST >> - CmdMap = ARRAY Bop OF Cmd { >> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >> Cmd {Bop.begin_unit, begin_unit}, >> Cmd {Bop.end_unit, end_unit}, >> Cmd {Bop.import_unit, import_unit}, >> Index: M3CG_Binary.i3 >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >> retrieving revision 1.6 >> diff -u -r1.6 M3CG_Binary.i3 >> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >> @@ -38,7 +38,17 @@ >> call_indirect, pop_param, pop_struct, pop_static_link, >> load_procedure, load_static_link, comment, >> store_ordered, load_ordered, exchange, compare_exchange, fence, >> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >> + >> + (* These only occur in memory, not in files. >> + Conversely, what they are converted to only occur in files, >> + not in memory. *) >> + set_error_handler, (* disk: contains a pointer, silently skipped *) >> + compare (* converted to eq/ne/etc. *) >> + cvt_int, (* converted to trunc/ceiling/etc. *) >> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >> + if_compare, (* converted to if_eq/if_ne/etc. *) >> + set_compare, (* converted to set_eq/set_ne/etc. *) >> }; > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 07:46:07 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 11 Oct 2012 05:46:07 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu>, , <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu>, <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> Message-ID: Tony, I think you might not understand, or have it backwards. In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory. For example, M3CG_Wr.m3: PROCEDURE set_compare (u: U; s: ByteSize; op: CompareOp; t: IType) = (* s1.t := (s1.B op s0.B) ; pop *) CONST OpName = ARRAY CompareOp OF TEXT { "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" }; BEGIN Cmd (u, OpName [op]); Int (u, s); TName (u, t); NL (u); END set_compare; but in my M3CG_MultiPass.m3 (not necessarily the commited version!) PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare; so -- ok with my change? Thank you, - Jay From: jay.krell at cornell.edu Date: Wed, 10 Oct 2012 20:08:41 -0700 To: hosking at cs.purdue.edu CC: m3devel at elegosoft.com; jay.krell at cornell.edu Subject: Re: [M3devel] completing M3CG_Binary.Op? I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 08:23:34 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 11 Oct 2012 06:23:34 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , , , , , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu>, , , , <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu>, , <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com>, Message-ID: Here is a more heavily commented diff.Again, notice that the existing code does a small translation in writing files. My desire is to represent M3CG call sequence more directly. Granted, it might be reasonable, really, to change one or the other -- either make M3CG.T more closely resemble M3CG_Wr, or the other way around -- remove the transform and adjust one backend(s) or other.I'd also be putting in more newlines, either to separate every enum element here, or to separate all the newly-commented ones, and put the comment on each one. Index: m3-sys/m3cggen/src/Main.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3cggen/src/Main.m3,vretrieving revision 1.6diff -u -r1.6 Main.m3--- m3-sys/m3cggen/src/Main.m3 1 Nov 2010 09:59:44 -0000 1.6+++ m3-sys/m3cggen/src/Main.m3 11 Oct 2012 06:18:42 -0000@@ -9,7 +9,7 @@ Desc = RECORD name: TEXT; op: Op; END; CONST- Map = ARRAY Op OF Desc {+ Map = ARRAY [Op.begin_unit..Op.fetch_and_xor] OF Desc { Desc { "begin_unit", Op.begin_unit }, Desc { "end_unit", Op.end_unit }, Desc { "import_unit", Op.import_unit }, Index: m3-sys/m3middle/src/M3CG_BinRd.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- m3-sys/m3middle/src/M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ m3-sys/m3middle/src/M3CG_BinRd.m3 11 Oct 2012 06:18:42 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: m3-sys/m3middle/src/M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- m3-sys/m3middle/src/M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ m3-sys/m3middle/src/M3CG_Binary.i3 11 Oct 2012 06:18:42 -0000@@ -21,14 +21,19 @@ end_init, init_int, init_proc, init_label, init_var, init_offset, init_chars, init_float, import_procedure, declare_procedure, begin_procedure, end_procedure, begin_block, end_block,- note_procedure_origin, set_label, jump, if_true, if_false, if_eq,- if_ne, if_gt, if_ge, if_lt, if_le, case_jump, exit_proc, load,+ note_procedure_origin, set_label, jump, if_true, if_false,+ if_eq, if_ne, if_gt, if_ge, if_lt, if_le, (* file only; in-memory uses if_compare *)+ case_jump, exit_proc, load, load_address, load_indirect, store, store_indirect,- load_nil, load_integer, load_float, eq, ne,- gt, ge, lt, le, add, subtract, multiply, divide, negate, abs, max,- min, round, trunc, floor, ceiling, cvt_float, div, mod, set_union,+ load_nil, load_integer, load_float,+ eq, ne, gt, ge, lt, le, (* file only; in-memory uses compare *)+ add, subtract, multiply, divide, negate, abs, max,+ min,+ round, trunc, floor, ceiling, (* file only; in-memory uses cvt_int *)+ cvt_float, div, mod, set_union, set_difference, set_intersection, set_sym_difference, set_member,- set_eq, set_ne, set_lt, set_le, set_gt, set_ge, set_range,+ set_eq, set_ne, set_lt, set_le, set_gt, set_ge, (* file only; in-memory uses set_compare *)+ set_range, set_singleton, not, and, or, xor, shift, shift_left, shift_right, rotate, rotate_left, rotate_right, widen, chop, extract, extract_n, extract_mn, insert, insert_n, insert_mn, swap, pop, copy_n, copy,@@ -38,7 +43,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, (* file only; in-memory uses fetch_and_op *)+ fetch_and_sub, (* file only; in-memory uses fetch_and_op *)+ fetch_and_or, (* file only; in-memory uses fetch_and_op *)+ fetch_and_and, (* file only; in-memory uses fetch_and_op *)+ fetch_and_xor, (* file only; in-memory uses fetch_and_op *)+ set_error_handler, (* in-memory only; contains a pointer, so silently skipped in files *)+ compare, (* in-memory only; file converts to eq/ne/etc. *)+ cvt_int, (* in-memory only; file converts to trunc/ceiling/etc. *)+ fetch_and_op, (* in-memory only; file converts to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* in-memory only; file converts to if_eq/if_ne/etc. *)+ set_compare (* in-memory only; file converts to set_eq/set_ne/etc. *) }; (* Integers are encoded as sequences of unsigned bytes, [0..255]. - Jay From: jay.krell at cornell.edu To: hosking at cs.purdue.edu Date: Thu, 11 Oct 2012 05:46:07 +0000 CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Tony, I think you might not understand, or have it backwards. In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory. For example, M3CG_Wr.m3: PROCEDURE set_compare (u: U; s: ByteSize; op: CompareOp; t: IType) = (* s1.t := (s1.B op s0.B) ; pop *) CONST OpName = ARRAY CompareOp OF TEXT { "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" }; BEGIN Cmd (u, OpName [op]); Int (u, s); TName (u, t); NL (u); END set_compare; but in my M3CG_MultiPass.m3 (not necessarily the commited version!) PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare; so -- ok with my change? Thank you, - Jay From: jay.krell at cornell.edu Date: Wed, 10 Oct 2012 20:08:41 -0700 To: hosking at cs.purdue.edu CC: m3devel at elegosoft.com; jay.krell at cornell.edu Subject: Re: [M3devel] completing M3CG_Binary.Op? I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 1.txt URL: From jay.krell at cornell.edu Fri Oct 12 06:43:58 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 04:43:58 +0000 Subject: [M3devel] C backend -- mode or call quake? Message-ID: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 12 18:50:46 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 16:50:46 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Oct 12 19:23:59 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 12 Oct 2012 13:23:59 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote: > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Oct 12 19:23:59 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 12 Oct 2012 13:23:59 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote: > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 12 19:46:42 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 17:46:42 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: Emulating the gcc-based approach is not good. We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. "External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake. OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). It shouldn't be a big deal either way. cm3/Builder still has to new up a different backend. For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. - Jay From: hosking at cs.purdue.edu Date: Fri, 12 Oct 2012 13:23:59 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Sat Oct 13 06:25:11 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Sat, 13 Oct 2012 00:25:11 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> On Oct 12, 2012, at 1:46 PM, Jay K wrote: > Emulating the gcc-based approach is not good. > > > We have four modes currently: > ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject > (They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) > > > NT/x86 uses IntegratedObject > gcc/m3cg uses ExternalAssembly > "External" means "produce .mc files and run the quake function m3back()" > "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. > > > currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. > > > "External" anything is convenient for development and testing, bad for performance. > It writes and reads the .mc files. > Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. > > > "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". > > > So that leaves us with IntegratedObject. > M3C.m3 will have to interact with quake. Yuck! > OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). Yes! > It shouldn't be a big deal either way. > > > cm3/Builder still has to new up a different backend. > > > For LLVM you'll likely follow a similar course. > "External" is convenient for development and testing, but slower. > "Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly". > You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. Agreed, but that is not so difficult. > > > > - Jay > > > From: hosking at cs.purdue.edu > Date: Fri, 12 Oct 2012 13:23:59 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com; antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > > Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. > > On Oct 12, 2012, at 12:50 PM, Jay K wrote: > > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 13 06:44:57 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 13 Oct 2012 04:44:57 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> References: , , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , , , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu>, , <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> Message-ID: Aha, you like a new mode, IntegratedC? A bit more of a change in cm3/Builder, but leaves M3C.m3 ignorant of quake? Ok. I like it too. I had it working. I sent the diff. The only perhaps controversial part is I changed an error to be "more fatal" (stop right away, I think). I can bring that back. - Jay From: hosking at cs.purdue.edu Date: Sat, 13 Oct 2012 00:25:11 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? On Oct 12, 2012, at 1:46 PM, Jay K wrote:Emulating the gcc-based approach is not good. We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. "External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake. Yuck! OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). Yes! It shouldn't be a big deal either way. cm3/Builder still has to new up a different backend. For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. Agreed, but that is not so difficult. - Jay From: hosking at cs.purdue.edu Date: Fri, 12 Oct 2012 13:23:59 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Mon Oct 15 20:35:01 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Mon, 15 Oct 2012 11:35:01 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: <20121015183501.4A7AB1A2082@async.async.caltech.edu> Jay K writes: ... >"External" anything is convenient for development and testing=2C bad for pe= >rformance. It writes and reads the .mc files. Besides development/testin= >g=2C it also is used for licensing reasons -- communication through files i= >nstead of "linking" code. ... Jay you keep coming back to this issue of the performance of the compiler. Do you use Modula-3 for some large projects I'm not aware of? I compile quite a bit of code with it, and sure it would be cool (always is) if it were faster but it's not like the lack of speed has ever bothered me (not since the silly 0.1-second delay was removed from Process.Wait). I also implemented a parallelized back-end mode a while ago (it's in the tree). The speed of the compiler is mainly an issue when recompiling the world, which is something that happens mainly during "development/testing", and then not by regular users, normally... Mika From jay.krell at cornell.edu Tue Oct 16 02:21:23 2012 From: jay.krell at cornell.edu (Jay) Date: Mon, 15 Oct 2012 17:21:23 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <20121015183501.4A7AB1A2082@async.async.caltech.edu> References: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: The current usage of C backend is noticeably much slower than cm3cg. I really don't like it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 15, 2012, at 11:35 AM, wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance. It writes and reads the .mc files. Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait). I also > implemented a parallelized back-end mode a while ago (it's in the tree). > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > > Mika From rodney_bates at lcwb.coop Tue Oct 16 18:36:35 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Tue, 16 Oct 2012 11:36:35 -0500 Subject: [M3devel] M3CG_Ops.Public vs. M3CG.T Message-ID: <507D8D13.80603@lcwb.coop> I'm finally getting around to responding to this. On 09/27/2012 02:00 PM, Jay K wrote:> One thing I missed is that > > > IMPORT M3CG; > > > Give you an M3CG.T that you can only pass around. > > Add IMPORT M3CG_Ops I think it was > and then you can make all the method calls on an M3CG.T. > > I don't see that the first intermediate step is useful, but oh well. > Everyone might as well just IMPORT M3CG_Ops. > > > It is kind of interesting that "private" and "protected" are kind of available in Modula-3, or at least one clump therein, by moving part of the interface into a separate file. Modula-3's hiding mechanism, while a lot simpler to define, is *much* more flexible than C++'s. In fact, the flexibility is, in a sense, unbounded. The fields and methods of an object type can have a different, arbitrary subset of them made visible in every interface or module. Just make a chain of opaque subtypes for each clump of fields/methods whose visibility you want to be able to control independently. Then provide a revelation for each clump. The one limitation is that each of the revelations has to be in a separate interface, because you want to be able to import any subset of the revelations, but you can't directly import a revelation, only an interface, which brings in all the revelations in that interface. This makes it syntactically a bit ponderous. But this cost brings a big benefit in language simplicity. A few sentences of language definition suffice, instead of a few pages. > > I say one clump, because I don't think you can do this: > > > FooRoot.i3: > TYPE Foo <: ROOT; > > Foo1.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F1(); > END; > > Foo2.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F2(); > END; > > Foo.m3: > REVEAL Foo = OBJECT METHODS > PROCEDURE F1(); > PROCEDURE F2(); > END; > You can write something like this, but Foo1.Foo and Foo2.Foo are distinct types not related to each other, nor to FooRoot.Foo. All three are side-by-side inheritance children of ROOT. Also, Foo1.Foo and Foo2.Foo will have to have full revelations somewhere. I'm not sure what you meant here, but I doubt this was it. > I think you can only have just: > > FooRoot.i3: > TYPE Foo <: ROOT; > > Foo1.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F1(); > END; > > Foo.m3: > REVEAL Foo = OBJECT METHODS > PROCEDURE F1(); > PROCEDURE F2(); > END; > Which is the same, apart from the nonexistence of Foo2 and Foo2.Foo. > > It'd also be useful if you could do like this: > > Stream.i3: > > Reader = OBJECT METHODS PROCEDURE Read(); END; > Writer = OBJECT METHODS PROCEDURE Write(); END; > TYPE Stream <: Reader; > TYPE Stream <: Writer; > > Stream.m3: > REVEAL Stream = OBJECT METHODS > PROCEDURE Read(); > PROCEDURE Write(); > END; > > i.e. -- multiple inheritance. > > I realize you can reveal in multiple linear steps though...which I'm not going to give an example of right now.. so it isn't just "one clump", but if you reveal "multiple clumps", they need to form a linear chain, right? You can't "mix" as I showed for read/write. ? > > I think not requiring linearizing fields/methods would inevitably suck you into the tar pit of multiple inheritance. Multiple inheritance has been debated to death many times. The most charitable thing you can say is the price in semantic complexity outweighs, by orders of magnitude, the useful benefits. Here is an example showing visibility of arbitrary subsets of 3 fields: INTERFACE Opaque ; TYPE HideA <: ROOT ; TYPE HideB <: HideA ; TYPE HideC <: HideB ; TYPE T <: HideC ; END Opaque . INTERFACE ShowA ; IMPORT Opaque ; REVEAL Opaque . HideA = BRANDED OBJECT A : INTEGER := 1 END ; END ShowA . INTERFACE ShowB ; IMPORT Opaque ; REVEAL Opaque . HideB = Opaque . HideA BRANDED OBJECT B : INTEGER := 1 END ; END ShowB . INTERFACE ShowC ; IMPORT Opaque ; REVEAL Opaque . HideC = Opaque . HideB BRANDED OBJECT C : INTEGER := 1 END ; END ShowC . MODULE Opaque ; REVEAL T = HideC BRANDED OBJECT END ; BEGIN END Opaque . MODULE Client EXPORTS Main ; IMPORT Opaque ; IMPORT ShowA ; IMPORT ShowB ; IMPORT ShowC ; VAR O := NEW ( Opaque . T ) ; BEGIN O . A := 4 (* Legal iff ShowA is imported. *) ; O . B := 5 (* Legal iff ShowB is imported. *) ; O . C := 6 (* Legal iff ShowC is imported. *) ; EVAL O END Client . > - Jay From jay.krell at cornell.edu Wed Oct 17 03:08:01 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 17 Oct 2012 01:08:01 +0000 Subject: [M3devel] in defense of ternary operator (Ada has it now) Message-ID: In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: e.g. sign := if a >= 0 then 1 else -1 They'd rather people NOT do like: sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Wed Oct 17 18:05:07 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 17 Oct 2012 11:05:07 -0500 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: <507ED733.7020602@lcwb.coop> On 10/15/2012 07:21 PM, Jay wrote: > The current usage of C backend is noticeably much slower than cm3cg. I really don't like it. > At first thought, this didn't surprise me. Leaving out combinatorially heavy back-end optimizations, the usual primary speed bottleneck in compilers has always been lexical scanning. Not because it is fundamentally an inefficient task, but because of fundamentally high iteration count. It has to look at files one character at a time, for every character. In contrast, parsing, which is not a lot different in algorithmic efficiency (perhaps slower), only has to process lexical tokens, minus comments and white space. This gives iteration counts lower by a factor of several. Mostly ditto for the rest of the phases. So, for a back-end that generates source code in some character-encoded language, an every-character-one-at-a-time process has to happen twice, once in generating the source code, and again in scanning it. The cm3cg approach skips both these. This difference is fundamental to the two approaches, and not a lot can be done about it. But on second thought, if I understand correctly, both gcc reading text file input and cm3cg do the same at a later stage by generating assembly source code, then passing it to an assembler. And I would expect equivalent assembly code to have higher character count than C code, by a factor of a few. (In a quick look, I see one case giving a 3-to-1 expansion from Modula-2 source to assembly code.) I would expect this to dilute the extra time spent generating/scanning the C code. But maybe slowdowns in the neighborhood of 10% to 20% might be explainable this way. > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 15, 2012, at 11:35 AM, wrote: > >> Jay K writes: >> ... >>> "External" anything is convenient for development and testing=2C bad for pe= >>> rformance. It writes and reads the .mc files. Besides development/testin= >>> g=2C it also is used for licensing reasons -- communication through files i= >>> nstead of "linking" code. >> ... >> >> Jay you keep coming back to this issue of the performance of the compiler. >> Do you use Modula-3 for some large projects I'm not aware of? I compile >> quite a bit of code with it, and sure it would be cool (always is) if it >> were faster but it's not like the lack of speed has ever bothered me (not >> since the silly 0.1-second delay was removed from Process.Wait). I also >> implemented a parallelized back-end mode a while ago (it's in the tree). >> The speed of the compiler is mainly an issue when recompiling the world, >> which is something that happens mainly during "development/testing", >> and then not by regular users, normally... >> >> Mika > From rodney_bates at lcwb.coop Wed Oct 17 18:11:22 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 17 Oct 2012 11:11:22 -0500 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <20121015183501.4A7AB1A2082@async.async.caltech.edu> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: <507ED8AA.6090105@lcwb.coop> On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance. It writes and reads the .mc files. Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait). I also > implemented a parallelized back-end mode a while ago (it's in the tree). I didn't know that. Any experience on how stable it is? Time compiling isn't a huge issue for me either, but now that we all have n cores on a chip, for growing n, and little way to utilize them, that would indeed be cool. > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > > Mika > From mika at async.caltech.edu Wed Oct 17 20:23:59 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Wed, 17 Oct 2012 11:23:59 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <507ED8AA.6090105@lcwb.coop> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> <507ED8AA.6090105@lcwb.coop> Message-ID: <20121017182359.5F8641A2082@async.async.caltech.edu> It was a little difficult to find, but here it is... https://mail.elegosoft.com/pipermail/m3commit/2011-February/009784.html Note I don't know how good pthreads are nowadays. It works fine with user threads... last time I tried it with pthreads my compiler hung, but I know there have been fixes since then. Mika "Rodney M. Bates" writes: > > >On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: >> Jay K writes: >> ... >>> "External" anything is convenient for development and testing=2C bad for pe= >>> rformance. It writes and reads the .mc files. Besides development/testin= >>> g=2C it also is used for licensing reasons -- communication through files i= >>> nstead of "linking" code. >> ... >> >> Jay you keep coming back to this issue of the performance of the compiler. >> Do you use Modula-3 for some large projects I'm not aware of? I compile >> quite a bit of code with it, and sure it would be cool (always is) if it >> were faster but it's not like the lack of speed has ever bothered me (not >> since the silly 0.1-second delay was removed from Process.Wait). I also >> implemented a parallelized back-end mode a while ago (it's in the tree). > >I didn't know that. Any experience on how stable it is? Time compiling >isn't a huge issue for me either, but now that we all have n cores on a >chip, for growing n, and little way to utilize them, that would indeed >be cool. > >> The speed of the compiler is mainly an issue when recompiling the world, >> which is something that happens mainly during "development/testing", >> and then not by regular users, normally... >> >> Mika >> From hendrik at topoi.pooq.com Thu Oct 18 02:11:47 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Wed, 17 Oct 2012 20:11:47 -0400 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: References: Message-ID: <20121018001147.GA2937@topoi.pooq.com> On Wed, Oct 17, 2012 at 01:08:01AM +0000, Jay K wrote: > In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: > e.g. > sign := if a >= 0 then 1 else -1 > They'd rather people NOT do like: > sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 > http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf > "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. > None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay This syntax originated a long time ago, with Algol 60. It wasn't a problem there, even though empty statements were invisible there, too. These, howerver, are expressions, and there are no empty expressions in either Algol 60 or Modula 3. The only problemm was the dangling "else" as in if ... then if ... then ... else ... But that's only a problem with statements, singe expressions always have to have their else's. For consistency of notation, IF expressions in Modula 3 should probably have explicit ENDs, as in Algol 68. -- hendrik From dabenavidesd at yahoo.es Thu Oct 18 17:08:46 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Thu, 18 Oct 2012 16:08:46 +0100 (BST) Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <507ED8AA.6090105@lcwb.coop> Message-ID: <1350572926.52530.YahooMailClassic@web29703.mail.ird.yahoo.com> Hi all: Some parallelized RT environments gave in DEC-SRC times degradation when N ~ 3 of processors than when it was > 10 in any particular program not only compilers. SO, I'm not so optimistic in general about that N growing too much. This is about what SPWM3 said succinctly I don't remember the quote. Hopefully research in other architectures like Message Passing could make the case for better compiler technology. I don't know what else you could make with those extra N < 10 cores, I believe there should be something but in those architectures, not emulating DEC architectures like currently amd tries to do, but other new approaches, but DEC is over Thanks in advance --- El mi?, 17/10/12, Rodney M. Bates escribi?: De: Rodney M. Bates Asunto: Re: [M3devel] C backend -- mode or call quake? Para: m3devel at elegosoft.com Fecha: mi?rcoles, 17 de octubre, 2012 11:11 On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance.? It writes and reads the .mc files.???Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of?? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait).? I also > implemented a parallelized back-end mode a while ago (it's in the tree). I didn't know that.? Any experience on how stable it is?? Time compiling isn't a huge issue for me either, but now that we all have n cores on a chip, for growing n, and little way to utilize them, that would indeed be cool. > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > >? ? ? Mika > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Thu Oct 18 17:28:57 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Thu, 18 Oct 2012 10:28:57 -0500 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: <20121018001147.GA2937@topoi.pooq.com> References: <20121018001147.GA2937@topoi.pooq.com> Message-ID: <50802039.6010102@lcwb.coop> On 10/17/2012 07:11 PM, Hendrik Boom wrote: > On Wed, Oct 17, 2012 at 01:08:01AM +0000, Jay K wrote: >> In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: >> e.g. >> sign := if a >= 0 then 1 else -1 >> They'd rather people NOT do like: >> sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 >> http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf >> "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. >> None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay > > This syntax originated a long time ago, with Algol 60. It wasn't a > problem there, even though empty statements were invisible there, too. > These, howerver, are expressions, and there are no empty expressions in > either Algol 60 or Modula 3. > > The only problemm was the dangling "else" as in > if ... then if ... then ... else ... > But that's only a problem with statements, singe expressions always have > to have their else's. > > For consistency of notation, IF expressions in Modula 3 should probably > have explicit ENDs, as in Algol 68. Yes. There is a somewhat different syntax problem here. Would: IF B THEN T ELSE IF C THEN U ELSE IF D THEN V ELSE F Mean: IF B THEN T ELSE (IF C THEN U ELSE IF D THEN V ELSE F) (* IF is right-associative. *) Or: IF B THEN T ELSE IF C THEN U ELSE (IF D THEN V ELSE F) (* IF is left-associative. *) Would: IF B THEN T ELSE E OR F Mean: IF B THEN T ELSE (E OR F) (* OR has higher precedence than IF. *) Or: (IF B THEN T ELSE E) OR F (* OR has lower precedence than IF. *) Precedence and associativity rules for the IF-expression would resolve these, and all the existing expression operators have these properties. But somehow, the IF-expression intuitively seems to me to be a lot harder to follow than for more traditional infix operators. And for associativity there is an unusual asymmetry about it. At first, I wanted to write (IF B THEN T ELSE IF C THEN U ELSE) IF D THEN V ELSE F (* IF is left-associative. *) But that's really wierd, and would make IF B THEN T ELSE IF C THEN U ELSE (* Nothing here *) an expression, which breaks everything. Giving it a closing END seems a lot easier to fix the syntax and easier to read. > > -- hendrik > > From hendrik at topoi.pooq.com Thu Oct 18 23:04:54 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Thu, 18 Oct 2012 17:04:54 -0400 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: <50802039.6010102@lcwb.coop> References: <20121018001147.GA2937@topoi.pooq.com> <50802039.6010102@lcwb.coop> Message-ID: <20121018210454.GA2496@topoi.pooq.com> On Thu, Oct 18, 2012 at 10:28:57AM -0500, Rodney M. Bates wrote: > > > On 10/17/2012 07:11 PM, Hendrik Boom wrote: > >For consistency of notation, IF expressions in Modula 3 should probably > >have explicit ENDs, as in Algol 68. > > Yes. There is a somewhat different syntax problem here. > > Would: > IF B THEN T ELSE IF C THEN U ELSE IF D THEN V ELSE F > Mean: > IF B THEN T ELSE (IF C THEN U ELSE IF D THEN V ELSE F) (* IF is right-associative. *) > Or: > IF B THEN T ELSE IF C THEN U ELSE (IF D THEN V ELSE F) (* IF is left-associative. *) Can't see how this would happen if IF is left-associative. It looks more ike right-associative to me. In fact, right-associative should look like this: IF B THEN T ELSE (IF C THEN U ELSE (IF D THEN V ELSE F)) And what could left-associative even mean if IF has no left argument? > > Would: > IF B THEN T ELSE E OR F > Mean: > IF B THEN T ELSE (E OR F) (* OR has higher precedence than IF. *) > Or: > (IF B THEN T ELSE E) OR F (* OR has lower precedence than IF. *) > > Precedence and associativity rules for the IF-expression would resolve > these, It would. > and all the existing expression operators have these properties. > But somehow, the IF-expression intuitively seems to me to be a lot harder > to follow than for more traditional infix operators. > > And for associativity there is an unusual asymmetry about it. At first, > I wanted to write > (IF B THEN T ELSE IF C THEN U ELSE) IF D THEN V ELSE F (* IF is left-associative. *) > But that's really wierd, Yes, it is, because IF doesn't take a left argument,so it's syntactic nonsense. > and would make > IF B THEN T ELSE IF C THEN U ELSE (* Nothing here *) > an expression, which breaks everything. Also syntactic nonsense for ane expression. > > Giving it a closing END seems a lot easier to fix the syntax and > easier to read. Yup, that's the right answer for IF. As discovered in Algol 68 long ago. ONly they spelled it FI instead of END. -- hendrik From hosking at cs.purdue.edu Fri Oct 19 15:56:11 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 19 Oct 2012 09:56:11 -0400 Subject: [M3devel] Windows issue Message-ID: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 19 17:51:27 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 19 Oct 2012 15:51:27 +0000 Subject: [M3devel] Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative.There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks.We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe.I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this:call c:\program files\...vcvars32.bat -- user editable line%~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts?Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10.cm3 does not find the Windows linker. I work with vim and have configured themake macro to call cm3/bin/cm3.exe and the error happens when quake tries toinvoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent.It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University305 N. University Street | West Lafayette | IN 47907 | USAMobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Fri Oct 19 17:53:18 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Fri, 19 Oct 2012 16:53:18 +0100 (BST) Subject: [M3devel] Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: <1350661998.61721.YahooMailClassic@web29705.mail.ird.yahoo.com> Hi all: why do you need vim to sep up the compiler, it seems odd, all you need is an installation with cminstall and you 'll be ready. If you want to use CM3IDE with vim you can build from CM3IDE with no problems, otherwise please give more details on your side so other can help you more (i.e are you building cm3 with what commands within vim, etc). I haven't used msi installers, are you trying to use those? I heard of someone having trouble with that, but I can't give you more details than that. Thanks in advance --- El vie, 19/10/12, Antony Hosking escribi?: De: Antony Hosking Asunto: [M3devel] Windows issue Para: "m3devel developers" Fecha: viernes, 19 de octubre, 2012 08:56 I have had a query from a user of CM3 regarding Windows installation. ?I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10.cm3 does not find the Windows linker. I work with vim and have configured themake macro to call cm3/bin/cm3.exe and the error happens when quake tries toinvoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent.It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking?|?Associate Professor?| Computer Science | Purdue University305 N. University Street | West Lafayette | IN 47907 | USAMobile?+1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rcolebur at SCIRES.COM Fri Oct 19 22:18:55 2012 From: rcolebur at SCIRES.COM (Coleburn, Randy) Date: Fri, 19 Oct 2012 16:18:55 -0400 Subject: [M3devel] EXT: Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: My post back on 9/20/2012 describes what I do for using CM3 on Windows. I can resend again if needed. My scripts will take care of calling vcvars.bat when setting up the command prompt window for using CM3. The script can be tailored easily to account for differences in location of vcvars.bat among the various Visual Studio releases, including VS 10. --Randy Coleburn From: Antony Hosking [mailto:hosking at cs.purdue.edu] Sent: Friday, October 19, 2012 9:56 AM To: m3devel developers Subject: EXT:[M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmuysers at hotmail.com Sat Oct 20 16:33:40 2012 From: dmuysers at hotmail.com (Dirk Muysers) Date: Sat, 20 Oct 2012 16:33:40 +0200 Subject: [M3devel] Windows issue In-Reply-To: References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A brute force approach such as copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). Now, the the interest of calling cm3 from within VIM resides in the fact that it leads one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative. There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay -------------------------------------------------------------------------------- From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Sat Oct 20 20:34:15 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Sat, 20 Oct 2012 19:34:15 +0100 (BST) Subject: [M3devel] Windows issue In-Reply-To: Message-ID: <1350758055.17350.YahooMailClassic@web29702.mail.ird.yahoo.com> Hi all: CM3IDE reloads packages each upon a time concurrently across clients whether browser tabs or all in one like Deckscape decks like functionality: http://www.ibiblio.org/openvideo/video/chi/chi96_17_m1.mpg IMHO if you combine both of them you can get a better distributed environment for programming than most people are used to. It's just like Modula-3 too ahead of its time if you like simplicity. The other approach for Modula-3 is M3clipse, a Eclipse Plugin that builds upon AST, needs more to work autocompletion, if we could make that work with extra functionalities in an Applet we could get the best framework IMHO for distributed programming, Thanks in advance --- El s?b, 20/10/12, Dirk Muysers escribi?: De: Dirk Muysers Asunto: Re: [M3devel] Windows issue Para: "Jay K" , "Tony" , "m3devel" Fecha: s?bado, 20 de octubre, 2012 09:33 Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second?solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A?brute force approach such as?copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). ? Now, the the interest of calling cm3 from within?VIM resides in the fact that it leads?one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a? pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. ? And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue ?> I?know there exists vcvars32.bat, but its effect is not permanent. ? Sure it is. If you use it right. Permance is relative. There are two easy ways. ? ? 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 ? ? 2.?somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). ? ? ?> It should be invoked somewhere by cm3/bin/config/NT386.common etc. ? ? Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. ? ? Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. ? ? Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: ? ? We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. ? ? On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com?that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. ? ? The lesson is "users should run foo" and "creative environments" should introduce "foo.com". ? ? But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. ? ? whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. ? ? Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. ? ? ?-?Jay ? From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. ?I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking?|?Associate Professor?| Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile?+1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 20 21:05:08 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 20 Oct 2012 19:05:08 +0000 Subject: [M3devel] comparisons and subranges Message-ID: Typecode = [0 .. 16_FFFFF]; (* can fit in 20 bits *)tc: Typecode. IF (tc # RTType.NoSuchType) AND (0 <= tc) AND (tc < n) THEN if(((INT64)(((INT64)(M3_INT64(0)))))>((INT64)(((INT64)(*(UINT32*)(&tc_L_68))))))goto L4F; gcc:../src/runtime/common/RTutils.m3:233: warning: comparison is always false due to limited range of data type I'd like to be warning-free.I think this is the only class of warning I have now. Thoughts? Could the frontend eliminate some of this stuff? Otherwise I might do constant-folding in the C backend. I had offered a patch months ago that would do some simple stuff in the frontendinvolving comparisons and subranges.Try that again?(i.e. see how many warnings it removes, see if it suffices?) I might just try hiding constants inside functions for now, at least zero since it is the biggest offender:.static int Zero(void) { return 0; } Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 20 21:09:17 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 20 Oct 2012 19:09:17 +0000 Subject: [M3devel] Windows issue In-Reply-To: References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu>, , Message-ID: > And Microsoft's command shell is a pain in the backside to say the least. I live in cmd every day and find it vastly preferable to e.g. Mac OS X Terminal.It's output is much faster. It's command line editing is much better, including history.The feature invoked by the F8 key -- command line completion against history -- I use all the time and have yet to find anywhere else. > A brute force approach such as copying "link.exe" to cm3/bin doesn't work either >because Agreed. A \cm3\bin\link.cmd that first runs vcvars32.bat would work. > it doesn't allow copy-paste etc etc Sure it does! I use it all the timeBy default you have to use the menu in the upper left, but you can enable "quickedit" and then it is more convenient. You should definitely try it. > And also, sorry to say so, cm3ide is far from being an elegant development tool, you caninspect only one file at a time and using VIM from cm3ide brings you back to the abovedilemma. Agreed. cm3ide is kind of worthless and not an "IDE" by anyone's expectation. - Jay From: dmuysers at hotmail.com To: jay.krell at cornell.edu; hosking at cs.purdue.edu; m3devel at elegosoft.com Date: Sat, 20 Oct 2012 16:33:40 +0200 Subject: Re: [M3devel] Windows issue Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A brute force approach such as copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). Now, the the interest of calling cm3 from within VIM resides in the fact that it leads one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative. There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 07:42:16 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 05:42:16 +0000 Subject: [M3devel] suspicious order of evaluation? Message-ID: m3tohtml/src/Main.m3: sources is global PROCEDURE Add() = BEGIN sources := NEW (Source, next := sources, from := Pathname.Join(pkgpath, file, NIL), to := Pathname.Join(pkg, FixDerived (file), NIL), kind := kind); It APPEARS this compiles to like: temp = RTHooks__AllocateTracedRef(...); sources = temp if temp == NULL raise exception sources->from = ... sources->to = ... To me this seems a bit suspicious. First, the null check should be against the temp. Sources should not be assigned and then checked. Second, probably, the fields of sources should be filled in before the global. So, it should be more like: temp = RTHooks__AllocateTracedRef(); if temp == NULL raise exception temp->from = ... temp->to = ... sources = temp ... Just as efficient, but "safer". Now, I realize, without a lock or barrier, the compiler is free to reorder like this.Maybe ideally temp would be gone but the original order used? C++ would implement it more like how I showed. Thoughts? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 07:57:37 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 05:57:37 +0000 Subject: [M3devel] suspicious order of evaluation? In-Reply-To: References: Message-ID: correction: temp = RTHooks__AllocateTracedRef(...); sources = temp if sources == NULL raise exception - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 25 Oct 2012 05:42:16 +0000 Subject: [M3devel] suspicious order of evaluation? m3tohtml/src/Main.m3: sources is global PROCEDURE Add() = BEGIN sources := NEW (Source, next := sources, from := Pathname.Join(pkgpath, file, NIL), to := Pathname.Join(pkg, FixDerived (file), NIL), kind := kind); It APPEARS this compiles to like: temp = RTHooks__AllocateTracedRef(...); sources = temp if temp == NULL raise exception sources->from = ... sources->to = ... To me this seems a bit suspicious. First, the null check should be against the temp. Sources should not be assigned and then checked. Second, probably, the fields of sources should be filled in before the global. So, it should be more like: temp = RTHooks__AllocateTracedRef(); if temp == NULL raise exception temp->from = ... temp->to = ... sources = temp ... Just as efficient, but "safer". Now, I realize, without a lock or barrier, the compiler is free to reorder like this.Maybe ideally temp would be gone but the original order used? C++ would implement it more like how I showed. Thoughts? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 10:12:41 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 08:12:41 +0000 Subject: [M3devel] what is wrong with TIntN? Message-ID: When faced with VAR a := FIRST(INTEGER) + 1;VAR b := LAST(INTEGER) + 1;VAR c := LAST(INTEGER) + 1 - 1;VAR d := (a > 0); I would like backends to optimize initialization a,not optimize initialization of b,and probably not optimize initialization of c,and hopefully optimize initialization of d, but that is moredifficult in the C backend. Fold constants when it is obviously safe.Do not fold constants when there is a chance of overflow -- evenat intermediate points of the expression. This is why I believe TIntN is useful. I bring this up because I'm about to add constant folding to M3C.m3.And to introduce use of TIntN.Which Tony has insisted is wrong, i.e. use in M3x86.m3. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 25 16:37:57 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 25 Oct 2012 10:37:57 -0400 Subject: [M3devel] what is wrong with TIntN? In-Reply-To: References: Message-ID: The problem is that you are trying to bring front-end mechanisms into the backend. If you want to perform optimizations in your backend they should be standalone and independent of the front end. For example, the llvm backend can perform a whole bunch of optimizations in its own IR. TInt is a service provided by m3middle to the front-end. Feel free to add whatever you like to your backend. I just don?t want to see unnecessary stuff introduced into m3middle. On Oct 25, 2012, at 4:12 AM, Jay K wrote: > When faced with > > > VAR a := FIRST(INTEGER) + 1; > VAR b := LAST(INTEGER) + 1; > VAR c := LAST(INTEGER) + 1 - 1; > VAR d := (a > 0); > > > I would like backends to optimize initialization a, > not optimize initialization of b, > and probably not optimize initialization of c, > and hopefully optimize initialization of d, but that is more > difficult in the C backend. > > > Fold constants when it is obviously safe. > Do not fold constants when there is a chance of overflow -- even > at intermediate points of the expression. > > > This is why I believe TIntN is useful. > > > I bring this up because I'm about to add constant folding to M3C.m3. > And to introduce use of TIntN. > Which Tony has insisted is wrong, i.e. use in M3x86.m3. > > > > Thanks, > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 25 16:43:27 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 25 Oct 2012 10:43:27 -0400 Subject: [M3devel] suspicious order of evaluation? In-Reply-To: References: Message-ID: I?m not sure that Modula-3 defines any order of initialization (unlike Java constructors and the JMM), so implementations are free to choose. So, programmers that care must be careful not to expose uninitialized objects by assigning them to globals only after the initializer has run. And of course in a multi-core setting you?d need to enforce fences accordingly. I agree that it might make sense to implement they way you suggest. Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 On Oct 25, 2012, at 1:42 AM, Jay K wrote: > m3tohtml/src/Main.m3: > > sources is global > > > PROCEDURE Add() = > BEGIN > sources := NEW (Source, next := sources, > from := Pathname.Join(pkgpath, file, NIL), > to := Pathname.Join(pkg, FixDerived (file), NIL), > kind := kind); > > > It APPEARS this compiles to like: > > > temp = RTHooks__AllocateTracedRef(...); > sources = temp > if temp == NULL > raise exception > sources->from = ... > sources->to = ... > > > To me this seems a bit suspicious. > > > First, the null check should be against the temp. > Sources should not be assigned and then checked. > > > Second, probably, the fields of sources should be filled in before > the global. > > > So, it should be more like: > > > temp = RTHooks__AllocateTracedRef(); > if temp == NULL > raise exception > temp->from = ... > temp->to = ... > sources = temp > ... > > > Just as efficient, but "safer". > > > Now, I realize, without a lock or barrier, the compiler is free to reorder like this. > Maybe ideally temp would be gone but the original order used? > > > C++ would implement it more like how I showed. > > > Thoughts? > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 21:44:44 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 19:44:44 +0000 Subject: [M3devel] what is wrong with TIntN? In-Reply-To: References: , Message-ID: So, if I just move the code to m3back, you are ok?Clearly m3middle is for front and backends though. i.e. at least Target, TInt, TFloat is needed by both/all.How does m3front get away w/o having similar functionality? What is the meaning of: CONST a = 16_7FFFFFFF + 1; CONST b = 16_7FFFFFFF + 1 - 1; for a 32bit target? or CONST c = 16_7FFFFFFFFFFFFFFFL + 1; CONST d = 16_7FFFFFFFFFFFFFFFL + 1 - 1; (I should try them and see and read code, granted.I should read more of m3front in general.) Restated, clearly larger-than-host-integer precisionarithemetic is needed by the frontend. But I don't seethat it is sufficient to have fixed-64-bit-precision arithmetic.It seems to me you would want to further "type" or restrictthe precision, depending on context, to one of INT8, UINT8, INT16,UINT16, INT32, UINT32, INT64, UINT64.(where "unsigned" is perhaps "half interval", 0 to the maximum signednumber of that precision...though this half interval stuff stillmakes me uneasy..but I grant that TInt does not implement full range64bit unsigned math, it is really a portable INT64). What I can't immediately guess with high confidence is if the "typing"is appropriate for intermediate results, or only final results.i.e. range checking all along, or only upon some conversion at the end. I guess, again, I should read m3front and the language spec more. Also, regarding m3middle..M3CG_Ops.i3 does lend itself to an intermediaterepresentation. In-memory that can be processed in multiple passes.I realize using it as such isn't very creative and ultimatelyone would want to augment it further. But it is useful. And so there is the idea that m3middle is code of use to multiple backends,even if not to the frontend at all. As well, the idea of actual "shared middle ends" or shared passes.i.e. in M3C I eliminate unused local variables.(not through sophisticated analysis like eliminating locals thatare only ever written to..though I could do that...but locals thatare neither written to nor read from. If M3CG were in-memory "in an array"and that was a common interface to multiple backends, this trasnformcould be shared among backends, or heck, always applied as a matter of course. It kind of seems to me that backends should have some characteristicsdescribed about them, communicated to the frontend, like requestingthe frontend interface with them in one of two or three ways, andrequesting certain passes be applied before them. Or, look how gcc is structured, as a series of passes.We could do that.passes: m3front m3cg function calls to in-memory format eliminate unused locals compute operations x types -- i.e. discover if extract is applied to int32 and/or int64, for backends that want to output helper functions; not all targets care compute or estimate maximum compile-time stack depth -- I've been tempted to add this, but so far haven't done it; it is easy to estimate; my motivation isn't good -- it is that I don't like the Modula-3 generic mechanism and how it steers me toward "RefSeq" and lots of NARROW() operations -- slower than needed. I'd rather use an open array if I can compute the right size early. move imports ahead of everything compute frames, maybe These can all be done reasonably well with the "obvious" internalrepresentation, plus just a little extra data. I guess what I'm saying is there could/should be more shared code forbackends. Given the two in existance today, that isn't really true, theyare too different.But it is perhaps true if we had some other mix of backend implementations. Granted, LLVM does "everything" itself anyway, all those passesare trivial for it, most likely. It doesn't need any help. - Jay From: hosking at cs.purdue.edu Date: Thu, 25 Oct 2012 10:37:57 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] what is wrong with TIntN? The problem is that you are trying to bring front-end mechanisms into the backend.If you want to perform optimizations in your backend they should be standalone and independent of the front end.For example, the llvm backend can perform a whole bunch of optimizations in its own IR.TInt is a service provided by m3middle to the front-end.Feel free to add whatever you like to your backend. I just don?t want to see unnecessary stuff introduced into m3middle. On Oct 25, 2012, at 4:12 AM, Jay K wrote:When faced with VAR a := FIRST(INTEGER) + 1;VAR b := LAST(INTEGER) + 1;VAR c := LAST(INTEGER) + 1 - 1;VAR d := (a > 0); I would like backends to optimize initialization a,not optimize initialization of b,and probably not optimize initialization of c,and hopefully optimize initialization of d, but that is moredifficult in the C backend. Fold constants when it is obviously safe.Do not fold constants when there is a chance of overflow -- evenat intermediate points of the expression. This is why I believe TIntN is useful. I bring this up because I'm about to add constant folding to M3C.m3.And to introduce use of TIntN.Which Tony has insisted is wrong, i.e. use in M3x86.m3. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 26 11:27:36 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 26 Oct 2012 09:27:36 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: <20121026092255.C9A94CC99F@birch.elegosoft.com> References: <20121026092255.C9A94CC99F@birch.elegosoft.com> Message-ID: I still really don't like how M3CG.TypeUID is defined. Asserting that a type fits in 32bitsshould not preclude putting it into a RECORD. Currently you cannot put M3CG.TypeUID into a record. The following does not work: RECORD whatever = typeid: M3CG.TypeUID; END; That seems really absurd to me. - Jay > Date: Fri, 26 Oct 2012 11:22:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/26 11:22:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > continue to hack around bogus packing of M3CG.TypeUID > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 26 11:31:30 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 26 Oct 2012 09:31:30 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, Message-ID: This is one reasonable way to fix it: Index: M3CG.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,vretrieving revision 1.10diff -u -r1.10 M3CG.i3--- M3CG.i3 6 Sep 2012 02:03:06 -0000 1.10+++ M3CG.i3 26 Oct 2012 09:30:31 -0000@@ -98,9 +98,9 @@ Always : Frequency = LAST (Frequency); TYPE- Int32 = [-16_7fffffff-1 .. 16_7fffffff];- TypeUID = BITS 32 FOR Int32;+ TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; (* a 32-bit unique id (fingerprint) for each type. *)+ assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; TYPE Label = INTEGER;Index: M3CG_MultiPass.i3 - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Fri, 26 Oct 2012 09:27:36 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record I still really don't like how M3CG.TypeUID is defined. Asserting that a type fits in 32bitsshould not preclude putting it into a RECORD. Currently you cannot put M3CG.TypeUID into a record. The following does not work: RECORD whatever = typeid: M3CG.TypeUID; END; That seems really absurd to me. - Jay > Date: Fri, 26 Oct 2012 11:22:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/26 11:22:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > continue to hack around bogus packing of M3CG.TypeUID > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Sun Oct 28 16:28:12 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 28 Oct 2012 10:28:12 -0500 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com> Message-ID: <508D4F0C.3080607@lcwb.coop> On 10/26/2012 04:27 AM, Jay K wrote: > I still really don't like how M3CG.TypeUID is defined. > > Asserting that a type fits in 32bits > should not preclude putting it into a RECORD. > > Currently you cannot put M3CG.TypeUID into a record. > > The following does not work: > > RECORD whatever = typeid: M3CG.TypeUID; END; I don't understand what the problem with this is. I expected it to work fine, which I confirmed by trying it, on both a 32-bit and a 64-bit compile. There is nothing here that would put the TypeUID at a place where it would have cross a word boundary or have problematic starting bit number. Did you perhaps mean in some other record type that has field(s) before the TypeUID that would leave it wrongly aligned? > > That seems really absurd to me. > > - Jay > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > To: m3commit at elegosoft.com > > From: jkrell at elego.de > > Subject: [M3commit] CVS Update: cm3 > > > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > Modified files: > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > Log message: > > continue to hack around bogus packing of M3CG.TypeUID > > From rodney_bates at lcwb.coop Sun Oct 28 17:00:26 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 28 Oct 2012 11:00:26 -0500 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, Message-ID: <508D569A.90609@lcwb.coop> I do like this idea. It took me a while to catch on to the rule that a field of packed type not only must occupy exactly the stated bit count, but also must not have any compiler-added padding ahead of it. While this is just what is needed for programmer-control of record layout, it seems that almost everyone keeps missing it and getting tripped up by it. After having trouble with record layouts that became illegal after changes in non-packed fields, I have made it a convention not to put BITS--FOR in a type declaration, but only use it as an anonymous type expression for a record field or array element. The named type in the type declaration will likely be used in several contexts, with differing packing contexts. The packing really needs to be independently thought about for each record field and array element. On 10/26/2012 04:31 AM, Jay K wrote: > This is one reasonable way to fix it: > > Index: M3CG.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,v > retrieving revision 1.10 > diff -u -r1.10 M3CG.i3 > --- M3CG.i36 Sep 2012 02:03:06 -00001.10 > +++ M3CG.i326 Oct 2012 09:30:31 -0000 > @@ -98,9 +98,9 @@ > Always : Frequency = LAST (Frequency); > TYPE > - Int32 = [-16_7fffffff-1 .. 16_7fffffff]; > - TypeUID = BITS 32 FOR Int32; > + TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; > (* a 32-bit unique id (fingerprint) for each type. *) > + assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; > TYPE > Label = INTEGER; > Index: M3CG_MultiPass.i3 > > > - Jay > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- > From: jay.krell at cornell.edu > To: m3devel at elegosoft.com > Date: Fri, 26 Oct 2012 09:27:36 +0000 > Subject: [M3devel] unable to put M3CG.TypeUID into a record > > I still really don't like how M3CG.TypeUID is defined. > > Asserting that a type fits in 32bits > should not preclude putting it into a RECORD. > > Currently you cannot put M3CG.TypeUID into a record. > > The following does not work: > > RECORD whatever = typeid: M3CG.TypeUID; END; > > That seems really absurd to me. > > - Jay > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > To: m3commit at elegosoft.com > > From: jkrell at elego.de > > Subject: [M3commit] CVS Update: cm3 > > > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > Modified files: > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > Log message: > > continue to hack around bogus packing of M3CG.TypeUID > > From jay.krell at cornell.edu Mon Oct 29 07:26:22 2012 From: jay.krell at cornell.edu (Jay K) Date: Mon, 29 Oct 2012 06:26:22 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: <508D569A.90609@lcwb.coop> References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, , , , <508D569A.90609@lcwb.coop> Message-ID: Thank you. > Date: Sun, 28 Oct 2012 11:00:26 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] unable to put M3CG.TypeUID into a record > > I do like this idea. It took me a while to catch on to the rule that > a field of packed type not only must occupy exactly the stated bit > count, but also must not have any compiler-added padding ahead of it. > While this is just what is needed for programmer-control of record > layout, it seems that almost everyone keeps missing it and getting > tripped up by it. > > After having trouble with record layouts that became illegal after > changes in non-packed fields, I have made it a convention not to > put BITS--FOR in a type declaration, but only use it as an anonymous > type expression for a record field or array element. The named type in > the type declaration will likely be used in several contexts, with differing > packing contexts. The packing really needs to be independently thought > about for each record field and array element. > > On 10/26/2012 04:31 AM, Jay K wrote: > > This is one reasonable way to fix it: > > > > Index: M3CG.i3 > > =================================================================== > > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,v > > retrieving revision 1.10 > > diff -u -r1.10 M3CG.i3 > > --- M3CG.i36 Sep 2012 02:03:06 -00001.10 > > +++ M3CG.i326 Oct 2012 09:30:31 -0000 > > @@ -98,9 +98,9 @@ > > Always : Frequency = LAST (Frequency); > > TYPE > > - Int32 = [-16_7fffffff-1 .. 16_7fffffff]; > > - TypeUID = BITS 32 FOR Int32; > > + TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; > > (* a 32-bit unique id (fingerprint) for each type. *) > > + assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; > > TYPE > > Label = INTEGER; > > Index: M3CG_MultiPass.i3 > > > > > > - Jay > > > > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > -- > > From: jay.krell at cornell.edu > > To: m3devel at elegosoft.com > > Date: Fri, 26 Oct 2012 09:27:36 +0000 > > Subject: [M3devel] unable to put M3CG.TypeUID into a record > > > > I still really don't like how M3CG.TypeUID is defined. > > > > Asserting that a type fits in 32bits > > should not preclude putting it into a RECORD. > > > > Currently you cannot put M3CG.TypeUID into a record. > > > > The following does not work: > > > > RECORD whatever = typeid: M3CG.TypeUID; END; > > > > That seems really absurd to me. > > > > - Jay > > > > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > > To: m3commit at elegosoft.com > > > From: jkrell at elego.de > > > Subject: [M3commit] CVS Update: cm3 > > > > > > CVSROOT: /usr/cvs > > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > > > Modified files: > > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > > > Log message: > > > continue to hack around bogus packing of M3CG.TypeUID > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hendrik at topoi.pooq.com Mon Oct 1 15:14:17 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Mon, 1 Oct 2012 09:14:17 -0400 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <5068B362.90304@lcwb.coop> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <5068B362.90304@lcwb.coop> Message-ID: <20121001131417.GA13426@topoi.pooq.com> On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > > > On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >Well that depends on how you maintain the vector, no? > > > >SortedTable uses "treaps" which are supposed to be good data structures. > >Too new to have made it into Knuth, last I checked. The amortized cost > >of your operations shouldn't be much worse than with your method, with > >the additional benefit that the sorted order is maintained dynamically. > > > >The separation of algorithms from containers sounds a bit like a bug. > >You have to be careful so you don't shoot yourself in the foot there! > >(Sorting a list using an algorithm that randomly accesses elements, > >say...) > > > >The Modula-3 approach is that you figure out what you want to do, pick > >the ADT you want that provides the minimal set of operations, import > >that interface, then instantiate a more carefully chosen implementation > >of the ADT. The language itself obviously can be coaxed into supporting the > >algorithm/data structure separation but no one uses it that way as > >far as I know. (Modula-3 generics are not that well explored, actually. > >I suspect there are many things you can do with them that no one has > >tried.) > > > > Mika > > > > > > I do think the ability to easily and inadvertently create mashups with > horrible asymptotic efficiency problems is a fundamental problem with > abstractions of any kind. Just plain old-fashioned procedural abstractions > give plenty of opportunity. Write one loop and call your code O(n). > Call something inside the loop. That guy did the same. Quickly, you > can O(n^3) etc., and nobody realizes it. > > Functional style abstractions are often just oh-so-easy to use, but > they can hide a lot. Even Modula-3 Text operations, immeasurably > more versatile and easy than when you have to worry about allocation, > have created some unpleasant surprises. Documenting the performance > characteristics in comments seems to be only solution. This has been > done in some places by both C++ and Modula-3 library writers. It might be interesting to speculate on language features that coul track performance problems the way type-checking checks types. Not tht I expect a practical solution today or tomorrow. -- hendrik From rodney_bates at lcwb.coop Mon Oct 1 18:18:50 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Mon, 01 Oct 2012 11:18:50 -0500 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <20121001131417.GA13426@topoi.pooq.com> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <5068B362.90304@lcwb.coop> <20121001131417.GA13426@topoi.pooq.com> Message-ID: <5069C26A.6030604@lcwb.coop> On 10/01/2012 08:14 AM, Hendrik Boom wrote: > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: >> >> >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: >>> Well that depends on how you maintain the vector, no? >>> >>> SortedTable uses "treaps" which are supposed to be good data structures. >>> Too new to have made it into Knuth, last I checked. The amortized cost >>> of your operations shouldn't be much worse than with your method, with >>> the additional benefit that the sorted order is maintained dynamically. >>> >>> The separation of algorithms from containers sounds a bit like a bug. >>> You have to be careful so you don't shoot yourself in the foot there! >>> (Sorting a list using an algorithm that randomly accesses elements, >>> say...) >>> >>> The Modula-3 approach is that you figure out what you want to do, pick >>> the ADT you want that provides the minimal set of operations, import >>> that interface, then instantiate a more carefully chosen implementation >>> of the ADT. The language itself obviously can be coaxed into supporting the >>> algorithm/data structure separation but no one uses it that way as >>> far as I know. (Modula-3 generics are not that well explored, actually. >>> I suspect there are many things you can do with them that no one has >>> tried.) >>> >>> Mika >>> >>> >> >> I do think the ability to easily and inadvertently create mashups with >> horrible asymptotic efficiency problems is a fundamental problem with >> abstractions of any kind. Just plain old-fashioned procedural abstractions >> give plenty of opportunity. Write one loop and call your code O(n). >> Call something inside the loop. That guy did the same. Quickly, you >> can O(n^3) etc., and nobody realizes it. >> >> Functional style abstractions are often just oh-so-easy to use, but >> they can hide a lot. Even Modula-3 Text operations, immeasurably >> more versatile and easy than when you have to worry about allocation, >> have created some unpleasant surprises. Documenting the performance >> characteristics in comments seems to be only solution. This has been >> done in some places by both C++ and Modula-3 library writers. > > It might be interesting to speculate on language features that coul > track performance problems the way type-checking checks types. > Yes, I agree. > Not tht I expect a practical solution today or tomorrow. > Yes, I agree here too. > -- hendrik > From jay.krell at cornell.edu Mon Oct 1 19:29:48 2012 From: jay.krell at cornell.edu (Jay K) Date: Mon, 1 Oct 2012 17:29:48 +0000 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <5069C26A.6030604@lcwb.coop> References: , <20120928075656.751E21A2082@async.async.caltech.edu>, <20120928080448.C80DD1A2082@async.async.caltech.edu>, , <20120929182948.6589C1A2082@async.async.caltech.edu>, <5068B362.90304@lcwb.coop> <20121001131417.GA13426@topoi.pooq.com>,<5069C26A.6030604@lcwb.coop> Message-ID: C++ already has this to some extent and has for a long time. You can't actually request to qsort a std::list. The type system doesn't allow it. They don't come up with random access that is ridiculously slow. They come up with none at all, and it is a compilation error. But if you are just writing loops over loops over loops over random access to large working sets and network I/O, talking to a server, that does more of the same..yeah.... What you want though is, I guess, "more composition", more flowing of data.A lot more.Tough problem...order of runtime is a factor of so many things, size of a file, or lines in the file, or tokens in a file, or number of heap allocations, or number of network I/O, or number of memory reads, or memory writes, etc.... - Jay > Date: Mon, 1 Oct 2012 11:18:50 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 10/01/2012 08:14 AM, Hendrik Boom wrote: > > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > >> > >> > >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >>> Well that depends on how you maintain the vector, no? > >>> > >>> SortedTable uses "treaps" which are supposed to be good data structures. > >>> Too new to have made it into Knuth, last I checked. The amortized cost > >>> of your operations shouldn't be much worse than with your method, with > >>> the additional benefit that the sorted order is maintained dynamically. > >>> > >>> The separation of algorithms from containers sounds a bit like a bug. > >>> You have to be careful so you don't shoot yourself in the foot there! > >>> (Sorting a list using an algorithm that randomly accesses elements, > >>> say...) > >>> > >>> The Modula-3 approach is that you figure out what you want to do, pick > >>> the ADT you want that provides the minimal set of operations, import > >>> that interface, then instantiate a more carefully chosen implementation > >>> of the ADT. The language itself obviously can be coaxed into supporting the > >>> algorithm/data structure separation but no one uses it that way as > >>> far as I know. (Modula-3 generics are not that well explored, actually. > >>> I suspect there are many things you can do with them that no one has > >>> tried.) > >>> > >>> Mika > >>> > >>> > >> > >> I do think the ability to easily and inadvertently create mashups with > >> horrible asymptotic efficiency problems is a fundamental problem with > >> abstractions of any kind. Just plain old-fashioned procedural abstractions > >> give plenty of opportunity. Write one loop and call your code O(n). > >> Call something inside the loop. That guy did the same. Quickly, you > >> can O(n^3) etc., and nobody realizes it. > >> > >> Functional style abstractions are often just oh-so-easy to use, but > >> they can hide a lot. Even Modula-3 Text operations, immeasurably > >> more versatile and easy than when you have to worry about allocation, > >> have created some unpleasant surprises. Documenting the performance > >> characteristics in comments seems to be only solution. This has been > >> done in some places by both C++ and Modula-3 library writers. > > > > It might be interesting to speculate on language features that coul > > track performance problems the way type-checking checks types. > > > > Yes, I agree. > > > Not tht I expect a practical solution today or tomorrow. > > > > Yes, I agree here too. > > > -- hendrik > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Mon Oct 1 21:07:26 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Mon, 1 Oct 2012 20:07:26 +0100 (BST) Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: Message-ID: <1349118446.66982.YahooMailClassic@web29702.mail.ird.yahoo.com> Hi all: None of this languages of today can predict anything about unbounded termination less they provide a clear solution for the problem of finding compile? time solutions for programs of bigger classes of complexity than what it takes to type check a given program if you consider both at each time is very hard problem probably to give a model itself. The only way seems to analyze execution traces and make prediction models. However I don't think this is more important than to make more efficient computer models. And current advances are not encouraging. Thanks in advance --- El lun, 1/10/12, Jay K escribi?: De: Jay K Asunto: Re: [M3devel] STL algorithms? sort/unique? Para: "Rodney M. Bates" , "m3devel" Fecha: lunes, 1 de octubre, 2012 12:29 C++ already has this to some extent and has for a long time.? You can't actually request to qsort a std::list. The type system doesn't allow it. They don't come up with random access that is ridiculously slow. They come up with none at all, and it is a compilation error. But if you are just writing loops over?loops over loops over random access to large working sets and network I/O, talking to a server, that does more of the same..yeah.... What you want though is, I guess, "more composition", more flowing of data.A lot more.Tough problem...order of runtime is a factor of so many things, size of a file, or lines in the file, or tokens in a file, or number of heap allocations, or number of network I/O, or number of memory reads, or memory writes, etc.... ?- Jay > Date: Mon, 1 Oct 2012 11:18:50 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 10/01/2012 08:14 AM, Hendrik Boom wrote: > > On Sun, Sep 30, 2012 at 04:02:26PM -0500, Rodney M. Bates wrote: > >> > >> > >> On 09/29/2012 01:29 PM, mika at async.caltech.edu wrote: > >>> Well that depends on how you maintain the vector, no? > >>> > >>> SortedTable uses "treaps" which are supposed to be good data structures. > >>> Too new to have made it into Knuth, last I checked. The amortized cost > >>> of your operations shouldn't be much worse than with your method, with > >>> the additional benefit that the sorted order is maintained dynamically. > >>> > >>> The separation of algorithms from containers sounds a bit like a bug. > >>> You have to be careful so you don't shoot yourself in the foot there! > >>> (Sorting a list using an algorithm that randomly accesses elements, > >>> say...) > >>> > >>> The Modula-3 approach is that you figure out what you want to do, pick > >>> the ADT you want that provides the minimal set of operations, import > >>> that interface, then instantiate a more carefully chosen implementation > >>> of the ADT. The language itself obviously can be coaxed into supporting the > >>> algorithm/data structure separation but no one uses it that way as > >>> far as I know. (Modula-3 generics are not that well explored, actually. > >>> I suspect there are many things you can do with them that no one has > >>> tried.) > >>> > >>> Mika > >>> > >>> > >> > >> I do think the ability to easily and inadvertently create mashups with > >> horrible asymptotic efficiency problems is a fundamental problem with > >> abstractions of any kind. Just plain old-fashioned procedural abstractions > >> give plenty of opportunity. Write one loop and call your code O(n). > >> Call something inside the loop. That guy did the same. Quickly, you > >> can O(n^3) etc., and nobody realizes it. > >> > >> Functional style abstractions are often just oh-so-easy to use, but > >> they can hide a lot. Even Modula-3 Text operations, immeasurably > >> more versatile and easy than when you have to worry about allocation, > >> have created some unpleasant surprises. Documenting the performance > >> characteristics in comments seems to be only solution. This has been > >> done in some places by both C++ and Modula-3 library writers. > > > > It might be interesting to speculate on language features that coul > > track performance problems the way type-checking checks types. > > > > Yes, I agree. > > > Not tht I expect a practical solution today or tomorrow. > > > > Yes, I agree here too. > > > -- hendrik > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Tue Oct 2 21:53:04 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Tue, 2 Oct 2012 21:53:04 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> Message-ID: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> I don't need stack allocated object. I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. As Anthony said. At this time and age? I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. I think we just need even better collector that we currently have. One passing Mika's thread test :). dd On Sep 30, 2012, at 8:06 AM, Jay K wrote: > I don't just want UNTRACED OBJECT. > I also want stack allocated objects. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Tue Oct 2 22:43:24 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Tue, 2 Oct 2012 21:43:24 +0100 (BST) Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> Message-ID: <1349210604.21624.YahooMailClassic@web29706.mail.ird.yahoo.com> Hi all: to make a proposal we could consider several options, for grow able stacks and fine grained heaps, my approach is pure Baby Modula-3, for the former and Obliq-like objects for the latter. But I'm no selling the idea to you guys! Just if someone could manage to make a proposal I support it. Thanks in advance --- El mar, 2/10/12, Dragi?a Duri? escribi?: De: Dragi?a Duri? Asunto: Re: [M3devel] STL algorithms? sort/unique? Para: "Jay K" CC: "m3devel" Fecha: martes, 2 de octubre, 2012 14:53 I don't need stack allocated object.? I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. As Anthony said. At this time and age? ? I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. I think we just need even better collector that we currently have. One passing Mika's thread test :). dd On Sep 30, 2012, at 8:06 AM, Jay K wrote: I don't just want UNTRACED OBJECT.I also want stack allocated objects. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 3 16:39:53 2012 From: jay.krell at cornell.edu (Jay) Date: Wed, 3 Oct 2012 07:39:53 -0700 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> Message-ID: <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> Growable stack is basically nonsense. True that stack allocation has large downside that picking a stack size is impossible. But it is super fast. Once we have NT/C backend that doesn't use a thread local, & we have cooperative suspend, I'd like to try writing an NT driver with Modula-3.. limited stack space there. :) (hm...what if we can't wrap the thread entry? Maybe ok.) Right, C++ is the answer, once I have my own compiler. :) - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 2, 2012, at 12:53 PM, Dragi?a Duri? wrote: > I don't need stack allocated object. > > I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? > > I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. > > As Anthony said. At this time and age? > > I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. > > I think we just need even better collector that we currently have. One passing Mika's thread test :). > > dd > > On Sep 30, 2012, at 8:06 AM, Jay K wrote: > >> I don't just want UNTRACED OBJECT. >> I also want stack allocated objects. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Wed Oct 3 20:24:06 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Wed, 3 Oct 2012 20:24:06 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <2957301D-001A-436B-9CD5-99407A60B68E@m3w.org> <333B39F1-10AE-47A2-B2C7-D7093497A27B@gmail.com> Message-ID: <300C8C70-BF12-4B78-B1B5-15A514360AD7@m3w.org> Current heap allocation (thanks to Anthony) is much much faster than it used to be, as each thread has it's own "current page to alloc from". Not like stack alloc, but also not limited as stack alloc. Your C++ compiler will cull those 60% of C++ standard? I can't wait to see it! :) -- Divided by a common language Dragi?a Duri? dragisha at m3w.org On Oct 3, 2012, at 4:39 PM, Jay wrote: > Growable stack is basically nonsense. > > > True that stack allocation has large downside that picking a stack size is impossible. But it is super fast. > > > Once we have NT/C backend that doesn't use a thread local, & we have cooperative suspend, I'd like to try writing an NT driver with Modula-3.. limited stack space there. :) > (hm...what if we can't wrap the thread entry? Maybe ok.) > > > Right, C++ is the answer, once I have my own compiler. :) > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 2, 2012, at 12:53 PM, Dragi?a Duri? wrote: > >> I don't need stack allocated object. >> >> I don't need to have lot's of big stacks in my multithreaded program. Can you implement growable stack? Is it worth your while? >> >> I need even less a hassle of hand-selecting stack size, for threads where I need stack objects and other threads. >> >> As Anthony said. At this time and age? >> >> I am sorry to even mention that, but maybe you just need C++? Or C++ without "a bit" of fat? Like..., 60% of language. >> >> I think we just need even better collector that we currently have. One passing Mika's thread test :). >> >> dd >> >> On Sep 30, 2012, at 8:06 AM, Jay K wrote: >> >>> I don't just want UNTRACED OBJECT. >>> I also want stack allocated objects. >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Thu Oct 4 03:40:57 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 03 Oct 2012 20:40:57 -0500 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> Message-ID: <506CE929.3000008@lcwb.coop> On 09/30/2012 01:06 AM, Jay K wrote: > I believe opinion remains strongly mixed on garbage collection / "managed" > etc. There is a lot of "managed" code. There is a lot of "native" code. > We all use a lot of both every day. > > > Modula-3 is actually pretty unusual in being native code and having garbage collection. > It is pretty unusual in having optional garbage collection. > It is pretty unusual in having optional safety. > C# allows some safety relaxation within "unsafe" blocks. > Like pointer manipulation. > > It pains me slightly in Modula-3 to write e.g. > > RTIO.PutText("foo " & Fmt.Int(123) & "bar"); > I've created at least two pieces of garbage. > In C++ any temporary strings would be cleaned up > right away at a deterministic time. > > > I'm really torn. > C# seems to be a highly "productive" "environment" (the language, > the libraries, possibly the IDEs). Perhaps far more than any C++ or Modula-3. > I know people who work on kernel drivers. They still use C. > > > I don't just want UNTRACED OBJECT. > I also want stack allocated objects. > C++ has them. > This idea has never made any sense to me at all: 1) No OOP advocate would let you get away with calling it OOP without having dispatching methods. (This despite the fact that the great majority of OO examples don't actually use them, and thus are really ADT programming.) 2) You can't actually use dispatching unless your variable can dynamically be assigned values of different subclasses at different times. Degenerately using a linguistic mechanism that dispatches, but the algorithm ensures it is always to the same place, does not count. 3) If a stack object is to be dynamically assignable to values of different subclasses, the compiler is going to have to allocate space for the largest of these. That can be declared anywhere, in a place unknown to exist, at the point where the variable is declared. I think I can see a way this could be implemented with whole-program techniques, but it still won't work with dynamically linked libraries, which rules out a major part of what the staunch OOP advocates advocate. And it creates a new kind of space waste. 4) Alternatively, a compiler could actually hiddenly allocate the objects in the heap and put a pointer on the stack. But now any real or imagined performance gains from on-stack objects are gone. Moreover, there will be reference assignment vs. value assignment semantic distinctions that violate what local variables are expected to do, with sometimes big bugs as consequence. 5) A compiler could fix this by simulating the correct value assignment semantics, making heap copies whenever necessary. This makes it effectively a functional language, which certainly would require a GC and greatly increases the volume of allocated and collected heap objects. 6) Or, a programmer could explicitly take pointers to stack objects of various subclasses and assign them to the same variable at different times. I guess this is what is done in C++. This amounts to enticing the naive to try dancing on a tight-wire over Dangling Pointer Abyss. Which would justify Stroustrup's comment. 7) Finally, a programmer diligent and skillful enough to pull this off would be extremely hard pressed to find an application where the actual stack lifetimes of the different subclass objects had any significant correlation to the real lifetimes of their usefulness to the program. > class C > { > void F1(); > virtual void F2(); > }; > > void F3() > { > C c; > } > > > I think the nearest equivalent in Modula-3 is a stack allocated RECORD > with function pointers. > > > - Jay > > > From jay.krell at cornell.edu Thu Oct 4 03:59:29 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 01:59:29 +0000 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: <506CE929.3000008@lcwb.coop> References: , ,,<20120928075656.751E21A2082@async.async.caltech.edu>, , ,,<20120928080448.C80DD1A2082@async.async.caltech.edu>, ,,, , ,,<20120929182948.6589C1A2082@async.async.caltech.edu>, ,,, , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , , , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu>, , <506CE929.3000008@lcwb.coop> Message-ID: std::vector vi; vi.push_back(1); vi.push_back(2); vi.push_back(3); vs. VAR s := NEW(IntSeq.T).init(); s.addhi(1); s.addhi(2); s.addhi(3); vector is small, contains 3 pointers. And one level of indirection for accessing the data. printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. IntSeq.T is one pointer, and probably contains also approximately 3 pointers. The Modula-3 has an extra level of indirection. Not every function should be "virtual". "object.method" is useful syntax for statically typed "object". s.get(0) probably involves like 3 pointer derefences. Somewhat this is a "standard library" matter. But I think the language is probably slightly lacking too. I understand that if the "virtual-ness" is part of the interface..you could have: si: IntSeq.T; IntSeq.push_back(si, 1); (* static non-virtual dispatch *) IntSeq.push_back(si, 2); IntSeq.push_back(si, 3); si.data[0]; (* public data *) This is good and bad. It is both better and worse to have the "virtual-ness" affect the public interface. Exposing data like that, well, that's kind of a quality of implementation matter. I could have it be. IntSeq.get(si, 0); and leave it up to the compiler to inline.. I have to go... - Jay > Date: Wed, 3 Oct 2012 20:40:57 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] STL algorithms? sort/unique? > > > > On 09/30/2012 01:06 AM, Jay K wrote: > > I believe opinion remains strongly mixed on garbage collection / "managed" > > etc. There is a lot of "managed" code. There is a lot of "native" code. > > We all use a lot of both every day. > > > > > > Modula-3 is actually pretty unusual in being native code and having garbage collection. > > It is pretty unusual in having optional garbage collection. > > It is pretty unusual in having optional safety. > > C# allows some safety relaxation within "unsafe" blocks. > > Like pointer manipulation. > > > > It pains me slightly in Modula-3 to write e.g. > > > > RTIO.PutText("foo " & Fmt.Int(123) & "bar"); > > I've created at least two pieces of garbage. > > In C++ any temporary strings would be cleaned up > > right away at a deterministic time. > > > > > > I'm really torn. > > C# seems to be a highly "productive" "environment" (the language, > > the libraries, possibly the IDEs). Perhaps far more than any C++ or Modula-3. > > I know people who work on kernel drivers. They still use C. > > > > > > I don't just want UNTRACED OBJECT. > > I also want stack allocated objects. > > C++ has them. > > > > This idea has never made any sense to me at all: > > 1) No OOP advocate would let you get away with calling it OOP without > having dispatching methods. (This despite the fact that the great > majority of OO examples don't actually use them, and thus are really > ADT programming.) > > 2) You can't actually use dispatching unless your variable can dynamically > be assigned values of different subclasses at different times. Degenerately > using a linguistic mechanism that dispatches, but the algorithm ensures it > is always to the same place, does not count. > > 3) If a stack object is to be dynamically assignable to values of different > subclasses, the compiler is going to have to allocate space for the > largest of these. That can be declared anywhere, in a place unknown > to exist, at the point where the variable is declared. I think I can > see a way this could be implemented with whole-program techniques, but > it still won't work with dynamically linked libraries, which rules out > a major part of what the staunch OOP advocates advocate. And it creates > a new kind of space waste. > > 4) Alternatively, a compiler could actually hiddenly allocate the > objects in the heap and put a pointer on the stack. But now any real > or imagined performance gains from on-stack objects are gone. Moreover, > there will be reference assignment vs. value assignment semantic > distinctions that violate what local variables are expected to do, > with sometimes big bugs as consequence. > > 5) A compiler could fix this by simulating the correct value assignment > semantics, making heap copies whenever necessary. This makes it > effectively a functional language, which certainly would require a GC > and greatly increases the volume of allocated and collected heap > objects. > > 6) Or, a programmer could explicitly take pointers to stack objects of > various subclasses and assign them to the same variable at different > times. I guess this is what is done in C++. This amounts to enticing > the naive to try dancing on a tight-wire over Dangling Pointer Abyss. > Which would justify Stroustrup's comment. > > 7) Finally, a programmer diligent and skillful enough to pull this off > would be extremely hard pressed to find an application where the > actual stack lifetimes of the different subclass objects had any > significant correlation to the real lifetimes of their usefulness > to the program. > > > class C > > { > > void F1(); > > virtual void F2(); > > }; > > > > void F3() > > { > > C c; > > } > > > > > > I think the nearest equivalent in Modula-3 is a stack allocated RECORD > > with function pointers. > > > > > > - Jay > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 07:45:10 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 05:45:10 +0000 Subject: [M3devel] another reminder -- jmpbuf size independence? Message-ID: Along with cooperative suspend, it'd be great if jmpbuf size was not known to cm3.We know roughly how to fix this -- use alloca(Csetjmp_jmpbuf_size).At function entry. Not in any loop.Or possibly in loop, but with a null check.VAR jmpbuf: ADDRESS := NIL;LOOP IF jmpbuf = NIL THEN jmpbuf := alloca(Csetjmp_jmpbuf_size); END; :) Granted, I want all layout optionally out of the frontend, and this is only part of the problem. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 08:13:28 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Message-ID: Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 08:25:53 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 06:25:53 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: References: Message-ID: declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 and here is some relevant M3x86 code: IF u.in_proc THEN v := get_temp_var (u, type, s, a, n); ELSE v := create_temp_var (u, type, s, a, n); END; PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name := M3ID.NoID): x86Var = BEGIN (* round size and alignment up to 4 *) IF s < 4 THEN s := 4; END; IF a < 4 THEN a := 4; END; PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name): x86Var = VAR v := NewVar(u, type, 0, s, a, n); BEGIN v.loc := VLoc.temp; v.parent := u.current_proc; u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, Alignmask[a]); INC(u.current_proc.framesize, s); v.offset := -u.current_proc.framesize; RETURN v; END create_temp_var; which isn't clear by inspection...it actually looks likezero size is allowed through commonly...in_proc is rare,so create is common...assuming the frame is already aligned,the size remains unchanged... Relevant aside: I have been ignoring alignment.I'm inclined to go with something like: <* ASSERT (size MOD alignment) = 0 *> If that ever fails, then I will change it to: FUNCTION RoundUp(a, b: INTEGER): INTEGER =BEGIN WITH c = a MOD b DO IF c # 0 THEN RETURN a + b - c; END; END; RETURN a;END; size := RoundUp(size, alignment); and then, more to the point, I'll go with: IF size = 0 THEN size = 1;END; I haven't dug into what the gcc backend would do here, too muchto dig through. :) Thoughts? I guess I should try both m3x86 and m3cc, and print the addressof these things???? - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 09:00:40 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 07:00:40 +0000 Subject: [M3devel] FW: entire system compiled with C backend In-Reply-To: <20121004065855.7FB082474003@birch.elegosoft.com> References: <20121004065855.7FB082474003@birch.elegosoft.com> Message-ID: entire system compiled with C backend: > Date: Thu, 4 Oct 2012 08:58:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/04 08:58:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > assert that alignments are all ok > If that fails, we'll round up in the backend. > assert that size >= 0 (and not merely > 0) > size := MAX(size, 1) (convert 0 to 1 -- 0 occurs) > perhaps it should be size := MAX(size, aligment) > > Should alignment be rounded up to 4 or 8 for variables like M3x86 does? > > I have now compiled the entire system using the C backend > targeting AMD64_DARWIN. This is a very big milestone. > > This last change has only been tested on a small part of the tree. > (i.e. that which has zero-sized variables, and everything "after" it) > > I can bring up and interact with various gui apps -- tetris, BadBricks (somewhat), > Juno, mentor (at least somehow). > > Juno doesn't come up centered, and I recall it always did before. > That might be something to look into. > > As well, the compiler has long been compiling itself. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 15:08:12 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 06:08:12 -0700 Subject: [M3devel] FW: entire system compiled with C backend In-Reply-To: References: <20121004065855.7FB082474003@birch.elegosoft.com> Message-ID: <20121004130812.B4AA11A207D@async.async.caltech.edu> This is very cool!!! Jay K writes: >--_333b0016-47c7-43b4-813e-76fd02b5ee50_ >Content-Type: text/plain; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > >entire system compiled with C backend: > > >> Date: Thu=2C 4 Oct 2012 08:58:55 +0000 >> To: m3commit at elegosoft.com >> From: jkrell at elego.de >> Subject: [M3commit] CVS Update: cm3 >>=20 >> CVSROOT: /usr/cvs >> Changes by: jkrell at birch. 12/10/04 08:58:55 >>=20 >> Modified files: >> cm3/m3-sys/m3back/src/: M3C.m3=20 >>=20 >> Log message: >> assert that alignments are all ok >> If that fails=2C we'll round up in the backend. >> assert that size >=3D 0 (and not merely > 0) >> size :=3D MAX(size=2C 1) (convert 0 to 1 -- 0 occurs) >> perhaps it should be size :=3D MAX(size=2C aligment) >> =09 >> Should alignment be rounded up to 4 or 8 for variables like M3x86 does? >> =09 >> I have now compiled the entire system using the C backend >> targeting AMD64_DARWIN. This is a very big milestone. >> =09 >> This last change has only been tested on a small part of the tree. >> (i.e. that which has zero-sized variables=2C and everything "after" it) >> =09 >> I can bring up and interact with various gui apps -- tetris=2C BadBricks= > (somewhat)=2C >> Juno=2C mentor (at least somehow). >> =09 >> Juno doesn't come up centered=2C and I recall it always did before. >> That might be something to look into. >> =09 >> As well=2C the compiler has long been compiling itself. >>=20 > = > >--_333b0016-47c7-43b4-813e-76fd02b5ee50_ >Content-Type: text/html; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > >
rif">entire system compiled with C backend:
i=2C sans-serif">


ans-serif=3B font-size: 12pt=3B ">
>= >=3B Date: Thu=2C 4 Oct 2012 08:58:55 +0000
>=3B To: m3commit at elegosoft= >.com
>=3B From: jkrell at elego.de
>=3B Subject: [M3commit] CVS Upda= >te: cm3
>=3B
>=3B CVSROOT: /usr/cvs
>=3B Changes by: jkrell= >@birch. 12/10/04 08:58:55
>=3B
>=3B Modified files:
>=3B c= >m3/m3-sys/m3back/src/: M3C.m3
>=3B
>=3B Log message:
>=3B = > assert that alignments are all ok
>=3B If that fails=2C we'll round = >up in the backend.
>=3B assert that size >=3B=3D 0 (and not merely = >>=3B 0)
>=3B size :=3D MAX(size=2C 1) (convert 0 to 1 -- 0 occurs)<= >br>>=3B perhaps it should be size :=3D MAX(size=2C aligment)
>=3B = >
>=3B Should alignment be rounded up to 4 or 8 for variables like M3x= >86 does?
>=3B
>=3B I have now compiled the entire system using= > the C backend
>=3B targeting AMD64_DARWIN. This is a very big milest= >one.
>=3B
>=3B This last change has only been tested on a smal= >l part of the tree.
>=3B (i.e. that which has zero-sized variables=2C= > and everything "after" it)
>=3B
>=3B I can bring up and inter= >act with various gui apps -- tetris=2C BadBricks (somewhat)=2C
>=3B J= >uno=2C mentor (at least somehow).
>=3B
>=3B Juno doesn't come = >up centered=2C and I recall it always did before.
>=3B That might be = >something to look into.
>=3B
>=3B As well=2C the compiler has = >long been compiling itself.
>=3B
ody> >= > >--_333b0016-47c7-43b4-813e-76fd02b5ee50_-- From jay.krell at cornell.edu Thu Oct 4 18:16:00 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 16:16:00 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: Yes..the assertions all passes..but granted, maybe we don't have full coverage. I can look at the frontend, or just make it so in the backend. On further thought..by quick read..this M3x86.m3 code is questionable.While in_proc is usually false for declare_local, I think it really goes both ways.So it looks like size is sometimes rounded up to 4, sometimes left as zero. But what does it mean?Does a zero sized array get any storage?In C and C++, two objects can't be at the same address, so, for example:struct foo { } bar; is not legal C. It is legal C++, however: struct foo { } a,b;assert(&a != &b); will pass. andvoid* a = malloc(0);void* b = malloc(0);assert(a != b) will also pass in C and C++. That is, size 0 struct is invalid in C. In C++ it is rounded up to at least 1.malloc(0) is rounded up to at least 1.No two "objects" can have the same address. What is the meaning Modula-3?Rounding up to 1 or alignment seems easy/decent.Certainly these zero sized things are rare in our tree. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] zero sized structs? Date: Thu, 4 Oct 2012 09:21:28 -0400 To: jay.krell at cornell.edu Try to respect alignment. Sent from my iPad On Oct 4, 2012, at 2:25 AM, Jay K wrote: declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 and here is some relevant M3x86 code: IF u.in_proc THEN v := get_temp_var (u, type, s, a, n); ELSE v := create_temp_var (u, type, s, a, n); END; PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name := M3ID.NoID): x86Var = BEGIN (* round size and alignment up to 4 *) IF s < 4 THEN s := 4; END; IF a < 4 THEN a := 4; END; PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; n: Name): x86Var = VAR v := NewVar(u, type, 0, s, a, n); BEGIN v.loc := VLoc.temp; v.parent := u.current_proc; u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, Alignmask[a]); INC(u.current_proc.framesize, s); v.offset := -u.current_proc.framesize; RETURN v; END create_temp_var; which isn't clear by inspection...it actually looks likezero size is allowed through commonly...in_proc is rare,so create is common...assuming the frame is already aligned,the size remains unchanged... Relevant aside: I have been ignoring alignment.I'm inclined to go with something like: <* ASSERT (size MOD alignment) = 0 *> If that ever fails, then I will change it to: FUNCTION RoundUp(a, b: INTEGER): INTEGER =BEGIN WITH c = a MOD b DO IF c # 0 THEN RETURN a + b - c; END; END; RETURN a;END; size := RoundUp(size, alignment); and then, more to the point, I'll go with: IF size = 0 THEN size = 1;END; I haven't dug into what the gcc backend would do here, too muchto dig through. :) Thoughts? I guess I should try both m3x86 and m3cc, and print the addressof these things???? - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 4 Oct 2012 06:13:28 +0000 Subject: [M3devel] zero sized structs? Building obliqrt I get: ****** runtime error:*** <*ASSERT*> failed.*** file "../src/M3C.m3", line 1768*** PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var =BEGIN IF type = Type.Struct THEN <* ASSERT byte_size > 0 *> self.sizes[self.count] := byte_size; INC(self.count); END; RETURN NIL;END GetStructSizes_Declare; due to presumably: PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ... PROCEDURE HandleWork (self: ObliqWork) = VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; ..PROCEDURE EvalThread ( self : PackageThread;...noArgs : ARRAY [0 .. -1] OF ObValue.Val; What is the meaning of this? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 18:17:37 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 16:17:37 +0000 Subject: [M3devel] another reminder -- jmpbuf size independence? In-Reply-To: <1C9D3D9A-57A8-45EE-8185-0ABD3341A6C7@gmail.com> References: , <1C9D3D9A-57A8-45EE-8185-0ABD3341A6C7@gmail.com> Message-ID: Agreed. TRY FOR i := 1 TO 100 DO TRY FOR j := 1 TO 100 DO END; FINALLYENDFINALLY should have two variables, allocate 2 * sizeof(jmpbuf), call alloca twice (most likely -- obviously it could be optimized), not 200 times. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] another reminder -- jmpbuf size independence? Date: Thu, 4 Oct 2012 09:25:14 -0400 To: jay.krell at cornell.edu Don't you need separate jmpbuf per exception scope? Sent from my iPad On Oct 4, 2012, at 1:45 AM, Jay K wrote: Along with cooperative suspend, it'd be great if jmpbuf size was not known to cm3.We know roughly how to fix this -- use alloca(Csetjmp_jmpbuf_size).At function entry. Not in any loop.Or possibly in loop, but with a null check.VAR jmpbuf: ADDRESS := NIL;LOOP IF jmpbuf = NIL THEN jmpbuf := alloca(Csetjmp_jmpbuf_size); END; :) Granted, I want all layout optionally out of the frontend, and this is only part of the problem. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 20:13:21 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 11:13:21 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> References: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> Message-ID: <2193F183-F903-44AA-BD13-D1354739FF7D@gmail.com> > No storage. That has been thought through and all ramifications are ok? And gcc backend does what is expected? -- multiple variables have same address. I'll answer some of the questions later -- try out gcc backend and NT/x86. NT/x86 looks "inconsistent" between variable at top of procedure vs sub blocks. The C/C++ design feels more conservative and safe and also reasonable and cheap enough. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 10:22 AM, Antony Hosking wrote: > No storage. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 20:15:47 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 11:15:47 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> References: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> Message-ID: <7C06CF62-3526-4E9C-BD84-2130CAD5CF0C@gmail.com> > But you can have zero-length arrays in C. Not in ANSI C 1989. Maybe C9X variable length ("open") arrays can be zero? But I bet maybe alloca(0) rounds up, like malloca(0). C really avoids zero sized things.. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 10:22 AM, Antony Hosking wrote: > But you can have zero-length arrays in C. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 20:23:39 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 11:23:39 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: <20121004182339.3ECEC1A207D@async.async.caltech.edu> It seems that CM3 puts them at the "same address".... UNSAFE MODULE Main; IMPORT IO, Fmt; TYPE T = ARRAY [1..-1] OF INTEGER; VAR t := NEW(REF T); u := NEW(REF T); v : T; w : T; BEGIN IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n"); IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n"); END Main. (114)async:~/ttt/src>../AMD64_LINUX/prog 2269030 2269040 602218 602218 I don't see a problem with it. Whoever thinks he needs to check whether ADR(v) equals ADR(w) should be using a different programming language... Mika From hosking at cs.purdue.edu Thu Oct 4 19:22:04 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 4 Oct 2012 13:22:04 -0400 Subject: [M3devel] zero sized structs? In-Reply-To: References: , Message-ID: <0B3C8F72-B8E9-43E4-A48D-284F86DC03D7@cs.purdue.edu> On Oct 4, 2012, at 12:16 PM, Jay K wrote: > Yes..the assertions all passes..but granted, maybe we don't have full coverage. I can look at the frontend, or just make it so in the backend. > > > On further thought..by quick read..this M3x86.m3 code is questionable. > While in_proc is usually false for declare_local, I think it really goes both ways. > So it looks like size is sometimes rounded up to 4, sometimes left as zero. > > > But what does it mean? > Does a zero sized array get any storage? No storage. > In C and C++, two objects can't be at the same address, so, for example: > struct foo { } bar; is not legal C. It is legal C++, however: But you can have zero-length arrays in C. > > > struct foo { } a,b; > assert(&a != &b); will pass. > > > and > void* a = malloc(0); > void* b = malloc(0); > assert(a != b) will also pass in C and C++. > > > That is, size 0 struct is invalid in C. In C++ it is rounded up to at least 1. > malloc(0) is rounded up to at least 1. > No two "objects" can have the same address. > > > What is the meaning Modula-3? > Rounding up to 1 or alignment seems easy/decent. > Certainly these zero sized things are rare in our tree. > > > - Jay > > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] zero sized structs? > Date: Thu, 4 Oct 2012 09:21:28 -0400 > To: jay.krell at cornell.edu > > Try to respect alignment. > > Sent from my iPad > > On Oct 4, 2012, at 2:25 AM, Jay K wrote: > > > declare_local noArgs 0 8 Struct -1522787086 T F 50 v.318 > > > and here is some relevant M3x86 code: > > IF u.in_proc THEN > v := get_temp_var (u, type, s, a, n); > ELSE > v := create_temp_var (u, type, s, a, n); > END; > > > PROCEDURE get_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; > n: Name := M3ID.NoID): x86Var = > BEGIN > > (* round size and alignment up to 4 *) > > IF s < 4 THEN > s := 4; > END; > > IF a < 4 THEN > a := 4; > END; > > > PROCEDURE create_temp_var (u: U; type: Type; s: ByteSize; a: Alignment; > n: Name): x86Var = > VAR v := NewVar(u, type, 0, s, a, n); > BEGIN > v.loc := VLoc.temp; > v.parent := u.current_proc; > > u.current_proc.framesize := Word.And(u.current_proc.framesize + a - 1, > Alignmask[a]); > > INC(u.current_proc.framesize, s); > > v.offset := -u.current_proc.framesize; > > RETURN v; > END create_temp_var; > > > which isn't clear by inspection...it actually looks like > zero size is allowed through commonly...in_proc is rare, > so create is common...assuming the frame is already aligned, > the size remains unchanged... > > > Relevant aside: I have been ignoring alignment. > I'm inclined to go with something like: > > <* ASSERT (size MOD alignment) = 0 *> > > > If that ever fails, then I will change it to: > > > FUNCTION RoundUp(a, b: INTEGER): INTEGER = > BEGIN > WITH c = a MOD b DO > IF c # 0 THEN > RETURN a + b - c; > END; > END; > RETURN a; > END; > > size := RoundUp(size, alignment); > > > and then, more to the point, I'll go with: > > IF size = 0 THEN > size = 1; > END; > > > I haven't dug into what the gcc backend would do here, too much > to dig through. :) > > > Thoughts? > > > I guess I should try both m3x86 and m3cc, and print the address > of these things???? > > > - Jay > > > > From: jay.krell at cornell.edu > To: m3devel at elegosoft.com > Date: Thu, 4 Oct 2012 06:13:28 +0000 > Subject: [M3devel] zero sized structs? > > Building obliqrt I get: > > > *** > *** runtime error: > *** <*ASSERT*> failed. > *** file "../src/M3C.m3", line 1768 > *** > > > > PROCEDURE GetStructSizes_Declare(self: GetStructSizes_t; type: Type; byte_size: ByteSize): M3CG.Var = > BEGIN > IF type = Type.Struct THEN > <* ASSERT byte_size > 0 *> > self.sizes[self.count] := byte_size; > INC(self.count); > END; > RETURN NIL; > END GetStructSizes_Declare; > > > due to presumably: > > > PROCEDURE ApplyThreadClosure (self: ObliqThreadClosure): REFANY = > VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; > > > ... > > PROCEDURE HandleWork (self: ObliqWork) = > VAR noArgs: ARRAY [0 .. -1] OF ObValue.Val; > > .. > PROCEDURE EvalThread ( self : PackageThread; > ... > noArgs : ARRAY [0 .. -1] OF ObValue.Val; > > > What is the meaning of this? > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From dragisha at m3w.org Thu Oct 4 20:30:40 2012 From: dragisha at m3w.org (=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?=) Date: Thu, 4 Oct 2012 20:30:40 +0200 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: , , , <20120928075656.751E21A2082@async.async.caltech.edu>, , , , <20120928080448.C80DD1A2082@async.async.caltech.edu>, , , , , , , <20120929182948.6589C1A2082@async.async.caltech.edu>, , , , , , <20120929201033.52DE71A2082@async.async.caltech.edu>, , , , <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu>, , <506CE929.3000008@lcwb.coop> Message-ID: On Oct 4, 2012, at 3:59 AM, Jay K wrote: > vector is small, contains 3 pointers. > And one level of indirection for accessing the data. > printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. Probably because preprocessor is in this equation? > > > > IntSeq.T is one pointer, and probably contains also approximately 3 pointers. > The Modula-3 has an extra level of indirection. And what is vector if not pointer to some collection of pointers? IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :). In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need. > > > Not every function should be "virtual". > "object.method" is useful syntax for statically typed "object". > s.get(0) probably involves like 3 pointer derefences. As opossed to C++'s two dereferences? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 4 21:33:33 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 12:33:33 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: <20121004182339.3ECEC1A207D@async.async.caltech.edu> References: <20121004182339.3ECEC1A207D@async.async.caltech.edu> Message-ID: Same address & same size implies same object & same type. But the types can vary. Please check also variables in sub-blocks. I think NT/x86 backend doesn't always put them at same place. Then again, that is probably ok too -- in general not all zero sized objects can be located -- they could be locals in different functions or globals in different modules. You say use a different language, but 1) they are exceedingly rare so ok to waste space 2) as small & simple Modula-3 is, it is still really isn't small or simple, there are surprising number & level of detail to understand and deal with. Adding a notion of a zero sized thing isn't necessarily so obviously simple and free of complexity down the line. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 11:23 AM, wrote: > It seems that CM3 puts them at the "same address".... > > UNSAFE MODULE Main; > IMPORT IO, Fmt; > > TYPE > T = ARRAY [1..-1] OF INTEGER; > > VAR t := NEW(REF T); u := NEW(REF T); > v : T; > w : T; > BEGIN > IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base := 16) & "\n"); > IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base := 16) & "\n"); > END Main. > > (114)async:~/ttt/src>../AMD64_LINUX/prog > 2269030 > 2269040 > 602218 > 602218 > > I don't see a problem with it. Whoever thinks he needs to check whether > ADR(v) equals ADR(w) should be using a different programming language... > > Mika > From jay.krell at cornell.edu Thu Oct 4 21:44:19 2012 From: jay.krell at cornell.edu (Jay) Date: Thu, 4 Oct 2012 12:44:19 -0700 Subject: [M3devel] STL algorithms? sort/unique? In-Reply-To: References: <20120928075656.751E21A2082@async.async.caltech.edu> <20120928080448.C80DD1A2082@async.async.caltech.edu> <20120929182948.6589C1A2082@async.async.caltech.edu> <20120929201033.52DE71A2082@async.async.caltech.edu> <51148932-5F6A-4D98-B076-3C4A30E9DEDC@cs.purdue.edu> <506CE929.3000008@lcwb.coop> Message-ID: Preprocessor does historically help -- makes inlining easier, including making sizes visible. > And what is vector if not pointer to some collection of pointers? No. Pointers to ints. The three pointers are start, just past end, just past end of allocation. Maybe easier to see as a pointer and 2 integers -- size and allocated size. But they are size_t and not 32bit int. I'll present object code later... - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 4, 2012, at 11:30 AM, Dragi?a Duri? wrote: > > > On Oct 4, 2012, at 3:59 AM, Jay K wrote: > >> vector is small, contains 3 pointers. >> And one level of indirection for accessing the data. >> printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler. > > Probably because preprocessor is in this equation? > >> >> >> >> IntSeq.T is one pointer, and probably contains also approximately 3 pointers. >> The Modula-3 has an extra level of indirection. > > And what is vector if not pointer to some collection of pointers? > > IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :). > > In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need. > >> >> >> Not every function should be "virtual". >> "object.method" is useful syntax for statically typed "object". >> s.get(0) probably involves like 3 pointer derefences. > > As opossed to C++'s two dereferences? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 22:37:33 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 13:37:33 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: <20121004182339.3ECEC1A207D@async.async.caltech.edu> Message-ID: <20121004203733.0E95A1A207D@async.async.caltech.edu> Well as a user I'm quite happy to see the two objects have different addresses, if it makes your life easier as a compiler writer. However it's certainly not documented---so I'd better not depend on it! You're not supposed to be taking the ADR of stuff on the stack. It's UNSAFE, caveat emptor, etc... I'm just saying that if you are doing that you're not writing programs that Modula-3 was intended for. If you want to pass something by reference, use VAR! I find that when you have trouble with zero-sized anything, you've usually used the wrong abstraction.... In any case the fact that the language allows certain things to be zero sized is very helpful when you are writing programs that have to generate Modula-3 code. You don't have to keep track and insert dummies in various places. But sure I can't think of any reason the compiler couldn't implement zero-sized things as being one-sized or four-sized, or whatever it/you want/s. It looks like they take 16 bytes when you NEW them... (of course the report also says that "The reference returned by NEW is distinct from all existing references") Mika Jay writes: >Same address & same size implies same object & same type. But the types can v= >ary. Please check also variables in sub-blocks. I think NT/x86 backend doesn= >'t always put them at same place. Then again, that is probably ok too -- in g= >eneral not all zero sized objects can be located -- they could be locals in d= >ifferent functions or globals in different modules. > > >You say use a different language, but 1) they are exceedingly rare so ok to w= >aste space 2) as small & simple Modula-3 is, it is still really isn't small o= >r simple, there are surprising number & level of detail to understand and de= >al with. Adding a notion of a zero sized thing isn't necessarily so obviousl= >y simple and free of complexity down the line.=20 > > > > - Jay (briefly/pocket-sized-computer-aka-phone) > >On Oct 4, 2012, at 11:23 AM, wrote: > >> It seems that CM3 puts them at the "same address".... >>=20 >> UNSAFE MODULE Main; >> IMPORT IO, Fmt; >>=20 >> TYPE >> T =3D ARRAY [1..-1] OF INTEGER; >>=20 >> VAR t :=3D NEW(REF T); u :=3D NEW(REF T); >> v : T; >> w : T; >> BEGIN >> IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base :=3D 16) & "\n"); >> IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base :=3D 16) & "\n"); >> END Main. >>=20 >> (114)async:~/ttt/src>../AMD64_LINUX/prog >> 2269030 >> 2269040 >> 602218 >> 602218 >>=20 >> I don't see a problem with it. Whoever thinks he needs to check whether >> ADR(v) equals ADR(w) should be using a different programming language... >>=20 >> Mika >>=20 From jay.krell at cornell.edu Thu Oct 4 23:27:55 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 4 Oct 2012 21:27:55 +0000 Subject: [M3devel] zero sized structs? In-Reply-To: <20121004203733.0E95A1A207D@async.async.caltech.edu> References: , , , , <20121004182339.3ECEC1A207D@async.async.caltech.edu>, , <20121004203733.0E95A1A207D@async.async.caltech.edu> Message-ID: > (of course the report also says that "The reference returned by NEW is distinct from all existing references") Aha. Good.And doesn't it seem kind of nice and correct if that same sort of thing applied to locals and globals?More consistent that way? Really I wouldn't mind if ARRAY [0..0] or ARRAY [0..-1] was just plain illegal.The following are not legal standard C/89/90:int a[-1];int a[0]; Though int a[0] may be a popular extension -- in both gcc and Visual C++ -- and many other compilers are forced to follow their lead. I know we don't in general "do what C does" but C is not really a set of all bad decisions that should all be avoided, and in fact, Modula-3 is almost trivially isomorphic to C. The main differences are 1) it disallows some operations 2) it adds optional garbage collection via inserted barrier checks 3) generics and vtables which are a fairly simple layering 4) strict interface separation which is just enforcing what people can do do in C, but it is important that it is strict, since it allows for faster compilation.) In the face of my own ignorance, I think considering what C and C++ do is not a bad option. They avoid the existance of zero sized things. On the other hand, C++ compilers then do work hard to "reoptimize" because of this. By "reoptimize" I mean, removal of zero sized things can actually be a significant deoptimization, that you then have to be pretty clever to optimize..when..if only zero size was ok in the first place, it would have been easy to keep optimal.In particular: struct A { }; struct B : A { }; struct C : B { }; struct D : C { }; struct E : D { }; what is the sizeof(E)? If zero size was ok, then the sizeof(A) and B and C and D and E would all be zero and the compiler's job would be easy. In reality keeping the sizeof(E) "small" isn't trivial. Perhaps perhaps multiple inheritance is needed to make the point. Let's see..hm..I need to research this..the "empty base optimization"..the problem doesn't seem that bad..without multiple inherirtance, the size was only 1. struct A1 { }; struct A2 { }; struct B1 : A1, A2 { }; struct B2 : A1, A2 { }; struct C1 : B1, B2 { }; struct C2 : B1, B2 { }; struct D : C1, C2 { }; struct E : D { }; extern int a = sizeof(E); Only with a "mess" could I blow it up e.g. 7: F:\>type 1.cpp && cl -c -FAsc 1.cpp && more 1.cod struct A1 { }; struct A2 { }; struct B1 : A1, A2 { }; struct B2 : A1, A2 { }; struct C1 : B1, B2 { }; struct C2 : B1, B2 { }; struct D : C1, C2 { }; struct E : D { }; extern int a = sizeof(E); Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.278 for x64 Copyright (C) Microsoft Corporation. All rights reserved.1.cpp ; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.278 include listing.incINCLUDELIB LIBCMT INCLUDELIB OLDNAMESPUBLIC ?a@@3HA ; a _DATA SEGMENT ?a@@3HA DD 07H ; a _DATA ENDS END - Jay > To: jay.krell at cornell.edu > Date: Thu, 4 Oct 2012 13:37:33 -0700 > From: mika at async.caltech.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] zero sized structs? > > > Well as a user I'm quite happy to see the two objects have different > addresses, if it makes your life easier as a compiler writer. However > it's certainly not documented---so I'd better not depend on it! > You're not supposed to be taking the ADR of stuff on the stack. > It's UNSAFE, caveat emptor, etc... I'm just saying that if you are > doing that you're not writing programs that Modula-3 was intended for. > If you want to pass something by reference, use VAR! > > I find that when you have trouble with zero-sized anything, you've usually > used the wrong abstraction.... In any case the fact that the language > allows certain things to be zero sized is very helpful when you are writing > programs that have to generate Modula-3 code. You don't have to keep > track and insert dummies in various places. But sure I can't think of any > reason the compiler couldn't implement zero-sized things as being one-sized > or four-sized, or whatever it/you want/s. It looks like they take 16 bytes > when you NEW them... (of course the report also says that "The reference > returned by NEW is distinct from all existing references") > > Mika > > > Jay writes: > >Same address & same size implies same object & same type. But the types can v= > >ary. Please check also variables in sub-blocks. I think NT/x86 backend doesn= > >'t always put them at same place. Then again, that is probably ok too -- in g= > >eneral not all zero sized objects can be located -- they could be locals in d= > >ifferent functions or globals in different modules. > > > > > >You say use a different language, but 1) they are exceedingly rare so ok to w= > >aste space 2) as small & simple Modula-3 is, it is still really isn't small o= > >r simple, there are surprising number & level of detail to understand and de= > >al with. Adding a notion of a zero sized thing isn't necessarily so obviousl= > >y simple and free of complexity down the line.=20 > > > > > > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > > >On Oct 4, 2012, at 11:23 AM, wrote: > > > >> It seems that CM3 puts them at the "same address".... > >>=20 > >> UNSAFE MODULE Main; > >> IMPORT IO, Fmt; > >>=20 > >> TYPE > >> T =3D ARRAY [1..-1] OF INTEGER; > >>=20 > >> VAR t :=3D NEW(REF T); u :=3D NEW(REF T); > >> v : T; > >> w : T; > >> BEGIN > >> IO.Put(Fmt.Int(LOOPHOLE(t,INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(u,INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(ADR(v),INTEGER), base :=3D 16) & "\n"); > >> IO.Put(Fmt.Int(LOOPHOLE(ADR(w),INTEGER), base :=3D 16) & "\n"); > >> END Main. > >>=20 > >> (114)async:~/ttt/src>../AMD64_LINUX/prog > >> 2269030 > >> 2269040 > >> 602218 > >> 602218 > >>=20 > >> I don't see a problem with it. Whoever thinks he needs to check whether > >> ADR(v) equals ADR(w) should be using a different programming language... > >>=20 > >> Mika > >>=20 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Thu Oct 4 23:51:02 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Thu, 04 Oct 2012 14:51:02 -0700 Subject: [M3devel] zero sized structs? In-Reply-To: References: , , , , <20121004182339.3ECEC1A207D@async.async.caltech.edu>, , <20121004203733.0E95A1A207D@async.async.caltech.edu> Message-ID: <20121004215102.450531A207D@async.async.caltech.edu> > > (of course the report also says that "The reference returned by NEW is d= >istinct from all existing references") Aha. Good.And doesn't it seem kind o= >f nice and correct if that same sort of thing applied to locals and globals= >?More consistent that way? Well either way it's just not visible from the safe subset of the language... >Really I wouldn't mind if ARRAY [0..0] or ARRAY = >[0..-1] was just plain illegal.The following are not legal standard C/89/90= Sure but C doesn't have a type [0..-1] either... and I don't think you can get away without those sorts of types (called "empty types" in the report). HOWEVER, declaring a variable of an empty type or NEWing an empty type is a static error... There's a little section in the report about "making non-empty types out of empty types". The example is x : [0..-1]; (* illegal *) y := NEW(REF [0..-1]); (* illegal *) s : SET OF [0..-1]; (* legal *) s is legal because the type isn't empty; it contains the empty set. Likewise I suppose ARRAY OF [0..-1] also is legal because it contains the empty array. But sure there's a stronger argument for ruling the latter illegal than the former. The problem is, though, that that leaves you no way of statically declaring an array of size zero, which is certainly a useful concept. E.g., x : REF ARRAY OF INTEGER := NEW(REF ARRAY OF INTEGER, 0); ... WITH new = NEW(REF ARRAY OF INTEGER, NUMBER(x^) + 1) DO SUBARRAY(new^, 0, NUMBER(x^)) := x^; new[LAST(new^)] := newElement; END ... So I don't use [0..-1] here but you could certainly see xx : ARRAY [0..-1] OF INTEGER as being compatible with the initial value of x. Mika From hosking at cs.purdue.edu Fri Oct 5 15:31:02 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 5 Oct 2012 09:31:02 -0400 Subject: [M3devel] Output from "cron" command In-Reply-To: References: <201210041115.q94BFkUE006378@niagara.cs.purdue.edu>, , , Message-ID: <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> Jay, is there any chance we can put your M3C backend stuff in a separate library. I don?t understand why we are adding clutter to m3middle. Similarly, your hacks to m3cgcat to run your C backend should be duplicated in the C backend space rather than in m3cgcat. I?d prefer to keep m3middle as pristine as it was previously if only to avoid confusion for others. From jay.krell at cornell.edu Fri Oct 5 15:42:39 2012 From: jay.krell at cornell.edu (Jay) Date: Fri, 5 Oct 2012 06:42:39 -0700 Subject: [M3devel] Output from "cron" command In-Reply-To: <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> References: <201210041115.q94BFkUE006378@niagara.cs.purdue.edu> <00B923F6-F5D2-42FB-9621-E936BB0C7123@cs.purdue.edu> Message-ID: On the 2nd point I'll soon have m3c interface to quake. For performance w/o adding another "mode". But having a separate executable going via .mc files is great for development and testing. On the 1st point..I added files, didn't change, as I recall. No difference if they are in m3back or m3middle. I found that decision unclear -- m3back vs m3middle. What I added is likely useful to other backend writers. Very generic. I really think this is about the right design. But code can be split up and moved fairly arbitrarily, cluttering the tree with more directories & libraries... The m3cgcat change is elegant and not a hack imo & very few people know about or understand this stuff, there shouldn't be much chance for confusion, but whatever.... - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 5, 2012, at 6:31 AM, Antony Hosking wrote: > Jay, is there any chance we can put your M3C backend stuff in a separate library. > I don?t understand why we are adding clutter to m3middle. > > Similarly, your hacks to m3cgcat to run your C backend should be duplicated in the C backend space rather than in m3cgcat. > > I?d prefer to keep m3middle as pristine as it was previously if only to avoid confusion for others. > From jay.krell at cornell.edu Wed Oct 10 06:08:52 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 04:08:52 +0000 Subject: [M3devel] completing M3CG_Binary.Op? Message-ID: M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 06:36:36 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 00:36:36 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote: > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 06:52:18 2012 From: jay.krell at cornell.edu (Jay) Date: Tue, 9 Oct 2012 21:52:18 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > >> M3CG_Binary.Op currently represents >> what we write to ".mc" files for the gcc >> backend to read in. This is very very close >> to what you'd want to fully represent M3CG.T. >> >> >> It missing an operation that takes a function pointer -- can't >> be stored in a file. It is missing operations that get converted >> to different operations by M3CG_Wr. There is no real >> value in the transform but it doesn't hurt either. >> >> >> I'd like to add the missing operations. >> It seems like a very sensible reasonable change to me. >> >> >> >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >> retrieving revision 1.19 >> diff -u -r1.19 M3CG_BinRd.m3 >> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >> @@ -37,7 +37,7 @@ >> END; >> >> CONST >> - CmdMap = ARRAY Bop OF Cmd { >> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >> Cmd {Bop.begin_unit, begin_unit}, >> Cmd {Bop.end_unit, end_unit}, >> Cmd {Bop.import_unit, import_unit}, >> Index: M3CG_Binary.i3 >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >> retrieving revision 1.6 >> diff -u -r1.6 M3CG_Binary.i3 >> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >> @@ -38,7 +38,17 @@ >> call_indirect, pop_param, pop_struct, pop_static_link, >> load_procedure, load_static_link, comment, >> store_ordered, load_ordered, exchange, compare_exchange, fence, >> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >> + >> + (* These only occur in memory, not in files. >> + Conversely, what they are converted to only occur in files, >> + not in memory. *) >> + set_error_handler, (* disk: contains a pointer, silently skipped *) >> + compare (* converted to eq/ne/etc. *) >> + cvt_int, (* converted to trunc/ceiling/etc. *) >> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >> + if_compare, (* converted to if_eq/if_ne/etc. *) >> + set_compare, (* converted to set_eq/set_ne/etc. *) >> }; >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 07:35:58 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 01:35:58 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: Message-ID: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Why? On Oct 10, 2012, at 12:52 AM, Jay wrote: > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > >> Forgive me, but I don?t understand the purpose of this change. >> >> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >> >>> M3CG_Binary.Op currently represents >>> what we write to ".mc" files for the gcc >>> backend to read in. This is very very close >>> to what you'd want to fully represent M3CG.T. >>> >>> >>> It missing an operation that takes a function pointer -- can't >>> be stored in a file. It is missing operations that get converted >>> to different operations by M3CG_Wr. There is no real >>> value in the transform but it doesn't hurt either. >>> >>> >>> I'd like to add the missing operations. >>> It seems like a very sensible reasonable change to me. >>> >>> >>> >>> =================================================================== >>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>> retrieving revision 1.19 >>> diff -u -r1.19 M3CG_BinRd.m3 >>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>> @@ -37,7 +37,7 @@ >>> END; >>> >>> CONST >>> - CmdMap = ARRAY Bop OF Cmd { >>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>> Cmd {Bop.begin_unit, begin_unit}, >>> Cmd {Bop.end_unit, end_unit}, >>> Cmd {Bop.import_unit, import_unit}, >>> Index: M3CG_Binary.i3 >>> =================================================================== >>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>> retrieving revision 1.6 >>> diff -u -r1.6 M3CG_Binary.i3 >>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>> @@ -38,7 +38,17 @@ >>> call_indirect, pop_param, pop_struct, pop_static_link, >>> load_procedure, load_static_link, comment, >>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>> + >>> + (* These only occur in memory, not in files. >>> + Conversely, what they are converted to only occur in files, >>> + not in memory. *) >>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>> + compare (* converted to eq/ne/etc. *) >>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>> }; >>> >>> >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 07:59:34 2012 From: jay.krell at cornell.edu (Jay) Date: Tue, 9 Oct 2012 22:59:34 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Message-ID: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > >> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >> >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >> >>> Forgive me, but I don?t understand the purpose of this change. >>> >>> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >>> >>>> M3CG_Binary.Op currently represents >>>> what we write to ".mc" files for the gcc >>>> backend to read in. This is very very close >>>> to what you'd want to fully represent M3CG.T. >>>> >>>> >>>> It missing an operation that takes a function pointer -- can't >>>> be stored in a file. It is missing operations that get converted >>>> to different operations by M3CG_Wr. There is no real >>>> value in the transform but it doesn't hurt either. >>>> >>>> >>>> I'd like to add the missing operations. >>>> It seems like a very sensible reasonable change to me. >>>> >>>> >>>> >>>> =================================================================== >>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>>> retrieving revision 1.19 >>>> diff -u -r1.19 M3CG_BinRd.m3 >>>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>>> @@ -37,7 +37,7 @@ >>>> END; >>>> >>>> CONST >>>> - CmdMap = ARRAY Bop OF Cmd { >>>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>>> Cmd {Bop.begin_unit, begin_unit}, >>>> Cmd {Bop.end_unit, end_unit}, >>>> Cmd {Bop.import_unit, import_unit}, >>>> Index: M3CG_Binary.i3 >>>> =================================================================== >>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>>> retrieving revision 1.6 >>>> diff -u -r1.6 M3CG_Binary.i3 >>>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>>> @@ -38,7 +38,17 @@ >>>> call_indirect, pop_param, pop_struct, pop_static_link, >>>> load_procedure, load_static_link, comment, >>>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>>> + >>>> + (* These only occur in memory, not in files. >>>> + Conversely, what they are converted to only occur in files, >>>> + not in memory. *) >>>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>>> + compare (* converted to eq/ne/etc. *) >>>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>>> }; >>>> >>>> >>>> >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 08:33:13 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 02:33:13 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> Message-ID: Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > >> Why? >> >> On Oct 10, 2012, at 12:52 AM, Jay wrote: >> >>> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >>> >>> >>> - Jay (briefly/pocket-sized-computer-aka-phone) >>> >>> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >>> >>>> Forgive me, but I don?t understand the purpose of this change. >>>> >>>> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >>>> >>>>> M3CG_Binary.Op currently represents >>>>> what we write to ".mc" files for the gcc >>>>> backend to read in. This is very very close >>>>> to what you'd want to fully represent M3CG.T. >>>>> >>>>> >>>>> It missing an operation that takes a function pointer -- can't >>>>> be stored in a file. It is missing operations that get converted >>>>> to different operations by M3CG_Wr. There is no real >>>>> value in the transform but it doesn't hurt either. >>>>> >>>>> >>>>> I'd like to add the missing operations. >>>>> It seems like a very sensible reasonable change to me. >>>>> >>>>> >>>>> >>>>> =================================================================== >>>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >>>>> retrieving revision 1.19 >>>>> diff -u -r1.19 M3CG_BinRd.m3 >>>>> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >>>>> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >>>>> @@ -37,7 +37,7 @@ >>>>> END; >>>>> >>>>> CONST >>>>> - CmdMap = ARRAY Bop OF Cmd { >>>>> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >>>>> Cmd {Bop.begin_unit, begin_unit}, >>>>> Cmd {Bop.end_unit, end_unit}, >>>>> Cmd {Bop.import_unit, import_unit}, >>>>> Index: M3CG_Binary.i3 >>>>> =================================================================== >>>>> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >>>>> retrieving revision 1.6 >>>>> diff -u -r1.6 M3CG_Binary.i3 >>>>> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >>>>> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >>>>> @@ -38,7 +38,17 @@ >>>>> call_indirect, pop_param, pop_struct, pop_static_link, >>>>> load_procedure, load_static_link, comment, >>>>> store_ordered, load_ordered, exchange, compare_exchange, fence, >>>>> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >>>>> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >>>>> + >>>>> + (* These only occur in memory, not in files. >>>>> + Conversely, what they are converted to only occur in files, >>>>> + not in memory. *) >>>>> + set_error_handler, (* disk: contains a pointer, silently skipped *) >>>>> + compare (* converted to eq/ne/etc. *) >>>>> + cvt_int, (* converted to trunc/ceiling/etc. *) >>>>> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >>>>> + if_compare, (* converted to if_eq/if_ne/etc. *) >>>>> + set_compare, (* converted to set_eq/set_ne/etc. *) >>>>> }; >>>>> >>>>> >>>>> >>>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Wed Oct 10 17:53:50 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 15:53:50 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , Message-ID: M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Wed Oct 10 18:13:51 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 12:13:51 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , Message-ID: <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote: > M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. > > - Jay > > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 02:33:13 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] completing M3CG_Binary.Op? > > Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? > > On Oct 10, 2012, at 1:59 AM, Jay wrote: > > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 01:33:35 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 10 Oct 2012 23:33:35 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> Message-ID: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 11 02:18:03 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Wed, 10 Oct 2012 20:18:03 -0400 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> Message-ID: <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: > > Look at M3CG_MultiPass. > > For each function, it creates a record to hold the parameters. > So they can be later be looped over in a different order and/or multiple times. > The record includes an enum. > I need an enum that looks almost exactly like M3CG_Binary.Op, > except that I need those few missing elements. > > M3CG_MultiPass already has most of this, except > 1) I somehow forgot got to handle a bunch of them > 2) I need the below diff for it to be complete, or some other nearly identical enum instead. > > - Jay > > Subject: Re: [M3devel] completing M3CG_Binary.Op? > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 12:13:51 -0400 > CC: m3devel at elegosoft.com > To: jay.krell at cornell.edu > > I still don?t understand why the change is needed. > > On Oct 10, 2012, at 11:53 AM, Jay K wrote: > > M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. > > - Jay > > From: hosking at cs.purdue.edu > Date: Wed, 10 Oct 2012 02:33:13 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com > Subject: Re: [M3devel] completing M3CG_Binary.Op? > > Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? > > On Oct 10, 2012, at 1:59 AM, Jay wrote: > > I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: > > Why? > > On Oct 10, 2012, at 12:52 AM, Jay wrote: > > I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. > > > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: > > Forgive me, but I don?t understand the purpose of this change. > > On Oct 10, 2012, at 12:08 AM, Jay K wrote: > > M3CG_Binary.Op currently represents > what we write to ".mc" files for the gcc > backend to read in. This is very very close > to what you'd want to fully represent M3CG.T. > > > It missing an operation that takes a function pointer -- can't > be stored in a file. It is missing operations that get converted > to different operations by M3CG_Wr. There is no real > value in the transform but it doesn't hurt either. > > > I'd like to add the missing operations. > It seems like a very sensible reasonable change to me. > > > > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v > retrieving revision 1.19 > diff -u -r1.19 M3CG_BinRd.m3 > --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 > +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 > @@ -37,7 +37,7 @@ > END; > > CONST > - CmdMap = ARRAY Bop OF Cmd { > + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { > Cmd {Bop.begin_unit, begin_unit}, > Cmd {Bop.end_unit, end_unit}, > Cmd {Bop.import_unit, import_unit}, > Index: M3CG_Binary.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v > retrieving revision 1.6 > diff -u -r1.6 M3CG_Binary.i3 > --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 > +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 > @@ -38,7 +38,17 @@ > call_indirect, pop_param, pop_struct, pop_static_link, > load_procedure, load_static_link, comment, > store_ordered, load_ordered, exchange, compare_exchange, fence, > - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor > + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, > + > + (* These only occur in memory, not in files. > + Conversely, what they are converted to only occur in files, > + not in memory. *) > + set_error_handler, (* disk: contains a pointer, silently skipped *) > + compare (* converted to eq/ne/etc. *) > + cvt_int, (* converted to trunc/ceiling/etc. *) > + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) > + if_compare, (* converted to if_eq/if_ne/etc. *) > + set_compare, (* converted to set_eq/set_ne/etc. *) > }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 05:08:41 2012 From: jay.krell at cornell.edu (Jay) Date: Wed, 10 Oct 2012 20:08:41 -0700 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> References: <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu> <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu> <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu> Message-ID: <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: > Why not simply capture the state of the existing ops? e.g,, cvt_int. > > On Oct 10, 2012, at 7:33 PM, Jay K wrote: > >> >> Look at M3CG_MultiPass. >> >> For each function, it creates a record to hold the parameters. >> So they can be later be looped over in a different order and/or multiple times. >> The record includes an enum. >> I need an enum that looks almost exactly like M3CG_Binary.Op, >> except that I need those few missing elements. >> >> M3CG_MultiPass already has most of this, except >> 1) I somehow forgot got to handle a bunch of them >> 2) I need the below diff for it to be complete, or some other nearly identical enum instead. >> >> - Jay >> >> Subject: Re: [M3devel] completing M3CG_Binary.Op? >> From: hosking at cs.purdue.edu >> Date: Wed, 10 Oct 2012 12:13:51 -0400 >> CC: m3devel at elegosoft.com >> To: jay.krell at cornell.edu >> >> I still don?t understand why the change is needed. >> >> On Oct 10, 2012, at 11:53 AM, Jay K wrote: >> >> M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. >> >> - Jay >> >> From: hosking at cs.purdue.edu >> Date: Wed, 10 Oct 2012 02:33:13 -0400 >> To: jay.krell at cornell.edu >> CC: m3devel at elegosoft.com >> Subject: Re: [M3devel] completing M3CG_Binary.Op? >> >> Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? >> >> On Oct 10, 2012, at 1:59 AM, Jay wrote: >> >> I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: >> >> Why? >> >> On Oct 10, 2012, at 12:52 AM, Jay wrote: >> >> I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. >> >> >> - Jay (briefly/pocket-sized-computer-aka-phone) >> >> On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: >> >> Forgive me, but I don?t understand the purpose of this change. >> >> On Oct 10, 2012, at 12:08 AM, Jay K wrote: >> >> M3CG_Binary.Op currently represents >> what we write to ".mc" files for the gcc >> backend to read in. This is very very close >> to what you'd want to fully represent M3CG.T. >> >> >> It missing an operation that takes a function pointer -- can't >> be stored in a file. It is missing operations that get converted >> to different operations by M3CG_Wr. There is no real >> value in the transform but it doesn't hurt either. >> >> >> I'd like to add the missing operations. >> It seems like a very sensible reasonable change to me. >> >> >> >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v >> retrieving revision 1.19 >> diff -u -r1.19 M3CG_BinRd.m3 >> --- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19 >> +++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000 >> @@ -37,7 +37,7 @@ >> END; >> >> CONST >> - CmdMap = ARRAY Bop OF Cmd { >> + CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { >> Cmd {Bop.begin_unit, begin_unit}, >> Cmd {Bop.end_unit, end_unit}, >> Cmd {Bop.import_unit, import_unit}, >> Index: M3CG_Binary.i3 >> =================================================================== >> RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,v >> retrieving revision 1.6 >> diff -u -r1.6 M3CG_Binary.i3 >> --- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6 >> +++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000 >> @@ -38,7 +38,17 @@ >> call_indirect, pop_param, pop_struct, pop_static_link, >> load_procedure, load_static_link, comment, >> store_ordered, load_ordered, exchange, compare_exchange, fence, >> - fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor >> + fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor, >> + >> + (* These only occur in memory, not in files. >> + Conversely, what they are converted to only occur in files, >> + not in memory. *) >> + set_error_handler, (* disk: contains a pointer, silently skipped *) >> + compare (* converted to eq/ne/etc. *) >> + cvt_int, (* converted to trunc/ceiling/etc. *) >> + fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *) >> + if_compare, (* converted to if_eq/if_ne/etc. *) >> + set_compare, (* converted to set_eq/set_ne/etc. *) >> }; > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 07:46:07 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 11 Oct 2012 05:46:07 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> References: , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu>, , <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu>, <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com> Message-ID: Tony, I think you might not understand, or have it backwards. In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory. For example, M3CG_Wr.m3: PROCEDURE set_compare (u: U; s: ByteSize; op: CompareOp; t: IType) = (* s1.t := (s1.B op s0.B) ; pop *) CONST OpName = ARRAY CompareOp OF TEXT { "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" }; BEGIN Cmd (u, OpName [op]); Int (u, s); TName (u, t); NL (u); END set_compare; but in my M3CG_MultiPass.m3 (not necessarily the commited version!) PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare; so -- ok with my change? Thank you, - Jay From: jay.krell at cornell.edu Date: Wed, 10 Oct 2012 20:08:41 -0700 To: hosking at cs.purdue.edu CC: m3devel at elegosoft.com; jay.krell at cornell.edu Subject: Re: [M3devel] completing M3CG_Binary.Op? I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 11 08:23:34 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 11 Oct 2012 06:23:34 +0000 Subject: [M3devel] completing M3CG_Binary.Op? In-Reply-To: References: , , , , , , <6B6EE7CB-2B89-4260-A57B-C391C6F79AC3@cs.purdue.edu>, , , , , , , , <303F93E5-368F-4740-837F-B8F24E3FBA54@cs.purdue.edu>, , , , <117BF340-F539-4E47-920A-74F371605FD4@cs.purdue.edu>, , <0076FED5-FA0D-48D8-B5A7-B2D1EC4BCDAD@gmail.com>, Message-ID: Here is a more heavily commented diff.Again, notice that the existing code does a small translation in writing files. My desire is to represent M3CG call sequence more directly. Granted, it might be reasonable, really, to change one or the other -- either make M3CG.T more closely resemble M3CG_Wr, or the other way around -- remove the transform and adjust one backend(s) or other.I'd also be putting in more newlines, either to separate every enum element here, or to separate all the newly-commented ones, and put the comment on each one. Index: m3-sys/m3cggen/src/Main.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3cggen/src/Main.m3,vretrieving revision 1.6diff -u -r1.6 Main.m3--- m3-sys/m3cggen/src/Main.m3 1 Nov 2010 09:59:44 -0000 1.6+++ m3-sys/m3cggen/src/Main.m3 11 Oct 2012 06:18:42 -0000@@ -9,7 +9,7 @@ Desc = RECORD name: TEXT; op: Op; END; CONST- Map = ARRAY Op OF Desc {+ Map = ARRAY [Op.begin_unit..Op.fetch_and_xor] OF Desc { Desc { "begin_unit", Op.begin_unit }, Desc { "end_unit", Op.end_unit }, Desc { "import_unit", Op.import_unit }, Index: m3-sys/m3middle/src/M3CG_BinRd.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- m3-sys/m3middle/src/M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ m3-sys/m3middle/src/M3CG_BinRd.m3 11 Oct 2012 06:18:42 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: m3-sys/m3middle/src/M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- m3-sys/m3middle/src/M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ m3-sys/m3middle/src/M3CG_Binary.i3 11 Oct 2012 06:18:42 -0000@@ -21,14 +21,19 @@ end_init, init_int, init_proc, init_label, init_var, init_offset, init_chars, init_float, import_procedure, declare_procedure, begin_procedure, end_procedure, begin_block, end_block,- note_procedure_origin, set_label, jump, if_true, if_false, if_eq,- if_ne, if_gt, if_ge, if_lt, if_le, case_jump, exit_proc, load,+ note_procedure_origin, set_label, jump, if_true, if_false,+ if_eq, if_ne, if_gt, if_ge, if_lt, if_le, (* file only; in-memory uses if_compare *)+ case_jump, exit_proc, load, load_address, load_indirect, store, store_indirect,- load_nil, load_integer, load_float, eq, ne,- gt, ge, lt, le, add, subtract, multiply, divide, negate, abs, max,- min, round, trunc, floor, ceiling, cvt_float, div, mod, set_union,+ load_nil, load_integer, load_float,+ eq, ne, gt, ge, lt, le, (* file only; in-memory uses compare *)+ add, subtract, multiply, divide, negate, abs, max,+ min,+ round, trunc, floor, ceiling, (* file only; in-memory uses cvt_int *)+ cvt_float, div, mod, set_union, set_difference, set_intersection, set_sym_difference, set_member,- set_eq, set_ne, set_lt, set_le, set_gt, set_ge, set_range,+ set_eq, set_ne, set_lt, set_le, set_gt, set_ge, (* file only; in-memory uses set_compare *)+ set_range, set_singleton, not, and, or, xor, shift, shift_left, shift_right, rotate, rotate_left, rotate_right, widen, chop, extract, extract_n, extract_mn, insert, insert_n, insert_mn, swap, pop, copy_n, copy,@@ -38,7 +43,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, (* file only; in-memory uses fetch_and_op *)+ fetch_and_sub, (* file only; in-memory uses fetch_and_op *)+ fetch_and_or, (* file only; in-memory uses fetch_and_op *)+ fetch_and_and, (* file only; in-memory uses fetch_and_op *)+ fetch_and_xor, (* file only; in-memory uses fetch_and_op *)+ set_error_handler, (* in-memory only; contains a pointer, so silently skipped in files *)+ compare, (* in-memory only; file converts to eq/ne/etc. *)+ cvt_int, (* in-memory only; file converts to trunc/ceiling/etc. *)+ fetch_and_op, (* in-memory only; file converts to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* in-memory only; file converts to if_eq/if_ne/etc. *)+ set_compare (* in-memory only; file converts to set_eq/set_ne/etc. *) }; (* Integers are encoded as sequences of unsigned bytes, [0..255]. - Jay From: jay.krell at cornell.edu To: hosking at cs.purdue.edu Date: Thu, 11 Oct 2012 05:46:07 +0000 CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Tony, I think you might not understand, or have it backwards. In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory. For example, M3CG_Wr.m3: PROCEDURE set_compare (u: U; s: ByteSize; op: CompareOp; t: IType) = (* s1.t := (s1.B op s0.B) ; pop *) CONST OpName = ARRAY CompareOp OF TEXT { "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" }; BEGIN Cmd (u, OpName [op]); Int (u, s); TName (u, t); NL (u); END set_compare; but in my M3CG_MultiPass.m3 (not necessarily the commited version!) PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare; so -- ok with my change? Thank you, - Jay From: jay.krell at cornell.edu Date: Wed, 10 Oct 2012 20:08:41 -0700 To: hosking at cs.purdue.edu CC: m3devel at elegosoft.com; jay.krell at cornell.edu Subject: Re: [M3devel] completing M3CG_Binary.Op? I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 10, 2012, at 5:18 PM, Antony Hosking wrote: Why not simply capture the state of the existing ops? e.g,, cvt_int. On Oct 10, 2012, at 7:33 PM, Jay K wrote: Look at M3CG_MultiPass. For each function, it creates a record to hold the parameters. So they can be later be looped over in a different order and/or multiple times. The record includes an enum. I need an enum that looks almost exactly like M3CG_Binary.Op, except that I need those few missing elements. M3CG_MultiPass already has most of this, except 1) I somehow forgot got to handle a bunch of them 2) I need the below diff for it to be complete, or some other nearly identical enum instead. - Jay Subject: Re: [M3devel] completing M3CG_Binary.Op? From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 12:13:51 -0400 CC: m3devel at elegosoft.com To: jay.krell at cornell.edu I still don?t understand why the change is needed. On Oct 10, 2012, at 11:53 AM, Jay K wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful. - Jay From: hosking at cs.purdue.edu Date: Wed, 10 Oct 2012 02:33:13 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] completing M3CG_Binary.Op? Hmm. But the M3CG calls don?t include those operations. e.g., cvt_int is defined in M3CG_Ops. Why wouldn?t you just have a record for that? On Oct 10, 2012, at 1:59 AM, Jay wrote: I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 10:35 PM, Antony Hosking wrote: Why? On Oct 10, 2012, at 12:52 AM, Jay wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 9, 2012, at 9:36 PM, Antony Hosking wrote: Forgive me, but I don?t understand the purpose of this change. On Oct 10, 2012, at 12:08 AM, Jay K wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T. It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either. I'd like to add the missing operations.It seems like a very sensible reasonable change to me. ===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3 4 Sep 2012 14:29:54 -0000 1.19+++ M3CG_BinRd.m3 10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@ END; CONST- CmdMap = ARRAY Bop OF Cmd {+ CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd { Cmd {Bop.begin_unit, begin_unit}, Cmd {Bop.end_unit, end_unit}, Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3 1 Nov 2010 09:59:44 -0000 1.6+++ M3CG_Binary.i3 10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@ call_indirect, pop_param, pop_struct, pop_static_link, load_procedure, load_static_link, comment, store_ordered, load_ordered, exchange, compare_exchange, fence,- fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+ fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++ (* These only occur in memory, not in files.+ Conversely, what they are converted to only occur in files,+ not in memory. *)+ set_error_handler, (* disk: contains a pointer, silently skipped *)+ compare (* converted to eq/ne/etc. *)+ cvt_int, (* converted to trunc/ceiling/etc. *)+ fetch_and_op, (* converted to fetch_and_add/fetch_and_sub/etc. *)+ if_compare, (* converted to if_eq/if_ne/etc. *)+ set_compare, (* converted to set_eq/set_ne/etc. *) }; -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 1.txt URL: From jay.krell at cornell.edu Fri Oct 12 06:43:58 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 04:43:58 +0000 Subject: [M3devel] C backend -- mode or call quake? Message-ID: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 12 18:50:46 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 16:50:46 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Oct 12 19:23:59 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 12 Oct 2012 13:23:59 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote: > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Oct 12 19:23:59 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 12 Oct 2012 13:23:59 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> Message-ID: <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote: > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 12 19:46:42 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 12 Oct 2012 17:46:42 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: Emulating the gcc-based approach is not good. We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. "External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake. OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). It shouldn't be a big deal either way. cm3/Builder still has to new up a different backend. For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. - Jay From: hosking at cs.purdue.edu Date: Fri, 12 Oct 2012 13:23:59 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Sat Oct 13 06:25:11 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Sat, 13 Oct 2012 00:25:11 -0400 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> On Oct 12, 2012, at 1:46 PM, Jay K wrote: > Emulating the gcc-based approach is not good. > > > We have four modes currently: > ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject > (They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) > > > NT/x86 uses IntegratedObject > gcc/m3cg uses ExternalAssembly > "External" means "produce .mc files and run the quake function m3back()" > "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. > > > currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. > > > "External" anything is convenient for development and testing, bad for performance. > It writes and reads the .mc files. > Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. > > > "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". > > > So that leaves us with IntegratedObject. > M3C.m3 will have to interact with quake. Yuck! > OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). Yes! > It shouldn't be a big deal either way. > > > cm3/Builder still has to new up a different backend. > > > For LLVM you'll likely follow a similar course. > "External" is convenient for development and testing, but slower. > "Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly". > You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. Agreed, but that is not so difficult. > > > > - Jay > > > From: hosking at cs.purdue.edu > Date: Fri, 12 Oct 2012 13:23:59 -0400 > To: jay.krell at cornell.edu > CC: m3devel at elegosoft.com; antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > > Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. > > On Oct 12, 2012, at 12:50 PM, Jay K wrote: > > Clarification: it is "integrated" either way -- no production of .mc files. > Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. > > > Currently I'm going through config-only changes. > > > - Jay > > > CC: m3devel at elegosoft.com > From: antony.hosking at gmail.com > Subject: Re: [M3devel] C backend -- mode or call quake? > Date: Fri, 12 Oct 2012 09:12:53 -0400 > To: jay.krell at cornell.edu > > I vote for integrated. > > Sent from my iPhone > > On Oct 12, 2012, at 0:43, Jay K wrote: > > ok..so..I think time to make this decision and implement it. > > - add a "mode" for C and deal with it in Builder.m3 > I implemented and tested that and presented the diff a few weeks ago > It is reasonable, simple, works..but it isn't strictly needed. > > or > > - use IntegratedObject and have the C backend call the C compiler "itself" (via the > existing quake/config files) > I can go ahead and implement that. > > > Either way, cm3 likely must know about the C backend. > It at least has to "new" it, and maybe pass down function pointers for running > the C compiler -- or maybe M3C can get the pointers itself. > > Or I can put this off a bit longer and improve the generated C... > Using "integrated" saves us from writing and reading back the .mc files. > More efficient. > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 13 06:44:57 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 13 Oct 2012 04:44:57 +0000 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> References: , , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , , , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu>, , <9511FE7F-C403-47A3-B9EF-DBCE29DFCEA5@cs.purdue.edu> Message-ID: Aha, you like a new mode, IntegratedC? A bit more of a change in cm3/Builder, but leaves M3C.m3 ignorant of quake? Ok. I like it too. I had it working. I sent the diff. The only perhaps controversial part is I changed an error to be "more fatal" (stop right away, I think). I can bring that back. - Jay From: hosking at cs.purdue.edu Date: Sat, 13 Oct 2012 00:25:11 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? On Oct 12, 2012, at 1:46 PM, Jay K wrote:Emulating the gcc-based approach is not good. We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.) NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler. currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o. "External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code. "Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly". So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake. Yuck! OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat). Yes! It shouldn't be a big deal either way. cm3/Builder still has to new up a different backend. For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend. Agreed, but that is not so difficult. - Jay From: hosking at cs.purdue.edu Date: Fri, 12 Oct 2012 13:23:59 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com; antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake. On Oct 12, 2012, at 12:50 PM, Jay K wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change. Currently I'm going through config-only changes. - Jay CC: m3devel at elegosoft.com From: antony.hosking at gmail.com Subject: Re: [M3devel] C backend -- mode or call quake? Date: Fri, 12 Oct 2012 09:12:53 -0400 To: jay.krell at cornell.edu I vote for integrated. Sent from my iPhone On Oct 12, 2012, at 0:43, Jay K wrote: ok..so..I think time to make this decision and implement it. - add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed. or - use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that. Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself. Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Mon Oct 15 20:35:01 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Mon, 15 Oct 2012 11:35:01 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> Message-ID: <20121015183501.4A7AB1A2082@async.async.caltech.edu> Jay K writes: ... >"External" anything is convenient for development and testing=2C bad for pe= >rformance. It writes and reads the .mc files. Besides development/testin= >g=2C it also is used for licensing reasons -- communication through files i= >nstead of "linking" code. ... Jay you keep coming back to this issue of the performance of the compiler. Do you use Modula-3 for some large projects I'm not aware of? I compile quite a bit of code with it, and sure it would be cool (always is) if it were faster but it's not like the lack of speed has ever bothered me (not since the silly 0.1-second delay was removed from Process.Wait). I also implemented a parallelized back-end mode a while ago (it's in the tree). The speed of the compiler is mainly an issue when recompiling the world, which is something that happens mainly during "development/testing", and then not by regular users, normally... Mika From jay.krell at cornell.edu Tue Oct 16 02:21:23 2012 From: jay.krell at cornell.edu (Jay) Date: Mon, 15 Oct 2012 17:21:23 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <20121015183501.4A7AB1A2082@async.async.caltech.edu> References: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: The current usage of C backend is noticeably much slower than cm3cg. I really don't like it. - Jay (briefly/pocket-sized-computer-aka-phone) On Oct 15, 2012, at 11:35 AM, wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance. It writes and reads the .mc files. Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait). I also > implemented a parallelized back-end mode a while ago (it's in the tree). > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > > Mika From rodney_bates at lcwb.coop Tue Oct 16 18:36:35 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Tue, 16 Oct 2012 11:36:35 -0500 Subject: [M3devel] M3CG_Ops.Public vs. M3CG.T Message-ID: <507D8D13.80603@lcwb.coop> I'm finally getting around to responding to this. On 09/27/2012 02:00 PM, Jay K wrote:> One thing I missed is that > > > IMPORT M3CG; > > > Give you an M3CG.T that you can only pass around. > > Add IMPORT M3CG_Ops I think it was > and then you can make all the method calls on an M3CG.T. > > I don't see that the first intermediate step is useful, but oh well. > Everyone might as well just IMPORT M3CG_Ops. > > > It is kind of interesting that "private" and "protected" are kind of available in Modula-3, or at least one clump therein, by moving part of the interface into a separate file. Modula-3's hiding mechanism, while a lot simpler to define, is *much* more flexible than C++'s. In fact, the flexibility is, in a sense, unbounded. The fields and methods of an object type can have a different, arbitrary subset of them made visible in every interface or module. Just make a chain of opaque subtypes for each clump of fields/methods whose visibility you want to be able to control independently. Then provide a revelation for each clump. The one limitation is that each of the revelations has to be in a separate interface, because you want to be able to import any subset of the revelations, but you can't directly import a revelation, only an interface, which brings in all the revelations in that interface. This makes it syntactically a bit ponderous. But this cost brings a big benefit in language simplicity. A few sentences of language definition suffice, instead of a few pages. > > I say one clump, because I don't think you can do this: > > > FooRoot.i3: > TYPE Foo <: ROOT; > > Foo1.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F1(); > END; > > Foo2.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F2(); > END; > > Foo.m3: > REVEAL Foo = OBJECT METHODS > PROCEDURE F1(); > PROCEDURE F2(); > END; > You can write something like this, but Foo1.Foo and Foo2.Foo are distinct types not related to each other, nor to FooRoot.Foo. All three are side-by-side inheritance children of ROOT. Also, Foo1.Foo and Foo2.Foo will have to have full revelations somewhere. I'm not sure what you meant here, but I doubt this was it. > I think you can only have just: > > FooRoot.i3: > TYPE Foo <: ROOT; > > Foo1.i3: > TYPE Foo <: OBJECT METHODS > PROCEDURE F1(); > END; > > Foo.m3: > REVEAL Foo = OBJECT METHODS > PROCEDURE F1(); > PROCEDURE F2(); > END; > Which is the same, apart from the nonexistence of Foo2 and Foo2.Foo. > > It'd also be useful if you could do like this: > > Stream.i3: > > Reader = OBJECT METHODS PROCEDURE Read(); END; > Writer = OBJECT METHODS PROCEDURE Write(); END; > TYPE Stream <: Reader; > TYPE Stream <: Writer; > > Stream.m3: > REVEAL Stream = OBJECT METHODS > PROCEDURE Read(); > PROCEDURE Write(); > END; > > i.e. -- multiple inheritance. > > I realize you can reveal in multiple linear steps though...which I'm not going to give an example of right now.. so it isn't just "one clump", but if you reveal "multiple clumps", they need to form a linear chain, right? You can't "mix" as I showed for read/write. ? > > I think not requiring linearizing fields/methods would inevitably suck you into the tar pit of multiple inheritance. Multiple inheritance has been debated to death many times. The most charitable thing you can say is the price in semantic complexity outweighs, by orders of magnitude, the useful benefits. Here is an example showing visibility of arbitrary subsets of 3 fields: INTERFACE Opaque ; TYPE HideA <: ROOT ; TYPE HideB <: HideA ; TYPE HideC <: HideB ; TYPE T <: HideC ; END Opaque . INTERFACE ShowA ; IMPORT Opaque ; REVEAL Opaque . HideA = BRANDED OBJECT A : INTEGER := 1 END ; END ShowA . INTERFACE ShowB ; IMPORT Opaque ; REVEAL Opaque . HideB = Opaque . HideA BRANDED OBJECT B : INTEGER := 1 END ; END ShowB . INTERFACE ShowC ; IMPORT Opaque ; REVEAL Opaque . HideC = Opaque . HideB BRANDED OBJECT C : INTEGER := 1 END ; END ShowC . MODULE Opaque ; REVEAL T = HideC BRANDED OBJECT END ; BEGIN END Opaque . MODULE Client EXPORTS Main ; IMPORT Opaque ; IMPORT ShowA ; IMPORT ShowB ; IMPORT ShowC ; VAR O := NEW ( Opaque . T ) ; BEGIN O . A := 4 (* Legal iff ShowA is imported. *) ; O . B := 5 (* Legal iff ShowB is imported. *) ; O . C := 6 (* Legal iff ShowC is imported. *) ; EVAL O END Client . > - Jay From jay.krell at cornell.edu Wed Oct 17 03:08:01 2012 From: jay.krell at cornell.edu (Jay K) Date: Wed, 17 Oct 2012 01:08:01 +0000 Subject: [M3devel] in defense of ternary operator (Ada has it now) Message-ID: In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: e.g. sign := if a >= 0 then 1 else -1 They'd rather people NOT do like: sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Wed Oct 17 18:05:07 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 17 Oct 2012 11:05:07 -0500 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: References: <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com> <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: <507ED733.7020602@lcwb.coop> On 10/15/2012 07:21 PM, Jay wrote: > The current usage of C backend is noticeably much slower than cm3cg. I really don't like it. > At first thought, this didn't surprise me. Leaving out combinatorially heavy back-end optimizations, the usual primary speed bottleneck in compilers has always been lexical scanning. Not because it is fundamentally an inefficient task, but because of fundamentally high iteration count. It has to look at files one character at a time, for every character. In contrast, parsing, which is not a lot different in algorithmic efficiency (perhaps slower), only has to process lexical tokens, minus comments and white space. This gives iteration counts lower by a factor of several. Mostly ditto for the rest of the phases. So, for a back-end that generates source code in some character-encoded language, an every-character-one-at-a-time process has to happen twice, once in generating the source code, and again in scanning it. The cm3cg approach skips both these. This difference is fundamental to the two approaches, and not a lot can be done about it. But on second thought, if I understand correctly, both gcc reading text file input and cm3cg do the same at a later stage by generating assembly source code, then passing it to an assembler. And I would expect equivalent assembly code to have higher character count than C code, by a factor of a few. (In a quick look, I see one case giving a 3-to-1 expansion from Modula-2 source to assembly code.) I would expect this to dilute the extra time spent generating/scanning the C code. But maybe slowdowns in the neighborhood of 10% to 20% might be explainable this way. > - Jay (briefly/pocket-sized-computer-aka-phone) > > On Oct 15, 2012, at 11:35 AM, wrote: > >> Jay K writes: >> ... >>> "External" anything is convenient for development and testing=2C bad for pe= >>> rformance. It writes and reads the .mc files. Besides development/testin= >>> g=2C it also is used for licensing reasons -- communication through files i= >>> nstead of "linking" code. >> ... >> >> Jay you keep coming back to this issue of the performance of the compiler. >> Do you use Modula-3 for some large projects I'm not aware of? I compile >> quite a bit of code with it, and sure it would be cool (always is) if it >> were faster but it's not like the lack of speed has ever bothered me (not >> since the silly 0.1-second delay was removed from Process.Wait). I also >> implemented a parallelized back-end mode a while ago (it's in the tree). >> The speed of the compiler is mainly an issue when recompiling the world, >> which is something that happens mainly during "development/testing", >> and then not by regular users, normally... >> >> Mika > From rodney_bates at lcwb.coop Wed Oct 17 18:11:22 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 17 Oct 2012 11:11:22 -0500 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <20121015183501.4A7AB1A2082@async.async.caltech.edu> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> Message-ID: <507ED8AA.6090105@lcwb.coop> On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance. It writes and reads the .mc files. Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait). I also > implemented a parallelized back-end mode a while ago (it's in the tree). I didn't know that. Any experience on how stable it is? Time compiling isn't a huge issue for me either, but now that we all have n cores on a chip, for growing n, and little way to utilize them, that would indeed be cool. > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > > Mika > From mika at async.caltech.edu Wed Oct 17 20:23:59 2012 From: mika at async.caltech.edu (mika at async.caltech.edu) Date: Wed, 17 Oct 2012 11:23:59 -0700 Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <507ED8AA.6090105@lcwb.coop> References: , , <800F7F2F-69BB-4ADE-A166-A2B2C87181CD@gmail.com>, , <75819CAB-EC22-4949-8478-6C10A8F794EE@cs.purdue.edu> <20121015183501.4A7AB1A2082@async.async.caltech.edu> <507ED8AA.6090105@lcwb.coop> Message-ID: <20121017182359.5F8641A2082@async.async.caltech.edu> It was a little difficult to find, but here it is... https://mail.elegosoft.com/pipermail/m3commit/2011-February/009784.html Note I don't know how good pthreads are nowadays. It works fine with user threads... last time I tried it with pthreads my compiler hung, but I know there have been fixes since then. Mika "Rodney M. Bates" writes: > > >On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: >> Jay K writes: >> ... >>> "External" anything is convenient for development and testing=2C bad for pe= >>> rformance. It writes and reads the .mc files. Besides development/testin= >>> g=2C it also is used for licensing reasons -- communication through files i= >>> nstead of "linking" code. >> ... >> >> Jay you keep coming back to this issue of the performance of the compiler. >> Do you use Modula-3 for some large projects I'm not aware of? I compile >> quite a bit of code with it, and sure it would be cool (always is) if it >> were faster but it's not like the lack of speed has ever bothered me (not >> since the silly 0.1-second delay was removed from Process.Wait). I also >> implemented a parallelized back-end mode a while ago (it's in the tree). > >I didn't know that. Any experience on how stable it is? Time compiling >isn't a huge issue for me either, but now that we all have n cores on a >chip, for growing n, and little way to utilize them, that would indeed >be cool. > >> The speed of the compiler is mainly an issue when recompiling the world, >> which is something that happens mainly during "development/testing", >> and then not by regular users, normally... >> >> Mika >> From hendrik at topoi.pooq.com Thu Oct 18 02:11:47 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Wed, 17 Oct 2012 20:11:47 -0400 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: References: Message-ID: <20121018001147.GA2937@topoi.pooq.com> On Wed, Oct 17, 2012 at 01:08:01AM +0000, Jay K wrote: > In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: > e.g. > sign := if a >= 0 then 1 else -1 > They'd rather people NOT do like: > sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 > http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf > "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. > None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay This syntax originated a long time ago, with Algol 60. It wasn't a problem there, even though empty statements were invisible there, too. These, howerver, are expressions, and there are no empty expressions in either Algol 60 or Modula 3. The only problemm was the dangling "else" as in if ... then if ... then ... else ... But that's only a problem with statements, singe expressions always have to have their else's. For consistency of notation, IF expressions in Modula 3 should probably have explicit ENDs, as in Algol 68. -- hendrik From dabenavidesd at yahoo.es Thu Oct 18 17:08:46 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Thu, 18 Oct 2012 16:08:46 +0100 (BST) Subject: [M3devel] C backend -- mode or call quake? In-Reply-To: <507ED8AA.6090105@lcwb.coop> Message-ID: <1350572926.52530.YahooMailClassic@web29703.mail.ird.yahoo.com> Hi all: Some parallelized RT environments gave in DEC-SRC times degradation when N ~ 3 of processors than when it was > 10 in any particular program not only compilers. SO, I'm not so optimistic in general about that N growing too much. This is about what SPWM3 said succinctly I don't remember the quote. Hopefully research in other architectures like Message Passing could make the case for better compiler technology. I don't know what else you could make with those extra N < 10 cores, I believe there should be something but in those architectures, not emulating DEC architectures like currently amd tries to do, but other new approaches, but DEC is over Thanks in advance --- El mi?, 17/10/12, Rodney M. Bates escribi?: De: Rodney M. Bates Asunto: Re: [M3devel] C backend -- mode or call quake? Para: m3devel at elegosoft.com Fecha: mi?rcoles, 17 de octubre, 2012 11:11 On 10/15/2012 01:35 PM, mika at async.caltech.edu wrote: > Jay K writes: > ... >> "External" anything is convenient for development and testing=2C bad for pe= >> rformance.? It writes and reads the .mc files.???Besides development/testin= >> g=2C it also is used for licensing reasons -- communication through files i= >> nstead of "linking" code. > ... > > Jay you keep coming back to this issue of the performance of the compiler. > Do you use Modula-3 for some large projects I'm not aware of?? I compile > quite a bit of code with it, and sure it would be cool (always is) if it > were faster but it's not like the lack of speed has ever bothered me (not > since the silly 0.1-second delay was removed from Process.Wait).? I also > implemented a parallelized back-end mode a while ago (it's in the tree). I didn't know that.? Any experience on how stable it is?? Time compiling isn't a huge issue for me either, but now that we all have n cores on a chip, for growing n, and little way to utilize them, that would indeed be cool. > The speed of the compiler is mainly an issue when recompiling the world, > which is something that happens mainly during "development/testing", > and then not by regular users, normally... > >? ? ? Mika > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Thu Oct 18 17:28:57 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Thu, 18 Oct 2012 10:28:57 -0500 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: <20121018001147.GA2937@topoi.pooq.com> References: <20121018001147.GA2937@topoi.pooq.com> Message-ID: <50802039.6010102@lcwb.coop> On 10/17/2012 07:11 PM, Hendrik Boom wrote: > On Wed, Oct 17, 2012 at 01:08:01AM +0000, Jay K wrote: >> In defense of ternary operator:Ada 2012 has equivalent of C/C++'s ternary operator: >> e.g. >> sign := if a >= 0 then 1 else -1 >> They'd rather people NOT do like: >> sign := ORD(a >= 0) * 1 + ORD(a < 0) * -1 >> http://www.adacore.com/uploads/technical-papers/Ada2012_Rationale_Chp2_expressions.pdf >> "It should be remembered that the difficulties in C stem from a combination of things - That assignment is permitted as an expression, - That integer values are used as Booleans, - That null statements are invisible. >> None of these applies to Ada so all is well" Modula-3 is also safe from the first two, I don't know about the last. - Jay > > This syntax originated a long time ago, with Algol 60. It wasn't a > problem there, even though empty statements were invisible there, too. > These, howerver, are expressions, and there are no empty expressions in > either Algol 60 or Modula 3. > > The only problemm was the dangling "else" as in > if ... then if ... then ... else ... > But that's only a problem with statements, singe expressions always have > to have their else's. > > For consistency of notation, IF expressions in Modula 3 should probably > have explicit ENDs, as in Algol 68. Yes. There is a somewhat different syntax problem here. Would: IF B THEN T ELSE IF C THEN U ELSE IF D THEN V ELSE F Mean: IF B THEN T ELSE (IF C THEN U ELSE IF D THEN V ELSE F) (* IF is right-associative. *) Or: IF B THEN T ELSE IF C THEN U ELSE (IF D THEN V ELSE F) (* IF is left-associative. *) Would: IF B THEN T ELSE E OR F Mean: IF B THEN T ELSE (E OR F) (* OR has higher precedence than IF. *) Or: (IF B THEN T ELSE E) OR F (* OR has lower precedence than IF. *) Precedence and associativity rules for the IF-expression would resolve these, and all the existing expression operators have these properties. But somehow, the IF-expression intuitively seems to me to be a lot harder to follow than for more traditional infix operators. And for associativity there is an unusual asymmetry about it. At first, I wanted to write (IF B THEN T ELSE IF C THEN U ELSE) IF D THEN V ELSE F (* IF is left-associative. *) But that's really wierd, and would make IF B THEN T ELSE IF C THEN U ELSE (* Nothing here *) an expression, which breaks everything. Giving it a closing END seems a lot easier to fix the syntax and easier to read. > > -- hendrik > > From hendrik at topoi.pooq.com Thu Oct 18 23:04:54 2012 From: hendrik at topoi.pooq.com (Hendrik Boom) Date: Thu, 18 Oct 2012 17:04:54 -0400 Subject: [M3devel] in defense of ternary operator (Ada has it now) In-Reply-To: <50802039.6010102@lcwb.coop> References: <20121018001147.GA2937@topoi.pooq.com> <50802039.6010102@lcwb.coop> Message-ID: <20121018210454.GA2496@topoi.pooq.com> On Thu, Oct 18, 2012 at 10:28:57AM -0500, Rodney M. Bates wrote: > > > On 10/17/2012 07:11 PM, Hendrik Boom wrote: > >For consistency of notation, IF expressions in Modula 3 should probably > >have explicit ENDs, as in Algol 68. > > Yes. There is a somewhat different syntax problem here. > > Would: > IF B THEN T ELSE IF C THEN U ELSE IF D THEN V ELSE F > Mean: > IF B THEN T ELSE (IF C THEN U ELSE IF D THEN V ELSE F) (* IF is right-associative. *) > Or: > IF B THEN T ELSE IF C THEN U ELSE (IF D THEN V ELSE F) (* IF is left-associative. *) Can't see how this would happen if IF is left-associative. It looks more ike right-associative to me. In fact, right-associative should look like this: IF B THEN T ELSE (IF C THEN U ELSE (IF D THEN V ELSE F)) And what could left-associative even mean if IF has no left argument? > > Would: > IF B THEN T ELSE E OR F > Mean: > IF B THEN T ELSE (E OR F) (* OR has higher precedence than IF. *) > Or: > (IF B THEN T ELSE E) OR F (* OR has lower precedence than IF. *) > > Precedence and associativity rules for the IF-expression would resolve > these, It would. > and all the existing expression operators have these properties. > But somehow, the IF-expression intuitively seems to me to be a lot harder > to follow than for more traditional infix operators. > > And for associativity there is an unusual asymmetry about it. At first, > I wanted to write > (IF B THEN T ELSE IF C THEN U ELSE) IF D THEN V ELSE F (* IF is left-associative. *) > But that's really wierd, Yes, it is, because IF doesn't take a left argument,so it's syntactic nonsense. > and would make > IF B THEN T ELSE IF C THEN U ELSE (* Nothing here *) > an expression, which breaks everything. Also syntactic nonsense for ane expression. > > Giving it a closing END seems a lot easier to fix the syntax and > easier to read. Yup, that's the right answer for IF. As discovered in Algol 68 long ago. ONly they spelled it FI instead of END. -- hendrik From hosking at cs.purdue.edu Fri Oct 19 15:56:11 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Fri, 19 Oct 2012 09:56:11 -0400 Subject: [M3devel] Windows issue Message-ID: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 19 17:51:27 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 19 Oct 2012 15:51:27 +0000 Subject: [M3devel] Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative.There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks.We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe.I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this:call c:\program files\...vcvars32.bat -- user editable line%~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts?Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10.cm3 does not find the Windows linker. I work with vim and have configured themake macro to call cm3/bin/cm3.exe and the error happens when quake tries toinvoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent.It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University305 N. University Street | West Lafayette | IN 47907 | USAMobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Fri Oct 19 17:53:18 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Fri, 19 Oct 2012 16:53:18 +0100 (BST) Subject: [M3devel] Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: <1350661998.61721.YahooMailClassic@web29705.mail.ird.yahoo.com> Hi all: why do you need vim to sep up the compiler, it seems odd, all you need is an installation with cminstall and you 'll be ready. If you want to use CM3IDE with vim you can build from CM3IDE with no problems, otherwise please give more details on your side so other can help you more (i.e are you building cm3 with what commands within vim, etc). I haven't used msi installers, are you trying to use those? I heard of someone having trouble with that, but I can't give you more details than that. Thanks in advance --- El vie, 19/10/12, Antony Hosking escribi?: De: Antony Hosking Asunto: [M3devel] Windows issue Para: "m3devel developers" Fecha: viernes, 19 de octubre, 2012 08:56 I have had a query from a user of CM3 regarding Windows installation. ?I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10.cm3 does not find the Windows linker. I work with vim and have configured themake macro to call cm3/bin/cm3.exe and the error happens when quake tries toinvoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent.It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking?|?Associate Professor?| Computer Science | Purdue University305 N. University Street | West Lafayette | IN 47907 | USAMobile?+1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rcolebur at SCIRES.COM Fri Oct 19 22:18:55 2012 From: rcolebur at SCIRES.COM (Coleburn, Randy) Date: Fri, 19 Oct 2012 16:18:55 -0400 Subject: [M3devel] EXT: Windows issue In-Reply-To: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: My post back on 9/20/2012 describes what I do for using CM3 on Windows. I can resend again if needed. My scripts will take care of calling vcvars.bat when setting up the command prompt window for using CM3. The script can be tailored easily to account for differences in location of vcvars.bat among the various Visual Studio releases, including VS 10. --Randy Coleburn From: Antony Hosking [mailto:hosking at cs.purdue.edu] Sent: Friday, October 19, 2012 9:56 AM To: m3devel developers Subject: EXT:[M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmuysers at hotmail.com Sat Oct 20 16:33:40 2012 From: dmuysers at hotmail.com (Dirk Muysers) Date: Sat, 20 Oct 2012 16:33:40 +0200 Subject: [M3devel] Windows issue In-Reply-To: References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu> Message-ID: Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A brute force approach such as copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). Now, the the interest of calling cm3 from within VIM resides in the fact that it leads one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative. There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay -------------------------------------------------------------------------------- From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dabenavidesd at yahoo.es Sat Oct 20 20:34:15 2012 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Sat, 20 Oct 2012 19:34:15 +0100 (BST) Subject: [M3devel] Windows issue In-Reply-To: Message-ID: <1350758055.17350.YahooMailClassic@web29702.mail.ird.yahoo.com> Hi all: CM3IDE reloads packages each upon a time concurrently across clients whether browser tabs or all in one like Deckscape decks like functionality: http://www.ibiblio.org/openvideo/video/chi/chi96_17_m1.mpg IMHO if you combine both of them you can get a better distributed environment for programming than most people are used to. It's just like Modula-3 too ahead of its time if you like simplicity. The other approach for Modula-3 is M3clipse, a Eclipse Plugin that builds upon AST, needs more to work autocompletion, if we could make that work with extra functionalities in an Applet we could get the best framework IMHO for distributed programming, Thanks in advance --- El s?b, 20/10/12, Dirk Muysers escribi?: De: Dirk Muysers Asunto: Re: [M3devel] Windows issue Para: "Jay K" , "Tony" , "m3devel" Fecha: s?bado, 20 de octubre, 2012 09:33 Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second?solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A?brute force approach such as?copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). ? Now, the the interest of calling cm3 from within?VIM resides in the fact that it leads?one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a? pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. ? And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue ?> I?know there exists vcvars32.bat, but its effect is not permanent. ? Sure it is. If you use it right. Permance is relative. There are two easy ways. ? ? 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 ? ? 2.?somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). ? ? ?> It should be invoked somewhere by cm3/bin/config/NT386.common etc. ? ? Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. ? ? Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. ? ? Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: ? ? We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. ? ? On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com?that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. ? ? The lesson is "users should run foo" and "creative environments" should introduce "foo.com". ? ? But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. ? ? whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. ? ? Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. ? ? ?-?Jay ? From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. ?I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking?|?Associate Professor?| Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile?+1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 20 21:05:08 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 20 Oct 2012 19:05:08 +0000 Subject: [M3devel] comparisons and subranges Message-ID: Typecode = [0 .. 16_FFFFF]; (* can fit in 20 bits *)tc: Typecode. IF (tc # RTType.NoSuchType) AND (0 <= tc) AND (tc < n) THEN if(((INT64)(((INT64)(M3_INT64(0)))))>((INT64)(((INT64)(*(UINT32*)(&tc_L_68))))))goto L4F; gcc:../src/runtime/common/RTutils.m3:233: warning: comparison is always false due to limited range of data type I'd like to be warning-free.I think this is the only class of warning I have now. Thoughts? Could the frontend eliminate some of this stuff? Otherwise I might do constant-folding in the C backend. I had offered a patch months ago that would do some simple stuff in the frontendinvolving comparisons and subranges.Try that again?(i.e. see how many warnings it removes, see if it suffices?) I might just try hiding constants inside functions for now, at least zero since it is the biggest offender:.static int Zero(void) { return 0; } Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Sat Oct 20 21:09:17 2012 From: jay.krell at cornell.edu (Jay K) Date: Sat, 20 Oct 2012 19:09:17 +0000 Subject: [M3devel] Windows issue In-Reply-To: References: <266A382C-BDB8-43CF-9688-512D0ECB2AB1@cs.purdue.edu>, , Message-ID: > And Microsoft's command shell is a pain in the backside to say the least. I live in cmd every day and find it vastly preferable to e.g. Mac OS X Terminal.It's output is much faster. It's command line editing is much better, including history.The feature invoked by the F8 key -- command line completion against history -- I use all the time and have yet to find anywhere else. > A brute force approach such as copying "link.exe" to cm3/bin doesn't work either >because Agreed. A \cm3\bin\link.cmd that first runs vcvars32.bat would work. > it doesn't allow copy-paste etc etc Sure it does! I use it all the timeBy default you have to use the menu in the upper left, but you can enable "quickedit" and then it is more convenient. You should definitely try it. > And also, sorry to say so, cm3ide is far from being an elegant development tool, you caninspect only one file at a time and using VIM from cm3ide brings you back to the abovedilemma. Agreed. cm3ide is kind of worthless and not an "IDE" by anyone's expectation. - Jay From: dmuysers at hotmail.com To: jay.krell at cornell.edu; hosking at cs.purdue.edu; m3devel at elegosoft.com Date: Sat, 20 Oct 2012 16:33:40 +0200 Subject: Re: [M3devel] Windows issue Both solutions 1. as well as 2. work only from within the shell where vcvars32 was called. Let's say you use the second solution and open a unix shell (e.g. UWIN's korn shell) the effect of vcvars32 is not visible from with that shell, and also if you open vim from within the ms command shell after calling "cmd /k" and then cm3 from within vim, the same thing happens, the effect of vcvars is strictly limited to the "CMD" environment. A brute force approach such as copying "link.exe" to cm3/bin doesn't work either because "link" refers to many (how many?) other files within the VS environment (e.g. mspdb100.dll). Now, the the interest of calling cm3 from within VIM resides in the fact that it leads one directly to the faulty lines in your preferred editor, sure, not as elegantly as in a real IDE such as Visual Studio or Eclipse, but fair enough if you are used to it. And Microsoft's command shell is a pain in the backside to say the least. (it uses a weird file syntax, it can't remember its history between incarnations, it doesn't allow copy-paste etc etc) One is bound to hate it. And also, sorry to say so, cm3ide is far from being an elegant development tool, you can inspect only one file at a time and using VIM from cm3ide brings you back to the above dilemma. From: Jay K Sent: Friday, October 19, 2012 5:51 PM To: Tony ; m3devel Subject: Re: [M3devel] Windows issue > I know there exists vcvars32.bat, but its effect is not permanent. Sure it is. If you use it right. Permance is relative. There are two easy ways. 1. start; run; run vcvars32.bat; stay in same cmd and use cm3 2. somewhere on the start menu is a link that will do #1 -- opens up a cmd that runs vcvars32.bat and sticks around; the command line for the shortcut is roughly cmd /k c:\program files (x86)\visual studio\vcvars32.bat -- that /k means "run and don't exit" as opposed to the Unix-shell-like /c which means "run and exit". (see cmd /? for plenty more decent documentation -- cmd isn't great, but it is better than people realize, and the command line editor and text output performance are a lot better than anything else I've used; the scripting language aspect of it is not good though -- use Python instead...). > It should be invoked somewhere by cm3/bin/config/NT386.common etc. Not really. But maybe/kind of/store of. If we could find vcvars32.bat, then we can likely know all that it does and just do it ourselves. Granted, past versions did try to do something like that, but they didn't work well. They hunted around in a few places for C compiler and linker, asked user to confirm, and tried to form up short paths to them. Short paths aren't predictable, aren't necessarily stable across backup/restore (APIs added only as recently as Windows XP to set them), and aren't available on all file systems -- either tools should tolerate spaces, or depend on %PATH%, %LIB%, and %INCLUDE%. Perhaps an option to configure where vcvars32.bat is and run it, and then run other stuff, should be considered. Because "it isn't permanant", what one can do is generate a little temporary .cmd file that runs vcvars32.bat, then does whatever you "really" wanted to do, then exists. Another thing we can consider is symlinks or hardlinks. We could create \cm3\bin\cl.exe, \cm3\bin\link.exe that..er..nevermind that..matter of setting %INCLUDE% and %LIB% not dealt with.., but this: We could create \cm3\bin\cl.cmd and \cm3\bin\link.cmd that run vcvars32.bat and then cl.exe/link.exe -- they'd be considered user editable to find vcvars.bat. On the other hand..I have a LOT of history with wrapper programs and such..might be better to create cl.exe/link.exe or cl.com/link.com that read some input and then run the real cl.exe/link.exe. I've been through a similar exercise with nmake and I'm happier to have nmake.com than nmake.cmd. ".com" comes before ".exe" in %PATHEXT% so if you run "foo" and there is "foo.com" and "foo.exe", "foo.com" will be run. Whereas ".cmd" is after ".exe" so if you have foo.cmd and foo.exe and run "foo", "foo.exe" will be run. The lesson is "users should run foo" and "creative environments" should introduce "foo.com". But still, cl.cmd/link.cmd are easier because they would look like this: call c:\program files\...vcvars32.bat -- user editable line %~0.exe %* -- foo.cmd => foo.exe, with repeated command line. whereas foo.com would have to either replicate vcvars32.bat somehow, or create a wrapper .cmd.. Thoughts? Really asis is not bad -- run vcvars32.bat yourself, and then use cm3. - Jay From: hosking at cs.purdue.edu Date: Fri, 19 Oct 2012 09:56:11 -0400 To: m3devel at elegosoft.com Subject: [M3devel] Windows issue I have had a query from a user of CM3 regarding Windows installation. I am completely at sea answering since I never use Windows. Here is his question: I have a problem with the M3 compiler since I have installed Visual Studio 10. cm3 does not find the Windows linker. I work with vim and have configured the make macro to call cm3/bin/cm3.exe and the error happens when quake tries to invoke the MS tools. I know there exists vcvars32.bat, but its effect is not permanent. It should be invoked somewhere by cm3/bin/config/NT386.common etc. Can anyone help? Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 07:42:16 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 05:42:16 +0000 Subject: [M3devel] suspicious order of evaluation? Message-ID: m3tohtml/src/Main.m3: sources is global PROCEDURE Add() = BEGIN sources := NEW (Source, next := sources, from := Pathname.Join(pkgpath, file, NIL), to := Pathname.Join(pkg, FixDerived (file), NIL), kind := kind); It APPEARS this compiles to like: temp = RTHooks__AllocateTracedRef(...); sources = temp if temp == NULL raise exception sources->from = ... sources->to = ... To me this seems a bit suspicious. First, the null check should be against the temp. Sources should not be assigned and then checked. Second, probably, the fields of sources should be filled in before the global. So, it should be more like: temp = RTHooks__AllocateTracedRef(); if temp == NULL raise exception temp->from = ... temp->to = ... sources = temp ... Just as efficient, but "safer". Now, I realize, without a lock or barrier, the compiler is free to reorder like this.Maybe ideally temp would be gone but the original order used? C++ would implement it more like how I showed. Thoughts? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 07:57:37 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 05:57:37 +0000 Subject: [M3devel] suspicious order of evaluation? In-Reply-To: References: Message-ID: correction: temp = RTHooks__AllocateTracedRef(...); sources = temp if sources == NULL raise exception - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Thu, 25 Oct 2012 05:42:16 +0000 Subject: [M3devel] suspicious order of evaluation? m3tohtml/src/Main.m3: sources is global PROCEDURE Add() = BEGIN sources := NEW (Source, next := sources, from := Pathname.Join(pkgpath, file, NIL), to := Pathname.Join(pkg, FixDerived (file), NIL), kind := kind); It APPEARS this compiles to like: temp = RTHooks__AllocateTracedRef(...); sources = temp if temp == NULL raise exception sources->from = ... sources->to = ... To me this seems a bit suspicious. First, the null check should be against the temp. Sources should not be assigned and then checked. Second, probably, the fields of sources should be filled in before the global. So, it should be more like: temp = RTHooks__AllocateTracedRef(); if temp == NULL raise exception temp->from = ... temp->to = ... sources = temp ... Just as efficient, but "safer". Now, I realize, without a lock or barrier, the compiler is free to reorder like this.Maybe ideally temp would be gone but the original order used? C++ would implement it more like how I showed. Thoughts? - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 10:12:41 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 08:12:41 +0000 Subject: [M3devel] what is wrong with TIntN? Message-ID: When faced with VAR a := FIRST(INTEGER) + 1;VAR b := LAST(INTEGER) + 1;VAR c := LAST(INTEGER) + 1 - 1;VAR d := (a > 0); I would like backends to optimize initialization a,not optimize initialization of b,and probably not optimize initialization of c,and hopefully optimize initialization of d, but that is moredifficult in the C backend. Fold constants when it is obviously safe.Do not fold constants when there is a chance of overflow -- evenat intermediate points of the expression. This is why I believe TIntN is useful. I bring this up because I'm about to add constant folding to M3C.m3.And to introduce use of TIntN.Which Tony has insisted is wrong, i.e. use in M3x86.m3. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 25 16:37:57 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 25 Oct 2012 10:37:57 -0400 Subject: [M3devel] what is wrong with TIntN? In-Reply-To: References: Message-ID: The problem is that you are trying to bring front-end mechanisms into the backend. If you want to perform optimizations in your backend they should be standalone and independent of the front end. For example, the llvm backend can perform a whole bunch of optimizations in its own IR. TInt is a service provided by m3middle to the front-end. Feel free to add whatever you like to your backend. I just don?t want to see unnecessary stuff introduced into m3middle. On Oct 25, 2012, at 4:12 AM, Jay K wrote: > When faced with > > > VAR a := FIRST(INTEGER) + 1; > VAR b := LAST(INTEGER) + 1; > VAR c := LAST(INTEGER) + 1 - 1; > VAR d := (a > 0); > > > I would like backends to optimize initialization a, > not optimize initialization of b, > and probably not optimize initialization of c, > and hopefully optimize initialization of d, but that is more > difficult in the C backend. > > > Fold constants when it is obviously safe. > Do not fold constants when there is a chance of overflow -- even > at intermediate points of the expression. > > > This is why I believe TIntN is useful. > > > I bring this up because I'm about to add constant folding to M3C.m3. > And to introduce use of TIntN. > Which Tony has insisted is wrong, i.e. use in M3x86.m3. > > > > Thanks, > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Oct 25 16:43:27 2012 From: hosking at cs.purdue.edu (Antony Hosking) Date: Thu, 25 Oct 2012 10:43:27 -0400 Subject: [M3devel] suspicious order of evaluation? In-Reply-To: References: Message-ID: I?m not sure that Modula-3 defines any order of initialization (unlike Java constructors and the JMM), so implementations are free to choose. So, programmers that care must be careful not to expose uninitialized objects by assigning them to globals only after the initializer has run. And of course in a multi-core setting you?d need to enforce fences accordingly. I agree that it might make sense to implement they way you suggest. Antony Hosking | Associate Professor | Computer Science | Purdue University 305 N. University Street | West Lafayette | IN 47907 | USA Mobile +1 765 427 5484 On Oct 25, 2012, at 1:42 AM, Jay K wrote: > m3tohtml/src/Main.m3: > > sources is global > > > PROCEDURE Add() = > BEGIN > sources := NEW (Source, next := sources, > from := Pathname.Join(pkgpath, file, NIL), > to := Pathname.Join(pkg, FixDerived (file), NIL), > kind := kind); > > > It APPEARS this compiles to like: > > > temp = RTHooks__AllocateTracedRef(...); > sources = temp > if temp == NULL > raise exception > sources->from = ... > sources->to = ... > > > To me this seems a bit suspicious. > > > First, the null check should be against the temp. > Sources should not be assigned and then checked. > > > Second, probably, the fields of sources should be filled in before > the global. > > > So, it should be more like: > > > temp = RTHooks__AllocateTracedRef(); > if temp == NULL > raise exception > temp->from = ... > temp->to = ... > sources = temp > ... > > > Just as efficient, but "safer". > > > Now, I realize, without a lock or barrier, the compiler is free to reorder like this. > Maybe ideally temp would be gone but the original order used? > > > C++ would implement it more like how I showed. > > > Thoughts? > > > - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Oct 25 21:44:44 2012 From: jay.krell at cornell.edu (Jay K) Date: Thu, 25 Oct 2012 19:44:44 +0000 Subject: [M3devel] what is wrong with TIntN? In-Reply-To: References: , Message-ID: So, if I just move the code to m3back, you are ok?Clearly m3middle is for front and backends though. i.e. at least Target, TInt, TFloat is needed by both/all.How does m3front get away w/o having similar functionality? What is the meaning of: CONST a = 16_7FFFFFFF + 1; CONST b = 16_7FFFFFFF + 1 - 1; for a 32bit target? or CONST c = 16_7FFFFFFFFFFFFFFFL + 1; CONST d = 16_7FFFFFFFFFFFFFFFL + 1 - 1; (I should try them and see and read code, granted.I should read more of m3front in general.) Restated, clearly larger-than-host-integer precisionarithemetic is needed by the frontend. But I don't seethat it is sufficient to have fixed-64-bit-precision arithmetic.It seems to me you would want to further "type" or restrictthe precision, depending on context, to one of INT8, UINT8, INT16,UINT16, INT32, UINT32, INT64, UINT64.(where "unsigned" is perhaps "half interval", 0 to the maximum signednumber of that precision...though this half interval stuff stillmakes me uneasy..but I grant that TInt does not implement full range64bit unsigned math, it is really a portable INT64). What I can't immediately guess with high confidence is if the "typing"is appropriate for intermediate results, or only final results.i.e. range checking all along, or only upon some conversion at the end. I guess, again, I should read m3front and the language spec more. Also, regarding m3middle..M3CG_Ops.i3 does lend itself to an intermediaterepresentation. In-memory that can be processed in multiple passes.I realize using it as such isn't very creative and ultimatelyone would want to augment it further. But it is useful. And so there is the idea that m3middle is code of use to multiple backends,even if not to the frontend at all. As well, the idea of actual "shared middle ends" or shared passes.i.e. in M3C I eliminate unused local variables.(not through sophisticated analysis like eliminating locals thatare only ever written to..though I could do that...but locals thatare neither written to nor read from. If M3CG were in-memory "in an array"and that was a common interface to multiple backends, this trasnformcould be shared among backends, or heck, always applied as a matter of course. It kind of seems to me that backends should have some characteristicsdescribed about them, communicated to the frontend, like requestingthe frontend interface with them in one of two or three ways, andrequesting certain passes be applied before them. Or, look how gcc is structured, as a series of passes.We could do that.passes: m3front m3cg function calls to in-memory format eliminate unused locals compute operations x types -- i.e. discover if extract is applied to int32 and/or int64, for backends that want to output helper functions; not all targets care compute or estimate maximum compile-time stack depth -- I've been tempted to add this, but so far haven't done it; it is easy to estimate; my motivation isn't good -- it is that I don't like the Modula-3 generic mechanism and how it steers me toward "RefSeq" and lots of NARROW() operations -- slower than needed. I'd rather use an open array if I can compute the right size early. move imports ahead of everything compute frames, maybe These can all be done reasonably well with the "obvious" internalrepresentation, plus just a little extra data. I guess what I'm saying is there could/should be more shared code forbackends. Given the two in existance today, that isn't really true, theyare too different.But it is perhaps true if we had some other mix of backend implementations. Granted, LLVM does "everything" itself anyway, all those passesare trivial for it, most likely. It doesn't need any help. - Jay From: hosking at cs.purdue.edu Date: Thu, 25 Oct 2012 10:37:57 -0400 To: jay.krell at cornell.edu CC: m3devel at elegosoft.com Subject: Re: [M3devel] what is wrong with TIntN? The problem is that you are trying to bring front-end mechanisms into the backend.If you want to perform optimizations in your backend they should be standalone and independent of the front end.For example, the llvm backend can perform a whole bunch of optimizations in its own IR.TInt is a service provided by m3middle to the front-end.Feel free to add whatever you like to your backend. I just don?t want to see unnecessary stuff introduced into m3middle. On Oct 25, 2012, at 4:12 AM, Jay K wrote:When faced with VAR a := FIRST(INTEGER) + 1;VAR b := LAST(INTEGER) + 1;VAR c := LAST(INTEGER) + 1 - 1;VAR d := (a > 0); I would like backends to optimize initialization a,not optimize initialization of b,and probably not optimize initialization of c,and hopefully optimize initialization of d, but that is moredifficult in the C backend. Fold constants when it is obviously safe.Do not fold constants when there is a chance of overflow -- evenat intermediate points of the expression. This is why I believe TIntN is useful. I bring this up because I'm about to add constant folding to M3C.m3.And to introduce use of TIntN.Which Tony has insisted is wrong, i.e. use in M3x86.m3. Thanks, - Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 26 11:27:36 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 26 Oct 2012 09:27:36 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: <20121026092255.C9A94CC99F@birch.elegosoft.com> References: <20121026092255.C9A94CC99F@birch.elegosoft.com> Message-ID: I still really don't like how M3CG.TypeUID is defined. Asserting that a type fits in 32bitsshould not preclude putting it into a RECORD. Currently you cannot put M3CG.TypeUID into a record. The following does not work: RECORD whatever = typeid: M3CG.TypeUID; END; That seems really absurd to me. - Jay > Date: Fri, 26 Oct 2012 11:22:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/26 11:22:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > continue to hack around bogus packing of M3CG.TypeUID > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Oct 26 11:31:30 2012 From: jay.krell at cornell.edu (Jay K) Date: Fri, 26 Oct 2012 09:31:30 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, Message-ID: This is one reasonable way to fix it: Index: M3CG.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,vretrieving revision 1.10diff -u -r1.10 M3CG.i3--- M3CG.i3 6 Sep 2012 02:03:06 -0000 1.10+++ M3CG.i3 26 Oct 2012 09:30:31 -0000@@ -98,9 +98,9 @@ Always : Frequency = LAST (Frequency); TYPE- Int32 = [-16_7fffffff-1 .. 16_7fffffff];- TypeUID = BITS 32 FOR Int32;+ TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; (* a 32-bit unique id (fingerprint) for each type. *)+ assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; TYPE Label = INTEGER;Index: M3CG_MultiPass.i3 - Jay From: jay.krell at cornell.edu To: m3devel at elegosoft.com Date: Fri, 26 Oct 2012 09:27:36 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record I still really don't like how M3CG.TypeUID is defined. Asserting that a type fits in 32bitsshould not preclude putting it into a RECORD. Currently you cannot put M3CG.TypeUID into a record. The following does not work: RECORD whatever = typeid: M3CG.TypeUID; END; That seems really absurd to me. - Jay > Date: Fri, 26 Oct 2012 11:22:55 +0000 > To: m3commit at elegosoft.com > From: jkrell at elego.de > Subject: [M3commit] CVS Update: cm3 > > CVSROOT: /usr/cvs > Changes by: jkrell at birch. 12/10/26 11:22:55 > > Modified files: > cm3/m3-sys/m3back/src/: M3C.m3 > > Log message: > continue to hack around bogus packing of M3CG.TypeUID > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodney_bates at lcwb.coop Sun Oct 28 16:28:12 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 28 Oct 2012 10:28:12 -0500 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com> Message-ID: <508D4F0C.3080607@lcwb.coop> On 10/26/2012 04:27 AM, Jay K wrote: > I still really don't like how M3CG.TypeUID is defined. > > Asserting that a type fits in 32bits > should not preclude putting it into a RECORD. > > Currently you cannot put M3CG.TypeUID into a record. > > The following does not work: > > RECORD whatever = typeid: M3CG.TypeUID; END; I don't understand what the problem with this is. I expected it to work fine, which I confirmed by trying it, on both a 32-bit and a 64-bit compile. There is nothing here that would put the TypeUID at a place where it would have cross a word boundary or have problematic starting bit number. Did you perhaps mean in some other record type that has field(s) before the TypeUID that would leave it wrongly aligned? > > That seems really absurd to me. > > - Jay > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > To: m3commit at elegosoft.com > > From: jkrell at elego.de > > Subject: [M3commit] CVS Update: cm3 > > > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > Modified files: > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > Log message: > > continue to hack around bogus packing of M3CG.TypeUID > > From rodney_bates at lcwb.coop Sun Oct 28 17:00:26 2012 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Sun, 28 Oct 2012 11:00:26 -0500 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, Message-ID: <508D569A.90609@lcwb.coop> I do like this idea. It took me a while to catch on to the rule that a field of packed type not only must occupy exactly the stated bit count, but also must not have any compiler-added padding ahead of it. While this is just what is needed for programmer-control of record layout, it seems that almost everyone keeps missing it and getting tripped up by it. After having trouble with record layouts that became illegal after changes in non-packed fields, I have made it a convention not to put BITS--FOR in a type declaration, but only use it as an anonymous type expression for a record field or array element. The named type in the type declaration will likely be used in several contexts, with differing packing contexts. The packing really needs to be independently thought about for each record field and array element. On 10/26/2012 04:31 AM, Jay K wrote: > This is one reasonable way to fix it: > > Index: M3CG.i3 > =================================================================== > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,v > retrieving revision 1.10 > diff -u -r1.10 M3CG.i3 > --- M3CG.i36 Sep 2012 02:03:06 -00001.10 > +++ M3CG.i326 Oct 2012 09:30:31 -0000 > @@ -98,9 +98,9 @@ > Always : Frequency = LAST (Frequency); > TYPE > - Int32 = [-16_7fffffff-1 .. 16_7fffffff]; > - TypeUID = BITS 32 FOR Int32; > + TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; > (* a 32-bit unique id (fingerprint) for each type. *) > + assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; > TYPE > Label = INTEGER; > Index: M3CG_MultiPass.i3 > > > - Jay > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- > From: jay.krell at cornell.edu > To: m3devel at elegosoft.com > Date: Fri, 26 Oct 2012 09:27:36 +0000 > Subject: [M3devel] unable to put M3CG.TypeUID into a record > > I still really don't like how M3CG.TypeUID is defined. > > Asserting that a type fits in 32bits > should not preclude putting it into a RECORD. > > Currently you cannot put M3CG.TypeUID into a record. > > The following does not work: > > RECORD whatever = typeid: M3CG.TypeUID; END; > > That seems really absurd to me. > > - Jay > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > To: m3commit at elegosoft.com > > From: jkrell at elego.de > > Subject: [M3commit] CVS Update: cm3 > > > > CVSROOT: /usr/cvs > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > Modified files: > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > Log message: > > continue to hack around bogus packing of M3CG.TypeUID > > From jay.krell at cornell.edu Mon Oct 29 07:26:22 2012 From: jay.krell at cornell.edu (Jay K) Date: Mon, 29 Oct 2012 06:26:22 +0000 Subject: [M3devel] unable to put M3CG.TypeUID into a record In-Reply-To: <508D569A.90609@lcwb.coop> References: <20121026092255.C9A94CC99F@birch.elegosoft.com>, , , , <508D569A.90609@lcwb.coop> Message-ID: Thank you. > Date: Sun, 28 Oct 2012 11:00:26 -0500 > From: rodney_bates at lcwb.coop > To: m3devel at elegosoft.com > Subject: Re: [M3devel] unable to put M3CG.TypeUID into a record > > I do like this idea. It took me a while to catch on to the rule that > a field of packed type not only must occupy exactly the stated bit > count, but also must not have any compiler-added padding ahead of it. > While this is just what is needed for programmer-control of record > layout, it seems that almost everyone keeps missing it and getting > tripped up by it. > > After having trouble with record layouts that became illegal after > changes in non-packed fields, I have made it a convention not to > put BITS--FOR in a type declaration, but only use it as an anonymous > type expression for a record field or array element. The named type in > the type declaration will likely be used in several contexts, with differing > packing contexts. The packing really needs to be independently thought > about for each record field and array element. > > On 10/26/2012 04:31 AM, Jay K wrote: > > This is one reasonable way to fix it: > > > > Index: M3CG.i3 > > =================================================================== > > RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG.i3,v > > retrieving revision 1.10 > > diff -u -r1.10 M3CG.i3 > > --- M3CG.i36 Sep 2012 02:03:06 -00001.10 > > +++ M3CG.i326 Oct 2012 09:30:31 -0000 > > @@ -98,9 +98,9 @@ > > Always : Frequency = LAST (Frequency); > > TYPE > > - Int32 = [-16_7fffffff-1 .. 16_7fffffff]; > > - TypeUID = BITS 32 FOR Int32; > > + TypeUID = [-16_7fffffff-1 .. 16_7fffffff]; > > (* a 32-bit unique id (fingerprint) for each type. *) > > + assert_TypeUID_fits_in_32bits = BITS 32 FOR TypeUID; > > TYPE > > Label = INTEGER; > > Index: M3CG_MultiPass.i3 > > > > > > - Jay > > > > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > -- > > From: jay.krell at cornell.edu > > To: m3devel at elegosoft.com > > Date: Fri, 26 Oct 2012 09:27:36 +0000 > > Subject: [M3devel] unable to put M3CG.TypeUID into a record > > > > I still really don't like how M3CG.TypeUID is defined. > > > > Asserting that a type fits in 32bits > > should not preclude putting it into a RECORD. > > > > Currently you cannot put M3CG.TypeUID into a record. > > > > The following does not work: > > > > RECORD whatever = typeid: M3CG.TypeUID; END; > > > > That seems really absurd to me. > > > > - Jay > > > > > > > Date: Fri, 26 Oct 2012 11:22:55 +0000 > > > To: m3commit at elegosoft.com > > > From: jkrell at elego.de > > > Subject: [M3commit] CVS Update: cm3 > > > > > > CVSROOT: /usr/cvs > > > Changes by: jkrell at birch. 12/10/26 11:22:55 > > > > > > Modified files: > > > cm3/m3-sys/m3back/src/: M3C.m3 > > > > > > Log message: > > > continue to hack around bogus packing of M3CG.TypeUID > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: