Commit 92c78799 authored by Kevin Modzelewski's avatar Kevin Modzelewski

fix the build issues

parent e78dc8d7
...@@ -8,8 +8,8 @@ extern "C" { ...@@ -8,8 +8,8 @@ extern "C" {
// Pyston addition: refcounting annotations: // Pyston addition: refcounting annotations:
#define BORROWED(T) T #define BORROWED(...) __VA_ARGS__
#define STOLEN(T) T #define STOLEN(...) __VA_ARGS__
#define NOREFCHECK ; #define NOREFCHECK ;
/* Object and type object interface */ /* Object and type object interface */
......
...@@ -469,6 +469,21 @@ int BoxedMethodDescriptor::traverse(Box* _self, visitproc visit, void *arg) noex ...@@ -469,6 +469,21 @@ int BoxedMethodDescriptor::traverse(Box* _self, visitproc visit, void *arg) noex
return 0; return 0;
} }
void BoxedWrapperDescriptor::dealloc(Box* _self) noexcept {
BoxedWrapperDescriptor* self = static_cast<BoxedWrapperDescriptor*>(_self);
PyObject_GC_UnTrack(self);
Py_XDECREF(self->type);
self->cls->tp_free(self);
}
int BoxedWrapperDescriptor::traverse(Box* _self, visitproc visit, void *arg) noexcept {
BoxedWrapperDescriptor* self = static_cast<BoxedWrapperDescriptor*>(_self);
Py_VISIT(self->type);
return 0;
}
void BoxedWrapperObject::dealloc(Box* _self) noexcept { void BoxedWrapperObject::dealloc(Box* _self) noexcept {
BoxedWrapperObject* self = static_cast<BoxedWrapperObject*>(_self); BoxedWrapperObject* self = static_cast<BoxedWrapperObject*>(_self);
......
...@@ -457,14 +457,16 @@ static int dict_ass_sub(PyDictObject* mp, PyObject* v, PyObject* w) noexcept { ...@@ -457,14 +457,16 @@ static int dict_ass_sub(PyDictObject* mp, PyObject* v, PyObject* w) noexcept {
extern "C" int PyDict_DelItem(PyObject* op, PyObject* key) noexcept { extern "C" int PyDict_DelItem(PyObject* op, PyObject* key) noexcept {
if (PyDict_Check(op)) { if (PyDict_Check(op)) {
BoxedDict* self = static_cast<BoxedDict*>(op);
assert(0 && "untested"); assert(0 && "untested");
decltype(self->d)::iterator it;
try { try {
auto it = self->d.find(k); it = self->d.find(key);
} catch (ExcInfo e) { } catch (ExcInfo e) {
setCAPIException(e); setCAPIException(e);
return -1; return -1;
} }
if (it == self->d.end()) if (it == self->d.end()) {
PyErr_SetObject(KeyError, autoDecref(BoxedTuple::create1(key))); PyErr_SetObject(KeyError, autoDecref(BoxedTuple::create1(key)));
return -1; return -1;
} }
......
...@@ -302,6 +302,11 @@ void caughtCxxException(ExcInfo* exc_info) { ...@@ -302,6 +302,11 @@ void caughtCxxException(ExcInfo* exc_info) {
struct ExcState {
bool is_reraise;
constexpr ExcState() : is_reraise(false) {}
} static __thread exc_state;
bool exceptionAtLineCheck() { bool exceptionAtLineCheck() {
if (exc_state.is_reraise) { if (exc_state.is_reraise) {
exc_state.is_reraise = false; exc_state.is_reraise = false;
......
...@@ -143,7 +143,7 @@ extern "C" Box* deopt(AST_expr* expr, Box* value) { ...@@ -143,7 +143,7 @@ extern "C" Box* deopt(AST_expr* expr, Box* value) {
} }
extern "C" void printHelper(Box* w, Box* v, bool nl) { extern "C" void printHelper(Box* w, Box* v, bool nl) {
assert(0 && "is this tested?");` assert(0 && "is this tested?");
// copied from cpythons PRINT_ITEM and PRINT_NEWLINE op handling code // copied from cpythons PRINT_ITEM and PRINT_NEWLINE op handling code
if (w == NULL || w == None) { if (w == NULL || w == None) {
w = PySys_GetObject("stdout"); w = PySys_GetObject("stdout");
...@@ -2878,7 +2878,7 @@ extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) { ...@@ -2878,7 +2878,7 @@ extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
return; return;
} }
AUTO_DECREF(val); AUTO_DECREF(attr_val);
if (rewriter.get()) { if (rewriter.get()) {
assert(setattr); assert(setattr);
...@@ -5312,8 +5312,9 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -5312,8 +5312,9 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
bool negate = (op_type == AST_TYPE::NotIn); bool negate = (op_type == AST_TYPE::NotIn);
if (rewrite_args) { if (rewrite_args) {
RewriterVar* r_contained_box = rewrite_args->rewriter->call(true, (void*)nonzeroAndBox<negate>, r_contained, RewriterVar* r_contained_box
r_negate)->setType(RefType::OWNED); = rewrite_args->rewriter->call(true, (void*)(negate ? nonzeroAndBox<true> : nonzeroAndBox<false>),
r_contained)->setType(RefType::OWNED);
rewrite_args->out_rtn = r_contained_box; rewrite_args->out_rtn = r_contained_box;
rewrite_args->out_success = true; rewrite_args->out_success = true;
} }
...@@ -5430,7 +5431,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -5430,7 +5431,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
} }
return lrtn; return lrtn;
} else { } else {
Py_DECREF(ltn); Py_DECREF(lrtn);
rewrite_args = NULL; rewrite_args = NULL;
} }
} }
...@@ -6921,8 +6922,8 @@ extern "C" void boxedLocalsDel(Box* boxedLocals, BoxedString* attr) { ...@@ -6921,8 +6922,8 @@ extern "C" void boxedLocalsDel(Box* boxedLocals, BoxedString* attr) {
assert(attr->data()[attr->size()] == '\0'); assert(attr->data()[attr->size()] == '\0');
assertNameDefined(0, attr->data(), NameError, false /* local_var_msg */); assertNameDefined(0, attr->data(), NameError, false /* local_var_msg */);
} }
Box* key = it.first.value; Box* key = it->first.value;
Box* value = it.second; Box* value = it->second;
d.erase(it); d.erase(it);
Py_DECREF(key); Py_DECREF(key);
Py_DECREF(value); Py_DECREF(value);
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
static void dealloc(BoxedSetIterator* o) noexcept { static void dealloc(BoxedSetIterator* o) noexcept {
PyObject_GC_UnTrack(o); PyObject_GC_UnTrack(o);
PyObject_ClearWeakRefs((PyObject*)self); PyObject_ClearWeakRefs((PyObject*)o);
Py_DECREF(o->s); Py_DECREF(o->s);
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "runtime/dict.h" #include "runtime/dict.h"
#include "runtime/hiddenclass.h" #include "runtime/hiddenclass.h"
#include "runtime/ics.h" #include "runtime/ics.h"
#include "runtime/inline/list.h"
#include "runtime/iterobject.h" #include "runtime/iterobject.h"
#include "runtime/list.h" #include "runtime/list.h"
#include "runtime/long.h" #include "runtime/long.h"
...@@ -2398,7 +2399,7 @@ public: ...@@ -2398,7 +2399,7 @@ public:
HCAttrs* attrs = self->b->getHCAttrsPtr(); HCAttrs* attrs = self->b->getHCAttrsPtr();
RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, ""); RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, "");
for (const auto& p : attrs->hcls->getStrAttrOffsets()) { for (const auto& p : attrs->hcls->getStrAttrOffsets()) {
listAppend(rtn, p.first); listAppendInternal(rtn, p.first);
} }
return rtn; return rtn;
} }
...@@ -2412,7 +2413,7 @@ public: ...@@ -2412,7 +2413,7 @@ public:
HCAttrs* attrs = self->b->getHCAttrsPtr(); HCAttrs* attrs = self->b->getHCAttrsPtr();
RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, ""); RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, "");
for (const auto& p : attrs->hcls->getStrAttrOffsets()) { for (const auto& p : attrs->hcls->getStrAttrOffsets()) {
listAppend(rtn, attrs->attr_list->attrs[p.second]); listAppendInternal(rtn, attrs->attr_list->attrs[p.second]);
} }
return rtn; return rtn;
} }
...@@ -2427,7 +2428,7 @@ public: ...@@ -2427,7 +2428,7 @@ public:
RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, ""); RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, "");
for (const auto& p : attrs->hcls->getStrAttrOffsets()) { for (const auto& p : attrs->hcls->getStrAttrOffsets()) {
BoxedTuple* t = BoxedTuple::create({ p.first, attrs->attr_list->attrs[p.second] }); BoxedTuple* t = BoxedTuple::create({ p.first, attrs->attr_list->attrs[p.second] });
listAppendStolen(rtn, t); listAppendInternalStolen(rtn, t);
} }
return rtn; return rtn;
} }
...@@ -2469,7 +2470,6 @@ public: ...@@ -2469,7 +2470,6 @@ public:
HCAttrs* attrs = self->b->getHCAttrsPtr(); HCAttrs* attrs = self->b->getHCAttrsPtr();
RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, ""); RELEASE_ASSERT(attrs->hcls->type == HiddenClass::NORMAL || attrs->hcls->type == HiddenClass::SINGLETON, "");
attrs->clear(); attrs->clear();
AOEU
// Add the existing attrwrapper object (ie self) back as the attrwrapper: // Add the existing attrwrapper object (ie self) back as the attrwrapper:
self->b->appendNewHCAttr(self, NULL); self->b->appendNewHCAttr(self, NULL);
...@@ -3529,7 +3529,7 @@ void BoxedModule::dealloc(Box* b) noexcept { ...@@ -3529,7 +3529,7 @@ void BoxedModule::dealloc(Box* b) noexcept {
int BoxedModule::traverse(Box* _m, visitproc visit, void* arg) noexcept { int BoxedModule::traverse(Box* _m, visitproc visit, void* arg) noexcept {
BoxedModule* m = static_cast<BoxedModule*>(_m); BoxedModule* m = static_cast<BoxedModule*>(_m);
Py_VISIT_HCATTRS(m->attrs); Py_VISIT_HCATTRS(m->attrs);
assert(!self->keep_alive.size()); assert(!m->keep_alive.size());
return 0; return 0;
} }
...@@ -3964,8 +3964,9 @@ void setupRuntime() { ...@@ -3964,8 +3964,9 @@ void setupRuntime() {
wrapperobject_cls = new (0) wrapperobject_cls = new (0)
BoxedClass(object_cls, 0, 0, sizeof(BoxedWrapperObject), false, "method-wrapper", false, BoxedClass(object_cls, 0, 0, sizeof(BoxedWrapperObject), false, "method-wrapper", false,
BoxedWrapperObject::dealloc, NULL, true, BoxedWrapperObject::traverse, NOCLEAR); BoxedWrapperObject::dealloc, NULL, true, BoxedWrapperObject::traverse, NOCLEAR);
wrapperdescr_cls = new (0) BoxedClass(object_cls, 0, 0, sizeof(BoxedWrapperDescriptor), false, "wrapper_descriptor", wrapperdescr_cls = new (0)
false, BoxedWrapperDescriptor::dealloc, NULL, false); BoxedClass(object_cls, 0, 0, sizeof(BoxedWrapperDescriptor), false, "wrapper_descriptor", false,
BoxedWrapperDescriptor::dealloc, NULL, true, BoxedWrapperDescriptor::traverse, NOCLEAR);
EmptyString = new (0) BoxedString(""); EmptyString = new (0) BoxedString("");
constants.push_back(EmptyString); constants.push_back(EmptyString);
......
...@@ -1200,7 +1200,8 @@ public: ...@@ -1200,7 +1200,8 @@ public:
Py_INCREF(type); Py_INCREF(type);
} }
void dealloc(Box* b) noexcept; static void dealloc(Box* b) noexcept;
static int traverse(Box* _self, visitproc visit, void *arg) noexcept;
DEFAULT_CLASS(wrapperdescr_cls); DEFAULT_CLASS(wrapperdescr_cls);
......
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