示例#1
0
    def _do_optimize_loop(self,
                          loop,
                          call_pure_results,
                          start_state=None,
                          export_state=False):
        from rpython.jit.metainterp.optimizeopt import optimize_trace
        from rpython.jit.metainterp.optimizeopt.util import args_dict

        self.loop = loop
        loop.call_pure_results = args_dict()
        if call_pure_results is not None:
            for k, v in call_pure_results.items():
                loop.call_pure_results[list(k)] = v
        metainterp_sd = FakeMetaInterpStaticData(self.cpu)
        if hasattr(self, 'vrefinfo'):
            metainterp_sd.virtualref_info = self.vrefinfo
        if hasattr(self, 'callinfocollection'):
            metainterp_sd.callinfocollection = self.callinfocollection
        #
        return optimize_trace(metainterp_sd,
                              None,
                              loop,
                              self.enable_opts,
                              start_state=start_state,
                              export_state=export_state)
示例#2
0
 def _convert_call_pure_results(self, d):
     if d is None:
         return
     call_pure_results = args_dict()
     for k, v in d.items():
         call_pure_results[list(k)] = v
     return call_pure_results
示例#3
0
文件: test_util.py 项目: fhalde/pypy
    def _convert_call_pure_results(self, d):
        from rpython.jit.metainterp.optimizeopt.util import args_dict

        if d is None:
            return
        call_pure_results = args_dict()
        for k, v in d.items():
            call_pure_results[list(k)] = v
        return call_pure_results
示例#4
0
    def _convert_call_pure_results(self, d):
        from rpython.jit.metainterp.optimizeopt.util import args_dict

        if d is None:
            return
        call_pure_results = args_dict()
        for k, v in d.items():
            call_pure_results[list(k)] = v
        return call_pure_results
示例#5
0
    def _do_optimize_loop(self, loop, call_pure_results):
        from rpython.jit.metainterp.optimizeopt.unroll import optimize_unroll
        from rpython.jit.metainterp.optimizeopt.util import args_dict
        from rpython.jit.metainterp.optimizeopt.pure import OptPure

        self.loop = loop
        loop.call_pure_results = args_dict()
        metainterp_sd = FakeMetaInterpStaticData(self.cpu)
        optimize_unroll(metainterp_sd, loop, [OptRewrite(), OptRenameStrlen(), OptHeap(), OptPure()], True)
示例#6
0
 def _optimize_CALL_DICT_LOOKUP(self, op):
     # Cache consecutive lookup() calls on the same dict and key,
     # depending on the 'flag_store' argument passed:
     # FLAG_LOOKUP: always cache and use the cached result.
     # FLAG_STORE:  don't cache (it might return -1, which would be
     #                incorrect for future lookups); but if found in
     #                the cache and the cached value was already checked
     #                non-negative, then we can reuse it.
     # FLAG_DELETE: never cache, never use the cached result (because
     #                if there is a cached result, the FLAG_DELETE call
     #                is needed for its side-effect of removing it).
     #                In theory we could cache a -1 for the case where
     #                the delete is immediately followed by a lookup,
     #                but too obscure.
     #
     from rpython.rtyper.lltypesystem.rordereddict import FLAG_LOOKUP
     from rpython.rtyper.lltypesystem.rordereddict import FLAG_STORE
     flag_value = self.getintbound(op.getarg(4))
     if not flag_value.is_constant():
         return False
     flag = flag_value.getint()
     if flag != FLAG_LOOKUP and flag != FLAG_STORE:
         return False
     #
     descrs = op.getdescr().get_extra_info().extradescrs
     assert descrs  # translation hint
     descr1 = descrs[0]
     try:
         d = self.cached_dict_reads[descr1]
     except KeyError:
         d = self.cached_dict_reads[descr1] = args_dict()
         self.corresponding_array_descrs[descrs[1]] = descr1
     #
     key = [
         get_box_replacement(op.getarg(1)),  # dict
         get_box_replacement(op.getarg(2))
     ]  # key
     # other args can be ignored here (hash, store_flag)
     try:
         res_v = d[key]
     except KeyError:
         if flag == FLAG_LOOKUP:
             d[key] = op
         return False
     else:
         if flag != FLAG_LOOKUP:
             if not self.getintbound(res_v).known_ge(IntBound(0, 0)):
                 return False
         self.make_equal_to(op, res_v)
         self.last_emitted_operation = REMOVED
         return True
示例#7
0
 def _optimize_CALL_DICT_LOOKUP(self, op):
     # Cache consecutive lookup() calls on the same dict and key,
     # depending on the 'flag_store' argument passed:
     # FLAG_LOOKUP: always cache and use the cached result.
     # FLAG_STORE:  don't cache (it might return -1, which would be
     #                incorrect for future lookups); but if found in
     #                the cache and the cached value was already checked
     #                non-negative, then we can reuse it.
     # FLAG_DELETE: never cache, never use the cached result (because
     #                if there is a cached result, the FLAG_DELETE call
     #                is needed for its side-effect of removing it).
     #                In theory we could cache a -1 for the case where
     #                the delete is immediately followed by a lookup,
     #                but too obscure.
     #
     from rpython.rtyper.lltypesystem.rordereddict import FLAG_LOOKUP
     from rpython.rtyper.lltypesystem.rordereddict import FLAG_STORE
     flag_value = self.getintbound(op.getarg(4))
     if not flag_value.is_constant():
         return False
     flag = flag_value.getint()
     if flag != FLAG_LOOKUP and flag != FLAG_STORE:
         return False
     #
     descrs = op.getdescr().get_extra_info().extradescrs
     assert descrs        # translation hint
     descr1 = descrs[0]
     try:
         d = self.cached_dict_reads[descr1]
     except KeyError:
         d = self.cached_dict_reads[descr1] = args_dict()
         self.corresponding_array_descrs[descrs[1]] = descr1
     #
     key = [self.optimizer.get_box_replacement(op.getarg(1)),   # dict
            self.optimizer.get_box_replacement(op.getarg(2))]   # key
            # other args can be ignored here (hash, store_flag)
     try:
         res_v = d[key]
     except KeyError:
         if flag == FLAG_LOOKUP:
             d[key] = op
         return False
     else:
         if flag != FLAG_LOOKUP:
             if not self.getintbound(res_v).known_ge(IntBound(0, 0)):
                 return False
         self.make_equal_to(op, res_v)
         self.last_emitted_operation = REMOVED
         return True
