Given a graph:
Point p = new Point;
PointHolder h = new PointHolder;
h.p = p;
int x = p.x;
escape(h);
Then, we should be able to determine that even when p is stored into h.p, the memory has not escaped because h has not escaped, and p has not escaped until escape(h). This allows us to fold the load int x = p.x.
The difficulties is that now there is a memory location that can alias p. And we need to ensure that any load from it is visited when deciding the escape status. For example:
Point p = new Point;
PointHolder h = new PointHolder;
h.p = p;
do_something;
Point q = h.p;
escape(q);
Then, we need to ensure that p escapes at the call escape(q).
Point p = new Point;
PointHolder h = new PointHolder;
h.p = p;
int x = p.x;
escape(h);
Then, we should be able to determine that even when p is stored into h.p, the memory has not escaped because h has not escaped, and p has not escaped until escape(h). This allows us to fold the load int x = p.x.
The difficulties is that now there is a memory location that can alias p. And we need to ensure that any load from it is visited when deciding the escape status. For example:
Point p = new Point;
PointHolder h = new PointHolder;
h.p = p;
do_something;
Point q = h.p;
escape(q);
Then, we need to ensure that p escapes at the call escape(q).
- relates to
-
JDK-8373495 C2: Aggressively fold loads from objects that have not escaped
-
- Open
-