99
POINTER ANALYSIS EVERYTHING YOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab

YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

POINTER ANALYSIS

EVERYTHINGYOU NEED TO KNOW ABOUT

10 RULESGeorge Kastrinis ~ University of Athens ~ PLAST lab

Page 2: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

BASED ON WORK FROM

● “Efficient and Effective Handling of Exceptions in Java Points-To Analysis” Kastrinis G., Smaragdakis Y. (CC'13)

● “Pick Your Contexts Well: Understanding Object-Sensitivity” Smaragdakis Y., Bravenboer M., Lhoták O. (POPL'11)

● “Strictly Declarative Specification of Sophisticated Points-to Analyses” Bravenboer M., Smaragdakis Y. (OOPSLA'09)

University of Athens ~ PL lab (PLAST)

Yannis Smaragdakis George Kastrinis George Balatsouras

Aggelos Biboudis Kostas Ferles George Kollias Prodromos Gerakios

George Kastrinis ~ University of Athens ~ PLAST lab

Page 3: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 4: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

George Kastrinis ~ University of Athens ~ PLAST lab

Page 5: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→

George Kastrinis ~ University of Athens ~ PLAST lab

Page 6: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→

Represent objects as

allocation sites

George Kastrinis ~ University of Athens ~ PLAST lab

Page 7: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a new A1(), new A2()→

George Kastrinis ~ University of Athens ~ PLAST lab

Page 8: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a new A1(), new A2()→foo::b new A1(), new A2()→bar::b new A1(), new A2()→

George Kastrinis ~ University of Athens ~ PLAST lab

Page 9: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a new A1(), new A2()→foo::b new A1(), new A2()→bar::b new A1(), new A2()→

Not the most precise, right?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 10: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a new A1(), new A2()→

George Kastrinis ~ University of Athens ~ PLAST lab

Page 11: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a new A1(), new A2()→

Add “context” to variables

George Kastrinis ~ University of Athens ~ PLAST lab

Page 12: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a (foo) new A1()→ id::a (bar) new A2()→

Add “context” to variables

George Kastrinis ~ University of Athens ~ PLAST lab

Page 13: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

IN SHORT: WHAT OBJECTS CAN A VARIABLE POINT TO?

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a (foo) new A1()→ id::a (bar) new A2()→foo::b new A1()→bar::b new A2()→

Add “context” to variables

George Kastrinis ~ University of Athens ~ PLAST lab

Page 14: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

10 RULES? NO ALGORITHMS?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 15: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

10 RULES? NO ALGORITHMS?

Using Datalog

George Kastrinis ~ University of Athens ~ PLAST lab

Page 16: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

10 RULES? NO ALGORITHMS?

Using Datalog Purely declarative

George Kastrinis ~ University of Athens ~ PLAST lab

Page 17: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

de·clar·a·tive/di kle( )r tiv/ˈ ə ə

Computing denoting high-level programming languages which can be used to solve problems without requiring the programmer to specify an exact procedure to be followed.

Adjective

~ Oxford dictionaries

George Kastrinis ~ University of Athens ~ PLAST lab

Page 18: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

de·clar·a·tive/di kle( )r tiv/ˈ ə ə

Computing denoting high-level programming languages which can be used to solve problems without requiring the programmer to specify an exact procedure to be followed.

Adjective

~ Oxford dictionaries

From algorithms to specifications

George Kastrinis ~ University of Athens ~ PLAST lab

Page 19: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

George Kastrinis ~ University of Athens ~ PLAST lab

Page 20: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

head

George Kastrinis ~ University of Athens ~ PLAST lab

Page 21: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

body

George Kastrinis ~ University of Athens ~ PLAST lab

Page 22: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

Output relations in red

George Kastrinis ~ University of Athens ~ PLAST lab

Page 23: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

Input relations in blue

George Kastrinis ~ University of Athens ~ PLAST lab

Page 24: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

#1meth(..,from,..)

George Kastrinis ~ University of Athens ~ PLAST lab

Page 25: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#1

invo: meth(..,from,..)meth(..,to,..) {

...}

callerCtx calleeCtx

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

meth(..,from,..)

George Kastrinis ~ University of Athens ~ PLAST lab

Page 26: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#1

invo: meth(..,from,..)meth(..,to,..) {

...}

INTERPROCASSIGN(to, calleeCtx, from, callerCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALARG(invo, i, from), FORMALARG(meth, i, to).

meth(..,from,..)

callerCtx calleeCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 27: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, callerCtx, from, calleeCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALRETURN(invo, to), FORMALRETURN(meth, from).

#2to = meth(..)

George Kastrinis ~ University of Athens ~ PLAST lab

Page 28: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, callerCtx, from, calleeCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALRETURN(invo, to), FORMALRETURN(meth, from).

#2to = meth(..)

invo: to = meth(..)meth(..) { .. return from;}

callerCtx calleeCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 29: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

INTERPROCASSIGN(to, callerCtx, from, calleeCtx) ←

CALLGRAPH(invo, callerCtx, meth, calleeCtx),

ACTUALRETURN(invo, to), FORMALRETURN(meth, from).

#2to = meth(..)

invo: to = meth(..)meth(..) { .. return from;}

calleeCtxcallerCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 30: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

RECORD(heap, ctx) = hctx,

VARPOINTSTO(var, ctx, heap, hctx) ←

REACHABLE(meth, ctx), ALLOC(var, heap, meth).

#3var = new A()

George Kastrinis ~ University of Athens ~ PLAST lab

Page 31: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

RECORD(heap, ctx) = hctx,

VARPOINTSTO(var, ctx, heap, hctx) ←

REACHABLE(meth, ctx), ALLOC(var, heap, meth).

#3var = new A()

meth

var = new A();

ctx

heap

George Kastrinis ~ University of Athens ~ PLAST lab

Page 32: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

RECORD(heap, ctx) = hctx,

VARPOINTSTO(var, ctx, heap, hctx) ←

REACHABLE(meth, ctx), ALLOC(var, heap, meth).

#3var = new A()

meth

var = new A(); heap

hctx

new context!

ctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 33: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

RECORD(heap, ctx) = hctx,

VARPOINTSTO(var, ctx, heap, hctx) ←

REACHABLE(meth, ctx), ALLOC(var, heap, meth).

#3var = new A()

meth

var = new A(); heap

hctx

ctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 34: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx), MOVE(to, from).

#4to = from

George Kastrinis ~ University of Athens ~ PLAST lab

Page 35: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx), MOVE(to, from).

#4to = from

heap

hctx

from

ctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 36: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx), MOVE(to, from).

#4to = from

heap

hctx

from

ctx

to

George Kastrinis ~ University of Athens ~ PLAST lab

Page 37: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx), MOVE(to, from).

