On a New Method for Dataow Analysis of Java Virtual Machine Subroutines Masami Hagiya and Akihiko Tozawa Department of Information Science, Graduate S

Size: px
Start display at page:

Download "On a New Method for Dataow Analysis of Java Virtual Machine Subroutines Masami Hagiya and Akihiko Tozawa Department of Information Science, Graduate S"

Transcription

1 On a New Method for Dataow Analysis of Java Virtual Machine Subroutines Masami Hagiya (corresponding author) and Akihiko Tozawa Department of Information Science, Graduate School of Science, University of Tokyo, Hongo, Bunkyo-ku, Tokyo , JAPAN tel: fax: hagiya@is.s.u-tokyo.ac.jp Abstract. The bytecode verier of Java Virtual Machine, which statically checks type safety of Java bytecode, is a basis of the security model of Java for guaranteeing safety of mobile code sent from an untrusted remote host. However, the type system for Java bytecode has some technical problems, one of which is in the handling of subroutines. Based on the work of Stata and Abadi and that of Qian, this paper presents yet another type system for subroutines of Java Virtual Machine. Our type system includes types of the form last(x). A value whose type is last(x) is the same as that of the x-th variable of the caller of the subroutine. In addition, we represent the type of a return address by the form return(n), which means returning to the n-th outer caller. By virtue of these types, we can analyze instructions purely in terms of types. As a result, the correctness proof of bytecode verication becomes extremely simple. Moreover, for some programs, our method turns out to be more powerful than existing ones. In particular, our method has no restrictions on the number of entries and exits of a subroutine. Keywords: Java, virtual machine, bytecode verication, dataow analysis, type system

