mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
ce8495a69e
# What's Changed? - Code refactoring with a new clang-format - More bug fixes / test case fixes in the new solver ## New Solver - More precise telemetry collection of `any` types - Simplification of two completely disjoint tables combines them into a single table that inherits all properties / indexers - Refining a `never & <anything>` does not produce type family types nor constraints - Silence "inference failed to complete" error when it is the only error reported --- ### Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Dibri Nsofor <dnsofor@roblox.com> Co-authored-by: Jeremy Yoo <jyoo@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: 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>
73 lines
2.4 KiB
C++
73 lines
2.4 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/CodeGen.h"
|
|
|
|
#include <vector>
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
namespace Luau
|
|
{
|
|
namespace CodeGen
|
|
{
|
|
|
|
constexpr uint32_t kCodeAlignment = 32;
|
|
|
|
struct CodeAllocator
|
|
{
|
|
CodeAllocator(size_t blockSize, size_t maxTotalSize);
|
|
CodeAllocator(size_t blockSize, size_t maxTotalSize, AllocationCallback* allocationCallback, void* allocationCallbackContext);
|
|
~CodeAllocator();
|
|
|
|
// Places data and code into the executable page area
|
|
// To allow allocation while previously allocated code is already running, allocation has page granularity
|
|
// It's important to group functions together so that page alignment won't result in a lot of wasted space
|
|
bool allocate(
|
|
const uint8_t* data,
|
|
size_t dataSize,
|
|
const uint8_t* code,
|
|
size_t codeSize,
|
|
uint8_t*& result,
|
|
size_t& resultSize,
|
|
uint8_t*& resultCodeStart
|
|
);
|
|
|
|
// Provided to unwind info callbacks
|
|
void* context = nullptr;
|
|
|
|
// Called when new block is created to create and setup the unwinding information for all the code in the block
|
|
// 'startOffset' reserves space for data at the beginning of the page
|
|
void* (*createBlockUnwindInfo)(void* context, uint8_t* block, size_t blockSize, size_t& startOffset) = nullptr;
|
|
|
|
// Called to destroy unwinding information returned by 'createBlockUnwindInfo'
|
|
void (*destroyBlockUnwindInfo)(void* context, void* unwindData) = nullptr;
|
|
|
|
private:
|
|
// Unwind information can be placed inside the block with some implementation-specific reservations at the beginning
|
|
// But to simplify block space checks, we limit the max size of all that data
|
|
static const size_t kMaxReservedDataSize = 256;
|
|
|
|
bool allocateNewBlock(size_t& unwindInfoSize);
|
|
|
|
uint8_t* allocatePages(size_t size) const;
|
|
void freePages(uint8_t* mem, size_t size) const;
|
|
|
|
// Current block we use for allocations
|
|
uint8_t* blockPos = nullptr;
|
|
uint8_t* blockEnd = nullptr;
|
|
|
|
// All allocated blocks
|
|
std::vector<uint8_t*> blocks;
|
|
std::vector<void*> unwindInfos;
|
|
|
|
size_t blockSize = 0;
|
|
size_t maxTotalSize = 0;
|
|
|
|
AllocationCallback* allocationCallback = nullptr;
|
|
void* allocationCallbackContext = nullptr;
|
|
};
|
|
|
|
} // namespace CodeGen
|
|
} // namespace Luau
|