Open marco-c opened 10 years ago
@andreasgal
Method calls in general aren't very well optimized yet. Especially virtual and interface dispatch is kinda comically slow. I would measure what slows us down most right now before we do this though. Are you sure this is a big cost right now?
Indeed I've noticed a big overhead with functions that override a virtual function. For example: 245ms 84260 com/sun/cldc/io/ResourceInputStream.read.()I On a phone: 14288ms 112518 com/sun/cldc/io/ResourceInputStream.read.()I
It's probably more worth improving method calls in general.
Yeah. We can implement a traditional virtual method table, or since we have JS and cheap hash tables we can implement a virtual method cache on the classInfo object. If you call method m on an object of class C and it triggers implementation n, then basically do C[m] = n and then check that first. That avoids walking the chain of classes in getMethod. The same works for interfaces.
(I would do a cache because most methods are never called, making VMTs large and sparsely used and we avoid regressing startup to create VMTs)
I'm doing it in #337.
Is it possible to reduce the native call overhead? There may be some steps in the invoke* bytecodes that we may skip in the native/override cases.