mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
d141a5c48d
* Fixed exported types not being suggested in autocomplete * `T...` is now convertible to `...any` (Fixes https://github.com/Roblox/luau/issues/767) * Fixed issue with `T?` not being convertible to `T | T` or `T?` (sometimes when internal pointer identity is different) * Fixed potential crash in missing table key error suggestion to use a similar existing key * `lua_topointer` now returns a pointer for strings C++ API Changes: * `prepareModuleScope` callback has moved from TypeChecker to Frontend * For LSPs, AstQuery functions (and `isWithinComment`) can be used without full Frontend data A lot of changes in our two experimental components as well. In our work on the new type-solver, the following issues were fixed: * Fixed table union and intersection indexing * Correct custom type environments are now used * Fixed issue with values of `free & number` type not accepted in numeric operations And these are the changes in native code generation (JIT): * arm64 lowering is almost complete with support for 99% of IR commands and all fastcalls * Fixed x64 assembly encoding for extended byte registers * More external x64 calls are aware of register allocator * `math.min`/`math.max` with more than 2 arguments are now lowered to IR as well * Fixed correctness issues with `math` library calls with multiple results in variadic context and with x64 register conflicts * x64 register allocator learnt to restore values from VM memory instead of always using stack spills * x64 exception unwind information now supports multiple functions and fixes function start offset in Dwarf2 info
112 lines
3.6 KiB
Python
112 lines
3.6 KiB
Python
#!/usr/bin/python3
|
|
# This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
# This code can be used to split lvmexecute.cpp VM switch into separate functions for use as native code generation fallbacks
|
|
import sys
|
|
import re
|
|
|
|
input = sys.stdin.readlines()
|
|
|
|
inst = ""
|
|
|
|
header = """// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
// This file was generated by 'tools/lvmexecute_split.py' script, do not modify it by hand
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
struct lua_State;
|
|
struct Closure;
|
|
typedef uint32_t Instruction;
|
|
typedef struct lua_TValue TValue;
|
|
typedef TValue* StkId;
|
|
|
|
"""
|
|
|
|
source = """// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
|
|
// This file was generated by 'tools/lvmexecute_split.py' script, do not modify it by hand
|
|
#include "Fallbacks.h"
|
|
#include "FallbacksProlog.h"
|
|
|
|
"""
|
|
|
|
function = ""
|
|
signature = ""
|
|
|
|
includeInsts = ["LOP_NEWCLOSURE", "LOP_NAMECALL", "LOP_FORGPREP", "LOP_GETVARARGS", "LOP_DUPCLOSURE", "LOP_PREPVARARGS", "LOP_BREAK", "LOP_GETGLOBAL", "LOP_SETGLOBAL", "LOP_GETTABLEKS", "LOP_SETTABLEKS", "LOP_SETLIST"]
|
|
|
|
state = 0
|
|
|
|
# parse with the state machine
|
|
for line in input:
|
|
# find the start of an instruction
|
|
if state == 0:
|
|
match = re.match("\s+VM_CASE\((LOP_[A-Z_0-9]+)\)", line)
|
|
|
|
if match:
|
|
inst = match[1]
|
|
signature = "const Instruction* execute_" + inst + "(lua_State* L, const Instruction* pc, StkId base, TValue* k)"
|
|
function = signature + "\n"
|
|
function += "{\n"
|
|
function += " [[maybe_unused]] Closure* cl = clvalue(L->ci->func);\n"
|
|
state = 1
|
|
|
|
# first line of the instruction which is "{"
|
|
elif state == 1:
|
|
assert(line == " {\n")
|
|
state = 2
|
|
|
|
# find the end of an instruction
|
|
elif state == 2:
|
|
# remove jumps back into the native code
|
|
if line == "#if LUA_CUSTOM_EXECUTION\n":
|
|
state = 3
|
|
continue
|
|
|
|
if line[0] == ' ':
|
|
finalline = line[12:-1] + "\n"
|
|
else:
|
|
finalline = line
|
|
|
|
finalline = finalline.replace("VM_NEXT();", "return pc;");
|
|
finalline = finalline.replace("goto exit;", "return NULL;");
|
|
finalline = finalline.replace("return;", "return NULL;");
|
|
|
|
function += finalline
|
|
match = re.match(" }", line)
|
|
|
|
if match:
|
|
# break is not supported
|
|
if inst == "LOP_BREAK":
|
|
function = "const Instruction* execute_" + inst + "(lua_State* L, const Instruction* pc, StkId base, TValue* k)\n"
|
|
function += "{\n LUAU_ASSERT(!\"Unsupported deprecated opcode\");\n LUAU_UNREACHABLE();\n}\n"
|
|
# handle fallthrough
|
|
elif inst == "LOP_NAMECALL":
|
|
function = function[:-len(finalline)]
|
|
function += " return pc;\n}\n"
|
|
|
|
if inst in includeInsts:
|
|
header += signature + ";\n"
|
|
source += function + "\n"
|
|
|
|
state = 0
|
|
|
|
# skip LUA_CUSTOM_EXECUTION code blocks
|
|
elif state == 3:
|
|
if line == "#endif\n":
|
|
state = 4
|
|
continue
|
|
|
|
# skip extra line
|
|
elif state == 4:
|
|
state = 2
|
|
|
|
# make sure we found the ending
|
|
assert(state == 0)
|
|
|
|
with open("Fallbacks.h", "w") as fp:
|
|
fp.writelines(header)
|
|
|
|
with open("Fallbacks.cpp", "w") as fp:
|
|
fp.writelines(source)
|