[pypy-svn] r51831 - in pypy/branch/jit-refactoring/pypy/jit: rainbow rainbow/test timeshifter

cfbolz at codespeak.net cfbolz at codespeak.net
Sun Feb 24 11:57:18 CET 2008


Author: cfbolz
Date: Sun Feb 24 11:57:15 2008
New Revision: 51831

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_serializegraph.py
   pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py
Log:
start supporting promotion in the rainbow interpreter


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	Sun Feb 24 11:57:15 2008
@@ -26,6 +26,7 @@
         self.raise_analyzer = hannotator.exceptiontransformer.raise_analyzer
         self.all_graphs = {} # mapping graph to bytecode
         self.unfinished_graphs = []
+        self.num_global_mergepoints = 0
 
     def can_raise(self, op):
         return self.raise_analyzer.analyze(op)
@@ -45,8 +46,9 @@
         self.arrayfielddescs = []
         self.interiordescs = []
         self.oopspecdescs = []
+        self.promotiondescs = []
         self.called_bytecodes = []
-        self.num_mergepoints = 0
+        self.num_local_mergepoints = 0
         self.graph_color = self.graph_calling_color(graph)
         self.nonrainbow_functions = []
         self.is_portal = is_portal
@@ -74,13 +76,17 @@
         self.interiordesc_positions = {}
         # mapping (fnobj, can_raise) to index
         self.oopspecdesc_positions = {}
+        # mapping (fnobj, can_raise) to index
+        self.promotiondesc_positions = {}
         # mapping graphs to index
         self.graph_positions = {}
         # mapping fnobjs to index
         self.nonrainbow_positions = {}
 
         self.graph = graph
-        self.entrymap = flowmodel.mkentrymap(graph)
+        self.mergepoint_set = {}
+        self.compute_merge_points()
+
         self.make_bytecode_block(graph.startblock)
         assert self.current_block is None
         bytecode = self.all_graphs[graph]
@@ -95,13 +101,16 @@
                           self.arrayfielddescs,
                           self.interiordescs,
                           self.oopspecdescs,
+                          self.promotiondescs,
                           self.called_bytecodes,
-                          self.num_mergepoints,
+                          self.num_local_mergepoints,
                           self.graph_color,
                           self.nonrainbow_functions,
                           self.is_portal)
         if is_portal:
             self.finish_all_graphs()
+            self.interpreter.set_num_global_mergepoints(
+                self.num_global_mergepoints)
             return bytecode
 
     def finish_all_graphs(self):
@@ -109,6 +118,43 @@
             graph = self.unfinished_graphs.pop()
             self.make_bytecode(graph, is_portal=False)
 
+    def compute_merge_points(self):
+        entrymap = flowmodel.mkentrymap(self.graph)
+        startblock = self.graph.startblock
+        global_merge_blocks = {}
+        for block in self.graph.iterblocks():
+            if not block.operations:
+                continue
+            op = block.operations[0]
+            hashint = False
+            cand = 0
+            if (op.opname == 'hint' and
+                op.args[1].value == {'global_merge_point': True}):
+                hashint = True
+                if block is startblock or len(entrymap[block]) > 1:
+                    global_merge_blocks[block] = True
+                    cand += 1
+                else:
+                    prevblock = entrymap[block][0].prevblock
+                    if len(entrymap[prevblock]) > 1:
+                        global_merge_blocks[prevblock] = True
+                        cand += 1
+            assert not hashint or cand==1, (
+                "ambigous global merge point hint: %r" % block)
+            for op in block.operations[1:]:
+                assert not (op.opname == 'hint' and
+                    op.args[1].value == {'global_merge_point': True}), (
+                    "stranded global merge point hint: %r" % block)
+                
+        for block, links in entrymap.items():
+            if len(links) > 1 and block is not self.graph.returnblock:
+                if block in global_merge_blocks:
+                    self.mergepoint_set[block] = 'global'
+                else:
+                    self.mergepoint_set[block] = 'local'
+        if startblock in global_merge_blocks:
+            self.mergepoint_set[startblock] = 'global'
+
     def make_bytecode_block(self, block, insert_goto=False):
         if block in self.seen_blocks:
             if insert_goto:
@@ -185,10 +231,8 @@
     def insert_merges(self, block):
         if block is self.graph.returnblock:
             return