#4to = from

heap

hctx

from

ctx

to

ctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 38: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx), MOVE(to, from).

#4to = from

Recursion!

George Kastrinis ~ University of Athens ~ PLAST lab

Page 39: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#5to ≈ from

VARPOINTSTO(to, toCtx, heap, hctx) ←

INTERPROCASSIGN(to, toCtx, from, fromCtx),

VARPOINTSTO(from, fromCtx, heap, hctx).

George Kastrinis ~ University of Athens ~ PLAST lab

Page 40: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#5to ≈ from

VARPOINTSTO(to, toCtx, heap, hctx) ←

INTERPROCASSIGN(to, toCtx, from, fromCtx),

VARPOINTSTO(from, fromCtx, heap, hctx).

from

fromCtx

to

toCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 41: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#5to ≈ from

VARPOINTSTO(to, toCtx, heap, hctx) ←

INTERPROCASSIGN(to, toCtx, from, fromCtx),

VARPOINTSTO(from, fromCtx, heap, hctx).

from

fromCtx

to

toCtx

heap

hctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 42: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#5to ≈ from

VARPOINTSTO(to, toCtx, heap, hctx) ←

INTERPROCASSIGN(to, toCtx, from, fromCtx),

VARPOINTSTO(from, fromCtx, heap, hctx).

from

fromCtx

to

toCtx

heap

hctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 43: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#6base.fld = from

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx),

STORE(base, fld, from), VARPOINTSTO(base, ctx, baseH, baseHCtx).

George Kastrinis ~ University of Athens ~ PLAST lab

Page 44: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#6base.fld = from

heap

hctxfrom

ctx

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx),

STORE(base, fld, from), VARPOINTSTO(base, ctx, baseH, baseHCtx).

George Kastrinis ~ University of Athens ~ PLAST lab

Page 45: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#6base.fld = from

heap

hctxfrom

ctx

base

ctx

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx),

STORE(base, fld, from), VARPOINTSTO(base, ctx, baseH, baseHCtx).

fld

George Kastrinis ~ University of Athens ~ PLAST lab

