[LLVMdev] Newbie questions
archie at dellroad.org
Wed Apr 26 07:01:54 PDT 2006
Alkis Evlogimenos wrote:
> On 4/25/06, Archie Cobbs <archie at dellroad.org> wrote:
>> Alkis Evlogimenos wrote:
>>> On 4/25/06, Archie Cobbs <archie at dellroad.org> wrote:
>>>> Motivation: Java's "first active use" requirement for class initialization.
>>>> When invoking a static method, it's possible that a class may need to
>>>> be initialized, However, when invoking an instance method, that's not
>>>> Perhaps there should be a way in LLVM to specify predicates (or at least
>>>> properties of global variables and parameters) that are known to be true
>>>> at the start of each function... ?
>>> I think this will end up being the same as the null pointer trapping
>>> instruction optimization. The implementation will very likely involve
>>> some pointer to the description of the class. To make this fast this
>>> pointer will be null if the class is not loaded and you trap when you
>>> try to use it and perform initialization. So in the end the same
>>> optimization pass that was used for successive field accesses can be
>>> used for class initialization as well.
>> If that were the implementation then yes that could work. But using
>> a null pointer like this probably wouldn't be the case. In Java you have
>> to load a class before you initialize it, so the pointer to the type
>> structure will already be non-null.
> That is why I said if you want it to be fast :-). My point was that if
> you want this to be fast you need to find a way to make it trap when a
> class is not initialized. If you employ the method you mention below
> for JCVM then you need to perform optimizations to simplify the
I get it. My point however is larger than just this one example.
You can't say "just use a null pointer" for every possible optimization
based on front end information. Maybe that happens to work for
active class checks, but it's not a general answer.
> I.e., my question is the more general one:
> how do optimizations that are specific to the front-end language get
> done? How does the front-end "secret knowledge" get passed through
> somehow so it can be used for optimization purposes?
Archie Cobbs * CTO, Awarix * http://www.awarix.com
More information about the llvm-dev