-        if len(self.entrymap[block]) <= 1:
+        if block not in self.mergepoint_set:
             return
-        num = self.num_mergepoints
-        self.num_mergepoints += 1
         # make keydesc
         key = ()
         for arg in self.sort_by_color(block.inputargs)[1]:
@@ -202,7 +246,16 @@
             self.keydescs.append(KeyDesc(self.RGenOp, *key))
         else:
             keyindex = self.keydesc_positions[key]
-        self.emit("merge")
+
+        kind = self.mergepoint_set[block]
+        if kind == "global":
+            self.emit("guard_global_merge")
+            num = self.num_global_mergepoints
+            self.num_global_mergepoints += 1
+        else:
+            num = self.num_local_mergepoints
+            self.num_local_mergepoints += 1
+        self.emit("%s_merge" % kind)
         self.emit(num)
         self.emit(keyindex)
 
@@ -367,6 +420,16 @@
         self.oopspecdesc_positions[key] = result
         return result
 
+    def promotiondesc_position(self, TYPE):
+        ERASED = self.RGenOp.erasedType(TYPE)
+        if ERASED in self.promotiondesc_positions:
+            return self.promotiondesc_positions[ERASED]
+        promotiondesc = rtimeshift.PromotionDesc(ERASED, self.interpreter)
+        result = len(self.promotiondescs)
+        self.promotiondescs.append(promotiondesc)
+        self.promotiondesc_positions[ERASED] = result
+        return result
+
     def graph_position(self, graph):
         if graph in self.graph_positions:
             return self.graph_positions[graph]
@@ -491,6 +554,18 @@
             else:
                 self.register_greenvar(result, self.green_position(arg))
             return
+        if "promote" in hints:
+            if self.varcolor(arg) == "green":
+                self.register_greenvar(result, self.green_position(arg))
+                return
+            self.emit("promote")
+            self.emit(self.serialize_oparg("red", arg))
+            self.emit(self.promotiondesc_position(arg.concretetype))
+            self.register_greenvar(result)
+            return
+        if "global_merge_point" in hints:
+            return # the compute_merge_points function already cared
+        XXX
 
     def args_of_call(self, args, colored_as):
         result = []

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py	Sun Feb 24 11:57:15 2008
@@ -1,7 +1,7 @@
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.jit.timeshifter import rtimeshift, rcontainer
-from pypy.jit.timeshifter.greenkey import empty_key, GreenKey
+from pypy.jit.timeshifter.greenkey import empty_key, GreenKey, newgreendict
 from pypy.rpython.lltypesystem import lltype
 
 class JitCode(object):
@@ -19,7 +19,8 @@
 
     def __init__(self, name, code, constants, typekinds, redboxclasses,
                  keydescs, structtypedescs, fielddescs, arrayfielddescs,
-                 interiordescs, oopspecdescs, called_bytecodes, num_mergepoints,
+                 interiordescs, oopspecdescs, promotiondescs,
+                 called_bytecodes, num_mergepoints,
                  graph_color, nonrainbow_functions, is_portal):
         self.name = name
         self.code = code
@@ -32,6 +33,7 @@
         self.arrayfielddescs = arrayfielddescs
         self.interiordescs = interiordescs
         self.oopspecdescs = oopspecdescs
+        self.promotiondescs = promotiondescs
         self.called_bytecodes = called_bytecodes
         self.num_mergepoints = num_mergepoints
         self.graph_color = graph_color
@@ -47,6 +49,29 @@
     pass
 STOP = STOP()
 
+
+class RainbowResumer(rtimeshift.Resumer):
+    def __init__(self, interpreter, frame):
+        self.interpreter = interpreter
+        self.bytecode = frame.bytecode
+        self.pc = frame.pc
+
+    def resume(self, jitstate, resuming):
+        interpreter = self.interpreter
+        dispatchqueue = rtimeshift.DispatchQueue(self.bytecode.num_mergepoints)
+        dispatchqueue.resuming = resuming
+        jitstate.frame.dispatchqueue = dispatchqueue
+        interpreter.newjitstate(jitstate)
+        interpreter.frame.pc = self.pc
+        interpreter.frame.bytecode = self.bytecode
+        interpreter.frame.local_green = jitstate.greens
+        jitstate.frame.dispatchqueue = dispatchqueue
+        interpreter.bytecode_loop()
+        finaljitstate = interpreter.jitstate
+        if finaljitstate is not None:
+            interpreter.finish_jitstate(interpreter.portalstate.sigtoken)
+
+
 class JitInterpreter(object):
     def __init__(self, exceptiondesc, RGenOp):
         self.exceptiondesc = exceptiondesc
