comp.lang.ada
 help / color / mirror / Atom feed
From: John Volan <johnv@ac3i.dseg.ti.com>
Subject: Re: Hotspot. Dynamic compilers "better" than static one?
Date: 1998/06/03
Date: 1998-06-03T00:00:00+00:00	[thread overview]
Message-ID: <3576007B.FC0E0827@ac3i.dseg.ti.com> (raw)
In-Reply-To: 3572FDA2.22E1@watson.ibm.com


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. :-)" );




  reply	other threads:[~1998-06-03  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6knj4m$odp$1@nnrp1.dejanews.com>
1998-05-30  0:00 ` Hotspot. Dynamic compilers "better" than static one? nabbasi
1998-05-30  0:00   ` Roedy Green
1998-05-30  0:00     ` Andi Kleen
     [not found]       ` <dewar.896629645@merv>
1998-06-02  0:00         ` Dr Richard A. O'Keefe
1998-06-02  0:00           ` Lieven Marchand
1998-06-01  0:00     ` Norman H. Cohen
1998-06-03  0:00       ` John Volan [this message]
1998-06-05  0:00         ` Norman H. Cohen
1998-06-08  0:00           ` John Volan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox