It&#39;s a little long for that, I was hoping people would request what is relevant. Here&#39;s some pertinent snippets (again, this is all an experiment, so it is not pretty).<br><br>jitdriver = JitDriver(greens=[&#39;pc&#39;, &#39;method&#39;], <br>
                      reds=[&#39;self&#39;],<br>                      virtualizables=[&#39;self&#39;],<br>                      get_printable_location=get_location)<br><br>class Frame:<br>    &quot;&quot;&quot; Represents one stack frame.&quot;&quot;&quot;<br>
    _immutable_fields_ = [&#39;space&#39;, &#39;method&#39;, &#39;opStack&#39;, &#39;scopeStack&#39;, &#39;locals&#39;]<br>    _virtualizable2_ = [&quot;locals[*]&quot;]<br>    def __init__(self, space, method):<br>        self = jit.hint(self, access_directly=True, fresh_virtualizable=True)<br>
        self.space = space<br>        self.method = method<br>        body = method.method_body<br>        self.opStack = [space.getUndefined()] * body.max_stack<br>        self.opCount = 0<br>        self.scopeStack = [space.getUndefined()] * body.max_scope_depth<br>
        self.scopeCount = 0<br>        self.locals = [space.getUndefined()] * body.local_count<br>    <br>    def dispatch(self):<br>        self = jit.hint(self, access_directly=True)<br>        pc = 0<br>        while True:<br>
            jitdriver.jit_merge_point(self=self, pc=pc, method=self.method)<br>            self.opCount = jit.hint(self.opCount, promote=True)<br>            self.scopeCount = jit.hint(self.scopeCount, promote=True)<br>            r, pc = self.handle_bytecode(pc)<br>
            if r is not None:<br>                return r    <br>def handle_bytecode(self, pc):<br>        &quot;&quot;&quot;Runs the interpreter for a single bytecode.<br>Returns (retvalue,pc) where retvalue is non-None if if the RETURNVALUE or RETURNVOID opcodes are run, and pc the new program counter.&quot;&quot;&quot;<br>
        bytecode = ord(self.method.method_body.code[pc])<br>        pc+=1<br>        if bytecode == Frame.LABEL:<br>
            pass<br>        elif bytecode == Frame.INCLOCAL_I:<br>            index, pc = readU30(self.method.method_body.code, pc)<br>            self.locals[force_non_neg(index)] = self.space.wrapInt(self.space.toInteger(self.locals[force_non_neg(index)]) + 1)<br>
        elif bytecode == Frame.GETLOCAL2:<br>            self.push(self.locals[2])<br>        elif bytecode == Frame.PUSHSHORT:<br>            i, pc = readU30(self.method.method_body.code, pc)<br>            self.push(self.space.wrapInt(i))<br>
        elif (bytecode == Frame.IFGE or<br>              bytecode == Frame.IFGT or<br>              bytecode == Frame.IFLE or<br>              bytecode == Frame.IFLT or<br>              bytecode == Frame.IFNGE or<br>              bytecode == Frame.IFNGT or<br>
              bytecode == Frame.IFNLE or<br>              bytecode == Frame.IFNLT):<br>            offset, pc = readSI24(self.method.method_body.code, pc)<br>            b = self.pop()<br>            a = self.pop()<br>            c = self.compare(a, b)<br>
            <br>            doBranch = False<br>            if c == -99:<br>                doBranch = False<br>            else:<br>                if   bytecode in (Frame.IFGE, Frame.IFNGE): doBranch = c &gt;= 0<br>                elif bytecode in (Frame.IFGT, Frame.IFNGT): doBranch = c &gt;  0<br>
                elif bytecode in (Frame.IFLE, Frame.IFNLE): doBranch = c &lt;= 0<br>                elif bytecode in (Frame.IFLT, Frame.IFNLT): doBranch = c &lt;  0<br>            if bytecode in (Frame.IFNGE,Frame.IFNGT,Frame.IFNLE,Frame.IFNLT):<br>
                doBranch = not doBranch<br>            if doBranch:<br>                pc += offset<br>                #jitdriver.can_enter_jit(self=self, pc=pc, method=self.method)<br><br><br><br><br><br><br>The bytecode in question:<br>
    L1: label           <br>        inclocal_i      2<br>    L0: getlocal2       <br>        pushshort       10000<br>        iflt            L1<br><br>(i.e. increment local variable 2 by 1, then compare it against 10000)<br>
<br><br><div class="gmail_quote">On Sat, Sep 17, 2011 at 6:25 PM, Benjamin Peterson <span dir="ltr">&lt;<a href="mailto:benjamin@python.org">benjamin@python.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
This would probably be easier if you showed us the code.<br>
<br>
2011/9/17 Boris &lt;<a href="mailto:boris2010@boristhebrave.com">boris2010@boristhebrave.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi,<br>
&gt;<br>
&gt; I&#39;ve been trying out writing my own interpreter using the PyPy framework<br>
&gt; recently, as a bit of fun. I&#39;ve been trying to get the JIT to optimize a<br>
&gt; trivial loop down to the minimal amount of operations. With judicious use of<br>
&gt; `_immutable_fields_` and `_virtualizable2_`, I&#39;ve got pretty close.<br>
&gt;<br>
&gt; But I&#39;m still seeing lots of calls to<br>
&gt; `ll_dict_lookup__dicttablePtr_Signed_Signed`, which don&#39;t correspond to any<br>
&gt; code in my interpreter. I don&#39;t think I even have any dicts that take<br>
&gt; integer keys. Could someone give me a hint where these are coming from and<br>
&gt; for what purpose? Or perhaps how to inspect the dicts or get further info?<br>
&gt;<br>
&gt; I append what I&#39;m seeing in the logs (Note: I&#39;ve augmented the logs to give<br>
&gt; the raw pointer). In this case, it is only looking up the value 21, but I&#39;ve<br>
&gt; seen other values in addition when running other programs. The<br>
&gt; setarrayitem_gc calls are expected - it is nulling out the stack that was<br>
&gt; being used. Everything from i17 is unexpected. I tested on revisions<br>
&gt; 00711ff1e03d and 96a212b0688a.<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Boris<br>
&gt;<br>
&gt;<br>
&gt; #############################<br>
&gt;<br>
&gt; [3fd12ea6569db] {jit-log-opt-loop<br>
&gt; # Loop 0 : loop with 37 ops<br>
&gt; [p0, p1, p2, i3, p4, p5]<br>
&gt; debug_merge_point(0, &#39;::Test$iinit:20&#39;)<br>
&gt; +113: i7 = int_add(i3, 1)<br>
&gt; debug_merge_point(0, &#39;::Test$iinit:22&#39;)<br>
&gt; debug_merge_point(0, &#39;::Test$iinit:23&#39;)<br>
&gt; debug_merge_point(0, &#39;::Test$iinit:26&#39;)<br>
&gt; +116: setarrayitem_gc(p5, 0, ConstPtr(ptr9,0x0), descr=&lt;GcPtrArrayDescr&gt;)<br>
&gt; +126: setarrayitem_gc(p5, 1, ConstPtr(ptr11,0x0), descr=&lt;GcPtrArrayDescr&gt;)<br>
&gt; +133: i13 = uint_lt(i7, 10000)<br>
&gt; guard_true(i13, descr=&lt;Guard2&gt;) [p0, p1, p2, p4, i7]<br>
&gt; +145: i17 = call(ConstClass(ll_dict_lookup__dicttablePtr_Signed_Signed),<br>
&gt; ConstPtr(ptr15,0x84c2958), 21, 21, descr=&lt;SignedCallDescr&gt;)<br>
&gt; +176: guard_no_exception(, descr=&lt;Guard3&gt;) [p0, i17, p1, p2, p4, i7]<br>
&gt; +189: i19 = int_and(i17, -<a href="tel:2147483648" value="+12147483648">2147483648</a>)<br>
&gt; +195: i20 = int_is_true(i19)<br>
&gt; guard_true(i20, descr=&lt;Guard4&gt;) [p0, p1, p2, p4, i7]<br>
&gt; +204: i23 = call(ConstClass(ll_dict_lookup__dicttablePtr_Signed_Signed),<br>
&gt; ConstPtr(ptr22,0x84c2978), 21, 21, descr=&lt;SignedCallDescr&gt;)<br>
&gt; +235: guard_no_exception(, descr=&lt;Guard5&gt;) [p0, i23, p1, p2, p4, i7]<br>
&gt; +248: i24 = int_and(i23, -<a href="tel:2147483648" value="+12147483648">2147483648</a>)<br>
&gt; +254: i25 = int_is_true(i24)<br>
&gt; guard_true(i25, descr=&lt;Guard6&gt;) [p0, p1, p2, p4, i7]<br>
&gt; +263: i28 = call(ConstClass(ll_dict_lookup__dicttablePtr_Signed_Signed),<br>
&gt; ConstPtr(ptr27,0x84c2988), 21, 21, descr=&lt;SignedCallDescr&gt;)<br>
&gt; +294: guard_no_exception(, descr=&lt;Guard7&gt;) [p0, i28, p1, p2, p4, i7]<br>
&gt; +307: i29 = int_and(i28, -2147483648)<br>
&gt; +313: i30 = int_is_true(i29)<br>
&gt; guard_true(i30, descr=&lt;Guard8&gt;) [p0, p1, p2, p4, i7]<br>
&gt; +322: i33 = call(ConstClass(ll_dict_lookup__dicttablePtr_Signed_Signed),<br>
&gt; ConstPtr(ptr32,0x84c2998), 21, 21, descr=&lt;SignedCallDescr&gt;)<br>
&gt; +353: guard_no_exception(, descr=&lt;Guard9&gt;) [p0, i33, p1, p2, p4, i7]<br>
&gt; +366: i34 = int_and(i33, -2147483648)<br>
&gt; +372: i35 = int_is_true(i34)<br>
&gt; guard_false(i35, descr=&lt;Guard10&gt;) [p0, p1, p2, p4, i7]<br>
&gt; +381: i38 = call(ConstClass(ll_dict_lookup__dicttablePtr_Signed_Signed),<br>
&gt; ConstPtr(ptr37,0x84c2968), 21, 21, descr=&lt;SignedCallDescr&gt;)<br>
&gt; +412: guard_no_exception(, descr=&lt;Guard11&gt;) [p0, i38, p1, p2, p4, i7]<br>
&gt; +425: i39 = int_and(i38, -2147483648)<br>
&gt; +431: i40 = int_is_true(i39)<br>
&gt; guard_true(i40, descr=&lt;Guard12&gt;) [p0, p1, p2, p4, i7]<br>
&gt; debug_merge_point(0, &#39;::Test$iinit:20&#39;)<br>
&gt; +440: i41 = arraylen_gc(p5, descr=&lt;GcPtrArrayDescr&gt;)<br>
&gt; +440: jump(p0, p1, p2, i7, p4, p5, descr=&lt;Loop0&gt;)<br>
&gt; +448: --end of the loop--<br>
&gt; [3fd12ea696ce9] jit-log-opt-loop}<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; pypy-dev mailing list<br>
&gt; <a href="mailto:pypy-dev@python.org">pypy-dev@python.org</a><br>
&gt; <a href="http://mail.python.org/mailman/listinfo/pypy-dev" target="_blank">http://mail.python.org/mailman/listinfo/pypy-dev</a><br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Regards,<br>
Benjamin<br>
</font></blockquote></div><br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>