Commit 15d12dc5 authored by Stefan Behnel's avatar Stefan Behnel

merge

parents cde600a1 a0654d24
...@@ -150,8 +150,9 @@ class FunctionState(object): ...@@ -150,8 +150,9 @@ class FunctionState(object):
freelist = self.temps_free.get((type, manage_ref)) freelist = self.temps_free.get((type, manage_ref))
if freelist is None: if freelist is None:
freelist = [] freelist = []
self.temps_free[(type, manage_ref)] = freelist self.temps_free[(type, manage_ref)] = freelist
if name in freelist:
raise RuntimeError("Temp %s freed twice!" % name)
freelist.append(name) freelist.append(name)
if DebugFlags.debug_temp_code_comments: if DebugFlags.debug_temp_code_comments:
self.owner.putln("/* %s released */" % name) self.owner.putln("/* %s released */" % name)
......
This diff is collapsed.
...@@ -2444,6 +2444,7 @@ class PyClassDefNode(ClassDefNode): ...@@ -2444,6 +2444,7 @@ class PyClassDefNode(ClassDefNode):
self.body.generate_execution_code(code) self.body.generate_execution_code(code)
self.target.generate_assignment_code(self.classobj, code) self.target.generate_assignment_code(self.classobj, code)
self.dict.generate_disposal_code(code) self.dict.generate_disposal_code(code)
self.dict.free_temps(code)
class CClassDefNode(ClassDefNode): class CClassDefNode(ClassDefNode):
...@@ -2659,6 +2660,7 @@ class ExprStatNode(StatNode): ...@@ -2659,6 +2660,7 @@ class ExprStatNode(StatNode):
if not self.expr.is_temp and self.expr.result(): if not self.expr.is_temp and self.expr.result():
code.putln("%s;" % self.expr.result()) code.putln("%s;" % self.expr.result())
self.expr.generate_disposal_code(code) self.expr.generate_disposal_code(code)
self.expr.free_temps(code)
def annotate(self, code): def annotate(self, code):
self.expr.annotate(code) self.expr.annotate(code)
...@@ -2884,6 +2886,7 @@ class CascadedAssignmentNode(AssignmentNode): ...@@ -2884,6 +2886,7 @@ class CascadedAssignmentNode(AssignmentNode):
lhs.generate_assignment_code(rhs, code) lhs.generate_assignment_code(rhs, code)
# Assignment has disposed of the cloned RHS # Assignment has disposed of the cloned RHS
self.rhs.generate_disposal_code(code) self.rhs.generate_disposal_code(code)
self.rhs.free_temps(code)
def annotate(self, code): def annotate(self, code):
for i in range(len(self.lhs_list)): for i in range(len(self.lhs_list)):
...@@ -3016,7 +3019,9 @@ class InPlaceAssignmentNode(AssignmentNode): ...@@ -3016,7 +3019,9 @@ class InPlaceAssignmentNode(AssignmentNode):
code.error_goto_if_null(self.result_value.py_result(), self.pos))) code.error_goto_if_null(self.result_value.py_result(), self.pos)))
self.result_value.generate_evaluation_code(code) # May be a type check... self.result_value.generate_evaluation_code(code) # May be a type check...
self.rhs.generate_disposal_code(code) self.rhs.generate_disposal_code(code)
self.rhs.free_temps(code)
self.dup.generate_disposal_code(code) self.dup.generate_disposal_code(code)
self.dup.free_temps(code)
self.lhs.generate_assignment_code(self.result_value, code) self.lhs.generate_assignment_code(self.result_value, code)
else: else:
c_op = self.operator c_op = self.operator
...@@ -3034,8 +3039,10 @@ class InPlaceAssignmentNode(AssignmentNode): ...@@ -3034,8 +3039,10 @@ class InPlaceAssignmentNode(AssignmentNode):
self.dup.generate_result_code(code) self.dup.generate_result_code(code)
code.putln("%s %s= %s;" % (self.lhs.result(), c_op, self.rhs.result()) ) code.putln("%s %s= %s;" % (self.lhs.result(), c_op, self.rhs.result()) )
self.rhs.generate_disposal_code(code) self.rhs.generate_disposal_code(code)
self.rhs.free_temps(code)
if self.dup.is_temp: if self.dup.is_temp:
self.dup.generate_subexpr_disposal_code(code) self.dup.generate_subexpr_disposal_code(code)
self.dup.free_subexpr_temps(code)
def create_dup_node(self, env): def create_dup_node(self, env):
import ExprNodes import ExprNodes
...@@ -3065,6 +3072,8 @@ class InPlaceAssignmentNode(AssignmentNode): ...@@ -3065,6 +3072,8 @@ class InPlaceAssignmentNode(AssignmentNode):
index = index, index = index,
indices = indices, indices = indices,
is_temp = self.dup.is_temp) is_temp = self.dup.is_temp)
else:
assert False
self.lhs = target_lhs self.lhs = target_lhs
return self.dup return self.dup
...@@ -3117,6 +3126,7 @@ class PrintStatNode(StatNode): ...@@ -3117,6 +3126,7 @@ class PrintStatNode(StatNode):
self.append_newline, self.append_newline,
code.error_goto(self.pos))) code.error_goto(self.pos)))
self.arg_tuple.generate_disposal_code(code) self.arg_tuple.generate_disposal_code(code)
self.arg_tuple.free_temps(code)
def annotate(self, code): def annotate(self, code):
self.arg_tuple.annotate(code) self.arg_tuple.annotate(code)
...@@ -3152,6 +3162,7 @@ class ExecStatNode(StatNode): ...@@ -3152,6 +3162,7 @@ class ExecStatNode(StatNode):
(self.temp_result,) + args)) (self.temp_result,) + args))
for arg in self.args: for arg in self.args:
arg.generate_disposal_code(code) arg.generate_disposal_code(code)
arg.free_temps(code)
code.putln( code.putln(
code.error_goto_if_null(self.temp_result, self.pos)) code.error_goto_if_null(self.temp_result, self.pos))
code.put_decref_clear(self.temp_result, py_object_type) code.put_decref_clear(self.temp_result, py_object_type)
...@@ -3287,6 +3298,7 @@ class ReturnStatNode(StatNode): ...@@ -3287,6 +3298,7 @@ class ReturnStatNode(StatNode):
Naming.retval_cname, Naming.retval_cname,
self.value.result_as(self.return_type))) self.value.result_as(self.return_type)))
self.value.generate_post_assignment_code(code) self.value.generate_post_assignment_code(code)
self.value.free_temps(code)
else: else:
if self.return_type.is_pyobject: if self.return_type.is_pyobject:
code.put_init_to_py_none(Naming.retval_cname, self.return_type) code.put_init_to_py_none(Naming.retval_cname, self.return_type)
...@@ -3372,10 +3384,13 @@ class RaiseStatNode(StatNode): ...@@ -3372,10 +3384,13 @@ class RaiseStatNode(StatNode):
"__Pyx_ReRaise();") "__Pyx_ReRaise();")
if self.exc_type: if self.exc_type:
self.exc_type.generate_disposal_code(code) self.exc_type.generate_disposal_code(code)
self.exc_type.free_temps(code)
if self.exc_value: if self.exc_value:
self.exc_value.generate_disposal_code(code) self.exc_value.generate_disposal_code(code)
self.exc_value.free_temps(code)
if self.exc_tb: if self.exc_tb:
self.exc_tb.generate_disposal_code(code) self.exc_tb.generate_disposal_code(code)
self.exc_tb.free_temps(code)
code.putln( code.putln(
code.error_goto(self.pos)) code.error_goto(self.pos))
...@@ -3442,6 +3457,7 @@ class AssertStatNode(StatNode): ...@@ -3442,6 +3457,7 @@ class AssertStatNode(StatNode):
"PyErr_SetObject(PyExc_AssertionError, %s);" % "PyErr_SetObject(PyExc_AssertionError, %s);" %
self.value.py_result()) self.value.py_result())
self.value.generate_disposal_code(code) self.value.generate_disposal_code(code)
self.value.free_temps(code)
else: else:
code.putln( code.putln(
"PyErr_SetNone(PyExc_AssertionError);") "PyErr_SetNone(PyExc_AssertionError);")
...@@ -3450,6 +3466,7 @@ class AssertStatNode(StatNode): ...@@ -3450,6 +3466,7 @@ class AssertStatNode(StatNode):
code.putln( code.putln(
"}") "}")
self.cond.generate_disposal_code(code) self.cond.generate_disposal_code(code)
self.cond.free_temps(code)
code.putln("#endif") code.putln("#endif")
def annotate(self, code): def annotate(self, code):
...@@ -3756,6 +3773,7 @@ class ForInStatNode(LoopNode, StatNode): ...@@ -3756,6 +3773,7 @@ class ForInStatNode(LoopNode, StatNode):
code.put_label(break_label) code.put_label(break_label)
self.iterator.release_counter_temp(code) self.iterator.release_counter_temp(code)
self.iterator.generate_disposal_code(code) self.iterator.generate_disposal_code(code)
self.iterator.free_temps(code)
def annotate(self, code): def annotate(self, code):
self.target.annotate(code) self.target.annotate(code)
...@@ -3878,9 +3896,12 @@ class ForFromStatNode(LoopNode, StatNode): ...@@ -3878,9 +3896,12 @@ class ForFromStatNode(LoopNode, StatNode):
code.putln("}") code.putln("}")
code.put_label(break_label) code.put_label(break_label)
self.bound1.generate_disposal_code(code) self.bound1.generate_disposal_code(code)
self.bound1.free_temps(code)
self.bound2.generate_disposal_code(code) self.bound2.generate_disposal_code(code)
self.bound2.free_temps(code)
if self.step is not None: if self.step is not None:
self.step.generate_disposal_code(code) self.step.generate_disposal_code(code)
self.step.free_temps(code)
relation_table = { relation_table = {
# {relop : (initial offset, increment op)} # {relop : (initial offset, increment op)}
...@@ -4103,6 +4124,7 @@ class ExceptClauseNode(Node): ...@@ -4103,6 +4124,7 @@ class ExceptClauseNode(Node):
self.match_flag, self.match_flag,
self.pattern.py_result())) self.pattern.py_result()))
self.pattern.generate_disposal_code(code) self.pattern.generate_disposal_code(code)
self.pattern.free_temps(code)
code.putln( code.putln(
"if (%s) {" % "if (%s) {" %
self.match_flag) self.match_flag)
...@@ -4539,6 +4561,7 @@ class FromImportStatNode(StatNode): ...@@ -4539,6 +4561,7 @@ class FromImportStatNode(StatNode):
code.error_goto_if_null(self.item.result(), self.pos))) code.error_goto_if_null(self.item.result(), self.pos)))
target.generate_assignment_code(self.item, code) target.generate_assignment_code(self.item, code)
self.module.generate_disposal_code(code) self.module.generate_disposal_code(code)
self.module.free_temps(code)
......
...@@ -8,9 +8,13 @@ import TypeSlots ...@@ -8,9 +8,13 @@ import TypeSlots
import Symtab import Symtab
from StringEncoding import EncodedString from StringEncoding import EncodedString
#def unwrap_node(node):
# while isinstance(node, ExprNodes.PersistentNode):
# node = node.arg
# return node
# Temporary hack while PersistentNode is out of order
def unwrap_node(node): def unwrap_node(node):
while isinstance(node, ExprNodes.PersistentNode):
node = node.arg
return node return node
def is_common_value(a, b): def is_common_value(a, 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