Optimize various initial pre-allocs to happen within memory tracing

This commit is contained in:
Wojtek Figat
2026-03-23 18:25:05 +01:00
parent 90a0cc0e03
commit 3baec506e2
7 changed files with 71 additions and 13 deletions

View File

@@ -24,6 +24,7 @@
#include <unistd.h>
#include <emscripten/emscripten.h>
#include <emscripten/threading.h>
#include <emscripten/emmalloc.h>
#include <emscripten/version.h>
#include <emscripten/heap.h>
@@ -78,6 +79,38 @@ void WebFileSystem::GetSpecialFolderPath(const SpecialFolder type, String& resul
result = TEXT("/");
}
#if 0
void* WebPlatform::Allocate(uint64 size, uint64 alignment)
{
void* ptr = nullptr;
if (alignment && size)
{
// Alignment always has to be power of two
ASSERT_LOW_LAYER((alignment & (alignment - 1)) == 0);
ptr = emscripten_builtin_memalign(alignment, size);
if (!ptr)
OutOfMemory();
#if COMPILE_WITH_PROFILER
OnMemoryAlloc(ptr, size);
#endif
}
return ptr;
}
void WebPlatform::Free(void* ptr)
{
if (ptr)
{
#if COMPILE_WITH_PROFILER
OnMemoryFree(ptr);
#endif
emscripten_builtin_free(ptr);
}
}
#endif
String WebPlatform::GetSystemName()
{
return TEXT("Browser");