<<

/

f .. X X THE -COMPILER IN A TIME-SHARING ENVIRONMENT J. A. Feldman

Massachusetts Institute of ft Lincoln Laboratory* Lexington, Massachusetts

J.E. Curry

Adams Associates Massachusetts

It has become increasingly clear that in the Definition of a Compiler-Compiler future the use of near creative A compiler-compiler is a program which will deal almost exclusively with interac- will produce a (compiler) for a tive time-shared systems. value The of in- from a suitable def- teractive has been programming estab- inition of that language. A generalized lished, and cost considerations time- block diagram of a compiler-compiler is sharing of large the best current in Figure, 1. a compiler for for such .shown When systems. The central ques- some language L, is required, the formal tion is how to improve the services a us- to syntax ol L, expressed in a syntactic meta- er keeping cost while the of compulation language, is fed into tin; Syntax Loader. within bounds. In this paper we will con- sider the role of a compiler-compiler in This program builds tables which will con- lowering the costs and extending the cap- trol the recognition and of pro- abilities of an interactive time-shared sys- grams in the language L. Then the seman- tem. tics of L, written in a semantic metalan- guage, is fed into the Semantic Loader. The discussion will be based on the ex- This program builds other tables contain- of the compiler-compiler, VITAL, ample ing a description of the meaningof state- within executive; as it functions the sys- ments in 1.. These tables are imbedded in on al Lin- tem,APEX, lhe'l'X-2 a Basic Compiler which consists ol code coln Laboratory. Although llie examples generators,inpul-oulpu Iand auxiliary rou- are specific, we will concentrate on points tines. which seem lo be ol general interest. VITAL has been running since early in 1 .66 and has been used for designing some Tin; resulting compiler is a table-driven special-purpose languages. It is based on translator based on a recognizer using a t the coiripiler-eom. filer, I'SL, developed by single pushdown slack. Each element in i one of the authors al Carnegie Institute ibis slack consists ol two words of Technology. Since the structure (2,.i) one lor a sy lilac lie construe! and Ilie oilier and.use (6) of I'SL have been reported in holding the semantics of Ihe construct. .Mime detail elsewhere, we will present When a particular syntactic construct is only a capsule description ol Ibis com- recognized, its semantic word and llie se- piler-compiler. mantic tables determine whal actions the translator will lake. Operated with support from llie U.S. Air Forr

Bedford, ..

I IN L T A SYNTAX OF L SYNTAX LOADER L E_ BASIC T COMPILER SEMANTIC A SEMANTICS OF L LOADER . B L E >

Figure 1 A COMPILER-COMPILER

The syntax of the language L, is described i Now suppose 'X' isrecognized in an arith- in a form of Production Language (3,4). metic context, say '+X\ The associated The semantic metalanguage FSL, is not as semantic routine might be: well known and will be discussed briefly TEMPOSYMBOL .DATUM, SEMANTICS} here. The semantic description of a trans- IF TEMP IS FLOATING THEN lator is a program in the metalanguage DATUM«-TF.MP ELSE FAULT 1 containingstatementswhich generatecode, The datum is looked up in the symbol ta- slate translator, or both. change the of the ble and the matched row is selected. The SEMANTICS(second)entryof thematched row is stored into the temporary cell. If Semantic Statements ibis word has been laggedor. 'FLOATING', il is assigned as the local meaning of 'X' Let us consider the semantic statements and translation continues. If the identifier which might be associated wilh various is of the wrong type or is not in the constructs in a simplified ALGOL. The table at all, the statement FAULT 1 is ex- semantics of a declaration 'REL X might ecuted. This causes the printing of an er- be expressed: ror message on the listing of the program ENTERLSYMBOL, DATUM, being compiled. The semantic, statement (STORLOC | FLOATING)}; would actually have to be augmented to STORLOOSTORLOC + 1 treat constants and other legal arithmetic data types. Thisslalcsthatan entry (row) istobemade in the . This row will con- Finally, let us consider the semantics of a sist of the datum (X in this case) and the statement "(Y + X)". The parenthesized contents of STORLOC lagged as a float- addition is complete, so a compiler would ing-point number. Then STORLOC, the presumably generate code at this point. system pointerfor datastorage, isincreasetl The semantic language statement by one. The entire routine has the effect CODE (DATUM 1 + DATUM 2) of assigning a location, to be kept in float- has precisely that effect Tint code brack- ing-point form, as the local meaning ol ets "CODE ("and")" play an essential rob; the identifier 'X. in the compiler-compiler and warrant fur-

