[pypy-commit] pypy vref-copy: progress. a 2 day 50 loc function
fijal
noreply at buildbot.pypy.org
Fri Aug 24 17:50:18 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: vref-copy
Changeset: r56841:206f4c0be88f
Date: 2012-08-24 17:50 +0200
http://bitbucket.org/pypy/pypy/changeset/206f4c0be88f/
Log: progress. a 2 day 50 loc function
diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -638,11 +638,11 @@
self.copy_all_attributes_into(res)
return res
- at specialize.arg(2)
-def read_field_from_resume(cpu, token, fieldname):
+ at specialize.arg(4)
+def read_field_from_resume(cpu, token, descr, vinst, TP):
faildescr = cpu.force(token)
assert isinstance(faildescr, ResumeGuardForcedDescr)
- return faildescr.handle_async_field_read(token, fieldname)
+ return faildescr.handle_async_field_read(token, descr, vinst, TP)
class ResumeGuardForcedDescr(ResumeGuardDescr):
@@ -692,12 +692,14 @@
# future failure of the GUARD_NOT_FORCED
self.save_data(force_token, all_virtuals)
- @specialize.arg(2)
- def handle_async_field_read(self, force_token, fieldname):
+ @specialize.arg(4)
+ def handle_async_field_read(self, force_token, descr, vinst, TP):
from pypy.jit.metainterp.resume import read_field_from_resumedata
metainterp_sd = self.metainterp_sd
+ vinfo = self.jitdriver_sd.virtualizable_info
ginfo = self.jitdriver_sd.greenfield_info
- return read_field_from_resumedata(metainterp_sd, self, ginfo)
+ return read_field_from_resumedata(metainterp_sd, self, vinfo, ginfo,
+ descr, vinst, TP)
def save_data(self, key, value):
globaldata = self.metainterp_sd.globaldata
diff --git a/pypy/jit/metainterp/resume.py b/pypy/jit/metainterp/resume.py
--- a/pypy/jit/metainterp/resume.py
+++ b/pypy/jit/metainterp/resume.py
@@ -793,8 +793,45 @@
resumereader.done()
return resumereader.liveboxes, virtualizable_boxes, virtualref_boxes
-def read_field_from_resumedata(metainterp, storage, greenfield_info):
- xxx
+ at specialize.arg(6)
+def read_field_from_resumedata(metainterp_sd, storage, vinfo, greenfield_info,
+ fielddescr, vinst, RES_TP):
+ cpu = metainterp_sd.cpu
+ numb = storage.rd_numb
+ end = len(numb.nums)
+ vinst = lltype.cast_opaque_ptr(llmemory.GCREF, vinst)
+ for i in range(0, end, 2):
+ # that's a vref
+ num, tag = untag(numb.nums[i + 1])
+ if tag == TAGBOX:
+ inst = cpu.get_latest_value_ref(num)
+ if inst == vinst:
+ # we found the correct vref, now we look for virtuals
+ # that are supposed to be stored in the place.
+ # Note that since we passed the vref to a residual
+ # call, it cannot potentially be virtual
+ num, tag = untag(numb.nums[i])
+ if tag != TAGVIRTUAL:
+ raise Exception("I'm not sure if this can happen, non-virtual, but not stored in a vref")
+ vinfo = storage.rd_virtuals[num]
+ for j, descr in enumerate(vinfo.fielddescrs):
+ if descr == fielddescr:
+ cpunum, tag = untag(vinfo.fieldnums[j])
+ assert tag in [TAGBOX, TAGCONST, TAGINT]
+ # no support for virtuals
+ if descr.is_pointer_field():
+ xxx
+ elif descr.is_float_field():
+ xxx
+ else:
+ if tag == TAGINT:
+ return rffi.cast(RES_TP, cpunum)
+ xxx
+ else:
+ assert False, "unreachable code"
+ else:
+ assert False, "cannot find the correct vref"
+
class ResumeDataBoxReader(AbstractResumeDataReader):
unique_id = lambda: None
diff --git a/pypy/jit/metainterp/virtualref.py b/pypy/jit/metainterp/virtualref.py
--- a/pypy/jit/metainterp/virtualref.py
+++ b/pypy/jit/metainterp/virtualref.py
@@ -164,6 +164,8 @@
return inputconst(lltype.typeOf(funcptr), funcptr)
def get_vref_getfield_fnptr(self, name, RES_TP):
+ descr = self.cpu.fielddescrof(self._vref_T.TO, 'inst_' + name)
+
def read_virtual_field(inst):
if inst.typeptr != self.jit_virtual_ref_vtable:
inst = lltype.cast_pointer(self._vref_T, inst)
@@ -174,10 +176,11 @@
# not a virtual at all, just pretending to be one
forced = lltype.cast_pointer(self._vref_T, vref.forced)
return getattr(forced, 'inst_' + name)
- else:
+ else:
assert not vref.forced
from pypy.jit.metainterp.compile import read_field_from_resume
- return read_field_from_resume(self.cpu, token, name)
+ return read_field_from_resume(self.cpu, token, descr, vref,
+ RES_TP)
FUNC = lltype.FuncType([rclass.OBJECTPTR], RES_TP)
funcptr = self.warmrunnerdesc.helper_func(
More information about the pypy-commit
mailing list