Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/en-us/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,8 @@ object<string, string>
"ffi": "default",
"io": "default",
"jit": "default",
"jit.profile": "default",
"jit.util": "default",
"math": "default",
"os": "default",
"package": "default",
Expand Down
2 changes: 2 additions & 0 deletions doc/pt-br/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,8 @@ object<string, string>
"ffi": "default",
"io": "default",
"jit": "default",
"jit.profile": "default",
"jit.util": "default",
"math": "default",
"os": "default",
"package": "default",
Expand Down
2 changes: 2 additions & 0 deletions doc/zh-cn/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,8 @@ object<string, string>
"ffi": "default",
"io": "default",
"jit": "default",
"jit.profile": "default",
"jit.util": "default",
"math": "default",
"os": "default",
"package": "default",
Expand Down
2 changes: 2 additions & 0 deletions doc/zh-tw/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,8 @@ object<string, string>
"ffi": "default",
"io": "default",
"jit": "default",
"jit.profile": "default",
"jit.util": "default",
"math": "default",
"os": "default",
"package": "default",
Expand Down
22 changes: 16 additions & 6 deletions meta/template/jit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,39 @@
---@class jitlib
---@field version string
---@field version_num number
---@field os string
---@field arch string
---@field os 'Windows'|'Linux'|'OSX'|'BSD'|'POSIX'|'Other'
---@field arch 'x86'|'x64'|'arm'|'arm64'|'arm64be'|'ppc'|'ppc64'|'ppc64le'|'mips'|'mipsel'|'mips64'|'mips64el'|string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you left |string at the end of this union?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some branches support other architectures

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a valid reason. Thanks for the explanation.

jit = {}

---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.on(func, recursive) end
function jit.on(func, recursive)
end

---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.off(func, recursive) end
function jit.off(func, recursive)
end

---@overload fun(...):...
---@overload fun(tr: number)
---@param func function|boolean
---@param recursive? boolean
function jit.flush(func, recursive) end
function jit.flush(func, recursive)
end

---@return boolean status
---@return string ...
---@nodiscard
function jit.status() end
function jit.status()
end

jit.opt = {}

---@param ... any flags
function jit.opt.start(...)
end

return jit
20 changes: 20 additions & 0 deletions meta/template/jit.profile.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---#if not JIT then DISABLE() end
---@meta jit.profile

local profile = {}

---@param mode string
---@param func fun(L:thread,samples:integer,vmst:string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you insert some spaces into your fun() annotations in this file?

---@param func fun(L: thread, samples: integer, vmst: string)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is not supported by formater. You can contribute these changes into the pull.Thanks

function profile.start(mode, func)
end

function profile.stop()
end

---@overload fun(th:thread,fmt:string,depth:integer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

---@param fmt string
---@param depth integer
function profile.dumpstack(fmt, depth)
end

return profile
120 changes: 120 additions & 0 deletions meta/template/jit.util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---#if not JIT then DISABLE() end
---@meta jit.util

---@class Trace
---@class Proto

local util = {}

---@class jit.funcinfo.lua
local funcinfo = {
linedefined = 0,
lastlinedefined = 0,
stackslots = 0,
params = 0,
bytecodes = 0,
gcconsts = 0,
nconsts = 0,
upvalues = 0,
currentline = 0,
isvararg = false,
children = false,
source = "",
loc = "",
---@type Proto[]
proto = {}
}

---@class jit.funcinfo.c
---@field ffid integer|nil
local funcinfo2 = {
addr = 0,
upvalues = 0,
}


---@param func function
---@param pc? integer
---@return jit.funcinfo.c|jit.funcinfo.lua info
function util.funcinfo(func, pc)
end

---@param func function
---@param pc integer
---@return integer? ins
---@return integer? m
function util.funcbc(func, pc)
end

---@param func function
---@param idx integer
---@return any? k
function util.funck(func, idx)
end

---@param func function
---@param idx integer
---@return string? name
function util.funcuvname(func, idx)
end

---@class jit.traceinfo
local traceinfo = {
nins = 0,
nk = 0,
link = 0,
nexit = 0,
linktype = ""
}

---@param tr Trace
---@return jit.traceinfo? info
function util.traceinfo(tr)
end

---@param tr Trace
---@param ref integer
---@return integer? m
---@return integer? ot
---@return integer? op1
---@return integer? op2
---@return integer? prev
function util.traceir(tr, ref)
end

---@param tr Trace
---@param idx integer
---@return any? k
---@return integer? t
---@return integer? slot
function util.tracek(tr, idx)
end

---@class jit.snap : integer[]

---@param tr Trace
---@param sn integer
---@return jit.snap? snap
function util.tracesnap(tr, sn)
end

---@param tr Trace
---@return string? mcode
---@return integer? addr
---@return integer? loop
function util.tracemc(tr)
end

---@overload fun(exitno:integer):integer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---@overload fun(exitno: integer): integer

---@param tr Trace
---@param exitno integer
---@return integer? addr
function util.traceexitstub(tr, exitno)
end

---@param idx integer
---@return integer? addr
function util.ircalladdr(idx)
end

return util
38 changes: 20 additions & 18 deletions script/proto/define.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,26 @@ m.TokenTypes = {
}

m.BuiltIn = {
['basic'] = 'default',
['bit'] = 'default',
['bit32'] = 'default',
['builtin'] = 'default',
['coroutine'] = 'default',
['debug'] = 'default',
['ffi'] = 'default',
['io'] = 'default',
['jit'] = 'default',
['math'] = 'default',
['os'] = 'default',
['package'] = 'default',
['string'] = 'default',
['table'] = 'default',
['table.new'] = 'default',
['table.clear'] = 'default',
['utf8'] = 'default',
['string.buffer']='default',
['basic'] = 'default',
['bit'] = 'default',
['bit32'] = 'default',
['builtin'] = 'default',
['coroutine'] = 'default',
['debug'] = 'default',
['ffi'] = 'default',
['io'] = 'default',
['jit'] = 'default',
['jit.profile'] = 'default',
['jit.util'] = 'default',
['math'] = 'default',
['os'] = 'default',
['package'] = 'default',
['string'] = 'default',
['table'] = 'default',
['table.new'] = 'default',
['table.clear'] = 'default',
['utf8'] = 'default',
['string.buffer'] = 'default',
}

m.InlayHintKind = {
Expand Down