Escape Analysis for Java

Size: px
Start display at page:

Download "Escape Analysis for Java"

Transcription

1 Escape Analysis for Java Michael Bohn Based on the paper by Jong-Deok Choi, Manish Gupta, Mauricio Serrano, Vugranam Sreedhar and Sam Midkiff

2 Escape Analysis? What is Escape Analysis and why do I need it? Consider this example: public int m() { Vector<Integer> v = new Vector<Integer>(); v.add(1); v.add(2); return v.size(); } 2

3 Escape Analysis? public int m() { Vector<Integer> v = new Vector<Integer>(); v.add(1); v.add(2); return v.size(); } In Java, all objects are allocated on the heap Allocation on heap is time expensive Object needs to be removed by the garbage collector Garbage collection is time expensive Improvements possible, if we know that an object does not escape a method 3

4 Escape Analysis? public int m() { Vector<Integer> v = new Vector<Integer>(); v.add(1); v.add(2); return v.size(); } Improvement here: Allocation on stack Without violating Java semantics! Object is recycled with stack frame for free 4

5 Escape Analysis? public int m() { Vector<Integer> v = new Vector<Integer>(); v.add(1); v.add(2); return v.size(); } Another improvement possible Vector is synchronized lock and unlock on every call to add() Pointless, because Object never accessed by more than one thread Sychronization can be removed 5

6 Outline Rest of this talk: How to automatically identify whether an object escapes or not Intraprocedural analysis Interprocedural analysis Objects are passed to other methods: public void m() { Object o = new Object(); callmethod(o); } How to track escape states between method calls 6

7 Definition Escape M Definition: Method Escape Let O be a concrete object Let M be a method invocation EscapeMethod(O, M) = true, if lifetime of O exceeds lifetime of M (plus: O is not passed to another thread) Push(O) Pop(O) O EscapeMethod(O,M) = false 7

8 Definition Escape M Definition: Method Escape Let O be a concrete object Let M be a method invocation EscapeMethod(O, M) = true, if lifetime of O exceeds lifetime of M (plus: O is not passed to another thread) Push(O) Pop(O) O EscapeMethod(O, M) = false stack-allocatable EscapeMethod(O,M) = false 8

9 Definition Escape Definition: Thread Escape Let O be a concrete object Let T be a thread EscapeThread(O, T) = true, if O is visible to another thread T' T T' O T EscapeThread(O,T) = true 9

10 Definition Escape Definition: Thread Escape Let O be a concrete object Let T be a thread EscapeThread(O, T) = true, if O is visible to another thread T' T T' O T EscapeThread(O, T) = false thread-local EscapeThread(O,T) = true 10

11 Java Example Program Two static methods caller callee program call graph (PCG) caller callee 11

12 Java Example Program public static void caller() { A a = new A(); a.fa2 = new Object(); public static A callee(a arg1) { A sac = new A(); A gec = new A(); } A r = callee(a); Example.global = r; A asc1 = new A(); A asc2 = new A(); if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } class A { public Object fa1; public Object fa2; } } return asc1; 12

13 Java Example Program public static A callee(a arg1) { S1: A sac = new A(); S2: A gec = new A(); S3: A asc1 = new A(); S4: A asc2 = new A(); if(...) { S5: arg1.fa1 = asc2; S6: A a = arg1.fa2; S7: A b = a; S8: Example.global = b; } else { S9: Example.global = gec; } S10: return asc1; } 13

14 Intraprocedural Analysis 14

15 Idea of the analysis Capture the references of objects in a connection graph (CG) CG = N o N v N f, E p E d E f N o : object nodes N v : reference nodes (globals, locals, parameters) N f : field nodes E p : p q p N r q N o E d : p D q p, q E d E f : p F q p N o q N f 15

16 Intraprocedural Analysis Iterative scheme for connection graph construction S CG output S CG input = f S S CG input r = r Pred S CG output (standard data flow equations) Four basic statements with non-trivial transfer functions: p = new τ() p = q p.f = q p = q.f 16