Page 46: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#6base.fld = from

heap

hctxfrom

ctx

base

ctx

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx),

STORE(base, fld, from), VARPOINTSTO(base, ctx, baseH, baseHCtx).

fldbaseH

baseHCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 47: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#6base.fld = from

heap

hctxfrom

ctx

base

ctx

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx) ←

VARPOINTSTO(from, ctx, heap, hctx),

STORE(base, fld, from), VARPOINTSTO(base, ctx, baseH, baseHCtx).

fldbaseH

baseHCtx

fld

George Kastrinis ~ University of Athens ~ PLAST lab

Page 48: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#7to = base.fld

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(base, ctx, baseH, baseHCtx),

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx), LOAD(to, base, fld).

George Kastrinis ~ University of Athens ~ PLAST lab

Page 49: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#7to = base.fld

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(base, ctx, baseH, baseHCtx),

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx), LOAD(to, base, fld).

base

ctx baseH

baseHCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 50: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#7to = base.fld

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(base, ctx, baseH, baseHCtx),

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx), LOAD(to, base, fld).

base

ctx baseH

baseHCtx

fld

heap

hctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 51: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#7to = base.fld

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(base, ctx, baseH, baseHCtx),

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx), LOAD(to, base, fld).

base

ctx baseH

baseHCtx

fld

heap

hctx

to

fld

George Kastrinis ~ University of Athens ~ PLAST lab

Page 52: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#7to = base.fld

VARPOINTSTO(to, ctx, heap, hctx) ←

VARPOINTSTO(base, ctx, baseH, baseHCtx),

FLDPOINTSTO(baseH, baseHCtx, fld, heap, hctx), LOAD(to, base, fld).

base

ctx baseH

baseHCtx

fld

to

fld

ctx

heap

hctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 53: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#8A::toMeth()

