Skip to content

Commit

Permalink
v0.8.2+luau613
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Feb 17, 2024
1 parent 49b3643 commit 2b8b9fe
Show file tree
Hide file tree
Showing 53 changed files with 813 additions and 752 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "luau0-src"
version = "0.8.1+luau611"
version = "0.8.2+luau613"
authors = ["Aleksandr Orlenko <[email protected]>"]
edition = "2021"
repository = "https://github.com/khvzak/luau-src-rs"
Expand Down
4 changes: 2 additions & 2 deletions luau/Ast/src/Ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ void AstStatLocal::visit(AstVisitor* visitor)
}
}

AstStatFor::AstStatFor(const Location& location, AstLocal* var, AstExpr* from, AstExpr* to, AstExpr* step, AstStatBlock* body, bool hasDo,
const Location& doLocation)
AstStatFor::AstStatFor(
const Location& location, AstLocal* var, AstExpr* from, AstExpr* to, AstExpr* step, AstStatBlock* body, bool hasDo, const Location& doLocation)
: AstStat(ClassIndex(), location)
, var(var)
, from(from)
Expand Down
6 changes: 2 additions & 4 deletions luau/Ast/src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,7 @@ AstStat* Parser::parseFor()
bool hasEnd = expectMatchEndAndConsume(Lexeme::ReservedEnd, matchDo);
body->hasEnd = hasEnd;

return allocator.alloc<AstStatForIn>(
Location(start, end), copy(vars), copy(values), body, hasIn, inLocation, hasDo, matchDo.location);
return allocator.alloc<AstStatForIn>(Location(start, end), copy(vars), copy(values), body, hasIn, inLocation, hasDo, matchDo.location);
}
}

Expand Down Expand Up @@ -907,8 +906,7 @@ AstStat* Parser::parseDeclaration(const Location& start)
{
props.push_back(parseDeclaredClassMethod());
}
else if (lexer.current().type == '[' && (lexer.lookahead().type == Lexeme::RawString ||
lexer.lookahead().type == Lexeme::QuotedString))
else if (lexer.current().type == '[' && (lexer.lookahead().type == Lexeme::RawString || lexer.lookahead().type == Lexeme::QuotedString))
{
const Lexeme begin = lexer.current();
nextLexeme(); // [
Expand Down
8 changes: 4 additions & 4 deletions luau/CodeGen/include/Luau/AddressA64.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct AddressA64
, offset(xzr)
, data(off)
{
LUAU_ASSERT(base.kind == KindA64::x || base == sp);
LUAU_ASSERT(kind != AddressKindA64::reg);
CODEGEN_ASSERT(base.kind == KindA64::x || base == sp);
CODEGEN_ASSERT(kind != AddressKindA64::reg);
}

constexpr AddressA64(RegisterA64 base, RegisterA64 offset)
Expand All @@ -42,8 +42,8 @@ struct AddressA64
, offset(offset)
, data(0)
{
LUAU_ASSERT(base.kind == KindA64::x);
LUAU_ASSERT(offset.kind == KindA64::x);
CODEGEN_ASSERT(base.kind == KindA64::x);
CODEGEN_ASSERT(offset.kind == KindA64::x);
}

AddressKindA64 kind;
Expand Down
2 changes: 1 addition & 1 deletion luau/CodeGen/include/Luau/AssemblyBuilderA64.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class AssemblyBuilderA64
// Extracts code offset (in bytes) from label
uint32_t getLabelOffset(const Label& label)
{
LUAU_ASSERT(label.location != ~0u);
CODEGEN_ASSERT(label.location != ~0u);
return label.location * 4;
}

Expand Down
2 changes: 1 addition & 1 deletion luau/CodeGen/include/Luau/AssemblyBuilderX64.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class AssemblyBuilderX64
// Extracts code offset (in bytes) from label
uint32_t getLabelOffset(const Label& label)
{
LUAU_ASSERT(label.location != ~0u);
CODEGEN_ASSERT(label.location != ~0u);
return label.location;
}

Expand Down
12 changes: 6 additions & 6 deletions luau/CodeGen/include/Luau/BytecodeSummary.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include "Luau/Common.h"
#include "Luau/CodeGenCommon.h"
#include "Luau/Bytecode.h"

#include <string>
Expand Down Expand Up @@ -49,21 +49,21 @@ class FunctionBytecodeSummary

void incCount(unsigned nesting, uint8_t op)
{
LUAU_ASSERT(nesting <= getNestingLimit());
LUAU_ASSERT(op < getOpLimit());
CODEGEN_ASSERT(nesting <= getNestingLimit());
CODEGEN_ASSERT(op < getOpLimit());
++counts[nesting][op];
}

unsigned getCount(unsigned nesting, uint8_t op) const
{
LUAU_ASSERT(nesting <= getNestingLimit());
LUAU_ASSERT(op < getOpLimit());
CODEGEN_ASSERT(nesting <= getNestingLimit());
CODEGEN_ASSERT(op < getOpLimit());
return counts[nesting][op];
}

const std::vector<unsigned>& getCounts(unsigned nesting) const
{
LUAU_ASSERT(nesting <= getNestingLimit());
CODEGEN_ASSERT(nesting <= getNestingLimit());
return counts[nesting];
}

Expand Down
20 changes: 14 additions & 6 deletions luau/CodeGen/include/Luau/CodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ enum CodeGenFlags
CodeGen_ColdFunctions = 1 << 1,
};

