EFFICIENT AND EFFECTIVE HANDLING OF EXCEPTIONS
IN JAVA POINTS-TO ANALYSIS
George Kastrinis ~ Yannis Smaragdakis University of Athens
method George Kastrinis , Yannis Smaragdakis ~ Efficient and - - PowerPoint PPT Presentation
E FFICIENT AND E FFECTIVE H ANDLING OF E XCEPTIONS IN J AVA P OINTS- T O A NALYSIS George Kastrinis ~ Yannis Smaragdakis University of Athens E XECUTIVE S UMMARY Huge amount of analysis time spent on exceptions They mainly affect
George Kastrinis ~ Yannis Smaragdakis University of Athens
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
What objects may a variable point to?
(statically, object = allocation site)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void foo (...) throws AnException {
...
... }
}
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
arguments return
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
arguments return throw
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
arguments return throw
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
Which one do you think dominates?
more objects that may be thrown out
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
normal flow exceptional flow
Which one do you think dominates?
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
Not per se
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
Overall analysis effect Not per se
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
v = new A(); to = from; to = base.fld; base.fld = from; void meth(..., A arg, ...) { ... return ret; } base.sig(...);
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
v = new A(); to = from; to = base.fld; base.fld = from; void meth(..., A arg, ...) { ... return ret; } base.sig(...); ALLOC (var, obj, meth) OBJTYPE (obj, type) MOVE (to, from) LOAD (to, base, fld) STORE (base, fld, from) FORMALARG (meth, i, arg) FORMALRETURN (meth, ret) VCALL (base, sig, invo)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
v = new A(); to = from; to = base.fld; base.fld = from; void meth(..., A arg, ...) { ... return ret; } base.sig(...); ALLOC (var, obj, meth) OBJTYPE (obj, type) MOVE (to, from) LOAD (to, base, fld) STORE (base, fld, from) FORMALARG (meth, i, arg) FORMALRETURN (meth, ret) VCALL (base, sig, invo)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
and many more... v = new A(); to = from; to = base.fld; base.fld = from; void meth(..., A arg, ...) { ... return ret; } base.sig(...); ALLOC (var, obj, meth) OBJTYPE (obj, type) MOVE (to, from) LOAD (to, base, fld) STORE (base, fld, from) FORMALARG (meth, i, arg) FORMALRETURN (meth, ret) VCALL (base, sig, invo)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
v = new A(); to = from; to = base.fld; base.fld = from; void meth(..., A arg, ...) { ... return ret; } base.sig(...); ALLOC (var, obj, meth) OBJTYPE (obj, type) MOVE (to, from) LOAD (to, base, fld) STORE (base, fld, from) FORMALARG (meth, i, arg) FORMALRETURN (meth, ret) VCALL (base, sig, invo)
Blue is Input
and many more...
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, objCtx)
most important...
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, objCtx) REACHABLE (meth, ctx) CALLGRAPH (invo, callerCtx, meth, calleeCtx)
most important... “On the fly” construction
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, objCtx) REACHABLE (meth, ctx) CALLGRAPH (invo, callerCtx, meth, calleeCtx)
most important... “On the fly” construction
Orange is Output
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, objCtx) REACHABLE (meth, ctx) CALLGRAPH (invo, callerCtx, meth, calleeCtx)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
RECORD (...) = newObjCtx MERGE (...) = newCtx
Pick Your Contexts Well: Understanding Object-Sensitivity
Smaragdakis – Bravenboer – Lhotak
POPL'11
VARPOINTSTO (var, ctx, obj, objCtx) REACHABLE (meth, ctx) CALLGRAPH (invo, callerCtx, meth, calleeCtx)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
P (x), Q (x, z) ← R (x, y, w), S (y, z).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
“Body” If... P (x), Q (x, z) ← R (x, y, w), S (y, z).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
“Body” If... “Head” Then... P (x), Q (x, z) ← R (x, y, w), S (y, z).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
REACHABLE (meth, ctx), ALLOC (var, obj, meth).
var = new ...
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, obj ) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth).
var = new ...
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj ) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth).
var = new ... Variables share context with their methods
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
RECORD (...) = objCtx, VARPOINTSTO (var, ctx, obj, objCtx) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth).
var = new ... Construct a new object context
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
to = from
MOVE (to, from), VARPOINTSTO (from, ctx, obj, objCtx).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
to = from
VARPOINTSTO (to, ctx, obj, objCtx) ← MOVE (to, from), VARPOINTSTO (from, ctx, obj, objCtx).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
to = from Recursion
VARPOINTSTO (to, ctx, obj, objCtx) ← MOVE (to, from), VARPOINTSTO (from, ctx, obj, objCtx).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
N u l l P
n t e r E x c e p t i
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
THROW (instr, e) CATCH (objT, instr, arg)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
THROWPOINTSTO (meth, ctx, obj, objCtx) THROW (instr, e) CATCH (objT, instr, arg)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
“On the fly” handling of exceptions
THROWPOINTSTO (meth, ctx, obj, objCtx) THROW (instr, e) CATCH (objT, instr, arg)
Exception Analysis and Points-to Analysis:Better Together
Bravenboer – Smaragdakis
ISSTA'09
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void meth() { ... throw e; ... }
THROW (instr, e)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void meth() { ... throw e; ... }
THROW (instr, e), VARPOINTSTO (e, ctx, obj, objCtx), OBJTYPE (obj, objT)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void meth() { ... throw e; ... }
THROW (instr, e), VARPOINTSTO (e, ctx, obj, objCtx), OBJTYPE (obj, objT), ¬CATCH (objT, instr, _)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void meth() { ... throw e; ... }
THROWPOINTSTO (meth, ctx, obj, objCtx) ← THROW (instr, e), VARPOINTSTO (e, ctx, obj, objCtx), OBJTYPE (obj, objT), ¬CATCH (objT, instr, _), INMETHOD (instr, meth).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void meth() { try { throw e; } catch (objT arg) {...} }
THROW (instr, e), VARPOINTSTO (e, ctx, obj, objCtx), OBJTYPE (obj, objT), CATCH (objT, instr, arg).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
void meth() { try { throw e; } catch (objT arg) {...} }
VARPOINTSTO (arg, ctx, obj, objCtx) ← THROW (instr, e), VARPOINTSTO (e, ctx, obj, objCtx), OBJTYPE (obj, objT), CATCH (objT, instr, arg).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
antlr bloat eclipse luindex xalan
1000 2000 3000 4000 5000
Context Insensitive
normal flow exceptional flow
(in thousands)
antlr bloat eclipse luindex xalan
20000 40000 60000 80000
1-Call-Site-Sensitive + Heap
normal flow exceptional flow
(in thousands)
antlr bloat eclipse luindex xalan
10000 20000 30000 40000 50000
1-Type-Sensitive + Heap
normal flow exceptional flow
(in thousands)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
RECORD (...) = objCtx, VARPOINTSTO (var, ctx, obj, objCtx) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth).
Recall...
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
RECORD (...) = objCtx, VARPOINTSTO (var, ctx, obj, objCtx) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), ¬EXCEPTIONTYPE (objT).
Change to...
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj ) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, ?) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
Single Context
VARPOINTSTO (var, ctx, obj, “ConstantObjCtx”) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, “ConstantObjCtx”) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT).
Not enough Get more aggressive
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, obj, “ConstantObjCtx”) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
VARPOINTSTO (var, ctx, reprObj, “ConstantObjCtx”) ← REACHABLE (meth, ctx), ALLOC (var, obj, meth), OBJTYPE (obj, objT), EXCEPTIONTYPE (objT), REPRESENTATIVE (obj, reprObj).
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis insensitive 1object 1object+H 2object+H 1type+H 2type+H 1call-site 1call-site+H
500 1000 1500 2000 2500
Eclipse
sensitive insensitive
(seconds)
insensitive 1object 1object+H 1type+H 2type+H 1call-site 1call-site+H
500 1000 1500 2000 2500 3000 3500
Bloat
sensitive insensitive
(seconds)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis insensitive 1object 1object+H 2object+H 1type+H 2type+H 1call-site 1call-site+H
200 400 600 800 1000 1200
Eclipse
insensitive merge
(seconds)
insensitive 1object 1object+H 1type+H 2type+H 1call-site 1call-site+H
500 1000 1500 2000 2500 insensitive merge
(seconds)
Bloat
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
insensitive 1object 1object+H 2object+H 1type+H 2type+H 1call-site 1call-site+H
200 400 600 800 1000 1200
Eclipse
insensitive merge
(seconds)
insensitive 1object 1object+H 1type+H 2type+H 1call-site 1call-site+H
500 1000 1500 2000 2500 insensitive merge
(seconds)
Bloat
Speedup as high as 70% Usually around 50%
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis insensitive 1object+H 2object+H 1type+H 1call-site+H
10000 20000 30000 40000
Eclipse - Context Insensitive Exceptions
normal flow exceptional flow
(in thousands)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis insensitive 1object+H 2object+H 1type+H 1call-site+H
5000 10000 15000 20000
Eclipse - Merge Exceptions
normal flow exceptional flow
(in thousands)
insensitive 1object+H 2object+H 1type+H 1call-site+H
10000 20000 30000 40000
Eclipse - Context Insensitive Exceptions
normal flow exceptional flow
(in thousands)
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis, Yannis Smaragdakis ~ Efficient and Effective Handling of Exceptions in Java Points-To Analysis
George Kastrinis
http://gkastrinis.info