Author: Armin Rigo <[email protected]>
Branch:
Changeset: r44201:910bd8607819
Date: 2011-05-16 12:08 +0200
http://bitbucket.org/pypy/pypy/changeset/910bd8607819/
Log: merge heads
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -82,7 +82,7 @@
raise
def getaddrstring(self, space):
- # XXX slowish
+ # slowish
w_id = space.id(self)
w_4 = space.wrap(4)
w_0x0F = space.wrap(0x0F)
@@ -616,7 +616,6 @@
def createcompiler(self):
"Factory function creating a compiler object."
- # XXX simple selection logic for now
try:
return self.default_compiler
except AttributeError:
@@ -821,11 +820,11 @@
def call_obj_args(self, w_callable, w_obj, args):
if not self.config.objspace.disable_call_speedhacks:
- # XXX start of hack for performance
+ # start of hack for performance
from pypy.interpreter.function import Function
if isinstance(w_callable, Function):
return w_callable.call_obj_args(w_obj, args)
- # XXX end of hack for performance
+ # end of hack for performance
return self.call_args(w_callable, args.prepend(w_obj))
def call(self, w_callable, w_args, w_kwds=None):
@@ -835,7 +834,7 @@
def call_function(self, w_func, *args_w):
nargs = len(args_w) # used for pruning funccall versions
if not self.config.objspace.disable_call_speedhacks and nargs < 5:
- # XXX start of hack for performance
+ # start of hack for performance
from pypy.interpreter.function import Function, Method
if isinstance(w_func, Method):
w_inst = w_func.w_instance
@@ -850,7 +849,7 @@
if isinstance(w_func, Function):
return w_func.funccall(*args_w)
- # XXX end of hack for performance
+ # end of hack for performance
args = Arguments(self, list(args_w))
return self.call_args(w_func, args)
@@ -864,7 +863,7 @@
return self.call_args_and_c_profile(frame, w_func, args)
if not self.config.objspace.disable_call_speedhacks:
- # XXX start of hack for performance
+ # start of hack for performance
if isinstance(w_func, Method):
w_inst = w_func.w_instance
if w_inst is not None:
@@ -879,7 +878,7 @@
if isinstance(w_func, Function):
return w_func.funccall_valuestack(nargs, frame)
- # XXX end of hack for performance
+ # end of hack for performance
args = frame.make_arguments(nargs)
return self.call_args(w_func, args)
@@ -1338,7 +1337,7 @@
source = source.lstrip()
assert source.startswith('('), "incorrect header in:\n%s" % (source,)
source = py.code.Source("def anonymous%s\n" % source)
- w_glob = space.newdict()
+ w_glob = space.newdict(module=True)
space.exec_(str(source), w_glob, w_glob)
return space.getitem(w_glob, space.wrap('anonymous'))
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
@@ -626,3 +626,23 @@
rop.PTR_EQ: rop.PTR_EQ,
rop.PTR_NE: rop.PTR_NE,
}
+
+def get_deep_immutable_oplist(operations):
+ """
+ When not we_are_translated(), turns ``operations`` into a tuple and
+ monkey-patch its items to make sure they are not mutated.
+
+ When we_are_translated(), do nothing and just return the old list.
+ """
+ if we_are_translated():
+ return operations
+ #
+ def setarg(*args):
+ assert False, "operations cannot change at this point"
+ def setdescr(*args):
+ assert False, "operations cannot change at this point"
+ newops = tuple(operations)
+ for op in newops:
+ op.setarg = setarg
+ op.setdescr = setdescr
+ return newops
diff --git a/pypy/jit/metainterp/test/test_resoperation.py
b/pypy/jit/metainterp/test/test_resoperation.py
--- a/pypy/jit/metainterp/test/test_resoperation.py
+++ b/pypy/jit/metainterp/test/test_resoperation.py
@@ -68,3 +68,11 @@
call = rop.ResOperation(rop.rop.CALL, ['a', 'b'], 'c', descr=mydescr)
assert call.can_malloc()
assert not rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'], 'c').can_malloc()
+
+def test_get_deep_immutable_oplist():
+ ops = [rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'], 'c')]
+ newops = rop.get_deep_immutable_oplist(ops)
+ py.test.raises(AttributeError, "newops.append('foobar')")
+ py.test.raises(TypeError, "newops[0] = 'foobar'")
+ py.test.raises(AssertionError, "newops[0].setarg(0, 'd')")
+ py.test.raises(AssertionError, "newops[0].setdescr('foobar')")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit