A short update on the current AOT api:
We discussed previously whether ImmPtr is suitable
for AOT interception.
-
ImmPtrshould be the right place to catch runtime ptrs being emitted through the masm. However there are some issues:-
a few uses of
ImmPtr(nullptr)prevent a verified reverse lookup -
Not all
ImmPtrs may want relocs, even if they do contain real addresees. -
Most importantly:
AbsoluteAddressis also used to emit runtime pointers, soImmPtralone doesn't provide total coverage.
To address this, AOT relocations are now explicit with
RelocImmPtrwhich is a wrapper ofImmPtr. This is a shallow abstraction, but it does let usMOZ_CRASHwhen a reverse lookup can't be found. The main downside being someAbsoluteAddreessmust be rewritten to useRelocImmPtrSome points in the code which help tell the story:
-
Some strengths:
- A single pointer type lets codegen opt-in to AOT relocations
and a single choke point in the MASM
movePtroverloaded onRelocImmPtrdoes the reverse lookup and emission.
Some weaknesses:
-
Requires rewriting
AbsoluteAddress->RelocImmPtrif a runtime pointer is emitted through the former. Alternatively, we could leave theAbsoluteAddressand do more interception in masm. -
AOT reloc system still reliant on
BaselineFrame. As we approach the "optimziing JS builtin" story, Ion compiling builtins with AOT relocations seems more compelling. But to do that, a pinned register is probably necessary. -
Shared masm routines like
loadJSContextmust hit the overloadedmovePtreven if called from a non-aot context. While theMOZ_UNLIKELYbranch hint helps, there is still an extra function call. -
Generally lots of boilerplate to serialize / deserialize through the binary format.
Thanks for the response.
Yes we could just whitelist
ImmPtr(nullptr)in the reverse lookup, good point.The original example I had in mind was shared masm routines, such as
loadJSContext, which would hit from a masm that doesn't want AOT.
But actually, we have the AOT state in masm specifically to skip relocations in
such circumstances. I think this was confusion on my part.
I think we should be able to get by purely w/
ImmPtrre
AbsoluteAddress: Yes in that case, especially if we move back to allImmPtr,having the interfaces which receive an
AbsolutePointeralso take part in thereverse-lookup + reloc emission would definitely be the least codegen invasive
approach.