r .—"'

ther discussion. Any construct enclosed utives are being developed for machines in code brackets specifies an action to be which incorporate many features designed performed at run time; any construct not for this purpose. For example, consider- so enclosed specifies an action to be per- able effort has gone into making the state formedat translate time. An example may of the machine easy to save and restore. help clarify this point. One of the most significant hardwarefea- FSL Translation tures is dynamic memory allocation. Since the system must rapidly alternate control In FSL as in many translators, the seman- amonguser programs, it is important that tics usually associated with an operand is as many of these as possible be in main a lagged machine address. If the FSL ex- memory. Further, since the of these pression 'DATUM 1 + DATUM 2' appeared programs is not predictable, the memory outside code brackets, the two addresses sharing cannot be scheduled in advance. would added. be This might be used in a By providing suitable hardware one can al- compiler for a new address to low the compiled addresses to be trans- and as in be lagged used. If, th*. example, formed and checked at every access [1 ]. the. expression were 'CODE (DATUM 1 + In such a scheme, programs may be dis- DATUM 2)', an mean- entirely different tributed in memory at addressesother than ing would result. In this ease the addition those in the compiled code. would be at run-time, the addends being the run-lime wjntenls of tin; twoaddresses. Most FSL constructs will have two mean- APEX System ings dependingon whether or not they are inside code brackets. The TX-2 time-sharing system, APEX, is based on one such scheme. The particular The major innovation in FSL was tint ma- address transformation used in APEX has chine-independent description of seman- been discussed in [ 5 |. It is based on a tics. Several other compiler- have thin-film memory which contains a trans- been implemented |9], and il is not our form for every page (256 register block ) purpose here to compare them. What we active in a user s symbolic memory. The will examine is the advantages gained and symbolic memory is divided into maps difficulties encounteredin embedding such (130, 672 registers) each consiting of 16 a program in a second- generation lime- books. A file is a named entity which may sharing system. occupy one or more books. A user program I lardwareDifferences will be dealing with only one map at a given moment,but changing maps is easily The distinction between generations of accomplished. The memory-sharing feature time-sharing systems can be made most of APEX and any comparable system is clearly in terms of hardware. Any time- closely related to the swapping scheme. sharing executive embodies an attempt to Oik; of the unusual features of APEX is provide last response and v.ariely of user that entire files arc swapped. This proce- services without excessive overhead; these dure is followed because there is no differ from the conventional multi-proces- swapping drum and is not generally advan- sing monitor mainly in tin; rapid switching tageous. The APEX page at 256 words is ofusers that isrequired. Tin; early systems closer to the common unit ol memory [8, 11] were implemented on machines swapping. This peculiarity of APEX will, which were designed for batch-processing however, allow us to measure directly and thus had limited capabilities and goals. certain parameterswhich would otherwise The second generation time-sharing exce- only be availableon a statistical basis.

t -—►

In addition to the hardware modifications, individual compilers, but also among all^ several programming developments have compilers within the system. To illustrate aimed at reducing the cost of switching this sharing we will consider a particular users. The most significant of these is the example in some detail. widespread use of programs which modify only a fixed block of working storage Program Sharing . pure during These so-called The example is based on the construction (reentrant) procedures can be shared by and use of a subset of ALGOL called the many users; switching the user of a pure Small Language [2, 3]. The three procedure involves only the swapping components of VITAL as depicted in (relativelysmall) working storage area. Figure 1are the Basic Compiler, the Syntax. Loader and the Semantics Loader. Each of Pure procedure techniques are especially these is assigned a separate APEX memory valuable for large programs, which are map,schematicsof whichform Appendixes used by much of the user community. A A,B,C. The length of each file in pages is compiler is just such a program. As we indicated in these schematics; the informa- will show, the compiler-compiler permits tion pertinent to memory-sharing is sum- the sharing of programs not only among marized in Figure 2.

