Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r59638:4c7349220b47
Date: 2012-12-31 13:33 +0200
http://bitbucket.org/pypy/pypy/changeset/4c7349220b47/
Log: merge missing-jit-operations, add a few jit operations
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
@@ -304,6 +304,8 @@
rewrite_op_convert_float_bytes_to_longlong = _noop_rewrite
rewrite_op_convert_longlong_bytes_to_float = _noop_rewrite
+ cast_ptr_to_weakrefptr = _noop_rewrite
+ cast_weakrefptr_to_ptr = _noop_rewrite
# ----------
# Various kinds of calls
@@ -450,6 +452,7 @@
resulttype, extra, extrakey)
return SpaceOperation('direct_call', [c_func] + args, op.result)
+
def _do_builtin_call(self, op, oopspec_name=None, args=None,
extra=None, extrakey=None):
if oopspec_name is None: oopspec_name = op.opname
@@ -482,6 +485,9 @@
rewrite_op_uint_mod = _do_builtin_call
rewrite_op_cast_float_to_uint = _do_builtin_call
rewrite_op_cast_uint_to_float = _do_builtin_call
+ rewrite_op_weakref_create = _do_builtin_call
+ rewrite_op_weakref_deref = _do_builtin_call
+ rewrite_op_gc_add_memory_pressure = _do_builtin_call
# ----------
# getfield/setfield/mallocs etc.
diff --git a/pypy/jit/codewriter/support.py b/pypy/jit/codewriter/support.py
--- a/pypy/jit/codewriter/support.py
+++ b/pypy/jit/codewriter/support.py
@@ -1,15 +1,13 @@
import sys
-from pypy.rpython.lltypesystem import lltype, rclass, rffi
+from pypy.rpython.lltypesystem import lltype, rclass, rffi, llmemory
from pypy.rpython.ootypesystem import ootype
from pypy.rpython import rlist
from pypy.rpython.lltypesystem import rstr as ll_rstr, rdict as ll_rdict
-from pypy.rpython.lltypesystem import rlist as lltypesystem_rlist
from pypy.rpython.lltypesystem.module import ll_math
from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rpython.ootypesystem import rdict as oo_rdict
from pypy.rpython.llinterp import LLInterpreter
from pypy.rpython.extregistry import ExtRegistryEntry
-from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
from pypy.translator.simplify import get_funcobj
from pypy.translator.unsimplify import split_block
from pypy.objspace.flow.model import Constant
@@ -648,6 +646,15 @@
build_ll_1_raw_free_no_track_allocation = (
build_raw_free_builder(track_allocation=False))
+ def _ll_1_weakref_create(obj):
+ return llop.weakref_create(llmemory.WeakRefPtr, obj)
+
+ def _ll_1_weakref_deref(TP, obj):
+ return llop.weakref_deref(lltype.Ptr(TP), obj)
+ _ll_1_weakref_deref.need_result_type = True
+
+ def _ll_1_gc_add_memory_pressure(num):
+ llop.gc_add_memory_pressure(lltype.Void, num)
class OOtypeHelpers:
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
@@ -1,24 +1,19 @@
-import math
import sys
import py
-from pypy import conftest
-from pypy.jit.codewriter import longlong
-from pypy.jit.codewriter.policy import JitPolicy, StopAtXPolicy
-from pypy.jit.metainterp import pyjitpl, history
-from pypy.jit.metainterp.optimizeopt import ALL_OPTS_DICT
+from pypy.jit.codewriter.policy import StopAtXPolicy
+from pypy.jit.metainterp import history
from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin, noConst
-from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
from pypy.jit.metainterp.warmspot import get_stats
from pypy.rlib import rerased
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, promote_string, set_param, record_known_class)
+ isconstant, isvirtual, set_param, record_known_class)
from pypy.rlib.longlong2float import float2longlong, longlong2float
from pypy.rlib.rarithmetic import ovfcheck, is_valid_int
-from pypy.rpython.lltypesystem import lltype, llmemory, rffi
+from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rpython.ootypesystem import ootype
@@ -3962,3 +3957,27 @@
return 42
self.interp_operations(f, [1, 2, 3])
self.check_operations_history(call=1, guard_no_exception=0)
+
+ def test_weakref(self):
+ import weakref
+
+ class A(object):
+ def __init__(self, x):
+ self.x = x
+
+ def f(i):
+ a = A(i)
+ w = weakref.ref(a)
+ return w().x + a.x
+
+ assert self.interp_operations(f, [3]) == 6
+
+ def test_gc_add_memory_pressure(self):
+ from pypy.rlib import rgc
+
+ def f():
+ rgc.add_memory_pressure(1234)
+ return 3
+
+ self.interp_operations(f, [])
+
diff --git a/pypy/rpython/lltypesystem/lltype.py
b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1456,7 +1456,7 @@
return _ptr(Ptr(self._TYPE), self, True)
def _as_obj(self, check=True):
return self
- def _normalizedcontainer(self):
+ def _normalizedcontainer(self, check=True):
return self
def _getid(self):
return id(self)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit