Commit Graph

807 Commits

Author SHA1 Message Date
Andy Friesen
1126490e24 Merge branch 'upstream' into merge 2023-04-21 14:45:20 -07:00
Andy Friesen
a0f9842ba2 Merge branch 'master' into merge 2023-04-21 14:41:12 -07:00
Andy Friesen
d5cdb687e0 Sync to upstream/release/573 2023-04-21 14:41:03 -07:00
JohnnyMorganz
8ed808eb52
Add prefix and name location to AstTypeReference (#902)
Closes #901
2023-04-17 07:19:56 -07:00
vegorov-rbx
d141a5c48d
Sync to upstream/release/572 (#899)
* 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
2023-04-14 11:06:22 -07:00
Vyacheslav Egorov
33b95582ac Build fix 2023-04-14 16:46:13 +03:00
Vyacheslav Egorov
1ffbf6cd14 Merge branch 'upstream' into merge 2023-04-14 15:06:30 +03:00
Vyacheslav Egorov
70ef0fbc83 Merge branch 'master' into merge 2023-04-14 15:06:24 +03:00
Vyacheslav Egorov
5e771b87ae Sync to upstream/release/572 2023-04-14 15:05:27 +03:00
Petri Häkkinen
7345891f6b
Add lua_getuserdatadtor (#870)
Some userdata objects may need to support manual destruction in addition
to automatic GC. For example, files, threads, GPU resources and objects
with large external allocations.

With Lua, a finalizer can be _generically_ called by invoking the __gc
metamethod manually, but this is currently not possible with tagged
userdata in Luau because it's not possible to query the destructor
associated with an userdata. While it is possible to workaround this by
duplicating the destructor table locally on client side (*), it's more
convenient to deduplicate the data and get the destructor using the API
instead.

(*) Note: a separate destructor table for each VM may be required if the
VMs use different set of tags.

Implementation notes:

1. I first considered adding a typedef for lua_Destructor but
unfortunately there are two kinds of destructors, one with and one
without the lua_State* argument, so I decided against it at this point.
Maybe it should be added later if the destructor API is unified (by
dropping the Lua state pointer argument?).

2. For some reason the conformance test produced warning "qualifier
applied to function type has no meaning; ignored" on VS2017 (possibly
because the test framework does not like function pointers for some
reason?). I silenced this by pulling out the test expressions from those
CHECKs.
2023-04-11 12:46:55 -07:00
Andy Friesen
ba67fb275e
Sync to upstream/release/571 (#895)
* `table.sort` was improved further. It now guarentees N*log(N) time
complexity in the worst case.
* Fix https://github.com/Roblox/luau/issues/880

We are also working on fixing final bugs and crashes in the new type
solver.

On the CodeGen front we have a few things going on:
* We have a smarter register allocator for the x86 JIT
* We lower more instructions on arm64
* The vector constructor builtin is now translated to IR

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-04-07 14:01:29 -07:00
Andy Friesen
395bf5cdf5 Merge branch 'upstream' into merge 2023-04-07 12:56:54 -07:00
Andy Friesen
97f8bf6cd8 Merge branch 'master' into merge 2023-04-07 12:56:51 -07:00
Andy Friesen
5309401f49 Sync to upstream/release/571 2023-04-07 12:56:27 -07:00
vegorov-rbx
d148d7d574
Luau Recap: March 2023 (#886) 2023-03-31 11:52:31 -07:00
vegorov-rbx
1212fdacbf
Sync to upstream/release/570 (#885)
Once again, all of our changes this week are for new type solver and the
JIT.

In the new type solver, we fixed cyclic type alias handling and multiple
stability issues.

In the JIT, our main progress was for arm64, where, after lowering 36%
of instructions, we start seeing first Luau functions executing
natively.
For x64, we performed code cleanup and refactoring to allow for future
optimizations.
2023-03-31 11:42:49 -07:00
Vyacheslav Egorov
d071e410ce g++ build fix 2023-03-31 16:25:13 +03:00
Vyacheslav Egorov
d70df6362e Merge branch 'upstream' into merge 2023-03-31 15:23:00 +03:00
Vyacheslav Egorov
c6b6ab6150 Merge branch 'master' into merge 2023-03-31 15:22:57 +03:00
Vyacheslav Egorov
d1acde36bb Sync to upstream/release/570 2023-03-31 15:21:14 +03:00
Andy Friesen
b4ebad4862
Sync to upstream/release/569 (#878)
All of our changes this week have been focused on the new type solver
and the JIT.

As we march toward feature parity with the old solver, we've tightened
up a bunch of lingering issues with overload resolution, unsealed
tables, and type normalization. We've also fixed a bunch of crashes and
assertion failures in the new solver.

On the JIT front, we've started work on an A64 backend, improved the IR
analysis in a bunch of cases, and implemented assembly generation for
the builtin functions `type()` and `typeof()`.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-03-24 11:03:04 -07:00
Andy Friesen
c9554518c6 Merge branch 'upstream' into merge 2023-03-24 10:35:02 -07:00
Andy Friesen
ce188220ba Merge branch 'master' into merge 2023-03-24 10:34:57 -07:00
Andy Friesen
81200e13f6 Sync to upstream/release/569 2023-03-24 10:34:14 -07:00
Petri Häkkinen
0d6aacf407
RFC: Floor division operator (#832)
[Rendered](https://github.com/petrihakkinen/luau/blob/rfc-floor-division/rfcs/syntax-floor-division-operator.md)
2023-03-20 15:12:48 -07:00
Arseny Kapoulkine
a4b31f940a
Update compatibility.md
Remove weak opposition to `//` operator as we decided to merge the RFC to support it.
2023-03-20 11:09:58 -07:00
vegorov-rbx
42a2805f85
Sync to upstream/release/568 (#865)
* A small subset of control-flow refinements have been added to
recognize type options that are unreachable after a
conditional/unconditional code block. (Fixes
https://github.com/Roblox/luau/issues/356).

Some examples:
```lua
local function f(x: string?)
    if not x then return end

    -- x is 'string' here
end
```
Throwing calls like `error` or `assert(false)` instead of 'return' are
also recognized.
Existing complex refinements like type/typeof and tagged union checks
are expected to work, among others.

To enable this feature, `LuauTinyControlFlowAnalysis` exclusion has to
be removed from `ExperimentalFlags.h`.
If will become enabled unconditionally in the near future.

* Linter has been integrated into the typechecker analysis so that
type-aware lint warnings can work in any mode
`Frontend::lint` methods were deprecated, `Frontend::check` has to be
used instead with `runLintChecks` option set.
Resulting lint warning are located inside `CheckResult`.

* Fixed large performance drop and increased memory consumption when
array is filled at an offset (Fixes
https://github.com/Roblox/luau/issues/590)
* Part of [Type error suppression
RFC](https://github.com/Roblox/luau/blob/master/rfcs/type-error-suppression.md)
was implemented making subtyping checks with `any` type transitive.

---
In our work on the new type-solver:
* `--!nocheck` mode no longer reports type errors
* New solver will not be used for `--!nonstrict` modules until all
issues with strict mode typechecking are fixed
* Added control-flow aware type refinements mentioned earlier

In native code generation:
* `LOP_NAMECALL` has been translated to IR
* `type` and `typeof` builtin fastcalls have been translated to
IR/assembly
* Additional steps were taken towards arm64 support
2023-03-17 12:20:37 -07:00
Vyacheslav Egorov
1c4d7a6be7 Merge branch 'upstream' into merge 2023-03-17 17:00:29 +02:00
Vyacheslav Egorov
bbeec108a7 Merge branch 'master' into merge 2023-03-17 17:00:25 +02:00
Vyacheslav Egorov
e280064f45 Sync to upstream/release/568 2023-03-17 16:59:30 +02:00
Alan Jeffrey
9311c0c57a
Add RFC for type error suppression (#835)
This formalizes our strategy for suppressing type errors, and fixes the
weirdness of `any` being both a top and bottom type.
2023-03-13 19:33:27 -05:00
Arseny Kapoulkine
29d0ea10cf
Add DCR solver to analysis benchmarks (#862)
For now just do this in strict mode. This will help us track performance
over time, although for now the behavior is going to keep changing so
it's not going to be a fully solid metric for a few weeks.
2023-03-13 13:58:29 -07:00
Andy Friesen
1fa8311a18
Sync to upstream/release/567 (#860)
* Fix #817 
* Fix #850 
* Optimize math.floor/ceil/round with SSE4.1
    * Results in a ~7-9% speedup on the math-cordic benchmark.
* Optimized table.sort.
* table.sort is now ~4.1x faster (when not using a predicate) and ~2.1x
faster when using a simple predicate. Performance may improve further in
the future.
* Reorganize the memory ownership of builtin type definitions.
* This is a small initial step toward affording parallel typechecking.

The new type solver is coming along nicely. We are working on fixing
crashes and bugs.

A few major changes to native codegen landed this week:
* Fixed lowering of Luau IR mod instruction when first argument is a
constant
* Added VM register data-flow/capture analysis
* Fixed issues with optimizations in unreachable blocks

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-03-10 12:21:07 -08:00
Andy Friesen
a0fe195305 Merge branch 'upstream' into merge 2023-03-10 11:21:41 -08:00
Andy Friesen
cfee765dc7 Merge branch 'master' into merge 2023-03-10 11:20:20 -08:00
Andy Friesen
4653484913 Sync to upstream/release/567 2023-03-10 11:20:04 -08:00
niansa/tuxifan
78798d4641
Fixed lerp() duplicate when compiling for C++20 (#851) 2023-03-06 04:42:59 -08:00
vegorov-rbx
140e5a1495
Sync to upstream/release/566 (#853)
* Fixed incorrect lexeme generated for string parts in the middle of an
interpolated string (Fixes https://github.com/Roblox/luau/issues/744)
* DeprecatedApi lint can report some issues without type inference
information
* Fixed performance of autocomplete requests when suggestions have large
intersection types (Solves
https://github.com/Roblox/luau/discussions/847)
* Marked `table.getn`/`foreach`/`foreachi` as deprecated ([RFC:
Deprecate
table.getn/foreach/foreachi](https://github.com/Roblox/luau/blob/master/rfcs/deprecate-table-getn-foreach.md))
* With -O2 optimization level, we now optimize builtin calls based on
known argument/return count.
Note that this change can be observable if `getfenv/setfenv` is used to
substitute a builtin, especially if arity is different.
Fastcall heavy tests show a 1-2% improvement.
* Luau can now be built with clang-cl (Fixes
https://github.com/Roblox/luau/issues/736)

We also made many improvements to our experimental components.

For our new type solver:
* Overhauled data flow analysis system, fixed issues with 'repeat'
loops, global variables and type annotations
* Type refinements now work on generic table indexing with a string
literal
* Type refinements will properly track potentially 'nil' values (like
t[x] for a missing key) and their further refinements
* Internal top table type is now isomorphic to `{}` which fixes issues
when `typeof(v) == 'table'` type refinement is handled
* References to non-existent types in type annotations no longer resolve
to 'error' type like in old solver
* Improved handling of class unions in property access expressions
* Fixed default type packs
* Unsealed tables can now have metatables
* Restored expected types for function arguments

And for native code generation:
* Added min and max IR instructions mapping to vminsd/vmaxsd on x64
* We now speculatively extract direct execution fast-paths based on
expected types of expressions which provides better optimization
opportunities inside a single basic block
* Translated existing math fastcalls to IR form to improve tag guard
removal and constant propagation
2023-03-03 12:21:14 -08:00
Vyacheslav Egorov
ac9718e31a Merge branch 'upstream' into merge 2023-03-03 15:53:22 +02:00
Vyacheslav Egorov
ca34b44be6 Merge branch 'master' into merge 2023-03-03 15:53:16 +02:00
Vyacheslav Egorov
9a281f0492 Sync to upstream/release/566 2023-03-03 15:45:38 +02:00
Arseny Kapoulkine
48172dd5b1
Update SECURITY.md
Note that native code gen is currently exempt from any security guarantees as it's a pre-production R&D component right now. This will change in the future as we deploy it to production.
2023-03-01 14:40:40 -08:00
Arseny Kapoulkine
6601c41bff
Correct table.getn/foreach deprecation RFC (#848)
It looks like all three functions actually have been deprecated in Lua
5.1, and removed in Lua 5.2.

We do not plan to remove them to retain backwards compatibility, but the
RFC should be more precise.
2023-02-27 12:30:33 -08:00
Arseny Kapoulkine
aef99ae0d4
docs: Add deprecation notice to getn/foreach/foreachi (#849)
RFC:
https://github.com/Roblox/luau/blob/master/rfcs/deprecate-table-getn-foreach.md
2023-02-27 12:30:23 -08:00
Andy Friesen
d2ab5df62b
Sync to upstream/release/565 (#845)
We've made a few small changes to reduce the amount of stack we use when
typechecking nested method calls (eg `foo:bar():baz():quux()`).

We've also fixed a small bytecode compiler issue that caused us to emit
redundant jump instructions in code that conditionally uses `break` or
`continue`.

On the new solver, we've switched to a new, better way to handle
augmentations to unsealed tables. We've also made some substantial
improvements to type inference and error reporting on function calls.
These things should both be on par with the old solver now.

The main improvements to the native code generator have been elimination
of some redundant type tag checks. Also, we are starting to inline
particular fastcalls directly to IR.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-02-24 13:49:38 -08:00
Andy Friesen
e58bb1b27f GCC fix. 2023-02-24 10:29:24 -08:00
Andy Friesen
7a822c9429 Merge branch 'upstream' into merge 2023-02-24 10:25:04 -08:00
Andy Friesen
3974fcc0e9 Merge branch 'master' into merge 2023-02-24 10:24:58 -08:00
Andy Friesen
1e7b23fbfc Sync to upstream/release/565 2023-02-24 10:24:22 -08:00
B. Gibbons
fbd93cbc03
docs: update readme installation guide (#792)
1. Added information about Homebrew installation (based off this
information [here](https://formulae.brew.sh/formula/luau#default))
2. Added details related to installing binary files that are downloaded
3. Rearranged and added titles for easier reading

Fixes #791.

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2023-02-23 13:08:45 -08:00