@@ -56,8 +81,21 @@
         self.jitstate = None
         self.queue = None
         self.rgenop = RGenOp()
+        self.portalstate = None
+        self.num_global_mergepoints = -1
+        self.global_state_dicts = None
         self._add_implemented_opcodes()
 
+    def set_portalstate(self, portalstate):
+        assert self.portalstate is None
+        self.portalstate = portalstate
+
+    def set_num_global_mergepoints(self, num_global_mergepoints):
+        assert self.num_global_mergepoints == -1
+        self.num_global_mergepoints = num_global_mergepoints
+        dicts = [newgreendict() for i in range(self.num_global_mergepoints)]
+        self.global_state_dicts = dicts
+
     def run(self, jitstate, bytecode, greenargs, redargs,
             start_bytecode_loop=True):
         self.jitstate = jitstate
@@ -72,6 +110,14 @@
             self.bytecode_loop()
         return self.jitstate
 
+    def resume(self, jitstate, greenargs, redargs):
+        self.newjitstate(jitstate)
+        self.frame.local_boxes = redargs
+        self.frame.local_green = greenargs
+        self.frame.gc = rtimeshift.getresumepoint(jitstate)
+        self.bytecode_loop()
+        return self.jitstate
+
     def fresh_jitstate(self, builder):
         return rtimeshift.JITState(builder, None,
                                    self.exceptiondesc.null_exc_type_box,
@@ -180,6 +226,15 @@
     def get_redarg(self):
         return self.frame.local_boxes[self.load_2byte()]
 
+
+    def get_greenkey(self):
+        keydescnum = self.load_2byte()
+        if keydescnum == -1:
+            return empty_key
+        else:
+            keydesc = self.frame.bytecode.keydescs[keydescnum]
+            return GreenKey(self.frame.local_green[:keydesc.nb_vals], keydesc)
+
     def red_result(self, box):
         self.frame.local_boxes.append(box)
 
@@ -287,20 +342,40 @@
             newgreens.append(self.get_greenarg())
         self.frame.local_green = newgreens
 
-    def opimpl_merge(self):
+    def opimpl_local_merge(self):
         mergepointnum = self.load_2byte()
-        keydescnum = self.load_2byte()
-        if keydescnum == -1:
-            key = empty_key
-        else:
-            keydesc = self.frame.bytecode.keydescs[keydescnum]
-            key = GreenKey(self.frame.local_green[:keydesc.nb_vals], keydesc)
+        key = self.get_greenkey()
         states_dic = self.queue.local_caches[mergepointnum]
         done = rtimeshift.retrieve_jitstate_for_merge(states_dic, self.jitstate,
                                                       key, None)
         if done:
             return self.dispatch()
 
+    def opimpl_global_merge(self):
+        mergepointnum = self.load_2byte()
+        key = self.get_greenkey()
+        states_dic = self.global_state_dicts[mergepointnum]
+        global_resumer = RainbowResumer(self, self.frame)
+        done = rtimeshift.retrieve_jitstate_for_merge(states_dic, self.jitstate,
+                                                      key, global_resumer)
+        if done:
+            return self.dispatch()
+
+    def opimpl_guard_global_merge(self):
+        rtimeshift.guard_global_merge(self.jitstate, self.frame.pc)
+        return self.dispatch()
+
+    def opimpl_promote(self):
+        promotebox = self.get_redarg()
+        promotiondescnum = self.load_2byte()
+        promotiondesc = self.frame.bytecode.promotiondescs[promotiondescnum]
+        done = rtimeshift.promote(self.jitstate, promotebox, promotiondesc)
+        if done:
+            return self.dispatch()
+        gv_switchvar = promotebox.getgenvar(self.jitstate)
+        assert gv_switchvar.is_const
+        self.green_result(gv_switchvar)
+
     def opimpl_red_direct_call(self):
         greenargs = self.get_green_varargs()
         redargs = self.get_red_varargs()

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py	Sun Feb 24 11:57:15 2008
@@ -54,11 +54,13 @@
         self.sigtoken = self.RGenOp.sigToken(self.RESIDUAL_FUNCTYPE)
 
     def make_state_instance(self):
-        state = self.PortalState(self.interpreter)
+        portalbytecode = self.codewriter.all_graphs[self.portalgraph]
+        state = self.PortalState(self.interpreter, portalbytecode)
         def portal_entry(*args):
             return state.portal_entry(*args)
         self.state = state
         self.portal_entry = portal_entry
+        self.interpreter.set_portalstate(state)
 
     def mutate_origportalgraph(self):
         # XXX
@@ -90,7 +92,7 @@
                 if lowleveltype.TO._hints.get('virtualizable', False):
                     redportargdesccls = RedVirtualizableStructPortalArgDesc
                 else:
-                    redportargdesccls = RedStructPortalArgDesc
+                    redportargdesccls = RedPortalArgDesc
         return redportargdesccls(lowleveltype, self.RGenOp)
 
 
@@ -98,10 +100,12 @@
                      portal_jitcode, rtyper):
     args_specification = unrolling_iterable(args_specification)
     class PortalState(object):
