[pypy-commit] pypy value-profiling: try to speed up the interpreter a bit
cfbolz
noreply at buildbot.pypy.org
Fri Aug 7 11:43:54 CEST 2015
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: value-profiling
Changeset: r78845:61627a2881ff
Date: 2015-08-07 11:43 +0200
http://bitbucket.org/pypy/pypy/changeset/61627a2881ff/
Log: try to speed up the interpreter a bit
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -174,6 +174,8 @@
if we_are_jitted():
return
vprof = self.pycode.vprof
+ if vprof.frozen:
+ return
if isinstance(value, W_IntObject):
times = vprof.see_int(varindex, value.intval)
else:
diff --git a/pypy/interpreter/valueprof.py b/pypy/interpreter/valueprof.py
--- a/pypy/interpreter/valueprof.py
+++ b/pypy/interpreter/valueprof.py
@@ -18,14 +18,17 @@
def see_int(self, index, value):
if self.frozen:
return 0
- if self.counters[index] < 0 and self.values_int[index] == value:
- self.counters[index] -= 1
- return -self.counters[index]
+ count = self.counters[index]
+ if count < 0:
+ if self.values_int[index] == value:
+ new_count = count - 1
+ self.counters[index] = new_count
+ return -new_count
else:
- self.values_int[index] = value
- self.counters[index] = -1
self.values_wref[index] = dead_ref
- return 1
+ self.values_int[index] = value
+ self.counters[index] = -1
+ return 1
def see_object(self, index, value):
if self.frozen:
@@ -34,15 +37,17 @@
self.values_wref[index] = dead_ref
self.counters[index] = 0
return 0
- if self.values_wref[index]() is value:
- assert self.counters[index] > 0
- self.counters[index] += 1
- return self.counters[index]
+ count = self.counters[index]
+ if count > 0:
+ if self.values_wref[index]() is value:
+ new_count = count + 1
+ self.counters[index] = new_count
+ return new_count
else:
- self.values_wref[index] = ref(value)
- self.counters[index] = 1
self.values_int[index] = -1
- return 1
+ self.values_wref[index] = ref(value)
+ self.counters[index] = 1
+ return 1
@jit.elidable
def is_variable_constant(self, index):
More information about the pypy-commit
mailing list