Commit Graph

1038 Commits

Author SHA1 Message Date
Andy Friesen
b26eeacfd2 Merge branch 'upstream' into merge 2023-08-04 10:02:13 -07:00
Andy Friesen
e25b717e54 Merge branch 'master' into merge 2023-08-04 10:02:07 -07:00
Andy Friesen
25cc75b096 * Progress toward a diffing algorithm for types. We hope that this will be useful for writing clearer error messages.
* Add a missing recursion limiter in `Unifier::tryUnifyTables`.  This was causing a crash in certain situations.
* Luau heap graph enumeration improvements:
    * Weak references are not reported
    * Added tag as a fallback name of non-string table links
    * Included top Luau function information in thread name to understand where thread might be suspended
* Constant folding for `math.pi` and `math.huge` at -O2
* Optimize `string.format` and `%*`
    * This change makes string interpolation 1.5x-2x faster depending on the number and type of formatted components, assuming a few are using primitive types, and reduces associated GC pressure.

New solver

* Initial work toward tracking the upper and lower bounds of types more accurately.

JIT

* Add IrCmd::CHECK_TRUTHY for improved assert fast-calls
* Do not compute type map for modules without types
* Capture metatable+readonly state for NEW_TABLE IR instructions
* Replace JUMP_CMP_ANY with CMP_ANY and existing JUMP_EQ_INT
* Add support for exits to VM with reentry lock in VmExit
2023-08-04 10:01:35 -07:00
Federico Cassano
fff897a75f
Fix some EBNF cases in grammar.md (#999) 2023-08-02 13:20:57 -07:00
Someon1e
8b510d3dbb
Add dark theme (#991)
Fixes #333 


![image](https://github.com/Roblox/luau/assets/120410318/539fec9f-3ad1-49cd-ba2f-a47b6c1ee42c)

![image](https://github.com/Roblox/luau/assets/120410318/981981c6-2fbe-46ae-99b1-a1fc2c647a6a)

---------

Co-authored-by: Someone-dQw4w9WgXcQ <dcheunggb@outlook.com>
2023-08-01 09:14:02 -07:00
vegorov-rbx
a08c3409b8
Luau Recap: July 2023 (#993)
If this does make it to the Roblox forum, I think I will cut intro about
new type solver and JIT.


[Rendered](https://github.com/vegorov-rbx/luau/blob/post-recap-july-2023/docs/_posts/2023-07-28-luau-recap-july-2023.md)


[Preview](https://vegorov-rbx.github.io/luau/2023/07/28/luau-recap-july-2023.html)
2023-07-31 13:02:24 -07:00
vegorov-rbx
76f67e0733
Sync to upstream/release/588 (#992)
Type checker/autocomplete:
* `Luau::autocomplete` no longer performs typechecking internally, make
sure to run `Frontend::check` before performing autocomplete requests
* Autocomplete string suggestions without "" are now only suggested
inside the ""
* Autocomplete suggestions now include `function (anonymous autofilled)`
key with a full suggestion for the function expression (with arguments
included) stored in `AutocompleteEntry::insertText`
* `AutocompleteEntry::indexedWithSelf` is provided for function call
suggestions made with `:`
* Cyclic modules now see each other type exports as `any` to prevent
memory use-after-free (similar to module return type)

Runtime:
* Updated inline/loop unroll cost model to better handle assignments
(Fixes https://github.com/Roblox/luau/issues/978)
* `math.noise` speed was improved by ~30%
* `table.concat` speed was improved by ~5-7%
* `tonumber` and `tostring` now have fastcall paths that execute ~1.5x
and ~2.5x faster respectively (fixes #777)
* Fixed crash in `luaL_typename` when index refers to a non-existing
value
* Fixed potential out of memory scenario when using `string.sub` or
`string.char` in a loop
* Fixed behavior of some fastcall builtins when called without arguments
under -O2 to match original functions
* Support for native code execution in VM is now enabled by default
(note: native code still has to be generated explicitly)
* `Codegen::compile` now accepts `CodeGen_OnlyNativeModules` flag. When
set, only modules that have a `--!native` hot-comment at the top will be
compiled to native code

In our new typechecker:
* Generic type packs are no longer considered to be variadic during
unification
* Timeout and cancellation now works in new solver
* Fixed false positive errors around 'table' and 'function' type
refinements
* Table literals now use covariant unification rules. This is sound
since literal has no type specified and has no aliases
* Fixed issues with blocked types escaping the constraint solver
* Fixed more places where error messages that should've been suppressed
were still reported
* Fixed errors when iterating over a top table type

In our native code generation (jit):
* 'DebugLuauAbortingChecks' flag is now supported on A64
* LOP_NEWCLOSURE has been translated to IR
2023-07-28 08:13:53 -07:00
Someon1e
087be529b0
Improve demo site (#990)
Updated builtins tables, made `` highlighted as a string, removed code
that replaced "stdin:" from print messages

Before:

![image](https://github.com/Roblox/luau/assets/120410318/ba399f0b-d612-4f69-a523-56369eafb037)
After:

![image](https://github.com/Roblox/luau/assets/120410318/98ab06c8-9b2a-4d9b-aa86-0a8432296417)

---------

Co-authored-by: Someone-dQw4w9WgXcQ <dcheunggb@outlook.com>
2023-07-28 08:11:16 -07:00
Vyacheslav Egorov
4c6a370872 Merge branch 'upstream' into merge 2023-07-28 15:05:40 +03:00
Vyacheslav Egorov
9fd79ade04 Merge branch 'master' into merge 2023-07-28 15:05:00 +03:00
Vyacheslav Egorov
5e1aca164c Sync to upstream/release/588 2023-07-28 14:37:00 +03:00
Arseny Kapoulkine
f80229c517
docs: Document return value for table.remove (#987)
Fixes #984.
2023-07-26 06:42:23 -07:00
MagelessMayhem
743afe6ec9
README.md: Add Gentoo Linux to listed distributions (#976)
Gentoo recently added Luau to their official overlay (the term they use
to describe their package repository) and it would only be appropriate
to include that detail here.

It may as well also be the first distribution to *officially* package
it, given the maintainer is one of Gentoo's own.

Signed-off-by: Sebastian France <MagelessMayhem@protonmail.com>
2023-07-24 07:21:44 -07:00
Alan Jeffrey
57368fbc58
HATRA 23 paper (#979)
A one-page "progress report" paper.
2023-07-21 15:05:26 -05:00
vegorov-rbx
218159140c
Sync to upstream/release/584 (#977)
* Added support for async typechecking cancellation using a token passed
through frontend options
* Added luaC_enumheap for building debug tools that need a graph of Luau
heap

In our new typechecker:
* Errors or now suppressed when checking property lookup of
error-suppressing unions

In our native code generation (jit):
* Fixed unhandled value type in NOT_ANY lowering
* Fast-call tag checks will exit to VM on failure, instead of relying on
a native fallback
* Added vector type to the type information
* Eliminated redundant direct jumps across dead blocks
* Debugger APIs are now disabled for call frames executing natively
* Implemented support for unwind registration on macOS 14
2023-07-14 11:08:53 -07:00
Vyacheslav Egorov
f16d002db9 GCC fix 2023-07-14 10:38:54 -07:00
Vyacheslav Egorov
4ffa98f4df Merge branch 'upstream' into merge 2023-07-14 08:59:07 -07:00
Vyacheslav Egorov
03063d09e4 Merge branch 'master' into merge 2023-07-14 08:59:01 -07:00
Vyacheslav Egorov
b403075573 Sync to upstream/release/584 2023-07-14 08:57:16 -07:00
Andy Friesen
e25de95445
Sync to upstream/release/583 (#974)
* Fixed indexing table intersections using `x["prop"]` syntax:
https://github.com/Roblox/luau/pull/971
* Add console output codepage for Windows:
https://github.com/Roblox/luau/pull/967
* Added `Frontend::parse` for a fast source graph preparation
* luau_load should check GC
* Work toward a type-diff system for nicer error messages

New Solver
* Correctly suppress errors in more cases
* Further improvements to typechecking of function calls and return
statements
* Crash fixes
* Propagate refinements drawn from the condition of a while loop into
the loop body

JIT
* Fix accidental bailout for math.frexp/modf/sign in A64
* Work toward bringing type annotation info in
* Do not propagate Luau IR constants of wrong type into load
instructions
* CHECK_SAFEENV exits to VM on failure
* Implement error handling in A64 reg allocator
* Inline the string.len builtin
* Do not enter native code of a function if arguments don’t match

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-07-07 13:10:48 -07:00
Andy Friesen
dc2a1cc12c GCC fix. 2023-07-07 12:41:34 -07:00
Andy Friesen
b92d4d7d99 Merge branch 'upstream' into merge 2023-07-07 10:14:50 -07:00
Andy Friesen
01cbf185e8 Merge branch 'master' into merge 2023-07-07 10:14:46 -07:00
Andy Friesen
e00dbbeaf2 Sync to upstream/release/583 2023-07-07 10:14:35 -07:00
Lodinu Kalugalage
c98a9d7051
Add console output codepage for windows (#967)
Previously unicode codepoints would be incorrectly shown in windows
terminals, such as with u2503(┃):
```ps
❯ "print('\u{2503}')" | luau.exe
Γöâ
```

This change fixes the issue by setting the console's codepage on
windows, resulting in fixed behaviour:
```ps
❯ "print('\u{2503}')" | luau.exe
┃
```
2023-07-06 13:00:34 -07:00
JohnnyMorganz
a02eb78c96
Fix indexing table intersections using x["prop"] syntax (#971)
Right now, you can index an intersection of tables fine when using
`x.prop` syntax, but not when using `x["prop"]` syntax.
This fixes it for the latter case

```lua
type Foo = {
	Bar: string,
} & { Baz: number }

local x: Foo = { Bar = "1", Baz = 2 }
local y = x["Bar"] -- TypeError: Expected type table, got '{| Bar: string |} & {| Baz: number |}' instead
```

Part of a fix to
https://github.com/Roblox/luau/issues/533#issuecomment-1291779353
2023-07-05 14:32:51 -07:00
vegorov-rbx
76bea81a7b
Sync to upstream/release/582 (#960)
* Optimized operations like instantiation and module export for very
large types

In our new typechecker:
* Typechecking of function calls was rewritten to handle more cases
correctly
* Fixed a crash that can happen after self-referential type is exported
from a module
* Fixed a false positive error in string comparison
* Added handling of `for...in` variable type annotations and fixed
issues with the iterator call inside
* Self-referential 'hasProp' and 'setProp' constraints are now handled
correctly
 
In our native code generation (jit):
* Added '--target' argument to luau-compile to test multiple
architectures different from host architecture
* GC barrier tag check is skipped if type is already known to be
GC-collectable
* Added GET_TYPE/GET_TYPEOF instructions for type/typeof fast-calls
* Improved code size of interrupt handlers on X64
2023-06-23 23:19:39 -07:00
Vyacheslav Egorov
e1a7c3b0f1 Merge branch 'upstream' into merge 2023-06-24 08:34:11 +03:00
Vyacheslav Egorov
7a2f94a6a0 Merge branch 'master' into merge 2023-06-24 08:34:06 +03:00
Vyacheslav Egorov
8bc2f51d89 Sync to upstream/release/582 2023-06-24 08:33:44 +03:00
Andy Friesen
d458d240cd
Sync to upstream/release/581 (#958)
* Definition files can now ascribe indexers to class types.
(https://github.com/Roblox/luau/pull/949)
* Remove --compile support from the REPL. You can just use luau-compile
instead.
* When an exception is thrown during parallel typechecking (usually an
ICE), we now gracefully stop typechecking and drain active workers
before rethrowing the exception.

New solver

* Include more source location information when we hit an internal
compiler error
* Improve the logic that simplifies intersections of tables

JIT

* Save testable type annotations to bytecode
* Improve block placement for linearized blocks
* Add support for lea reg, [rip+offset] for labels
* Unify X64 and A64 codegen for RETURN
* Outline interrupt handlers for X64
* Remove global rArgN in favor of build.abi
* Change A64 INTERRUPT lowering to match X64

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-06-16 10:35:18 -07:00
Andy Friesen
00b9898ffc Merge branch 'upstream' into merge 2023-06-16 10:06:38 -07:00
Andy Friesen
f9cfef16c2 Merge branch 'master' into merge 2023-06-16 10:06:33 -07:00
Andy Friesen
6ee4f190ab Sync to upstream/release/581 2023-06-16 10:01:18 -07:00
JohnnyMorganz
bc0722471f
Add support for ClassType indexer in definition files (#949) 2023-06-12 13:02:54 -07:00
RadiatedExodus
7fa69377be
Fix Arch Linux install instructions to use AUR (#953)
The existing instruction is incorrect, the luau package exists on the
Arch Linux User Repository (AUR), not at the official repository.

Feel free to suggest edits if something is wrong/missing, thanks!

(I also have a pkgbuild that builds every executable possible excluding
tests (repl, analyze, ast, reduce), however I did not include this since
releases only include repl and analyze)
2023-06-12 12:06:28 -07:00
Arseny Kapoulkine
ba65b0e9cd
Build and use luau-compile in CI (#952) 2023-06-12 08:46:44 -07:00
vegorov-rbx
3ecd3a82ab
Sync to upstream/release/580 (#951)
* Added luau-compile executable target to build/test compilation without
having full REPL included.

In our new typechecker:
* Fixed the order in which constraints are checked to get more
deterministic errors in different environments
* Fixed `isNumber`/`isString` checks to fix false positive errors in
binary comparisons
* CannotCallNonFunction error is reported when calling an intersection
type of non-functions
 
In our native code generation (jit):
* Outlined X64 return instruction code to improve code size
* Improved performance of return instruction on A64
* Added construction of a dominator tree for future optimizations
2023-06-09 10:08:00 -07:00
Vyacheslav Egorov
212888c361 Fix build warning 2023-06-09 15:46:43 +03:00
Vyacheslav Egorov
a9becc9b70 Merge branch 'upstream' into merge 2023-06-09 15:21:03 +03:00
Vyacheslav Egorov
ef2e46e25e Merge branch 'master' into merge 2023-06-09 15:20:56 +03:00
Vyacheslav Egorov
88cd3dda87 Sync to upstream/release/580 2023-06-09 15:20:36 +03:00
Arseny Kapoulkine
febebde72a
Update performance.md (#948)
We haven't updated this document in a while and yet there was a fair
amount of performance work, some of which can be documented here.

Note that this is not fully comprehensive in that it excludes a lot of
internal tuning that is difficult to describe other than with "we made
things faster".
2023-06-06 15:11:29 -07:00
Ben Mactavsin
e78897229a
Fix website demo's string highlighting behaviour (#942)
Fixes #935:
* String literals that include `\z` escape sequence followed by newline
characters are now correctly highlighted.
* Unescaped backslash (`\`) character at the end of the line no longer
acts like the `\z` escape sequence inside string literals when
highlighting.
2023-06-06 11:22:31 -07:00
Ben Mactavsin
4f82a77396
Update lint.md to specify language on fenced code blocks which have none (#946)
Specified language on the last two fenced code blocks in the page as
they were inconsistent with the others on the same page.
2023-06-06 08:57:36 -07:00
Andy Friesen
63679f7288
Sync to upstream/release/579 (#943)
A pretty small changelist this week:

* When type inference fails to find any matching overload for a
function, we were declining to commit any changes to the type graph at
all. This was resulting in confusing type errors in certain cases. Now,
when a matching overload cannot be found, we always commit to the first
overload we tried.

JIT

* Fix missing variadic register invalidation in FALLBACK_GETVARARGS
* Add a missing null pointer check for the result of luaT_gettm

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-06-02 12:52:15 -07:00
Andy Friesen
a3d22decf8 Merge branch 'upstream' into merge 2023-06-02 11:18:16 -07:00
Andy Friesen
349d6f4342 Merge branch 'master' into merge 2023-06-02 11:18:12 -07:00
Andy Friesen
f4357400c5 Sync to upstream/release/579 2023-06-02 11:17:31 -07:00
vegorov-rbx
271c509046
Sync to upstream/release/578 (#939)
* Fixed gcc warning about uninitialized `std::optional`
* Fixed inlining of functions when they are used to compute their own
arguments

In the new type solver:
* Type families that are not part of a function signature cannot be
resolved at instantiation time and will now produce an error. This will
be relaxed in the future when we get constraint clauses on function
signatures (internally)
* `never` type is now comparable
* Improved typechecking of `for..in` statements
* Fixed checks for number type in `Add` type family
* Performance was improved, with particularly large gains on large
projects

And in native code generation (jit):
* We eliminated the call instruction overhead when native code support
is enabled in the VM
* Small optimizations to arm64 lowering
* Reworked LOP_GETIMPORT handling to reduce assembly code size
* Fixed non-deterministic binary output
* Fixed bad code generation caused by incorrect SSA to VM register links
invalidation

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
2023-05-25 14:36:34 -07:00