From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10a146,7bdd56c6db71678c X-Google-Attributes: gid10a146,public X-Google-Thread: 103376,b4c0f0f8a3cf7068 X-Google-Attributes: gid103376,public From: John Volan Subject: Re: Hotspot. Dynamic compilers "better" than static one? Date: 1998/06/03 Message-ID: <3576007B.FC0E0827@ac3i.dseg.ti.com>#1/1 X-Deja-AN: 359344793 Content-Transfer-Encoding: 7bit References: <6kocc1$d80@drn.newsguy.com> <6kpk0h$qmo$1@supernews.com> <3572FDA2.22E1@watson.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Raytheon Systems Company, Advanced C3I Systems Newsgroups: comp.lang.java.programmer,comp.lang.ada Date: 1998-06-03T00:00:00+00:00 List-Id: Norman H. Cohen wrote: > > (Translation into Java: Suppose there is a class T with method p and > final subclasses T1, T2, T3, .... If we know that most of the calls on > p are going to be for objects of class T1, the call > > x.p(); > > (where x is of type T) can, in effect, be transformed into > > if ( x instanceof T1 ) { > ((T1)x).p(); > } else { > x.p(); > } > > where the check for the cast to T1 can be optimized away and the call to > ((T1)x).p can be compiled as direct method call to T1's version of p.) Doesn't that presume that T1 is a "final" class (i.e., a leaf on the inheritance tree, with no further subclasses allowed)? Or at least that T1.p() is a "final" method (i.e., locked out from all further overriding in any subclass of T1)? If T1 isn't final, then even the expression (T1)x has to be treated as a potentially polymorphic. Given the JVM's dynamic class-loading mechanism, you can never know when a subclass of T1 might suddenly be pulled into the JVM. If T1.p() isn't final, then the call ((T1)x).p() is still potentially dispatching, so how can the optimization described above be done legally? Note that the Java expression ( x instanceof T1 ) is NOT equivalent to the Ada expression ( A in T1 ) -- i.e., A'Tag = T1'Tag it's equivalent to ( A in T1'Class ) -- i.e., A'Tag = 'Tag of T1 or any subclass of T1 If I'm missing something here, I'd be grateful for a clarification. -- Signature volanSignature = new Signature ( /*name: */ "John G. Volan", /*employer: */ "Raytheon Advanced C3I Systems, San Jose", /*workEmail: */ "johnv@ac3i.dseg.ti.com", /*homeEmail: */ "johnvolan@sprintmail.com", /*selfPlug: */ "Sun Certified Java Programmer", /*twoCents: */ "Java would be even cooler with Ada95's " + "generics, enumerated types, function types, " + "named parameter passing, etc...", /*disclaimer:*/ "These views not packaged in COM.ti.dseg.ac3i, " + "so loading them throws DontQuoteMeError. :-)" );