Chris Lattner wrote:> > I'm missing something here. If you lazily compile getDoubleFromOne the > first time it is called, it seems like you are guaranteed to have layout > information, as an instance of "One" is required to be passed in for this > to run. >Right, you got me ;) Thanks for giving a better example.> 1. interpret the first time through the code, then jit compile after the > class is loaded, or: >Not the best way to do: what if you have many field operations on many classes in one method? You'll interpret the function as long as all field operations are not resolved?> 2. jit compile code that is slower than need be (using function calls to > cause the lazy stuff to happen) and then replace it when the class is > loaded. >You mean replace the code at the IR level right? and then recompile the function. You then have the same issue than 1). By the way, this is a classic optimization in Java that all VMs with JIT do (sorry, I don't have links here). Nicolas> -Chris > >
On Tue, 6 Nov 2007, Nicolas Geoffray wrote:> Not the best way to do: what if you have many field operations on many > classes in one method? You'll interpret the function as long as all > field operations are not resolved?right>> 2. jit compile code that is slower than need be (using function calls to >> cause the lazy stuff to happen) and then replace it when the class is >> loaded. >> > > You mean replace the code at the IR level right? and then recompile the > function. You then have the same issue than 1).I don't see how it's the same issue. Once you jit it, it is just machine code. Updating the machine code with better code seems like a reasonable and obvious optimization. -Chris -- http://nondot.org/sabre/ http://llvm.org/
Chris Lattner wrote:> > I don't see how it's the same issue. Once you jit it, it is just machine > code. Updating the machine code with better code seems like a reasonable > and obvious optimization. > >That's what I want to do! ;-) However, from what I understand, your solution is to recompile the method. And I don't want to do that. I only want to dynamically patch the field operation in the native code.