MERGESTATIC(invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

SCALL(toMeth, invo, inMeth), REACHABLE(inMeth, callerCtx).

George Kastrinis ~ University of Athens ~ PLAST lab

Page 54: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#8A::toMeth()

MERGESTATIC(invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

SCALL(toMeth, invo, inMeth), REACHABLE(inMeth, callerCtx).

invo: A::toMeth(..)

inMeth

callerCtx

toMeth

George Kastrinis ~ University of Athens ~ PLAST lab

Page 55: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#8A::toMeth()

MERGESTATIC(invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

SCALL(toMeth, invo, inMeth), REACHABLE(inMeth, callerCtx).

invo: A::toMeth(..)

inMeth

callerCtx

toMeth

callerCtx

new context!

George Kastrinis ~ University of Athens ~ PLAST lab

Page 56: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#8A::toMeth()

MERGESTATIC(invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

SCALL(toMeth, invo, inMeth), REACHABLE(inMeth, callerCtx).

invo: A::toMeth(..)

inMeth

callerCtx

toMeth

calleeCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 57: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

George Kastrinis ~ University of Athens ~ PLAST lab

Page 58: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

invo: base.sig(..)

inMeth

callerCtx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 59: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

George Kastrinis ~ University of Athens ~ PLAST lab

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

invo: base.sig(..)

inMeth

callerCtx heap

hctx

Page 60: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

George Kastrinis ~ University of Athens ~ PLAST lab

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

invo: base.sig(..)

inMeth

callerCtx heap

hctx this

toMeth

Page 61: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

George Kastrinis ~ University of Athens ~ PLAST lab

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

invo: base.sig(..)

inMeth

callerCtx heap

hctx this

toMeth

calleeCtx

new context!

Page 62: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

George Kastrinis ~ University of Athens ~ PLAST lab

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

invo: base.sig(..)

inMeth

callerCtx heap

hctx this

toMeth

calleeCtx

Page 63: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

George Kastrinis ~ University of Athens ~ PLAST lab

Datalog Rules#9MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

base.sig(..)!!

invo: base.sig(..)

inMeth

callerCtx heap

hctx this

toMeth

calleeCtx

Page 64: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#10

George Kastrinis ~ University of Athens ~ PLAST lab

Page 65: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Datalog Rules#10

9 RULES ARE ENOUGH!

George Kastrinis ~ University of Athens ~ PLAST lab

Page 66: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Variety of Analyses

George Kastrinis ~ University of Athens ~ PLAST lab

Page 67: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Variety of Analyses

Just alter the definition of “context”

George Kastrinis ~ University of Athens ~ PLAST lab

Page 68: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

LET'S RECALL WHERE CONTEXTS ARE CREATED

George Kastrinis ~ University of Athens ~ PLAST lab

Page 69: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

RECORD(heap, ctx) = hctx,

VARPOINTSTO(var, ctx, heap, hctx) ←

REACHABLE(meth, ctx), ALLOC(var, heap, meth).

MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

MERGESTATIC(invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

SCALL(toMeth, invo, inMeth), REACHABLE(inMeth, callerCtx).

#3

#8

#9

LET'S RECALL WHERE CONTEXTS ARE CREATED

George Kastrinis ~ University of Athens ~ PLAST lab

Page 70: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

RECORD(heap, ctx) = hctx,

VARPOINTSTO(var, ctx, heap, hctx) ←

REACHABLE(meth, ctx), ALLOC(var, heap, meth).

MERGE(heap, hctx, invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

VARPOINTSTO(this, calleeCtx, heap, hctx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

REACHABLE(inMeth, callerCtx), VCALL(base, sig, invo, inMeth),

VARPOINTSTO(base, callerCtx, heap, hctx),

HEAPTYPE(heap, heapT), LOOKUP(heapT, sig, toMeth),

THISVAR(toMeth, this).

MERGESTATIC(invo, callerCtx) = calleeCtx,

REACHABLE(toMeth, calleeCtx),

CALLGRAPH(invo, callerCtx, toMeth, calleeCtx) ←

SCALL(toMeth, invo, inMeth), REACHABLE(inMeth, callerCtx).

#3

#8

#9

LET'S RECALL WHERE CONTEXTS ARE CREATED

George Kastrinis ~ University of Athens ~ PLAST lab

Method invocation

Object allocation

Page 71: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

CONTEXT INSENSITIVEIGNORE CONTEXT ALTOGETHER

George Kastrinis ~ University of Athens ~ PLAST lab

Page 72: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

CONTEXT INSENSITIVEIGNORE CONTEXT ALTOGETHER

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a new A1(), new A2()→foo::b new A1(), new A2()→bar::b new A1(), new A2()→

George Kastrinis ~ University of Athens ~ PLAST lab

Page 73: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

CONTEXT INSENSITIVEIGNORE CONTEXT ALTOGETHER

RECORD(heap, ctx) = *

MERGE(heap, hctx, invo, callerCtx) = *

MERGESTATIC(invo, callerCtx) = *

Use a single context everywhere!

George Kastrinis ~ University of Athens ~ PLAST lab

Page 74: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

CALL-SITE SENSITIVITYUSE CALL-SITES AS CONTEXTS

George Kastrinis ~ University of Athens ~ PLAST lab

Page 75: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

CALL-SITE SENSITIVITYUSE CALL-SITES AS CONTEXTS

void foo() {a = new A1();b = id(a);

}

void bar() {a = new A2();b = id(a);

}

A id(A a) {return a;

}

foo::a new A1()→bar::a new A2()→ id::a (inv1) new A1()→ id::a (inv2) new A2()→foo::b new A1()→bar::b new A2()→

inv1

inv2

George Kastrinis ~ University of Athens ~ PLAST lab

Page 76: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-CALL-SITE SENSITIVEContext's depth

George Kastrinis ~ University of Athens ~ PLAST lab

Page 77: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-CALL-SITE SENSITIVE

RECORD(heap, ctx) = *

No context for heap abstractions

George Kastrinis ~ University of Athens ~ PLAST lab

Page 78: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-CALL-SITE SENSITIVE

RECORD(heap, ctx) = *

MERGE(heap, hctx, invo, callerCtx) = invo

MERGESTATIC(invo, callerCtx) = invo

George Kastrinis ~ University of Athens ~ PLAST lab

Page 79: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-CALL-SITE SENSITIVE+1-HEAP

Context sensitive heap abstractions

George Kastrinis ~ University of Athens ~ PLAST lab

Page 80: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-CALL-SITE SENSITIVE+1-HEAP

RECORD(heap, ctx) = ctx

George Kastrinis ~ University of Athens ~ PLAST lab

Page 81: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-CALL-SITE SENSITIVE+1-HEAP

RECORD(heap, ctx) = ctx

MERGE(heap, hctx, invo, callerCtx) = invo

MERGESTATIC(invo, callerCtx) = invo

George Kastrinis ~ University of Athens ~ PLAST lab

Page 82: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

OBJECT SENSITIVITYUSE ALLOCATION-SITES AS CONTEXTS

George Kastrinis ~ University of Athens ~ PLAST lab

Page 83: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

OBJECT SENSITIVITYUSE ALLOCATION-SITES AS CONTEXTS

Based on the receiverobject in a method call

George Kastrinis ~ University of Athens ~ PLAST lab

Page 84: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

OBJECT SENSITIVITYUSE ALLOCATION-SITES AS CONTEXTS

Really good for Object-Oriented languages

George Kastrinis ~ University of Athens ~ PLAST lab

Page 85: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

OBJECT SENSITIVITYUSE ALLOCATION-SITES AS CONTEXTS

class C {void meth(Object o) { ... }

}

class Client {void bar(C c1, C c2) {

...c1.meth(obj1);...c2.meth(obj2);

}}

George Kastrinis ~ University of Athens ~ PLAST lab

Page 86: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

OBJECT SENSITIVITYUSE ALLOCATION-SITES AS CONTEXTS

class C {void meth(Object o) { ... }

}

class Client {void bar(C c1, C c2) {

...c1.meth(obj1);...c2.meth(obj2);

}}

#contexts for meth::o?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 87: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

OBJECT SENSITIVITYUSE ALLOCATION-SITES AS CONTEXTS

class C {void meth(Object o) { ... }

}

class Client {void bar(C c1, C c2) {

...c1.meth(obj1);...c2.meth(obj2);

}}

#contexts for meth::o?

#objects (and which) c1 and c2 point to?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 88: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-OBJECT SENSITIVE

RECORD(heap, ctx) = *

No context for heap abstractions

George Kastrinis ~ University of Athens ~ PLAST lab

Page 89: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-OBJECT SENSITIVE

RECORD(heap, ctx) = *

MERGE(heap, hctx, invo, callerCtx) = heap

Use the allocation-site of the receiver object

George Kastrinis ~ University of Athens ~ PLAST lab

Page 90: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-OBJECT SENSITIVE

RECORD(heap, ctx) = *

MERGE(heap, hctx, invo, callerCtx) = heap

MERGESTATIC(invo, callerCtx) = ctx

No receiver object to use!

George Kastrinis ~ University of Athens ~ PLAST lab

Page 91: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

1-OBJECT SENSITIVE

RECORD(heap, ctx) = *

MERGE(heap, hctx, invo, callerCtx) = heap

MERGESTATIC(invo, callerCtx) = ctx

No receiver object to use!

Copy context from caller

George Kastrinis ~ University of Athens ~ PLAST lab

Page 92: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

AND NOW?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 93: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

AND NOW?

● DIFFERENT CONTEXT DEPTHS

George Kastrinis ~ University of Athens ~ PLAST lab

Page 94: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

AND NOW?

● DIFFERENT CONTEXT DEPTHS

● ALTER DEFINITIONS OF RECORD AND MERGE

George Kastrinis ~ University of Athens ~ PLAST lab

Page 95: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

AND NOW?

● DIFFERENT CONTEXT DEPTHS

● ALTER DEFINITIONS OF RECORD AND MERGE

● OTHER TYPES OF CONTEXT

George Kastrinis ~ University of Athens ~ PLAST lab

Page 96: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

AND NOW?

● DIFFERENT CONTEXT DEPTHS

● ALTER DEFINITIONS OF RECORD AND MERGE

● OTHER TYPES OF CONTEXT

● COMBINE DIFFERENT CONTEXTS

George Kastrinis ~ University of Athens ~ PLAST lab

Page 97: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

AND NOW?

● DIFFERENT CONTEXT DEPTHS

● ALTER DEFINITIONS OF RECORD AND MERGE

● OTHER TYPES OF CONTEXT

● COMBINE DIFFERENT CONTEXTSWhat to combine? Where? How?

George Kastrinis ~ University of Athens ~ PLAST lab

Page 98: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

9 Rules 3 Context Functions

x = ∞ Analyses

RECAP

George Kastrinis ~ University of Athens ~ PLAST lab

Page 99: YOU NEED TO KNOW ABOUT POINTER ANALYSIS 10 RULES › pdf › softlab_2012.pdfYOU NEED TO KNOW ABOUT 10 RULES George Kastrinis ~ University of Athens ~ PLAST lab. BASED ON WORK FROM

Hope you enjoyed!http://gkastrinis.infoGeorge Kastrinis ●