[pypy-commit] pypy ppc-jit-backend: Implemented GUARD_CLASS and GUARD_NONNULL_CLASS.

hager noreply at buildbot.pypy.org
Fri Oct 21 17:17:04 CEST 2011


Author: hager <sven.hager at uni-duesseldorf.de>
Branch: ppc-jit-backend
Changeset: r48313:6c9c2b1b0146
Date: 2011-10-21 17:16 +0200
http://bitbucket.org/pypy/pypy/changeset/6c9c2b1b0146/

Log:	Implemented GUARD_CLASS and GUARD_NONNULL_CLASS.

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -214,6 +214,30 @@
     emit_guard_nonnull = emit_guard_true
     emit_guard_isnull = emit_guard_false
 
+    def _cmp_guard_class(self, op, locs, regalloc):
+        offset = locs[2]
+        if offset is not None:
+            if offset.is_imm():
+                self.mc.lwz(r.r0.value, locs[0].value, offset.value)
+            else:
+                self.mc.lwzx(r.r0.value, locs[0].value, offset.value)
+            self.mc.cmp(r.r0.value, locs[1].value)
+        else:
+            assert 0, "not implemented yet"
+        self._emit_guard(op, locs[3:], c.NE)
+
+    def emit_guard_class(self, op, arglocs, regalloc):
+        self._cmp_guard_class(op, arglocs, regalloc)
+
+    def emit_guard_nonnull_class(self, op, arglocs, regalloc):
+        offset = self.cpu.vtable_offset
+        self.mc.cmpi(arglocs[0].value, 0)
+        if offset is not None:
+            self._emit_guard(op, arglocs[3:], c.EQ)
+        else:
+            raise NotImplementedError
+        self._cmp_guard_class(op, arglocs, regalloc)
+
     def emit_finish(self, op, arglocs, regalloc):
         self.gen_exit_stub(op.getdescr(), op.getarglist(), arglocs)
 
diff --git a/pypy/jit/backend/ppc/ppcgen/regalloc.py b/pypy/jit/backend/ppc/ppcgen/regalloc.py
--- a/pypy/jit/backend/ppc/ppcgen/regalloc.py
+++ b/pypy/jit/backend/ppc/ppcgen/regalloc.py
@@ -11,7 +11,7 @@
                                                          prepare_binary_int_op_with_imm,
                                                          prepare_unary_cmp)
 from pypy.jit.metainterp.history import (INT, REF, FLOAT, Const, ConstInt, 
-                                         ConstPtr, LoopToken)
+                                         ConstPtr, LoopToken, Box)
 from pypy.jit.backend.llsupport.descr import BaseFieldDescr, BaseArrayDescr, \
                                              BaseCallDescr, BaseSizeDescr
 from pypy.jit.metainterp.resoperation import rop
@@ -299,6 +299,30 @@
         self.possibly_free_vars(op.getfailargs())
         return arglocs
 
+    def prepare_guard_class(self, op):
+        assert isinstance(op.getarg(0), Box)
+        boxes = list(op.getarglist())
+
+        x, x_box = self._ensure_value_is_boxed(boxes[0], boxes)
+        boxes.append(x_box)
+
+        t = TempInt()
+        y = self.force_allocate_reg(t, boxes)
+        boxes.append(t)
+        y_val = rffi.cast(lltype.Signed, op.getarg(1).getint())
+        self.assembler.load_imm(y.value, y_val)
+
+        offset = self.cpu.vtable_offset
+        assert offset is not None
+        offset_loc, offset_box = self._ensure_value_is_boxed(ConstInt(offset), boxes)
+        boxes.append(offset_box)
+        arglocs = self._prepare_guard(op, [x, y, offset_loc])
+        self.possibly_free_vars(boxes)
+        self.possibly_free_vars(op.getfailargs())
+        return arglocs
+
+    prepare_guard_nonnull_class = prepare_guard_class
+
     def prepare_jump(self, op):
         descr = op.getdescr()
         assert isinstance(descr, LoopToken)


More information about the pypy-commit mailing list