[pypy-commit] lang-js default: some "magic" jit annotations

stepahn noreply at buildbot.pypy.org
Tue Jun 14 20:09:29 CEST 2011


Author: Stephan <stephan at stzal.com>
Branch: 
Changeset: r101:2f4919f73524
Date: 2011-06-14 20:08 +0200
http://bitbucket.org/pypy/lang-js/changeset/2f4919f73524/

Log:	some "magic" jit annotations

diff --git a/js/jscode.py b/js/jscode.py
--- a/js/jscode.py
+++ b/js/jscode.py
@@ -6,6 +6,8 @@
 from js.opcodes import opcodes, POP, LABEL, BaseJump, WITH_START, WITH_END
 from js.jsobj import W_Root, W_String
 
+from pypy.rlib import jit, debug
+
 def get_printable_location(pc, jsfunction):
     try:
         return str(jsfunction.opcodes[pc])
@@ -48,12 +50,13 @@
         self.content[i] = element
         self.pointer = i + 1
 
+    @jit.unroll_safe
     def pop_n(self, n):
-        list = []
-        for i in xrange(0, n):
-            list.append(self.pop())
-        list.reverse()
-        return list
+        l = [None] * n
+        for i in range(n-1, -1, -1):
+            l[i] = self.pop()
+        debug.make_sure_not_resized(l)
+        return l
 
     def check(self):
         assert self.pointer == 1
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -147,7 +147,7 @@
         self.counter = counter
 
     def eval(self, ctx, stack):
-        list_w = stack.pop_n(self.counter)
+        list_w = stack.pop_n(self.counter)[:] # pop_n returns a non-resizable list
         stack.append(W_List(list_w))
 
     def __repr__(self):


More information about the pypy-commit mailing list