--- old/src/share/vm/opto/graphKit.cpp 2012-06-05 17:03:38.318538731 +0200 +++ new/src/share/vm/opto/graphKit.cpp 2012-06-05 17:03:38.124420396 +0200 @@ -2279,16 +2279,16 @@ // Foo[] fa = blah(); Foo x = fa[0]; fa[1] = x; // Here, the type of 'fa' is often exact, so the store check // of fa[1]=x will fold up, without testing the nullness of x. - switch (static_subtype_check(superk, subk)) { - case SSC_always_false: + switch (C->static_subtype_check(superk, subk)) { + case Compile::SSC_always_false: { Node* always_fail = control(); set_control(top()); return always_fail; } - case SSC_always_true: + case Compile::SSC_always_true: return top(); - case SSC_easy_test: + case Compile::SSC_easy_test: { // Just do a direct pointer compare and be done. Node* cmp = _gvn.transform( new(C, 3) CmpPNode(subklass, superklass) ); @@ -2297,7 +2297,7 @@ set_control( _gvn.transform( new(C, 1) IfTrueNode (iff) ) ); return _gvn.transform( new(C, 1) IfFalseNode(iff) ); } - case SSC_full_test: + case Compile::SSC_full_test: break; default: ShouldNotReachHere(); @@ -2415,56 +2415,6 @@ return _gvn.transform(r_not_subtype); } -//----------------------------static_subtype_check----------------------------- -// Shortcut important common cases when superklass is exact: -// (0) superklass is java.lang.Object (can occur in reflective code) -// (1) subklass is already limited to a subtype of superklass => always ok -// (2) subklass does not overlap with superklass => always fail -// (3) superklass has NO subtypes and we can check with a simple compare. -int GraphKit::static_subtype_check(ciKlass* superk, ciKlass* subk) { - if (StressReflectiveCode) { - return SSC_full_test; // Let caller generate the general case. - } - - if (superk == env()->Object_klass()) { - return SSC_always_true; // (0) this test cannot fail - } - - ciType* superelem = superk; - if (superelem->is_array_klass()) - superelem = superelem->as_array_klass()->base_element_type(); - - if (!subk->is_interface()) { // cannot trust static interface types yet - if (subk->is_subtype_of(superk)) { - return SSC_always_true; // (1) false path dead; no dynamic test needed - } - if (!(superelem->is_klass() && superelem->as_klass()->is_interface()) && - !superk->is_subtype_of(subk)) { - return SSC_always_false; - } - } - - // If casting to an instance klass, it must have no subtypes - if (superk->is_interface()) { - // Cannot trust interfaces yet. - // %%% S.B. superk->nof_implementors() == 1 - } else if (superelem->is_instance_klass()) { - ciInstanceKlass* ik = superelem->as_instance_klass(); - if (!ik->has_subklass() && !ik->is_interface()) { - if (!ik->is_final()) { - // Add a dependency if there is a chance of a later subclass. - C->dependencies()->assert_leaf_type(ik); - } - return SSC_easy_test; // (3) caller can do a simple ptr comparison - } - } else { - // A primitive array type has no subtypes. - return SSC_easy_test; // (3) caller can do a simple ptr comparison - } - - return SSC_full_test; -} - // Profile-driven exact type check: Node* GraphKit::type_check_receiver(Node* receiver, ciKlass* klass, float prob, @@ -2535,7 +2485,7 @@ profile.morphism() == 1) { ciKlass* exact_kls = profile.receiver(0); if (require_klass == NULL || - static_subtype_check(require_klass, exact_kls) == SSC_always_true) { + C->static_subtype_check(require_klass, exact_kls) == Compile::Compile::SSC_always_true) { // If we narrow the type to match what the type profile sees, // we can then remove the rest of the cast. // This is a win, even if the exact_kls is very specific, @@ -2552,7 +2502,7 @@ replace_in_map(not_null_obj, exact_obj); return exact_obj; } - // assert(ssc == SSC_always_true)... except maybe the profile lied to us. + // assert(ssc == Compile::SSC_always_true)... except maybe the profile lied to us. } return NULL; @@ -2652,10 +2602,10 @@ if (tk->singleton()) { const TypeOopPtr* objtp = _gvn.type(obj)->isa_oopptr(); if (objtp != NULL && objtp->klass() != NULL) { - switch (static_subtype_check(tk->klass(), objtp->klass())) { - case SSC_always_true: + switch (C->static_subtype_check(tk->klass(), objtp->klass())) { + case Compile::SSC_always_true: return obj; - case SSC_always_false: + case Compile::SSC_always_false: // It needs a null check because a null will *pass* the cast check. // A non-null value will always produce an exception. return do_null_assert(obj, T_OBJECT);