MAIN MEMORY IN PAGES (256 Words)

Figure 2 MEMORY SHARING IN VITAL

The first column ofFigure 2 indicates that The second column gives the portion of the program sharedamongall VITAL levels memory shared among users on the same (memory maps) is 16 pages. This includes level of VITAL. Forexample,all compilers the executive interlace, control and input- share in common au additional ten pages output routines. This is sharable between of memory (the Basic Compiler). If two a user defining a new translator and users weresimultaneously compiling Small another user compiling a program with an Language programs, a further sharing of existing translator. live pages (the Syntax and Semantic

t Tables) would be possible, as indicated by In VITAL we have included editing and the third column. features in the compiler-com- piler and these are also sharable programs. The unshared memory at each level is the There are other features of VITAL which, amount required by the modifiable parts while not entirely new, seem particularly of VITAL, plus the storage occupied by a valuable in a time-sharing environment. particularuser's program. Theusers storage The symbolic form of all programs is en- includes space for the symbolic form, coded in a symmetric list of blocks. A translator storage and compiled code of block corresponds to one line of text and the source program or languagedescription contains pointers to the dictionary entries being processed. This obviously varies with ol the words in that line. This encoding the size of the user program. The figures takes lessspace than the original character given for the compiler level are for pro- string and permits insertionsand deletions grams ofabout 100 lines. We estimatethat to be made easily. Further, recompilalion unshared storage will grow at about five from this form takes about half as long as memory pages for each additional 100 the original compilation. In keeping with lines of source program. For large pro- the general philosophy of VITAL, the grams, the total requirement will be seg- syntactic and semantic descriptions of all mented, but the segment size has not yet languages in the system are also kept in been determined. this form. While these economic con- siderations were important in our design, the main purpose of VITAL is to extend the capabilities of the sophisticated user. Results Extended Capabilities Although these results look impressive, it is not easy to form precise conclusions The most significant extension is the from them. We have not yet implemented availability of the compiler-compiler itself. anyreally complex languages. Both VITAL A number of groups have used compiler- and the executive APEX are undergoing compilers to great advantage; in batch- continual development so that perform- processing systems. One barrier to more ance statistics are hard to evaluate;. There widespread use of such systems has been is a further difficulty in attempting to the problem of programming al several extrapolate our results to page-swapping levels. It is difficult to predict the effect systems. In APEX, any file being used of a change in language definition on the must Ik; completely in main memory. In a code compiled from a program in the page-swapping scheme;, only pari of any language. An interactive system will allow file can he expected to be in main memory the language designer to experiment di- at a given time and thus memory-sharing rectly with the effects of any changes in must be evaluated on a probabilistic basis. the syntax or semantics of his language. This experimentation should be further Several other economic advantages are facilitated by the fact that languages and potentially available from a compiler- meta-languagesarc represented in thesame compiler system. The translator-executive way within VITAL. interlace in a lime-sharing system has an important effect on performance and can The memory maps in the Appendixes be extremely complicated. By pulling a indicate the parallel representation of the large; effort inlei interface,^consider- various VITAL functions. These functions able amount of le;ve;rage; on ihe; problem are; coordinale'. by a reentrant controller could be; gained. whie;h automatically sets up the appropri-

