Abstract. Programs written in languages of the Oberon family usually. contain runtime tests on the dynamic type of variables.

Size: px
Start display at page:

Download "Abstract. Programs written in languages of the Oberon family usually. contain runtime tests on the dynamic type of variables."

Transcription

1 Type Test Elimination using Typeow Analysis Diane Corney and John Gough Queensland University of Technology, Brisbane, Australia Abstract. Programs written in languages of the Oberon family usually contain runtime tests on the dynamic type of variables. In some cases it may be desirable to reduce the number of such tests. Typeow analysis is a static method of determining bounds on the types that objects may possess at runtime. We show that this analysis is able to reduce the number of tests in certain plausible circumstances. Furthermore, the same analysis is able to detect certain program errors at compile time, which would normally only be detected at program execution. This paper introduces the concepts of typeow analysis and details its use in the reduction of runtime overhead in Oberon-2. 1 Introduction Implementations of object-oriented languages based on type extension[1] such as Oberon[2] and Oberon-2 [3] must perform tests on the dynamic type of objects. These type tests are comparable in runtime cost to the index bounds checks of Pascal-like languages[4]. Just as it is possible to eliminate much of the overhead of index bounds checking by careful static analysis of programs (see [5], for example, for a recent review), so it is possible to eliminate some of the runtime cost of type testing. In this paper we introduce the concept of typeow analysis, which has some similarities to dataow analysis, and explain how these concepts have been implemented to achieve this objective in an Oberon-2 compiler. Section 2 discusses type extension as a form of inheritance and introduces a notation for type extension and explains its use. Section 3 shows how conventional common subexpression elimination may be used to eliminate some type tests. However, we show that this method falls short of detecting some obvious redundancies, demonstrating the need for a more careful analysis. A discussion is given in Section 4 of the concepts of typeow analysis and its relation to control ow. The notion of a manifest type is introduced and its use in tracking variable types during this form of static analysis is explained. For dierent control ow constructs, the manner in which the manifest type may be updated is discussed, and examples given. Section 5 discusses the testing of an implementation of typeow analysis limited to some simple cases. Consideration is given as to how typeow analysis might be fully implemented and utilised. This work is supported by the Cooperative Research Centre for Distributed Systems Technology

