Persona is no longer an option for authentication on BMO. For more details see Persona Deprecated.
Last Comment Bug 639967 - TI+JM: handle stack patching native calls on x64
: TI+JM: handle stack patching native calls on x64
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: x86_64 Mac OS X
: -- normal (vote)
: ---
Assigned To: general
: Jason Orendorff [:jorendorff]
Depends on: 602333
Blocks: 619433
  Show dependency treegraph
Reported: 2011-03-08 12:44 PST by Brian Hackett (:bhackett)
Modified: 2011-05-09 14:03 PDT (History)
3 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description Brian Hackett (:bhackett) 2011-03-08 12:44:43 PST
When recompiling a function that has an IC making a native call on the stack, we need code for the native to return to which will readjust the machine stack and test the return value.  Currently, we just steal the native stub from the original code and reuse it for the new code.  This doesn't always work on x64 since the jumps to/from the stub could be out of range, and we end up crashing.

This can be fixed in several ways:

1) Still steal the natives, but use far jumps so that we can always steal the stub.
2) Use a more general mechanism to ensure the jumps will be in range, like code motion or restricting the code address space.
3) Emit the tail of the native stub when doing on-stack recompilation of opcodes with old native stubs, but do not steal the whole stub.

2) would apply to all ICs on x64, with or without type inference, and is tricky but something that should be done regardless (as a separate bug) as it hurts our x64 perf.  3) is probably simplest and the best approach for this bug.
Comment 1 Brian Hackett (:bhackett) 2011-05-09 14:03:16 PDT
The needs here changed with bug 650163, where instead of stealing a native stub and giving it to the recompiled script, we steal the stub and orphan it (with a vector and refcount attached to the compartment of orphaned native stubs, after references go to zero all orphaned stubs are destroyed).

Now the jump at the end of the stub has been patched to go to the interpoline, which is more likely to be out of range from the ExecutableAllocator code.  The fix below uses an indirect jump at the end of native stubs, which can be patched to go to any address (this is the only place where such far jumps are needed with recompilation).

Note You need to log in before you can comment on or make changes to this bug.