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