[pypy-commit] pypy default: move SomeAddress and SomeTypedAddressAccess to rpython.rtyper
rlamy
noreply at buildbot.pypy.org
Sun Jan 26 19:56:33 CET 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r68953:6472d7d4cba1
Date: 2014-01-26 18:54 +0000
http://bitbucket.org/pypy/pypy/changeset/6472d7d4cba1/
Log: move SomeAddress and SomeTypedAddressAccess to rpython.rtyper
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -10,10 +10,11 @@
SomeDict, SomeOrderedDict, SomeUnicodeCodePoint, SomeUnicodeString,
SomeTuple, SomeImpossibleValue, s_ImpossibleValue, SomeInstance,
SomeBuiltin, SomeIterator, SomePBC, SomeFloat, s_None, SomeByteArray,
- SomeWeakRef, SomeAddress, SomeTypedAddressAccess, SomeSingleFloat,
+ SomeWeakRef, SomeSingleFloat,
SomeLongFloat, SomeType, SomeConstantType, unionof, UnionError,
read_can_only_throw, add_knowntypedata,
merge_knowntypedata,)
+from rpython.rtyper.llannotation import SomeAddress, SomeTypedAddressAccess
from rpython.annotator.bookkeeper import getbookkeeper
from rpython.flowspace.model import Variable, Constant
from rpython.flowspace.operation import op
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -9,10 +9,11 @@
from rpython.flowspace.model import Constant
from rpython.annotator.model import (SomeOrderedDict,
SomeString, SomeChar, SomeFloat, SomePtr, unionof, SomeInstance, SomeDict,
- SomeBuiltin, SomePBC, SomeInteger, TLS, SomeAddress, SomeUnicodeCodePoint,
+ SomeBuiltin, SomePBC, SomeInteger, TLS, SomeUnicodeCodePoint,
s_None, s_ImpossibleValue, SomeLLADTMeth, SomeBool, SomeTuple,
SomeImpossibleValue, SomeUnicodeString, SomeList, HarmlesslyBlocked,
SomeWeakRef, lltype_to_annotation, SomeType, SomeByteArray, SomeConstantType)
+from rpython.rtyper.llannotation import SomeAddress
from rpython.annotator.classdef import InstanceSource, ClassDef
from rpython.annotator.listdef import ListDef, ListItem
from rpython.annotator.dictdef import DictDef
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -5,11 +5,12 @@
from rpython.annotator.model import (
SomeInteger, SomeObject, SomeChar, SomeBool, SomeString, SomeTuple, s_Bool,
- SomeUnicodeCodePoint, SomeAddress, SomeFloat, unionof, SomeUnicodeString,
+ SomeUnicodeCodePoint, SomeFloat, unionof, SomeUnicodeString,
SomePBC, SomeInstance, SomeDict, SomeList, SomeWeakRef, SomeIterator,
SomeOrderedDict,
SomeByteArray, annotation_to_lltype, lltype_to_annotation,
ll_to_annotation, add_knowntypedata, s_ImpossibleValue,)
+from rpython.rtyper.llannotation import SomeAddress
from rpython.annotator.bookkeeper import getbookkeeper
from rpython.annotator import description
from rpython.flowspace.model import Constant
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -568,33 +568,6 @@
# 'classdef' is None for known-to-be-dead weakrefs.
self.classdef = classdef
-# ____________________________________________________________
-# memory addresses
-
-from rpython.rtyper.lltypesystem import llmemory
-
-
-class SomeAddress(SomeObject):
- immutable = True
-
- def can_be_none(self):
- return False
-
- def is_null_address(self):
- return self.is_immutable_constant() and not self.const
-
-
-# The following class is used to annotate the intermediate value that
-# appears in expressions of the form:
-# addr.signed[offset] and addr.signed[offset] = value
-
-class SomeTypedAddressAccess(SomeObject):
- def __init__(self, type):
- self.type = type
-
- def can_be_none(self):
- return False
-
#____________________________________________________________
# annotation of low-level types
@@ -630,6 +603,8 @@
return False
+from rpython.rtyper.llannotation import SomeAddress
+from rpython.rtyper.lltypesystem import llmemory
annotation_to_ll_map = [
(SomeSingleFloat(), lltype.SingleFloat),
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -9,9 +9,10 @@
from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool,
SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeFloat, SomeIterator,
- SomePBC, SomeTypedAddressAccess, SomeAddress, SomeType, s_ImpossibleValue,
+ SomePBC, SomeType, s_ImpossibleValue,
s_Bool, s_None, unionof, add_knowntypedata,
HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray)
+from rpython.rtyper.llannotation import SomeAddress, SomeTypedAddressAccess
from rpython.annotator.bookkeeper import getbookkeeper
from rpython.annotator import builtin
from rpython.annotator.binaryop import _clone ## XXX where to put this?
diff --git a/rpython/memory/gctransform/asmgcroot.py b/rpython/memory/gctransform/asmgcroot.py
--- a/rpython/memory/gctransform/asmgcroot.py
+++ b/rpython/memory/gctransform/asmgcroot.py
@@ -7,6 +7,7 @@
from rpython.rtyper.lltypesystem.lloperation import llop
from rpython.memory.gctransform.framework import (
BaseFrameworkGCTransformer, BaseRootWalker)
+from rpython.rtyper.llannotation import SomeAddress
from rpython.rtyper.rbuiltin import gen_cast
from rpython.translator.unsimplify import copyvar, varoftype
from rpython.translator.tool.cbuild import ExternalCompilationInfo
@@ -215,7 +216,7 @@
# update the global stack counter
rffi.stackcounter.stacks_counter += 1
#
- s_addr = annmodel.SomeAddress()
+ s_addr = SomeAddress()
s_None = annmodel.s_None
self.gc_detach_callback_pieces_ptr = getfn(gc_detach_callback_pieces,
[], s_addr)
@@ -327,10 +328,10 @@
inline=True)
self.thread_die_ptr = getfn(thread_die, [], annmodel.s_None)
self.thread_before_fork_ptr = getfn(thread_before_fork, [],
- annmodel.SomeAddress())
+ SomeAddress())
self.thread_after_fork_ptr = getfn(thread_after_fork,
[annmodel.SomeInteger(),
- annmodel.SomeAddress()],
+ SomeAddress()],
annmodel.s_None)
#
# check that the order of the need_*() is correct for us: if we
@@ -496,7 +497,7 @@
# location -- but we check for consistency that ebp points
# to a JITFRAME object.
from rpython.jit.backend.llsupport.jitframe import STACK_DEPTH_OFS
-
+
tid = self.gc.get_possibly_forwarded_type_id(ebp_in_caller)
ll_assert(rffi.cast(lltype.Signed, tid) ==
rffi.cast(lltype.Signed, self.frame_tid),
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -1,4 +1,5 @@
from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomeAddress
from rpython.rlib import rgc
from rpython.rtyper import rmodel, annlowlevel
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, llgroup
@@ -195,21 +196,11 @@
# the point of this little dance is to not annotate
# self.gcdata.static_root_xyz as constants. XXX is it still needed??
data_classdef = bk.getuniqueclassdef(gctypelayout.GCData)
- data_classdef.generalize_attr(
- 'static_root_start',
- annmodel.SomeAddress())
- data_classdef.generalize_attr(
- 'static_root_nongcend',
- annmodel.SomeAddress())
- data_classdef.generalize_attr(
- 'static_root_end',
- annmodel.SomeAddress())
- data_classdef.generalize_attr(
- 'max_type_id',
- annmodel.SomeInteger())
- data_classdef.generalize_attr(
- 'typeids_z',
- annmodel.SomeAddress())
+ data_classdef.generalize_attr('static_root_start', SomeAddress())
+ data_classdef.generalize_attr('static_root_nongcend', SomeAddress())
+ data_classdef.generalize_attr('static_root_end', SomeAddress())
+ data_classdef.generalize_attr('max_type_id', annmodel.SomeInteger())
+ data_classdef.generalize_attr('typeids_z', SomeAddress())
annhelper = annlowlevel.MixLevelHelperAnnotator(self.translator.rtyper)
@@ -310,13 +301,13 @@
self.collect_ptr = getfn(GCClass.collect.im_func,
[s_gc, annmodel.SomeInteger()], annmodel.s_None)
self.can_move_ptr = getfn(GCClass.can_move.im_func,
- [s_gc, annmodel.SomeAddress()],
+ [s_gc, SomeAddress()],
annmodel.SomeBool())
if hasattr(GCClass, 'shrink_array'):
self.shrink_array_ptr = getfn(
GCClass.shrink_array.im_func,
- [s_gc, annmodel.SomeAddress(),
+ [s_gc, SomeAddress(),
annmodel.SomeInteger(nonneg=True)], annmodel.s_Bool)
else:
self.shrink_array_ptr = None
@@ -333,7 +324,7 @@
if hasattr(GCClass, 'writebarrier_before_copy'):
self.wb_before_copy_ptr = \
getfn(GCClass.writebarrier_before_copy.im_func,
- [s_gc] + [annmodel.SomeAddress()] * 2 +
+ [s_gc] + [SomeAddress()] * 2 +
[annmodel.SomeInteger()] * 3, annmodel.SomeBool())
elif GCClass.needs_write_barrier:
raise NotImplementedError("GC needs write barrier, but does not provide writebarrier_before_copy functionality")
@@ -421,7 +412,7 @@
if getattr(GCClass, 'obtain_free_space', False):
self.obtainfreespace_ptr = getfn(GCClass.obtain_free_space.im_func,
[s_gc, annmodel.SomeInteger()],
- annmodel.SomeAddress())
+ SomeAddress())
if GCClass.moving_gc:
self.id_ptr = getfn(GCClass.id.im_func,
@@ -470,8 +461,7 @@
self.write_barrier_from_array_ptr = None
if GCClass.needs_write_barrier:
self.write_barrier_ptr = getfn(GCClass.write_barrier.im_func,
- [s_gc,
- annmodel.SomeAddress()],
+ [s_gc, SomeAddress()],
annmodel.s_None,
inline=True)
func = getattr(gcdata.gc, 'remember_young_pointer', None)
@@ -479,13 +469,12 @@
# func should not be a bound method, but a real function
assert isinstance(func, types.FunctionType)
self.write_barrier_failing_case_ptr = getfn(func,
- [annmodel.SomeAddress()],
+ [SomeAddress()],
annmodel.s_None)
func = getattr(GCClass, 'write_barrier_from_array', None)
if func is not None:
self.write_barrier_from_array_ptr = getfn(func.im_func,
- [s_gc,
- annmodel.SomeAddress(),
+ [s_gc, SomeAddress(),
annmodel.SomeInteger()],
annmodel.s_None,
inline=True)
@@ -497,7 +486,7 @@
assert isinstance(func, types.FunctionType)
self.write_barrier_from_array_failing_case_ptr = \
getfn(func,
- [annmodel.SomeAddress()],
+ [SomeAddress()],
annmodel.s_None)
diff --git a/rpython/memory/gctransform/shadowstack.py b/rpython/memory/gctransform/shadowstack.py
--- a/rpython/memory/gctransform/shadowstack.py
+++ b/rpython/memory/gctransform/shadowstack.py
@@ -5,6 +5,7 @@
from rpython.rtyper import rmodel
from rpython.rtyper.annlowlevel import llhelper
from rpython.rtyper.lltypesystem import lltype, llmemory
+from rpython.rtyper.llannotation import SomeAddress
from rpython.memory.gctransform.framework import (
BaseFrameworkGCTransformer, BaseRootWalker, sizeofaddr)
from rpython.rtyper.rbuiltin import gen_cast
@@ -14,11 +15,11 @@
def annotate_walker_functions(self, getfn):
self.incr_stack_ptr = getfn(self.root_walker.incr_stack,
[annmodel.SomeInteger()],
- annmodel.SomeAddress(),
+ SomeAddress(),
inline = True)
self.decr_stack_ptr = getfn(self.root_walker.decr_stack,
[annmodel.SomeInteger()],
- annmodel.SomeAddress(),
+ SomeAddress(),
inline = True)
def build_root_walker(self):
@@ -211,7 +212,7 @@
# no thread_before_fork_ptr here
self.thread_after_fork_ptr = getfn(thread_after_fork,
[annmodel.SomeInteger(),
- annmodel.SomeAddress()],
+ SomeAddress()],
annmodel.s_None,
minimal_transform=False)
@@ -242,7 +243,7 @@
shadow_stack_pool.start_fresh_new_state()
s_gcref = annmodel.SomePtr(llmemory.GCREF)
- s_addr = annmodel.SomeAddress()
+ s_addr = SomeAddress()
self.gc_shadowstackref_new_ptr = getfn(gc_shadowstackref_new,
[], s_gcref,
minimal_transform=False)
diff --git a/rpython/rtyper/lltypesystem/llmemory.py b/rpython/rtyper/lltypesystem/llmemory.py
--- a/rpython/rtyper/lltypesystem/llmemory.py
+++ b/rpython/rtyper/lltypesystem/llmemory.py
@@ -905,11 +905,12 @@
_about_ = raw_memmove
def compute_result_annotation(self, s_from, s_to, s_size):
- from rpython.annotator.model import SomeAddress, SomeInteger
+ from rpython.annotator.model import SomeInteger
+ from rpython.rtyper.llannotation import SomeAddress
assert isinstance(s_from, SomeAddress)
assert isinstance(s_to, SomeAddress)
assert isinstance(s_size, SomeInteger)
-
+
def specialize_call(self, hop):
hop.exception_cannot_occur()
v_list = hop.inputargs(Address, Address, lltype.Signed)
diff --git a/rpython/rtyper/raddress.py b/rpython/rtyper/raddress.py
--- a/rpython/rtyper/raddress.py
+++ b/rpython/rtyper/raddress.py
@@ -1,5 +1,5 @@
# rtyping of memory address operations
-from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomeAddress, SomeTypedAddressAccess
from rpython.rlib.rarithmetic import r_uint
from rpython.rtyper.lltypesystem import lltype
from rpython.rtyper.lltypesystem.llmemory import (NULL, Address,
@@ -9,14 +9,14 @@
from rpython.tool.pairtype import pairtype
-class __extend__(annmodel.SomeAddress):
+class __extend__(SomeAddress):
def rtyper_makerepr(self, rtyper):
return address_repr
def rtyper_makekey(self):
return self.__class__,
-class __extend__(annmodel.SomeTypedAddressAccess):
+class __extend__(SomeTypedAddressAccess):
def rtyper_makerepr(self, rtyper):
return TypedAddressAccessRepr(self.type)
diff --git a/rpython/rtyper/test/test_nongc.py b/rpython/rtyper/test/test_nongc.py
--- a/rpython/rtyper/test/test_nongc.py
+++ b/rpython/rtyper/test/test_nongc.py
@@ -1,6 +1,7 @@
import py
from rpython.annotator import model as annmodel
+from rpython.rtyper.llannotation import SomeAddress
from rpython.annotator.annrpython import RPythonAnnotator
from rpython.rtyper.rtyper import RPythonTyper
from rpython.rlib.objectmodel import free_non_gc_object
@@ -25,7 +26,7 @@
assert t.method2() == 42
free_non_gc_object(t)
py.test.raises(RuntimeError, "t.method1()")
- py.test.raises(RuntimeError, "t.method2()")
+ py.test.raises(RuntimeError, "t.method2()")
py.test.raises(RuntimeError, "t.a")
py.test.raises(RuntimeError, "t.a = 1")
py.test.raises(AssertionError, "free_non_gc_object(TestClass2())")
@@ -43,8 +44,8 @@
rtyper = RPythonTyper(a)
rtyper.specialize()
assert (Adef, 'raw') in rtyper.instance_reprs
- assert (Adef, 'gc') not in rtyper.instance_reprs
-
+ assert (Adef, 'gc') not in rtyper.instance_reprs
+
def test_alloc_flavor_subclassing():
class A:
_alloc_flavor_ = "raw"
@@ -64,7 +65,7 @@
assert (Adef, 'raw') in rtyper.instance_reprs
assert (Adef, 'gc') not in rtyper.instance_reprs
assert (Bdef, 'raw') in rtyper.instance_reprs
- assert (Bdef, 'gc') not in rtyper.instance_reprs
+ assert (Bdef, 'gc') not in rtyper.instance_reprs
def test_unsupported():
class A:
@@ -85,7 +86,7 @@
pass
class C(B):
pass
-
+
def f(i):
if i == 0:
o = None
@@ -226,7 +227,7 @@
return b
a = RPythonAnnotator()
#does not raise:
- s = a.build_types(malloc_and_free, [annmodel.SomeAddress()])
- assert isinstance(s, annmodel.SomeAddress)
+ s = a.build_types(malloc_and_free, [SomeAddress()])
+ assert isinstance(s, SomeAddress)
rtyper = RPythonTyper(a)
rtyper.specialize()
More information about the pypy-commit
mailing list