Commit da2a9964 authored by Kevin Modzelewski's avatar Kevin Modzelewski

enough refcounting to test the bjit for real

parent 247869a5
......@@ -871,6 +871,9 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
assert(node->args.size() == 1);
Value val = visit_expr(node->args[0]);
v = Value(getPystonIter(val.o), jit ? jit->emitGetPystonIter(val) : NULL);
Py_DECREF(val.o);
if (jit)
val.var->decref();
} else if (node->opcode == AST_LangPrimitive::IMPORT_FROM) {
assert(node->args.size() == 2);
assert(node->args[0]->type == AST_TYPE::Name);
......@@ -956,6 +959,9 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
assert(node->args.size() == 1);
Value obj = visit_expr(node->args[0]);
v = Value(boxBool(hasnext(obj.o)), jit ? jit->emitHasnext(obj) : NULL);
Py_DECREF(obj.o);
if (jit)
obj.var->decref();
} else if (node->opcode == AST_LangPrimitive::PRINT_EXPR) {
abortJITing();
Value obj = visit_expr(node->args[0]);
......
......@@ -342,9 +342,9 @@ void compileAndRunModule(AST_Module* m, BoxedModule* bm) {
Py_DECREF(r);
// XXX for bjit testing
r = astInterpretFunction(md, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
assert(r == None);
Py_DECREF(r);
//r = astInterpretFunction(md, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
//assert(r == None);
//Py_DECREF(r);
}
Box* evalOrExec(FunctionMetadata* md, Box* globals, Box* boxedLocals) {
......
......@@ -46,8 +46,8 @@ bool ENABLE_TRACEBACKS = true;
bool FORCE_LLVM_CAPI_CALLS = false;
bool FORCE_LLVM_CAPI_THROWS = false;
int OSR_THRESHOLD_INTERPRETER = 1;
int REOPT_THRESHOLD_INTERPRETER = 1;
int OSR_THRESHOLD_INTERPRETER = 25; // XXX
int REOPT_THRESHOLD_INTERPRETER = 2; // XXX
int OSR_THRESHOLD_BASELINE = 2500;
int REOPT_THRESHOLD_BASELINE = 1500;
int OSR_THRESHOLD_T2 = 10000;
......
......@@ -34,8 +34,8 @@ extern "C" Box* boolRepr(BoxedBool* v) {
static BoxedString* false_str = getStaticString("False");
if (v == True)
return true_str;
return false_str;
return incref(true_str);
return incref(false_str);
}
size_t bool_hash(BoxedBool* v) {
......@@ -59,7 +59,7 @@ extern "C" Box* boolAnd(BoxedBool* lhs, BoxedBool* rhs) {
getTypeName(lhs));
if (rhs->cls != bool_cls)
return NotImplemented;
return incref(NotImplemented);
return boxBool(lhs->n && rhs->n);
}
......@@ -69,7 +69,7 @@ extern "C" Box* boolOr(BoxedBool* lhs, BoxedBool* rhs) {
raiseExcHelper(TypeError, "descriptor '__or__' requires a 'bool' object but received a '%s'", getTypeName(lhs));
if (rhs->cls != bool_cls)
return NotImplemented;
return incref(NotImplemented);
return boxBool(lhs->n || rhs->n);
}
......@@ -80,7 +80,7 @@ extern "C" Box* boolXor(BoxedBool* lhs, BoxedBool* rhs) {
getTypeName(lhs));
if (rhs->cls != bool_cls)
return NotImplemented;
return incref(NotImplemented);
return boxBool(lhs->n ^ rhs->n);
}
......
......@@ -20,6 +20,7 @@
namespace pyston {
BoxedTupleIterator::BoxedTupleIterator(BoxedTuple* t) : t(t), pos(0) {
Py_INCREF(t);
}
Box* tupleIterIter(Box* s) {
......@@ -53,6 +54,7 @@ Box* tupleiter_next(Box* s) noexcept {
Box* rtn = self->t->elts[self->pos];
self->pos++;
Py_INCREF(rtn);
return rtn;
}
......
......@@ -240,6 +240,7 @@ Box* tupleRepr(BoxedTuple* t) {
}
BoxedString* elt_repr = static_cast<BoxedString*>(repr(t->elts[i]));
chars.insert(chars.end(), elt_repr->s().begin(), elt_repr->s().end());
Py_DECREF(elt_repr);
}
if (n == 1)
......
......@@ -2626,7 +2626,7 @@ static PyObject* object_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
static Box* typeName(Box* b, void*);
Box* objectRepr(Box* self) {
BoxedClass* type = self->cls;
Box* mod = NULL;
DecrefHandle<Box, true> mod(NULL);
try {
mod = typeModule(type, NULL);
if (!PyString_Check(mod))
......@@ -2634,7 +2634,7 @@ Box* objectRepr(Box* self) {
} catch (ExcInfo) {
}
Box* name = typeName(type, NULL);
DecrefHandle<Box> name(typeName(type, NULL));
if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__"))
return PyString_FromFormat("<%s.%s object at %p>", PyString_AS_STRING(mod), PyString_AS_STRING(name), self);
return PyString_FromFormat("<%s object at %p>", type->tp_name, self);
......@@ -3023,7 +3023,7 @@ static Box* typeName(Box* b, void*) {
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
BoxedHeapClass* et = static_cast<BoxedHeapClass*>(type);
return et->ht_name;
return incref(et->ht_name);
} else {
const char* s = strrchr(type->tp_name, '.');
if (s == NULL)
......
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