-        def __init__(self, interpreter):
+        def __init__(self, interpreter, portalbytecode):
             self.cache = {}
             self.graph_compilation_queue = []
             self.interpreter = interpreter
+            self.portalbytecode = portalbytecode
+            self.sigtoken = sigtoken
 
         def compile_more_functions(self):
             while self.graph_compilation_queue:
@@ -185,6 +189,17 @@
             self.compile_more_functions()
             return gv_generated
 
+        
+        def make_dummy_args(self):
+            redargs = ()
+            greenargs = ()
+            for color, _, make_arg_redbox in args_specification:
+                if color == "green":
+                    greenargs += (None, )
+                else:
+                    redargs += (None, )
+            return list(greenargs), list(redargs)
+
         # debug helpers
         def readportal(self, *args):
             i = 0

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	Sun Feb 24 11:57:15 2008
@@ -1,11 +1,12 @@
 import py
 from pypy.translator.translator import TranslationContext, graphof
+from pypy.jit.codegen.llgraph.rgenop import RGenOp as LLRGenOp
 from pypy.jit.hintannotator.annotator import HintAnnotator
 from pypy.jit.hintannotator.policy import StopAtXPolicy, HintAnnotatorPolicy
 from pypy.jit.hintannotator.model import SomeLLAbstractConstant, OriginFlags
 from pypy.jit.hintannotator.model import originalconcretetype
 from pypy.jit.rainbow.codewriter import BytecodeWriter, label, tlabel, assemble
-from pypy.jit.codegen.llgraph.rgenop import RGenOp as LLRGenOp
+from pypy.jit.rainbow.portal import PortalRewriter
 from pypy.jit.rainbow.test.test_serializegraph import AbstractSerializationTest
 from pypy.jit.timeshifter import rtimeshift, rvalue
 from pypy.rpython.lltypesystem import lltype, rstr
@@ -98,6 +99,7 @@
         t = hannotator.translator
         graph2 = graphof(t, portal)
         self.graph = graph2
+        self.maingraph = graphof(rtyper.annotator.translator, func)
         writer = BytecodeWriter(t, hannotator, self.RGenOp)
         jitcode = writer.make_bytecode(graph2)
         # the bytecode writer can ask for llhelpers about lists and dicts
@@ -117,6 +119,19 @@
         for i, ll_val in enumerate(values):
             color = writer.varcolor(graph2.startblock.inputargs[i])
             argcolors.append(color)
+
+
+        # rewire the original portal
+
+        rewriter = PortalRewriter(self.hintannotator, self.rtyper, self.RGenOp,
+                                  writer)
+        self.rewriter = rewriter
+        origportalgraph = graphof(self.rtyper.annotator.translator, portal)
+        portalgraph = graphof(t, portal)
+        rewriter.rewrite(origportalgraph=origportalgraph,
+                         portalgraph=portalgraph,
+                         view = conftest.option.view and self.small)
+
         self.writer = writer
         self.jitcode = jitcode
         self.argcolors = argcolors

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py	Sun Feb 24 11:57:15 2008
@@ -40,22 +40,8 @@
                         policy=policy, inline=inline,
                         backendoptimize=backendoptimize)
 
