1
0

Added JIT std library.

This commit is contained in:
Jon Michael Aanes 2017-01-05 15:07:08 +01:00
parent 616c9f7a6b
commit a333bb2b36

View File

@ -2,6 +2,7 @@
local function_library = {}
local function library_function ( func_def )
-- TODO: Add clause requiring that func_def.func is a builtin.
if func_def.func then
function_library[func_def.func] = func_def
end
@ -237,7 +238,8 @@ library_function {
name = 'newproxy',
para = '',
docs = [[
TODO: Missing documentation.
Undocumented. (And depricated in PUC Lua 5.2)
For info, see: http://stackoverflow.com/questions/23592388/create-new-empty-userdata-from-pure-lua
]]
}
@ -1225,6 +1227,116 @@ Returns a string with a traceback of the call stack. An optional message string
end
--------------------------------------------------------------------------------
-- JIT
if jit then
library_function {
func = jit.on,
name = 'jit.on',
para = '[func|true [, true|false]]',
docs = [[
Enables jit compilation, depending upon the given arguments:
- None: Enable entirely
- (func): For the given function
- (true): For the calling function
- (func|true, true): The function and all sub-functions (recursivly).
- (func|true, false): Not the function but all sub-functions (recursivly).
Does not trigger immidiate compilation.
]]
}
library_function {
func = jit.off,
name = 'jit.off',
para = '[func|true [, true|false]]',
docs = [[
Disables jit compilation, depending upon the given arguments:
- None: Disable Entirely
- (func): For the given function
- (true): For the calling function
- (func|true, true): The function and all sub-functions (recursivly).
- (func|true, false): Not the function but all sub-functions (recursivly).
Also flushes the cache of the affected compiled code.
]]
}
library_function {
func = jit.flush,
name = 'jit.flush',
para = '[func|true|trace [, true|false]]',
docs = [[
Flushes cache of compiled code, depending upon the given arguments:
- None: Flush entire cache.
- (func): For the given function
- (true): For the calling function
- (func|true, true): The function and all sub-functions (recursivly).
- (func|true, false): Not the function but all sub-functions (recursivly).
- (trace): Flushes the root trace, specified by its number, and all of its side traces from the cache. The code for the trace will be retained as long as there are any other traces which link to it.
]]
}
library_function {
func = jit.status,
name = 'jit.status',
para = '',
docs = [[
Returns the current status of the JIT compiler.
The first result is either true or false if the JIT compiler is turned on or off.
The remaining results are strings for CPU-specific features and enabled optimizations.
]]
}
library_function {
func = jit.opt and jit.opt.start,
name = 'jit.opt.start',
para = '...',
docs = [[
This sub-module provides the backend for the -O command line option.
You can also use it programmatically, e.g.:
jit.opt.start(2) -- same as -O2
jit.opt.start("-dce")
jit.opt.start("hotloop=10", "hotexit=2")
Unlike in LuaJIT 1.x, the module is built-in and optimization is turned on by default! It's no longer necessary to run require("jit.opt").start(), which was one of the ways to enable optimization.
]]
}
library_function {
func = jit.attach,
name = 'jit.attach',
para = '...',
docs = [[
Undocumented.
For info, see: http://wiki.luajit.org/JIT-Compiler-API
]]
}
for func_name, func in pairs(jit.util or {}) do
library_function {
func = func,
name = 'jit.util.'..func_name,
para = '...',
docs = [[
Undocumented, in flux and thus unstable!
Part of the sub-module for introspection of bytecode, traces, IR and machine code.
For info, see: http://luajit.org/ext_jit.html#jit_util
]]
}
end
end
--------------------------------------------------------------------------------
-- FFI
-- TODO
-- Documentation is here: http://luajit.org/ext_ffi_api.html
--------------------------------------------------------------------------------
return function_library