Commit 6a880f44 authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by Kevin Modzelewski

Move some functions to where I think they make more sense

parent 3a811c26
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "capi/typeobject.h" #include "capi/typeobject.h"
#include "capi/types.h" #include "capi/types.h"
#include "codegen/unwinding.h"
#include "core/types.h" #include "core/types.h"
#include "runtime/objmodel.h" #include "runtime/objmodel.h"
#include "runtime/rewrite_args.h" #include "runtime/rewrite_args.h"
......
...@@ -337,10 +337,6 @@ extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size) { ...@@ -337,10 +337,6 @@ extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size) {
return &elts[0]; return &elts[0];
} }
void dealloc_null(Box* box) {
assert(box->cls->tp_del == NULL);
}
// Analoguous to CPython's implementation of subtype_dealloc, but having a GC // Analoguous to CPython's implementation of subtype_dealloc, but having a GC
// saves us from complications involving "trashcan macros". // saves us from complications involving "trashcan macros".
// //
...@@ -378,12 +374,6 @@ static void subtype_dealloc(Box* self) { ...@@ -378,12 +374,6 @@ static void subtype_dealloc(Box* self) {
} }
} }
// We don't need CPython's version of tp_free since we have GC.
// We still need to set tp_free to something and not a NULL pointer,
// because C extensions might still call tp_free from tp_dealloc.
void default_free(void*) {
}
bool BoxedClass::hasNonDefaultTpDealloc() { bool BoxedClass::hasNonDefaultTpDealloc() {
// Find nearest base with a different tp_dealloc. // Find nearest base with a different tp_dealloc.
BoxedClass* base = this; BoxedClass* base = this;
......
...@@ -42,17 +42,11 @@ void _printStacktrace(); ...@@ -42,17 +42,11 @@ void _printStacktrace();
extern "C" Box* deopt(AST_expr* expr, Box* value); extern "C" Box* deopt(AST_expr* expr, Box* value);
// Finalizer-related
void default_free(void*);
void dealloc_null(Box* box);
// helper function for raising from the runtime: // helper function for raising from the runtime:
void raiseExcHelper(BoxedClass*, const char* fmt, ...) __attribute__((__noreturn__)) void raiseExcHelper(BoxedClass*, const char* fmt, ...) __attribute__((__noreturn__))
__attribute__((format(printf, 2, 3))); __attribute__((format(printf, 2, 3)));
void raiseExcHelper(BoxedClass*, Box* arg) __attribute__((__noreturn__)); void raiseExcHelper(BoxedClass*, Box* arg) __attribute__((__noreturn__));
BoxedModule* getCurrentModule();
// TODO sort this // TODO sort this
extern "C" bool softspace(Box* b, bool newval); extern "C" bool softspace(Box* b, bool newval);
extern "C" void printHelper(Box* dest, Box* var, bool nl); extern "C" void printHelper(Box* dest, Box* var, bool nl);
......
...@@ -3498,6 +3498,16 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept { ...@@ -3498,6 +3498,16 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
return unicode; return unicode;
} }
// We don't need CPython's version of tp_free since we have GC.
// We still need to set tp_free to something and not a NULL pointer,
// because C extensions might still call tp_free from tp_dealloc.
void default_free(void*) {
}
void dealloc_null(Box* box) {
assert(box->cls->tp_del == NULL);
}
// Normally we don't call the Python tp_ slots that are present to support // Normally we don't call the Python tp_ slots that are present to support
// CPython's reference-counted garbage collection. // CPython's reference-counted garbage collection.
static void setTypeGCProxy(BoxedClass* cls) { static void setTypeGCProxy(BoxedClass* cls) {
......
...@@ -181,6 +181,10 @@ void ensureCAPIExceptionSet(); ...@@ -181,6 +181,10 @@ void ensureCAPIExceptionSet();
struct ExcInfo; struct ExcInfo;
void setCAPIException(const ExcInfo& e); void setCAPIException(const ExcInfo& e);
// Finalizer-related
void default_free(void*);
void dealloc_null(Box* box);
// In Pyston, this is the same type as CPython's PyTypeObject (they are interchangeable, but we // In Pyston, this is the same type as CPython's PyTypeObject (they are interchangeable, but we
// use BoxedClass in Pyston wherever possible as a convention). // use BoxedClass in Pyston wherever possible as a convention).
class BoxedClass : public BoxVar { class BoxedClass : public BoxVar {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment