Commit 5e84e304 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #588 from undingen/fix_stats

Fix compile error when enabling memstats + call tp_richcompare even if rewrite_args == NULL
parents 05fb51ad 217bcb06
...@@ -92,8 +92,8 @@ struct Stats { ...@@ -92,8 +92,8 @@ struct Stats {
static void setEnabled(bool enabled) {} static void setEnabled(bool enabled) {}
static void dump(bool includeZeros = true) { printf("(Stats disabled)\n"); } static void dump(bool includeZeros = true) { printf("(Stats disabled)\n"); }
static void clear() {} static void clear() {}
static void log(int id, int count = 1) {} static void log(uint64_t* counter, int count = 1) {}
static int getStatId(const std::string& name) { return 0; } static uint64_t* getStatCounter(const std::string& name) { return nullptr; }
static void endOfInit() {} static void endOfInit() {}
}; };
struct StatCounter { struct StatCounter {
...@@ -200,8 +200,7 @@ public: ...@@ -200,8 +200,7 @@ public:
}; };
#else #else
struct StatTimer { struct StatTimer {
StatTimer(int statid) {} StatTimer(uint64_t*) {}
StatTimer(int statid, uint64_t at_time) {}
~StatTimer() {} ~StatTimer() {}
bool isPaused() const { return false; } bool isPaused() const { return false; }
......
...@@ -524,8 +524,8 @@ extern "C" PyObject* PystonType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems) ...@@ -524,8 +524,8 @@ extern "C" PyObject* PystonType_GenericAlloc(BoxedClass* cls, Py_ssize_t nitems)
if (cls->tp_name) { \ if (cls->tp_name) { \
std::string per_name_alloc_name = "alloc." + std::string(cls->tp_name); \ std::string per_name_alloc_name = "alloc." + std::string(cls->tp_name); \
std::string per_name_allocsize_name = "allocsize." + std::string(cls->tp_name); \ std::string per_name_allocsize_name = "allocsize." + std::string(cls->tp_name); \
Stats::log(Stats::getStatId(per_name_alloc_name)); \ Stats::log(Stats::getStatCounter(per_name_alloc_name)); \
Stats::log(Stats::getStatId(per_name_allocsize_name), size); \ Stats::log(Stats::getStatCounter(per_name_allocsize_name), size); \
} }
#define ALLOC_STATS_VAR(cls) \ #define ALLOC_STATS_VAR(cls) \
if (cls->tp_name) { \ if (cls->tp_name) { \
......
...@@ -205,10 +205,7 @@ Box* dictGetitem(BoxedDict* self, Box* k) { ...@@ -205,10 +205,7 @@ Box* dictGetitem(BoxedDict* self, Box* k) {
raiseExcHelper(KeyError, k); raiseExcHelper(KeyError, k);
} }
return it->second;
Box* pos = self->d[k];
return pos;
} }
extern "C" PyObject* PyDict_New() noexcept { extern "C" PyObject* PyDict_New() noexcept {
......
...@@ -3711,7 +3711,8 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -3711,7 +3711,8 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
return boxBool(b); return boxBool(b);
} }
if (isUserDefined(lhs->cls) || isUserDefined(rhs->cls)) { bool any_user_defined = isUserDefined(lhs->cls) || isUserDefined(rhs->cls);
if (any_user_defined) {
rewrite_args = NULL; rewrite_args = NULL;
REWRITE_ABORTED(""); REWRITE_ABORTED("");
} }
...@@ -3753,7 +3754,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -3753,7 +3754,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
RELEASE_ASSERT(0, "%d", op_type); RELEASE_ASSERT(0, "%d", op_type);
} }
if (rewrite_args && lhs->cls == rhs->cls && !PyInstance_Check(lhs) && lhs->cls->tp_richcompare != NULL if (!any_user_defined && lhs->cls == rhs->cls && !PyInstance_Check(lhs) && lhs->cls->tp_richcompare != NULL
&& lhs->cls->tp_richcompare != slot_tp_richcompare) { && lhs->cls->tp_richcompare != slot_tp_richcompare) {
// This branch is the `v->ob_type == w->ob_type` branch of PyObject_RichCompare, but // This branch is the `v->ob_type == w->ob_type` branch of PyObject_RichCompare, but
// simplified by using the assumption that tp_richcompare exists and never returns NotImplemented // simplified by using the assumption that tp_richcompare exists and never returns NotImplemented
...@@ -3763,10 +3764,12 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -3763,10 +3764,12 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
Box* r = lhs->cls->tp_richcompare(lhs, rhs, cpython_op_type); Box* r = lhs->cls->tp_richcompare(lhs, rhs, cpython_op_type);
RELEASE_ASSERT(r != NotImplemented, "%s returned notimplemented?", lhs->cls->tp_name); RELEASE_ASSERT(r != NotImplemented, "%s returned notimplemented?", lhs->cls->tp_name);
rewrite_args->out_rtn if (rewrite_args) {
= rewrite_args->rewriter->call(true, (void*)lhs->cls->tp_richcompare, rewrite_args->lhs, rewrite_args->rhs, rewrite_args->out_rtn
rewrite_args->rewriter->loadConst(cpython_op_type)); = rewrite_args->rewriter->call(true, (void*)lhs->cls->tp_richcompare, rewrite_args->lhs,
rewrite_args->out_success = true; rewrite_args->rhs, rewrite_args->rewriter->loadConst(cpython_op_type));
rewrite_args->out_success = true;
}
return r; return r;
} }
......
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