Commit f1e8700d authored by Kevin Modzelewski's avatar Kevin Modzelewski

Found some issues

parent 7f70ab5c
......@@ -385,6 +385,9 @@ class BoxedString;
class Box {
public:
// Add a no-op constructor to make sure that we don't zero-initialize cls
Box() {}
void* operator new(size_t size, BoxedClass* cls) __attribute__((visibility("default")));
void operator delete(void* ptr) __attribute__((visibility("default"))) { abort(); }
......
......@@ -63,17 +63,6 @@ int Py_Py3kWarningFlag;
BoxedClass* capifunc_cls;
extern "C" PyObject* PyType_GenericAlloc(PyTypeObject* cls, Py_ssize_t nitems) noexcept {
RELEASE_ASSERT(nitems == 0, "unimplemented");
RELEASE_ASSERT(cls->tp_itemsize == 0, "unimplemented");
auto rtn = (PyObject*)gc_alloc(cls->tp_basicsize, gc::GCKind::PYTHON);
memset(rtn, 0, cls->tp_basicsize);
PyObject_Init(rtn, cls);
return rtn;
}
BoxedClass* wrapperdescr_cls, *wrapperobject_cls;
Box* BoxedWrapperDescriptor::__get__(BoxedWrapperDescriptor* self, Box* inst, Box* owner) {
......
......@@ -57,9 +57,7 @@ bool IN_SHUTDOWN = false;
#define SLICE_STOP_OFFSET ((char*)&(((BoxedSlice*)0x01)->stop) - (char*)0x1)
#define SLICE_STEP_OFFSET ((char*)&(((BoxedSlice*)0x01)->step) - (char*)0x1)
PyObject* PyType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems) noexcept {
abort(); // untested
extern "C" PyObject* PyType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems) noexcept {
assert(cls);
RELEASE_ASSERT(nitems == 0, "");
RELEASE_ASSERT(cls->tp_itemsize == 0, "");
......@@ -75,6 +73,7 @@ PyObject* PyType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems) noexcept {
Box* rtn = static_cast<Box*>(mem);
PyObject_Init(rtn, cls);
assert(rtn->cls);
return rtn;
}
......@@ -898,6 +897,7 @@ void setupRuntime() {
none_cls = new BoxedHeapClass(object_cls, NULL, 0, sizeof(Box), false);
None = new (none_cls) Box();
assert(None->cls);
gc::registerPermanentRoot(None);
// You can't actually have an instance of basestring
......
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