RFR(L): 8031755: Type speculation should be used to optimize explicit null checks (original) (raw)

Roland Westrelin roland.westrelin at oracle.com
Fri Feb 28 09:43:58 PST 2014


http://cr.openjdk.java.net/~roland/8031755/webrev.00/

Most Type profiling points record whether a null reference was seen but type speculation doesn’t currently take advantage of it. With this change, not only is the type seen at a profiling point feed to type speculation but also whether a null pointer was seen or not. This is then used to optimize null checks.

The _speculative field becomes: const TypePtr* _speculative;

so that if all we know from profiling is that a reference is not null: _speculative = TypePtr::NOT NULL;

When a type is met with a TypePtr (NULL_PTR for instance), the meet must be applied to the speculative types as well. To keep the type system symmetric, the _speculative field had to be moved to class TypePtr. I also moved the _inline_depth there to keep all speculative stuff together but with the current code it could have stayed in class TypeOopPtr.

Traps caused by a failed speculative null check are recorded with speculative traps, similarly to what is done for a failed class check.

I made the following change:

*** 3561,3571 ****

  // Since klasses are different, we require a LCA in the Java
  // class hierarchy - which means we have to fall to at least NotNull.
  if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
    ptr = NotNull;

--- 3706,3715 ——

because I hit a type not symmetric failure that I think it causes:

=== Meet Not Symmetric === t = javax/management/openmbean/OpenType:AnyNull * (inline_depth=-2) this= javax/management/openmbean/ArrayType:TopPTR *,iid=top (inline_depth=InlineDepthTop) mt=(t meet this)= javax/management/openmbean/ArrayType:AnyNull * (inline_depth=-2) t_dual= javax/management/openmbean/OpenType:NotNull *,iid=top (inline_depth=2) this_dual= javax/management/openmbean/ArrayType * mt_dual= javax/management/openmbean/ArrayType:NotNull *,iid=top (inline_depth=2) mt_dual meet t_dual= javax/management/openmbean/OpenType:NotNull * (inline_depth=2) mt_dual meet this_dual= javax/management/openmbean/ArrayType *

Roland.



More information about the hotspot-compiler-dev mailing list