[pypy-svn] pypy 32ptr-on-64bit: In-progress: add HIDE_INTO_PTR32 and SHOW_FROM_PTR32 as explicit
arigo
commits-noreply at bitbucket.org
Sat Apr 16 12:29:57 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: 32ptr-on-64bit
Changeset: r43396:0b1a8ed1bd80
Date: 2011-04-16 11:50 +0200
http://bitbucket.org/pypy/pypy/changeset/0b1a8ed1bd80/
Log: In-progress: add HIDE_INTO_PTR32 and SHOW_FROM_PTR32 as explicit
operations, inserted by llsupport.gc.
diff --git a/pypy/jit/metainterp/test/support.py b/pypy/jit/metainterp/test/support.py
--- a/pypy/jit/metainterp/test/support.py
+++ b/pypy/jit/metainterp/test/support.py
@@ -1,4 +1,3 @@
-
import py, sys
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython.ootypesystem import ootype
@@ -10,6 +9,9 @@
from pypy.jit.codewriter.policy import JitPolicy
from pypy.jit.codewriter import longlong
+class SkipThisRun(Exception):
+ pass
+
def _get_jitcodes(testself, CPUClass, func, values, type_system,
supports_longlong=False, **kwds):
from pypy.jit.codewriter import support, codewriter
@@ -112,6 +114,8 @@
#if conftest.option.view:
# metainterp.stats.view()
return e.args[0]
+ except SkipThisRun:
+ return NotImplemented
else:
raise Exception("FAILED")
@@ -180,10 +184,11 @@
result1 = _run_with_blackhole(self, args)
# try to run it with pyjitpl.py
result2 = _run_with_pyjitpl(self, args)
- assert result1 == result2
- # try to run it by running the code compiled just before
- result3 = _run_with_machine_code(self, args)
- assert result1 == result3 or result3 == NotImplemented
+ if result2 != NotImplemented:
+ assert result1 == result2
+ # try to run it by running the code compiled just before
+ result3 = _run_with_machine_code(self, args)
+ assert result1 == result3 or result3 == NotImplemented
#
if (longlong.supports_longlong and
isinstance(result1, longlong.r_float_storage)):
diff --git a/pypy/jit/metainterp/resoperation.py b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -445,6 +445,9 @@
#'INSTANCEOF/1db',
#'SUBCLASSOF/2b',
#
+ # backend-only operations
+ 'HIDE_INTO_PTR32/1',
+ 'SHOW_FROM_PTR32/1',
'_ALWAYS_PURE_LAST', # ----- end of always_pure operations -----
'GETARRAYITEM_GC/2d',
diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -1,4 +1,4 @@
-import os
+import os, py
from pypy.rlib import rgc
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.debug import fatalerror
@@ -17,6 +17,8 @@
from pypy.jit.backend.llsupport.descr import GcCache, get_field_descr
from pypy.jit.backend.llsupport.descr import GcPtrFieldDescr
from pypy.jit.backend.llsupport.descr import get_call_descr
+from pypy.jit.backend.llsupport.descr import GcPtrHidden32FieldDescr
+from pypy.jit.backend.llsupport.descr import GcPtrHidden32ArrayDescr
from pypy.rpython.memory.gctransform import asmgcroot
# ____________________________________________________________
@@ -36,7 +38,13 @@
def do_write_barrier(self, gcref_struct, gcref_newptr):
pass
def rewrite_assembler(self, cpu, operations):
- pass
+ if not we_are_translated():
+ # skip non-translated tests (using Boehm) if compressed ptrs
+ for op in operations:
+ if (isinstance(op.getdescr(), GcPtrHidden32FieldDescr) or
+ isinstance(op.getdescr(), GcPtrHidden32ArrayDescr)):
+ from pypy.jit.metainterp.test.support import SkipThisRun
+ raise SkipThisRun("non-translated test with compressptr")
def can_inline_malloc(self, descr):
return False
def can_inline_malloc_varsize(self, descr, num_elem):
@@ -579,6 +587,7 @@
self.single_gcref_descr = GcPtrFieldDescr('', 0)
self.supports_compressed_ptrs = gcdescr.config.translation.compressptr
if self.supports_compressed_ptrs:
+ assert WORD == 8
assert rffi.sizeof(rffi.UINT)==rffi.sizeof(llmemory.HiddenGcRef32)
# make a TransformerLayoutBuilder and save it on the translator
@@ -773,7 +782,7 @@
llmemory.cast_ptr_to_adr(gcref_newptr))
def rewrite_assembler(self, cpu, operations):
- # Perform two kinds of rewrites in parallel:
+ # Perform three kinds of rewrites in parallel:
#
# - Add COND_CALLs to the write barrier before SETFIELD_GC and
# SETARRAYITEM_GC operations.
@@ -786,6 +795,9 @@
# replace direct usage of ConstPtr with a BoxPtr loaded by a
# GETFIELD_RAW from the array 'gcrefs.list'.
#
+ # - For compressptr, add explicit HIDE_INTO_PTR32 and
+ # SHOW_FROM_PTR32 operations.
+ #
newops = []
# we can only remember one malloc since the next malloc can possibly
# collect
@@ -833,6 +845,30 @@
# write_barrier_from_array
self._gen_write_barrier(newops, op.getarg(0), v)
op = op.copy_and_change(rop.SETARRAYITEM_RAW)
+ # ---------- compressptr support ----------
+ if (self.supports_compressed_ptrs and
+ (isinstance(op.getdescr(), GcPtrHidden32FieldDescr) or
+ isinstance(op.getdescr(), GcPtrHidden32ArrayDescr))):
+ num = op.getopnum()
+ if (num == rop.GETFIELD_GC or
+ num == rop.GETFIELD_GC_PURE or
+ num == rop.GETARRAYITEM_GC or
+ num == rop.GETARRAYITEM_GC_PURE):
+ v1 = BoxInt()
+ v2 = op.result
+ newops.append(op.copy_and_change(num, result=v1))
+ op = ResOperation(rop.SHOW_FROM_PTR32, [v1], v2)
+ elif num == rop.SETFIELD_GC or num == rop.SETFIELD_RAW:
+ v1 = op.getarg(1)
+ v2 = BoxInt()
+ newops.append(ResOperation(rop.HIDE_INTO_PTR32, [v1], v2))
+ op = op.copy_and_change(num, args=[op.getarg(0), v2])
+ elif num == rop.SETARRAYITEM_GC or num == rop.SETARRAYITEM_RAW:
+ v1 = op.getarg(2)
+ v2 = BoxInt()
+ newops.append(ResOperation(rop.HIDE_INTO_PTR32, [v1], v2))
+ op = op.copy_and_change(num, args=[op.getarg(0),
+ op.getarg(1), v2])
# ----------
newops.append(op)
del operations[:]
diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py
--- a/pypy/jit/metainterp/executor.py
+++ b/pypy/jit/metainterp/executor.py
@@ -312,6 +312,8 @@
rop.DEBUG_MERGE_POINT,
rop.JIT_DEBUG,
rop.SETARRAYITEM_RAW,
+ rop.HIDE_INTO_PTR32,
+ rop.SHOW_FROM_PTR32,
): # list of opcodes never executed by pyjitpl
continue
raise AssertionError("missing %r" % (key,))
More information about the Pypy-commit
mailing list