2 On a New Method for Dataow Analysis of Java Virtual Machine Subroutines Masami Hagiya and Akihiko Tozawa Department of Information Science, Graduate School of Science, University of Tokyo fhagiya,milesg@is.s.u-tokyo.ac.jp Abstract. The bytecode verier of Java Virtual Machine, which statically checks type safety of Java bytecode, is a basis of the security model of Java for guaranteeing safety of mobile code sent from an untrusted remote host. However, the type system for Java bytecode has some technical problems, one of which is in the handling of subroutines. Based on the work of Stata and Abadi and that of Qian, this paper presents yet another type system for subroutines of Java Virtual Machine. Our type system includes types of the form last(x). A value whose type is last(x) is the same as that of the x-th variable of the caller of the subroutine. In addition, we represent the type of a return address by the form return(n), which means returning to the n-th outer caller. By virtue of these types, we can analyze instructions purely in terms of types. As a result, the correctness proof of bytecode verication becomes extremely simple. Moreover, for some programs, our method turns out to be more powerful than existing ones. In particular, our method has no restrictions on the number of entries and exits of a subroutine. 1 Introduction One of the contributions of Java is in its bytecode verier, which statically checks type safety of bytecode for JVM (Java Virtual Machine) prior to execution. Thanks to the bytecode verier, bytecode sent from an untrusted remote host can be executed without the danger of causing type errors and destroying the entire security model of Java, even when source code is not available. Verifying type safety of bytecode (or native code) seems to be a new research area that is not only technically interesting but also practically important due to availability of remote binary code in web browsers and other applications. Much eort has been made for guaranteeing security of Java programs including type safety of bytecode: { Security model for Java applets: The security model for Java applets is said to consist of three prongs: the bytecode verier, the applet class loader and the security manager [9]. In this model, the bytecode verier plays the most fundamental role, on which the other two prongs are based. If the bytecode verier is cheated, the other two also become ineective. The applet

3 class loader dynamically loads classes into an applet. The security manager explicitly controls accesses from within applets. { Type safety of source code: The type safety of Java programs has been proved, either formally (using a theorem proving assistant), or rigorously (but not formally) [3, 4, 17, 12]. This means that a program that has passed static type checking is guaranteed to cause no type errors while it is running. For example, Nipkow and von Oheimb formally proved the type safety of a subset of Java, called Bali, using Isabelle/HOL [12]. { Safety of class loading: Java allows loading classes lazily, i.e., only when classes are actually accessed. In order to support various loading disciplines, Java allows programmers to dene their own class loaders. This has opened one of the security holes of Java [14]. To avoid such a security hole, Dean formalized part of the class loader functionality and formally proved its correctness using PVS [2]. Drossopoulou et al. recently formulated the concept of binary compatibility on which class loading is based [18]!%Goldberg's main concern is also class loading, though he copes with bytecode verication [5]. { Type safety of bytecode: The bytecode verier statically checks type safety of Java bytecode. If the bytecode verier accepts incorrectly typed bytecode, it will break the entire security model of Java. It guarantees that no type error occurs at each instruction by performing dataow analysis on bytecode. Besides researches on each aspect of security as mentioned above, there are some on-going projects, which are developing network programming environments that are more secure than existing ones [7, 15]. This paper is concerning bytecode verication. Since it is a basis of the entire security model of Java, it is desirable to rigorously prove that if a bytecode program has passed bytecode verication, it never causes a runtime type error. However, the specication of the bytecode verier is written in an ambiguous natural language (i.e., English) [8]. In order to be able to show the correctness of the bytecode verier, one has to begin with formally specifying the operational semantics of the virtual machine and then give the formal specication of the bytecode verier. Cohen described the operational semantics of JVM in the input language of ACL2 (the most recent descendant of Boyer and Moore's prover) [1]. The operational semantics dened there is called defensive and detects type errors each time an instruction is executed. Therefore, it is supposed that this work is aimed at proving the correctness of the bytecode verier. Qian rigorously dened the operational semantics of a subset of JVM and formulated the bytecode verier as a type system [13]. He then succeeded in proving the correctness of the bytecode verier, though not completely. Bytecode verication of JVM has some technical challenges. One is that of handling object initialization, where objects created but not initialized yet may open a security hole. In Qian's work, much attention is paid to the handling of object initialization. Another is that of handling polymorphism of subroutines. This paper is on this issue. Inside a JVM subroutine, which is a result of compiling a finally

4 clause in a try statement, local variables may have values of dierent types depending on a caller of the subroutine. This is a kind of polymorphism. For investigating analysis of JVM subroutines, Stata and Abadi dened a type system for a small subset of JVM and proved its correctness with respect to the operational semantics of the subset [16]. Qian's system is similar to Stata and Abadi's in the handling of subroutines [13]. Both the systems faithfully follow the specication of the bytecode verier, and make use of the information on which variables are accessed or modied in a subroutine. Those variables that are not accessed or modied are simply ignored during analysis of the subroutine. This paper takes a dierent approach. We introduce types of the form last(x). A value whose type is last(x) is the same as that of the x-th variable of the caller of the subroutine. In addition, we represent the type of a return address by the form return(n), which means returning to the n-th outer caller. Our approach has the following advantages. { By virtue of last and return types, we can analyze instructions purely in terms of types. As a result, the correctness proof of bytecode verication becomes extremely simple. We do not need separate analysis on variable access or modication. { For some programs (unfortunately, not those produced by the Java compiler), our method turns out to be more powerful than existing ones. In particular, our method has no restrictions on the number of entries and exits of a subroutine. Due to these advantages, we hope that our method can be modied and applied to analysis of other kinds of bytecode or native code [10, 11]. This paper is organized as follows. In the next section, we explain more on JVM subroutines and our approach to bytecode verication. In Section 3, a subset of JVM, which is similar to Stata and Abadi's, is dened. In Section 4, our method for analysis of bytecode is described and its correctness is shown. In Section 5, issues on implementation are briey discussed. Section 6 is for concluding remark. 2 Analysis of Subroutines JVM is a classical virtual machine consisting of { an array for storing values of local variables, { a stack for placing arguments and results of operators, called the operand stack, { a heap for storing method code and object bodies, and { a stack for frames. To allow checking type safety of bytecode, it prepares dierent instructions for the same operation depending on the type of the operands. For example, it has the instruction istore for storing integers and fstore for storing oating-point numbers.

5 JVM subroutines are mainly used for compiling finally clauses of try statements of Java. Notice that subroutine calls are completely dierent from method calls. A subroutine is locally dened inside a method. In contrast to methods, it is not allowed to call subroutines recursively. In this paper, we dene a virtual machine based on JVML0, which was formulated by State and Abadi for investigating analysis of JVM subroutines. Subroutines are called by instructions of the following form. jsr(l) An instruction of this form pushes the address of its next instruction (i.e., the return address) onto the operand stack and jumps to the subroutine L. Subroutines are usually dened as follows. L : store(x). ret(x) store(x) pops a value from the operand stack and stores it in the x-th local variable. ret(x) is an instruction for jumping to the address stored in the x-th local variable. Note that, in contrast to JVM, our virtual machine has only one instruction for the store operation. Subroutines in JVM have increased the diculty of bytecode verication by the following reasons. { The return address of ret(x) can only be determined after values of local variables are analyzed by the bytecode verier. On the other hand, return addresses aect control ow and analysis of local variables. { In some situations, a subroutine does not return to the immediate caller but returns to an outer caller, such as the caller of the caller. { Inside a subroutine, local variables may have values of dierent types depending on a caller of the subroutine. In this paper, to cope with the last problem, we introduce types of the form last(x). For a value, to have this type means have to the same value as that of the x-th local variable in the caller of a subroutine. As an example, let us consider the following program. const0 store(1) 2 : jsr(7) constnull store(1) 5 : jsr(7) halt

6 7 : store(0) load(1) store(2) ret(0) Subroutine 7 is called from two callers (2 and 5). The return address is stored in variable 0 (the 0-th local variable). The value of variable 1 is an integer when the subroutine is called from caller 2, and is an object pointer when called from caller 5. This is a typical case in which a subroutine is polymorphic. In this program, the value of variable 1 is copied to variable 2. As JVM has dierent store instructions depending on the type of the operand, the above program is impossible under JVM. However, even if JVM allows the untyped store instruction, the bytecode verier of JVM signals an error for the above program, because it always assigns a unique type for a variable accessed in a subroutine. According to the specication of JVM [8], { Each instruction and each jsr targets needed to reach that instruction, a bit vector is maintained of all local variables accessed or modied since the execution of the jsr instruction. { For any local variable for which the bit vector (constructed above) indicates that the subroutine has accessed or modied, use the type of the local variable at the time of the ret. { For other local variables, use the type of the local variable before the jsr instruction. The work of Stata and Abadi as well as that of Qian faithfully follows this specication. For each subroutine, it is recorded which local variables are accessed or modied in it. Those variables that are not accessed or modied are simply ignored during analysis of the subroutine. By the method of this paper, to variable 1 in subroutine 7 is assigned a type of the form last(1). This means that a value in it is passed from variable 1 of the caller. This type is propagated through instructions in the subroutine. In particular, by the instruction store(2), the type of variable 2 becomes last(1). This information is used when the control returns from the subroutine to the caller. In this way, polymorphism of local variables in a subroutine is expressed by types of the form last(x). In our method, return addresses have types of the form return(n). A type of the form return(n) means to return to the n-th outer caller. For example, the address returning to the immediate caller has type return(1), while the address returning to the caller of the caller has type return(2). In Stata and Abadi's work (and similarly in Qian's work), return addresses have types of the form (ret-from L), where L is the address of the subroutine, from which the callers of the subroutines are obtained. In our analysis, the callers are obtained from the set of histories assigned to each instruction (cf. Section 4.3).

7 3 Virtual Machine 3.1 Values A value is a return address or an integer or an object pointer. We can easily add other kinds of values, such as that of oating point number. In the following formal treatment of the operational semantics of the virtual machine, a return address has the constructor retaddr, an integer the constructor intval, and an object pointer the constructor objval. They all take an integer as an argument. 3.2 Instructions A bytecode program is a list of instructions. An instruction takes one of the following formats. jsr(l) (L: subroutine address) ret(x) (x: variable index) load(x) (x: variable index) store(x) (x: variable index) const0 constnull inc(x) (x: variable index) if0(l) (L: branch address) ifnull(l) (L: branch address) halt Each mnemonic is considered as a constructor of instructions. Some of the mnemonics takes a nonnegative integer x or L as an operand. 3.3 Operational Semantics The virtual machine consists of { the program, which is a list of instructions and denoted by P, { the program counter, which is an index to P, { the local variables, where the list of values of the local variables is denoted by f, and { the operand stack, denoted by s. Let us use the notation l[i] for extracting the i-th element of list l, where the rst element of l has the index 0. The i-th instruction of the program P is denoted by P [i]. The value of the x-th local variable is denoted by f[x]. The p-th element of the operand stack s is denoted by s[p], where s[0] denotes the top element of s. As in the work by Stata and Abadi, the operational semantics of the virtual machine is dened as a transition relation between triples of the form hi; f; si, where i is the program counter, i.e., the index to the program P, f the value

8 list of the local variables, and s the operand stack. While the length of s may change during execution of the virtual machine, the length of f, i.e., the number of local variables is unchanged. The program P, of course, never changes during execution. The transition relation is dened as follows. { If P [i] = jsr(l), then hi; f; si! hl; f; retaddr(i + 1)::si: The return address retaddr(i + 1) is pushed onto the operand stack. The operator :: is the cons operator for lists. { If P [i] = ret(x) and f[x] = retaddr(j + 1), then { If P [i] = load(x), then { If P [i] = store(x), then hi; f; si! hj + 1; f; si: hi; f; si! hi + 1; f; f[x]::si: hi; f; v::si! hi + 1; f[x 7! v]; si: The notation f[x 7! v] means a list whose element is the same as that of f except for the x-th element, which is set to v. { If P [i] = const0, then { If P [i] = constnull, then hi; f; si! hi + 1; intval(0)::si: hi; f; si! hi + 1; objval(0)::si: { If P [i] = inc(x) and f[x] = intval(k), then { If P [i] = if0(l), then hi; f; si! hi + 1; f[x 7! intval(k + 1)]; si: If P [i] = if0(l) and k 6= 0, then { If P [i] = ifnull(l), then If P [i] = ifnull(l) and k 6= 0, then hi; f; intval(0)::si! hl; f; si: hi; f; intval(k)::si! hi + 1; f; si: hi; f; objval(0)::si! hl; f; si: hi; f; objval(k)::si! hi + 1; f; si:

9 The transition relation! is considered as the least relation satisfying the above conditions. The relation is dened so that when a type error occurs, no transition is dened. This means that to show type safety is to show that a transition sequence stops only at the halt instruction. For proving the correctness of our bytecode analysis, we also need another version of the operational semantics that maintains invocation histories of subroutines. This semantics corresponds to the structured dynamic semantics of Stata and Abadi. The transition relation is now dened for quadruples of the form hi; f; s; hi, where the last component h is an invocation history of subroutines. It is a list of addresses of callers of subroutines. This component is only changed by the jsr and ret instructions. { If P [i] = jsr(l), then hi; f; s; hi! hl; f; retaddr(i + 1)::s; i::hi: Note that the address i of the caller of the subroutine is pushed onto the invocation history. { If P [i] = ret(x), f[x] = retaddr(j + 1) and h = h 00, where j does not appear in h 0, then hi; f; s; hi! hj + 1; f; s; h 00 i: The is the append operator for lists. For other instructions, the invocation histories before and after transition are the same. As for the two transition relations, we immediately have the following proposition. Proposition 1: If hi; f; s; hi! hi 0 ; f 0 ; s 0 ; h 0 i, then hi; f; si! hi 0 ; f 0 ; s 0 i. 4 Analysis 4.1 Types Types in our analysis are among the following syntactic entities: >;? (top and bottom) INT; OBJ; (basic types) return(n) (n: caller level) last(x) (x: variable index) A type is >,?, a basic type, a return type, or a last type. In this paper, we assume as basic types INT, the type of integers, and OBJ, the type of object pointers. It is easy to add other basic types, such as that of oating point numbers.

10 return types and last types are only meaningful inside a subroutine. A return type is the type of a return address. For positive integer n, return(n) denotes the type of the address for returning to the n-th outer caller. For example, return(1) denotes the type of the address for returning to the direct caller of the subroutine, and return(2) the type of the address for returning to the caller of the caller. A last type means that a value is passed from the caller of the subroutine. For nonnegative integer x, last(x) denotes the type of a value that was stored in the x-th local variable of the caller. A value can have this type only when it is exactly the same as the value of the x-th local variable when the subroutine was called. 4.2 Order among Types We dene the order among types as follows. > > INT >? > > OBJ >? > > return(n) >? > > last(x) >? Since we do not distinguish object pointers by their classes in this paper, the order is at, with > and? as the top and bottom elements. This order is extended to lists of types. For type lists t 1 and t 2, t 1 > t 2 holds if and only if t 1 and t 2 are of the same length and t 1 [i] > t 2 [i] holds for any i ranging over the indices for the lists. 4.3 Target of Analysis The target of our bytecode analysis is to obtain the following pieces of information for the i-th instruction of the given program P. F i S i H i F i is a type list. F i [x] describes the type of f[x], i.e., the value of the x-th local variable of the virtual machine. S i is a also type list. Each element of S i describes the type of the corresponding element of the operand stack of the virtual machine. Both F i and S i describe the types of the components of the virtual machine just before the i-th instruction is executed. H i is a set of invocation histories for the i-th instruction. F, S and H should follow a rule that is dened for each kind of P [i]. The rule says that certain conditions must be satised before and after the execution of P [i]. Rule for jsr) If h 2 H i and P [i] = jsr(l), then the following conditions must be satised. { 0 L < jp j.

11 { For each variable index y, either F L [y] return(n + 1) (if F i [y] = return(n)), and F L [y] F i [y] (if F i [y] is neither return nor last) or F L [y] last(y) (even if F i [y] is last). { js L j = js i j + 1, where jlj denotes the length of list l. { S L [0] return(1). { For each index p, where 0 p < js i j, S i [p] is not last, S L [p + 1] S i [p] (if S i [p] is not return), and S L [p + 1] return(n + 1) (if S i [p] = return(n)). { i does not appear in h. (Recursion is not allowed.) { i::h 2 H L. Note that when F i [y] is not last, F L [y] cannot be determined uniquely. We must use some kind of backtracking for implementing our analysis. The following gures show the two possibilities for typing local variables inside a subroutine. In this example, it is assumed that there is only one caller (2) of subroutine 7. The column [F i [0]; F i [1]; F i [2]] shows the types of local variables (before each instruction). i instruction [F i [0]; F i [1]; F i [2]] S i H i 0 const0 [>; >; >] [] f[]g 1 store(1) [>; >; >] [INT] f[]g 2 jsr(7) [>; INT; >] [] f[]g 3 constnull [>; INT; INT] [] f[]g 7 store(0) [>; INT; >] [r(1)] f[2]g 8 load(1) [r(1); INT; >] [] f[2]g 9 store(2) [r(1); INT; >] [INT] f[2]g 10 ret(0) [r(1); INT; INT] [] f[2]g i instruction [F i [0]; F i [1]; F i [2]] S i H i 0 const0 [>; >; >] [] f[]g 1 store(1) [>; >; >] [INT] f[]g 2 jsr(7) [>; INT; >] [] f[]g 3 constnull [>; INT; INT] [] f[]g 7 store(0) [l(0); l(1); l(2)] [r(1)] f[2]g 8 load(1) [r(1); l(1); l(2)] [] f[2]g 9 store(2) [r(1); l(1); l(2)] [l(1)] f[2]g 10 ret(0) [r(1); l(1); l(1)] [] f[2]g

12 Rule for ret) If h 2 H i and P [i] = ret(x), then the following conditions must be satised. { F i [x] = return(n). { h = h 00, where jh 0 j = n? 1. { 0 j + 1 < jp j. { For each variable index y, F j+1 [y] follow last(n; h; F i [y]). { S j+1 follow last(n; h; S i ). { h 00 2 H j+1. follow last is a function for extracting the type of a variable in a caller of a subroutine according to an invocation history. For nonnegative integer n, invocation history h and type t, follow last(n; h; t) is dened as follows. follow last(0; h; t) = t follow last(n + 1; i::h; return(m)) = if m > n + 1 then return(m? n? 1) else > follow last(n + 1; i::h; last(x)) = follow last(n; h; F i [x]) follow last(n + 1; i::h; t) = t (otherwise) follow last is extended to type lists, i.e., follow last(n; h; t) is also dened when t is a type list. Rule for load) If h 2 H i and P [i] = load(x), then the following conditions must be satised. { 0 i + 1 < jp j. { F i+1 F i. { S i+1 F i [x]::s i. { h 2 H i+1. Rule for store) If h 2 H i and P [i] = store(x), then the following conditions must be satised. { 0 i + 1 < jp j. { S i = t::t. { F i+1 F i [x 7! t]. { S i+1 t. { h 2 H i+1. Rule for const0) must be satised. { 0 i + 1 < jp j. { F i+1 F i. { S i+1 INT ::S i. { h 2 H i+1. If h 2 H i and P [i] = const0, then the following conditions

13 The rule for constnull is similar. Rule for inc) If h 2 H i and P [i] = inc(x), then the following conditions must be satised. { 0 i + 1 < jp j. { F i [x] = INT. { F i+1 F i. { S i+1 S i. { h 2 H i+1. Rule for if0) If h 2 H i and P [i] = if0(l), then the following conditions must be satised. { 0 L < jp j. 0 i + 1 < jp j. { S i = INT ::t. { F L F i. F i+1 F i. { S L t. S i+1 t. { h 2 H L. h 2 H i+1. The rule for ifnull is similar. Rule for halt) There is no rule for halt. 4.4 Correctness of Analysis In order to state the correctness of our analysis, we rst introduce the following relation. hv; hi : t v is a value and h is an invocation history. t is a type. By hv; hi : t, we mean that the value v belongs to the type t provided that v appears with the invocation history h. Following is the denition of this relation. { hv; hi : >. { hintval(k); hi : INT. { hobjval(k); hi : OBJ. { If h[n? 1] = j, then hretaddr(j + 1); hi : return(n). { If hv; hi : F i [x], then hv; i::hi : last(x). This denition is also inductive, i.e., hv; hi : t holds if and only if it can be derived only by the above rules. We have two lemmas. Lemma 1: If hv; hi : t and t 0 t, then hv; hi : t 0. Lemma 2: Let h 0 be a prex of h of length n and h 00 be its corresponding sux, i.e., h = h 00 and jh 0 j = n. If hv; hi : t, then hv; h 00 i : follow last(n; h; t). We say that the quadruple hi; f; s; hi is sound with respect to hf; S; Hi and write hi; f; s; hi : hf; S; Hi, if the following conditions are satised.

14 { 0 i < jp j. { For each variable index y, hf[y]; hi : F i [y]. { For each index p for s, hs[p]; hi : S i [p]. { h 2 H i. { h does not have duplication, i.e., no element of h occurs more than once in h. We have the following correctness theorem. It says that if F, S and H follow the rule for each instruction of P, then the soundness is preserved under the transition of quadruples. This means that if the initial quadruple is sound, then quadruples that appear during execution of the virtual machine are always sound. Theorem (correctness of analysis): Assume that F, S and H follow the rule for each instruction of P. If hi; f; s; hi : hf; S; Hi and hi; f; s; hi! hi 0 ; f 0 ; s 0 ; h 0 i, then hi 0 ; f 0 ; s 0 ; h 0 i : hf; S; Hi. The theorem is proved by the case analysis on the kind of P [i]. In this short paper, we only examine the case when P [i] = ret(n). Assume that hi; f; s; hi : hf; S; Hi and hi; f; s; hi! hi 0 ; f 0 ; s 0 ; h 0 i. Since F, S and H follow the rule for ret, the following facts hold. (i) F i [x] = return(n). (ii) h = h 2, where jh 1 j = n? 1. (iii) 0 j + 1 < jp j. (iv) For each variable index y, F j+1 [y] follow last(n; h; F i [y]). (v) S j+1 follow last(n; h; S i ). (vi) h 2 2 H j+1. By (i) and the soundness of hi; f; s; hi, hf[x]; hi : return(n). Therefore, by (ii), f[x] = retaddr(j+1) and i 0 = j+1. Moreover, since h does not have duplication, h 1 does not contain j. This implies that h 0 = h 2. We also have that f 0 = f and s 0 = s. Let us check the conditions for the soundness of hi 0 ; f 0 ; s 0 ; h 0 i = hj+1; f; s; h 2 i. { By (iii), 0 i 0 < jp j. { By (iv), F i 0[y] follow last(n; h; F i [y]). By the soundness of hi; f; s; hi, hf[y]; hi : F i [y]. By Lemma 2, hf[y]; h 0 i : follow last(n; h; F i [y]). Therefore, by Lemma 1, hf[y]; h 0 i : F i 0[y]. { Similarly, by (v), we have that hs[p]; h 0 i : S i 0[p]. { By (vi) and since h 0 = h 2, h 0 2 H i 0. { Finally, since h does not have duplication, h 0 does not have duplication, either. Proposition 2: If hi; f; s; hi : hf; S; Hi and hi; f; si! hi 0 ; f 0 ; s 0 i, then there exists some h 0 such that hi; f; s; hi! hi 0 ; f 0 ; s 0 ; h 0 i.

15 The only case that must be examined is that of ret. Note that h 0 is uniquely determined. The above proposition guarantees that if F, S and H follow the rule for each instruction and the initial quadruple hi; f; s; hi is sound, then the transition sequence starting from the triple hi; f; si can always be lifted to a sequence starting from hi; f; s; hi. This means that the semantics for triples and that for quadruples coincide when F, S and H follow the rule for each instruction. The following nal theorem guarantees type safety. Theorem (type safety): If F, S and H follow the rule for each instruction and the initial quadruple hi; f; s; hi is sound, then a transition sequence stops only at the halt instruction. 4.5 Example Let us abbreviate last(x) and return(n) by l(x) and r(n), respectively. Following is the result of analyzing the example in Section 2. i instruction [F i [0]; F i [1]; F i [2]] S i H i 0 const0 [>; >; >] [] f[]g 1 store(1) [>; >; >] [INT] f[]g 2 jsr(7) [>; INT; >] [] f[]g 3 constnull [>; INT; INT] [] f[]g 4 store(1) [>; INT; INT] [OBJ] f[]g 5 jsr(7) [>; OBJ; INT] [] f[]g 6 halt [>; OBJ; OBJ] [] f[]g 7 store(0) [l(0); l(1); l(2)] [r(1)] f[2]; [5]g 8 load(1) [r(1); l(1); l(2)] [] f[2]; [5]g 9 store(2) [r(1); l(1); l(2)] [l(1)] f[2]; [5]g 10 ret(0) [r(1); l(1); l(1)] [] f[2]; [5]g The rule for ret(0) at 10 is satised because, for [2] 2 H 10, { F 10 [0] = return(1). { [2] = []@[2]@[]. { = 3 < 11. { F 3 [0] = > follow last(1; [2]; F 10 [0]) = follow last(1; [2]; return(1)) = >. { F 3 [1] = INT follow last(1; [2]; F 10 [1]) = follow last(1; [2]; last(1)) = F 2 [1] = INT. { F 3 [2] = INT follow last(1; [2]; F 10 [2]) = follow last(1; [2]; last(1)) = F 2 [1] = INT. { S 3 = []. { [] 2 f[]g = H 3, and similarly for [5] 2 H 10.

16 4.6 Returning to an Outer Caller When P [i] = ret(x) returns to the caller of the caller, for example, F i [x] must be equal to the type return(2): In this case, H i should consist of histories of length at least 2. If [j 1 ; j 2 ; j 3 ; ] is in H i, P [i] returns to i 0 = j 2 +1 and F i 0 should satisfy F i 0[y] follow last(2; [j 1 ; j 2 ; j 3 ; ]; F i [y]): If F i [y] = last(y) and F j1 = last(y), for example, then follow last(2; [j 1 ; j 2 ; j 3 ; ]; F i [y]) = F j2 [y]: This is how information at j 2 (which is a jsr) is propagated to i 0 = j If F i [y] is not last, information at i is propagated. 5 Implementation A dataow analysis is usually implemented by an iterative algorithm. For each instruction, we check if the rule for the instruction is satised by F, S and H. If not, we update F, S and H accordingly, and check the next instruction that is aected by the update. There are two problems for implementing our analysis by such an iterative algorithm. Firstly, the rule for jsr does not uniquely determine F L [y] when F i [y] is not last. We have two choices: one is to set F L [y] = last(y), and the other is to set F L [y] = F i [y] (or F L [y] = return(n + 1) if F i [y] = return(n)). In our current implementation, we rst set F L [y] = last(y) and proceed the analysis. If the analysis fails at some point because F L [y] = last(y), we take the alternative and redo the analysis from L. (We need not completely abandon the work after we set F L [y] = last(y).) The second problem is that by a nave iterative algorithm, a subroutine is analyzed each time it is called. In the worst case this may require an exponential number of steps with respect to the length of the program. This problem can be avoided by representing invocation histories by a node in the call graph of the program, which is a graph whose nodes are addresses of subroutines and whose (directed) edges are labeled with addresses of jsr instructions. Since JVM does not allow recursion, it is a connected acyclic graph with a unique root node representing the initial address. A path from the root to a node in the graph corresponds to an invocation history by concatenating the labels of edges in the path. Each node in the graph then represents the set of all the invocation histories from the root to the node. Now, instead of keeping a set of invocation histories (i.e., H i ), we can keep a set of nodes in the graph. From a program in the following (left), the call graph in the right is constructed. The node L 3 represents the set f[c; b; a]; [c; b 0 ; a 0 ]; [c 0 ; b; a]; [c 0 ; b 0 ; a 0 ]g of invocation histories.

17 a : jsr(l 1 ) : : : a 0 : jsr(l 0 1) : : : L 1 : : : : b : jsr(l 2 ) : : : L 0 1 : : : : b 0 : jsr(l 2 ) : : : L 2 : : : : c : jsr(l 3 ) : : : c 0 : jsr(l 3 ) : : : L 3 : : : : L 3 c H H HY H c 0 L L 1 L @??? a 0? If histories are represented by nodes in the call graph, then the values that H i can take are bounded by the set of all the nodes in the call graph. This means that H i can only be updated for the number of times equal to the number of nodes. 6 Concluding Remark Since we introduced types of the form last(x), it has become possible to assign types to polymorphic subroutines that move a value from a variable to another. Our analysis is towards real polymorphism of subroutines in binary code, because we do not simply ignore unaccessed variables. For some programs, our method is more powerful than existing ones. In particular, we impose no restrictions on the number of entries and exits of a subroutine. It is also important that the correctness proof of bytecode verication becomes extremely simple. A dataow analysis, in general, assigns an abstract value x i to the i-th instruction so that a certain predicate P (x i ; ) always holds for any state that reaches the i-th instruction. To this end, for any transition! 0, where 0 is at i 0, one must show that P (x i ; ) implies P (x i 0 ; 0 ). Since corresponds to hi; f; s; hi in our analysis, x i seems to correspond to hf i ; S i ; H i i. However, the predicate hi; f; s; hi : hf; S; Hi, which should correspond to P (x i ; ), does not only refer to hf i ; S i ; H i i. When F i [y] is last, it also refers to F h[0]. This means that in terms of last types, our analysis relates values assigned to dierent instructions. This makes the analysis powerful while keeping the overall data structure for the analysis compact. The representation of invocation histories by a node in the call graph is also for making the data structure small and ecient. By this representation, the

18 number of updates of H i is limited by the size of the call graph, and an iterative algorithm is expected to stop in polynomial time with respect to the program size. This kind of complexity analysis should be made more rigorously in the future. Acknowledgments The author would like to thank Zhenyu Qian and Martn Abadi for their comments on the earlier draft of this paper. References 1. Richard M. Cohen: The Defensive Java Virtual Machine Specication, Version Alpha 1 Release, DRAFT VERSION, Drew Dean: The Security of Static Typing with Dynamic Linking, Fourth ACM Conference on Computer and Communication Security, 1997, pp.18{ Sophia Drossopoulou and Susan Eisenbach: Java is Type Safe Probably, ECOOP'97 Object-Oriented Programming, Lecture Notes in Computer Science, Vol.1241, 1997, pp.389{ Sophia Drossopoulou, Susan Eisenbach and Sarfraz Khurshid: Is the Java Type System Sound? Proceedings of the Fourth International Workshop on Foundations of Object-Oriented Languages, Allen Goldberg: A Specication of Java Loading and Bytecode Verication, James Gosling, Bill Joy and Guy Steele: The Java TM Language Specication, Addison-Weslay, Kimera: 8. Tim Lindholm and Frank Yellin: The Java TM Virtual Machine Specication, Addison-Weslay, Gary McGraw and Edward W. Felten: Java Security: Hostile Applets, Holes and Antidotes, John Wiley and Sons, George C. Necula: Proof-Carrying Code, the Proceedings of the 24th Annual SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 1997, pp.106{ George C. Necula, Peter Lee: The Design and Implementation of a Certifying Compiler, submitted to PLDI' Tobias Nipkow and David von Oheimb: Java light is Type-Safe Denitely, Proceedings of the 25th Annual SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 1998, pp.161{ Zhenyu Qian: A Formal Specication of Java TM Virtual Machine Instructions, Vijay Saraswat: Java is not type-safe,

19 15. Secure Internet Programming: Raymie Stata and Martn Abadi: A Type System for Java Bytecode Subroutines, Proceedings of the 25th Annual SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 1998, pp.149{ Don Syme: Proving Java Type Soundness, David Wragg, Sophia Drossopoulou and Susan Eisenbach: Java Binary Compatibility is Almost Correct, Version 2,

1 Introduction One of the contributions of Java is in its bytecode verier, which checks type safety of bytecode for JVM (Java Virtual Machine) prior t

1 Introduction One of the contributions of Java is in its bytecode verier, which checks type safety of bytecode for JVM (Java Virtual Machine) prior t On a New Method for Dataow Analysis of Java Virtual Machine Subroutines Masami Hagiya Department of Information Science, Graduate School of Science, University of Tokyo hagiyais.s.u-tokyo.ac.jp Abstract

More information

A Type System for Object Initialization In the Java TM Bytecode Language

A Type System for Object Initialization In the Java TM Bytecode Language Electronic Notes in Theoretical Computer Science 10 (1998) URL: http://www.elsevier.nl/locate/entcs/volume10.html 7 pages A Type System for Object Initialization In the Java TM Bytecode Language Stephen

More information

A Type System for Java Bytecode Subroutines

A Type System for Java Bytecode Subroutines A Type System for Java Bytecode Subroutines Raymie Stata and Martín Abadi Digital Equipment Corporation Systems Research Center Abstract Java is typically compiled into an intermediate language, JVML,

More information

A.java class A f void f() f... g g - Java - - class file Compiler > B.class network class file A.class Java Virtual Machine Loa

A.java class A f void f() f... g g - Java - - class file Compiler > B.class network class file A.class Java Virtual Machine Loa A Type System for Object Initialization In the Java TM Bytecode Language Stephen N. Freund John C. Mitchell Department of Computer Science Stanford University Stanford, CA 94305-9045 ffreunds, mitchellg@cs.stanford.edu

More information

void f() { try { something(); } finally { done(); } } Figure 1: A method using a try-finally statement. system developed by Stata and Abadi [SA98a]. E

void f() { try { something(); } finally { done(); } } Figure 1: A method using a try-finally statement. system developed by Stata and Abadi [SA98a]. E The Costs and Benets of Java Bytecode Subroutines Stephen N. Freund Department of Computer Science Stanford University Stanford, CA 94305-9045 freunds@cs.stanford.edu September 20, 1998 Abstract Java bytecode

More information

Natural Semantics [14] within the Centaur system [6], and the Typol formalism [8] which provides us with executable specications. The outcome of such

Natural Semantics [14] within the Centaur system [6], and the Typol formalism [8] which provides us with executable specications. The outcome of such A Formal Executable Semantics for Java Isabelle Attali, Denis Caromel, Marjorie Russo INRIA Sophia Antipolis, CNRS - I3S - Univ. Nice Sophia Antipolis, BP 93, 06902 Sophia Antipolis Cedex - France tel:

More information

that programs might be downloaded and executed without users realizing that this is happening. Users are keen to take advantage of the new functionali

that programs might be downloaded and executed without users realizing that this is happening. Users are keen to take advantage of the new functionali The Functions of Java Bytecode Mark P. Jones Languages and Programming, Department of Computer Science University of Nottingham, Nottingham NG7 2RD, England. http://www.cs.nott.ac.uk/~ mpj/ Abstract Java

More information

Java Internals. Frank Yellin Tim Lindholm JavaSoft

Java Internals. Frank Yellin Tim Lindholm JavaSoft Java Internals Frank Yellin Tim Lindholm JavaSoft About This Talk The JavaSoft implementation of the Java Virtual Machine (JDK 1.0.2) Some companies have tweaked our implementation Alternative implementations

More information

1 Introduction An exciting recent development in program verication is the notion of certied code. When downloading executable code from an untrusted

1 Introduction An exciting recent development in program verication is the notion of certied code. When downloading executable code from an untrusted Ecient Code Certication Dexter Kozen Department of Computer Science Cornell University Ithaca, NY 14853-7501 kozen@cs.cornell.edu January 8, 1998 Abstract We introduce a simple and ecient approach to the

More information

Java byte code verification

Java byte code verification Java byte code verification SOS Master Science Informatique U. Rennes 1 Thomas Jensen SOS Java byte code verification 1 / 26 Java security architecture Java: programming applications with code from different

More information

An Approach to the Generation of High-Assurance Java Card Applets

An Approach to the Generation of High-Assurance Java Card Applets An Approach to the Generation of High-Assurance Java Card Applets Alessandro Coglio Kestrel Institute 3260 Hillview Avenue, Palo Alto, CA 94304, USA Ph. +1-650-493-6871 Fax +1-650-424-1807 http://www.kestrel.edu/

More information

16 Greedy Algorithms

16 Greedy Algorithms 16 Greedy Algorithms Optimization algorithms typically go through a sequence of steps, with a set of choices at each For many optimization problems, using dynamic programming to determine the best choices

More information

SORT INFERENCE \coregular" signatures, they derive an algorithm for computing a most general typing for expressions e which is only slightly more comp

SORT INFERENCE \coregular signatures, they derive an algorithm for computing a most general typing for expressions e which is only slightly more comp Haskell Overloading is DEXPTIME{complete Helmut Seidl Fachbereich Informatik Universitat des Saarlandes Postfach 151150 D{66041 Saarbrucken Germany seidl@cs.uni-sb.de Febr., 1994 Keywords: Haskell type

More information

arxiv: v3 [cs.ds] 18 Apr 2011

arxiv: v3 [cs.ds] 18 Apr 2011 A tight bound on the worst-case number of comparisons for Floyd s heap construction algorithm Ioannis K. Paparrizos School of Computer and Communication Sciences Ècole Polytechnique Fèdèrale de Lausanne

More information

Problems of Bytecode Verification

Problems of Bytecode Verification Eidgenossische Technische Hochschule Zurich Ecole polytechnique federale de Zurich Politecnico federale di Zurigo Swiss Federal Institute of Technology Zurich Problems of Bytecode Verification Robert F.

More information

Provably Correct Software

Provably Correct Software Provably Correct Software Max Schäfer Institute of Information Science/Academia Sinica September 17, 2007 1 / 48 The Need for Provably Correct Software BUT bugs are annoying, embarrassing, and cost gazillions

More information

2 Egon Borger, Wolfram Schulte: Initialization Problems for Java 1 class A implements I{ } 2 3 interface I { static boolean dummy = Main.sideeffect =

2 Egon Borger, Wolfram Schulte: Initialization Problems for Java 1 class A implements I{ } 2 3 interface I { static boolean dummy = Main.sideeffect = Initialization Problems for Java? Egon Borger 1, Wolfram Schulte 2 1 Universita di Pisa, Dipartimento di Informatica, I-56125 Pisa, Italy, e-mail: boerger@di.unipi.it 2 Universitat Ulm, Fakultat fur Informatik,

More information

Combining Analyses, Combining Optimizations - Summary

Combining Analyses, Combining Optimizations - Summary Combining Analyses, Combining Optimizations - Summary 1. INTRODUCTION Cliff Click s thesis Combining Analysis, Combining Optimizations [Click and Cooper 1995] uses a structurally different intermediate

More information

Operational Semantics

Operational Semantics 15-819K: Logic Programming Lecture 4 Operational Semantics Frank Pfenning September 7, 2006 In this lecture we begin in the quest to formally capture the operational semantics in order to prove properties

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

time using O( n log n ) processors on the EREW PRAM. Thus, our algorithm improves on the previous results, either in time complexity or in the model o

time using O( n log n ) processors on the EREW PRAM. Thus, our algorithm improves on the previous results, either in time complexity or in the model o Reconstructing a Binary Tree from its Traversals in Doubly-Logarithmic CREW Time Stephan Olariu Michael Overstreet Department of Computer Science, Old Dominion University, Norfolk, VA 23529 Zhaofang Wen

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

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1 Agenda CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Summer 2004 Java virtual machine architecture.class files Class loading Execution engines Interpreters & JITs various strategies

More information

A Nim game played on graphs II

A Nim game played on graphs II Theoretical Computer Science 304 (2003) 401 419 www.elsevier.com/locate/tcs A Nim game played on graphs II Masahiko Fukuyama Graduate School of Mathematical Sciences, University of Tokyo, 3-8-1 Komaba,

More information

Project 3 Due October 21, 2015, 11:59:59pm

Project 3 Due October 21, 2015, 11:59:59pm Project 3 Due October 21, 2015, 11:59:59pm 1 Introduction In this project, you will implement RubeVM, a virtual machine for a simple bytecode language. Later in the semester, you will compile Rube (a simplified

More information

Practical Java Card bytecode compression 1

Practical Java Card bytecode compression 1 RENPAR 14 / ASF / SYMPA Practical Java Card bytecode compression 1 Gabriel Bizzotto Gilles Grimaud LIFL, Universite de Lille 1 Gemplus Research Lab bizzotto@dea.lifl.fr grimaud@lifl.fr Abstract Our work

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

In Our Last Exciting Episode

In Our Last Exciting Episode In Our Last Exciting Episode #1 Lessons From Model Checking To find bugs, we need specifications What are some good specifications? To convert a program into a model, we need predicates/invariants and

More information

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1 CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Winter 2008 3/11/2008 2002-08 Hal Perkins & UW CSE V-1 Agenda Java virtual machine architecture.class files Class loading Execution engines

More information

The security mechanisms of Java

The security mechanisms of Java The security mechanisms of Java Carlo U. Nicola, SGI FHNW With extracts from publications of : Sun developers' center documentation; David A. Wheeler, UC Berkeley; Klaus Ostermann, TH-Darmstadt. Topics

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

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy International Journal Information Theories and Applications, Vol. 20, Number 2, 2013 131 ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES Nikolay Kosovskiy Abstract: A mathematical

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

JAM 16: The Instruction Set & Sample Programs

JAM 16: The Instruction Set & Sample Programs JAM 16: The Instruction Set & Sample Programs Copyright Peter M. Kogge CSE Dept. Univ. of Notre Dame Jan. 8, 1999, modified 4/4/01 Revised to 16 bits: Dec. 5, 2007 JAM 16: 1 Java Terms Java: A simple,

More information

Outline. Proof Carrying Code. Hardware Trojan Threat. Why Compromise HDL Code?

Outline. Proof Carrying Code. Hardware Trojan Threat. Why Compromise HDL Code? Outline Proof Carrying Code Mohammad Tehranipoor ECE6095: Hardware Security & Trust University of Connecticut ECE Department Hardware IP Verification Hardware PCC Background Software PCC Description Software

More information

CITS5501 Software Testing and Quality Assurance Formal methods

CITS5501 Software Testing and Quality Assurance Formal methods CITS5501 Software Testing and Quality Assurance Formal methods Unit coordinator: Arran Stewart May 1, 2018 1 / 49 Sources Pressman, R., Software Engineering: A Practitioner s Approach, McGraw-Hill, 2005

More information

CS 3410 Ch 7 Recursion

CS 3410 Ch 7 Recursion CS 3410 Ch 7 Recursion Sections Pages 7.1-7.4, 7.7 93-319, 333-336 7.1 Introduction 1. A recursive method is a method that either directly or indirectly makes a call to itself. [Weiss]. It does this by

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

Deep type inference for mobile functions

Deep type inference for mobile functions Deep type inference for mobile functions Stephen Gilmore Laboratory for Foundations of Computer Science The University of Edinburgh King s Buildings Edinburgh EH9 3JZ Scotland. Telephone: +44 (0)131-650-5189.

More information

C. E. McDowell August 25, Baskin Center for. University of California, Santa Cruz. Santa Cruz, CA USA. abstract

C. E. McDowell August 25, Baskin Center for. University of California, Santa Cruz. Santa Cruz, CA USA. abstract Unloading Java Classes That Contain Static Fields C. E. McDowell E. A. Baldwin 97-18 August 25, 1997 Baskin Center for Computer Engineering & Information Sciences University of California, Santa Cruz Santa

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA Thunks (continued) Olivier Danvy, John Hatcli Department of Computing and Information Sciences Kansas State University Manhattan, Kansas 66506, USA e-mail: (danvy, hatcli)@cis.ksu.edu Abstract: Call-by-name

More information

A Combined BIT and TIMESTAMP Algorithm for. the List Update Problem. Susanne Albers, Bernhard von Stengel, Ralph Werchner

A Combined BIT and TIMESTAMP Algorithm for. the List Update Problem. Susanne Albers, Bernhard von Stengel, Ralph Werchner A Combined BIT and TIMESTAMP Algorithm for the List Update Problem Susanne Albers, Bernhard von Stengel, Ralph Werchner International Computer Science Institute, 1947 Center Street, Berkeley, CA 94704,

More information

Heap-on-Top Priority Queues. March Abstract. We introduce the heap-on-top (hot) priority queue data structure that combines the

Heap-on-Top Priority Queues. March Abstract. We introduce the heap-on-top (hot) priority queue data structure that combines the Heap-on-Top Priority Queues Boris V. Cherkassky Central Economics and Mathematics Institute Krasikova St. 32 117418, Moscow, Russia cher@cemi.msk.su Andrew V. Goldberg NEC Research Institute 4 Independence

More information

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the The Semi-Full Closure of Pure Type Systems? Gilles Barthe Institutionen for Datavetenskap, Chalmers Tekniska Hogskola, Goteborg, Sweden Departamento de Informatica, Universidade do Minho, Braga, Portugal

More information

Language Techniques for Provably Safe Mobile Code

Language Techniques for Provably Safe Mobile Code Language Techniques for Provably Safe Mobile Code Frank Pfenning Carnegie Mellon University Distinguished Lecture Series Computing and Information Sciences Kansas State University October 27, 2000 Acknowledgments:

More information

Mechanized Operational Semantics

Mechanized Operational Semantics Mechanized Operational Semantics J Strother Moore Department of Computer Sciences University of Texas at Austin Marktoberdorf Summer School 2008 (Lecture 2: An Operational Semantics) 1 M1 An M1 state consists

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

QUTE: A PROLOG/LISP TYPE LANGUAGE FOR LOGIC PROGRAMMING

QUTE: A PROLOG/LISP TYPE LANGUAGE FOR LOGIC PROGRAMMING QUTE: A PROLOG/LISP TYPE LANGUAGE FOR LOGIC PROGRAMMING Masahiko Sato Takafumi Sakurai Department of Information Science, Faculty of Science University of Tokyo 7-3-1 Hongo, Bunkyo-ku, Tokyo 113, JAPAN

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Recap: Taking Conditional Branches into Account Extending

More information

Code Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline.

Code Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline. The Main Idea of Today s Lecture Code Generation We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?

More information

(Preliminary Version 2 ) Jai-Hoon Kim Nitin H. Vaidya. Department of Computer Science. Texas A&M University. College Station, TX

(Preliminary Version 2 ) Jai-Hoon Kim Nitin H. Vaidya. Department of Computer Science. Texas A&M University. College Station, TX Towards an Adaptive Distributed Shared Memory (Preliminary Version ) Jai-Hoon Kim Nitin H. Vaidya Department of Computer Science Texas A&M University College Station, TX 77843-3 E-mail: fjhkim,vaidyag@cs.tamu.edu

More information

We can emit stack-machine-style code for expressions via recursion

We can emit stack-machine-style code for expressions via recursion Code Generation The Main Idea of Today s Lecture We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?

More information

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting CS2 Algorithms and Data Structures Note 10 Depth-First Search and Topological Sorting In this lecture, we will analyse the running time of DFS and discuss a few applications. 10.1 A recursive implementation

More information

to automatically generate parallel code for many applications that periodically update shared data structures using commuting operations and/or manipu

to automatically generate parallel code for many applications that periodically update shared data structures using commuting operations and/or manipu Semantic Foundations of Commutativity Analysis Martin C. Rinard y and Pedro C. Diniz z Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 fmartin,pedrog@cs.ucsb.edu

More information

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

STABILITY AND PARADOX IN ALGORITHMIC LOGIC STABILITY AND PARADOX IN ALGORITHMIC LOGIC WAYNE AITKEN, JEFFREY A. BARRETT Abstract. Algorithmic logic is the logic of basic statements concerning algorithms and the algorithmic rules of deduction between

More information

2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006

2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006 2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006 The Encoding Complexity of Network Coding Michael Langberg, Member, IEEE, Alexander Sprintson, Member, IEEE, and Jehoshua Bruck,

More information

Global Scheduler. Global Issue. Global Retire

Global Scheduler. Global Issue. Global Retire The Delft-Java Engine: An Introduction C. John Glossner 1;2 and Stamatis Vassiliadis 2 1 Lucent / Bell Labs, Allentown, Pa. 2 Delft University oftechnology, Department of Electrical Engineering Delft,

More information

javac 29: pop 30: iconst_0 31: istore_3 32: jsr [label_51]

javac 29: pop 30: iconst_0 31: istore_3 32: jsr [label_51] Analyzing Control Flow in Java Bytecode Jianjun Zhao Department of Computer Science and Engineering Fukuoka Institute of Technology 3-10-1 Wajiro-Higashi, Higashi-ku, Fukuoka 811-02, Japan zhao@cs.t.ac.jp

More information

Parallelism of Java Bytecode Programs and a Java ILP Processor Architecture

Parallelism of Java Bytecode Programs and a Java ILP Processor Architecture Australian Computer Science Communications, Vol.21, No.4, 1999, Springer-Verlag Singapore Parallelism of Java Bytecode Programs and a Java ILP Processor Architecture Kenji Watanabe and Yamin Li Graduate

More information

1.3. Conditional expressions To express case distinctions like

1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

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

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

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53 Modal Logic: Implications for Design of a Language for Distributed Computation Jonathan Moody (with Frank Pfenning) Department of Computer Science Carnegie Mellon University Modal Logic: Implications for

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

University of Utrecht. 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler,

University of Utrecht. 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler, J. Functional Programming 1 (1): 1{000, January 1993 c 1993 Cambridge University Press 1 F U N C T I O N A L P E A R L S Monadic Parsing in Haskell Graham Hutton University of Nottingham Erik Meijer University

More information

Parallel Program Graphs and their. (fvivek dependence graphs, including the Control Flow Graph (CFG) which

Parallel Program Graphs and their. (fvivek dependence graphs, including the Control Flow Graph (CFG) which Parallel Program Graphs and their Classication Vivek Sarkar Barbara Simons IBM Santa Teresa Laboratory, 555 Bailey Avenue, San Jose, CA 95141 (fvivek sarkar,simonsg@vnet.ibm.com) Abstract. We categorize

More information

Lecture Notes on Contracts

Lecture Notes on Contracts Lecture Notes on Contracts 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 30, 2012 1 Introduction For an overview the course goals and the mechanics and schedule of the course,

More information

JPred-P 2. Josh Choi, Michael Welch {joshchoi,

JPred-P 2. Josh Choi, Michael Welch {joshchoi, JPred-P 2 Josh Choi, Michael Welch {joshchoi, mjwelch}@cs.ucla.edu 1. Introduction Precondition and postcondition checking on methods aids the development process by explicitly notifying the programmer

More information

CS4215 Programming Language Implementation

CS4215 Programming Language Implementation CS4215 Programming Language Implementation You have 45 minutes to complete the exam. Use a B2 pencil to fill up the provided MCQ form. Leave Section A blank. Fill up Sections B and C. After finishing,

More information

Byzantine Consensus in Directed Graphs

Byzantine Consensus in Directed Graphs Byzantine Consensus in Directed Graphs Lewis Tseng 1,3, and Nitin Vaidya 2,3 1 Department of Computer Science, 2 Department of Electrical and Computer Engineering, and 3 Coordinated Science Laboratory

More information

Let us dene the basic notation and list some results. We will consider that stack eects (type signatures) form a polycyclic monoid (introduced in [NiP

Let us dene the basic notation and list some results. We will consider that stack eects (type signatures) form a polycyclic monoid (introduced in [NiP Validation of Stack Eects in Java Bytecode Jaanus Poial Institute of Computer Science University of Tartu, Estonia e-mail: jaanus@cs.ut.ee February 21, 1997 Abstract The Java language is widely used in

More information

Adam Chlipala University of California, Berkeley ICFP 2006

Adam Chlipala University of California, Berkeley ICFP 2006 Modular Development of Certified Program Verifiers with a Proof Assistant Adam Chlipala University of California, Berkeley ICFP 2006 1 Who Watches the Watcher? Program Verifier Might want to ensure: Memory

More information

THE FREUDENTHAL-HOPF THEOREM

THE FREUDENTHAL-HOPF THEOREM THE FREUDENTHAL-HOPF THEOREM SOFI GJING JOVANOVSKA Abstract. In this paper, we will examine a geometric property of groups: the number of ends of a group. Intuitively, the number of ends of a group is

More information

Identity-based Access Control

Identity-based Access Control Identity-based Access Control The kind of access control familiar from operating systems like Unix or Windows based on user identities This model originated in closed organisations ( enterprises ) like

More information

Compiling Techniques

Compiling Techniques Lecture 10: Introduction to 10 November 2015 Coursework: Block and Procedure Table of contents Introduction 1 Introduction Overview Java Virtual Machine Frames and Function Call 2 JVM Types and Mnemonics

More information

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable A Simplied NP-complete MAXSAT Problem Venkatesh Raman 1, B. Ravikumar 2 and S. Srinivasa Rao 1 1 The Institute of Mathematical Sciences, C. I. T. Campus, Chennai 600 113. India 2 Department of Computer

More information

Towards a formal model of object-oriented hyperslices

Towards a formal model of object-oriented hyperslices Towards a formal model of object-oriented hyperslices Torsten Nelson, Donald Cowan, Paulo Alencar Computer Systems Group, University of Waterloo {torsten,dcowan,alencar}@csg.uwaterloo.ca Abstract This

More information

original term canonical completion minimal d.t. completion original term canonical completion minimal d.t. completion minimal s.c. completion (x:x) (y

original term canonical completion minimal d.t. completion original term canonical completion minimal d.t. completion minimal s.c. completion (x:x) (y Dynamic Typing and Subtype Inference Alexander Aiken Manuel Fahndrich Computer Science Division University of California, Berkeley Berkeley, CA 94720-1776 faiken,manuelg@cs.berkeley.edu Abstract Dynamic

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

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17 01.433/33 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/2/1.1 Introduction In this lecture we ll talk about a useful abstraction, priority queues, which are

More information

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Any questions about the syllabus?! Course Material available at www.cs.unic.ac.cy/ioanna! Next time reading assignment [ALSU07]

More information

The Encoding Complexity of Network Coding

The Encoding Complexity of Network Coding The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

More information

Super-Key Classes for Updating. Materialized Derived Classes in Object Bases

Super-Key Classes for Updating. Materialized Derived Classes in Object Bases Super-Key Classes for Updating Materialized Derived Classes in Object Bases Shin'ichi KONOMI 1, Tetsuya FURUKAWA 1 and Yahiko KAMBAYASHI 2 1 Comper Center, Kyushu University, Higashi, Fukuoka 812, Japan

More information

CS 164 Handout 16. Final Examination. There are nine questions on the exam, some in multiple parts. You have 3 hours to work on the

CS 164 Handout 16. Final Examination. There are nine questions on the exam, some in multiple parts. You have 3 hours to work on the Final Examination Please read all instructions (including these) carefully. Please print your name at the bottom of each page on the exam. There are nine questions on the exam, some in multiple parts.

More information

CMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013

CMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013 CMPSCI 250: Introduction to Computation Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013 Induction and Recursion Three Rules for Recursive Algorithms Proving

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

Localization in Graphs. Richardson, TX Azriel Rosenfeld. Center for Automation Research. College Park, MD

Localization in Graphs. Richardson, TX Azriel Rosenfeld. Center for Automation Research. College Park, MD CAR-TR-728 CS-TR-3326 UMIACS-TR-94-92 Samir Khuller Department of Computer Science Institute for Advanced Computer Studies University of Maryland College Park, MD 20742-3255 Localization in Graphs Azriel

More information

COMPOSABILITY, PROVABILITY, REUSABILITY (CPR) FOR SURVIVABILITY

COMPOSABILITY, PROVABILITY, REUSABILITY (CPR) FOR SURVIVABILITY AFRL-IF-RS-TR-2002-61 Final Technical Report April 2002 COMPOSABILITY, PROVABILITY, REUSABILITY (CPR) FOR SURVIVABILITY Kestrel Institute Sponsored by Defense Advanced Research Projects Agency DARPA Order

More information

Implementation of Hopcroft's Algorithm

Implementation of Hopcroft's Algorithm Implementation of Hopcroft's Algorithm Hang Zhou 19 December 2009 Abstract Minimization of a deterministic nite automaton(dfa) is a well-studied problem of formal language. An ecient algorithm for this

More information

Framework for Design of Dynamic Programming Algorithms

Framework for Design of Dynamic Programming Algorithms CSE 441T/541T Advanced Algorithms September 22, 2010 Framework for Design of Dynamic Programming Algorithms Dynamic programming algorithms for combinatorial optimization generalize the strategy we studied

More information

Reading 1 : Introduction

Reading 1 : Introduction CS/Math 240: Introduction to Discrete Mathematics Fall 2015 Instructors: Beck Hasti and Gautam Prakriya Reading 1 : Introduction Welcome to CS 240, an introduction to discrete mathematics. This reading

More information

Symbolic Execution and Proof of Properties

Symbolic Execution and Proof of Properties Chapter 7 Symbolic Execution and Proof of Properties Symbolic execution builds predicates that characterize the conditions under which execution paths can be taken and the effect of the execution on program

More information

Programs with infinite loops: from primitive recursive predicates to the arithmetic hierarchy

Programs with infinite loops: from primitive recursive predicates to the arithmetic hierarchy Programs with infinite loops: from primitive recursive predicates to the arithmetic hierarchy ((quite) preliminary) Armando B. Matos September 11, 2014 Abstract Infinite time Turing machines have been

More information

Draw a diagram of an empty circular queue and describe it to the reader.

Draw a diagram of an empty circular queue and describe it to the reader. 1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 1 1983/84 COSC1020/30 Tests >>> The following was given to students. >>> Students can have a good idea of test questions by examining and trying the

More information

ER E P M S S I TRANSLATION OF CONDITIONAL COMPIL DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A

ER E P M S S I TRANSLATION OF CONDITIONAL COMPIL DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A S I N S UN I ER E P M TA S A S I T VER TRANSLATION OF CONDITIONAL COMPIL DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A-1997-13 UNIVERSITY OF TAMPERE DEPARTMENT OF COMPUTER SCIENCE SERIES

More information

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

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

More information

Field Analysis. Last time Exploit encapsulation to improve memory system performance

Field Analysis. Last time Exploit encapsulation to improve memory system performance Field Analysis Last time Exploit encapsulation to improve memory system performance This time Exploit encapsulation to simplify analysis Two uses of field analysis Escape analysis Object inlining April

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

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information