Skip to content

Commit

Permalink
Try not storing call_conv in generators and lower
Browse files Browse the repository at this point in the history
  • Loading branch information
sklam authored and guilhermeleobas committed Mar 14, 2023
1 parent af82ab9 commit 66a683b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
6 changes: 5 additions & 1 deletion numba/core/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def __init__(self, lower):
self.context = lower.context
self.fndesc = lower.fndesc
self.library = lower.library
self.call_conv = lower.call_conv
self.func_ir = lower.func_ir
self.lower = lower

self.geninfo = lower.generator_info
self.gentype = self.get_generator_type()
Expand All @@ -66,6 +66,10 @@ def __init__(self, lower):

self.resume_blocks = {}

@property
def call_conv(self):
return self.lower.call_conv

def get_args_ptr(self, builder, genptr):
return cgutils.gep_inbounds(builder, genptr, 0, 1)

Expand Down
33 changes: 4 additions & 29 deletions numba/core/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __init__(self, context, library, fndesc, func_ir, metadata=None):
self.fndesc = fndesc
self.blocks = utils.SortedMap(func_ir.blocks.items())
self.func_ir = func_ir
self.call_conv = context.call_conv
self.generator_info = func_ir.generator_info
self.metadata = metadata
self.flags = targetconfig.ConfigStack.top_or_none()
Expand Down Expand Up @@ -71,6 +70,10 @@ def __init__(self, context, library, fndesc, func_ir, metadata=None):
# Subclass initialization
self.init()

@property
def call_conv(self):
return self.context.call_conv

def init(self):
pass

Expand Down Expand Up @@ -137,12 +140,6 @@ def post_block(self, block):
Called after lowering a block.
"""

def return_dynamic_exception(self, exc_class, exc_args, nb_types, loc=None):
self.call_conv.return_dynamic_user_exc(
self.builder, exc_class, exc_args, nb_types,
loc=loc, func_name=self.func_ir.func_id.func_name,
)

def return_exception(self, exc_class, exc_args=None, loc=None):
"""Propagate exception to the caller.
"""
Expand Down Expand Up @@ -563,9 +560,6 @@ def lower_inst(self, inst):
elif isinstance(inst, ir.StaticRaise):
self.lower_static_raise(inst)

elif isinstance(inst, ir.DynamicRaise):
self.lower_dynamic_raise(inst)

elif isinstance(inst, ir.StaticTryRaise):
self.lower_static_try_raise(inst)

Expand Down Expand Up @@ -603,25 +597,6 @@ def lower_setitem(self, target_var, index_var, value_var, signature):

return impl(self.builder, (target, index, value))

def lower_dynamic_raise(self, inst):
exc_args = inst.exc_args
args = []
nb_types = []
for exc_arg in exc_args:
if isinstance(exc_arg, ir.Var):
# dynamic values
typ = self.typeof(exc_arg.name)
val = self.loadvar(exc_arg.name)
self.incref(typ, val)
else:
typ = None
val = exc_arg
nb_types.append(typ)
args.append(val)

self.return_dynamic_exception(inst.exc_class, tuple(args),
tuple(nb_types), loc=self.loc)

def lower_static_raise(self, inst):
if inst.exc_class is None:
# Reraise
Expand Down

0 comments on commit 66a683b

Please sign in to comment.