// These enum values can be reported through telemetry.
// To ensure consistency, changes should be additive.
enum class CodeGenCompilationResult
{
Success, // Successfully generated code for at least one function
NothingToCompile, // There were no new functions to compile

CodeGenNotInitialized, // Native codegen system is not initialized
CodeGenFailed, // Native codegen failed due to an internal compiler error
AllocationFailed, // Native codegen failed due to an allocation error
Success = 0, // Successfully generated code for at least one function
NothingToCompile = 1, // There were no new functions to compile
NotNativeModule = 2, // Module does not have `--!native` comment

CodeGenNotInitialized = 3, // Native codegen system is not initialized
CodeGenOverflowInstructionLimit = 4, // Instruction limit overflow
CodeGenOverflowBlockLimit = 5, // Block limit overflow
CodeGenOverflowBlockInstructionLimit = 6, // Block instruction limit overflow
CodeGenAssemblerFinalizationFailure = 7, // Failure during assembler finalization
CodeGenLoweringFailure = 8, // Lowering failed
AllocationFailed = 9, // Native codegen failed due to an allocation error
};

struct CompilationStats
Expand All @@ -40,6 +47,7 @@ struct CompilationStats
size_t nativeDataSizeBytes = 0;
size_t nativeMetadataSizeBytes = 0;

uint32_t functionsTotal = 0;
uint32_t functionsCompiled = 0;
};

Expand Down
12 changes: 12 additions & 0 deletions luau/CodeGen/include/Luau/CodeGenCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include "Luau/Common.h"

#if defined(LUAU_ASSERTENABLED)
#define CODEGEN_ASSERT(expr) ((void)(!!(expr) || (Luau::assertCallHandler(#expr, __FILE__, __LINE__, __FUNCTION__) && (LUAU_DEBUGBREAK(), 0))))
#elif defined(CODEGEN_ENABLE_ASSERT_HANDLER)
#define CODEGEN_ASSERT(expr) ((void)(!!(expr) || Luau::assertCallHandler(#expr, __FILE__, __LINE__, __FUNCTION__)))
#else
#define CODEGEN_ASSERT(expr) (void)sizeof(!!(expr))
#endif
4 changes: 2 additions & 2 deletions luau/CodeGen/include/Luau/ConditionX64.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include "Luau/Common.h"
#include "Luau/CodeGenCommon.h"

namespace Luau
{
Expand Down Expand Up @@ -102,7 +102,7 @@ inline ConditionX64 getReverseCondition(ConditionX64 cond)
case ConditionX64::NotParity:
return ConditionX64::Parity;
case ConditionX64::Count:
LUAU_ASSERT(!"invalid ConditionX64 value");
CODEGEN_ASSERT(!"invalid ConditionX64 value");
}

return ConditionX64::Count;
Expand Down
4 changes: 2 additions & 2 deletions luau/CodeGen/include/Luau/IrAnalysis.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include "Luau/Common.h"
#include "Luau/CodeGenCommon.h"

#include <bitset>
#include <queue>
Expand Down Expand Up @@ -167,7 +167,7 @@ struct BlockIteratorWrapper

uint32_t operator[](size_t pos) const
{
LUAU_ASSERT(pos < size_t(itEnd - itBegin));
CODEGEN_ASSERT(pos < size_t(itEnd - itBegin));
return itBegin[pos];
}
};
Expand Down
30 changes: 15 additions & 15 deletions luau/CodeGen/include/Luau/IrData.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,13 +995,13 @@ struct IrFunction

IrBlock& blockOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::Block);
CODEGEN_ASSERT(op.kind == IrOpKind::Block);
return blocks[op.index];
}

IrInst& instOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::Inst);
CODEGEN_ASSERT(op.kind == IrOpKind::Inst);
return instructions[op.index];
}

Expand All @@ -1015,15 +1015,15 @@ struct IrFunction

IrConst& constOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::Constant);
CODEGEN_ASSERT(op.kind == IrOpKind::Constant);
return constants[op.index];
}

uint8_t tagOp(IrOp op)
{
IrConst& value = constOp(op);

LUAU_ASSERT(value.kind == IrConstKind::Tag);
CODEGEN_ASSERT(value.kind == IrConstKind::Tag);
return value.valueTag;
}

