23 if (Chunk && Chunk->Next)
24 std::free(Chunk->Next);
34 for (
PrimType Item : llvm::reverse(ItemTypes)) {
37 assert(ItemTypes.empty());
44 if (NewSize ==
size())
47 assert(NewSize <=
size());
48 for (
PrimType Item : llvm::reverse(ItemTypes)) {
51 if (
size() == NewSize)
56 assert(
size() == NewSize);
59void *InterpStack::grow(
size_t Size) {
60 assert(Size < ChunkSize -
sizeof(StackChunk) &&
"Object too large");
62 if (!Chunk ||
sizeof(StackChunk) + Chunk->size() + Size > ChunkSize) {
63 if (Chunk && Chunk->Next) {
66 StackChunk *Next =
new (std::malloc(ChunkSize)) StackChunk(Chunk);
73 auto *
Object =
reinterpret_cast<void *
>(Chunk->End);
79void *InterpStack::peekData(
size_t Size)
const {
80 assert(Chunk &&
"Stack is empty!");
82 StackChunk *Ptr = Chunk;
83 while (Size > Ptr->size()) {
86 assert(Ptr &&
"Offset too large");
89 return reinterpret_cast<void *
>(Ptr->End -
Size);
92void InterpStack::shrink(
size_t Size) {
93 assert(Chunk &&
"Chunk is empty!");
95 while (Size > Chunk->size()) {
96 Size -= Chunk->size();
98 std::free(Chunk->Next);
99 Chunk->Next =
nullptr;
101 Chunk->End = Chunk->start();
103 assert(Chunk &&
"Offset too large");
111 llvm::errs() <<
"Items: " << ItemTypes.size() <<
". Size: " <<
size() <<
'\n';
112 if (ItemTypes.empty())
120 for (
PrimType Item : llvm::reverse(ItemTypes)) {
123 llvm::errs() << Index <<
'/' << Offset <<
": ";
125 const T &
V = peek<T>(Offset);
128 llvm::errs() <<
'\n';
#define TYPE_SWITCH(Expr, B)
void clearTo(size_t NewSize)
void dump() const
dump the stack contents to stderr.
void clear()
Clears the stack.
size_t size() const
Returns the size of the stack in bytes.
bool empty() const
Returns whether the stack is empty.
~InterpStack()
Destroys the stack, freeing up storage.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
PrimType
Enumeration of the primitive types of the VM.
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T