Commit 1d01207e authored by Stefan Behnel's avatar Stefan Behnel

Fix optimised calls with a separate 'self' argument, e.g. for specialised calls to known builtins.

parent 086f80ae
...@@ -5678,20 +5678,21 @@ class SimpleCallNode(CallNode): ...@@ -5678,20 +5678,21 @@ class SimpleCallNode(CallNode):
return True return True
def generate_evaluation_code(self, code): def generate_evaluation_code(self, code):
# Avoid tuple creation for Python calls with 0 or 1 args. function = self.function
func_type = self.function_type() if function.is_name or function.is_attribute:
if self.function.is_name or self.function.is_attribute: code.globalstate.use_entry_utility_code(function.entry)
code.globalstate.use_entry_utility_code(self.function.entry)
if not func_type.is_pyobject or len(self.arg_tuple.args) > 1: if not function.type.is_pyobject or len(self.arg_tuple.args) > 1 or (
self.arg_tuple.args and self.arg_tuple.is_literal):
super(SimpleCallNode, self).generate_evaluation_code(code) super(SimpleCallNode, self).generate_evaluation_code(code)
return return
function = self.function # Special case 0-args and try to avoid explicit tuple creation for Python calls with 1 arg.
function.generate_evaluation_code(code)
arg = self.arg_tuple.args[0] if self.arg_tuple.args else None arg = self.arg_tuple.args[0] if self.arg_tuple.args else None
if arg is not None: subexprs = (self.self, self.coerced_self, function, arg)
arg.generate_evaluation_code(code) for subexpr in subexprs:
if subexpr is not None:
subexpr.generate_evaluation_code(code)
code.mark_pos(self.pos) code.mark_pos(self.pos)
assert self.is_temp assert self.is_temp
...@@ -5717,11 +5718,10 @@ class SimpleCallNode(CallNode): ...@@ -5717,11 +5718,10 @@ class SimpleCallNode(CallNode):
code.put_gotref(self.py_result()) code.put_gotref(self.py_result())
function.generate_disposal_code(code) for subexpr in subexprs:
function.free_temps(code) if subexpr is not None:
if arg is not None: subexpr.generate_disposal_code(code)
arg.generate_disposal_code(code) subexpr.free_temps(code)
arg.free_temps(code)
def generate_result_code(self, code): def generate_result_code(self, code):
func_type = self.function_type() func_type = self.function_type()
......
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