Author: Richard Plangger <[email protected]>
Branch: s390x-backend
Changeset: r82637:9eab49cb6677
Date: 2016-03-01 15:45 +0100
http://bitbucket.org/pypy/pypy/changeset/9eab49cb6677/

Log:    trying to translate the current interpreter in a test and later feed
        it with hypothesis. in addition fixed a bug that occurs while
        emitting jump. the assembled loop is too long, and BRC could not
        reach the top. thus BRCL is emitted if needed

diff --git a/rpython/jit/backend/llsupport/tl/interp.py 
b/rpython/jit/backend/llsupport/tl/interp.py
--- a/rpython/jit/backend/llsupport/tl/interp.py
+++ b/rpython/jit/backend/llsupport/tl/interp.py
@@ -1,6 +1,7 @@
 from rpython.rlib.rstruct.runpack import runpack
 from rpython.rlib.objectmodel import specialize, always_inline
-from rpython.jit.backend.llsupport.tl import code, stack
+from rpython.jit.backend.llsupport.tl import code
+from rpython.jit.backend.llsupport.tl.stack import Stack
 
 class W_Root(object):
     pass
@@ -9,25 +10,28 @@
     def __init__(self, items):
         self.items = items
 
-    def concat(self, w_lst):
+    def concat(self, space, w_lst):
         assert isinstance(w_lst, W_ListObject)
-        return self.items + w_lst.items
+        return space.wrap(self.items + w_lst.items)
 
 class W_IntObject(W_Root):
     def __init__(self, value):
         self.value = value
 
-    def compare(self, w_int):
+    def compare(self, space, w_int):
         assert isinstance(w_int, W_IntObject)
-        return cmp(self.value, w_int.value)
+        return space.wrap(self.value - w_int.value)
+
+    def concat(self, space, w_obj):
+        raise NotImplementedError("cannot concat int with object")
 
 class W_StrObject(W_Root):
     def __init__(self, value):
         self.value = value
 
-    def concat(self, w_str):
+    def concat(self, space, w_str):
         assert isinstance(w_str, W_StrObject)
-        return self.value + w_str.value
+        return space.wrap(self.value + w_str.value)
 
 class Space(object):
     @specialize.argtype(1)
@@ -42,17 +46,18 @@
             return W_StrObject(val.encode('utf-8'))
         if isinstance(val, list):
             return W_ListObject(val)
-        raise NotImplementedError("cannot handle: " + str(val) + 
str(type(val)))
+        raise NotImplementedError("cannot handle: " + str(val))
 
 def entry_point(argv):
     bytecode = argv[0]
     pc = 0
     end = len(bytecode)
     stack = Stack(16)
-    space = space.Space()
-    consts = []
-    while i < end:
-        i = dispatch_once(space, i, bytecode, consts, stack)
+    space = Space()
+    consts = ["hello"] * 100
+    consts[0] = "world"
+    while pc < end:
+        pc = dispatch_once(space, pc, bytecode, consts, stack)
     return 0
 
 @always_inline
@@ -65,8 +70,7 @@
     elif opcode == code.CompareInt.BYTE_CODE:
         w_int2 = stack.pop()
         w_int1 = stack.pop()
-        w_int3 = space.wrap(w_int1.compare(w_int2))
-        stack.append(w_int3)
+        stack.append(w_int1.compare(space, w_int2))
     elif opcode == code.LoadStr.BYTE_CODE:
         pos = runpack('h', bytecode[i+1:i+3])
         w_str = space.wrap(consts[pos])
@@ -75,11 +79,11 @@
     elif opcode == code.AddStr.BYTE_CODE:
         w_str2 = stack.pop()
         w_str1 = stack.pop()
-        stack.append(space.wrap(w_str1.concat(w_str2)))
+        stack.append(w_str1.concat(space, w_str2))
     elif opcode == code.AddList.BYTE_CODE:
         w_lst2 = stack.pop()
         w_lst1 = stack.pop()
-        stack.append(space.wrap(w_lst1.concat(w_lst2)))
+        stack.append(w_lst1.concat(space, w_lst2))
     elif opcode == code.CreateList.BYTE_CODE:
         size = runpack('h', bytecode[i+1:i+3])
         stack.append(space.wrap([None] * size))
@@ -91,11 +95,13 @@
     elif opcode == code.InsertList.BYTE_CODE:
         w_val = stack.pop()
         w_idx = stack.pop()
+        assert isinstance(w_idx, W_IntObject)
         w_lst = stack.peek(0)
         w_lst.items[w_idx.value] = w_val
         # index error, just crash here!
     elif opcode == code.DelList.BYTE_CODE:
         w_idx = stack.pop()
+        assert isinstance(w_idx, W_IntObject)
         w_lst = stack.peek(0)
         del w_lst.items[w_idx.value]
         # index error, just crash the machine!!
diff --git a/rpython/jit/backend/llsupport/tl/stack.py 
b/rpython/jit/backend/llsupport/tl/stack.py
--- a/rpython/jit/backend/llsupport/tl/stack.py
+++ b/rpython/jit/backend/llsupport/tl/stack.py
@@ -5,7 +5,7 @@
 
     def __init__(self, size):
         self = hint(self, access_directly=True, fresh_virtualizable=True)
-        self.stack = [0] * size
+        self.stack = [None] * size
         self.stackpos = 0        # always store a known-nonneg integer here
 
     def size(self):
diff --git a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py 
b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py
--- a/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py
+++ b/rpython/jit/backend/llsupport/tl/test/zrpy_gc_hypo_test.py
@@ -10,7 +10,7 @@
 from rpython.translator.unsimplify import call_initial_function
 from rpython.translator.translator import TranslationContext
 from rpython.translator.c import genc
-from rpython.jit.backend.llsupport.gcstress import interp
+from rpython.jit.backend.llsupport.tl import interp
 
 class GCHypothesis(object):
     def setup_class(self):
diff --git a/rpython/jit/backend/zarch/codebuilder.py 
b/rpython/jit/backend/zarch/codebuilder.py
--- a/rpython/jit/backend/zarch/codebuilder.py
+++ b/rpython/jit/backend/zarch/codebuilder.py
@@ -128,7 +128,11 @@
 
     def b_offset(self, reladdr):
         offset = reladdr - self.get_relative_pos()
-        self.BRC(c.ANY, l.imm(offset))
+        if -2**15 <= offset <= 2**15-1:
+            self.BRC(c.ANY, l.imm(offset))
+        else:
+            # we have big loops!
+            self.BRCL(c.ANY, l.imm(offset))
 
     def reserve_guard_branch(self):
         self.BRCL(l.imm(0x0), l.imm(0))
diff --git a/rpython/jit/backend/zarch/test/test_zrpy_gc_hypo.py 
b/rpython/jit/backend/zarch/test/test_zrpy_gc_hypo.py
--- a/rpython/jit/backend/zarch/test/test_zrpy_gc_hypo.py
+++ b/rpython/jit/backend/zarch/test/test_zrpy_gc_hypo.py
@@ -1,7 +1,6 @@
-from rpython.jit.backend.llsupport.gcstress.test.zrpy_gc_hypo_test import 
GCHypothesis
-
+from rpython.jit.backend.llsupport.tl.test.zrpy_gc_hypo_test import 
GCHypothesis
 
 class TestGCHypothesis(GCHypothesis):
-    # runs ../../llsupport/gcstress/test/zrpy_gc_hypo_test.py
+    # runs ../../llsupport/tl/test/zrpy_gc_hypo_test.py
     gcrootfinder = "shadowstack"
     gc = "incminimark"
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to