< prev index next >

src/hotspot/share/opto/compile.cpp

Print this page




4285     cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type);
4286   }
4287 }
4288 
4289 //----------------------------static_subtype_check-----------------------------
4290 // Shortcut important common cases when superklass is exact:
4291 // (0) superklass is java.lang.Object (can occur in reflective code)
4292 // (1) subklass is already limited to a subtype of superklass => always ok
4293 // (2) subklass does not overlap with superklass => always fail
4294 // (3) superklass has NO subtypes and we can check with a simple compare.
4295 int Compile::static_subtype_check(ciKlass* superk, ciKlass* subk) {
4296   if (StressReflectiveCode || superk == NULL || subk == NULL) {
4297     return SSC_full_test;       // Let caller generate the general case.
4298   }
4299 
4300   if (superk == env()->Object_klass()) {
4301     return SSC_always_true;     // (0) this test cannot fail
4302   }
4303 
4304   ciType* superelem = superk;
4305   if (superelem->is_array_klass())






4306     superelem = superelem->as_array_klass()->base_element_type();

4307 
4308   if (!subk->is_interface()) {  // cannot trust static interface types yet
4309     if (subk->is_subtype_of(superk)) {
4310       return SSC_always_true;   // (1) false path dead; no dynamic test needed
4311     }
4312     if (!(superelem->is_klass() && superelem->as_klass()->is_interface()) &&
4313         !superk->is_subtype_of(subk)) {
4314       return SSC_always_false;
4315     }
4316   }
4317 
4318   // If casting to an instance klass, it must have no subtypes
4319   if (superk->is_interface()) {
4320     // Cannot trust interfaces yet.
4321     // %%% S.B. superk->nof_implementors() == 1
4322   } else if (superelem->is_instance_klass()) {
4323     ciInstanceKlass* ik = superelem->as_instance_klass();
4324     if (!ik->has_subklass() && !ik->is_interface()) {
4325       if (!ik->is_final()) {
4326         // Add a dependency if there is a chance of a later subclass.




4285     cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type);
4286   }
4287 }
4288 
4289 //----------------------------static_subtype_check-----------------------------
4290 // Shortcut important common cases when superklass is exact:
4291 // (0) superklass is java.lang.Object (can occur in reflective code)
4292 // (1) subklass is already limited to a subtype of superklass => always ok
4293 // (2) subklass does not overlap with superklass => always fail
4294 // (3) superklass has NO subtypes and we can check with a simple compare.
4295 int Compile::static_subtype_check(ciKlass* superk, ciKlass* subk) {
4296   if (StressReflectiveCode || superk == NULL || subk == NULL) {
4297     return SSC_full_test;       // Let caller generate the general case.
4298   }
4299 
4300   if (superk == env()->Object_klass()) {
4301     return SSC_always_true;     // (0) this test cannot fail
4302   }
4303 
4304   ciType* superelem = superk;
4305   if (superelem->is_array_klass()) {
4306     ciArrayKlass* ak = superelem->as_array_klass();
4307     // Do not perform the subtype check on the element klasses for [V? arrays. The runtime type might
4308     // be [V due to [V <: [V? and the klass for [V? and [V is the same but the component mirror is not.
4309     if (ak->is_obj_array_klass() && !ak->storage_properties().is_null_free() && ak->element_klass()->is_valuetype()) {
4310       return SSC_full_test;
4311     }
4312     superelem = superelem->as_array_klass()->base_element_type();
4313   }
4314 
4315   if (!subk->is_interface()) {  // cannot trust static interface types yet
4316     if (subk->is_subtype_of(superk)) {
4317       return SSC_always_true;   // (1) false path dead; no dynamic test needed
4318     }
4319     if (!(superelem->is_klass() && superelem->as_klass()->is_interface()) &&
4320         !superk->is_subtype_of(subk)) {
4321       return SSC_always_false;
4322     }
4323   }
4324 
4325   // If casting to an instance klass, it must have no subtypes
4326   if (superk->is_interface()) {
4327     // Cannot trust interfaces yet.
4328     // %%% S.B. superk->nof_implementors() == 1
4329   } else if (superelem->is_instance_klass()) {
4330     ciInstanceKlass* ik = superelem->as_instance_klass();
4331     if (!ik->has_subklass() && !ik->is_interface()) {
4332       if (!ik->is_final()) {
4333         // Add a dependency if there is a chance of a later subclass.


< prev index next >