mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 22:35:43 +08:00
ea14e65ea0
# What's changed? * Compiler now targets bytecode version 5 by default, this includes support for vector type literals and sub/div opcodes with a constant on lhs ### New Type Solver * Normalizer type inhabitance check has been optimized * Added ability to reduce cyclic `and`/`or` type families ### Native Code Generation * `CodeGen::compile` now returns more specific causes of a code generation failure * Fixed linking issues on platforms that don't support unwind frame data registration --- ### Internal Contributors Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@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: 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>
84 lines
1.7 KiB
C++
84 lines
1.7 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/CodeGenCommon.h"
|
|
#include "Luau/Bytecode.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <stdint.h>
|
|
|
|
struct lua_State;
|
|
struct Proto;
|
|
|
|
namespace Luau
|
|
{
|
|
namespace CodeGen
|
|
{
|
|
|
|
class FunctionBytecodeSummary
|
|
{
|
|
public:
|
|
FunctionBytecodeSummary(std::string source, std::string name, const int line, unsigned nestingLimit);
|
|
|
|
const std::string& getSource() const
|
|
{
|
|
return source;
|
|
}
|
|
|
|
const std::string& getName() const
|
|
{
|
|
return name;
|
|
}
|
|
|
|
int getLine() const
|
|
{
|
|
return line;
|
|
}
|
|
|
|
const unsigned getNestingLimit() const
|
|
{
|
|
return nestingLimit;
|
|
}
|
|
|
|
const unsigned getOpLimit() const
|
|
{
|
|
return LOP__COUNT;
|
|
}
|
|
|
|
void incCount(unsigned nesting, uint8_t op)
|
|
{
|
|
CODEGEN_ASSERT(nesting <= getNestingLimit());
|
|
CODEGEN_ASSERT(op < getOpLimit());
|
|
++counts[nesting][op];
|
|
}
|
|
|
|
unsigned getCount(unsigned nesting, uint8_t op) const
|
|
{
|
|
CODEGEN_ASSERT(nesting <= getNestingLimit());
|
|
CODEGEN_ASSERT(op < getOpLimit());
|
|
return counts[nesting][op];
|
|
}
|
|
|
|
const std::vector<unsigned>& getCounts(unsigned nesting) const
|
|
{
|
|
CODEGEN_ASSERT(nesting <= getNestingLimit());
|
|
return counts[nesting];
|
|
}
|
|
|
|
static FunctionBytecodeSummary fromProto(Proto* proto, unsigned nestingLimit);
|
|
|
|
private:
|
|
std::string source;
|
|
std::string name;
|
|
int line;
|
|
unsigned nestingLimit;
|
|
std::vector<std::vector<unsigned>> counts;
|
|
};
|
|
|
|
std::vector<FunctionBytecodeSummary> summarizeBytecode(lua_State* L, int idx, unsigned nestingLimit);
|
|
|
|
} // namespace CodeGen
|
|
} // namespace Luau
|