[pypy-svn] r51413 - pypy/dist/pypy/lang/smalltalk
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Feb 12 16:48:01 CET 2008
Author: cfbolz
Date: Tue Feb 12 16:48:00 2008
New Revision: 51413
Modified:
pypy/dist/pypy/lang/smalltalk/interpreter.py
Log:
tiny optimization to smalltalk vm
Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py Tue Feb 12 16:48:00 2008
@@ -356,6 +356,9 @@
def longJumpIfFalse(self, interp):
self.jumpConditional(interp.FALSE,self.longJumpPosition())
+ # RPython trick: specialize the following function on its second argument
+ # this makes sure that the primitive call is a direct one
+ @objectmodel.specialize.arg(1)
def callPrimitive(self, primitive, selector, argcount, interp):
# WARNING: this is used for bytecodes for which it is safe to
# directly call the primitive. In general, it is not safe: for
@@ -364,12 +367,14 @@
# else that the user put in a class in an 'at:' method.
# The rule of thumb is that primitives with only int and float
# in their unwrap_spec are safe.
- try:
- # note that argcount does not include self
- primitives.prim_table[primitive](interp, argcount)
- # the primitive pushes the result (if any) onto the stack itself
- except primitives.PrimitiveFailedError:
- self._sendSelfSelector(selector, argcount, interp)
+ for i, func in primitives.unrolling_prim_table:
+ if i == primitive:
+ try:
+ func(interp, argcount)
+ return
+ except primitives.PrimitiveFailedError:
+ break
+ self._sendSelfSelector(selector, argcount, interp)
def callPrimitive2(self, primitive1, primitive2,
selector, argcount, interp):
More information about the Pypy-commit
mailing list