[pypy-svn] r76475 - in pypy/trunk/pypy: module/_stackless objspace/std
arigo at codespeak.net
arigo at codespeak.net
Wed Aug 4 18:55:06 CEST 2010
Author: arigo
Date: Wed Aug 4 18:55:02 2010
New Revision: 76475
Modified:
pypy/trunk/pypy/module/_stackless/interp_coroutine.py
pypy/trunk/pypy/objspace/std/callmethod.py
Log:
Properly fix the rstack.resume_point()s.
Note that there is no need for try:finally: in one of the
two cases in callmethod.py, if we make sure to pop all
arguments before the call, as pyopcode.py does.
Modified: pypy/trunk/pypy/module/_stackless/interp_coroutine.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/interp_coroutine.py (original)
+++ pypy/trunk/pypy/module/_stackless/interp_coroutine.py Wed Aug 4 18:55:02 2010
@@ -265,10 +265,14 @@
instr += 1
oparg = ord(code[instr]) | ord(code[instr + 1]) << 8
nargs = oparg & 0xff
+ nkwds = (oparg >> 8) & 0xff
if space.config.objspace.opcodes.CALL_METHOD and opcode == map['CALL_METHOD']:
- chain = resume_state_create(chain, 'CALL_METHOD', frame,
- nargs)
- elif opcode == map['CALL_FUNCTION'] and (oparg >> 8) & 0xff == 0:
+ if nkwds == 0: # only positional arguments
+ chain = resume_state_create(chain, 'CALL_METHOD', frame,
+ nargs)
+ else: # includes keyword arguments
+ chain = resume_state_create(chain, 'CALL_METHOD_KW', frame)
+ elif opcode == map['CALL_FUNCTION'] and nkwds == 0:
# Only positional arguments
# case1: ("CALL_FUNCTION", f, nargs, returns=w_result)
chain = resume_state_create(chain, 'CALL_FUNCTION', frame,
Modified: pypy/trunk/pypy/objspace/std/callmethod.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/callmethod.py (original)
+++ pypy/trunk/pypy/objspace/std/callmethod.py Wed Aug 4 18:55:02 2010
@@ -62,12 +62,13 @@
n_args = oparg & 0xff
n_kwargs = (oparg >> 8) & 0xff
w_self = f.peekvalue(n_args + (2 * n_kwargs))
- w_callable = f.peekvalue(n_args + (2 * n_kwargs) + 1)
n = n_args + (w_self is not None)
if not n_kwargs:
+ w_callable = f.peekvalue(n_args + (2 * n_kwargs) + 1)
try:
w_result = f.space.call_valuestack(w_callable, n, f)
+ rstack.resume_point("CALL_METHOD", f, n_args, returns=w_result)
finally:
f.dropvalues(n_args + 2)
else:
@@ -83,14 +84,13 @@
keywords[n_kwargs] = key
keywords_w[n_kwargs] = w_value
- arguments = f.popvalues(n)
+ arguments = f.popvalues(n) # includes w_self if it is not None
args = f.argument_factory(arguments, keywords, keywords_w, None, None)
-
- try:
- w_result = f.space.call_args(w_callable, args)
- finally:
- f.dropvalues(1 + (w_self is None))
- rstack.resume_point("CALL_METHOD", f, n_args, returns=w_result)
+ if w_self is None:
+ f.popvalue() # removes w_self, which is None
+ w_callable = f.popvalue()
+ w_result = f.space.call_args(w_callable, args)
+ rstack.resume_point("CALL_METHOD_KW", f, returns=w_result)
f.pushvalue(w_result)
More information about the Pypy-commit
mailing list