mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
some fix
This commit is contained in:
parent
d8d5a1588a
commit
48bd3e113e
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
|
void init_memory_pools_if_needed();
|
||||||
|
|
||||||
void* pool64_alloc(size_t) noexcept;
|
void* pool64_alloc(size_t) noexcept;
|
||||||
void pool64_dealloc(void*) noexcept;
|
void pool64_dealloc(void*) noexcept;
|
||||||
|
|
||||||
|
@ -267,21 +267,26 @@ struct MemoryPool{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static MemoryPool<64> pool64;
|
static MemoryPool<64>* pool64;
|
||||||
static MemoryPool<128> pool128;
|
static MemoryPool<128>* pool128;
|
||||||
|
|
||||||
void* pool64_alloc(size_t size) noexcept { return pool64.alloc(size); }
|
void init_memory_pools_if_needed(){
|
||||||
void pool64_dealloc(void* p) noexcept { pool64.dealloc(p); }
|
if(pool64 == nullptr) pool64 = new MemoryPool<64>();
|
||||||
|
if(pool128 == nullptr) pool128 = new MemoryPool<128>();
|
||||||
|
}
|
||||||
|
|
||||||
void* pool128_alloc(size_t size) noexcept { return pool128.alloc(size); }
|
void* pool64_alloc(size_t size) noexcept { return pool64->alloc(size); }
|
||||||
void pool128_dealloc(void* p) noexcept { pool128.dealloc(p); }
|
void pool64_dealloc(void* p) noexcept { pool64->dealloc(p); }
|
||||||
|
|
||||||
|
void* pool128_alloc(size_t size) noexcept { return pool128->alloc(size); }
|
||||||
|
void pool128_dealloc(void* p) noexcept { pool128->dealloc(p); }
|
||||||
|
|
||||||
void pools_shrink_to_fit() noexcept {
|
void pools_shrink_to_fit() noexcept {
|
||||||
pool64.shrink_to_fit();
|
pool64->shrink_to_fit();
|
||||||
pool128.shrink_to_fit();
|
pool128->shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pool64_info() noexcept { return pool64.info(); }
|
std::string pool64_info() noexcept { return pool64->info(); }
|
||||||
std::string pool128_info() noexcept { return pool128.info(); }
|
std::string pool128_info() noexcept { return pool128->info(); }
|
||||||
|
|
||||||
}
|
}
|
@ -73,6 +73,7 @@ namespace pkpy{
|
|||||||
};
|
};
|
||||||
|
|
||||||
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
|
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
|
||||||
|
init_memory_pools_if_needed();
|
||||||
this->vm = this;
|
this->vm = this;
|
||||||
this->_c.error = nullptr;
|
this->_c.error = nullptr;
|
||||||
_stdout = [](const char* buf, int size) { std::cout.write(buf, size); };
|
_stdout = [](const char* buf, int size) { std::cout.write(buf, size); };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user