-        t = self.rtyper.annotator.translator
-        self.maingraph = graphof(t, main)
-
-        # rewire the original portal
-
-        rewriter = PortalRewriter(self.hintannotator, self.rtyper, self.RGenOp,
-                                  self.writer)
-        self.rewriter = rewriter
-        origportalgraph = graphof(t, portal)
-        portalgraph = graphof(self.hintannotator.translator, portal)
-        rewriter.rewrite(origportalgraph=origportalgraph,
-                         portalgraph=portalgraph,
-                         view = conftest.option.view and self.small)
-
         if conftest.option.view and self.small:
-            t.view()
+            self.rtyper.annotator.translator.view()
 
         # Populate the cache
         if len(self._cache_order) >= 3:

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_serializegraph.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_serializegraph.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_serializegraph.py	Sun Feb 24 11:57:15 2008
@@ -160,7 +160,7 @@
                             "make_new_redvars", 1, 2,
                             "make_new_greenvars", 0,
                             label("after"),
-                            "merge", 0, -1,
+                            "local_merge", 0, -1,
                             "make_redbox", -1, 0,
                             "red_int_add", 1, 0,
                             "make_new_redvars", 1, 2,
@@ -193,7 +193,7 @@
                             "make_new_redvars", 2, 0, 1,
                             "make_new_greenvars", 0,
                             label("while"),
-                            "merge", 0, -1, 
+                            "local_merge", 0, -1, 
                             "red_int_is_true", 0,
                             "red_goto_iftrue", 2, tlabel("body"),
                             "make_new_redvars", 1, 0,

Modified: pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py	Sun Feb 24 11:57:15 2008
@@ -4,10 +4,11 @@
 from pypy.jit.hintannotator.model import originalconcretetype
 from pypy.jit.timeshifter import rvalue, rcontainer, rvirtualizable
 from pypy.jit.timeshifter.greenkey import newgreendict, empty_key
+from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rpython.annlowlevel import cachedtype, base_ptr_lltype
 from pypy.rpython.annlowlevel import cast_instance_to_base_ptr
-from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
+from pypy.rpython.annlowlevel import cast_base_ptr_to_instance, llhelper
 
 FOLDABLE_GREEN_OPS = dict.fromkeys(lloperation.enum_foldable_ops())
 FOLDABLE_GREEN_OPS['getfield'] = None
@@ -263,8 +264,11 @@
         incoming[i].genvar = linkargs[i]
     return newblock
 
-def return_marker(jitstate, resuming):
-    raise AssertionError("shouldn't get here")
+class Resumer(object):
+    def resume(self, jitstate, resumepoint):
+        raise NotImplementedError("abstract base class")
+
+return_marker = Resumer()
 
 def start_new_block(states_dic, jitstate, key, global_resumer, index=-1):
     memo = rvalue.freeze_memo()
@@ -293,10 +297,10 @@
         dispatchqueue.clearlocalcaches()
         jitstate.promotion_path = PromotionPathMergesToSee(node, 0)
         #debug_print(lltype.Void, "PROMOTION ROOT")
-start_new_block._annspecialcase_ = "specialize:arglltype(2)"
 
 def retrieve_jitstate_for_merge(states_dic, jitstate, key, global_resumer,
                                 force_merge=False):
+    # global_resumer is always None, just not for global merge points
     if jitstate.virtualizables:
         jitstate.enter_block_sweep_virtualizables()
     if key not in states_dic:
@@ -663,6 +667,10 @@
         self.incoming_gv = incoming_gv
         self.promotion_path = promotion_path
 
+    # hack for testing: make the llinterpreter believe this is a Ptr to base
+    # instance
+    _TYPE = base_ptr_lltype()
+
 class AbstractPromotionPath(object):
     cut_limit = False
 
@@ -692,7 +700,7 @@
         jitstate.greens = self.greens_gv
         assert jitstate.frame.backframe is None
         resuminginfo.merges_to_see()
-        self.global_resumer(jitstate, resuminginfo)
+        self.global_resumer.resume(jitstate, resuminginfo)
         builder.show_incremental_progress()
 
 class PromotionPathNode(AbstractPromotionPath):
