Exemple #1
0
 def no_more_blocks_to_annotate(pol, annotator):
     bk = annotator.bookkeeper
     # hint to all pending specializers that we are done
     for callback in bk.pending_specializations:
         callback()
     del bk.pending_specializations[:]
     if annotator.added_blocks is not None:
         all_blocks = annotator.added_blocks
     else:
         all_blocks = annotator.annotated
     for block in list(all_blocks):
         for i, instr in enumerate(block.operations):
             if not isinstance(instr, (op.simple_call, op.call_args)):
                 continue
             v_func = instr.args[0]
             s_func = annotator.annotation(v_func)
             if not hasattr(s_func, 'needs_sandboxing'):
                 continue
             key = ('sandboxing', s_func.const)
             if key not in bk.emulated_pbc_calls:
                 params_s = s_func.args_s
                 s_result = s_func.s_result
                 from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline
                 sandbox_trampoline = make_sandbox_trampoline(
                     s_func.name, params_s, s_result)
                 sandbox_trampoline._signature_ = [SomeTuple(items=params_s)], s_result
                 bk.emulate_pbc_call(key, bk.immutablevalue(sandbox_trampoline), params_s)
             else:
                 s_trampoline = bk.emulated_pbc_calls[key][0]
                 sandbox_trampoline = s_trampoline.const
             new = instr.replace({instr.args[0]: Constant(sandbox_trampoline)})
             block.operations[i] = new
Exemple #2
0
    def getcallable(self, graph):
        def getconcretetype(v):
            return self.bindingrepr(v).lowleveltype
        if self.annotator.translator.config.translation.sandbox:
            try:
                name = graph.func._sandbox_external_name
            except AttributeError:
                pass
            else:
                args_s = [v.annotation for v in graph.getargs()]
                s_result = graph.getreturnvar().annotation
                sandboxed = make_sandbox_trampoline(name, args_s, s_result)
                return self.getannmixlevel().delayedfunction(
                        sandboxed, args_s, s_result)

        return getfunctionptr(graph, getconcretetype)
Exemple #3
0
    def getcallable(self, graph):
        def getconcretetype(v):
            return self.bindingrepr(v).lowleveltype
        if self.annotator.translator.config.translation.sandbox:
            try:
                name = graph.func._sandbox_external_name
            except AttributeError:
                pass
            else:
                args_s = [v.annotation for v in graph.getargs()]
                s_result = graph.getreturnvar().annotation
                sandboxed = make_sandbox_trampoline(name, args_s, s_result)
                return self.getannmixlevel().delayedfunction(
                        sandboxed, args_s, s_result)

        return getfunctionptr(graph, getconcretetype)
Exemple #4
0
 def no_more_blocks_to_annotate(pol, annotator):
     bk = annotator.bookkeeper
     # hint to all pending specializers that we are done
     for callback in bk.pending_specializations:
         callback()
     del bk.pending_specializations[:]
     if annotator.added_blocks is not None:
         all_blocks = annotator.added_blocks
     else:
         all_blocks = annotator.annotated
     for block in list(all_blocks):
         for i, instr in enumerate(block.operations):
             if not isinstance(instr, (op.simple_call, op.call_args)):
                 continue
             v_func = instr.args[0]
             s_func = annotator.annotation(v_func)
             if not hasattr(s_func, 'needs_sandboxing'):
                 continue
             key = ('sandboxing', s_func.const)
             if key not in bk.emulated_pbc_calls:
                 params_s = s_func.args_s
                 s_result = s_func.s_result
                 from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline
                 sandbox_trampoline = make_sandbox_trampoline(
                     s_func.name, params_s, s_result)
                 sandbox_trampoline._signature_ = [
                     SomeTuple(items=params_s)
                 ], s_result
                 bk.emulate_pbc_call(key,
                                     bk.immutablevalue(sandbox_trampoline),
                                     params_s)
             else:
                 s_trampoline = bk.emulated_pbc_calls[key][0]
                 sandbox_trampoline = s_trampoline.const
             new = instr.replace(
                 {instr.args[0]: Constant(sandbox_trampoline)})
             block.operations[i] = new