25 if (Chunk && Chunk->Next)
26 std::free(Chunk->Next);
37 assert(NewSize <=
size());
38 size_t ToShrink =
size() - NewSize;
43 assert(
size() == NewSize);
46void *InterpStack::grow(
size_t Size) {
47 assert(Size < ChunkSize -
sizeof(StackChunk) &&
"Object too large");
49 if (!Chunk ||
sizeof(StackChunk) + Chunk->size() + Size > ChunkSize) {
50 if (Chunk && Chunk->Next) {
53 StackChunk *Next =
new (std::malloc(ChunkSize)) StackChunk(Chunk);
60 auto *
Object =
reinterpret_cast<void *
>(Chunk->End);
66void *InterpStack::peekData(
size_t Size)
const {
67 assert(Chunk &&
"Stack is empty!");
69 StackChunk *Ptr = Chunk;
70 while (Size > Ptr->size()) {
73 assert(Ptr &&
"Offset too large");
76 return reinterpret_cast<void *
>(Ptr->End -
Size);
79void InterpStack::shrink(
size_t Size) {
80 assert(Chunk &&
"Chunk is empty!");
82 while (Size > Chunk->size()) {
83 Size -= Chunk->size();
85 std::free(Chunk->Next);
86 Chunk->Next =
nullptr;
88 Chunk->End = Chunk->start();
90 assert(Chunk &&
"Offset too large");
101 size_t StackSize =
size();
102 while (TypesSize > StackSize) {
104 TypesSize -= aligned_size<T>();
105 ItemTypes.pop_back();
108 assert(TypesSize == StackSize);
114 llvm::errs() <<
"Items: " << ItemTypes.size() <<
". Size: " <<
size() <<
'\n';
115 if (ItemTypes.empty())
123 for (
auto TyIt = ItemTypes.rbegin(); TyIt != ItemTypes.rend(); ++TyIt) {
126 llvm::errs() << Index <<
'/' << Offset <<
": ";
128 const T &
V = peek<T>(Offset);
131 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 without calling any destructors.
size_t size() const
Returns the size of the stack in bytes.
~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