[pypy-commit] pypy guard-value-limit: add example for testing
Raemi
pypy.commits at gmail.com
Fri Jun 7 09:09:55 EDT 2019
Author: Remi Meier <remi.meier at gmail.com>
Branch: guard-value-limit
Changeset: r96774:c6bc0ea32200
Date: 2019-06-07 15:09 +0200
http://bitbucket.org/pypy/pypy/changeset/c6bc0ea32200/
Log: add example for testing
diff --git a/pypy/goal/overspecialize_type.py b/pypy/goal/overspecialize_type.py
new file mode 100644
--- /dev/null
+++ b/pypy/goal/overspecialize_type.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+
+import sys
+
+def run(objs, n):
+ res = 0
+ for o in objs:
+ for i in range(n):
+ res += o.f()
+ print res
+
+def thefun():
+ return 1
+
+if __name__ == "__main__":
+ try:
+ num_types = int(sys.argv[1])
+ n = int(sys.argv[2])
+ objs = []
+ for i in range(num_types):
+ exec("""
+class A_%s(object):
+ field = %s
+ #def f(self): return 1#return self.field
+ """ % (i, i))
+ objs.append(eval("A_%s()" % i))
+ # use same 'thefun' for each obj (to avoid more failing guards)
+ setattr(objs[-1], 'f', thefun)
+
+ run(objs, n)
+ except Exception as e:
+ print e
+ print "Arguments: num_types iterations"
+ print "env PYPYLOG=jit-sum:- ./pypy-c --jit guard_value_limit=8 overspecialize_type.py 42 50000"
More information about the pypy-commit
mailing list