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.
A couple questions:
Overall, the story you tell, I quite like.
From a software engineering perspective we could do a first-cut assist by making AbsoluteAddress assert if you find an AOT slot for the address.
I'm interested in hearing more about the baseline frame requirements. There's a part of me which would like to see a variation on this where the baseline frame dependent AOT stuff is kept slightly distinct from the totally runtime independent stuff. Just makes the cuts more obvious.
I wouldn't worry about codegen emission differences of one well predicted branch.
Serialization and deserialization in C++ tends towards the verbose, not sure there's great answers.