- 
                Notifications
    
You must be signed in to change notification settings  - Fork 173
 
Open
Description
Currently we use heuristics to determine if code is likely to fit in our JIT cache with excessively large bounds to try and ensure code will fit.
Current heuristic at time of this issue being created is one page plus 24-bytes per SSA node, which...usually works at least but we definitely have SSA nodes that are larger than six instructions.
Instead of relying solely on that heuristic (which we still want to reduce fault overheads), we support a guard page on the end of the JIT buffer that is can be hit when the heuristic fails and we can then longjump back to a safe location in the JIT. Pretty straightforward and we already have a longjump implementation that we can use.
Limitations:
- Can't have nested longjumps
- Not worth supporting currently
 
 - Can't do unwinding
- Should be fine, the JIT itself doesn't really need it.
 
 
Overheads:
- Each JIT instance calls the 
SetJumphandler in to a TLSJumpBufand sets a flag that it is currently in a long-jump region- Function is low cost, 14 instructions.
 
 - Fault check is low cost on Linux, fairly high on Arm64ec
- On Linux just check the flag and restore the context from the JumpBuf
 - On Arm64ec it needs to do some ridiculous triple fault and a couple hundred syscalls or something, basically same cost as handling SMC/SIGBUS today. Main reason to still require the heuristic.
 
 
Metadata
Metadata
Assignees
Labels
No labels