Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jit: introduce new JIT state for XS calls
Current JIT recording semantics consider FFI calls as an atomic action regarding the LuaJIT VM: it doesn't change the guest stack at the result, and the only way the flow yields to the VM after leaving it -- return through the corresponding FFI machinery to the place it enters. However, there are ways to break this atomicity via FFI: the lua_State can be replaced with another one, or one can make another Lua call via LuaC API within C function called via FFI on the current lua_State (@mraleph called the latter approach an "FFI sandwich", and I'm strictly against eating it). E.g. Tarantool fibers do not respect the native Lua coroutine switching mechanism, thus current lua_State can be substituted via FFI while recording, with no notification to compiler, tracing another lua_State. Furthermore there is triggers machinery in Tarantool creating the "FFI sandwiches" mentioned above to execute a Lua function, with the same lua_State the action triggering its execution via FFI does. Thereby I propose to mask the JIT state with the introduced LJ_TRACE_XS bit, while calling C function for already recorded FFI semantics. If C call is "atomic" as described above, the JIT state is unmasked and the recording is resumed. Otherwise the recording is asyncroniously aborted. Fixes: tarantool gh-4427 Fixes: tarantool gh-4491
- Loading branch information