Commit 59c8721b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Renable ICs and the int freelist

parent c2e7665b
......@@ -1511,6 +1511,7 @@ bool Rewriter::finishAssembly(int continue_offset) {
void Rewriter::commitReturning(RewriterVar* var) {
STAT_TIMER(t0, "us_timer_rewriter", 10);
assert(var->reftype != RefType::UNKNOWN);
assert(var->vrefcount == 1);
var->stealRef();
......@@ -1525,6 +1526,20 @@ void Rewriter::commitReturning(RewriterVar* var) {
commit();
}
void Rewriter::commitReturningNonPython(RewriterVar* var) {
STAT_TIMER(t0, "us_timer_rewriter", 10);
assert(var->reftype == RefType::UNKNOWN);
addAction([=]() {
if (LOG_IC_ASSEMBLY) assembler->comment("commitReturning");
var->getInReg(getReturnDestination(), true /* allow_constant_in_reg */);
var->bumpUse();
}, { var }, ActionType::NORMAL);
commit();
}
void Rewriter::addDependenceOn(ICInvalidator& invalidator) {
rewrite->addDependenceOn(invalidator);
}
......
......@@ -722,6 +722,7 @@ public:
void abort();
void commit();
void commitReturning(RewriterVar* rtn);
void commitReturningNonPython(RewriterVar* rtn);
void addDependenceOn(ICInvalidator&);
......
......@@ -59,7 +59,7 @@ int SPECULATION_THRESHOLD = 100;
int MAX_OBJECT_CACHE_ENTRIES = 500;
static bool _GLOBAL_ENABLE = 1;
bool ENABLE_ICS = 0 && _GLOBAL_ENABLE;
bool ENABLE_ICS = 1 && _GLOBAL_ENABLE;
bool ENABLE_ICGENERICS = 1 && ENABLE_ICS;
bool ENABLE_ICGETITEMS = 1 && ENABLE_ICS;
bool ENABLE_ICSETITEMS = 1 && ENABLE_ICS;
......
......@@ -88,15 +88,21 @@ PyIntObject* BoxedInt::fill_free_list(void) {
}
void BoxedInt::tp_dealloc(Box* v) {
//if (PyInt_CheckExact(v)) {
//BoxedInt::tp_free(v);
//} else {
#ifdef DISABLE_INT_FREELIST
v->cls->tp_free(v);
#else
if (PyInt_CheckExact(v)) {
BoxedInt::tp_free(v);
} else {
v->cls->tp_free(v);
//}
}
#endif
}
void BoxedInt::tp_free(void* b) {
#ifdef DISABLE_INT_FREELIST
assert(0);
#endif
PyIntObject* v = static_cast<PyIntObject*>(b);
v->ob_type = (struct _typeobject *)free_list;
free_list = v;
......
......@@ -2709,7 +2709,7 @@ extern "C" bool nonzero(Box* obj) {
// TODO: is it faster to compare to True? (especially since it will be a constant we can embed in the rewrite)
if (rewriter.get()) {
RewriterVar* b = r_obj->getAttr(offsetof(BoxedBool, n), rewriter->getReturnDestination());
rewriter->commitReturning(b);
rewriter->commitReturningNonPython(b);
}
BoxedBool* bool_obj = static_cast<BoxedBool*>(obj);
......@@ -2718,7 +2718,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* n = r_obj->getAttr(offsetof(BoxedInt, n), rewriter->getReturnDestination());
RewriterVar* b = n->toBool(rewriter->getReturnDestination());
rewriter->commitReturning(b);
rewriter->commitReturningNonPython(b);
}
BoxedInt* int_obj = static_cast<BoxedInt*>(obj);
......@@ -2726,13 +2726,13 @@ extern "C" bool nonzero(Box* obj) {
} else if (obj->cls == float_cls) {
if (rewriter.get()) {
RewriterVar* b = rewriter->call(false, (void*)floatNonzeroUnboxed, r_obj);
rewriter->commitReturning(b);
rewriter->commitReturningNonPython(b);
}
return static_cast<BoxedFloat*>(obj)->d != 0;
} else if (obj->cls == none_cls) {
if (rewriter.get()) {
RewriterVar* b = rewriter->loadConst(0, rewriter->getReturnDestination());
rewriter->commitReturning(b);
rewriter->commitReturningNonPython(b);
}
return false;
} else if (obj->cls == long_cls) {
......@@ -2741,7 +2741,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* r_rtn = rewriter->call(false, (void*)longNonzeroUnboxed, r_obj);
rewriter->commitReturning(r_rtn);
rewriter->commitReturningNonPython(r_rtn);
}
return r;
} else if (obj->cls == tuple_cls) {
......@@ -2751,7 +2751,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* r_rtn
= r_obj->getAttr(offsetof(BoxedTuple, ob_size))->toBool(rewriter->getReturnDestination());
rewriter->commitReturning(r_rtn);
rewriter->commitReturningNonPython(r_rtn);
}
return r;
} else if (obj->cls == list_cls) {
......@@ -2760,7 +2760,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* r_rtn = r_obj->getAttr(offsetof(BoxedList, size))->toBool(rewriter->getReturnDestination());
rewriter->commitReturning(r_rtn);
rewriter->commitReturningNonPython(r_rtn);
}
return r;
} else if (obj->cls == str_cls) {
......@@ -2770,7 +2770,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* r_rtn
= r_obj->getAttr(offsetof(BoxedString, ob_size))->toBool(rewriter->getReturnDestination());
rewriter->commitReturning(r_rtn);
rewriter->commitReturningNonPython(r_rtn);
}
return r;
} else if (obj->cls == unicode_cls) {
......@@ -2780,7 +2780,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* r_rtn
= r_obj->getAttr(offsetof(PyUnicodeObject, length))->toBool(rewriter->getReturnDestination());
rewriter->commitReturning(r_rtn);
rewriter->commitReturningNonPython(r_rtn);
}
return r;
}
......@@ -2823,7 +2823,7 @@ extern "C" bool nonzero(Box* obj) {
if (rewriter.get()) {
RewriterVar* b = rewriter->loadConst(1, rewriter->getReturnDestination());
rewriter->commitReturning(b);
rewriter->commitReturningNonPython(b);
}
return true;
}
......@@ -2832,7 +2832,7 @@ extern "C" bool nonzero(Box* obj) {
if (crewrite_args.isSuccessful()) {
RewriterVar* rtn = crewrite_args.getReturn(ReturnConvention::HAS_RETURN);
RewriterVar* b = rewriter->call(false, (void*)nonzeroHelper, rtn);
rewriter->commitReturning(b);
rewriter->commitReturningNonPython(b);
}
return nonzeroHelper(rtn);
}
......
......@@ -403,6 +403,8 @@ template <typename B> B* xincref(B* b) {
return b;
}
//#define DISABLE_INT_FREELIST
extern "C" int PyInt_ClearFreeList() noexcept;
class BoxedInt : public Box {
private:
......@@ -419,8 +421,9 @@ public:
}
// int uses a customized allocator, so we can't use DEFAULT_CLASS_SIMPLE (which inlines the default allocator)
void* operator new(size_t size) __attribute__((visibility("default"))) {
#ifdef DISABLE_INT_FREELIST
return Box::operator new (size, int_cls);
/*
#else
if (free_list == NULL) {
free_list = fill_free_list();
RELEASE_ASSERT(free_list, "");
......@@ -430,7 +433,7 @@ public:
free_list = (PyIntObject*)v->ob_type;
PyObject_INIT((BoxedInt*)v, &PyInt_Type);
return v;
*/
#endif
}
static void tp_dealloc(Box* b);
......
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