[pypy-commit] pypy compress-numbering: start working on virtualizables
fijal
noreply at buildbot.pypy.org
Wed Nov 25 10:37:17 EST 2015
Author: fijal
Branch: compress-numbering
Changeset: r80946:1d8a732a6a78
Date: 2015-11-25 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/1d8a732a6a78/
Log: start working on virtualizables
diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py
--- a/rpython/jit/metainterp/resume.py
+++ b/rpython/jit/metainterp/resume.py
@@ -1481,14 +1481,15 @@
# from the CPU stack, and copy them into the virtualizable
numb = self.numb
first_snapshot_size = rffi.cast(lltype.Signed, numb.first_snapshot_size)
- if vinfo is None:
- return first_snapshot_size
- xxx
- index = len(numb.nums) - 1
- virtualizable = self.decode_ref(numb.nums[index])
+ item, _ = resumecode.numb_next_item(self.numb,
+ first_snapshot_size - 1)
+ virtualizable = self.decode_ref(item)
+ start_index = first_snapshot_size - 1 - vinfo.get_total_size(virtualizable)
# just reset the token, we'll force it later
vinfo.reset_token_gcref(virtualizable)
- return vinfo.write_from_resume_data_partial(virtualizable, self, numb)
+ vinfo.write_from_resume_data_partial(virtualizable, self, start_index,
+ numb)
+ return start_index
def load_value_of_type(self, TYPE, tagged):
from rpython.jit.metainterp.warmstate import specialize_value
@@ -1506,10 +1507,12 @@
def consume_vref_and_vable(self, vrefinfo, vinfo, ginfo):
if self.resume_after_guard_not_forced != 2:
- end_vref = self.consume_vable_info(vinfo)
+ end_vref = rffi.cast(lltype.Signed, self.numb.first_snapshot_size)
+ if vinfo is not None:
+ end_vref = self.consume_vable_info(vinfo)
if ginfo is not None:
end_vref -= 1
- self.consume_virtualref_info(vrefinfo, end_vref)
+ self.consume_virtualref_info(vrefinfo, end_vref)
self.cur_index = rffi.cast(lltype.Signed, self.numb.first_snapshot_size)
def allocate_with_vtable(self, descr=None):
diff --git a/rpython/jit/metainterp/virtualizable.py b/rpython/jit/metainterp/virtualizable.py
--- a/rpython/jit/metainterp/virtualizable.py
+++ b/rpython/jit/metainterp/virtualizable.py
@@ -2,6 +2,7 @@
from rpython.jit.metainterp import history
from rpython.jit.metainterp.typesystem import deref, fieldType, arrayItem
from rpython.jit.metainterp.warmstate import wrap, unwrap
+from rpython.jit.metainterp.resumecode import numb_next_item
from rpython.rlib.unroll import unrolling_iterable
from rpython.rtyper import rvirtualizable
from rpython.rtyper.lltypesystem import lltype, llmemory
@@ -116,31 +117,36 @@
i = i + 1
assert len(boxes) == i + 1
- def write_from_resume_data_partial(virtualizable, reader, numb):
+ def get_total_size(virtualizable):
+ virtualizable = cast_gcref_to_vtype(virtualizable)
+ size = 0
+ for _, fieldname in unroll_array_fields:
+ lst = getattr(virtualizable, fieldname)
+ size += getlength(lst)
+ for _, fieldname in unroll_static_fields:
+ size += 1
+ return size
+
+ def write_from_resume_data_partial(virtualizable, reader, index, numb):
virtualizable = cast_gcref_to_vtype(virtualizable)
# Load values from the reader (see resume.py) described by
# the list of numbers 'nums', and write them in their proper
- # place in the 'virtualizable'. This works from the end of
- # the list and returns the index in 'nums' of the start of
- # the virtualizable data found, allowing the caller to do
- # further processing with the start of the list.
- i = len(numb.nums) - 1
- assert i >= 0
- for ARRAYITEMTYPE, fieldname in unroll_array_fields_rev:
+ # place in the 'virtualizable'.
+ for FIELDTYPE, fieldname in unroll_static_fields:
+ item, index = numb_next_item(numb, index)
+ x = reader.load_value_of_type(FIELDTYPE, item)
+ setattr(virtualizable, fieldname, x)
+ for ARRAYITEMTYPE, fieldname in unroll_array_fields:
+ yyyy
lst = getattr(virtualizable, fieldname)
- for j in range(getlength(lst) - 1, -1, -1):
+ for j in range(getlength(lst)):
i -= 1
assert i >= 0
x = reader.load_value_of_type(ARRAYITEMTYPE, numb.nums[i])
setarrayitem(lst, j, x)
- for FIELDTYPE, fieldname in unroll_static_fields_rev:
- i -= 1
- assert i >= 0
- x = reader.load_value_of_type(FIELDTYPE, numb.nums[i])
- setattr(virtualizable, fieldname, x)
- return i
def load_list_of_boxes(virtualizable, reader, numb):
+ xxx
virtualizable = cast_gcref_to_vtype(virtualizable)
# Uses 'virtualizable' only to know the length of the arrays;
# does not write anything into it. The returned list is in
@@ -217,6 +223,7 @@
self.check_boxes = check_boxes
self.get_index_in_array = get_index_in_array
self.get_array_length = get_array_length
+ self.get_total_size = get_total_size
def cast_to_vtype(virtualizable):
return self.cpu.ts.cast_to_instance_maybe(VTYPEPTR, virtualizable)
More information about the pypy-commit
mailing list