You're correct. During the GWT compilation, the compiler performs type tightening (or a similar term) where it will reduce your polymorphic call to the appropriate object. For example, if you have a Shape class that has a getArea() method and a subclass called Square that overrides the getArea() method, GWT will do the following to this piece of code:
Shape square = new Square(); int area = square.getArea(); will probably compile to something like: int area = square.x * square.y You can check out Bruce's talk in Google I/O for more details. -- Arthur Kalmenson On Sat, Jan 3, 2009 at 7:09 AM, Jason Morris <[email protected]> wrote: > > [email protected] wrote: >> Hi GWTers >> >> I'm writing some performance sensitive code for GWT. I'm wondering how >> GWT compiles virtual functions to JavaScript. What's the associated >> performance overhead? Obviously I'd like to use proper polymorphism >> but if there's a significant performance overhead it may be worth re- >> factoring various parts of the code-base. >> >> Regards, >> >> Nathan >> > > > Hi Nathan, > > Someone else can correct me if I'm wrong, but after taking a look at the > generated code, it seems > that virtual methods shouldn't incur any additional performance overhead in > GWT. Basically the > bottom level method is given the top-level declared name in each object > instance, thus the lookup > expense is the same as that of a non-virtual method. > > Like I said, if I'm wrong on this, someone should correct me. ;) > > Cheers, > Jason. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
