From a1f7a16ddc3d8f006fe59b0c582f8f455cd1f3c6 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 20 May 2024 00:24:35 +0800 Subject: [PATCH] some fix --- include/pocketpy/gc.h | 4 ++-- include/pocketpy/obj.h | 5 +++-- src/codeobject.cpp | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/pocketpy/gc.h b/include/pocketpy/gc.h index 21090ce0..e9ab0435 100644 --- a/include/pocketpy/gc.h +++ b/include/pocketpy/gc.h @@ -43,7 +43,7 @@ struct ManagedHeap{ using __T = std::decay_t; static_assert(!is_sso_v<__T>, "gcnew cannot be used with SSO types"); // https://github.com/pocketpy/pocketpy/issues/94#issuecomment-1594784476 - PyObject* p = new(pool128_alloc(py_sizeof<__T>)) PyObject(true); + PyObject* p = new(pool128_alloc(py_sizeof<__T>)) PyObject(); p->placement_new<__T>(std::forward(args)...); gen.emplace_back(type, p); gc_counter++; @@ -54,7 +54,7 @@ struct ManagedHeap{ PyVar _new(Type type, Args&&... args){ using __T = std::decay_t; static_assert(!is_sso_v<__T>); - PyObject* p = new(pool128_alloc<__T>()) PyObject(false); + PyObject* p = new(pool128_alloc<__T>()) PyObject(); p->placement_new<__T>(std::forward(args)...); _no_gc.emplace_back(type, p); return _no_gc.back(); diff --git a/include/pocketpy/obj.h b/include/pocketpy/obj.h index eabaf4b3..3a3bb7a9 100644 --- a/include/pocketpy/obj.h +++ b/include/pocketpy/obj.h @@ -102,7 +102,6 @@ struct Slice { }; struct PyObject final{ - bool gc_enabled; // whether this object is managed by GC bool gc_marked; // whether this object is marked NameDict* _attr; @@ -119,7 +118,7 @@ struct PyObject final{ return (*_attr)[name]; } - PyObject(bool gc_enabled) : gc_enabled(gc_enabled), gc_marked(false), _attr(nullptr) {} + PyObject() : gc_marked(false), _attr(nullptr) {} template void placement_new(Args&&... args){ @@ -147,6 +146,8 @@ struct PyObject final{ template inline constexpr int py_sizeof = sizeof(PyObject) + sizeof(T); +static_assert(sizeof(PyObject) == 16); + const int kTpIntIndex = 3; const int kTpFloatIndex = 4; diff --git a/src/codeobject.cpp b/src/codeobject.cpp index 177ac565..358b19a8 100644 --- a/src/codeobject.cpp +++ b/src/codeobject.cpp @@ -7,7 +7,7 @@ namespace pkpy{ blocks.push_back(CodeBlock(CodeBlockType::NO_BLOCK, -1, 0, 0)); } - PyVar const PY_NULL(Type(), new PyObject(false)); - PyVar const PY_OP_CALL(Type(), new PyObject(false)); - PyVar const PY_OP_YIELD(Type(), new PyObject(false)); + PyVar const PY_NULL(Type(), new PyObject()); + PyVar const PY_OP_CALL(Type(), new PyObject()); + PyVar const PY_OP_YIELD(Type(), new PyObject()); } // namespace pkpy \ No newline at end of file