Mercurial > hg > graal-jvmci-8
diff src/share/vm/c1/c1_Canonicalizer.cpp @ 6135:8f37087fc13f
7171890: C1: add Class.isInstance intrinsic
Summary: Class.cast which calls Class.isInstance is heavily used by the new JSR 292 implementation
Reviewed-by: roland
Contributed-by: Krystal Mok <rednaxelafx@gmail.com>
author | roland |
---|---|
date | Tue, 05 Jun 2012 10:15:27 +0200 |
parents | c8289830e172 |
children | e1635876b206 |
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Canonicalizer.cpp Fri Jun 01 11:25:12 2012 -0700 +++ b/src/share/vm/c1/c1_Canonicalizer.cpp Tue Jun 05 10:15:27 2012 +0200 @@ -456,6 +456,28 @@ } break; } + case vmIntrinsics::_isInstance : { + assert(x->number_of_arguments() == 2, "wrong type"); + + InstanceConstant* c = x->argument_at(0)->type()->as_InstanceConstant(); + if (c != NULL && !c->value()->is_null_object()) { + // ciInstance::java_mirror_type() returns non-NULL only for Java mirrors + ciType* t = c->value()->as_instance()->java_mirror_type(); + if (t->is_klass()) { + // substitute cls.isInstance(obj) of a constant Class into + // an InstantOf instruction + InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state()); + set_canonical(i); + // and try to canonicalize even further + do_InstanceOf(i); + } else { + assert(t->is_primitive_type(), "should be a primitive type"); + // cls.isInstance(obj) always returns false for primitive classes + set_constant(0); + } + } + break; + } } }