1.1 --- a/src/share/vm/opto/graphKit.cpp Wed Mar 18 11:37:48 2009 -0400 1.2 +++ b/src/share/vm/opto/graphKit.cpp Thu Mar 19 09:13:24 2009 -0700 1.3 @@ -2277,7 +2277,7 @@ 1.4 r_not_subtype->init_req(1, _gvn.transform( new (C, 1) IfTrueNode (iff2) ) ); 1.5 set_control( _gvn.transform( new (C, 1) IfFalseNode(iff2) ) ); 1.6 1.7 - // Check for self. Very rare to get here, but its taken 1/3 the time. 1.8 + // Check for self. Very rare to get here, but it is taken 1/3 the time. 1.9 // No performance impact (too rare) but allows sharing of secondary arrays 1.10 // which has some footprint reduction. 1.11 Node *cmp3 = _gvn.transform( new (C, 3) CmpPNode( subklass, superklass ) ); 1.12 @@ -2286,11 +2286,27 @@ 1.13 r_ok_subtype->init_req(2, _gvn.transform( new (C, 1) IfTrueNode ( iff3 ) ) ); 1.14 set_control( _gvn.transform( new (C, 1) IfFalseNode( iff3 ) ) ); 1.15 1.16 + // -- Roads not taken here: -- 1.17 + // We could also have chosen to perform the self-check at the beginning 1.18 + // of this code sequence, as the assembler does. This would not pay off 1.19 + // the same way, since the optimizer, unlike the assembler, can perform 1.20 + // static type analysis to fold away many successful self-checks. 1.21 + // Non-foldable self checks work better here in second position, because 1.22 + // the initial primary superclass check subsumes a self-check for most 1.23 + // types. An exception would be a secondary type like array-of-interface, 1.24 + // which does not appear in its own primary supertype display. 1.25 + // Finally, we could have chosen to move the self-check into the 1.26 + // PartialSubtypeCheckNode, and from there out-of-line in a platform 1.27 + // dependent manner. But it is worthwhile to have the check here, 1.28 + // where it can be perhaps be optimized. The cost in code space is 1.29 + // small (register compare, branch). 1.30 + 1.31 // Now do a linear scan of the secondary super-klass array. Again, no real 1.32 // performance impact (too rare) but it's gotta be done. 1.33 - // (The stub also contains the self-check of subklass == superklass. 1.34 // Since the code is rarely used, there is no penalty for moving it 1.35 - // out of line, and it can only improve I-cache density.) 1.36 + // out of line, and it can only improve I-cache density. 1.37 + // The decision to inline or out-of-line this final check is platform 1.38 + // dependent, and is found in the AD file definition of PartialSubtypeCheck. 1.39 Node* psc = _gvn.transform( 1.40 new (C, 3) PartialSubtypeCheckNode(control(), subklass, superklass) ); 1.41