Exemple #1
0
 def graph_calling_color(self, tsgraph):
     args_hs, hs_res = self.hannotator.bookkeeper.tsgraphsigs[tsgraph]
     if originalconcretetype(hs_res) is lltype.Void:
         c = 'gray'
     elif hs_res.is_green():
         c = 'yellow'
     else:
         c = 'red'
     return c
Exemple #2
0
 def make_call(self, block, op, save_locals_vars, color='red'):
     # the 'save_locals' pseudo-operation is used to save all
     # alive local variables into the current JITState
     self.genop(block, 'save_locals', save_locals_vars)
     targets = dict(self.graphs_from(op))
     #for tsgraph in targets.values():
     #    if self.graph_global_mps(tsgraph):
     #        # make sure jitstate.resumepoint is set to zero
     #        self.genop(block, 'resetresumepoint', [])
     #        break
     #  XXX do the right thing for call to portals
     #
     args_v = op.args[1:]
     if op.opname == 'indirect_call':
         del args_v[-1]
     if len(targets) == 1:
         [tsgraph] = targets.values()
         c_tsgraph = inputconst(lltype.Void, tsgraph)
         v_finished = self.genop(block, '%s_call' % (color,),
                                 [c_tsgraph] + args_v,
                                 resulttype = lltype.Bool)
         # Void result, because the call doesn't return its redbox result,
         # but only has the hidden side-effect of putting it in the jitstate
     else:
         c_targets = inputconst(lltype.Void, targets)
         args_v = op.args[:1] + args_v + [c_targets]
         hs_func = self.hannotator.binding(args_v[0])
         if not hs_func.is_green():
             # handle_red_call() has checked with is_constant that
             # the hs_func is actually a constant red box
             v_greenfunc = self.genop(block, 'revealconst', [args_v[0]],
                               resulttype = originalconcretetype(hs_func))
             args_v[0] = v_greenfunc
         v_finished = self.genop(block, 'indirect_%s_call' % (color,),
                                 args_v,
                                 resulttype = lltype.Bool)
     self.go_to_dispatcher_if(block, v_finished)