comparison 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
comparison
equal deleted inserted replaced
6134:7bc2d5136f54 6135:8f37087fc13f
451 LongConstant* c = x->argument_at(0)->type()->as_LongConstant(); 451 LongConstant* c = x->argument_at(0)->type()->as_LongConstant();
452 if (c != NULL) { 452 if (c != NULL) {
453 JavaValue v; 453 JavaValue v;
454 v.set_jlong(c->value()); 454 v.set_jlong(c->value());
455 set_constant(v.get_jdouble()); 455 set_constant(v.get_jdouble());
456 }
457 break;
458 }
459 case vmIntrinsics::_isInstance : {
460 assert(x->number_of_arguments() == 2, "wrong type");
461
462 InstanceConstant* c = x->argument_at(0)->type()->as_InstanceConstant();
463 if (c != NULL && !c->value()->is_null_object()) {
464 // ciInstance::java_mirror_type() returns non-NULL only for Java mirrors
465 ciType* t = c->value()->as_instance()->java_mirror_type();
466 if (t->is_klass()) {
467 // substitute cls.isInstance(obj) of a constant Class into
468 // an InstantOf instruction
469 InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state());
470 set_canonical(i);
471 // and try to canonicalize even further
472 do_InstanceOf(i);
473 } else {
474 assert(t->is_primitive_type(), "should be a primitive type");
475 // cls.isInstance(obj) always returns false for primitive classes
476 set_constant(0);
477 }
456 } 478 }
457 break; 479 break;
458 } 480 }
459 } 481 }
460 } 482 }