cine; ate map and file for a function. The con- code brackets. With this facility one can troller resides in Book 0 of each map and alsodesign aspecific input-output language is always available through an interrupt for each compiler. There is also a new no- button on the console. The encoded sym- tionofpersistentstorage with an associated bolic form is the list of blocks of diction- pointer, PERSLOC. Persistent storage is ary-pinters described above. This uniform accessible bothat compile-time and atrun- and convenient representation allows the time. A related feature is the command auxiliary features such as interactive edit- RUN, which will cause the execution of a ing and debugging systems to be used in block of compiled code at . the same mannerby the language designer To make effective use of RUN, one must and the user of his language. have set initial values of certain variables, presumably in persistent storage. Another The editing and debugging programsmake use of these two features would be the use of the extensive graphics capabilities compile-time initialization of a program of the TX-2 computer. The debugging which is to be run many times. program is anambitious hardware and soft- ware system designed by T. G. Stockham, Some features have been provided to aid jr. [10]. It permits symbolic program and in communicating with the editing and data trapping and will eventually include debugging programs. One new operator dynamic flow-mapping. The complete sys- marks the boundaries of a statement in tem has a very flexible set of capabilities. the language being defined. Another re- For example, we could have a mode in cords symbolic names for selected abso- which a compiler-detected error would luteaddresses. Finally, there isan operator produce a display of the relevant section used to set up a compiled program as a of the source and meta-languages. Theuser self-contained entity in the time-sharing couldthen directly editor tag any of these executive, APEX. This enables one to and continue. The interactive capabilities prepare routines which are useable by of VITAL seem to present a marked people; having only minimal knowledge of advance overprevious compiler-compilers. APEX. are several other significant differe- There Future Development nces between VITAL and the Carnegie it is Tech FSL system on which based. There are also some problems which we Those which are hot specific to changes not yet considered carefully. The discussed have time-sharing will be in a separate omissions were due to personal taste and the paper. Thecontrolling factor in redesign the current capabilities of APEX rather of FSL was an attemptto exploit the inter-' than their intrinsic importance. One im- activecapabilities of a time-sharing system. portant addition to the semantic meta- aid in We have added features to the con- language would be information calls to the as struction of interactive compilers as well executive. These would permit both the features to help the language designer in language designerand language user to pro- his own programming. vide information helpful to the resource The mostsignificant change is the addition allocationroutineofthe executiveprogram. of a powerful input-output facility to the A typical use would be the reporting of semantic meta-language. This allows the areas of memory which are no longer re- language designer to specify a full set of quired by a program.A large class of ques- input-output operations to occur during tions concerns the linking of programs either the compilation or the running of a and data. Aside from the many existing source program; that is, input-output link loaders, this area has received little at- commands can occur inside or outside tention [7]. Considerations of this sort -

will become increasingly important as the 4. FLOYD, R. "A Descriptive-Lan- goalsof time-sharing systemsareextended. guage for Symbol Manipulation", J. of the ACM, Vol. 8, pp. 579 - 584, The effect of VITAL on the TX-2 graphics October 1961. effort has yet to be fully investigated. One current project is the design of a graphics 5. FORGIE, J. W. " A Time-and system which can be tailored to a variety Memory-SharingExecutive Program of applications. The use of meta-languages for Quick-Response, On-Line Appli- and associated processors seems a natural cation",Proc.FJCC,LasVegas, 1965. approach to this problem. A preliminary investigation suggests that much ofVITAL 6. ITURRIAGA, R., T. STANDISH, R. could be adapted for this purpose. KRUTARJ.EARLEY. "Techniques and Advantages of Using the Formal Compiler Writing System FSL to Prognosis Implement a FORMULA ALGOL Compiler",Proc.SJCC, Boston, 1966. Ineractive time-sharing systems have won wide spread acceptance; the compiler- 7. LEONARD, G., and J. GOODROE. compiler is still generally considered an "MoreExtensible Machines", CACM, interesting toy. It does seem, however, Vol. 9, pp. 190 195, March 1966. that a combination of the two ideas can - be productive. The availability of an inter- 8. SCHWARZ, J. I. "The SDC Time- active system should greatly facilitate the Sharing System", Datamation, 10, task of language design with a compiler- pp. 28-31,54-55, 1964. compile.r. Further, such a system seems exceptionally well-suited to the joint 9. SHAW, MARY. "Formal Compiler- demands of low overhead and extended Descriptive Systems",GomputerCen- user capabilities inherent in time-sharing. ter, CarnegieInstituteofTechnology, November An experimental system based on these, 1965. to efficient principles has proved be quite 1 0. STOCKHAM, T. G., Jr. "INSIGHT, tei significant and may lead improve;ment A Graphical Debugging System", in in compiler design and use. preparation.

