[pypy-commit] pypy default: (cfbolz, arigo and fijal around): change record_known_class to record_exact_class
cfbolz
noreply at buildbot.pypy.org
Wed Aug 12 19:10:42 CEST 2015
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r78949:2e627a5cee8b
Date: 2015-08-12 19:10 +0200
http://bitbucket.org/pypy/pypy/changeset/2e627a5cee8b/
Log: (cfbolz, arigo and fijal around): change record_known_class to
record_exact_class
diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -252,9 +252,11 @@
TO = op.result.concretetype.TO
if lltype._castdepth(TO, FROM) > 0:
vtable = heaptracker.get_vtable_for_gcstruct(self.cpu, TO)
- const_vtable = Constant(vtable, lltype.typeOf(vtable))
- return [None, # hack, do the right renaming from op.args[0] to op.result
- SpaceOperation("record_known_class", [op.args[0], const_vtable], None)]
+ if vtable.subclassrange_max - vtable.subclassrange_min == 1:
+ # it's a precise class check
+ const_vtable = Constant(vtable, lltype.typeOf(vtable))
+ return [None, # hack, do the right renaming from op.args[0] to op.result
+ SpaceOperation("record_exact_class", [op.args[0], const_vtable], None)]
def rewrite_op_likely(self, op):
return None # "no real effect"
@@ -271,8 +273,8 @@
arg = llmemory.raw_malloc_usage(arg)
return [Constant(arg, lltype.Signed)]
- def rewrite_op_jit_record_known_class(self, op):
- return SpaceOperation("record_known_class", [op.args[0], op.args[1]], None)
+ def rewrite_op_jit_record_exact_class(self, op):
+ return SpaceOperation("record_exact_class", [op.args[0], op.args[1]], None)
def rewrite_op_cast_bool_to_int(self, op): pass
def rewrite_op_cast_bool_to_uint(self, op): pass
diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -536,7 +536,7 @@
def bhimpl_mark_opaque_ptr(a):
pass
@arguments("r", "i")
- def bhimpl_record_known_class(a, b):
+ def bhimpl_record_exact_class(a, b):
pass
@arguments("i", returns="i")
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -331,7 +331,7 @@
def optimize_GUARD_FALSE(self, op):
self.optimize_guard(op, CONST_0)
- def optimize_RECORD_KNOWN_CLASS(self, op):
+ def optimize_RECORD_EXACT_CLASS(self, op):
value = self.getvalue(op.getarg(0))
expectedclassbox = op.getarg(1)
assert isinstance(expectedclassbox, Const)
diff --git a/rpython/jit/metainterp/optimizeopt/simplify.py b/rpython/jit/metainterp/optimizeopt/simplify.py
--- a/rpython/jit/metainterp/optimizeopt/simplify.py
+++ b/rpython/jit/metainterp/optimizeopt/simplify.py
@@ -35,7 +35,7 @@
# but it's a bit hard to implement robustly if heap.py is also run
pass
- def optimize_RECORD_KNOWN_CLASS(self, op):
+ def optimize_RECORD_EXACT_CLASS(self, op):
pass
def optimize_LABEL(self, op):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -7084,11 +7084,11 @@
# not obvious, because of the exception UnicodeDecodeError that
# can be raised by ll_str2unicode()
- def test_record_known_class(self):
+ def test_record_exact_class(self):
ops = """
[p0]
p1 = getfield_gc(p0, descr=nextdescr)
- record_known_class(p1, ConstClass(node_vtable))
+ record_exact_class(p1, ConstClass(node_vtable))
guard_class(p1, ConstClass(node_vtable)) []
jump(p1)
"""
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py b/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_zdisable_opts.py
@@ -30,7 +30,7 @@
rop.VIRTUAL_REF,
rop.QUASIIMMUT_FIELD,
rop.MARK_OPAQUE_PTR,
- rop.RECORD_KNOWN_CLASS)
+ rop.RECORD_EXACT_CLASS)
def raises(self, e, fn, *args):
try:
diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -275,16 +275,13 @@
return self.execute(rop.MARK_OPAQUE_PTR, box)
@arguments("box", "box")
- def opimpl_record_known_class(self, box, clsbox):
+ def opimpl_record_exact_class(self, box, clsbox):
from rpython.rtyper.lltypesystem import llmemory
if self.metainterp.heapcache.is_class_known(box):
return
adr = clsbox.getaddr()
- bounding_class = llmemory.cast_adr_to_ptr(adr, rclass.CLASSTYPE)
- if bounding_class.subclassrange_max - bounding_class.subclassrange_min == 1:
- # precise class knowledge, this can be used
- self.execute(rop.RECORD_KNOWN_CLASS, box, clsbox)
- self.metainterp.heapcache.class_now_known(box)
+ self.execute(rop.RECORD_EXACT_CLASS, box, clsbox)
+ self.metainterp.heapcache.class_now_known(box)
@arguments("box")
def _opimpl_any_return(self, box):
diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -529,7 +529,7 @@
'COPYSTRCONTENT/5', # src, dst, srcstart, dststart, length
'COPYUNICODECONTENT/5',
'QUASIIMMUT_FIELD/1d', # [objptr], descr=SlowMutateDescr
- 'RECORD_KNOWN_CLASS/2', # [objptr, clsptr]
+ 'RECORD_EXACT_CLASS/2', # [objptr, clsptr]
'KEEPALIVE/1',
'_CANRAISE_FIRST', # ----- start of can_raise operations -----
diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -10,7 +10,7 @@
from rpython.rlib.jit import (JitDriver, we_are_jitted, hint, dont_look_inside,
loop_invariant, elidable, promote, jit_debug, assert_green,
AssertGreenFailed, unroll_safe, current_trace_length, look_inside_iff,
- isconstant, isvirtual, set_param, record_known_class)
+ isconstant, isvirtual, set_param, record_exact_class)
from rpython.rlib.longlong2float import float2longlong, longlong2float
from rpython.rlib.rarithmetic import ovfcheck, is_valid_int, int_force_ge_zero
from rpython.rtyper.lltypesystem import lltype, rffi
@@ -3756,19 +3756,19 @@
res1 = f(6)
res2 = self.interp_operations(f, [6])
assert res1 == res2
- self.check_operations_history(guard_class=0, record_known_class=1)
+ self.check_operations_history(guard_class=0, record_exact_class=1)
res1 = f(-6)
res2 = self.interp_operations(f, [-6])
assert res1 == res2
- # cannot use record_known_class here, because B has a subclass
+ # cannot use record_exact_class here, because B has a subclass
self.check_operations_history(guard_class=1)
res1 = f(0)
res2 = self.interp_operations(f, [0])
assert res1 == res2
# here it works again
- self.check_operations_history(guard_class=0, record_known_class=1)
+ self.check_operations_history(guard_class=0, record_exact_class=1)
def test_give_class_knowledge_to_tracer_explicitly(self):
from rpython.rtyper.lltypesystem.lloperation import llop
@@ -3808,31 +3808,30 @@
def f(x):
a = make(x)
if x > 0:
- record_known_class(a, A)
+ record_exact_class(a, A)
z = a.f()
elif x < 0:
- record_known_class(a, B)
+ record_exact_class(a, B)
z = a.f()
else:
- record_known_class(a, C)
+ record_exact_class(a, C)
z = a.f()
return z + a.g()
res1 = f(6)
res2 = self.interp_operations(f, [6])
assert res1 == res2
- self.check_operations_history(guard_class=0, record_known_class=1)
+ self.check_operations_history(guard_class=0, record_exact_class=1)
res1 = f(-6)
res2 = self.interp_operations(f, [-6])
assert res1 == res2
- # cannot use record_known_class here, because B has a subclass
- self.check_operations_history(guard_class=1)
+ self.check_operations_history(guard_class=0, record_exact_class=1)
res1 = f(0)
res2 = self.interp_operations(f, [0])
assert res1 == res2
# here it works again
- self.check_operations_history(guard_class=0, record_known_class=1)
+ self.check_operations_history(guard_class=0, record_exact_class=1)
def test_generator(self):
def g(n):
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -1080,19 +1080,18 @@
instance, overwrite for custom behavior
"""
-def record_known_class(value, cls):
+def record_exact_class(value, cls):
"""
- Assure the JIT that value is an instance of cls. This is not a precise
- class check, unlike a guard_class.
+ Assure the JIT that value is an instance of cls. This is a precise
+ class check, like a guard_class.
"""
- assert isinstance(value, cls)
+ assert type(value) is cls
class Entry(ExtRegistryEntry):
- _about_ = record_known_class
+ _about_ = record_exact_class
def compute_result_annotation(self, s_inst, s_cls):
from rpython.annotator import model as annmodel
- assert s_cls.is_constant()
assert not s_inst.can_be_none()
assert isinstance(s_inst, annmodel.SomeInstance)
@@ -1105,7 +1104,7 @@
hop.exception_cannot_occur()
v_inst = hop.inputarg(hop.args_r[0], arg=0)
v_cls = hop.inputarg(classrepr, arg=1)
- return hop.genop('jit_record_known_class', [v_inst, v_cls],
+ return hop.genop('jit_record_exact_class', [v_inst, v_cls],
resulttype=lltype.Void)
def _jit_conditional_call(condition, function, *args):
diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -545,7 +545,7 @@
def op_jit_marker(self, *args):
pass
- def op_jit_record_known_class(self, *args):
+ def op_jit_record_exact_class(self, *args):
pass
def op_jit_conditional_call(self, *args):
diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -449,7 +449,7 @@
'jit_force_virtual': LLOp(canrun=True),
'jit_is_virtual': LLOp(canrun=True),
'jit_force_quasi_immutable': LLOp(canrun=True),
- 'jit_record_known_class' : LLOp(canrun=True),
+ 'jit_record_exact_class' : LLOp(canrun=True),
'jit_ffi_save_result': LLOp(canrun=True),
'jit_conditional_call': LLOp(),
'get_exception_addr': LLOp(),
diff --git a/rpython/rtyper/lltypesystem/opimpl.py b/rpython/rtyper/lltypesystem/opimpl.py
--- a/rpython/rtyper/lltypesystem/opimpl.py
+++ b/rpython/rtyper/lltypesystem/opimpl.py
@@ -618,7 +618,7 @@
def op_jit_force_quasi_immutable(*args):
pass
-def op_jit_record_known_class(x, y):
+def op_jit_record_exact_class(x, y):
pass
def op_jit_ffi_save_result(*args):
diff --git a/rpython/translator/c/src/support.h b/rpython/translator/c/src/support.h
--- a/rpython/translator/c/src/support.h
+++ b/rpython/translator/c/src/support.h
@@ -6,7 +6,7 @@
#define _SRC_SUPPORT_H
#define RUNNING_ON_LLINTERP 0
-#define OP_JIT_RECORD_KNOWN_CLASS(i, c, r) /* nothing */
+#define OP_JIT_RECORD_EXACT_CLASS(i, c, r) /* nothing */
#define FAIL_OVF(msg) _RPyRaiseSimpleException(RPyExc_OverflowError)
#define FAIL_VAL(msg) _RPyRaiseSimpleException(RPyExc_ValueError)
More information about the pypy-commit
mailing list