Added temp arena and use it in hot reload

This commit is contained in:
2026-02-15 13:33:27 -05:00
parent 38f8662d80
commit 4ca3ef1706
4 changed files with 24 additions and 4 deletions

2
External/Imgui vendored

View File

@@ -51,6 +51,12 @@ namespace Juliet
}; };
static_assert(sizeof(Arena) <= k_ArenaHeaderSize); static_assert(sizeof(Arena) <= k_ArenaHeaderSize);
struct TempArena
{
Arena* Arena;
index_t Position;
};
struct ArenaParams struct ArenaParams
{ {
uint64 ReserveSize = g_Arena_Default_Reserve_Size; uint64 ReserveSize = g_Arena_Default_Reserve_Size;
@@ -97,4 +103,7 @@ namespace Juliet
return static_cast<Type*>(ArenaPush(arena, sizeof(Type) * count, Max(8ull, AlignOf(Type)), return static_cast<Type*>(ArenaPush(arena, sizeof(Type) * count, Max(8ull, AlignOf(Type)),
true JULIET_DEBUG_ONLY(, typeid(Type).name()))); true JULIET_DEBUG_ONLY(, typeid(Type).name())));
} }
TempArena ArenaTempBegin(NonNullPtr<Arena> arena);
void ArenaTempEnd(TempArena temp);
} // namespace Juliet } // namespace Juliet

View File

@@ -56,8 +56,8 @@ namespace Juliet
basePathLength + StringLength(code.TransientDLLName) + /* _ */ 1 + kTempDLLBufferSizeForID + 1 /* \0 */; basePathLength + StringLength(code.TransientDLLName) + /* _ */ 1 + kTempDLLBufferSizeForID + 1 /* \0 */;
// Allocate from Scratch Arena (transient) // Allocate from Scratch Arena (transient)
index_t pos = ArenaPos(code.Arena); TempArena temp = ArenaTempBegin(code.Arena);
auto tempDllPath = ArenaPushArray<char>(code.Arena, tempDllMaxBufferSize); auto tempDllPath = ArenaPushArray<char>(temp.Arena, tempDllMaxBufferSize);
for (uint32 attempt = 0; attempt < kMaxAttempts; ++attempt) for (uint32 attempt = 0; attempt < kMaxAttempts; ++attempt)
{ {
@@ -97,7 +97,7 @@ namespace Juliet
break; break;
} }
} }
ArenaPopTo(code.Arena, pos); ArenaTempEnd(temp);
code.Dll = LoadDynamicLibrary(tempDllPath); code.Dll = LoadDynamicLibrary(tempDllPath);
if (code.Dll) if (code.Dll)

View File

@@ -327,4 +327,15 @@ namespace Juliet
size_t position = current->BasePosition + current->Position; size_t position = current->BasePosition + current->Position;
return position; return position;
} }
TempArena ArenaTempBegin(NonNullPtr<Arena> arena)
{
index_t position = ArenaPos(arena);
return { arena.Get(), position };
}
void ArenaTempEnd(TempArena temp)
{
ArenaPopTo(temp.Arena, temp.Position);
}
} // namespace Juliet } // namespace Juliet