Expand All @@ -1044,7 +1044,7 @@ struct IrFunction
{
IrConst& value = constOp(op);

LUAU_ASSERT(value.kind == IrConstKind::Int);
CODEGEN_ASSERT(value.kind == IrConstKind::Int);
return value.valueInt;
}

Expand All @@ -1065,7 +1065,7 @@ struct IrFunction
{
IrConst& value = constOp(op);

LUAU_ASSERT(value.kind == IrConstKind::Uint);
CODEGEN_ASSERT(value.kind == IrConstKind::Uint);
return value.valueUint;
}

Expand All @@ -1086,7 +1086,7 @@ struct IrFunction
{
IrConst& value = constOp(op);

LUAU_ASSERT(value.kind == IrConstKind::Double);
CODEGEN_ASSERT(value.kind == IrConstKind::Double);
return value.valueDouble;
}

Expand All @@ -1106,14 +1106,14 @@ struct IrFunction
uint32_t getBlockIndex(const IrBlock& block) const
{
// Can only be called with blocks from our vector
LUAU_ASSERT(&block >= blocks.data() && &block <= blocks.data() + blocks.size());
CODEGEN_ASSERT(&block >= blocks.data() && &block <= blocks.data() + blocks.size());
return uint32_t(&block - blocks.data());
}

uint32_t getInstIndex(const IrInst& inst) const
{
// Can only be called with instructions from our vector
LUAU_ASSERT(&inst >= instructions.data() && &inst <= instructions.data() + instructions.size());
CODEGEN_ASSERT(&inst >= instructions.data() && &inst <= instructions.data() + instructions.size());
return uint32_t(&inst - instructions.data());
}

Expand Down Expand Up @@ -1154,7 +1154,7 @@ struct IrFunction

BytecodeTypes getBytecodeTypesAt(int pcpos) const
{
LUAU_ASSERT(pcpos >= 0);
CODEGEN_ASSERT(pcpos >= 0);

if (size_t(pcpos) < bcTypes.size())
return bcTypes[pcpos];
Expand All @@ -1165,31 +1165,31 @@ struct IrFunction

inline IrCondition conditionOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::Condition);
CODEGEN_ASSERT(op.kind == IrOpKind::Condition);
return IrCondition(op.index);
}

inline int vmRegOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::VmReg);
CODEGEN_ASSERT(op.kind == IrOpKind::VmReg);
return op.index;
}

inline int vmConstOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::VmConst);
CODEGEN_ASSERT(op.kind == IrOpKind::VmConst);
return op.index;
}

inline int vmUpvalueOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::VmUpvalue);
CODEGEN_ASSERT(op.kind == IrOpKind::VmUpvalue);
return op.index;
}

inline uint32_t vmExitOp(IrOp op)
{
LUAU_ASSERT(op.kind == IrOpKind::VmExit);
CODEGEN_ASSERT(op.kind == IrOpKind::VmExit);
return op.index;
}

Expand Down
14 changes: 7 additions & 7 deletions luau/CodeGen/include/Luau/IrVisitUseDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void visitVmRegDefsUses(T& visitor, IrFunction& function, const IrInst& i
{
if (count >= 3)
{
LUAU_ASSERT(inst.d.kind == IrOpKind::VmReg && vmRegOp(inst.d) == vmRegOp(inst.c) + 1);
CODEGEN_ASSERT(inst.d.kind == IrOpKind::VmReg && vmRegOp(inst.d) == vmRegOp(inst.c) + 1);

visitor.useRange(vmRegOp(inst.c), count);
}
Expand Down Expand Up @@ -206,12 +206,12 @@ static void visitVmRegDefsUses(T& visitor, IrFunction& function, const IrInst& i

default:
// All instructions which reference registers have to be handled explicitly
LUAU_ASSERT(inst.a.kind != IrOpKind::VmReg);
LUAU_ASSERT(inst.b.kind != IrOpKind::VmReg);
LUAU_ASSERT(inst.c.kind != IrOpKind::VmReg);
LUAU_ASSERT(inst.d.kind != IrOpKind::VmReg);
LUAU_ASSERT(inst.e.kind != IrOpKind::VmReg);
LUAU_ASSERT(inst.f.kind != IrOpKind::VmReg);
CODEGEN_ASSERT(inst.a.kind != IrOpKind::VmReg);
CODEGEN_ASSERT(inst.b.kind != IrOpKind::VmReg);
CODEGEN_ASSERT(inst.c.kind != IrOpKind::VmReg);
CODEGEN_ASSERT(inst.d.kind != IrOpKind::VmReg);
CODEGEN_ASSERT(inst.e.kind != IrOpKind::VmReg);
CODEGEN_ASSERT(inst.f.kind != IrOpKind::VmReg);
break;
}
}
Expand Down
Loading

0 comments on commit 2b8b9fe

Please sign in to comment.