17 Initialized connection graph public static void caller() { //... A r = callee(a); //... } arg1 = a1 public static A callee(a arg1) { //... } 17

18 Initialized connection graph public static A callee(a arg1) { //... if(...) { //... S8: Example.global = b; } else { S9: Example.global = gec; } //... } 18

19 Intraprocedural Analysis Statement type: p = new τ() 1. New object node O for new allocation site (1-limited scheme) 2. Apply ByPass(p) 3. Add p O Precisely, transform first: A sac = null; sac = new A(); 19

20 ByPass? ByPass(p) Formally: Let R={r r D p}(incoming deferred edges) Let S ={s p P s}(outgoing points-to edges) Let T ={t p D t}(outgoing deferred edges) ByPass p removes the edges in set {r D p} {p P s} {p D t} from the CG and adds edges {r P s r R s S } {r D s r R t T } to the CG 20

21 Intraprocedural Analysis Statement type: p = new τ() 1. New object node O for new allocation site (1-limited scheme) 2. Apply ByPass(p) 3. Add p O 21

22 Intraprocedural Analysis Statement type: p = new τ() 1. New object node O for new allocation site 2. Apply ByPass(p) 3. Add p O 22

23 Intraprocedural Analysis Statement type: p = new τ() 1. New object node O for new allocation site 2. Apply ByPass(p) 3. Add p O 23

24 Intraprocedural Analysis Statement type: p = new τ() 1. New object node O for new allocation site 2. Apply ByPass(p) 3. Add p O 24

25 Intraprocedural Analysis Identity transfer function (condition without side-effects) 25

26 Intraprocedural Analysis Control flow branch We take left branch first 26

27 Intraprocedural Analysis Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object 27

28 Intraprocedural Analysis Objects arg1 points to= add phantom object node S5 and arg1 S5 to CG Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object 28

29 Intraprocedural Analysis Objects arg1 points to= add phantom object node S5 and arg1 S5 to CG Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object 29

30 Intraprocedural Analysis Objects arg1 points to= add phantom object node S5 and arg1 S5 to CG Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object Lazily add field node fa1 30

31 Intraprocedural Analysis Objects arg1 points to= add phantom object node S5 and arg1 S5 to CG Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object Lazily add field node fa1 31

32 Intraprocedural Analysis Objects arg1 points to= add phantom object node S5and arg1 S5 to CG Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object Lazily add field node fa1 Add fa1 D asc2 to CG 32

33 Intraprocedural Analysis Objects arg1 points to= add phantom object node S5and arg1 S5 to CG Statement type: p.f = q 1. Get objects p possibly points to 2. Lazily add field node f to objects 3. Add f D q to CG for each object Lazily add field node fa1 Add fa1 D asc2 to CG 33

34 Intraprocedural Analysis Statement type: p = q.f Get objects q possibly points to Lazily add field node f to objects ByPass(p) Add object p D f to CG for each 34

35 Intraprocedural Analysis Objects arg1 points to={s5} Statement type: p = q.f 1. Get objects q possibly points to 2. Lazily add field node f to objects 3. ByPass(p) 4. Add f to CG for p D each object 35

36 Intraprocedural Analysis Objects arg1 points to={s5} Lazily add field node fa2 Statement type: p = q.f 1. Get objects q possibly points to 2. Lazily add field node f to objects 3. ByPass(p) 4. Add f to CG for p D each object 36

37 Intraprocedural Analysis Objects arg1 points to={s5} Lazily add field node fa2 Statement type: p = q.f 1. Get objects q possibly points to 2. Lazily add field node f to objects 3. ByPass(p) 4. Add f to CG for p D each object 37

38 Intraprocedural Analysis Objects arg1 points to={s5} Lazily add field node fa2 Statement type: p = q.f 1. Get objects q possibly points to 2. Lazily add field node f to objects 3. ByPass(p) 4. Add f to CG for p D each object ByPass a Add a D fa2 to CG 38

39 Intraprocedural Analysis Objects arg1 points to={s5} Lazily add field node fa2 Statement type: p = q.f 1. Get objects q possibly points to 2. Lazily add field node f to objects 3. ByPass(p) 4. Add f to CG for p D each object ByPass a Add a D fa2 to CG 39

40 Intraprocedural Analysis Statement type: p = q Apply ByPass p Add edge p D q to CG 40

41 Intraprocedural Analysis Apply ByPass p Add edge p D q to CG ByPass b Add edge b D a 41

42 Intraprocedural Analysis Apply ByPass p Add edge p D q to CG ByPass b Add edge b D a 42

43 Intraprocedural Analysis Statement type again: p.f = q But here: global variable Similar transfer function 43

44 Intraprocedural Analysis 44

45 Intraprocedural Analysis 45

46 Intraprocedural Analysis We now take the right branch Extend CG at exit of if-node (conceptually) 46

47 Intraprocedural Analysis Again assignment to global variable 47

48 Intraprocedural Analysis 48

49 Intraprocedural Analysis 49

50 Intraprocedural Analysis Control flow merge: Meet-Operation = graph merge 50

51 Intraprocedural Analysis Left branch result Right branch result Merged 51

52 Intraprocedural Analysis Return statement: Modeled as an assignment to phantom variable return (return = asc1) Statement type: p = q Apply ByPass p Add edge p D q to CG 52

53 Intraprocedural Analysis Apply ByPass p Add edge p D q to CG 53

54 Intraprocedural Analysis Apply ByPass p Add edge p D q to CG 54

55 Intraprocedural Analysis Graph Compacting Apply ByPass(p) to each non-terminal node p Terminal node = node without outgoing edges Makes subsequent calculations more efficient Works, because we are only interested in the objects 55

56 Intraprocedural Analysis - Graph Compacting Apply ByPass(p) to each non-terminal node p Terminal node = node without outgoing edges Makes subsequent calculations more efficient Works, because we are only interested in the objects 56

57 Intraprocedural Analysis - Graph Compacting Apply ByPass(p) to each non-terminal node p Terminal node = node without outgoing edges Makes subsequent calculations more efficient Works, because we are only interested in the objects 57

58 Intraprocedural Analysis - Graph Compacting Special handling of terminal nodes 58

59 Intraprocedural Analysis - Graph Compacting Special handling of terminal nodes 59

60 Intraprocedural Analysis - Graph Compacting Special handling of terminal nodes 60

61 Intraprocedural Analysis Three escape states: Global, Arg, No Global = stack-allocatable thread-local Arg = stack-allocatable thread-local No = stack-allocatable thread-local 61

62 Intraprocedural Analyis The escape states form a lattice With es EscapeSet : NoEscape < < ArgEscape GlobalEscape es es = es es NoEscape = es es GlobalEscape = GlobalEscape 62

63 Intraprocedural Analysis Initial marking of nodes Global = all static fields (red) 63

64 Intraprocedural Analysis Initial marking of nodes Global = all static fields (red) Arg = phantom argument nodes and return phantom node (yellow) 64

65 Intraprocedural Analysis Initial marking of nodes Global = all static fields (red) Arg = phantom argument nodes and return phantom node (yellow) No = all other nodes 65

66 Intraprocedural Analysis Reachability analysis Subgraph of nodes that are reachable from global-escape-node 66

67 Intraprocedural Analysis Reachability analysis Subgraph of nodes that are reachable from arg-escape-nodes, but not from global-escape-nodes 67

68 Intraprocedural Analysis Reachability analysis Subgraph of nodes that are not reachable from global-escapenodes or arg-escape-node (remain marked no-escape) 68

69 Intraprocedural Analysis No-escape-nodes Do not escape method call and can be marked stack-allocatable 69

70 Intraprocedural Analysis public static A callee(a arg1) { S1: A sac = new A(); S2: A gec = new A(); S3: A asc1 = new A(); S4: A asc2 = new A(); if(...) { S5: arg1.fa1 = asc2; S6: A a = arg1.fa2; S7: A b = a; S8: Example.global = b; } else { S9: Example.global = gec; } S10: return asc1; } 70

71 Intraprocedural Analysis public static A callee(a arg1) { S1: A sac = new A(); S2: A gec = new A(); S3: A asc1 = new A(); S4: A asc2 = new A(); if(...) { S5: arg1.fa1 = asc2; S6: A a = arg1.fa2; S7: A b = a; S8: Example.global = b; } else { S9: Example.global = gec; } S10: return asc1; } We keep the red and yellow subgraphs for interprocedural analysis 71

72 Interprocedural analysis 72

73 Idea of interprocedural analysis Use callee CG to update caller CG Connect object nodes in caller with object nodes in callee program call graph (PCG) caller callee Traversal in inverse topologicial order (if there are no cycles in the PCG) 73

74 General traversal 74

75 The Java example public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } 75

76 Interprocedural Analysis public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Before call: connect caller CG constructed so far with callee CG 76

77 Interprocedural Analysis public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } After call: Apply effect of method call to caller CG 77