References 11. The MIT Computing Center. The Compatible Time-Sharing System, The; MIT Press, Cambridge, 1963. 1. DENNIS, J. B. "Segmentation and the DesignofMultiprogrammed Com- puter "Systems", j. ACM, Vol. 12, pp. 589-602, October 1965. NATIONAL NOMINATIONS FELDMAN,,|. 2. A. "A Formal Seman- Recommcndationsfor nominations arenow tics for Computer Lan- open for national offices of the ACM. (.enter, guages", Computer Carnegie Any person who desires to have his name of Institute Technology, May 1964. recommended to the Nominating Commit- 3. FELDMAN, J.A. 'A Formal Seman- tee is invited to appearin person and seek tics for Computer Languages and lis endorsement of the Council at its next Application inaCompiler-Compiler", meeting at 4:30 p.m. on the day and at Comm. of the ACM, Vol. 9,.]anuary tbe place of the regular dinner meeting 1966. for September.

Oriente;d -- -

EXECUTIVE COUNCIL MINUTES- Old Business AUGUST 17, 1967 Audit Report Present NED CHAPIN as Chairman, Audit Com- M.ATCHISON, mittee filed a report concerning the audit NEDCHAPIN,CHARLES of the Chapter's A.E. CORDLIAN, PETERSON, financial books and ERIC ED records. The DODGE, FLETCHER W. findings indicated that there DONALDSON had been no errors of omission or PASTEUR S.T. YUEN, MURRAYBERG, com- mission and that the books GORDON PELTON. and records 'PHILLIP UTSTRT had been maintained in a manner LOWELL HILL consis- tent with the practices of prior fiscal years. The Committee recommended that the auelit hereafter be handled by a CPA.

Announcements Budget A The; audit Committee filed its report on motion was carried that the budget for 1967-68 the; past year. The report was favorable be approved by the end of the anel approved all activities of the Treas- month (August). To this end a special urer. A recommendation was made that Budget meeting was called for August 24. future audits be conducted by a CPA and thai the Treasurer arrange the chapter ac- count to permit this. Bit Dropper

The meetingwith the Naval Post-Graduate M. BERG described the plan to change the School Student Chapter at Monterevy is Bit-Dropper publication procedures to re- tentatively scheduled for November 17. flect a "new look." The plan was author- More information will be available later. izedfor 3 months starting with September.

New Business October Dinner Me;eting Appointments Be;eause; of conflict with the one-day sem- The following nanus were submitted by inar scheduled by the National ACM on the Chairman for the positions indicated: October 19, tbe dinner meeting normally Publicity Chairman held on the 3rd Thursday was rescheduled PHILLIP LHSTRI, Shell Oil Co. to October 26. Speaker and Place will be announced at a later time. Program Chairman Coordinator grayson Aram Spe;ake;r's Repe>rt Program Subchairmcn FRED BRAND LMSC The; National ACM has requested that a L. JOHNSON, IBM re;pe>rl be- submitted regarding the speaker's G. WYLEK, RCA lalk and its acceptance by llie audience. 11 was moved anel seconded that the re- Procedure Commillc.c Chairman peat be- the' responsibility of the officer G.MeCORMICK, LMSC introducing the speaker, with inputs from I'Kill Technical Symposium Menibers-al-large. Tbe Secretary will mail NEDCHAPIN re-peirl to headquarters.

Chairman,