@@ -742,37 +750,47 @@
 MC_IGNORE_UNTIL_RETURN = -1
 MC_CALL_NOT_TAKEN      = -2
 
+# for testing purposes
+def _cast_base_ptr_to_promotion_point(ptr):
+    if we_are_translated():
+        return cast_base_ptr_to_instance(PromotionPoint, ptr)
+    else:
+        return ptr
+
+def _cast_promotion_point_to_base_ptr(instance):
+    assert isinstance(instance, PromotionPoint)
+    if we_are_translated():
+        return cast_instance_to_base_ptr(instance)
+    else:
+        return instance
+
 
 class PromotionDesc:
     __metaclass__ = cachedtype
 
-    def __init__(self, ERASED, hrtyper):
-        state = hrtyper.portalstate
+    def __init__(self, ERASED, interpreter):
+        self.exceptiondesc = interpreter.exceptiondesc
 
         def ll_continue_compilation(promotion_point_ptr, value):
             try:
-                promotion_point = cast_base_ptr_to_instance(
-                    PromotionPoint, promotion_point_ptr)
+                promotion_point = _cast_base_ptr_to_promotion_point(
+                    promotion_point_ptr)
                 path = [None]
                 root = promotion_point.promotion_path.follow_path(path)
                 gv_value = root.rgenop.genconst(value)
                 resuminginfo = ResumingInfo(promotion_point, gv_value, path)
                 root.continue_compilation(resuminginfo)
-                state.compile_more_functions()
+                interpreter.portalstate.compile_more_functions()
             except Exception, e:
+                if not we_are_translated():
+                    import pdb; pdb.set_trace()
                 lloperation.llop.debug_fatalerror(
                     lltype.Void, "compilation-time error %s" % e)
+        self.ll_continue_compilation = ll_continue_compilation
 
-        fnptr = hrtyper.annhelper.delayedfunction(
-            ll_continue_compilation,
-            [annmodel.SomePtr(base_ptr_lltype()),
-             annmodel.lltype_to_annotation(ERASED)],
-            annmodel.s_None, needtype=True)
-        RGenOp = hrtyper.RGenOp
-        self.exceptiondesc = hrtyper.exceptiondesc
-        self.gv_continue_compilation = RGenOp.constPrebuiltGlobal(fnptr)
-        self.sigtoken = RGenOp.sigToken(lltype.typeOf(fnptr).TO)
-##        self.PROMOTION_POINT = r_PromotionPoint.lowleveltype
+        FUNCTYPE = lltype.FuncType([base_ptr_lltype(), ERASED], lltype.Void)
+        self.FUNCPTRTYPE = lltype.Ptr(FUNCTYPE)
+        self.sigtoken = interpreter.rgenop.sigToken(FUNCTYPE)
 
     def _freeze_(self):
         return True
@@ -796,7 +814,7 @@
             pm = PromotionPoint(flexswitch, incoming_gv,
                                 jitstate.promotion_path)
             #debug_print(lltype.Void, "PROMOTE")
-            ll_pm = cast_instance_to_base_ptr(pm)
+            ll_pm = _cast_promotion_point_to_base_ptr(pm)
             gv_pm = default_builder.rgenop.genconst(ll_pm)
             gv_switchvar = promotebox.genvar
             exceptiondesc = promotiondesc.exceptiondesc
@@ -806,9 +824,12 @@
                                               exceptiondesc.gv_null_exc_type )
             exceptiondesc.genop_set_exc_value(default_builder,
                                               exceptiondesc.gv_null_exc_value)
+            fnptr = llhelper(promotiondesc.FUNCPTRTYPE,
+                             promotiondesc.ll_continue_compilation)
+            gv_continue_compilation = default_builder.rgenop.genconst(fnptr)
             default_builder.genop_call(promotiondesc.sigtoken,
-                               promotiondesc.gv_continue_compilation,
-                               [gv_pm, gv_switchvar])
+                                       gv_continue_compilation,
+                                       [gv_pm, gv_switchvar])
             exceptiondesc.genop_set_exc_type (default_builder, gv_exc_type )
             exceptiondesc.genop_set_exc_value(default_builder, gv_exc_value)
             linkargs = []



More information about the Pypy-commit mailing list