646 void Canonicalizer::do_NewInstance (NewInstance* x) {} |
646 void Canonicalizer::do_NewInstance (NewInstance* x) {} |
647 void Canonicalizer::do_NewTypeArray (NewTypeArray* x) {} |
647 void Canonicalizer::do_NewTypeArray (NewTypeArray* x) {} |
648 void Canonicalizer::do_NewObjectArray (NewObjectArray* x) {} |
648 void Canonicalizer::do_NewObjectArray (NewObjectArray* x) {} |
649 void Canonicalizer::do_NewMultiArray (NewMultiArray* x) {} |
649 void Canonicalizer::do_NewMultiArray (NewMultiArray* x) {} |
650 void Canonicalizer::do_CheckCast (CheckCast* x) { |
650 void Canonicalizer::do_CheckCast (CheckCast* x) { |
651 if (x->klass()->is_loaded() && !x->is_invokespecial_receiver_check()) { |
651 if (x->klass()->is_loaded()) { |
652 Value obj = x->obj(); |
652 Value obj = x->obj(); |
653 ciType* klass = obj->exact_type(); |
653 ciType* klass = obj->exact_type(); |
654 if (klass == NULL) klass = obj->declared_type(); |
654 if (klass == NULL) { |
655 if (klass != NULL && klass->is_loaded() && klass->is_subtype_of(x->klass())) { |
655 klass = obj->declared_type(); |
656 set_canonical(obj); |
656 } |
657 return; |
657 if (klass != NULL && klass->is_loaded()) { |
|
658 bool is_interface = klass->is_instance_klass() && |
|
659 klass->as_instance_klass()->is_interface(); |
|
660 // Interface casts can't be statically optimized away since verifier doesn't |
|
661 // enforce interface types in bytecode. |
|
662 if (!is_interface && klass->is_subtype_of(x->klass())) { |
|
663 set_canonical(obj); |
|
664 return; |
|
665 } |
658 } |
666 } |
659 // checkcast of null returns null |
667 // checkcast of null returns null |
660 if (obj->as_Constant() && obj->type()->as_ObjectType()->constant_value()->is_null_object()) { |
668 if (obj->as_Constant() && obj->type()->as_ObjectType()->constant_value()->is_null_object()) { |
661 set_canonical(obj); |
669 set_canonical(obj); |
662 } |
670 } |