diff options
author | Mike Pall <mike> | 2012-10-21 19:15:03 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-10-21 19:17:14 +0200 |
commit | 1d5c2ce4e295562daddfe6ce8e470749f0d42542 (patch) | |
tree | e56ef2c9b51a466654548bb52a0ebaf7f9cb6e3d /doc | |
parent | f6536c6696deca9fb7b9744573406c83f0f893a4 (diff) | |
download | luajit-1d5c2ce4e295562daddfe6ce8e470749f0d42542.tar.gz luajit-1d5c2ce4e295562daddfe6ce8e470749f0d42542.tar.bz2 luajit-1d5c2ce4e295562daddfe6ce8e470749f0d42542.zip |
Replace error with PANIC for callbacks from JIT-compiled code.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ext_ffi_semantics.html | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html index f8da1e60..ab02f2b8 100644 --- a/doc/ext_ffi_semantics.html +++ b/doc/ext_ffi_semantics.html | |||
@@ -934,6 +934,22 @@ advisable in general. Do this only if you know the C function, that | |||
934 | called the callback, copes with the forced stack unwinding and doesn't | 934 | called the callback, copes with the forced stack unwinding and doesn't |
935 | leak resources. | 935 | leak resources. |
936 | </p> | 936 | </p> |
937 | <p> | ||
938 | One thing that's not allowed, is to let an FFI call into a C function | ||
939 | get JIT-compiled, which in turn calls a callback, calling into Lua again. | ||
940 | Usually this attempt is caught by the interpreter first and the | ||
941 | C function is blacklisted for compilation. | ||
942 | </p> | ||
943 | <p> | ||
944 | However, this heuristic may fail under specific circumstances: e.g. a | ||
945 | message polling function might not run Lua callbacks right away and the call | ||
946 | gets JIT-compiled. If it later happens to call back into Lua, you'll get a | ||
947 | VM PANIC with the message <tt>"bad callback"</tt>. Then you'll need to | ||
948 | manually turn off JIT-compilation with | ||
949 | <a href="ext_jit.html#jit_onoff_func"><tt>jit.off()</tt></a> for the | ||
950 | surrounding Lua function that invokes such a message polling function (or | ||
951 | similar). | ||
952 | </p> | ||
937 | 953 | ||
938 | <h3 id="callback_resources">Callback resource handling</h3> | 954 | <h3 id="callback_resources">Callback resource handling</h3> |
939 | <p> | 955 | <p> |