Commit Graph

1140 Commits

Author SHA1 Message Date
Vyacheslav Egorov
ca46dd6fe8 Merge branch 'upstream' into merge 2024-05-16 15:22:49 -07:00
Vyacheslav Egorov
e5de2ed3cc Merge branch 'master' into merge 2024-05-16 15:22:42 -07:00
Vyacheslav Egorov
0386eec734 Sync to upstream/release/626 2024-05-16 15:22:22 -07:00
Vighnesh-V
2a80f5e1d1
Sync to upstream/release/625 (#1252)
# What's changed?

* Fix warning issued when Cmake version is too low (contributed by OSS
community)

## New Solver

* Fix an issue with inhabitance testing of tables with cyclic properties
* Preserve error suppression during type unification
* Overhaul type reference counting in the constraint solver
* Other miscellaneous constraint ordering fixes

## Native Codegen

* Fix incorrect assertion check in loadBytecodeTypeInfo

---

## Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-05-10 11:21:45 -07:00
Vighnesh
f172471b87 Merge branch 'upstream' into merge 2024-05-10 09:21:07 -07:00
Vighnesh
f76a99b800 Merge branch 'master' into merge 2024-05-10 09:18:10 -07:00
Vighnesh
9bce20cb5c Sync to upstream/release/625 2024-05-10 09:17:09 -07:00
Bjorn
a775bbc6fc
Fix confusing warning when CMake version is too low (#1251)
Experienced brief moment of panic when this warning said I had clang 3
installed.
2024-05-10 03:36:37 -07:00
vegorov-rbx
905a37b928
Update native code generation note in the security guarantees (#1250) 2024-05-08 13:35:12 -07:00
Andy Friesen
8a64cb8b73
Sync to upstream/release/624 (#1245)
# What's changed?

* Optimize table.maxn.  This function is now 5-14x faster
* Reserve Luau stack space for error message.

## New Solver

* Globals can be type-stated, but only if they are already in scope
* Fix a stack overflow that could occur when normalizing certain kinds
of recursive unions of intersections (of unions of intersections...)
* Fix an assertion failure that would trigger when the __iter metamethod
has a bad signature

## Native Codegen

* Type propagation and temporary register type hints
* Direct vector property access should only happen for names of right
length
* BytecodeAnalysis will only predict that some of the vector value
fields are numbers

---

## Internal Contributors

Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-05-03 13:17:51 -07:00
Andy Friesen
1ad7b9cc56 Merge branch 'upstream' into merge 2024-05-03 09:49:16 -07:00
Andy Friesen
f4ecf437ba Merge branch 'master' into merge 2024-05-03 09:47:22 -07:00
Andy Friesen
93468ca88d Sync to upstream/release/624 2024-05-03 09:38:34 -07:00
vegorov-rbx
7edd58afed
Add benchmarks for native compilation with type info enabled (#1244) 2024-05-02 08:33:47 -07:00
Arseny Kapoulkine
f5303b3dd7
Make table.concat faster (#1243)
table.concat is idiomatic and should be the fastest way to concatenate
all table array elements together, but apparently you can beat it by
using `string.format`, `string.rep` and `table.unpack`:

```lua
string.format(string.rep("%*", #t), table.unpack(t))
```

... this just won't do, so we should fix table.concat performance.

The deficit comes from two places:

- rawgeti overhead followed by other stack accesses, all to extract a
string from what is almost always an in-bounds array lookup
- addlstring overhead in case separator is empty (extra function calls)

This change fixes this by using a fast path for in-bounds array lookup
for a string. Note that `table.concat` also supports numbers (these need
to be converted to strings which is a little cumbersome and has innate
overhead), and out-of-bounds accesses*. In these cases we fall back to
the old implementation.

To trigger out-of-bounds accesses, you need to skip the past-array-end
element (which is nil per array invariant), but this is achievable
because table.concat supports offset+length arguments. This should
almost never come up in practice but the per-element branches et al are
fairly cheap compared to the eventual string copy/alloc anyway.

This change makes table.concat ~2x faster when the separator is empty;
the table.concat benchmark shows +40% gains but it uses a variety of
string separators of different lengths so it doesn't get the full
benefit from this change.

---------

Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
2024-04-29 05:19:01 -07:00
Arseny Kapoulkine
af15c3cf17
CodeGen: Fix a typo in X64 (dis)assembler (#1238) 2024-04-26 11:14:13 -07:00
Alexander McCord
259e509038
Sync to upstream/release/623 (#1236)
# What's changed?

### New Type Solver

- Unification of two fresh types no longer binds them together.
- Replaced uses of raw `emplace` with `emplaceType` to catch cyclic
bound types when they are created.
- `SetIndexerConstraint` is blocked until the indexer result type is not
blocked.
- Fix a case where a blocked type got past the constraint solver.
- Searching for free types should no longer traverse into `ClassType`s.
- Fix a corner case that could result in the non-testable type `~{}`.
- Fix incorrect flagging when `any` was a parameter of some checked
function in nonstrict type checker.
- `IterableConstraint` now consider tables without `__iter` to be
iterables.

### Native Code Generation

- Improve register type info lookup by program counter.
- Generate type information for locals and upvalues

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: James McNellis <jmcnellis@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-04-25 15:26:09 -07:00
Alexander McCord
88dd289100 Fix missing include. 2024-04-25 14:03:47 -07:00
Alexander McCord
76ed1a5370 Merge branch 'heads/upstream' into merge 2024-04-25 13:57:53 -07:00
Alexander McCord
8d0a650a25 Merge branch 'master' into merge 2024-04-25 13:57:44 -07:00
Alexander McCord
50a2f8daa8 Sync to upstream/release/623 2024-04-25 13:57:23 -07:00
aaron
68bd1b2349
Sync to upstream/release/622 (#1232)
# What's changed?

* Improved the actual message for the type errors for `cannot call
non-function` when attempting to call a union of functions/callable
tables. The error now correctly explains the issue is an inability to
determine the return type of the call in this situation.
* Resolve an issue where tables and metatables were not correctly being
cloned during instantiation (fixes #1176).
* Refactor `luaM_getnextgcopage` to `luaM_getnextpage` (generally
removing `gco` prefix where appropriate).
* Optimize `table.move` between tables for large ranges of elements.
* Reformat a bunch of code automatically using `clang-format`.

### New Type Solver

* Clean up minimally-used or unused constraints in the constraint solver
(`InstantiationConstraint`, `SetOpConstraint`,
`SingletonOrTopTypeConstraint`).
* Add a builtin `singleton` type family to replace
`SingletonOrTopTypeConstraint` when inferring refinements.
* Fixed a crash involving type path reasoning by recording when type
family reduction has taken place in the path.
* Improved constraint ordering by blocking on unreduced types families
that are not yet proven uninhabitable.
* Improved the handling of `SetIndexerConstraints` for both better
inference quality and to resolve crashes.
* Fix a crash when normalizing cyclic unions of intersections.
* Fix a crash when normalizing an intersection with the negation of
`unknown`.
* Fix a number of crashes caused by missing `follow` calls on `TypeId`s.
* Changed type family reduction to correctly use a semantic notion of
uninhabited types, rather than checking for `never` types specifically.
* Refactor the `union` and `intersect` type families to be variadic.

### Native Code Generation

* Improve translation for userdata key get/set and userdata/vector
namecall.
* Provide `[top level]` and `[anonymous]` as function names to
`FunctionStats` as appropriate when no function name is available.
* Disable unwind support on Android platforms since it is unsupported.
*  

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-04-19 14:48:02 -07:00
Aaron Weiss
641e9f6eb5 Merge branch 'upstream' into merge 2024-04-19 14:05:22 -07:00
Aaron Weiss
5cf508a73b Merge branch 'master' into merge 2024-04-19 14:05:01 -07:00
Aaron Weiss
67b9145268 Sync to upstream/release/622 2024-04-19 14:04:30 -07:00
vegorov-rbx
9c2146288d
Sync to upstream/release/621 (#1229)
# What's changed?

* Support for new 'require by string' RFC with relative paths and
aliases in now enabled in Luau REPL application

### New Type Solver

* Fixed assertion failure on generic table keys (`[expr] = value`)
* Fixed an issue with type substitution traversing into the substituted
parts during type instantiation
* Fixed crash in union simplification when that union contained
uninhabited unions and other types inside
* Union types in binary type families like `add<a | b, c>` are expanded
into `add<a, c> | add<b, c>` to handle
* Added handling for type family solving creating new type families
* Fixed a bug with normalization operation caching types with unsolved
parts
* Tables with uninhabited properties are now simplified to `never`
* Fixed failures found by fuzzer

### Native Code Generation

* Added support for shared code generation between multiple Luau VM
instances
* Fixed issue in load-store propagation and new tagged LOAD_TVALUE
instructions
* Fixed issues with partial register dead store elimination causing
failures in GC assists

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: James McNellis <jmcnellis@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-04-12 10:18:49 -07:00
Vyacheslav Egorov
858b93a5f3 Sync fixup 2024-04-12 14:07:34 +03:00
Vyacheslav Egorov
f97e96dc29 Merge branch 'upstream' into merge 2024-04-12 13:46:23 +03:00
Vyacheslav Egorov
7c346a0a69 Merge branch 'master' into merge 2024-04-12 13:45:09 +03:00
Vyacheslav Egorov
0f0c0e4d28 Sync to upstream/release/621 2024-04-12 13:44:40 +03:00
Vighnesh-V
67e16cba18
Sync to upstream/release/620 (#1223)
# What's Changed

## New Type Solver
- Many more fixes to crashes, assertions, and hangs
- Annotated locals now countermand the inferred types of locals, meaning
that for a type `type MyType = number | string`, `local foo : MyType =
5` behaves the same as `local foo = 5 :: MyType`, where before, foo
would be assigned the type of the value on the rhs.
- Type Normalization now respects resource limits.
- Subtyping between classes and cyclic tables now supported

## Native Code Generation
- Work on the Native Code Generation(NCG) allocator continues

---

# Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: James McNellis <jmcnellis@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-04-05 13:45:09 -07:00
Vighnesh
5aa6d99340 transplant game engine fix for memory safety issues in normalization into OSS changes 2024-04-05 13:27:37 -07:00
Vighnesh
0f1973954c remove trailing . 2024-04-05 11:30:53 -07:00
Vighnesh
9cb93a98bc manually fix cmake configuration error 2024-04-05 11:27:48 -07:00
Vighnesh
2e1c0404d1 Merge branch 'upstream' into merge 2024-04-05 10:45:02 -07:00
Vighnesh
6bef0b10ca Merge branch 'master' into merge 2024-04-05 10:44:49 -07:00
Vighnesh
c730a51ca8 Sync to upstream/release/620 2024-04-05 10:41:05 -07:00
vegorov-rbx
9649e5e446
Fix CMake configuration error when CLI targets are not included again (#1219)
A mistake was made in https://github.com/luau-lang/luau/pull/1218

Fixes https://github.com/luau-lang/luau/issues/1208
2024-03-31 05:59:46 -07:00
Lily Brown
47ad768c69
Sync to upstream/release/619 (#1218)
# What's Changed

## New Type Solver
- Many fixes to crashes, assertions, and hangs
- Binary type family aliases now have a default parameter
- Added a debug check for unsolved types escaping the constraint solver
- Overloaded functions are no longer inferred
- Unification creates additional subtyping constraints for blocked types
- Attempt to guess the result type for type families that are too large
to resolve timely

## Native Code Generation
- Fixed `IrCmd::CHECK_TRUTHY` lowering in a specific case
- Detailed compilation errors are now supported
- More work on the new allocator

---

# Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: James McNellis <jmcnellis@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
2024-03-30 16:14:44 -07:00
Lily Brown
3e1b4130ea Merge branch 'upstream' into merge 2024-03-30 15:51:08 -07:00
Lily Brown
77598ed0a6 Merge branch 'master' into merge 2024-03-30 15:50:29 -07:00
Lily Brown
fb90dc083b Sync with upstream/release/620 2024-03-30 15:49:03 -07:00
vegorov-rbx
bac85116f6
Fix CMake configuration error when CLI targets are not included (#1213)
Doesn't really make sense to configure sources list based on target
presence.

Should fix https://github.com/luau-lang/luau/issues/1208
2024-03-25 09:08:15 -07:00
Andy Friesen
c1830d8b81
Sync to upstream/release/618 (#1205)
# What's changed

### Debugger

* Values after a 'continue' statement should not be accessible by
debugger in the 'until' condition

### New Type Solver

* Many fixes to crashes and hangs
* Better bidirectional inference of table literal expressions

### Native Code Generation

* Initial steps toward a shared code allocator

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-03-22 10:47:10 -07:00
Andy Friesen
d8f49d6ca2 Compiler fixes for MSVC and GCC. 2024-03-22 10:33:09 -07:00
Andy Friesen
4931165635 Merge branch 'upstream' into merge 2024-03-22 10:24:30 -07:00
Andy Friesen
a30b2aebfd Merge branch 'master' into merge 2024-03-22 10:21:47 -07:00
Andy Friesen
6fff08b621 Sync to upstream/release/618 2024-03-22 10:21:27 -07:00
Alexander McCord
d21b6fdb93
Sync to upstream/release/617 (#1204)
# What's Changed

* Fix a case where the stack wasn't completely cleaned up where
`debug.info` errored when passed `"f"` option and a thread.
* Fix a case of uninitialized field in `luaF_newproto`.

### New Type Solver

* When a local is captured in a function, don't add a new entry to the
`DfgScope::bindings` if the capture occurs within a loop.
* Fix a poor performance characteristic during unification by not trying
to simplify an intersection.
* Fix a case of multiple constraints mutating the same blocked type
causing incorrect inferences.
* Fix a case of assertion failure when overload resolution encounters a
return typepack mismatch.
* When refining a property of the top `table` type, we no longer signal
an unknown property error.
* Fix a misuse of free types when trying to infer the type of a
subscript expression.
* Fix a case of assertion failure when trying to resolve an overload
from `never`.

### Native Code Generation

* Fix dead store optimization issues caused by partial stores.

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-03-15 16:37:39 -07:00
Alexander McCord
c1bbf1ebec Merge branch 'heads/upstream' into merge 2024-03-15 14:15:29 -07:00