[stringtemplate-interest] it's 60% of time in ObjectModelAdaptor.getProperty()
Sam Harwell
sharwell at pixelminegames.com
Sun Feb 6 12:59:15 PST 2011
The C# version generates the equivalent of this (one accessor class modeled
but not derived from ExampleAccessor per type/property name):
interface AccessorStub {
Object getValue(Object o);
}
class ExampleAccessor implements AccessorStub {
public Object getValue(Object o) {
return (Object)((T)o).getSomePropertyName();
}
}
This handles auto-boxing as well. I then store the instances of the
accessors in a map from Type->Property name->Accessor. The implementation
for field accesses is similar to this, but emits a ldfld bytecode
instruction instead of a callvirt instruction.
Sam
-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Sunday, February 06, 2011 1:04 PM
To: stringtemplate-interest List
Subject: Re: [stringtemplate-interest] it's 60% of time in
ObjectModelAdaptor.getProperty()
Yep, so i can't really ever see compilation being useful for ST since i
can't add static types.
Ter
On Feb 6, 2011, at 10:06 AM, Oliver Zeigermann wrote:
> You will never know without static type declarations.
>
> 2011/2/6 Terence Parr <parrt at cs.usfca.edu>:
>> here's the issue: what's the type in the cast? we don't know it.
>> Ter
>> On Feb 6, 2011, at 7:23 AM, Johan Stuyts wrote:
>>
>>>> Hi Johan, good idea. Still though, w/o a type, it's still got to
>>>> use .invoke. There is no interface that covers every field /
>>>> method in all possible incoming objects.
>>>
>>> What if you included a cast in the generated bytecode? Then you can
>>> always invoke with type Object.
_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list