Request for review (M): 7171890: C1: add Class.isInstance intrinsic

Christian Thalinger christian.thalinger at oracle.com
Wed May 30 12:43:34 PDT 2012


On May 30, 2012, at 11:49 AM, Rémi Forax wrote:

> Hi Krystal,
> is it also possible to try to trap Class.isAssignableFrom(Class),
> if one of Class is constant ?

If Kris has time, why not.  The Class.isInstance is important now because we will heavily use it in the new JSR 292 implementation.  For JRuby's red-black tree it used 67% of the run time (yeah, JNI is expensive).

-- Chris

> 
> Rémi
> 
> On 05/30/2012 05:31 PM, Krystal Mok wrote:
>> Hi all,
>> 
>> Could I have a couple of review for this change, please?
>> https://gist.github.com/2830194#file_c1_is_instance.patch
>> 
>> This patch implements Class.isInstance() intrinsic in C1.
>> As a first cut, the current implementation is pretty straightforward:
>> 1. During HIR construction, Class.isInstance() is inlined as an Intrinsic node
>>   in GraphBuilder::try_inline_intrinsics();
>> 2. Try to canonicalize the Intrinsic node into an InstanceOf node when
>>   appending the node to the HIR graph;
>> 3. Generate a leaf call to a runtime helper (Runtime1::is_instance_of) during
>>   LIR generation for the remaining Intrinsic nodes for Class.isInstance().
>>   This keeps the change platform-independent.
>> 
>> There are several opportunities for more optimizations. e.g.
>> 1. Turn more Intrinsic nodes into InstanceOf nodes during HIR optimizations and
>>   during LIR generation;
>> 2. Check the clazz.isInstance(null) case in a couple of places *after* clazz is
>>   null-checked or guaranteed to be non-null; turn that into a constant false.
>> 3. Follow the lir_store_check example for better platform-dependent performance
>> 
>> These shall be addressed in some future change, if necessary.
>> 
>> Regards,
>> Kris
> 



More information about the hotspot-compiler-dev mailing list