2 2 Inheritance and Type Extension Type extension is a data structuring mechanism introduced by Niklaus Wirth in the language Oberon. It allows record types to be declared which extend previously declared record types by the addition of extra elds. This mechanism is a form of single inheritance and allows a type hierarchy to be constructed. 2.1 Notation If there is a type T 0, which we shall call a base type, and T 1 is an extension of T 0, then we denote this T 1 > T 0. We say that T 1 is a direct extension of T 0. However, T 1 could then be further extended, so that T 2 > T 1, and so on. The reexive transitive closure of the extends relation is denoted >. For example, T n > T m states that T n is a (possibly indirect) extension of T m, or else T n = T m. The language semantics provide that references to objects may be assigned bound objects of any type which is an extension of the statically declared bound type of the reference. When a program makes an access to a selected component belonging only to certain extensions of a type, the designator of the selector component contains a type guard. This type guard is an assertion that the dynamic type of the object will be in the `extends' relation of the nominated type, and causes a runtime test to be generated. Syntactically the type guard is denoted by a type name, appearing in parenthesis, following the denoter of the referenced object. For example, the designator exp(binop).op asserts that the object referenced by exp is dynamically of a type which is in the > relation with the type BinOp. It should be noted that the word \type" in this connection has its conventional meaning in strongly typed languages. This is in constrast to the use of the word to refer to a nite set of classes, as discussed in [8], for example. In our notation, all types are distinct, and an object has a unique type at every epoch of its lifetime. 3 The Limitations of Common Subexpression Elimination Some type tests may be eliminated by conventional common subexpression elimination. Consider a situation where a type Expr has several extensions including a BinOp type, and the BinOp type has extensions Plus and Star. The relevant part of the type hierarchy is shown in Figure 1. A typical fragment of code might be -... exp(binop).leftexp...;... exp(binop).rightexp...; It is clear that if the type guard is treated as a unary operator on the object designator, the second of the two runtime tests may be eliminated. In eect, the tested value becomes a common subexpression.

3 Q Q Q Q Q Q R@ Unary Expr Plus Binop Star Fig. 1. Fragment of type hierarchy Unfortunately, this mechanism is insucient to eliminate all unnecessary tests. Consider the fragment -... exp(plus).field1...;... exp(binop).field2...; In this case the second test is redundant (since if an object is an extension of type Plus it is necessarily an extension of type BinOp), although there is no common subexpression. exp:=starvar exp:=plusvar Q Qs + exp(binop).leftexp Fig. 2. Merging control ow Global ow of type information must also be taken into account. Consider the control ow graph fragment in Figure 2, where the variables have static types as indicated by their names. In this case, understanding the semantics of the type system, we can deduce that the type guard in the successor block is redundant, since all paths leading to that block set the type to an extension of the BinOp type. 4 Typeow Analysis If a particular reference object is declared as being of some static type S, then the static semantic checks of Oberon-2 ensure that the dynamic type D is always such that D > S. However, we wish to place some tighter bound on the type

4 by computing a manifest type M for the object so that, at every point in the program D > M > S For any given variable S is constant, while D and M may vary from place to place in the program. If we use the manifest type as a bound on the dynamic type of a variable, then the manifest type can be used to decide if a type guard is redundant. At any point in the program a type assertion D > t is redundant if the statically computed manifest type M > t, since we know that D > M. For technical reasons which become clear later we lift the domain of types to include two additional, extremal values. The special type value is an error type, and is an extension of every type. All types in a program are considered to be an extension of the other special value >. Formally, for every type T, > T > >. It is not dicult to see that every \object oriented language" which admits (a possibly limited form of) polymorphic assignment could be subjected to static analysis to compute the set of possible types which an object might take at runtime. In general, such a computation requires the nding of a least xed point of a set of set-valued equations[9]. In this general case the computations are over vectors of elements which are members of the powerset of program types. It is the major contribution of this paper to show that for Oberon-2 the computation may be carried out in terms of vectors of elements of a denumerable type, of cardinality equal to the number of types in the program. Furthermore, the equations have a formal correspondence to the familiar equations of dataow analysis, although the meaning of the symbols is somewhat dierent. 4.1 Control Flow Typeow analysis involves the tracking of the type of variables across the control ow graph. At entry to the control ow graph the manifest type of each reference object is set equal to its static type, that is, M = S. The static type does not change, but the manifest type is updated as the eect of each statement in the block is computed. The manifest type of a variable into a particular block is denoted M in. At the end of the block the new manifest type, that is, the manifest type out of the block, is denoted M out. In straight line control ow the M in of one block is equal to the M out for the predecessor block. However, in more complex control ow the M in of a block requires more computation. For a merge block, that is, a block with several predecessor blocks, M in is the lowest common ancestor of the set of M out values of all the predecessor blocks. The lowest common ancestor (LCA) of a set of types is the most extended type in the type hierarchy which includes all of the types in the set. For example, using the type hierarchy fragment in Figure 1, the LCA of the set fplus,starg is BinOp. The LCA of the set funary,plus,starg is Expr, and the LCA of the set fbinop,plus,starg is BinOp. In a companion paper[6], we develop the formal theory of typeow based on an algebra of clades, a term borrowed from evolutionary biology to denote a

5 species and all the species evolved from that species. For any type T we dene the corresponding clade as the set Clade(T ) = ft j t > T g In the companion paper we show that the manifest type into each single input, single output region is given by the following equations Mstart in = S _ Mi in = j2pred(i) A j _ (B j ^ M in j ) (1) In these equations, pred(i) is the set of blocks which are control ow predecessors of block i, and _ denotes the LCA operation. ^ denotes the more extended of its two operands if one is an extension of the other, and the special value if the two are incommensurate. The value denotes an error value, the root of the empty clade. The local information from each region appears in the coecients A i ; B i. These encapsulate the eect of downwardly visible Assignments and type Bounding tests respectively for each region. For a basic block i, if j is an index over program objects, and a ij ; b ij are the j-th elements of the vectors A i ; B i, then one of a ij ; b ij will be an extremal value for every index j. Blocks with assignments to a particular variable with index j will have the corresponding element, b ij equal to, while blocks with no assignments to variable j will have the corresponding element, a ij equal to >. The equations 1 must be solved in the forward control ow direction, so as to obtain a least (most constrained) value for M. In dataow terms this is a forward ow, all paths problem. However, it should be noted that the meaning of the ^; _ are quite distinct to the bitwise, Boolean and and or of conventional dataow analysis. Strict analysis would show that at every point in a program the strongest possible assertion regarding the dynamic type of an object would constrain the type to be a member of some set of types. However, there are no operations in Oberon-2 which test membership in such an arbitrary set of types. Instead, all explicit and implicit tests are based on the > relation. Suppose that D is the type of an object at some point in a program, and it is known that D 2 S, where S is some set of types. In this case, the condition that a test D > T is redundant is S Clade(T ). What we have called the manifest type M is simply the smallest clade covering S, and the redundancy condition is M > T. The approximation which we make is to compute the smallest covering clades (that is, the manifest types) directly and test the > predicate, rather than compute the exact sets and test the subset predicate. It is this mechanism of representing arbitrary sets by their smallest covering clade which results in the reduction of cardinality in the entities which we compute. In a program with N types there are 2 N sets of types, but there are only N + 2 clades. In common with the formally similar dataow equations, the system of equations (1) possess a \loop breaking rule". The practical consequence of this rule is

6 ) A UA / ) that loops need only be traversed twice to determine the manifest type at each point in the body. 4.2 Manifest Types and the Control Flow Graph Any reducible control ow graph can be derived from a small number of constructs. They are straight line control ow, merging control ow, and control ow with back edges. The following describes how the equations are solved for each case. Straight Line Control Flow. This is a trivial case for typeow. This structure is produced by simple sequential code. The M out of a block becomes the M in to the following block, see Figure M1 in M2 in = M1 out M2 out Fig. 3. A sequence construct Merging Control Flow. Merging control ow is produced by WITH, IF and CASE statements in Oberon-2. Figure 4 shows a control ow graph fragment which contains merging control ow 2. In this situation the M out of block 1 is the M in for blocks 2{5. The M in to block 6 is the LCA of the manifest types out of blocks 2{5. The equations are also shown in Figure 4. 2 P P P P Pq P P P P Pq S ws 4 5 M2 in = M1 out M3 in = M1 out M4 in = M1 out M5 in = M1 out M6 in = LCA(M2 out, M3 out, M4 out, M5 out ) Fig. 4. Example of merging control ow 2 This diagram strictly applies only to those cases where the ow of control is not predicated on the result of type tests. The modications required to handle such predicates are dealt with in a later section.

7 Q Control Flow With Back Edges. The control ow graph fragment in Figure 5 contains a back edge. This may require the traversal of the block more than once. As can be seen, the M in to block 2 is the LCA of the manifest types out of block 1 and block 2. To calculate the M out of block 2 it is rst traversed with an 1 2 M2 in = LCA(M1 out, M2 out ) M3 in = M2 out 3 Fig. 5. Fragment with a back edge initial M in equal to the M out of block 1. Then the block is traversed a second time with M in equal to the LCA of the M out of block 1 and the M out of block 2 which was calculated on the rst traversal. The M out of block 2 is the M in for block 3 in the usual way. The Oberon-2 statements which produce this type of control ow are the WHILE, FOR and REPEAT loops. The LOOP statement produces the slightly dierent control ow, shown in Figure 6. The fragment shown is for a loop with two exits. The M in into block 2 is calculated by the same method as for other loops, that is, blocks 2, 3 and 4 are traversed with the M in to block 2 being the M out of block 1. Once the M out of block 4 is calculated, blocks 2, 3 and 4 are traversed again using the LCA of the manifest types out of blocks 1 and 4 as the M in for block 2. The M in to block 5 is then calculated as the LCA of the manifest types out of blocks 2 and Q Qs Fig. 6. Loop with multiple exits LOOP......EXIT;......EXIT;... END;

8 4.3 Local Typeow In order to compute the relationship between M in and M out in any particular block, we must take account of the eect of the statements of the block. Three constructs aect the manifest type of variables within a block. These are assignment statements, procedure calls and type guards. Assignment Statement. The Oberon-2 language semantics allow for variables of a particular type to be assigned expressions which are extensions of that type. For reference objects the dynamic type then becomes equal to the dynamic type of the expression. With this is mind, consider the assignment statement var := exp; where the static type of exp is T e. The static semantic rules of Oberon demand that T e must be in the extends relations with T v, the static (declared) type of the variable. After this assignment statement has been executed it can be asserted that the type of the variable is equal to the type of the expression. During typeow analysis this means that the manifest type of the variable becomes the manifest type of the expression. Procedure Call. When a reference object is sent as a variable parameter of a procedure call, the called procedure may change the type of that parameter. Without inter-procedural type tracking, the only assertion that can be made about the type of the variable after the procedure call is that it is an extension of the static type of the formal parameter. The manifest type of the actual is changed to reect this. Type Guards. As mentioned previously, a type guard is an assertion that the dynamic type of a variable is in the extends relation of the guard type. A type guard produces a runtime test for this. Since the goal of typeow analysis is to remove redundant type tests, each type guard must be compared to the manifest type of the variable it is guarding. The type guard var(t ).eld has dierent eects depending on the manifest type of the variable var. First, suppose that the manifest type of var is M, and this is an extension of T. In this case the type guard may be removed. We know that the dynamic type of var will be at least as extended as M, so if M is an extension of T, the test is bound to evaluate to true. In this case, the manifest type of var is unchanged by the test, as M is already more extended than T. On the other hand, if the guard type is an extension of the manifest type of var, T > M, then the test cannot be removed. However, following the test it is known that the type of var is at least as extended as T, and so the manifest type of var is thus updated to equal T. 4.4 Type Predicates There are two constructs in Oberon-2 in which the ow of control is explicitly mediated by the dynamic type of objects. These are IS expressions and WITH statements, also called regional type guards.

9 IS Expression. In Oberon the IS expression is a boolean expression of the form var IS T, which gives the result of the runtime type test D > T where D is the dynamic type of var. When this expression is used as the condition for a loop or an if statement, then the manifest type of var can be updated to be the more extended of M and T, where M is the existing manifest type of var. Note that the manifest type of var should not be simply set to T, as the existing manifest type may already be more extended than T. For example, again referring to the type hierarchy in Figure 1, for the if statement - IF exp IS BinOp THEN StatementSequence ELSE StatementSequence END; If exp is statically of the type Expr, and its existing manifest type is also Expr then the manifest type of exp should be changed to BinOp before the thenpart statement sequence is traversed. However, if the existing manifest type of exp is Plus, say, which is an extension of BinOp, then the manifest type is unchanged for the traversal. In either case, the manifest type entering the elsepart statement sequence is the same as the manifest type on entry to the if statement. WITH Statement. Syntactically, a WITH statement in Oberon-2 has the form{ WITH var : T1 DO StatementSequence; var : T2 DO StatementSequence; var : T3 DO StatementSequence; ELSE StatementSequence; END; The WITH statement is equivalent to an IF statement containing multiple ELSIF s with a number of IS expressions as the condition on each. It sequentially tests each option for the var > T n relation, where T n is the type in the option, until it nds a test which succeeds. If none of the tests succeed, then the statements in the ELSE clause are executed. The ELSE clause is optional and, if it is not present and no other test succeeds, then the program aborts. Each option in the WITH statement is treated as an IS expression. Before traversal of each statement sequence the manifest type of the variable is changed to be the lower of the existing manifest type of var and T n. This WITH statement produces the control ow found in Figure 7. The manifest type of var after the WITH statement, that is, M in for the merge block

10 Fig. 7. A WITH statement fragment (block 8), is changed to the LCA of the manifest type of var after traversal of each of the options of the WITH. 4.5 A Bonus Detection of Incorrect Programs We have described how typeow analysis can be used to detect type tests which will always evaluate true at runtime. At the same time, and at no extra cost, type tests which are bound to fail at runtime may be detected. Incorrect programs can be found when carrying out the tests for type guards. As suggested previously in Section 4.3, the manifest type following a type test for Typeof(var) > T is the lower of M and T. If M > T the test is redundant and may be removed, otherwise the test must remain. If T and M are incommensurate, then the new manifest type is, the error type dened in section 4.1. In this case the program is in error, and will certainly fail at runtime if control ever reaches the test. As an example, consider the following fragment of code, referring to the type hierarchy in Figure 1, where exp is of type Expr and unary is of type Unary{... exp := unary; exp(binop).leftexp;... This code is statically correct. In the rst statement exp is assigned a variable which has a type which is an extension of the static type of exp. The second statement contains a type guard which tests that exp is of some type which is an extension of its static type. However, it is obvious that the type guard in the second statement will fail at runtime, as exp is dynamically of type Unary, and Binop and Unary are roots of non-overlapping clades 3. Runtime errors also occur in Oberon-2 if the dynamic type of a record on the left of an assignment is not equal to its static type. This is automatically 3 If we set the initial manifest type of unallocated (NIL) objects to > rather than to the static type, then the same computation will detect programs where the object is not allocated along every path leading to the type guard.

11 the case for record variables, since their type cannot change. For references to records an implicit runtime test must be generated. If it is found during typeow analysis that the manifest type of the record being referenced is not equal to its static type, then a warning can be issued that the program will fail at runtime. Dead code can also be detected in WITH statement options. If the same two comparisons of the manifest type and the option type are carried out as for type guards, for example, M > T n and T n > M, and both fail, then code for that option of the WITH statement will never be executed. Of course, if all the options of a WITH statement are found to be dead code and there is no ELSE clause, then the program is incorrect and must fail at runtime. For example, consider the WITH statement: WITH var : Plus DO... var : BinOp DO... END; If the manifest type of var is Star then the code in the Plus option is dead, whereas if the manifest type of var is Plus then the code in the BinOp option is dead code. If var has the manifest type Unary then the code for both options is dead, and the program will give a runtime error. An ELSE clause added to this WITH statement would prevent the runtime error, if the manifest type were Unary, but the code in the Plus and BinOp options would still be dead. WHILE loops and IF statement branches which are never executed can be found by the same method. This only applies for those statements where the condition is an IS expression. The same tests used for the WITH options are applied to the IS expression to determine if the conditional code will ever be executed. 5 An Implementation of Typeow Analysis We have described the computation of manifest types in terms of manipulation of the control ow graph. However, typeow analysis can be carried out without the need for constructing the control ow graph. Since Oberon-2 is a structured language and only produces a limited number of control ow constructs, it is not necessary to solve the manifest type equations for arbitrary control ow. In fact, the equations may be solved \on the y" during a traversal of the abstract syntax tree of the program. This method is similar to that described by Mossenbock for computing static single assignment form[7]. It is probably possible to carry out typeow analysis during the same traversal which checks static semantic rules. However, our initial implementation of typeow analysis is done during a separate traversal, after the static semantic checks have been completed. To achieve this, each variable descriptor contains a manifest type attribute as well as the expected static type attribute. This attribute is updated during

12 the traversal for assignments, type guards and so on. When a statement is encountered which has diverging control ow (see Figure 4) then as variables are encountered in each of these blocks, a record is kept of the manifest type emerging from the predecessor block. As each divergent path is traversed the M in of modied variables are reset before the traversal of the next path. Referring to Figure 4, this means that before traversing each of blocks 2, 3, 4 and 5 the manifest type is reset to the M out of block 1. At the end of each block the M out of the variable is `collected' so as to be able to compute M in for the successor block. After traversing the rst block with an in edge to the merge block (block 2) the M in is initialised. For subsequent blocks M in is replaced by the lowest common ancestor of the previous M in and the M out on the new in edge. After all predecessor blocks have been traversed, the nal value for M in is known. 5.1 Implementation Details In the analysis so far, it has been assumed that the manifest type out of each block is the same along each edge. However, this is not strictly correct for either WITH statements, or other conditional forms which include an explicit type test. In our formal analysis[6] we introduce type assertions in synthetic blocks placed on edges to regularise the analysis. Here however we may take this information directly into account. The WITH statement serves as a good example of this 4. Figure 7 shows the control ow graph representing the WITH statement in Section 4.4 which has three options and an ELSE clause. Blocks 1, 3 and 5 are the tests for executions of the dierent options and blocks 2,4 and 6 respectively, contain the corresponding statements for each option. Block 7 is the ELSE statements. Because of the semantics of the WITH statement the manifest types along the two out edges from block 1 are not the same. The statements in block 2 are only executed if the test in block 1 evaluates true, that is, WITH var : T 1 DO... Thus on this path we assert that M is T 1. On the path from block 1 to block 3, the manifest type of var is unchanged from M in to block 1. In detail, the steps of the typeow analysis for the WITH statement structure in Figure 7 for a particular variable are as follows{ { block 1 is traversed. This sets the manifest type of Mvar to the type of the rst WITH option { block 2 is traversed. M in for block 8 is set to the current manifest type of the variable Mvar (i.e. M out for block 2) { block 3 is traversed, which sets Mvar to the type of the second WITH option { block 4 is traversed. M in for block 8 is adjusted to the LCA of the interim M in and the M out of block 4 { block 5 is traversed, which sets Mvar to the type of the third WITH option { block 6 is traversed. M in for block 8 is adjusted to the LCA of the interim M in and the M out of block 6 4 For simplicity of exposition, we shall assume that neither dead code nor errors are discovered during typeow analysis in out example.

