From 205f6ff2256f704854bff9a51bb86b64ad0473d6 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 3 Aug 2024 15:28:41 +0800 Subject: [PATCH] ... --- include/pocketpy/common/config.h | 12 ------------ src/common/memorypool.c | 18 +++--------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/include/pocketpy/common/config.h b/include/pocketpy/common/config.h index 65305e9e..48dbe861 100644 --- a/include/pocketpy/common/config.h +++ b/include/pocketpy/common/config.h @@ -13,12 +13,6 @@ #define PK_ENABLE_OS 0 #endif -// Enable this if you are working with multi-threading (experimental) -// This triggers necessary locks to make the VM thread-safe -#ifndef PK_ENABLE_THREAD // can be overridden by cmake -#define PK_ENABLE_THREAD 0 -#endif - // Enable `line_profiler` module and `breakpoint()` function #ifndef PK_ENABLE_PROFILER // can be overridden by cmake #define PK_ENABLE_PROFILER 0 @@ -56,9 +50,3 @@ #else #define PK_PLATFORM_SEP '/' #endif - -#if PK_ENABLE_THREAD -#define PK_THREAD_LOCAL thread_local -#else -#define PK_THREAD_LOCAL static -#endif diff --git a/src/common/memorypool.c b/src/common/memorypool.c index fd5f4d9d..40adb69f 100644 --- a/src/common/memorypool.c +++ b/src/common/memorypool.c @@ -238,59 +238,47 @@ static int FixedMemoryPool__total_bytes(FixedMemoryPool* self) { return self->BlockCount * self->BlockSize; } -PK_THREAD_LOCAL FixedMemoryPool PoolExpr; -PK_THREAD_LOCAL FixedMemoryPool PoolFrame; -PK_THREAD_LOCAL MemoryPool PoolObject; -PK_THREAD_LOCAL bool _Pools_initialized = false; +static FixedMemoryPool PoolExpr; +static FixedMemoryPool PoolFrame; +static MemoryPool PoolObject; void pk_MemoryPools__initialize(){ - if(_Pools_initialized) return; FixedMemoryPool__ctor(&PoolExpr, kPoolExprBlockSize, 64); FixedMemoryPool__ctor(&PoolFrame, kPoolFrameBlockSize, 128); MemoryPool__ctor(&PoolObject); - _Pools_initialized = true; } void pk_MemoryPools__finalize(){ - if(!_Pools_initialized) return; FixedMemoryPool__dtor(&PoolExpr); FixedMemoryPool__dtor(&PoolFrame); MemoryPool__dtor(&PoolObject); - _Pools_initialized = false; } void* PoolExpr_alloc() { - assert(_Pools_initialized); return FixedMemoryPool__alloc(&PoolExpr); } void PoolExpr_dealloc(void* p) { - assert(_Pools_initialized); FixedMemoryPool__dealloc(&PoolExpr, p); } void* PoolFrame_alloc() { - assert(_Pools_initialized); return FixedMemoryPool__alloc(&PoolFrame); } void PoolFrame_dealloc(void* p) { - assert(_Pools_initialized); FixedMemoryPool__dealloc(&PoolFrame, p); } void* PoolObject_alloc() { - assert(_Pools_initialized); return MemoryPool__alloc(&PoolObject); } void PoolObject_dealloc(void* p) { - assert(_Pools_initialized); MemoryPool__dealloc(&PoolObject, p); } void PoolObject_shrink_to_fit() { - assert(_Pools_initialized); MemoryPool__shrink_to_fit(&PoolObject); }