示例#8
0
    def _do_optimize_loop(self, loop, call_pure_results):
        from rpython.jit.metainterp.optimizeopt import optimize_trace
        from rpython.jit.metainterp.optimizeopt.util import args_dict

        self.loop = loop
        loop.call_pure_results = args_dict()
        if call_pure_results is not None:
            for k, v in call_pure_results.items():
                loop.call_pure_results[list(k)] = v
        metainterp_sd = FakeMetaInterpStaticData(self.cpu)
        if hasattr(self, 'vrefinfo'):
            metainterp_sd.virtualref_info = self.vrefinfo
        if hasattr(self, 'callinfocollection'):
            metainterp_sd.callinfocollection = self.callinfocollection
        #
        optimize_trace(metainterp_sd, loop, self.enable_opts)
示例#9
0
    def _do_optimize_bridge(self, bridge, call_pure_results):
        from rpython.jit.metainterp.optimizeopt import optimize_trace
        from rpython.jit.metainterp.optimizeopt.util import args_dict

        self.bridge = bridge
        bridge.call_pure_results = args_dict()
        if call_pure_results is not None:
            for k, v in call_pure_results.items():
                bridge.call_pure_results[list(k)] = v
        metainterp_sd = FakeMetaInterpStaticData(self.cpu)
        if hasattr(self, "vrefinfo"):
            metainterp_sd.virtualref_info = self.vrefinfo
        if hasattr(self, "callinfocollection"):
            metainterp_sd.callinfocollection = self.callinfocollection
        #
        bridge.resume_at_jump_descr = FakeDescrWithSnapshot()
        optimize_trace(metainterp_sd, bridge, self.enable_opts)
示例#10
0
    def _do_optimize_loop(self,
                          loop,
                          call_pure_results,
                          state,
                          export_state=False):
        from rpython.jit.metainterp.optimizeopt.unroll import optimize_unroll
        from rpython.jit.metainterp.optimizeopt.util import args_dict
        from rpython.jit.metainterp.optimizeopt.pure import OptPure

        self.loop = loop
        loop.call_pure_results = args_dict()
        metainterp_sd = FakeMetaInterpStaticData(self.cpu)
        return optimize_unroll(
            metainterp_sd, loop,
            [OptRewrite(),
             OptRenameStrlen(),
             OptHeap(), OptPure()], True, state, export_state)
示例#11
0
    def _do_optimize_bridge(self, bridge, call_pure_results):
        from rpython.jit.metainterp.optimizeopt import optimize_trace
        from rpython.jit.metainterp.optimizeopt.util import args_dict

        self.bridge = bridge
        bridge.call_pure_results = args_dict()
        if call_pure_results is not None:
            for k, v in call_pure_results.items():
                bridge.call_pure_results[list(k)] = v
        metainterp_sd = FakeMetaInterpStaticData(self.cpu)
        if hasattr(self, 'vrefinfo'):
            metainterp_sd.virtualref_info = self.vrefinfo
        if hasattr(self, 'callinfocollection'):
            metainterp_sd.callinfocollection = self.callinfocollection
        #
        bridge.resume_at_jump_descr = FakeDescrWithSnapshot()
        optimize_trace(metainterp_sd, bridge, self.enable_opts)
示例#12
0
 def _optimize_CALL_DICT_LOOKUP(self, op):
     descrs = op.getdescr().get_extra_info().extradescrs
     assert descrs  # translation hint
     descr1 = descrs[0]
     try:
         d = self.cached_dict_reads[descr1]
     except KeyError:
         d = self.cached_dict_reads[descr1] = args_dict()
         self.corresponding_array_descrs[descrs[1]] = descr1
     args = self.optimizer.make_args_key(op)
     try:
         res_v = d[args]
     except KeyError:
         d[args] = self.getvalue(op.result)
         return False
     else:
         self.make_equal_to(op.result, res_v)
         self.last_emitted_operation = REMOVED
         return True
示例#13
0
文件: pure.py 项目: Qointum/pypy
 def __init__(self):
     self.postponed_op = None
     self.pure_operations = args_dict()
     self.call_pure_positions = []
示例#14
0
 def __init__(self):
     self.postponed_op = None
     self.pure_operations = args_dict()
     self.call_pure_positions = []
示例#15
0
文件: pure.py 项目: yuyichao/pypy
 def __init__(self):
     self.postponed_op = None
     self.pure_operations = args_dict()
     self.emitted_pure_operations = {}