Author: Stephan <[email protected]>
Branch:
Changeset: r153:8de686192a9c
Date: 2011-11-09 13:48 +0100
http://bitbucket.org/pypy/lang-js/changeset/8de686192a9c/
Log: memoize estimated stack size
diff --git a/js/jscode.py b/js/jscode.py
--- a/js/jscode.py
+++ b/js/jscode.py
@@ -31,15 +31,21 @@
self.updatelooplabel = []
from js.astbuilder import Scope
self.scope = Scope()
+ self._estimated_stack_size = -1
+ @jit.elidable
def estimated_stack_size(self):
- max_size = 0
- moving_size = 0
- for opcode in self.opcodes:
- moving_size += opcode.stack_change()
- max_size = max(moving_size, max_size)
- assert max_size >= 0
- return max_size
+ # TODO: compute only once
+ if self._estimated_stack_size == -1:
+ max_size = 0
+ moving_size = 0
+ for opcode in self.opcodes:
+ moving_size += opcode.stack_change()
+ max_size = max(moving_size, max_size)
+ assert max_size >= 0
+ self._estimated_stack_size = max_size
+
+ return self._estimated_stack_size
def emit_label(self, num = -1):
if num == -1:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit