1. A machine-implemented method for just-in-time trace compilation, comprising: collecting a trace of an operation segment of a profiling code; resolving a local pointer of the operation segment to a memory object; and inserting a guard in the trace that invalidates the trace if the local pointer does not resolve to the memory object.