Author: Maciej Fijalkowski <fij...@gmail.com> Branch: string-promote-2 Changeset: r47932:e7fbc95d83be Date: 2011-10-11 11:48 +0200 http://bitbucket.org/pypy/pypy/changeset/e7fbc95d83be/
Log: pyjitpl support, unfinished diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py --- a/pypy/jit/codewriter/jtransform.py +++ b/pypy/jit/codewriter/jtransform.py @@ -464,11 +464,13 @@ [S, S], lltype.Signed, EffectInfo.EF_ELIDABLE_CANNOT_RAISE) - descr = self.callcontrol.callinfocollection.callinfo_for_oopspec( - EffectInfo.OS_STREQ_NONNULL)[0] - op1 = SpaceOperation('str_guard_value', [op.args[0], descr], + descr, p = self.callcontrol.callinfocollection.callinfo_for_oopspec( + EffectInfo.OS_STREQ_NONNULL) + # XXX + c = Constant(p.adr.ptr, lltype.typeOf(p.adr.ptr)) + op1 = SpaceOperation('str_guard_value', [op.args[0], c, descr], op.result) - return op1 + return [SpaceOperation('-live-', [], None), op1, None] else: log.WARNING('ignoring hint %r at %r' % (hints, self.graph)) @@ -1439,7 +1441,6 @@ func = heaptracker.adr2int( llmemory.cast_ptr_to_adr(c_func.value)) self.callcontrol.callinfocollection.add(oopspecindex, calldescr, func) - return calldescr def _handle_stroruni_call(self, op, oopspec_name, args): SoU = args[0].concretetype # Ptr(STR) or Ptr(UNICODE) diff --git a/pypy/jit/codewriter/test/test_jtransform.py b/pypy/jit/codewriter/test/test_jtransform.py --- a/pypy/jit/codewriter/test/test_jtransform.py +++ b/pypy/jit/codewriter/test/test_jtransform.py @@ -858,7 +858,8 @@ tr = Transformer(FakeCPU(), FakeBuiltinCallControl()) op0 = tr.rewrite_operation(op) assert op0.opname == 'str_guard_value' - assert op0.args == [v1, 'calldescr'] + assert op0.args[0] == v1 + assert op0.args[2] == 'calldescr' assert op0.result == v2 def test_unicode_concat(): diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py --- a/pypy/jit/metainterp/blackhole.py +++ b/pypy/jit/metainterp/blackhole.py @@ -523,6 +523,9 @@ @arguments("f") def bhimpl_float_guard_value(a): pass + @arguments("r") + def bhimpl_str_guard_value(a): + pass @arguments("self", "i") def bhimpl_int_push(self, a): diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -166,11 +166,12 @@ def make_result_of_lastop(self, resultbox): got_type = resultbox.type - if not we_are_translated(): - typeof = {'i': history.INT, - 'r': history.REF, - 'f': history.FLOAT} - assert typeof[self.jitcode._resulttypes[self.pc]] == got_type + # XXX disabled for now, conflicts with str_guard_value + #if not we_are_translated(): + # typeof = {'i': history.INT, + # 'r': history.REF, + # 'f': history.FLOAT} + # assert typeof[self.jitcode._resulttypes[self.pc]] == got_type target_index = ord(self.bytecode[self.pc-1]) if got_type == history.INT: self.registers_i[target_index] = resultbox @@ -895,6 +896,17 @@ def _opimpl_guard_value(self, orgpc, box): self.implement_guard_value(orgpc, box) + @arguments("orgpc", "box", "box", "descr") + def opimpl_str_guard_value(self, orgpc, box, funcbox, descr): + if isinstance(box, Const): + return box # no promotion needed, already a Const + else: + constbox = box.constbox() + resbox = self.do_residual_call(funcbox, descr, [box, constbox]) + self.generate_guard(rop.GUARD_TRUE, resbox, resumepc=orgpc) + self.metainterp.replace_box(box, constbox) + return constbox + opimpl_int_guard_value = _opimpl_guard_value opimpl_ref_guard_value = _opimpl_guard_value opimpl_float_guard_value = _opimpl_guard_value diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py --- a/pypy/jit/metainterp/test/test_ajit.py +++ b/pypy/jit/metainterp/test/test_ajit.py @@ -13,7 +13,7 @@ from pypy.rlib.jit import (JitDriver, we_are_jitted, hint, dont_look_inside, loop_invariant, elidable, promote, jit_debug, assert_green, AssertGreenFailed, unroll_safe, current_trace_length, look_inside_iff, - isconstant, isvirtual) + isconstant, isvirtual, promote_string) from pypy.rlib.rarithmetic import ovfcheck from pypy.rpython.lltypesystem import lltype, llmemory, rffi from pypy.rpython.ootypesystem import ootype diff --git a/pypy/jit/metainterp/test/test_string.py b/pypy/jit/metainterp/test/test_string.py --- a/pypy/jit/metainterp/test/test_string.py +++ b/pypy/jit/metainterp/test/test_string.py @@ -3,7 +3,8 @@ from pypy.jit.codewriter.policy import StopAtXPolicy from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin from pypy.rlib.debug import debug_print -from pypy.rlib.jit import JitDriver, dont_look_inside, we_are_jitted +from pypy.rlib.jit import JitDriver, dont_look_inside, we_are_jitted,\ + promote_string from pypy.rlib.rstring import StringBuilder from pypy.rpython.ootypesystem import ootype @@ -507,6 +508,17 @@ 'jump': 1, 'int_is_true': 1, 'guard_not_invalidated': 1}) + def test_promote_string(self): + driver = JitDriver(greens = [], reds = ['n']) + + def f(n): + while n < 12: + driver.jit_merge_point(n=n) + promote_string(str(n % 3)) + n += 1 + return 0 + + self.meta_interp(f, [0]) #class TestOOtype(StringTests, OOJitMixin): # CALL = "oosend" diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -38,7 +38,7 @@ possible arguments are: * promote - promote the argument from a variable into a constant - * string_promote - same, but promote string by *value* + * promote_string - same, but promote string by *value* * access_directly - directly access a virtualizable, as a structure and don't treat it as a virtualizable * fresh_virtualizable - means that virtualizable was just allocated. _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit