Commit 97842832 authored by Marius Wachtler's avatar Marius Wachtler

fix OSR

this let's minibenchmark/raytrace.py run with enabled interpreter + OSR (but disabled bjit)
parent c8cd334a
...@@ -564,6 +564,7 @@ Value ASTInterpreter::getNone() { ...@@ -564,6 +564,7 @@ Value ASTInterpreter::getNone() {
Value ASTInterpreter::visit_unaryop(AST_UnaryOp* node) { Value ASTInterpreter::visit_unaryop(AST_UnaryOp* node) {
Value operand = visit_expr(node->operand); Value operand = visit_expr(node->operand);
AUTO_DECREF(operand.o);
if (node->op_type == AST_TYPE::Not) if (node->op_type == AST_TYPE::Not)
return Value(boxBool(!nonzero(operand.o)), jit ? jit->emitNotNonzero(operand) : NULL); return Value(boxBool(!nonzero(operand.o)), jit ? jit->emitNotNonzero(operand) : NULL);
else else
...@@ -726,7 +727,8 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) { ...@@ -726,7 +727,8 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) {
} }
for (auto&& dead : dead_symbols) { for (auto&& dead : dead_symbols) {
assert(getSymVRegMap().count(dead)); assert(getSymVRegMap().count(dead));
vregs[getSymVRegMap()[dead]] = NULL; int vreg_num = getSymVRegMap()[dead];
Py_CLEAR(vregs[vreg_num]);
} }
const OSREntryDescriptor* found_entry = nullptr; const OSREntryDescriptor* found_entry = nullptr;
...@@ -750,12 +752,13 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) { ...@@ -750,12 +752,13 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) {
if (phis->isPotentiallyUndefinedAfter(name, current_block)) { if (phis->isPotentiallyUndefinedAfter(name, current_block)) {
bool is_defined = val != NULL; bool is_defined = val != NULL;
assert(is_defined && "check refcounting");
// TODO only mangle once // TODO only mangle once
sorted_symbol_table[getIsDefinedName(name, source_info->getInternedStrings())] = (Box*)is_defined; sorted_symbol_table[getIsDefinedName(name, source_info->getInternedStrings())] = (Box*)is_defined;
sorted_symbol_table[name] = is_defined ? val : VAL_UNDEFINED; sorted_symbol_table[name] = is_defined ? incref(val) : VAL_UNDEFINED;
} else { } else {
ASSERT(val != NULL, "%s", name.c_str()); ASSERT(val != NULL, "%s", name.c_str());
Box* v = sorted_symbol_table[name] = val; sorted_symbol_table[name] = incref(val);
} }
} }
......
...@@ -459,7 +459,9 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc ...@@ -459,7 +459,9 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if (p.second == phi_type) { if (p.second == phi_type) {
// good to go // good to go
v = from_arg; v = from_arg;
irstate->getRefcounts()->setType(v, RefType::BORROWED);
} else if (p.second->canConvertTo(phi_type)) { } else if (p.second->canConvertTo(phi_type)) {
assert(0 && "check refcounting");
// not sure if/when this happens, but if there's a type mismatch but one we know // not sure if/when this happens, but if there's a type mismatch but one we know
// can be handled (such as casting from a subclass to a superclass), handle it: // can be handled (such as casting from a subclass to a superclass), handle it:
ConcreteCompilerVariable* converted = var->makeConverted(*unbox_emitter, phi_type); ConcreteCompilerVariable* converted = var->makeConverted(*unbox_emitter, phi_type);
...@@ -601,7 +603,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc ...@@ -601,7 +603,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// TODO might be more efficient to do post-call safepoints? // TODO might be more efficient to do post-call safepoints?
generator->doSafePoint(block->body[0]); generator->doSafePoint(block->body[0]);
} else if (entry_descriptor && block == entry_descriptor->backedge->target) { } else if (entry_descriptor && block == entry_descriptor->backedge->target) {
assert(0 && "check refcounting");
assert(block->predecessors.size() > 1); assert(block->predecessors.size() > 1);
assert(osr_entry_block); assert(osr_entry_block);
assert(phis); assert(phis);
...@@ -619,11 +620,9 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc ...@@ -619,11 +620,9 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// printf("For %s, given %s, analyzed for %s\n", p.first.c_str(), p.second->debugName().c_str(), // printf("For %s, given %s, analyzed for %s\n", p.first.c_str(), p.second->debugName().c_str(),
// analyzed_type->debugName().c_str()); // analyzed_type->debugName().c_str());
assert(0 && "check refcounting");
llvm::PHINode* phi = emitter->getBuilder()->CreatePHI(analyzed_type->llvmType(), llvm::PHINode* phi = emitter->getBuilder()->CreatePHI(analyzed_type->llvmType(),
block->predecessors.size() + 1, p.first.s()); block->predecessors.size() + 1, p.first.s());
if (analyzed_type->getBoxType() == analyzed_type) { if (analyzed_type->getBoxType() == analyzed_type) {
assert(0 && "check refcounting");
irstate->getRefcounts()->setType(phi, RefType::OWNED); irstate->getRefcounts()->setType(phi, RefType::OWNED);
} }
ConcreteCompilerVariable* var = new ConcreteCompilerVariable(analyzed_type, phi); ConcreteCompilerVariable* var = new ConcreteCompilerVariable(analyzed_type, phi);
...@@ -877,7 +876,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc ...@@ -877,7 +876,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
} }
if (this_is_osr_entry) { if (this_is_osr_entry) {
assert(0 && "check refcounting");
ConcreteCompilerVariable* v = (*osr_syms)[it->first]; ConcreteCompilerVariable* v = (*osr_syms)[it->first];
assert(v); assert(v);
......
...@@ -225,13 +225,12 @@ void IRGenState::setupFrameInfoVar(llvm::Value* passed_closure, llvm::Value* pas ...@@ -225,13 +225,12 @@ void IRGenState::setupFrameInfoVar(llvm::Value* passed_closure, llvm::Value* pas
assert(!passed_globals); assert(!passed_globals);
// The OSR case // The OSR case
assert(0 && "check refcounting");
this->frame_info = frame_info_arg; this->frame_info = frame_info_arg;
// use vrags array from the interpreter // use vrags array from the interpreter
vregs = builder.CreateLoad(getVRegsGep(builder, frame_info_arg)); vregs = builder.CreateLoad(getVRegsGep(builder, frame_info_arg));
this->globals = builder.CreateLoad(getGlobalsGep(builder, frame_info_arg)); this->globals = builder.CreateLoad(getGlobalsGep(builder, frame_info_arg));
getRefcounts()->setType(this->globals, RefType::BORROWED);
if (getScopeInfo()->usesNameLookup()) { if (getScopeInfo()->usesNameLookup()) {
// load frame_info.boxedLocals // load frame_info.boxedLocals
......
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