This commit is contained in:
blueloveTH 2025-01-23 13:14:41 +08:00
parent 723407dafe
commit ce97587689
7 changed files with 55 additions and 108 deletions

View File

@ -1,12 +1,18 @@
#pragma once #pragma once
#define kPoolExprBlockSize 128 typedef struct FixedMemoryPool {
#define kPoolFrameBlockSize 80 int BlockSize;
int BlockCount;
void MemoryPools__initialize(); char* data;
void MemoryPools__finalize(); char* data_end;
int exceeded_bytes;
void* PoolExpr_alloc(); char** _free_list;
void PoolExpr_dealloc(void*); char** _free_list_end;
void* PoolFrame_alloc(); } FixedMemoryPool;
void PoolFrame_dealloc(void*);
void FixedMemoryPool__ctor(FixedMemoryPool* self, int BlockSize, int BlockCount);
void FixedMemoryPool__dtor(FixedMemoryPool* self);
void* FixedMemoryPool__alloc(FixedMemoryPool* self);
void FixedMemoryPool__dealloc(FixedMemoryPool* self, void* p);

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "pocketpy/common/memorypool.h"
#include "pocketpy/objects/codeobject.h" #include "pocketpy/objects/codeobject.h"
#include "pocketpy/pocketpy.h" #include "pocketpy/pocketpy.h"
#include "pocketpy/interpreter/heap.h" #include "pocketpy/interpreter/heap.h"
@ -38,6 +39,7 @@ typedef struct VM {
py_StackRef __curr_function; py_StackRef __curr_function;
py_TValue __vectorcall_buffer[PK_MAX_CO_VARNAMES]; py_TValue __vectorcall_buffer[PK_MAX_CO_VARNAMES];
FixedMemoryPool pool_frame;
ManagedHeap heap; ManagedHeap heap;
ValueStack stack; // put `stack` at the end for better cache locality ValueStack stack; // put `stack` at the end for better cache locality
} VM; } VM;

View File

@ -4,19 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
typedef struct FixedMemoryPool { void FixedMemoryPool__ctor(FixedMemoryPool* self, int BlockSize, int BlockCount) {
int BlockSize;
int BlockCount;
char* data;
char* data_end;
int exceeded_bytes;
char** _free_list;
char** _free_list_end;
} FixedMemoryPool;
static void FixedMemoryPool__ctor(FixedMemoryPool* self, int BlockSize, int BlockCount) {
self->BlockSize = BlockSize; self->BlockSize = BlockSize;
self->BlockCount = BlockCount; self->BlockCount = BlockCount;
self->exceeded_bytes = 0; self->exceeded_bytes = 0;
@ -29,12 +17,12 @@ static void FixedMemoryPool__ctor(FixedMemoryPool* self, int BlockSize, int Bloc
} }
} }
static void FixedMemoryPool__dtor(FixedMemoryPool* self) { void FixedMemoryPool__dtor(FixedMemoryPool* self) {
PK_FREE(self->_free_list); PK_FREE(self->_free_list);
PK_FREE(self->data); PK_FREE(self->data);
} }
static void* FixedMemoryPool__alloc(FixedMemoryPool* self) { void* FixedMemoryPool__alloc(FixedMemoryPool* self) {
if(self->_free_list_end != self->_free_list) { if(self->_free_list_end != self->_free_list) {
self->_free_list_end--; self->_free_list_end--;
return *self->_free_list_end; return *self->_free_list_end;
@ -44,7 +32,7 @@ static void* FixedMemoryPool__alloc(FixedMemoryPool* self) {
} }
} }
static void FixedMemoryPool__dealloc(FixedMemoryPool* self, void* p) { void FixedMemoryPool__dealloc(FixedMemoryPool* self, void* p) {
bool is_valid = (char*)p >= self->data && (char*)p < self->data_end; bool is_valid = (char*)p >= self->data && (char*)p < self->data_end;
if(is_valid) { if(is_valid) {
*self->_free_list_end = p; *self->_free_list_end = p;
@ -55,39 +43,10 @@ static void FixedMemoryPool__dealloc(FixedMemoryPool* self, void* p) {
} }
} }
static int FixedMemoryPool__used_bytes(FixedMemoryPool* self) { // static int FixedMemoryPool__used_bytes(FixedMemoryPool* self) {
return (self->_free_list_end - self->_free_list) * self->BlockSize; // return (self->_free_list_end - self->_free_list) * self->BlockSize;
} // }
static int FixedMemoryPool__total_bytes(FixedMemoryPool* self) { // static int FixedMemoryPool__total_bytes(FixedMemoryPool* self) {
return self->BlockCount * self->BlockSize; // return self->BlockCount * self->BlockSize;
} // }
static FixedMemoryPool PoolExpr;
static FixedMemoryPool PoolFrame;
void MemoryPools__initialize(){
FixedMemoryPool__ctor(&PoolExpr, kPoolExprBlockSize, 64);
FixedMemoryPool__ctor(&PoolFrame, kPoolFrameBlockSize, 128);
}
void MemoryPools__finalize(){
FixedMemoryPool__dtor(&PoolExpr);
FixedMemoryPool__dtor(&PoolFrame);
}
void* PoolExpr_alloc() {
return FixedMemoryPool__alloc(&PoolExpr);
}
void PoolExpr_dealloc(void* p) {
FixedMemoryPool__dealloc(&PoolExpr, p);
}
void* PoolFrame_alloc() {
return FixedMemoryPool__alloc(&PoolFrame);
}
void PoolFrame_dealloc(void* p) {
FixedMemoryPool__dealloc(&PoolFrame, p);
}

View File

@ -1,10 +1,10 @@
#include "pocketpy/compiler/compiler.h" #include "pocketpy/compiler/compiler.h"
#include "pocketpy/compiler/lexer.h" #include "pocketpy/compiler/lexer.h"
#include "pocketpy/objects/base.h"
#include "pocketpy/objects/codeobject.h" #include "pocketpy/objects/codeobject.h"
#include "pocketpy/objects/sourcedata.h" #include "pocketpy/objects/sourcedata.h"
#include "pocketpy/objects/object.h" #include "pocketpy/objects/object.h"
#include "pocketpy/common/sstream.h" #include "pocketpy/common/sstream.h"
#include "pocketpy/common/memorypool.h"
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
@ -30,8 +30,6 @@ typedef struct ExprVt {
void (*dtor)(Expr*); void (*dtor)(Expr*);
} ExprVt; } ExprVt;
#define static_assert_expr_size(T) static_assert(sizeof(T) <= kPoolExprBlockSize, "")
#define vtcall(f, self, ctx) ((self)->vt->f((self), (ctx))) #define vtcall(f, self, ctx) ((self)->vt->f((self), (ctx)))
#define vtemit_(self, ctx) vtcall(emit_, (self), (ctx)) #define vtemit_(self, ctx) vtcall(emit_, (self), (ctx))
#define vtemit_del(self, ctx) ((self)->vt->emit_del ? vtcall(emit_del, self, ctx) : false) #define vtemit_del(self, ctx) ((self)->vt->emit_del ? vtcall(emit_del, self, ctx) : false)
@ -44,7 +42,7 @@ typedef struct ExprVt {
do { \ do { \
if(self) { \ if(self) { \
if((self)->vt->dtor) (self)->vt->dtor(self); \ if((self)->vt->dtor) (self)->vt->dtor(self); \
PoolExpr_dealloc(self); \ PK_FREE(self); \
} \ } \
} while(0) } while(0)
@ -148,8 +146,7 @@ NameExpr* NameExpr__new(int line, py_Name name, NameScope scope) {
.emit_del = NameExpr__emit_del, .emit_del = NameExpr__emit_del,
.emit_store = NameExpr__emit_store, .emit_store = NameExpr__emit_store,
.is_name = true}; .is_name = true};
static_assert_expr_size(NameExpr); NameExpr* self = PK_MALLOC(sizeof(NameExpr));
NameExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->name = name; self->name = name;
@ -186,8 +183,7 @@ StarredExpr* StarredExpr__new(int line, Expr* child, int level) {
.emit_store = StarredExpr__emit_store, .emit_store = StarredExpr__emit_store,
.is_starred = true, .is_starred = true,
.dtor = StarredExpr__dtor}; .dtor = StarredExpr__dtor};
static_assert_expr_size(StarredExpr); StarredExpr* self = PK_MALLOC(sizeof(StarredExpr));
StarredExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->child = child; self->child = child;
@ -216,8 +212,7 @@ static void UnaryExpr__emit_(Expr* self_, Ctx* ctx) {
UnaryExpr* UnaryExpr__new(int line, Expr* child, Opcode opcode) { UnaryExpr* UnaryExpr__new(int line, Expr* child, Opcode opcode) {
const static ExprVt Vt = {.emit_ = UnaryExpr__emit_, .dtor = UnaryExpr__dtor}; const static ExprVt Vt = {.emit_ = UnaryExpr__emit_, .dtor = UnaryExpr__dtor};
static_assert_expr_size(UnaryExpr); UnaryExpr* self = PK_MALLOC(sizeof(UnaryExpr));
UnaryExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->child = child; self->child = child;
@ -240,8 +235,7 @@ void FStringSpecExpr__emit_(Expr* self_, Ctx* ctx) {
FStringSpecExpr* FStringSpecExpr__new(int line, Expr* child, c11_sv spec) { FStringSpecExpr* FStringSpecExpr__new(int line, Expr* child, c11_sv spec) {
const static ExprVt Vt = {.emit_ = FStringSpecExpr__emit_, .dtor = UnaryExpr__dtor}; const static ExprVt Vt = {.emit_ = FStringSpecExpr__emit_, .dtor = UnaryExpr__dtor};
static_assert_expr_size(FStringSpecExpr); FStringSpecExpr* self = PK_MALLOC(sizeof(FStringSpecExpr));
FStringSpecExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->child = child; self->child = child;
@ -263,8 +257,7 @@ void RawStringExpr__emit_(Expr* self_, Ctx* ctx) {
RawStringExpr* RawStringExpr__new(int line, c11_sv value, Opcode opcode) { RawStringExpr* RawStringExpr__new(int line, c11_sv value, Opcode opcode) {
const static ExprVt Vt = {.emit_ = RawStringExpr__emit_}; const static ExprVt Vt = {.emit_ = RawStringExpr__emit_};
static_assert_expr_size(RawStringExpr); RawStringExpr* self = PK_MALLOC(sizeof(RawStringExpr));
RawStringExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->value = value; self->value = value;
@ -288,8 +281,7 @@ void ImagExpr__emit_(Expr* self_, Ctx* ctx) {
ImagExpr* ImagExpr__new(int line, double value) { ImagExpr* ImagExpr__new(int line, double value) {
const static ExprVt Vt = {.emit_ = ImagExpr__emit_}; const static ExprVt Vt = {.emit_ = ImagExpr__emit_};
static_assert_expr_size(ImagExpr); ImagExpr* self = PK_MALLOC(sizeof(ImagExpr));
ImagExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->value = value; self->value = value;
@ -333,8 +325,7 @@ void LiteralExpr__emit_(Expr* self_, Ctx* ctx) {
LiteralExpr* LiteralExpr__new(int line, const TokenValue* value) { LiteralExpr* LiteralExpr__new(int line, const TokenValue* value) {
const static ExprVt Vt = {.emit_ = LiteralExpr__emit_, .is_literal = true}; const static ExprVt Vt = {.emit_ = LiteralExpr__emit_, .is_literal = true};
static_assert_expr_size(LiteralExpr); LiteralExpr* self = PK_MALLOC(sizeof(LiteralExpr));
LiteralExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->value = value; self->value = value;
@ -362,8 +353,7 @@ void Literal0Expr__emit_(Expr* self_, Ctx* ctx) {
Literal0Expr* Literal0Expr__new(int line, TokenIndex token) { Literal0Expr* Literal0Expr__new(int line, TokenIndex token) {
const static ExprVt Vt = {.emit_ = Literal0Expr__emit_}; const static ExprVt Vt = {.emit_ = Literal0Expr__emit_};
static_assert_expr_size(Literal0Expr); Literal0Expr* self = PK_MALLOC(sizeof(Literal0Expr));
Literal0Expr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->token = token; self->token = token;
@ -403,8 +393,7 @@ void SliceExpr__emit_(Expr* self_, Ctx* ctx) {
SliceExpr* SliceExpr__new(int line) { SliceExpr* SliceExpr__new(int line) {
const static ExprVt Vt = {.dtor = SliceExpr__dtor, .emit_ = SliceExpr__emit_}; const static ExprVt Vt = {.dtor = SliceExpr__dtor, .emit_ = SliceExpr__emit_};
static_assert_expr_size(SliceExpr); SliceExpr* self = PK_MALLOC(sizeof(SliceExpr));
SliceExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->start = NULL; self->start = NULL;
@ -433,8 +422,7 @@ static void DictItemExpr__emit_(Expr* self_, Ctx* ctx) {
static DictItemExpr* DictItemExpr__new(int line) { static DictItemExpr* DictItemExpr__new(int line) {
const static ExprVt Vt = {.dtor = DictItemExpr__dtor, .emit_ = DictItemExpr__emit_}; const static ExprVt Vt = {.dtor = DictItemExpr__dtor, .emit_ = DictItemExpr__emit_};
static_assert_expr_size(DictItemExpr); DictItemExpr* self = PK_MALLOC(sizeof(DictItemExpr));
DictItemExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->key = NULL; self->key = NULL;
@ -521,8 +509,7 @@ bool TupleExpr__emit_del(Expr* self_, Ctx* ctx) {
} }
static SequenceExpr* SequenceExpr__new(int line, const ExprVt* vt, int count, Opcode opcode) { static SequenceExpr* SequenceExpr__new(int line, const ExprVt* vt, int count, Opcode opcode) {
static_assert_expr_size(SequenceExpr); SequenceExpr* self = PK_MALLOC(sizeof(SequenceExpr));
SequenceExpr* self = PoolExpr_alloc();
self->vt = vt; self->vt = vt;
self->line = line; self->line = line;
self->opcode = opcode; self->opcode = opcode;
@ -608,8 +595,7 @@ void CompExpr__emit_(Expr* self_, Ctx* ctx) {
CompExpr* CompExpr__new(int line, Opcode op0, Opcode op1) { CompExpr* CompExpr__new(int line, Opcode op0, Opcode op1) {
const static ExprVt Vt = {.dtor = CompExpr__dtor, .emit_ = CompExpr__emit_}; const static ExprVt Vt = {.dtor = CompExpr__dtor, .emit_ = CompExpr__emit_};
static_assert_expr_size(CompExpr); CompExpr* self = PK_MALLOC(sizeof(CompExpr));
CompExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->op0 = op0; self->op0 = op0;
@ -633,8 +619,7 @@ static void LambdaExpr__emit_(Expr* self_, Ctx* ctx) {
LambdaExpr* LambdaExpr__new(int line, int index) { LambdaExpr* LambdaExpr__new(int line, int index) {
const static ExprVt Vt = {.emit_ = LambdaExpr__emit_}; const static ExprVt Vt = {.emit_ = LambdaExpr__emit_};
static_assert_expr_size(LambdaExpr); LambdaExpr* self = PK_MALLOC(sizeof(LambdaExpr));
LambdaExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->index = index; self->index = index;
@ -665,8 +650,7 @@ void LogicBinaryExpr__emit_(Expr* self_, Ctx* ctx) {
LogicBinaryExpr* LogicBinaryExpr__new(int line, Opcode opcode) { LogicBinaryExpr* LogicBinaryExpr__new(int line, Opcode opcode) {
const static ExprVt Vt = {.emit_ = LogicBinaryExpr__emit_, .dtor = LogicBinaryExpr__dtor}; const static ExprVt Vt = {.emit_ = LogicBinaryExpr__emit_, .dtor = LogicBinaryExpr__dtor};
static_assert_expr_size(LogicBinaryExpr); LogicBinaryExpr* self = PK_MALLOC(sizeof(LogicBinaryExpr));
LogicBinaryExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->lhs = NULL; self->lhs = NULL;
@ -705,8 +689,7 @@ GroupedExpr* GroupedExpr__new(int line, Expr* child) {
.emit_ = GroupedExpr__emit_, .emit_ = GroupedExpr__emit_,
.emit_del = GroupedExpr__emit_del, .emit_del = GroupedExpr__emit_del,
.emit_store = GroupedExpr__emit_store}; .emit_store = GroupedExpr__emit_store};
static_assert_expr_size(GroupedExpr); GroupedExpr* self = PK_MALLOC(sizeof(GroupedExpr));
GroupedExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->child = child; self->child = child;
@ -833,8 +816,7 @@ BinaryExpr* BinaryExpr__new(int line, TokenIndex op, bool inplace) {
const static ExprVt Vt = {.emit_ = BinaryExpr__emit_, const static ExprVt Vt = {.emit_ = BinaryExpr__emit_,
.dtor = BinaryExpr__dtor, .dtor = BinaryExpr__dtor,
.is_binary = true}; .is_binary = true};
static_assert_expr_size(BinaryExpr); BinaryExpr* self = PK_MALLOC(sizeof(BinaryExpr));
BinaryExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->lhs = NULL; self->lhs = NULL;
@ -871,8 +853,7 @@ void TernaryExpr__emit_(Expr* self_, Ctx* ctx) {
TernaryExpr* TernaryExpr__new(int line) { TernaryExpr* TernaryExpr__new(int line) {
const static ExprVt Vt = {.dtor = TernaryExpr__dtor, .emit_ = TernaryExpr__emit_}; const static ExprVt Vt = {.dtor = TernaryExpr__dtor, .emit_ = TernaryExpr__emit_};
static_assert_expr_size(TernaryExpr); TernaryExpr* self = PK_MALLOC(sizeof(TernaryExpr));
TernaryExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->cond = NULL; self->cond = NULL;
@ -942,8 +923,7 @@ SubscrExpr* SubscrExpr__new(int line) {
.emit_del = SubscrExpr__emit_del, .emit_del = SubscrExpr__emit_del,
.is_subscr = true, .is_subscr = true,
}; };
static_assert_expr_size(SubscrExpr); SubscrExpr* self = PK_MALLOC(sizeof(SubscrExpr));
SubscrExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->lhs = NULL; self->lhs = NULL;
@ -1005,8 +985,7 @@ AttribExpr* AttribExpr__new(int line, Expr* child, py_Name name) {
.emit_istore = AttribExpr__emit_istore, .emit_istore = AttribExpr__emit_istore,
.dtor = AttribExpr__dtor, .dtor = AttribExpr__dtor,
.is_attrib = true}; .is_attrib = true};
static_assert_expr_size(AttribExpr); AttribExpr* self = PK_MALLOC(sizeof(AttribExpr));
AttribExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->child = child; self->child = child;
@ -1078,8 +1057,7 @@ void CallExpr__emit_(Expr* self_, Ctx* ctx) {
CallExpr* CallExpr__new(int line, Expr* callable) { CallExpr* CallExpr__new(int line, Expr* callable) {
const static ExprVt Vt = {.dtor = CallExpr__dtor, .emit_ = CallExpr__emit_}; const static ExprVt Vt = {.dtor = CallExpr__dtor, .emit_ = CallExpr__emit_};
static_assert_expr_size(CallExpr); CallExpr* self = PK_MALLOC(sizeof(CallExpr));
CallExpr* self = PoolExpr_alloc();
self->vt = &Vt; self->vt = &Vt;
self->line = line; self->line = line;
self->callable = callable; self->callable = callable;

View File

@ -1,4 +1,5 @@
#include "pocketpy/interpreter/frame.h" #include "pocketpy/interpreter/frame.h"
#include "pocketpy/common/memorypool.h"
#include "pocketpy/interpreter/vm.h" #include "pocketpy/interpreter/vm.h"
#include "pocketpy/objects/base.h" #include "pocketpy/objects/base.h"
#include "pocketpy/objects/codeobject.h" #include "pocketpy/objects/codeobject.h"
@ -42,8 +43,7 @@ Frame* Frame__new(const CodeObject* co,
py_StackRef p0, py_StackRef p0,
py_StackRef locals, py_StackRef locals,
bool has_function) { bool has_function) {
static_assert(sizeof(Frame) <= kPoolFrameBlockSize, "!(sizeof(Frame) <= kPoolFrameBlockSize)"); Frame* self = FixedMemoryPool__alloc(&pk_current_vm->pool_frame);
Frame* self = PoolFrame_alloc();
self->f_back = NULL; self->f_back = NULL;
self->ip = (Bytecode*)co->codes.data - 1; self->ip = (Bytecode*)co->codes.data - 1;
self->co = co; self->co = co;
@ -62,7 +62,7 @@ void Frame__delete(Frame* self) {
self->uw_list = p->next; self->uw_list = p->next;
UnwindTarget__delete(p); UnwindTarget__delete(p);
} }
PoolFrame_dealloc(self); FixedMemoryPool__dealloc(&pk_current_vm->pool_frame, self);
} }
int Frame__prepare_jump_exception_handler(Frame* self, ValueStack* _s) { int Frame__prepare_jump_exception_handler(Frame* self, ValueStack* _s) {

View File

@ -1,4 +1,5 @@
#include "pocketpy/interpreter/vm.h" #include "pocketpy/interpreter/vm.h"
#include "pocketpy/common/memorypool.h"
#include "pocketpy/common/sstream.h" #include "pocketpy/common/sstream.h"
#include "pocketpy/common/utils.h" #include "pocketpy/common/utils.h"
#include "pocketpy/interpreter/generator.h" #include "pocketpy/interpreter/generator.h"
@ -75,6 +76,8 @@ void VM__ctor(VM* self) {
self->__curr_class = NULL; self->__curr_class = NULL;
self->__curr_function = NULL; self->__curr_function = NULL;
FixedMemoryPool__ctor(&self->pool_frame, sizeof(Frame), 32);
ManagedHeap__ctor(&self->heap); ManagedHeap__ctor(&self->heap);
ValueStack__ctor(&self->stack); ValueStack__ctor(&self->stack);
@ -246,6 +249,7 @@ void VM__dtor(VM* self) {
VM__pop_frame(self); VM__pop_frame(self);
ModuleDict__dtor(&self->modules); ModuleDict__dtor(&self->modules);
TypeList__dtor(&self->types); TypeList__dtor(&self->types);
FixedMemoryPool__dtor(&self->pool_frame);
ValueStack__clear(&self->stack); ValueStack__clear(&self->stack);
} }

View File

@ -27,7 +27,6 @@ void py_initialize() {
static_assert(sizeof(py_TValue) == 16, "sizeof(py_TValue) != 16"); static_assert(sizeof(py_TValue) == 16, "sizeof(py_TValue) != 16");
static_assert(offsetof(py_TValue, extra) == 4, "offsetof(py_TValue, extra) != 4"); static_assert(offsetof(py_TValue, extra) == 4, "offsetof(py_TValue, extra) != 4");
MemoryPools__initialize();
py_Name__initialize(); py_Name__initialize();
pk_current_vm = pk_all_vm[0] = &pk_default_vm; pk_current_vm = pk_all_vm[0] = &pk_default_vm;
@ -63,7 +62,6 @@ void py_finalize() {
VM__dtor(&pk_default_vm); VM__dtor(&pk_default_vm);
pk_current_vm = NULL; pk_current_vm = NULL;
py_Name__finalize(); py_Name__finalize();
MemoryPools__finalize();
} }
void py_switchvm(int index) { void py_switchvm(int index) {