Xref: utzoo comp.lang.c:11335 comp.arch:5502
Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!yale!lisper-bjorn
From: lisper-bjorn@CS.YALE.EDU (Bjorn Lisper)
Newsgroups: comp.lang.c,comp.arch
Subject: Re: Self-modifying code (and space/time complexity)
Keywords: self-modifying code, generate-and-execute
Message-ID: <33652@yale-celray.yale.UUCP>
Date: 15 Jul 88 18:43:44 GMT
References: <3353@cognos.UUCP> <619@goofy.megatest.UUCP> <429@uwovax.uwo.ca> <12360@ut-sally.UUCP> <1744@vaxb.calgary.UUCP>
Sender: root@yale.UUCP
Reply-To: lisper-bjorn@CS.YALE.EDU (Bjorn Lisper)
Organization: Yale University Computer Science Dept, New Haven CT  06520-2158
Lines: 39

In article <1744@vaxb.calgary.UUCP> radford@calgary.UUCP (Radford Neal) writes:
>
>There are interesting cases where on-the-fly generation of code seems
>to be essential to get good asymptotic space and/or time complexity.
>
>Consider the following code fragment (version A):
>
>     for (i = 0; i     { if (c1) p1();
>       if (c2) p2();
>       ...
>       if (cN) pN();
>     }
>
>The Boolean variables c1, c2, ... cN are assumed to be loop invariants.

(...version B deleted...)

>The following lets you get both (version C):
>
>     start generating code;
>     if (c1) generate instruction to call p1;
>     if (c2) generate instruction to call p2;
>     ...
>     if (cN) generate instruction to call pN;
>     for (i = 0; i