[pypy-commit] pypy value-classes: Cleanup

sbauman pypy.commits at gmail.com
Mon Sep 26 16:42:40 EDT 2016


Author: Spenser Bauman <sabauma at gmail.com>
Branch: value-classes
Changeset: r87403:e927b403b073
Date: 2016-09-26 13:05 -0400
http://bitbucket.org/pypy/pypy/changeset/e927b403b073/

Log:	Cleanup

diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py
@@ -132,7 +132,6 @@
     def debug_header(self, indent):
         raise NotImplementedError
 
-
 class AbstractVirtualStructStateInfo(AbstractVirtualStateInfo):
     _attrs_ = ('typedescr', 'fielddescrs')
 
@@ -141,6 +140,9 @@
         self.fielddescrs = fielddescrs
 
     def _generate_guards(self, other, box, runtime_box, state):
+        if isinstance(other, NotVirtualStateInfo):
+            return self._generate_guards_non_virtual(other, box, runtime_box, state)
+
         if not self._generalization_of_structpart(other):
             raise VirtualStatesCantMatch("different kinds of structs")
 
@@ -178,7 +180,13 @@
                                                    fieldbox_runtime, state)
 
     def _generate_guards_non_virtual(self, other, box, runtime_box, state):
-        pass
+        """
+        Generate guards for the case where a virtual object is expected, but
+        a non-virtual is given. When the underlying type is a value class,
+        the non-virtual may be virtualized by unpacking it and forwarding the
+        components elementwise.
+        """
+        raise VirtualStatesCantMatch("different kinds of structs")
 
     def enum_forced_boxes(self, boxes, box, optimizer, force_boxes=False):
         box = optimizer.get_box_replacement(box)
@@ -227,6 +235,7 @@
         debug_print(indent + 'VStructStateInfo(%d):' % self.position)
 
 class VArrayStateInfo(AbstractVirtualStateInfo):
+    _attrs_ = ('arraydescr',)
 
     def __init__(self, arraydescr):
         self.arraydescr = arraydescr
@@ -277,6 +286,8 @@
 
 
 class VArrayStructStateInfo(AbstractVirtualStateInfo):
+    _attrs_ = ('arraydescr', 'fielddescrs', 'length')
+
     def __init__(self, arraydescr, fielddescrs, length):
         self.arraydescr = arraydescr
         self.fielddescrs = fielddescrs
@@ -355,10 +366,12 @@
         return NotVirtualStateInfoInt(cpu, type, info)
     if type == 'r':
         return NotVirtualStateInfoPtr(cpu, type, info)
+    assert type == 'f'
     return NotVirtualStateInfo(cpu, type, info)
 
 
 class NotVirtualStateInfo(AbstractVirtualStateInfo):
+    _attrs_ = ('level', 'constbox', 'position_in_notvirtuals')
     level = LEVEL_UNKNOWN
     constbox = None
 
@@ -458,6 +471,7 @@
         debug_print(result)
 
 class NotVirtualStateInfoInt(NotVirtualStateInfo):
+    _attrs_ = ('intbound')
     intbound = None
 
     def __init__(self, cpu, type, info):
@@ -492,6 +506,7 @@
 
 
 class NotVirtualStateInfoPtr(NotVirtualStateInfo):
+    _attrs_ = ('lenbound', 'known_class')
     lenbound = None
     known_class = None
 
diff --git a/rpython/jit/metainterp/test/test_virtual.py b/rpython/jit/metainterp/test/test_virtual.py
--- a/rpython/jit/metainterp/test/test_virtual.py
+++ b/rpython/jit/metainterp/test/test_virtual.py
@@ -1048,12 +1048,7 @@
         # virtual X object. The side exit in this case will contain a non-virtual
         # value class, which should be unpacked into the
 
-        # self.check_resops(jump=3, label=2, new_with_vtable=2)
-        # self.check_target_token_count(2)
-        # self.check_trace_count(3)
-
-
-    def test_conflated_virtual_states(self):
+    def test_aliased_virtual_states(self):
         # All cases are covered when forcing one component of the virtual state
         # also forces an as yet unseen component.
         # i.e. expect [NotVirtual, Virtual] and given a pair of aliasing virtual


More information about the pypy-commit mailing list