Commit Graph

1163 Commits

Author SHA1 Message Date
Vighnesh
c932b8e03f remove tests for require by string 2023-12-01 20:50:35 -08:00
Vighnesh
41669c9f30 Sync to upstream/release/605 2023-12-01 20:40:43 -08:00
Vighnesh
c592f50e20 can CI handle this? 2023-12-01 20:37:13 -08:00
Vighnesh
79854143e4 resolve one last merge conflict 2023-12-01 19:11:31 -08:00
Vighnesh
e70eec0c59 Merge branch 'upstream' into merge
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>
2023-12-01 18:56:54 -08:00
Vighnesh
98d2db7325 add stdint import 2023-12-01 18:35:40 -08:00
Vighnesh
557e77a676 VM
- Add SUBRK and DIVRK bytecode instructions
    - Enables future performance optimizations

Miscellaneous
- Small performance improvements to new non-strict mode
- Introduce more scripts for fuzzing
- Improcements to dataflow analysis
2023-12-01 18:04:44 -08:00
Arseny Kapoulkine
89b437bb4e
Add SUBRK and DIVRK bytecode instructions to bytecode v5 (#1115)
Right now, we can compile R\*K for all arithmetic instructions, but K\*R
gets compiled into two instructions (LOADN/LOADK + arithmetic opcode).

This is problematic since it leads to reduced performance for some code.
However, we'd like to avoid adding reverse variants of ADDK et al for
all opcodes to avoid the increase in I$ footprint for interpreter.

Looking at the arithmetic instructions, % and // don't have interesting
use cases for K\*V; ^ is sometimes used with constant on the left hand
side but this would need to call pow() by necessity in all cases so it
would be slow regardless of the dispatch overhead. This leaves the four
basic arithmetic operations.

For + and \*, we can implement a compiler-side optimization in the
future that transforms K\*R to R\*K automatically. This could either be
done unconditionally at -O2, or conditionally based on the type of the
value (driven by type annotations / inference) -- this technically
changes behavior in presence of metamethods, although it might be
sensible to just always do this because non-commutative +/* are evil.

However, for - and / it is impossible for the compiler to optimize this
in the future, so we need dedicated opcodes. This only increases the
interpreter size by ~300 bytes (~1.5%) on X64.

This makes spectral-norm and math-partial-sums 6% faster; maybe more
importantly, voxelgen gets 1.5% faster (so this change does have
real-world impact).

To avoid the proliferation of bytecode versions this change piggybacks
on the bytecode version bump that was just made in 604 for vector
constants; we would still be able to enable these independently but
we'll consider v5 complete when both are enabled.

Related: #626

---------

Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
2023-11-28 07:35:01 -08:00
Arseny Kapoulkine
7fb7f4382d
Use ubuntu-latest on GHA when possible (#1112)
We need ubuntu-20.04 for coverage analysis (clang after 10 doesn't seem
to properly interact with gcov version used for codecov) and for
releases (to produce binaries targeting earlier glibc).

However, we still should be verifying that Luau builds on latest,
because newer toolchains have stricter standard library headers and/or
warnings; without this we're at risk of constantly regressing the build
for packaging or external applications.

Note that release.yml can probably just be deleted but for now we simply
adjust it.
2023-11-27 03:24:57 -08:00
vegorov-rbx
1cda8304bf
Add missing include file to BytecodeSummary.h (#1110) 2023-11-21 08:28:54 -08:00
JohnnyMorganz
ae53051814
Include module name for definitions files (#861)
Closes #818 

We set the `moduleName` of the source module to the provided
`packageName`.
This then populates the relevant `definitionModuleName`'s on
CTV/FTV/TTVs, so it allows us to lookup where they originated from.

The one place I can see this having an impact inside of Luau code is the
following:

1fa8311a18/Analysis/src/Error.cpp (L70-L90)
Which will potentially change they way error messages are formatted.
Should there be a way to exclude definition files when calling
`getDefinitionModuleName`, so we can preserve this behaviour?
2023-11-21 08:12:18 -08:00
Andy Friesen
74c532053f
Sync to upstream/release/604 (#1106)
New Solver

* New algorithm for inferring the types of locals that have no
annotations. This
algorithm is very conservative by default, but is augmented with some
control
  flow awareness to handle most common scenarios.
* Fix bugs in type inference of tables
* Improve performance of by switching out standard C++ containers for
`DenseHashMap`
* Infrastructure to support clearer error messages in strict mode

Native Code Generation

* Fix a lowering issue with buffer.writeu8 and 0x80-0xff values: A
constant
  argument wasn't truncated to the target type range and that causes an
  assertion failure in `build.mov`.
* Store full lightuserdata value in loop iteration protocol lowering
* Add analysis to compute function bytecode distribution
* This includes a class to analyze the bytecode operator distribution
per
function and a CLI tool that produces a JSON report. See the new cmake
      target `Luau.Bytecode.CLI`

---------

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: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-11-17 10:46:18 -08:00
Andy Friesen
2d4a544709 Merge branch 'upstream' into merge 2023-11-17 10:18:37 -08:00
Andy Friesen
43201531b3 Merge branch 'master' into merge 2023-11-17 10:18:24 -08:00
Andy Friesen
674c6c40c0 Sync to upstream/release/604 2023-11-17 10:15:31 -08:00
Petri Häkkinen
298cd70154
Optimize vector literals by storing them in the constant table (#1096)
With this optimization, built-in vector constructor calls with 3/4 arguments are detected by the compiler and turned into vector constants when the arguments are constant numbers.
Requires optimization level 2 because built-ins are not folded otherwise by the compiler.
Bytecode version is bumped because of the new constant type, but old bytecode versions can still be loaded.

The following synthetic benchmark shows ~6.6x improvement.
```
local v
for i = 1, 10000000 do
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
	v = vector(1, 2, 3)
end
```

Also tried a more real world scenario and could see a few percent improvement.

Added a new fast flag LuauVectorLiterals for enabling the feature.

---------

Co-authored-by: Petri Häkkinen <petrih@rmd.remedy.fi>
Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2023-11-17 04:54:32 -08:00
Kostadin
0492ecffdf
Add #include <algorithm> to fix building with gcc 14 (#1104)
With gcc 14 some C++ Standard Library headers have been changed to no
longer include other headers that were used internally by the library.
In luau's case it is the `<algorithm>` header.
2023-11-16 11:51:16 -08:00
Arseny Kapoulkine
d2059dd50d
Update codecov.yml
Make status checks informational
2023-11-15 06:30:40 -08:00
Arseny Kapoulkine
64d2d0fb76
Update README.md
Use rfcs.luau-lang.org for the .luaurc link
2023-11-13 07:41:15 -08:00
JohnnyMorganz
4b2af900c2
Fix link to .luaurc info in README (#1101) 2023-11-12 13:48:41 -08:00
Alexander McCord
c2ba1058c3
Sync to upstream/release/603 (#1097)
# What's changed?

- Record the location of properties for table types (closes #802)
- Implement stricter UTF-8 validations as per the RFC
(https://github.com/luau-lang/rfcs/pull/1)
- Implement `buffer` as a new type in both the old and new solvers.
- Changed errors produced by some `buffer` builtins to be a bit more
generic to avoid platform-dependent error messages.
- Fixed a bug where `Unifier` would copy some persistent types, tripping
some internal assertions.
- Type checking rules on relational operators is now a little bit more
lax.
- Improve dead code elimination for some `if` statements with complex
always-false conditions

## New type solver

- Dataflow analysis now generates phi nodes on exit of branches.
- Dataflow analysis avoids producing a new definition for locals or
properties that are not owned by that loop.
- If a function parameter has been constrained to `never`, report errors
at all uses of that parameter within that function.
- Switch to using the new `Luau::Set` to replace `std::unordered_set` to
alleviate some poor allocation characteristics which was negatively
affecting overall performance.
- Subtyping can now report many failing reasons instead of just the
first one that we happened to find during the test.
- Subtyping now also report reasons for type pack mismatches.
- When visiting `if` statements or expressions, the resulting context
are the common terms in both branches.

## Native codegen

- Implement support for `buffer` builtins to its IR for x64 and A64.
- Optimized `table.insert` by not inserting a table barrier if it is
fastcalled with a constant.

## 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: Arseny Kapoulkine <arseny@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-11-10 13:10:07 -08:00
Alexander McCord
e57cbf6132 Merge branch 'heads/upstream' into merge 2023-11-10 10:13:36 -08:00
Alexander McCord
63436480a0 Merge branch 'master' into merge 2023-11-10 10:08:30 -08:00
Alexander McCord
4b68791b2c Sync to upstream/release/603 2023-11-10 10:05:48 -08:00
aaron
7105c81579
Sync to upstream/release/602 (#1089)
# What's changed?

* Fixed a bug in type cloning by maintaining persistent types.
* We now parse imprecise integer literals to report the imprecision as a
warning to developers.
* Add a compiler flag to specify the name of the statistics output file.

### New type solver

* Renamed `ConstraintGraphBuilder` to `ConstraintGenerator`
* LValues now take into account the type being assigned during
constraint generation.
* Normalization performance has been improved by 33% by replacing the an
internal usage of `std::unordered_set` with `DenseHashMap`.
* Normalization now has a helper to identify types that are equivalent
to `unknown`, which is being used to fix some bugs in subtyping.
* Uses of the old unifier in the new type solver have been eliminated.
* Improved error explanations for subtyping errors in `TypeChecker2`.

### Native code generation

* Expanded some of the statistics recorded during compilation to include
the number of instructions and blocks.
* Introduce instruction and block count limiters for controlling what
bytecode is translated into native code.
* Implement code generation for byteswap instruction.

### 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: Lily Brown <lbrown@roblox.com>
2023-11-03 16:45:04 -07:00
Aaron Weiss
efe133abe9 Merge branch 'upstream' into merge 2023-11-03 12:48:56 -07:00
Aaron Weiss
a0b9950541 Sync to upstream/release/602 2023-11-03 12:47:28 -07:00
JohnnyMorganz
1a9159daff
Record table type alias property locations (#1046)
For table type aliases, records the location of the property in the
alias declaration.

This is an alternate solution to the particular case noted in #802.
Instead of tracking the type alias definition for FTVs, it tracks it for
the encompassing property instead.

Note that we still don't have positions in the following case:

```
type Func = () -> ()
```

Closes #802 (Although not completely...)
2023-11-02 09:14:51 -07:00
Arseny Kapoulkine
5622474b6a Merge remote-tracking branch 'origin/merge' 2023-11-01 18:11:17 -07:00
Arseny Kapoulkine
b647288375
Delete rfcs directory
This folder is now hosted in a separate repository https://github.com/luau-lang/rfcs (see https://github.com/luau-lang/luau/issues/1074 for details)
2023-10-30 10:49:36 -07:00
Arseny Kapoulkine
88eec1da37
Update CONTRIBUTING.md
Fix the guide to point to docs and rfcs repositories for associated changes
2023-10-30 09:16:59 -07:00
Arseny Kapoulkine
6d564abf81
Update README.md
Correct links and language to docs and RFCs repository and mention usage in non-Roblox games.
2023-10-30 09:02:22 -07:00
Arseny Kapoulkine
45f4b87991 Attempt to disable codecov patch status check 2023-10-27 17:11:17 -07:00
Lily Brown
e5ec0cdff3
Sync to upstream/release/601 (#1084)
## What's changed

- `bit32.byteswap` added
([RFC](4f543ec23b/docs/function-bit32-byteswap.md))
- Buffer library implementation
([RFC](4f543ec23b/docs/type-byte-buffer.md))
- Fixed a missing `stdint.h` include
- Fixed parser limiter for recursive type annotations being kind of
weird (fixes #645)

### Native Codegen
- Fixed a pair of issues when lowering `bit32.extract`
- Fixed a narrow edge case that could result in an infinite loop without
an interruption
- Fixed a negative array out-of-bounds access issue
- Temporarily reverted linear block predecessor value propagation

### New type solver
- We now type check assignments to annotated variables
- Fixed some test cases under local type inference
- Moved `isPending` checks for type families to improve performance
- Optimized our process for testing if a free type is sufficiently
solved
- Removed "none ptr" from lea instruction disassembly logging

### Build system & tooling
- CMake configuration now validates dependencies to maintain separation
between components
- Improvements to the fuzzer coverage
- Deduplicator for fuzzed callstacks

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
2023-10-27 14:18:41 -07:00
Lily Brown
98217437ec perhaps this works better 2023-10-27 13:42:42 -07:00
Lily Brown
9216e4cb27 attempt allowing a more complex expression here 2023-10-27 13:22:39 -07:00
Lily Brown
592469373b Merge branch 'upstream' into merge 2023-10-27 13:04:04 -07:00
Lily Brown
a4ceaa10ec Merge branch 'master' into merge 2023-10-27 12:34:25 -07:00
Lily Brown
8237b2f593 Sync to upstream/release/601 2023-10-27 12:33:36 -07:00
Arseny Kapoulkine
87d955d5eb Fix remaining references to Roblox org outside of source code 2023-10-24 10:32:59 -07:00
Arseny Kapoulkine
88fcbd58e6
Update README.md
Fix status badges and various repository links
2023-10-24 10:28:19 -07:00
Arseny Kapoulkine
ff59ced5ee
Delete docs directory
The directory was moved to https://github.com/luau-lang/site

See #1074 for context
2023-10-24 10:22:54 -07:00
Maciej Barć
26f79951f7
TypePairHash.h: include cstdint (#1078)
luau fails to compile w/o this on Gentoo

Signed-off-by: Maciej Barć <xgqt@gentoo.org>
2023-10-24 10:02:46 -07:00
Arseny Kapoulkine
13e3af2724
Delete papers directory
The directory was moved to https://github.com/luau-lang/research

See https://github.com/Roblox/luau/issues/1074 for context
2023-10-23 09:02:08 -07:00
Arseny Kapoulkine
d70a02a2d0
Delete CNAME 2023-10-23 08:57:58 -07:00
Micah
011c1afbde
Implement bit32.byteswap (#1075)
I've decided to take a stab at implementing `bit32.byteswap` from the
[recently merged
RFC](https://github.com/Roblox/luau/blob/master/rfcs/function-bit32-byteswap.md).
I asked on Discord for some guidance, but for the sake of posterity:
this is my first time doing this and I am likely to have made some
mistakes.

The biggest gaps in this implementation are the lack of tests and the
lack of native codegen support. I'd appreciate help with those since I'm
not sure what's relevant for me to touch for tests, and I'm told that
relevant assembler instructions don't exist publicly yet. Intuition
tells me that Luau-side tests would go into
`tests/conformance/bitwise.luau` but this is not well documented and I'm
not sure how I'm meant to test built-in implementations.

The current implementation compiles down to `bswap` and `rev` on x86 and
ARM respectively when optimized.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2023-10-23 08:00:48 -07:00
Vighnesh-V
fd6250cf9d
Sync to upstream/release/600 (#1076)
### What's Changed

- Improve readability of unions and intersections by limiting the number
of elements of those types that can be presented on a single line (gated
under `FFlag::LuauToStringSimpleCompositeTypesSingleLine`)
- Adds a new option to the compiler `--record-stats` to record and
output compilation statistics
- `if...then...else` expressions are now optimized into `AND/OR` form
when possible.

### VM

- Add a new `buffer` type to Luau based on the [buffer
RFC](https://github.com/Roblox/luau/pull/739) and additional C API
functions to work with it; this release does not include the library.
- Internal C API to work with string buffers has been updated to align
with Lua version more closely

### Native Codegen

- Added support for new X64 instruction (rev) and new A64 instruction
(bswap) in the assembler
- Simplified the way numerical loop condition is translated to IR

### New Type Solver

- Operator inference now handled by type families
- Created a new system called `Type Paths` to explain why subtyping
tests fail in order to improve the quality of error messages.
- Systematic changes to implement Data Flow analysis in the new solver
(`Breadcrumb` removed and replaced with `RefinementKey`)

---
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: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
2023-10-20 18:10:30 -07:00
Vighnesh
46f18bb352 comment out whole test case 2023-10-20 17:37:59 -07:00
Vighnesh
43915a4675 More test uncommenting 2023-10-20 17:07:09 -07:00
Vighnesh
7602c43214 Disable failing tests that rely on type paths 2023-10-20 16:09:58 -07:00