78 Interprocedural Analysis Construct CG up to method call public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } 78

79 Interprocedural Analysis Construct CG up to method call public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } 79

80 Interprocedural Analysis Construct CG up to method call public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Modelling parameter passing Assignment of parameter to phantom node Return value: new phantom object node 80

81 Interprocedural Analysis Parameter passing to method public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Modelling parameter passing Assignment of parameter to phantom node 81

82 Interprocedural Analysis Parameter passing to method public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Formally: Let u 1. foo u 2,...,u n be a method call, with u 2,..., u n actual arguments to foo Model the call as follows: a 1 =u 1, a 2 =u 2, where a i is a phantom reference node 82

83 Update of caller CG Two steps Update nodes Update edges Node update via MapsTo-Relation 83

84 MapsTo-Relation Initially caller callee MapsTo: a 1 a 1 return r 84

85 MapsTo-Relation Recursive update caller callee MapsTo: a 1 a 1 return r S5 T1 85

86 MapsTo-Relation Recursive update caller callee MapsTo: a 1 a 1 return r S5 T1 pfa2 T2 86

87 MapsTo-Relation Recursive update caller callee MapsTo: a 1 a 1 return r S5 T1 pfa2 T2 S4 T0 87

88 MapsTo-Relation Recursive update caller callee MapsTo: a 1 a 1 return r S5 T1 pfa2 T2 S4 T0 S3 T3 88

89 MapsTo-Relation Update Escape state caller callee Nodes in MapsTo(n) are marked global escape, if escape state of n is global escape MapsTo: a 1 a 1 S5 T1 S3 T3 S4 T01 pfa2 T2 89

90 MapsTo-Relation Update Escape state caller callee Nodes in MapsTo(n) are marked global escape, if escape state of n is global escape MapsTo: a 1 a 1 S5 T1 S3 T3 S4 T01 pfa2 T2 90

91 Update of caller CG Node update Finds objects in caller that possibly could be the objects in callee Next: Edge update Updates the connection effects of calling a method 91

92 MapsTo-Relation Edge update MapsTo: a 1 a 1 S5 T1 S3 T3 S4 T01 pfa2 T2 92

93 MapsTo-Relation Edge update MapsTo: a 1 a 1 S5 T1 S3 T3 S4 T01 pfa2 T2 93

94 Update of caller CG Edge update Let p, q be object nodes of the callee graph such that: p F f p P q For each p MapsTo p q MapsTo q : establish p F f p P q for fid f p = fid f p 94

95 Interprocedural Analysis CG after method call public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Only remaining statement: assignment to global variable 95

96 Interprocedural Analysis CG after method call public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Only remaining statement: assignment to global variable 96

97 Interprocedural Analysis Again propagation of escape states: public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } 97

98 Interprocedural Analysis Again propagation of escape states: public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } 98

99 Interprocedural Analysis Again propagation of escape states: public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } Problem: Object T3 marked as global escape in caller, but not in callee 99

100 Interprocedural Analysis Solution For each object marked global escape in caller: find corresponding nodes in (all) callees (via inverse MapsTo- Relation) 100

101 Interprocedural Analysis Solution For each object marked global escape in caller: find corresponding nodes in (all) callees (via inverse MapsTo- Relation) 101

102 Interprocedural Analysis Checking the result public static A callee(a arg1) { S1: A sac = new A(); S2: A gec = new A(); S3: A asc1 = new A(); S4: A asc2 = new A(); if(...) { S5: arg1.fa1 = asc2; S6: A a = arg1.fa2; S7: A b = a; S8: Example.global = b; } else { S9: Example.global = gec; } S10: return asc1; } 102

103 Interprocedural Analysis Checking the result public static void caller() { T1: A a = new A(); T2: a.fa2 = new Object(); T3: A r = callee(a); T4: Example.global = r; } 103

104 Special cases Loops Iterate until solution converges Maximum of 10 iterations If maximum exceeded Mark all objects in method as global escape Recursive method calls No inverse topological sort possible Iterate until solution converges (again max. 10 iterations) 104

105 Special cases Objects of classes that implement Runnable interface Threads Objects that could be used as threads Marked as global escape Virtual methods Apply effects of all possible methods to caller Objects with non-trivial finalizers Mark all objects with overwritten finalizer-method as global escape 105

106 Special cases Exceptions Inside try-catch block: Kill only references to variables that are local to the block Objects that are thrown are marked as global escape Native or non-analyzable methods Mark all objects passed to or returned from such methods as global escape 106

107 Conclusion Static program analysis that finds out whether an object can be allocated on stack synchronization can be omitted Approach Construct a graph that captures all possible references to objects Combine graphs in interprocedural analysis The question if an object escapes is transformed to a graph reachability problem 107

108 Almost last slide... Questions? 108

