[pypy-svn] r58900 - pypy/branch/builtin-profiling/pypy/interpreter
arigo at codespeak.net
arigo at codespeak.net
Fri Oct 10 13:21:00 CEST 2008
Author: arigo
Date: Fri Oct 10 13:20:59 2008
New Revision: 58900
Modified:
pypy/branch/builtin-profiling/pypy/interpreter/baseobjspace.py
pypy/branch/builtin-profiling/pypy/interpreter/pyopcode.py
Log:
(antocuni, arigo)
Remove some code duplication.
Modified: pypy/branch/builtin-profiling/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/builtin-profiling/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/builtin-profiling/pypy/interpreter/baseobjspace.py Fri Oct 10 13:20:59 2008
@@ -695,32 +695,16 @@
def call_valuestack(self, w_func, nargs, frame):
from pypy.interpreter.function import Function, Method, is_builtin_code
- if frame.is_being_profiled:
- ec = self.getexecutioncontext()
- is_c_call = is_builtin_code(w_func)
-
- # XXX: this code is copied&pasted :-( from the slow path
- # below. The profiling info could be not very accurate
- # because by doing this we disable fast paths when calling
- # the function
+ if frame.is_being_profiled and is_builtin_code(w_func):
+ # XXX: this code is copied&pasted :-( from the slow path below
+ # call_valuestack().
args = frame.make_arguments(nargs)
try:
- try:
- if is_c_call:
- ec.c_call_trace(frame, w_func)
- w_res = self.call_args(w_func, args)
- if is_c_call:
- ec.c_return_trace(frame, w_res)
- return w_res
- except OperationError, e:
- if is_c_call:
- ec.c_exception_trace(frame, e.w_value)
- raise
+ return self.call_args_and_c_profile(frame, w_func, args)
finally:
if isinstance(args, ArgumentsFromValuestack):
args.frame = None
-
if not self.config.objspace.disable_call_speedhacks:
# XXX start of hack for performance
hint(w_func.__class__, promote=True)
@@ -746,6 +730,17 @@
if isinstance(args, ArgumentsFromValuestack):
args.frame = None
+ def call_args_and_c_profile(self, frame, w_func, args):
+ ec = self.getexecutioncontext()
+ ec.c_call_trace(frame, w_func)
+ try:
+ w_res = self.call_args(w_func, args)
+ except OperationError, e:
+ ec.c_exception_trace(frame, e.w_value)
+ raise
+ ec.c_return_trace(frame, w_res)
+ return w_res
+
def call_method(self, w_obj, methname, *arg_w):
w_meth = self.getattr(w_obj, self.wrap(methname))
return self.call_function(w_meth, *arg_w)
Modified: pypy/branch/builtin-profiling/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/builtin-profiling/pypy/interpreter/pyopcode.py (original)
+++ pypy/branch/builtin-profiling/pypy/interpreter/pyopcode.py Fri Oct 10 13:20:59 2008
@@ -867,18 +867,7 @@
args = Arguments(f.space, arguments, keywords, w_star, w_starstar)
w_function = f.popvalue()
if f.is_being_profiled and is_builtin_code(w_function):
- is_c_call = is_builtin_code(w_function)
- ec = f.space.getexecutioncontext()
- if is_c_call:
- ec.c_call_trace(f, w_function)
- try:
- w_result = f.space.call_args(w_function, args)
- except OperationError, e:
- if is_c_call:
- ec.c_exception_trace(f, e.w_value)
- raise
- if is_c_call:
- ec.c_return_trace(f, w_function)
+ w_result = f.space.call_args_and_c_profile(f, w_function, args)
else:
w_result = f.space.call_args(w_function, args)
rstack.resume_point("call_function", f, returns=w_result)
More information about the Pypy-commit
mailing list