[pypy-svn] r79126 - in pypy/release/1.4.x: . pypy pypy/jit/codewriter pypy/jit/codewriter/test pypy/jit/metainterp pypy/jit/metainterp/optimizeopt pypy/jit/metainterp/test pypy/module/array/benchmark pypy/module/array/test pypy/rlib pypy/rlib/test
fijal at codespeak.net
fijal at codespeak.net
Mon Nov 15 20:08:33 CET 2010
Author: fijal
Date: Mon Nov 15 20:08:31 2010
New Revision: 79126
Modified:
pypy/release/1.4.x/ (props changed)
pypy/release/1.4.x/pypy/ (props changed)
pypy/release/1.4.x/pypy/jit/codewriter/assembler.py
pypy/release/1.4.x/pypy/jit/codewriter/call.py
pypy/release/1.4.x/pypy/jit/codewriter/codewriter.py
pypy/release/1.4.x/pypy/jit/codewriter/effectinfo.py
pypy/release/1.4.x/pypy/jit/codewriter/jtransform.py
pypy/release/1.4.x/pypy/jit/codewriter/test/test_jtransform.py
pypy/release/1.4.x/pypy/jit/metainterp/optimizeopt/optimizer.py (props changed)
pypy/release/1.4.x/pypy/jit/metainterp/optimizeopt/string.py
pypy/release/1.4.x/pypy/jit/metainterp/pyjitpl.py
pypy/release/1.4.x/pypy/jit/metainterp/resume.py
pypy/release/1.4.x/pypy/jit/metainterp/test/test_optimizeopt.py
pypy/release/1.4.x/pypy/jit/metainterp/test/test_resume.py
pypy/release/1.4.x/pypy/jit/metainterp/test/test_virtualref.py
pypy/release/1.4.x/pypy/module/array/benchmark/Makefile (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/intimg.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/intimgtst.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/intimgtst.py (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/loop.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/sum.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/sumtst.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/sumtst.py (props changed)
pypy/release/1.4.x/pypy/module/array/test/test_array_old.py (props changed)
pypy/release/1.4.x/pypy/rlib/rerased.py (props changed)
pypy/release/1.4.x/pypy/rlib/test/test_rerased.py (props changed)
Log:
merge 79004 from trunk
Modified: pypy/release/1.4.x/pypy/jit/codewriter/assembler.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/codewriter/assembler.py (original)
+++ pypy/release/1.4.x/pypy/jit/codewriter/assembler.py Mon Nov 15 20:08:31 2010
@@ -233,10 +233,9 @@
addr = llmemory.cast_ptr_to_adr(value)
self.list_of_addr2name.append((addr, name))
- def finished(self):
+ def finished(self, callinfocollection):
# Helper called at the end of assembling. Registers the extra
# functions shown in _callinfo_for_oopspec.
- from pypy.jit.codewriter.effectinfo import _callinfo_for_oopspec
- for _, func in _callinfo_for_oopspec.values():
+ for func in callinfocollection.all_function_addresses_as_int():
func = heaptracker.int2adr(func)
self.see_raw_object(func.ptr)
Modified: pypy/release/1.4.x/pypy/jit/codewriter/call.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/codewriter/call.py (original)
+++ pypy/release/1.4.x/pypy/jit/codewriter/call.py Mon Nov 15 20:08:31 2010
@@ -7,7 +7,7 @@
from pypy.jit.codewriter.jitcode import JitCode
from pypy.jit.codewriter.effectinfo import VirtualizableAnalyzer
from pypy.jit.codewriter.effectinfo import effectinfo_from_writeanalyze
-from pypy.jit.codewriter.effectinfo import EffectInfo
+from pypy.jit.codewriter.effectinfo import EffectInfo, CallInfoCollection
from pypy.translator.simplify import get_funcobj, get_functype
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.translator.backendopt.canraise import RaiseAnalyzer
@@ -23,6 +23,7 @@
self.jitdrivers_sd = jitdrivers_sd
self.jitcodes = {} # map {graph: jitcode}
self.unfinished_graphs = [] # list of graphs with pending jitcodes
+ self.callinfocollection = CallInfoCollection()
if hasattr(cpu, 'rtyper'): # for tests
self.rtyper = cpu.rtyper
translator = self.rtyper.annotator.translator
Modified: pypy/release/1.4.x/pypy/jit/codewriter/codewriter.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/codewriter/codewriter.py (original)
+++ pypy/release/1.4.x/pypy/jit/codewriter/codewriter.py Mon Nov 15 20:08:31 2010
@@ -73,7 +73,7 @@
count += 1
if not count % 500:
log.info("Produced %d jitcodes" % count)
- self.assembler.finished()
+ self.assembler.finished(self.callcontrol.callinfocollection)
heaptracker.finish_registering(self.cpu)
log.info("there are %d JitCode instances." % count)
Modified: pypy/release/1.4.x/pypy/jit/codewriter/effectinfo.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/codewriter/effectinfo.py (original)
+++ pypy/release/1.4.x/pypy/jit/codewriter/effectinfo.py Mon Nov 15 20:08:31 2010
@@ -144,30 +144,44 @@
# ____________________________________________________________
-_callinfo_for_oopspec = {} # {oopspecindex: (calldescr, func_as_int)}
-
-def callinfo_for_oopspec(oopspecindex):
- """A function that returns the calldescr and the function
- address (as an int) of one of the OS_XYZ functions defined above.
- Don't use this if there might be several implementations of the same
- OS_XYZ specialized by type, e.g. OS_ARRAYCOPY."""
- try:
- return _callinfo_for_oopspec[oopspecindex]
- except KeyError:
- return (None, 0)
-
-
-def _funcptr_for_oopspec_memo(oopspecindex):
- from pypy.jit.codewriter import heaptracker
- _, func_as_int = callinfo_for_oopspec(oopspecindex)
- funcadr = heaptracker.int2adr(func_as_int)
- return funcadr.ptr
-_funcptr_for_oopspec_memo._annspecialcase_ = 'specialize:memo'
-
-def funcptr_for_oopspec(oopspecindex):
- """A memo function that returns a pointer to the function described
- by OS_XYZ (as a real low-level function pointer)."""
- funcptr = _funcptr_for_oopspec_memo(oopspecindex)
- assert funcptr
- return funcptr
-funcptr_for_oopspec._annspecialcase_ = 'specialize:arg(0)'
+class CallInfoCollection(object):
+ def __init__(self):
+ # {oopspecindex: (calldescr, func_as_int)}
+ self._callinfo_for_oopspec = {}
+
+ def _freeze_(self):
+ return True
+
+ def add(self, oopspecindex, calldescr, func_as_int):
+ self._callinfo_for_oopspec[oopspecindex] = calldescr, func_as_int
+
+ def has_oopspec(self, oopspecindex):
+ return oopspecindex in self._callinfo_for_oopspec
+
+ def all_function_addresses_as_int(self):
+ return [func for (_, func) in self._callinfo_for_oopspec.values()]
+
+ def callinfo_for_oopspec(self, oopspecindex):
+ """A function that returns the calldescr and the function
+ address (as an int) of one of the OS_XYZ functions defined above.
+ Don't use this if there might be several implementations of the same
+ OS_XYZ specialized by type, e.g. OS_ARRAYCOPY."""
+ try:
+ return self._callinfo_for_oopspec[oopspecindex]
+ except KeyError:
+ return (None, 0)
+
+ def _funcptr_for_oopspec_memo(self, oopspecindex):
+ from pypy.jit.codewriter import heaptracker
+ _, func_as_int = self.callinfo_for_oopspec(oopspecindex)
+ funcadr = heaptracker.int2adr(func_as_int)
+ return funcadr.ptr
+ _funcptr_for_oopspec_memo._annspecialcase_ = 'specialize:memo'
+
+ def funcptr_for_oopspec(self, oopspecindex):
+ """A memo function that returns a pointer to the function described
+ by OS_XYZ (as a real low-level function pointer)."""
+ funcptr = self._funcptr_for_oopspec_memo(oopspecindex)
+ assert funcptr
+ return funcptr
+ funcptr_for_oopspec._annspecialcase_ = 'specialize:arg(1)'
Modified: pypy/release/1.4.x/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/codewriter/jtransform.py (original)
+++ pypy/release/1.4.x/pypy/jit/codewriter/jtransform.py Mon Nov 15 20:08:31 2010
@@ -6,7 +6,7 @@
from pypy.objspace.flow.model import Block, Link, c_last_exception
from pypy.jit.codewriter.flatten import ListOfKind, IndirectCallTargets
from pypy.jit.codewriter import support, heaptracker
-from pypy.jit.codewriter.effectinfo import EffectInfo, _callinfo_for_oopspec
+from pypy.jit.codewriter.effectinfo import EffectInfo
from pypy.jit.codewriter.policy import log
from pypy.jit.metainterp.typesystem import deref, arrayItem
from pypy.rlib import objectmodel
@@ -1084,7 +1084,8 @@
else:
func = heaptracker.adr2int(
llmemory.cast_ptr_to_adr(op.args[0].value))
- _callinfo_for_oopspec[oopspecindex] = calldescr, func
+ self.callcontrol.callinfocollection.add(oopspecindex,
+ calldescr, func)
op1 = self.rewrite_call(op, 'residual_call',
[op.args[0], calldescr],
args=args)
@@ -1095,7 +1096,7 @@
def _register_extra_helper(self, oopspecindex, oopspec_name,
argtypes, resulttype):
# a bit hackish
- if oopspecindex in _callinfo_for_oopspec:
+ if self.callcontrol.callinfocollection.has_oopspec(oopspecindex):
return
c_func, TP = support.builtin_func_for_spec(self.cpu.rtyper,
oopspec_name, argtypes,
@@ -1109,7 +1110,7 @@
else:
func = heaptracker.adr2int(
llmemory.cast_ptr_to_adr(c_func.value))
- _callinfo_for_oopspec[oopspecindex] = calldescr, func
+ self.callcontrol.callinfocollection.add(oopspecindex, calldescr, func)
def _handle_stroruni_call(self, op, oopspec_name, args):
SoU = args[0].concretetype # Ptr(STR) or Ptr(UNICODE)
Modified: pypy/release/1.4.x/pypy/jit/codewriter/test/test_jtransform.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/codewriter/test/test_jtransform.py (original)
+++ pypy/release/1.4.x/pypy/jit/codewriter/test/test_jtransform.py Mon Nov 15 20:08:31 2010
@@ -74,7 +74,20 @@
def calldescr_canraise(self, calldescr):
return False
+class FakeCallInfoCollection:
+ def __init__(self):
+ self.seen = []
+ def add(self, oopspecindex, calldescr, func):
+ self.seen.append((oopspecindex, calldescr, func))
+ def has_oopspec(self, oopspecindex):
+ for i, c, f in self.seen:
+ if i == oopspecindex:
+ return True
+ return False
+
class FakeBuiltinCallControl:
+ def __init__(self):
+ self.callinfocollection = FakeCallInfoCollection()
def guess_call_kind(self, op):
return 'builtin'
def getcalldescr(self, op, oopspecindex=None):
@@ -810,7 +823,8 @@
v2 = varoftype(PSTR)
v3 = varoftype(PSTR)
op = SpaceOperation('direct_call', [const(func), v1, v2], v3)
- tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
+ cc = FakeBuiltinCallControl()
+ tr = Transformer(FakeCPU(), cc)
op1 = tr.rewrite_operation(op)
assert op1.opname == 'residual_call_r_r'
assert op1.args[0].value == func
@@ -819,9 +833,10 @@
assert op1.result == v3
#
# check the callinfo_for_oopspec
- got = effectinfo.callinfo_for_oopspec(effectinfo.EffectInfo.OS_UNI_CONCAT)
- assert got[0] == op1.args[1] # the calldescr
- assert heaptracker.int2adr(got[1]) == llmemory.cast_ptr_to_adr(func)
+ got = cc.callinfocollection.seen[0]
+ assert got[0] == effectinfo.EffectInfo.OS_UNI_CONCAT
+ assert got[1] == op1.args[1] # the calldescr
+ assert heaptracker.int2adr(got[2]) == llmemory.cast_ptr_to_adr(func)
def test_str_slice():
# test that the oopspec is present and correctly transformed
@@ -893,7 +908,8 @@
v2 = varoftype(PUNICODE)
v3 = varoftype(lltype.Bool)
op = SpaceOperation('direct_call', [const(func), v1, v2], v3)
- tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
+ cc = FakeBuiltinCallControl()
+ tr = Transformer(FakeCPU(), cc)
op1 = tr.rewrite_operation(op)
assert op1.opname == 'residual_call_r_i'
assert op1.args[0].value == func
@@ -901,9 +917,9 @@
assert op1.args[2] == ListOfKind('ref', [v1, v2])
assert op1.result == v3
# test that the OS_UNIEQ_* functions are registered
- cifo = effectinfo._callinfo_for_oopspec
- assert effectinfo.EffectInfo.OS_UNIEQ_SLICE_NONNULL in cifo
- assert effectinfo.EffectInfo.OS_UNIEQ_CHECKNULL_CHAR in cifo
+ cic = cc.callinfocollection
+ assert cic.has_oopspec(effectinfo.EffectInfo.OS_UNIEQ_SLICE_NONNULL)
+ assert cic.has_oopspec(effectinfo.EffectInfo.OS_UNIEQ_CHECKNULL_CHAR)
def test_list_ll_arraycopy():
from pypy.rlib.rgc import ll_arraycopy
Modified: pypy/release/1.4.x/pypy/jit/metainterp/optimizeopt/string.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/metainterp/optimizeopt/string.py (original)
+++ pypy/release/1.4.x/pypy/jit/metainterp/optimizeopt/string.py Mon Nov 15 20:08:31 2010
@@ -9,7 +9,7 @@
from pypy.jit.metainterp.optimizeopt.optimizer import CONST_0, CONST_1
from pypy.jit.metainterp.optimizeopt.optimizer import llhelper
from pypy.jit.metainterp.optimizeutil import _findall
-from pypy.jit.codewriter.effectinfo import EffectInfo, callinfo_for_oopspec
+from pypy.jit.codewriter.effectinfo import EffectInfo
from pypy.jit.codewriter import heaptracker
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.objectmodel import specialize, we_are_translated
@@ -593,7 +593,8 @@
def generate_modified_call(self, oopspecindex, args, result, mode):
oopspecindex += mode.OS_offset
- calldescr, func = callinfo_for_oopspec(oopspecindex)
+ cic = self.optimizer.metainterp_sd.callinfocollection
+ calldescr, func = cic.callinfo_for_oopspec(oopspecindex)
op = ResOperation(rop.CALL, [ConstInt(func)] + args, result,
descr=calldescr)
self.optimizer.newoperations.append(op)
Modified: pypy/release/1.4.x/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/release/1.4.x/pypy/jit/metainterp/pyjitpl.py Mon Nov 15 20:08:31 2010
@@ -1261,6 +1261,7 @@
#
self.jitdrivers_sd = codewriter.callcontrol.jitdrivers_sd
self.virtualref_info = codewriter.callcontrol.virtualref_info
+ self.callinfocollection = codewriter.callcontrol.callinfocollection
self.setup_jitdrivers_sd(optimizer)
#
# store this information for fastpath of call_assembler
Modified: pypy/release/1.4.x/pypy/jit/metainterp/resume.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/metainterp/resume.py (original)
+++ pypy/release/1.4.x/pypy/jit/metainterp/resume.py Mon Nov 15 20:08:31 2010
@@ -4,8 +4,7 @@
from pypy.jit.metainterp.history import INT, REF, FLOAT, HOLE
from pypy.jit.metainterp.resoperation import rop
from pypy.jit.metainterp import jitprof
-from pypy.jit.codewriter.effectinfo import EffectInfo, callinfo_for_oopspec
-from pypy.jit.codewriter.effectinfo import funcptr_for_oopspec
+from pypy.jit.codewriter.effectinfo import EffectInfo
from pypy.rpython.lltypesystem import lltype, llmemory, rffi, rstr
from pypy.rlib import rarithmetic
from pypy.rlib.objectmodel import we_are_translated, specialize
@@ -774,14 +773,16 @@
strbox, ConstInt(index), charbox)
def concat_strings(self, str1num, str2num):
- calldescr, func = callinfo_for_oopspec(EffectInfo.OS_STR_CONCAT)
+ cic = self.metainterp.staticdata.callinfocollection
+ calldescr, func = cic.callinfo_for_oopspec(EffectInfo.OS_STR_CONCAT)
str1box = self.decode_box(str1num, REF)
str2box = self.decode_box(str2num, REF)
return self.metainterp.execute_and_record_varargs(
rop.CALL, [ConstInt(func), str1box, str2box], calldescr)
def slice_string(self, strnum, startnum, lengthnum):
- calldescr, func = callinfo_for_oopspec(EffectInfo.OS_STR_SLICE)
+ cic = self.metainterp.staticdata.callinfocollection
+ calldescr, func = cic.callinfo_for_oopspec(EffectInfo.OS_STR_SLICE)
strbox = self.decode_box(strnum, REF)
startbox = self.decode_box(startnum, INT)
lengthbox = self.decode_box(lengthnum, INT)
@@ -800,14 +801,16 @@
strbox, ConstInt(index), charbox)
def concat_unicodes(self, str1num, str2num):
- calldescr, func = callinfo_for_oopspec(EffectInfo.OS_UNI_CONCAT)
+ cic = self.metainterp.staticdata.callinfocollection
+ calldescr, func = cic.callinfo_for_oopspec(EffectInfo.OS_UNI_CONCAT)
str1box = self.decode_box(str1num, REF)
str2box = self.decode_box(str2num, REF)
return self.metainterp.execute_and_record_varargs(
rop.CALL, [ConstInt(func), str1box, str2box], calldescr)
def slice_unicode(self, strnum, startnum, lengthnum):
- calldescr, func = callinfo_for_oopspec(EffectInfo.OS_UNI_SLICE)
+ cic = self.metainterp.staticdata.callinfocollection
+ calldescr, func = cic.callinfo_for_oopspec(EffectInfo.OS_UNI_SLICE)
strbox = self.decode_box(strnum, REF)
startbox = self.decode_box(startnum, INT)
lengthbox = self.decode_box(lengthnum, INT)
@@ -903,8 +906,8 @@
def blackhole_from_resumedata(blackholeinterpbuilder, jitdriver_sd, storage,
all_virtuals=None):
- resumereader = ResumeDataDirectReader(blackholeinterpbuilder.cpu, storage,
- all_virtuals)
+ resumereader = ResumeDataDirectReader(blackholeinterpbuilder.metainterp_sd,
+ storage, all_virtuals)
vinfo = jitdriver_sd.virtualizable_info
ginfo = jitdriver_sd.greenfield_info
vrefinfo = blackholeinterpbuilder.metainterp_sd.virtualref_info
@@ -939,7 +942,7 @@
return firstbh
def force_from_resumedata(metainterp_sd, storage, vinfo, ginfo):
- resumereader = ResumeDataDirectReader(metainterp_sd.cpu, storage)
+ resumereader = ResumeDataDirectReader(metainterp_sd, storage)
resumereader.handling_async_forcing()
vrefinfo = metainterp_sd.virtualref_info
resumereader.consume_vref_and_vable(vrefinfo, vinfo, ginfo)
@@ -953,8 +956,9 @@
# 1: in handle_async_forcing
# 2: resuming from the GUARD_NOT_FORCED
- def __init__(self, cpu, storage, all_virtuals=None):
- self._init(cpu, storage)
+ def __init__(self, metainterp_sd, storage, all_virtuals=None):
+ self._init(metainterp_sd.cpu, storage)
+ self.callinfocollection = metainterp_sd.callinfocollection
if all_virtuals is None: # common case
self._prepare(storage)
else:
@@ -1047,7 +1051,8 @@
str2 = self.decode_ref(str2num)
str1 = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), str1)
str2 = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), str2)
- funcptr = funcptr_for_oopspec(EffectInfo.OS_STR_CONCAT)
+ cic = self.callinfocollection
+ funcptr = cic.funcptr_for_oopspec(EffectInfo.OS_STR_CONCAT)
result = funcptr(str1, str2)
return lltype.cast_opaque_ptr(llmemory.GCREF, result)
@@ -1056,7 +1061,8 @@
start = self.decode_int(startnum)
length = self.decode_int(lengthnum)
str = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), str)
- funcptr = funcptr_for_oopspec(EffectInfo.OS_STR_SLICE)
+ cic = self.callinfocollection
+ funcptr = cic.funcptr_for_oopspec(EffectInfo.OS_STR_SLICE)
result = funcptr(str, start, start + length)
return lltype.cast_opaque_ptr(llmemory.GCREF, result)
@@ -1072,7 +1078,8 @@
str2 = self.decode_ref(str2num)
str1 = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), str1)
str2 = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), str2)
- funcptr = funcptr_for_oopspec(EffectInfo.OS_UNI_CONCAT)
+ cic = self.callinfocollection
+ funcptr = cic.funcptr_for_oopspec(EffectInfo.OS_UNI_CONCAT)
result = funcptr(str1, str2)
return lltype.cast_opaque_ptr(llmemory.GCREF, result)
@@ -1081,7 +1088,8 @@
start = self.decode_int(startnum)
length = self.decode_int(lengthnum)
str = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), str)
- funcptr = funcptr_for_oopspec(EffectInfo.OS_UNI_SLICE)
+ cic = self.callinfocollection
+ funcptr = cic.funcptr_for_oopspec(EffectInfo.OS_UNI_SLICE)
result = funcptr(str, start, start + length)
return lltype.cast_opaque_ptr(llmemory.GCREF, result)
Modified: pypy/release/1.4.x/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/metainterp/test/test_optimizeopt.py (original)
+++ pypy/release/1.4.x/pypy/jit/metainterp/test/test_optimizeopt.py Mon Nov 15 20:08:31 2010
@@ -264,6 +264,8 @@
metainterp_sd = FakeMetaInterpStaticData(self.cpu)
if hasattr(self, 'vrefinfo'):
metainterp_sd.virtualref_info = self.vrefinfo
+ if hasattr(self, 'callinfocollection'):
+ metainterp_sd.callinfocollection = self.callinfocollection
optimize_loop_1(metainterp_sd, loop)
#
expected = self.parse(optops)
@@ -4180,22 +4182,20 @@
# ----------
def optimize_strunicode_loop_extradescrs(self, ops, spectext, optops):
from pypy.jit.metainterp.optimizeopt import string
- def my_callinfo_for_oopspec(oopspecindex):
- calldescrtype = type(LLtypeMixin.strequaldescr)
- for value in LLtypeMixin.__dict__.values():
- if isinstance(value, calldescrtype):
- if (value.get_extra_info() and
- value.get_extra_info().oopspecindex == oopspecindex):
- # returns 0 for 'func' in this test
- return value, 0
- raise AssertionError("not found: oopspecindex=%d" % oopspecindex)
+ class FakeCallInfoCollection:
+ def callinfo_for_oopspec(self, oopspecindex):
+ calldescrtype = type(LLtypeMixin.strequaldescr)
+ for value in LLtypeMixin.__dict__.values():
+ if isinstance(value, calldescrtype):
+ extra = value.get_extra_info()
+ if extra and extra.oopspecindex == oopspecindex:
+ # returns 0 for 'func' in this test
+ return value, 0
+ raise AssertionError("not found: oopspecindex=%d" %
+ oopspecindex)
#
- saved = string.callinfo_for_oopspec
- try:
- string.callinfo_for_oopspec = my_callinfo_for_oopspec
- self.optimize_strunicode_loop(ops, spectext, optops)
- finally:
- string.callinfo_for_oopspec = saved
+ self.callinfocollection = FakeCallInfoCollection()
+ self.optimize_strunicode_loop(ops, spectext, optops)
def test_str_equal_noop1(self):
ops = """
Modified: pypy/release/1.4.x/pypy/jit/metainterp/test/test_resume.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/metainterp/test/test_resume.py (original)
+++ pypy/release/1.4.x/pypy/jit/metainterp/test/test_resume.py Mon Nov 15 20:08:31 2010
@@ -51,6 +51,7 @@
class MyMetaInterp:
_already_allocated_resume_virtuals = None
+ callinfocollection = None
def __init__(self, cpu=None):
if cpu is None:
@@ -156,12 +157,12 @@
storage.rd_numb = numb
#
cpu = MyCPU([42, gcref1, -66])
- reader = ResumeDataDirectReader(cpu, storage)
+ metainterp = MyMetaInterp(cpu)
+ reader = ResumeDataDirectReader(metainterp, storage)
_next_section(reader, 42, 111, gcrefnull, 42, gcref1)
_next_section(reader, 222, 333)
_next_section(reader, 42, gcref1, -66)
#
- metainterp = MyMetaInterp(cpu)
reader = ResumeDataBoxReader(storage, metainterp)
bi, br, bf = [None]*3, [None]*2, [None]*0
info = MyBlackholeInterp([lltype.Signed, lltype.Signed,
@@ -193,7 +194,7 @@
storage.rd_numb = numb
#
cpu = MyCPU([])
- reader = ResumeDataDirectReader(cpu, storage)
+ reader = ResumeDataDirectReader(MyMetaInterp(cpu), storage)
_next_section(reader, 100)
@@ -211,7 +212,7 @@
class FakeMetainterp(object):
_already_allocated_resume_virtuals = None
cpu = None
- reader = ResumeDataDirectReader(None, FakeStorage())
+ reader = ResumeDataDirectReader(MyMetaInterp(None), FakeStorage())
assert reader.force_all_virtuals() == ["allocated", reader.virtual_default]
# ____________________________________________________________
@@ -925,7 +926,7 @@
liveboxes = modifier.finish({})
assert storage.rd_snapshot is None
cpu = MyCPU([])
- reader = ResumeDataDirectReader(cpu, storage)
+ reader = ResumeDataDirectReader(MyMetaInterp(cpu), storage)
_next_section(reader, sys.maxint, 2**16, -65)
_next_section(reader, 2, 3)
_next_section(reader, sys.maxint, 1, sys.maxint, 2**16)
Modified: pypy/release/1.4.x/pypy/jit/metainterp/test/test_virtualref.py
==============================================================================
--- pypy/release/1.4.x/pypy/jit/metainterp/test/test_virtualref.py (original)
+++ pypy/release/1.4.x/pypy/jit/metainterp/test/test_virtualref.py Mon Nov 15 20:08:31 2010
@@ -88,7 +88,11 @@
cpu.get_latest_value_int = lambda i:guard_op.getfailargs()[i].getint()
cpu.get_latest_value_ref = lambda i:guard_op.getfailargs()[i].getref_base()
cpu.clear_latest_values = lambda count: None
- resumereader = ResumeDataDirectReader(cpu, guard_op.getdescr())
+ class FakeMetaInterpSd:
+ callinfocollection = None
+ FakeMetaInterpSd.cpu = cpu
+ resumereader = ResumeDataDirectReader(FakeMetaInterpSd(),
+ guard_op.getdescr())
vrefinfo = self.metainterp.staticdata.virtualref_info
lst = []
vrefinfo.continue_tracing = lambda vref, virtual: \
More information about the Pypy-commit
mailing list