109 References Jong-Deok Choi, Manish Gupta, Mauricio Serrano, Vugranam C. Sreedhar, Sam Midkiff Escape Analysis for Java, 1999 Jong-Deok Choi, Manish Gupta, Mauricio Serrano, Vugranam C. Sreedhar, Sam Midkiff Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis, 2003 Gary A. Kildall A Unified Approach to Global Program Optimization,

110 Backup-Slides 110

111 Thread-local vs. Stack-allocatable Stack-allocatable => Thread-local If object does not escape method, it does not escape thread If object is not passed to another thread Thread-local > Stack-allocatable e.g. if object is returned from method, but not accessed from another thread Global escape = Stack-allocatable Thread-local 111

112 Java Example Program public static A callee(a arg1) { A sac = new A(); A gec = new A(); A asc1 = new A(); A asc2 = new A(); } if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } return asc1; class A { public Object fa1; public Object fa2; } 112

113 Java Example Program public static A callee(a arg1) { A sac = new A(); A gec = new A(); A asc1 = new A(); A asc2 = new A(); if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } does not escape stack-allocatable (locally decidable) } return asc1; 113

114 Java Example Program public static A callee(a arg1) { A sac = new A(); A gec = new A(); A asc1 = new A(); A asc2 = new A(); if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } global escapes } return asc1; 114

115 Java Example Program public static A callee(a arg1) { A sac = new A(); A gec = new A(); A asc1 = new A(); A asc2 = new A(); if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } object returned definitely not stack-allocatable thread-locality depends on (any) caller } return asc1; 115

116 Java Example Program public static A callee(a arg1) { A sac = new A(); A gec = new A(); A asc1 = new A(); A asc2 = new A(); if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } object returned (via argument) definitely not stack-allocatable thread-locality depends on caller } return asc1; 116

117 Java Example Program public static A callee(a arg1) { A sac = new A(); A gec = new A(); A asc1 = new A(); A asc2 = new A(); if(...) { arg1.fa1 = asc2; A a = arg1.fa2; A b = a; Example.global = b; } else { Example.global = gec; } object passed in whether stack-allocatable in caller depends on this method } return asc1; 117

118 Java Example Program public static void caller() { A a = new A(); a.fa2 = new Object(); } A r = callee(a); Example.global = r; 118

119 Java Example Program public static void caller() { A a = new A(); a.fa2 = new Object(); escape state depends on callee } A r = callee(a); Example.global = r; 119

120 Java Example Program public static void caller() { A a = new A(); a.fa2 = new Object(); } A r = callee(a); Example.global = r; return value escapes 120

121 Intraprocedural Analysis Statement type: p.f = q Let U =PointsTo p If U = create phantom node O ph and add points-to edge from p to O ph Let V ={v u F v u U fid v = f } For each u U if corresponding field reference node v does not exists, add it to V Add edges in{v D q v V } to CG 121

122 PointsTo? PointsTo(p) = {O1, O2} PointsTo(p) Traverse each outgoing path terminated by a points-to edge Set of all object that can be reached from p = PointsTo-Set 122

123 Intraprocedural Analysis U = add phantom node and points-to edge from arg1 to phantom node 123

124 Intraprocedural Analysis U = add phantom node and points-to edge from arg1 to phantom node 124

125 Intraprocedural Analysis U = add phantom node and points-to edge from arg1 to phantom node V = add field node fa1 to every object U 125

126 Intraprocedural Analysis U = add phantom node and points-to edge from arg1 to phantom node V = add field node fa1 to every object U 126

127 Intraprocedural Analysis U = add phantom node and points-to edge from arg1 to phantom node V = add field node fa1 to every object U Add deferred edges from fa1 to asc2 for every v V 127

128 Intraprocedural Analysis U = add phantom node and points-to edge from arg1 to phantom node V = add field node fa1 to every object U Add deferred edges from fa1 to asc2 for every v V 128

129 Intraprocedural Analysis Statement type: p = q.f Let U =PointsTo q If U = create phantom node O ph and add points-to edge from p to O ph Let V ={v u F v u U fid v = f } For each u U if corresponding field reference node v does not exists, add it to V Apply ByPass p Add edges in {v D q v V } to CG Precisely, transform first: A a = null; a = arg1.fa2; 129

130 Intraprocedural Analysis Statement type: p = q.f Get objects q possibly points to Lazily add field node f to objects ByPass(p) Add object p D f to CG for each Precisely, transform first: A a = null; a = arg1.fa2; 130

131 Intraprocedural Analysis U ={S5} V = add field node fa2 to every object U 131

132 Intraprocedural Analysis U ={S5} V = add field node fa2to every object U 132

133 Intraprocedural Analysis U ={S5} V = add field node fa2 to every object U Apply ByPass a Add deferred edges from a to fa2 for every v V 133

134 Intraprocedural Analysis U ={S5} V = add field node fa2 to every object U Apply ByPass a Add deferred edges from a to fa2 for every v V 134

135 MapsTo-Relation Formally 1 a i a i 2 O p PointsTo p O q PointsTo q, if p=a i q= a i, or p=o.f q= O. g O O fid f = fid g 135

136 Interprocedural Analysis Conservative solution Consider all arg-escape nodes in callee as not thread-local (i.e. accessed by more than one thread) 136

Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis

Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis JONG-DEOK CHOI, MANISH GUPTA, MAURICIO J. SERRANO, VUGRANAM C. SREEDHAR and SAMUEL P. MIDKIFF This article presents an

More information

Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis

Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis JONG-DEOK CHOI, MANISH GUPTA, MAURICIO J. SERRANO, and VUGRANAM C. SREEDHAR IBM SAMUEL P. MIDKIFF Purdue University This

More information

Escape Analysis for Java

Escape Analysis for Java Escape Analysis for Java Jong-Deok Choi Manish Gupta Mauricio Serrano Vugranam C. Sreedhar Sam Midkiff IBM T. J. Watson Research Center P. O. Box 218, Yorktown Heights, NY 10598 dchoi, mgupta, mserrano,

More information

Escape Analysis for Java

Escape Analysis for Java Escape Analysis for Java Jong-eok Choi Manish Gupta Mauricio Serrano Vugranam C. Sreedhar Sam Midkiff IBM T. J. Watson Research Center P. O. Box 218, Yorktown Heights, NY 10598 jdchoi, mgupta, mserrano,

More information

Pointer Analysis in the Presence of Dynamic Class Loading. Hind Presented by Brian Russell

Pointer Analysis in the Presence of Dynamic Class Loading. Hind Presented by Brian Russell Pointer Analysis in the Presence of Dynamic Class Loading Martin Hirzel, Amer Diwan and Michael Hind Presented by Brian Russell Claim: First nontrivial pointer analysis dealing with all Java language features

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

Write Barrier Removal by Static Analysis

Write Barrier Removal by Static Analysis Write Barrier Removal by Static Analysis Karen Zee and Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Cambridge, MA 02139 {kkz, rinard@lcs.mit.edu ABSTRACT We present

More information

Lecture 5. Data Flow Analysis

Lecture 5. Data Flow Analysis Lecture 5. Data Flow Analysis Wei Le 2014.10 Abstraction-based Analysis dataflow analysis: combines model checking s fix point engine with abstract interpretation of data values abstract interpretation:

More information

Compositional Pointer and Escape Analysis for Java Programs

Compositional Pointer and Escape Analysis for Java Programs Compositional Pointer and Escape Analysis for Java Programs based on the paper by John Whaley and Martin Rinard presented by Natalia Prytkova 28.06.2010 Universität des Saarlandes Motivation The aim: Optimization

More information

Introduction A Tiny Example Language Type Analysis Static Analysis 2009

Introduction A Tiny Example Language Type Analysis Static Analysis 2009 Introduction A Tiny Example Language Type Analysis 2009 Michael I. Schwartzbach Computer Science, University of Aarhus 1 Questions About Programs Does the program terminate? How large can the heap become

More information

Interprocedural Dataflow Analysis. Galeotti/Gorla/Rau Saarland University

Interprocedural Dataflow Analysis. Galeotti/Gorla/Rau Saarland University Interprocedural Dataflow Analysis Galeotti/Gorla/Rau Saarland University int divbyx(int x) { [result := 10/x] 1 ; void caller1() { [x := 5] 1 ; [y := divbyx(x)] 2 ; [y := divbyx(5)] 3 ; [y := divbyx(1)]

More information

The Perfect Getaway: Using Escape Analysis in Embedded Real-Time Systems

The Perfect Getaway: Using Escape Analysis in Embedded Real-Time Systems The Perfect Getaway: Using Escape Analysis in Embedded Real-Time Systems ISABELLA STILKERICH, CLEMENS LANG, CHRISTOPH ERHARDT, CHRISTIAN BAY, and MICHAEL STILKERICH, Friedrich-Alexander-University Erlangen-Nuremberg

More information

Advanced Compiler Construction

Advanced Compiler Construction CS 526 Advanced Compiler Construction http://misailo.cs.illinois.edu/courses/cs526 INTERPROCEDURAL ANALYSIS The slides adapted from Vikram Adve So Far Control Flow Analysis Data Flow Analysis Dependence

More information

Calvin Lin The University of Texas at Austin

Calvin Lin The University of Texas at Austin Interprocedural Analysis Last time Introduction to alias analysis Today Interprocedural analysis March 4, 2015 Interprocedural Analysis 1 Motivation Procedural abstraction Cornerstone of programming Introduces

More information

Interprocedural Analysis. Motivation. Interprocedural Analysis. Function Calls and Pointers

Interprocedural Analysis. Motivation. Interprocedural Analysis. Function Calls and Pointers Interprocedural Analysis Motivation Last time Introduction to alias analysis Today Interprocedural analysis Procedural abstraction Cornerstone of programming Introduces barriers to analysis Example x =

More information

Contents. 8-1 Copyright (c) N. Afshartous

Contents. 8-1 Copyright (c) N. Afshartous Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10 Introduction to Object-Oriented

More information

Siloed Reference Analysis

Siloed Reference Analysis Siloed Reference Analysis Xing Zhou 1. Objectives: Traditional compiler optimizations must be conservative for multithreaded programs in order to ensure correctness, since the global variables or memory

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

Static Program Analysis Part 9 pointer analysis. Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University

Static Program Analysis Part 9 pointer analysis. Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Static Program Analysis Part 9 pointer analysis Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Agenda Introduction to points-to analysis Andersen s analysis Steensgaards s

More information

Q1: /8 Q2: /30 Q3: /30 Q4: /32. Total: /100

Q1: /8 Q2: /30 Q3: /30 Q4: /32. Total: /100 ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam Three November 20 th 2013 Name: Q1: /8 Q2: /30 Q3: /30 Q4: /32 Total: /100 1/10 For functional call related questions, let s assume

More information

CS 4120 Lecture 31 Interprocedural analysis, fixed-point algorithms 9 November 2011 Lecturer: Andrew Myers

CS 4120 Lecture 31 Interprocedural analysis, fixed-point algorithms 9 November 2011 Lecturer: Andrew Myers CS 4120 Lecture 31 Interprocedural analysis, fixed-point algorithms 9 November 2011 Lecturer: Andrew Myers These notes are not yet complete. 1 Interprocedural analysis Some analyses are not sufficiently

More information

Operational Semantics. One-Slide Summary. Lecture Outline

Operational Semantics. One-Slide Summary. Lecture Outline Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:

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

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

Pointer and Escape Analysis for Multithreaded Programs

Pointer and Escape Analysis for Multithreaded Programs Pointer and Escape Analysis for Multithreaded Programs Alexandru Sălcianu Laboratory for Computer Science Massachusetts Institute of Technology Cambridge, MA 02139 salcianu@lcs.mit.edu Martin Rinard Laboratory

More information

Thread-Sensitive Points-to Analysis for Multithreaded Java Programs

Thread-Sensitive Points-to Analysis for Multithreaded Java Programs Thread-Sensitive Points-to Analysis for Multithreaded Java Programs Byeong-Mo Chang 1 and Jong-Deok Choi 2 1 Dept. of Computer Science, Sookmyung Women s University, Seoul 140-742, Korea chang@sookmyung.ac.kr

More information

Escape Analysis in the Context of Dynamic Compilation and Deoptimization

Escape Analysis in the Context of Dynamic Compilation and Deoptimization Escape Analysis in the Context of Dynamic Compilation and Deoptimization ABSTRACT Thomas Kotzmann Institute for System Software Johannes Kepler University Linz Linz, Austria kotzmann@ssw.jku.at In object-oriented

More information

Azul Systems, Inc.

Azul Systems, Inc. 1 Stack Based Allocation in the Azul JVM Dr. Cliff Click cliffc@azulsystems.com 2005 Azul Systems, Inc. Background The Azul JVM is based on Sun HotSpot a State-of-the-Art Java VM Java is a GC'd language

More information

Optimizing Java Programs in the Presence of. Exceptions. Manish Gupta, Jong-Deok Choi, and Michael Hind

Optimizing Java Programs in the Presence of. Exceptions. Manish Gupta, Jong-Deok Choi, and Michael Hind Optimizing Java Programs in the Presence of Exceptions Manish Gupta, Jong-Deok Choi, and Michael Hind IBM Thomas J. Watson Research Center, P.O. Box 704, Yorktown Heights, NY 10598, USA fmgupta,jdchoi,hindmg@us.ibm.com

More information

CS711 Advanced Programming Languages Pointer Analysis Overview and Flow-Sensitive Analysis

CS711 Advanced Programming Languages Pointer Analysis Overview and Flow-Sensitive Analysis CS711 Advanced Programming Languages Pointer Analysis Overview and Flow-Sensitive Analysis Radu Rugina 8 Sep 2005 Pointer Analysis Informally: determine where pointers (or references) in the program may

More information

Chapter 9 :: Subroutines and Control Abstraction

Chapter 9 :: Subroutines and Control Abstraction Chapter 9 :: Subroutines and Control Abstraction Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter09_Subroutines_and_Control_Abstraction_4e - Tue November

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

Procedure Calls Main Procedure. MIPS Calling Convention. MIPS-specific info. Procedure Calls. MIPS-specific info who cares? Chapter 2.7 Appendix A.

Procedure Calls Main Procedure. MIPS Calling Convention. MIPS-specific info. Procedure Calls. MIPS-specific info who cares? Chapter 2.7 Appendix A. MIPS Calling Convention Chapter 2.7 Appendix A.6 Procedure Calls Main Procedure Call Procedure Call Procedure Procedure Calls Procedure must from any call Procedure uses that main was using We need a convention

More information

More Dataflow Analysis

More Dataflow Analysis More Dataflow Analysis Steps to building analysis Step 1: Choose lattice Step 2: Choose direction of dataflow (forward or backward) Step 3: Create transfer function Step 4: Choose confluence operator (i.e.,

More information

Compilation 2012 Static Analysis

Compilation 2012 Static Analysis Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University Interesting Questions Is every statement reachable? Does every non-void method return a value? Will local variables definitely be

More information

Name: CIS 341 Final Examination 10 December 2008

Name: CIS 341 Final Examination 10 December 2008 Name: CIS 341 Final Examination 10 December 2008 1 /8 2 /12 3 /18 4 /18 5 /14 Total /70 Do not begin the exam until you are told to do so. You have 120 minutes to complete the exam. There are 11 pages

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

Class 6. Review; questions Assign (see Schedule for links) Slicing overview (cont d) Problem Set 3: due 9/8/09. Program Slicing

Class 6. Review; questions Assign (see Schedule for links) Slicing overview (cont d) Problem Set 3: due 9/8/09. Program Slicing Class 6 Review; questions Assign (see Schedule for links) Slicing overview (cont d) Problem Set 3: due 9/8/09 1 Program Slicing 2 1 Program Slicing 1. Slicing overview 2. Types of slices, levels of slices

More information

Chap. 8 :: Subroutines and Control Abstraction

Chap. 8 :: Subroutines and Control Abstraction Chap. 8 :: Subroutines and Control Abstraction Michael L. Scott Programming Language Theory 2015, kkman@sangji.ac.kr 1 Review Of Stack Layout Allocation strategies Static Code Globals Own variables Explicit

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

More information

Static Analysis. Systems and Internet Infrastructure Security

Static Analysis. Systems and Internet Infrastructure Security Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Static Analysis Trent

More information

Concurrent Programming using Threads

Concurrent Programming using Threads Concurrent Programming using Threads Threads are a control mechanism that enable you to write concurrent programs. You can think of a thread in an object-oriented language as a special kind of system object

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

More information

Region Analysis for Imperative Languages

Region Analysis for Imperative Languages Region Analysis for Imperative Languages Radu Rugina and Sigmund Cherem Computer Science Department Cornell University Ithaca, NY 14853 {rugina,siggi}@cs.cornell.edu Abstract This paper presents a region

More information

Names, Scope, and Bindings

Names, Scope, and Bindings Names, Scope, and Bindings COMS W4115 Prof. Stephen A. Edwards Spring 2007 Columbia University Department of Computer Science What s In a Name? Name: way to refer to something else variables, functions,

More information

Chapter 8 :: Subroutines and Control Abstraction. Final Test. Final Test Review Tomorrow

Chapter 8 :: Subroutines and Control Abstraction. Final Test. Final Test Review Tomorrow Chapter 8 :: Subroutines and Control Abstraction Programming Language Pragmatics Michael L. Scott Administrative Notes Final Test Thursday, August 3 2006 at 11:30am No lecture before or after the mid-term

More information

CSE 504: Compiler Design. Runtime Environments

CSE 504: Compiler Design. Runtime Environments Runtime Environments Pradipta De pradipta.de@sunykorea.ac.kr Current Topic Procedure Abstractions Mechanisms to manage procedures and procedure calls from compiler s perspective Runtime Environment Choices

More information

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Shrideep Pallickara Computer Science Colorado State University L6.1 Frequently asked questions from the previous class survey L6.2 SLIDES CREATED BY:

More information

Implementing Subprograms

Implementing Subprograms 1 Implementing Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University CS315 Programming Languages Pinar Duygulu The General Semantics of Calls and Returns 2 The subprogram call and return

More information

COP4020 Fall 2006 Final Exam

COP4020 Fall 2006 Final Exam COP4020 Fall 2006 Final Exam Name: (Please print) Put the answers on these sheets. You can collect 100 points in total for this exam. 1. Consider the following Ada program fragment: search: loop i := i+1;

More information

Interprocedural Analysis. Dealing with Procedures. Course so far: Terminology

Interprocedural Analysis. Dealing with Procedures. Course so far: Terminology Interprocedural Analysis Course so far: Control Flow Representation Dataflow Representation SSA form Classic DefUse and UseDef Chains Optimizations Scheduling Register Allocation Just-In-Time Compilation

More information

Control Abstraction. Hwansoo Han

Control Abstraction. Hwansoo Han Control Abstraction Hwansoo Han Review of Static Allocation Static allocation strategies Code Global variables Own variables (live within an encapsulation - static in C) Explicit constants (including strings,

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

Programming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions.1

Programming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions.1 Programming Languages and Compilers Qualifying Examination Monday, September 19, 2016 Answer 4 of 6 questions.1 GENERAL INSTRUCTIONS 1. Answer each question in a separate book. 2. Indicate on the cover

More information

CMSC330 Fall 2013 Practice Problems 6 Solutions

CMSC330 Fall 2013 Practice Problems 6 Solutions CMSC330 Fall 2013 Practice Problems 6 Solutions 1. Programming languages a. Describe how functional programming may be used to simulate OOP. An object may be simulated as a tuple, where each element of

More information

Computing Approximate Happens-Before Order with Static and Dynamic Analysis

Computing Approximate Happens-Before Order with Static and Dynamic Analysis Department of Distributed and Dependable Systems Technical report no. D3S-TR-2013-06 May 7, 2018 Computing Approximate Happens-Before Order with Static and Dynamic Analysis Pavel Parízek, Pavel Jančík

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far.

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far. Lecture Outline Operational Semantics of Cool COOL operational semantics Motivation Adapted from Lectures by Profs. Alex Aiken and George Necula (UCB) Notation The rules CS781(Prasad) L24CG 1 CS781(Prasad)

More information

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.! True object-oriented programming: Dynamic Objects Reference Variables D0010E Object-Oriented Programming and Design Lecture 3 Static Object-Oriented Programming UML" knows-about Eckel: 30-31, 41-46, 107-111,

More information

R O O T S Interprocedural Analysis

R O O T S Interprocedural Analysis R O O T S Interprocedural Analysis Aleksandra Biresev s6albire@cs.uni-bonn.de Interprocedural Analysis An interprocedural analysis operates across an entire program, flowing information from call sites

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False

More information

Names, Scope, and Bindings

Names, Scope, and Bindings Names, Scope, and Bindings COMS W4115 Prof. Stephen A. Edwards Fall 2007 Columbia University Department of Computer Science What s In a Name? Name: way to refer to something else variables, functions,

More information

New Compiler Optimizations in the Java HotSpot Virtual Machine

New Compiler Optimizations in the Java HotSpot Virtual Machine New Compiler Optimizations in the Java HotSpot Virtual Machine Steve Dever Steve Goldman Kenneth Russell Sun Microsystems, Inc. TS-3412 Copyright 2006, Sun Microsystems Inc., All rights reserved. 2006

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

Lecture 15 Garbage Collection

Lecture 15 Garbage Collection Lecture 15 Garbage Collection I. Introduction to GC -- Reference Counting -- Basic Trace-Based GC II. Copying Collectors III. Break Up GC in Time (Incremental) IV. Break Up GC in Space (Partial) Readings:

More information

Goal of lecture. Object-oriented Programming. Context of discussion. Message of lecture

Goal of lecture. Object-oriented Programming. Context of discussion. Message of lecture Goal of lecture Object-oriented Programming Understand inadequacies of class languages like Ur- Java Extend Ur-Java so it becomes an object-oriented language Implementation in SaM heap allocation of objects

More information

Compiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts

Compiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts Compiler Structure Source Code Abstract Syntax Tree Control Flow Graph Object Code CMSC 631 Program Analysis and Understanding Fall 2003 Data Flow Analysis Source code parsed to produce AST AST transformed

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

Interprocedural Analysis with Data-Dependent Calls. Circularity dilemma. A solution: optimistic iterative analysis. Example

Interprocedural Analysis with Data-Dependent Calls. Circularity dilemma. A solution: optimistic iterative analysis. Example Interprocedural Analysis with Data-Dependent Calls Circularity dilemma In languages with function pointers, first-class functions, or dynamically dispatched messages, callee(s) at call site depend on data

More information

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content Core Java - SCJP Course content NOTE: For exam objectives refer to the SCJP 1.6 objectives. 1. Declarations and Access Control Java Refresher Identifiers & JavaBeans Legal Identifiers. Sun's Java Code

More information

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1 Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for

More information

System Software Assignment 1 Runtime Support for Procedures

System Software Assignment 1 Runtime Support for Procedures System Software Assignment 1 Runtime Support for Procedures Exercise 1: Nested procedures Some programming languages like Oberon and Pascal support nested procedures. 1. Find a run-time structure for such

More information

Calling Conventions. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See P&H 2.8 and 2.12

Calling Conventions. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See P&H 2.8 and 2.12 Calling Conventions Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H 2.8 and 2.12 Goals for Today Calling Convention for Procedure Calls Enable code to be reused by allowing

More information

Legato: An At-Most-Once Analysis with Applications to Dynamic Configuration Updates

Legato: An At-Most-Once Analysis with Applications to Dynamic Configuration Updates Legato: An At-Most-Once Analysis with Applications to Dynamic Configuration Updates John Toman Paul G. Allen School of Computer Science & Engineering, University of Washington, USA jtoman@cs.washington.edu

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Supporting Nested Procedures James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Memory Layout

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - XX April 4 th, 2006 1 Roadmap Subroutines Allocation Strategies Calling Sequences Parameter Passing Generic Subroutines Exception Handling Co-routines 2 1 Review

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Detecting Read-Only Methods in Java

Detecting Read-Only Methods in Java Detecting Read-Only Methods in Java Jeff Bogda Department of Computer Science University of California Santa Barbara, CA 93106 bogda@cs.ucsb.edu Abstract. One typically defines a read-only method as a

More information

Estimating the Impact of Heap Liveness Information on Space Consumption in Java

Estimating the Impact of Heap Liveness Information on Space Consumption in Java Estimating the Impact of Heap Liveness Information on Space Consumption in Java by R. Shaham, E. Kolodner and M. Sagiv first presented at ISSM'02 presentation: Adrian Moos Contents what is this about?

More information

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] The House of Heap and Stacks Stacks clean up after themselves But over deep recursions they fret The cheerful heap has nary a care Harboring memory

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Bugs in software. Using Static Analysis to Find Bugs. David Hovemeyer

Bugs in software. Using Static Analysis to Find Bugs. David Hovemeyer Bugs in software Programmers are smart people We have good techniques for finding bugs early: Unit testing, pair programming, code inspections So, most bugs should be subtle, and require sophisticated

More information

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University Processes Design, Spring 2011 Department of Computer Science Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode instruction Execute instruction CPU

More information

Run-time Environments

Run-time Environments Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

More information

Run-time Environments

Run-time Environments Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

More information

CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University

CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

More information

Concurrent Garbage Collection

Concurrent Garbage Collection Concurrent Garbage Collection Deepak Sreedhar JVM engineer, Azul Systems Java User Group Bangalore 1 @azulsystems azulsystems.com About me: Deepak Sreedhar JVM student at Azul Systems Currently working

More information

Parallel Memory Defragmentation on a GPU

Parallel Memory Defragmentation on a GPU Parallel Memory Defragmentation on a GPU Ronald Veldema, Michael Philippsen University of Erlangen-Nuremberg Germany Informatik 2 Programmiersysteme Martensstraße 3 91058 Erlangen Motivation Application

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Program Static Analysis. Overview

Program Static Analysis. Overview Program Static Analysis Overview Program static analysis Abstract interpretation Data flow analysis Intra-procedural Inter-procedural 2 1 What is static analysis? The analysis to understand computer software

More information

Alias Analysis in Java with Reference-Set Representation for High-Performance Computing

Alias Analysis in Java with Reference-Set Representation for High-Performance Computing Alias Analysis in Java with Reference-Set Representation for High-Performance Computing Jongwook Woo Department of Computer Information Systems California State University Los Angeles, CA 90032 jwoo5@calstatela.edu

More information

Chapter 10. Implementing Subprograms ISBN

Chapter 10. Implementing Subprograms ISBN Chapter 10 Implementing Subprograms ISBN 0-321-33025-0 Chapter 10 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables

More information

Scope, Functions, and Storage Management

Scope, Functions, and Storage Management Scope, Functions, and Storage Management Implementing Functions and Blocks cs3723 1 Simplified Machine Model (Compare To List Abstract Machine) Registers Code Data Program Counter (current instruction)

More information

CS159. Nathan Sprague

CS159. Nathan Sprague CS159 Nathan Sprague What s wrong with the following code? 1 /* ************************************************** 2 * Return the mean, or -1 if the array has length 0. 3 ***************************************************

More information

CS 153 Lab4 and 5. Kishore Kumar Pusukuri. Kishore Kumar Pusukuri CS 153 Lab4 and 5

CS 153 Lab4 and 5. Kishore Kumar Pusukuri. Kishore Kumar Pusukuri CS 153 Lab4 and 5 CS 153 Lab4 and 5 Kishore Kumar Pusukuri Outline Introduction A thread is a straightforward concept : a single sequential flow of control. In traditional operating systems, each process has an address

More information

Certified Memory Usage Analysis

Certified Memory Usage Analysis Certified Memory Usage Analysis David Cachera, Thomas Jensen, David Pichardie, Gerardo Schneider IRISA, ENS Cachan Bretagne, France Context Embedded devices (smart cards, mobile phones) memory is limited

More information

Running class Timing on Java HotSpot VM, 1

Running class Timing on Java HotSpot VM, 1 Compiler construction 2009 Lecture 3. A first look at optimization: Peephole optimization. A simple example A Java class public class A { public static int f (int x) { int r = 3; int s = r + 5; return

More information

Plan. Regression testing: Demo of how to use the regress.sh script.

Plan. Regression testing: Demo of how to use the regress.sh script. Plan PA3 and PA4 Look at PA3 peer reviews and some code. PA3 demos Make sure to indicate group(s) you were in and groups you are building off of in README. You must cite other people s code if you use

More information

Run-time Environments - 2

Run-time Environments - 2 Run-time Environments - 2 Y.N. Srikant Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Outline of the Lecture n What is run-time

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

Run-Time Environments/Garbage Collection

Run-Time Environments/Garbage Collection Run-Time Environments/Garbage Collection Department of Computer Science, Faculty of ICT January 5, 2014 Introduction Compilers need to be aware of the run-time environment in which their compiled programs

More information