13 { Mvar is reset to M in for block 1. Block 7, which is the block for the ELSE clause is then traversed. Again, M in for block 8 is updated to the LCA of the interim M in and the M out of block 7 { all of the blocks of the WITH statement have now been traversed. The M in of block 8 is now the LCA of its predecessor blocks and analysis may proceed with block 8 Because the control ow produced by each statement is known, the required information about types can be stored as state variables of the recursive traversal procedures. All structures produced by Oberon-2 statements are traversed in a similar manner. An extra step must be included when traversing loop structures. As mentioned earlier, the block(s) in a loop must be traversed twice so that the correct M in to the loop can be computed using the M out of the loop block(s). It is a consequence of the \loop breaking rule" that the types out of a loop can be correctly computed without knowing the manifest types on the back edge. Once the M out values are known, the correct M in may be computed and the necessity of any type tests evaluated. A rst traversal is performed, without removing any apparently redundant type tests. The M out value obtained is then used to calculate the nal M in value for a second traversal of the loop. Since the correct M in value is known during the second traversal, redundant type tests may be removed on this pass. In the case of nested loops, the same reasoning shows that the statements of the innermost loop may be traversed a number of times equal to the loop nesting-level plus one. 5.2 Future Work Our initial implementation of typeow analysis computes manifest types on a procedure basis. There is no inter-procedural analysis. It also deals only with entire variables, and does not track elds of objects. For example, for the designator{ exp(binop).leftexp(unaryop).op the variable exp is tracked, and the BinOp type guard will be checked for redundancy and thus might be removed. However, the eld leftexp, which also is a record, is not tracked and the Unary type guard is not redundancy checked. This represents a limitation of our current descriptor structure. The implementation is currently being extended to track elds of records. Inter-procedural typeow analysis should be able to be carried out, at least for procedures local to the module being compiled. This can be done by type traversing a procedure before traversing any code which calls that procedure. The manifest type of formal parameters at procedure exit can then be used to rene manifest type information in the caller. For each called procedure an attribute indicates if the formal is modied within the procedure. If a formal parameter is agged as type modied, the manifest type of the corresponding

14 actual parameter can be updated to the manifest type already calculated for the formal at exit. If the formal parameter is not so agged, then the manifest type of the actual will be the lower of the previous value and the manifest type of the formal at exit. 6 Summary The typeow analysis outlined in this paper has been implemented and incorporated into an Oberon-2 compiler. Some preliminary testing has been carried out, and removal of redundant type tests as well as the incorrect program detection have been achieved. References 1. N. Wirth: Type Extension, ACM Trans. on Prog. Lang. and Systems Vol 10, No 2 pp 204{214, April N. Wirth: The Programming Language Oberon, Software Practice and Experience, Vol 18, No 7, pp 671{690, July H. Mossenbock and N. Wirth: The Programming Language Oberon-2, Computer Science Report 160, ETH Zurich, May N. H. Cohen: Type-Extension Type Tests Can Be Performed in Constant Time, (Technical Correspondence), ACM Trans. on Prog. Lang. and Systems, Vol 13, No 4, pp 626{629, October J. Asuru: Optimisation of Array Subscript Range Checks, ACM Letters on Prog. Lang. and Systems, Vol 1, No 2, June J. Gough and D. Corney: Typeow Analysis by Clade Algebra, Information Technology Report 9/93, QUT Brisbane, July 1993, (preprint) 7. H. Mossenbock: private communication March J. Palsberg and M. Schwartzbach: Static Typing for Object-Oriented Programming, To appear in Science of Computer Programming. 9. N. Oxhj, J. Palsberg and M. Schwartzbach: Making Type Inference Practical, ECOOP '92, Lecture Notes in Computer Science, Vol 615, Springer Verlag, This article was processed using the LaT E X macro package with LLNCS style

A taxonomy of race. D. P. Helmbold, C. E. McDowell. September 28, University of California, Santa Cruz. Santa Cruz, CA

A taxonomy of race. D. P. Helmbold, C. E. McDowell. September 28, University of California, Santa Cruz. Santa Cruz, CA A taxonomy of race conditions. D. P. Helmbold, C. E. McDowell UCSC-CRL-94-34 September 28, 1994 Board of Studies in Computer and Information Sciences University of California, Santa Cruz Santa Cruz, CA

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Joint Entity Resolution

Joint Entity Resolution Joint Entity Resolution Steven Euijong Whang, Hector Garcia-Molina Computer Science Department, Stanford University 353 Serra Mall, Stanford, CA 94305, USA {swhang, hector}@cs.stanford.edu No Institute

More information

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

Worst-case running time for RANDOMIZED-SELECT

Worst-case running time for RANDOMIZED-SELECT Worst-case running time for RANDOMIZED-SELECT is ), even to nd the minimum The algorithm has a linear expected running time, though, and because it is randomized, no particular input elicits the worst-case

More information

The Compositional C++ Language. Denition. Abstract. This document gives a concise denition of the syntax and semantics

The Compositional C++ Language. Denition. Abstract. This document gives a concise denition of the syntax and semantics The Compositional C++ Language Denition Peter Carlin Mani Chandy Carl Kesselman March 12, 1993 Revision 0.95 3/12/93, Comments welcome. Abstract This document gives a concise denition of the syntax and

More information

Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of C

Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of C Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of California, San Diego CA 92093{0114, USA Abstract. We

More information

Compiler Construction

Compiler Construction Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Recap: Static Data Structures Outline of Lecture 18 Recap:

More information

Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization

Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES (2018-19) (ODD) Code Optimization Prof. Jonita Roman Date: 30/06/2018 Time: 9:45 to 10:45 Venue: MCA

More information

proc {Produce State Out} local State2 Out2 in State2 = State + 1 Out = State Out2 {Produce State2 Out2}

proc {Produce State Out} local State2 Out2 in State2 = State + 1 Out = State Out2 {Produce State2 Out2} Laziness and Declarative Concurrency Raphael Collet Universite Catholique de Louvain, B-1348 Louvain-la-Neuve, Belgium raph@info.ucl.ac.be May 7, 2004 Abstract Concurrency and distribution in a programming

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Functional Programming. Pure Functional Programming

Functional Programming. Pure Functional Programming Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

More information

Single-Pass Generation of Static Single Assignment Form for Structured Languages

Single-Pass Generation of Static Single Assignment Form for Structured Languages 1 Single-Pass Generation of Static Single Assignment Form for Structured Languages MARC M. BRANDIS and HANSPETER MÖSSENBÖCK ETH Zürich, Institute for Computer Systems Over the last few years, static single

More information

Structure of Abstract Syntax trees for Colored Nets in PNML

Structure of Abstract Syntax trees for Colored Nets in PNML Structure of Abstract Syntax trees for Colored Nets in PNML F. Kordon & L. Petrucci Fabrice.Kordon@lip6.fr Laure.Petrucci@lipn.univ-paris13.fr version 0.2 (draft) June 26, 2004 Abstract Formalising the

More information

DRAFT for FINAL VERSION. Accepted for CACSD'97, Gent, Belgium, April 1997 IMPLEMENTATION ASPECTS OF THE PLC STANDARD IEC

DRAFT for FINAL VERSION. Accepted for CACSD'97, Gent, Belgium, April 1997 IMPLEMENTATION ASPECTS OF THE PLC STANDARD IEC DRAFT for FINAL VERSION. Accepted for CACSD'97, Gent, Belgium, 28-3 April 1997 IMPLEMENTATION ASPECTS OF THE PLC STANDARD IEC 1131-3 Martin hman Stefan Johansson Karl-Erik rzen Department of Automatic

More information

such internal data dependencies can be formally specied. A possible approach to specify

such internal data dependencies can be formally specied. A possible approach to specify Chapter 6 Specication and generation of valid data unit instantiations In this chapter, we discuss the problem of generating valid data unit instantiations. As valid data unit instantiations must adhere

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2002 Vol. 1, No. 2, July-August 2002 The Theory of Classification Part 2: The Scratch-Built

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

THE IMPLEMENTATION OF A DISTRIBUTED FILE SYSTEM SUPPORTING THE PARALLEL WORLD MODEL. Jun Sun, Yasushi Shinjo and Kozo Itano

THE IMPLEMENTATION OF A DISTRIBUTED FILE SYSTEM SUPPORTING THE PARALLEL WORLD MODEL. Jun Sun, Yasushi Shinjo and Kozo Itano THE IMPLEMENTATION OF A DISTRIBUTED FILE SYSTEM SUPPORTING THE PARALLEL WORLD MODEL Jun Sun, Yasushi Shinjo and Kozo Itano Institute of Information Sciences and Electronics University of Tsukuba Tsukuba,

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information

A Parallel Intermediate Representation based on. Lambda Expressions. Timothy A. Budd. Oregon State University. Corvallis, Oregon.

A Parallel Intermediate Representation based on. Lambda Expressions. Timothy A. Budd. Oregon State University. Corvallis, Oregon. A Parallel Intermediate Representation based on Lambda Expressions Timothy A. Budd Department of Computer Science Oregon State University Corvallis, Oregon 97331 budd@cs.orst.edu September 20, 1994 Abstract

More information

Compiler Construction

Compiler Construction Compiler Construction Lecture 18: Code Generation V (Implementation of Dynamic Data Structures) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/

More information

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments Programming Languages Third Edition Chapter 10 Control II Procedures and Environments Objectives Understand the nature of procedure definition and activation Understand procedure semantics Learn parameter-passing

More information

This book is licensed under a Creative Commons Attribution 3.0 License

This book is licensed under a Creative Commons Attribution 3.0 License 6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars

More information

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) January 11, 2018 Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 In this lecture

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

(Not Quite) Minijava

(Not Quite) Minijava (Not Quite) Minijava CMCS22620, Spring 2004 April 5, 2004 1 Syntax program mainclass classdecl mainclass class identifier { public static void main ( String [] identifier ) block } classdecl class identifier

More information

(Refer Slide Time: 4:00)

(Refer Slide Time: 4:00) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional

More information

Example. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; :

Example. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; : Runtime Environment Relationship between names and data objects (of target machine) Allocation & de-allocation is managed by run time support package Each execution of a procedure is an activation of the

More information

The SPL Programming Language Reference Manual

The SPL Programming Language Reference Manual The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming

More information

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN NOTES ON OBJECT-ORIENTED MODELING AND DESIGN Stephen W. Clyde Brigham Young University Provo, UT 86402 Abstract: A review of the Object Modeling Technique (OMT) is presented. OMT is an object-oriented

More information

UNIT 3

UNIT 3 UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment

More information

Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.

Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996. References: Topic IV Block-structured procedural languages Algol and Pascal Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapter 5 of Programming languages: Concepts

More information

Lecture Notes on Liveness Analysis

Lecture Notes on Liveness Analysis Lecture Notes on Liveness Analysis 15-411: Compiler Design Frank Pfenning André Platzer Lecture 4 1 Introduction We will see different kinds of program analyses in the course, most of them for the purpose

More information

Software Testing. 1. Testing is the process of demonstrating that errors are not present.

Software Testing. 1. Testing is the process of demonstrating that errors are not present. What is Testing? Software Testing Many people understand many definitions of testing :. Testing is the process of demonstrating that errors are not present.. The purpose of testing is to show that a program

More information

Topic IV. Block-structured procedural languages Algol and Pascal. References:

Topic IV. Block-structured procedural languages Algol and Pascal. References: References: Topic IV Block-structured procedural languages Algol and Pascal Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapters 10( 2) and 11( 1) of Programming

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

ICC++ Language Denition. Andrew A. Chien and Uday S. Reddy 1. May 25, 1995

ICC++ Language Denition. Andrew A. Chien and Uday S. Reddy 1. May 25, 1995 ICC++ Language Denition Andrew A. Chien and Uday S. Reddy 1 May 25, 1995 Preface ICC++ is a new dialect of C++ designed to support the writing of both sequential and parallel programs. Because of the signicant

More information

Persistent Oberon Language Specification

Persistent Oberon Language Specification Persistent Oberon Language Specification Luc Bläser Institute of Computer Systems ETH Zurich, Switzerland blaeser@inf.ethz.ch The programming language Persistent Oberon is an extension of Active Oberon

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

M.Ward. Centre for Software Maintenance. University of Durham. July 16, Abstract

M.Ward. Centre for Software Maintenance. University of Durham. July 16, Abstract Transforming a Program into a Specication M.Ward Centre for Software Maintenance School of Engineering and Applied Science University of Durham July 16, 1993 Abstract There has been much research in recent

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

2.2 Syntax Definition

2.2 Syntax Definition 42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions

More information

Lecture 9 - Matrix Multiplication Equivalences and Spectral Graph Theory 1

Lecture 9 - Matrix Multiplication Equivalences and Spectral Graph Theory 1 CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanfordedu) February 6, 2018 Lecture 9 - Matrix Multiplication Equivalences and Spectral Graph Theory 1 In the

More information

Algebraic Properties of CSP Model Operators? Y.C. Law and J.H.M. Lee. The Chinese University of Hong Kong.

Algebraic Properties of CSP Model Operators? Y.C. Law and J.H.M. Lee. The Chinese University of Hong Kong. Algebraic Properties of CSP Model Operators? Y.C. Law and J.H.M. Lee Department of Computer Science and Engineering The Chinese University of Hong Kong Shatin, N.T., Hong Kong SAR, China fyclaw,jleeg@cse.cuhk.edu.hk

More information

Improving the Static Analysis of Loops by Dynamic Partitioning Techniques

Improving the Static Analysis of Loops by Dynamic Partitioning Techniques Improving the Static Analysis of Loops by Dynamic Partitioning echniques Matthieu Martel CEA - Recherche echnologique LIS-DSI-SLA CEA F91191 Gif-Sur-Yvette Cedex, France Matthieu.Martel@cea.fr Abstract

More information

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End

More information

Destination-Driven Code Generation R. Kent Dybvig, Robert Hieb, Tom Butler Computer Science Department Indiana University Bloomington, IN Februa

Destination-Driven Code Generation R. Kent Dybvig, Robert Hieb, Tom Butler Computer Science Department Indiana University Bloomington, IN Februa Destination-Driven Code Generation R. Kent Dybvig, Robert Hieb, Tom Butler dyb@cs.indiana.edu Indiana University Computer Science Department Technical Report #302 February 1990 Destination-Driven Code

More information

when a process of the form if be then p else q is executed and also when an output action is performed. 1. Unnecessary substitution: Let p = c!25 c?x:

when a process of the form if be then p else q is executed and also when an output action is performed. 1. Unnecessary substitution: Let p = c!25 c?x: URL: http://www.elsevier.nl/locate/entcs/volume27.html 7 pages Towards Veried Lazy Implementation of Concurrent Value-Passing Languages (Abstract) Anna Ingolfsdottir (annai@cs.auc.dk) BRICS, Dept. of Computer

More information

Generalized Iteration Space and the. Parallelization of Symbolic Programs. (Extended Abstract) Luddy Harrison. October 15, 1991.

Generalized Iteration Space and the. Parallelization of Symbolic Programs. (Extended Abstract) Luddy Harrison. October 15, 1991. Generalized Iteration Space and the Parallelization of Symbolic Programs (Extended Abstract) Luddy Harrison October 15, 1991 Abstract A large body of literature has developed concerning the automatic parallelization

More information

Incremental Flow Analysis. Andreas Krall and Thomas Berger. Institut fur Computersprachen. Technische Universitat Wien. Argentinierstrae 8

Incremental Flow Analysis. Andreas Krall and Thomas Berger. Institut fur Computersprachen. Technische Universitat Wien. Argentinierstrae 8 Incremental Flow Analysis Andreas Krall and Thomas Berger Institut fur Computersprachen Technische Universitat Wien Argentinierstrae 8 A-1040 Wien fandi,tbg@mips.complang.tuwien.ac.at Abstract Abstract

More information

Lecture Notes on Common Subexpression Elimination

Lecture Notes on Common Subexpression Elimination Lecture Notes on Common Subexpression Elimination 15-411: Compiler Design Frank Pfenning Lecture 18 October 29, 2015 1 Introduction Copy propagation allows us to have optimizations with this form: l :

More information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

More information

Control Structures. Outline. In Text: Chapter 8. Control structures Selection. Iteration. Gotos Guarded statements. One-way Two-way Multi-way

Control Structures. Outline. In Text: Chapter 8. Control structures Selection. Iteration. Gotos Guarded statements. One-way Two-way Multi-way Control Structures In Text: Chapter 8 1 Control structures Selection One-way Two-way Multi-way Iteration Counter-controlled Logically-controlled Gotos Guarded statements Outline Chapter 8: Control Structures

More information

Conditional Elimination through Code Duplication

Conditional Elimination through Code Duplication Conditional Elimination through Code Duplication Joachim Breitner May 27, 2011 We propose an optimizing transformation which reduces program runtime at the expense of program size by eliminating conditional

More information

Induction and Semantics in Dafny

Induction and Semantics in Dafny 15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

More information

1 Maximum Independent Set

1 Maximum Independent Set CS 408 Embeddings and MIS Abhiram Ranade In this lecture we will see another application of graph embedding. We will see that certain problems (e.g. maximum independent set, MIS) can be solved fast for

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

CSCE 531, Spring 2015 Final Exam Answer Key

CSCE 531, Spring 2015 Final Exam Answer Key CSCE 531, Spring 2015 Final Exam Answer Key 1. (40 points total) Consider the following grammar with start symbol S : S S S asb S T T T a T cs T ɛ (a) (10 points) Find FIRST(S), FIRST(T ), FOLLOW(S), and

More information

Qualifying Exam in Programming Languages and Compilers

Qualifying Exam in Programming Languages and Compilers Qualifying Exam in Programming Languages and Compilers University of Wisconsin Fall 1991 Instructions This exam contains nine questions, divided into two parts. All students taking the exam should answer

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2003 Vol. 2, No. 6, November-December 2003 UML 2 Activity and Action Models Part 3:

More information

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 Lecture notes for CS 6110 (Spring 09) taught by Andrew Myers at Cornell; edited by Amal Ahmed, Fall 09. 1 Static vs. dynamic scoping The scope of a variable

More information

Finding a winning strategy in variations of Kayles

Finding a winning strategy in variations of Kayles Finding a winning strategy in variations of Kayles Simon Prins ICA-3582809 Utrecht University, The Netherlands July 15, 2015 Abstract Kayles is a two player game played on a graph. The game can be dened

More information

Compiler Construction 2010/2011 Loop Optimizations

Compiler Construction 2010/2011 Loop Optimizations Compiler Construction 2010/2011 Loop Optimizations Peter Thiemann January 25, 2011 Outline 1 Loop Optimizations 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6

More information

Compiler construction

Compiler construction Compiler construction Martin Steffen March 13, 2017 Contents 1 Abstract 1 1.1 Symbol tables. 1 1.1.1 Introduction 1 1.1.2 Symbol table design and interface.. 2 1.1.3 Implementing symbol tables 3 1.1.4

More information

Type Checking and Type Inference

Type Checking and Type Inference Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled

More information

perspective, logic programs do have a notion of control ow, and the in terms of the central control ow the program embodies.

perspective, logic programs do have a notion of control ow, and the in terms of the central control ow the program embodies. Projections of Logic Programs Using Symbol Mappings Ashish Jain Department of Computer Engineering and Science Case Western Reserve University Cleveland, OH 44106 USA email: jain@ces.cwru.edu Abstract

More information

CMa simple C Abstract Machine

CMa simple C Abstract Machine CMa simple C Abstract Machine CMa architecture An abstract machine has set of instructions which can be executed in an abstract hardware. The abstract hardware may be seen as a collection of certain data

More information

On Meaning Preservation of a Calculus of Records

On Meaning Preservation of a Calculus of Records On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract

More information

Optimizing Finite Automata

Optimizing Finite Automata Optimizing Finite Automata We can improve the DFA created by MakeDeterministic. Sometimes a DFA will have more states than necessary. For every DFA there is a unique smallest equivalent DFA (fewest states

More information

Parametric Polymorphism for Java: A Reflective Approach

Parametric Polymorphism for Java: A Reflective Approach Parametric Polymorphism for Java: A Reflective Approach By Jose H. Solorzano and Suad Alagic Presented by Matt Miller February 20, 2003 Outline Motivation Key Contributions Background Parametric Polymorphism

More information

Algorithmic "imperative" language

Algorithmic imperative language Algorithmic "imperative" language Undergraduate years Epita November 2014 The aim of this document is to introduce breiy the "imperative algorithmic" language used in the courses and tutorials during the

More information

Khoral Research, Inc. Khoros is a powerful, integrated system which allows users to perform a variety

Khoral Research, Inc. Khoros is a powerful, integrated system which allows users to perform a variety Data Parallel Programming with the Khoros Data Services Library Steve Kubica, Thomas Robey, Chris Moorman Khoral Research, Inc. 6200 Indian School Rd. NE Suite 200 Albuquerque, NM 87110 USA E-mail: info@khoral.com

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design i About the Tutorial A compiler translates the codes written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

perform. If more storage is required, more can be added without having to modify the processor (provided that the extra memory is still addressable).

perform. If more storage is required, more can be added without having to modify the processor (provided that the extra memory is still addressable). How to Make Zuse's Z3 a Universal Computer Raul Rojas January 14, 1998 Abstract The computing machine Z3, built by Konrad Zuse between 1938 and 1941, could only execute xed sequences of oating-point arithmetical

More information

Compiler Construction 2016/2017 Loop Optimizations

Compiler Construction 2016/2017 Loop Optimizations Compiler Construction 2016/2017 Loop Optimizations Peter Thiemann January 16, 2017 Outline 1 Loops 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6 Loop Unrolling

More information

The ACK Modula-2 Compiler

The ACK Modula-2 Compiler The ACK Modula-2 Compiler Ceriel J.H. Jacobs Department of Mathematics and Computer Science Vrije Universiteit Amsterdam The Netherlands 1. Introduction This document describes the implementation-specific

More information

9/24/ Hash functions

9/24/ Hash functions 11.3 Hash functions A good hash function satis es (approximately) the assumption of SUH: each key is equally likely to hash to any of the slots, independently of the other keys We typically have no way

More information

Assign auniquecodeto each state to produce a. Given jsj states, needed at least dlog jsje state bits. (minimum width encoding), at most jsj state bits

Assign auniquecodeto each state to produce a. Given jsj states, needed at least dlog jsje state bits. (minimum width encoding), at most jsj state bits State Assignment The problem: Assign auniquecodeto each state to produce a logic level description. Given jsj states, needed at least dlog jsje state bits (minimum width encoding), at most jsj state bits

More information

IC Language Specification

IC Language Specification CS 301 Spring 2016 IC Language Specification The IC Language For the implementation project, you will build a compiler for an object-oriented language called IC (for Irish Coffee 1 ), which is essentially

More information

10.3 Recursive Programming in Datalog. While relational algebra can express many useful operations on relations, there

10.3 Recursive Programming in Datalog. While relational algebra can express many useful operations on relations, there 1 10.3 Recursive Programming in Datalog While relational algebra can express many useful operations on relations, there are some computations that cannot be written as an expression of relational algebra.

More information

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Semantics via Syntax. f (4) = if define f (x) =2 x + 55. 1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)

More information

Acknowledgments 2

Acknowledgments 2 Program Slicing: An Application of Object-oriented Program Dependency Graphs Anand Krishnaswamy Dept. of Computer Science Clemson University Clemson, SC 29634-1906 anandk@cs.clemson.edu Abstract A considerable

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

Data Types The ML Type System

Data Types The ML Type System 7 Data Types 7.2.4 The ML Type System The following is an ML version of the tail-recursive Fibonacci function introduced Fibonacci function in ML in Section 6.6.1: EXAMPLE 7.96 1. fun fib (n) = 2. let

More information

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics. Oscar Nierstrasz 7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

More information

A Boolean Expression. Reachability Analysis or Bisimulation. Equation Solver. Boolean. equations.

A Boolean Expression. Reachability Analysis or Bisimulation. Equation Solver. Boolean. equations. A Framework for Embedded Real-time System Design? Jin-Young Choi 1, Hee-Hwan Kwak 2, and Insup Lee 2 1 Department of Computer Science and Engineering, Korea Univerity choi@formal.korea.ac.kr 2 Department

More information

Modern Programming Languages. Lecture LISP Programming Language An Introduction

Modern Programming Languages. Lecture LISP Programming Language An Introduction Modern Programming Languages Lecture 18-21 LISP Programming Language An Introduction 72 Functional Programming Paradigm and LISP Functional programming is a style of programming that emphasizes the evaluation

More information

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token. Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 7 Espresso Language Definition Wednesday, September 4 The project for the 18-unit

More information

Part I Logic programming paradigm

Part I Logic programming paradigm Part I Logic programming paradigm 1 Logic programming and pure Prolog 1.1 Introduction 3 1.2 Syntax 4 1.3 The meaning of a program 7 1.4 Computing with equations 9 1.5 Prolog: the first steps 15 1.6 Two

More information

KeyNote: Trust Management for Public-Key. 180 Park Avenue. Florham Park, NJ USA.

KeyNote: Trust Management for Public-Key. 180 Park Avenue. Florham Park, NJ USA. KeyNote: Trust Management for Public-Key Infrastructures Matt Blaze 1 Joan Feigenbaum 1 Angelos D. Keromytis 2 1 AT&T Labs { Research 180 Park Avenue Florham Park, NJ 07932 USA fmab,jfg@research.att.com

More information

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1) Topics Data Structures and Information Systems Part 1: Data Structures Michele Zito Lecture 3: Arrays (1) Data structure definition: arrays. Java arrays creation access Primitive types and reference types

More information