[pypy-commit] pypy vmprof-newstack: fixes
fijal
noreply at buildbot.pypy.org
Wed Nov 4 03:49:13 EST 2015
Author: fijal
Branch: vmprof-newstack
Changeset: r80534:c67fc4fb2414
Date: 2015-11-04 08:49 +0000
http://bitbucket.org/pypy/pypy/changeset/c67fc4fb2414/
Log: fixes
diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -31,6 +31,7 @@
else:
self._code_unique_id = 0x7000000000000000
self.cintf = cintf.setup()
+ self._stack = self.cintf.vmprof_stack_new()
def _cleanup_(self):
self.is_enabled = False
@@ -129,7 +130,6 @@
if self.cintf.vmprof_register_virtual_function(name, uid, 500000) < 0:
raise VMProfError("vmprof buffers full! disk full or too slow")
-
def vmprof_execute_code(name, get_code_fn, result_class=None):
"""Decorator to be used on the function that interprets a code object.
@@ -147,7 +147,7 @@
"""
def decorate(func):
try:
- _get_vmprof()
+ _vmprof = _get_vmprof()
except cintf.VMProfPlatformUnsupported:
return func
@@ -169,6 +169,8 @@
@specialize.memo()
def get_ll_trampoline(token):
+ """ Used by the trampoline-version only
+ """
if result_class is None:
restok = "i"
else:
@@ -185,18 +187,27 @@
# If we are being JITted, we want to skip the trampoline, else the
# JIT cannot see through it.
#
- if we_are_translated() and not jit.we_are_jitted():
- # if we are translated, call the trampoline
+ if 0: # this is the trampoline case
+ if we_are_translated() and not jit.we_are_jitted():
+ # if we are translated, call the trampoline
+ unique_id = get_code_fn(*args)._vmprof_unique_id
+ ll_args, token = lower(*args)
+ ll_trampoline = get_ll_trampoline(token)
+ ll_result = ll_trampoline(*ll_args + (unique_id,))
+ if result_class is not None:
+ return cast_base_ptr_to_instance(result_class, ll_result)
+ else:
+ return ll_result
+ else:
+ return func(*args)
+ else: # this is the case of the stack
unique_id = get_code_fn(*args)._vmprof_unique_id
- ll_args, token = lower(*args)
- ll_trampoline = get_ll_trampoline(token)
- ll_result = ll_trampoline(*ll_args + (unique_id,))
- if result_class is not None:
- return cast_base_ptr_to_instance(result_class, ll_result)
- else:
- return ll_result
- else:
- return func(*args)
+ _vmprof.cintf.vmprof_stack_append(_vmprof._stack, unique_id)
+ try:
+ res = func(*args)
+ finally:
+ _vmprof.cintf.vmprof_stack_pop(_vmprof._stack)
+ return res
decorated_function.__name__ = func.__name__ + '_rvmprof'
return decorated_function
diff --git a/rpython/rlib/rvmprof/src/rvmprof.c b/rpython/rlib/rvmprof/src/rvmprof.c
--- a/rpython/rlib/rvmprof/src/rvmprof.c
+++ b/rpython/rlib/rvmprof/src/rvmprof.c
@@ -13,9 +13,9 @@
# include "common_header.h"
# include "rvmprof.h"
-# ifndef VMPROF_ADDR_OF_TRAMPOLINE
+/*# ifndef VMPROF_ADDR_OF_TRAMPOLINE
# error "RPython program using rvmprof, but not calling vmprof_execute_code()"
-# endif
+# endif*/
#endif
diff --git a/rpython/rlib/rvmprof/src/vmprof_stack.h b/rpython/rlib/rvmprof/src/vmprof_stack.h
--- a/rpython/rlib/rvmprof/src/vmprof_stack.h
+++ b/rpython/rlib/rvmprof/src/vmprof_stack.h
@@ -7,14 +7,14 @@
long stack_items[STACK_SIZE];
} vmprof_stack;
-void *vmprof_stack_new(void)
+RPY_EXTERN void *vmprof_stack_new(void)
{
vmprof_stack* stack = (vmprof_stack *)malloc(sizeof(vmprof_stack));
stack->stack_depth = 0;
return (void*)stack;
}
-int vmprof_stack_append(void *_stack, long item)
+RPY_EXTERN int vmprof_stack_append(void *_stack, long item)
{
vmprof_stack* stack = (vmprof_stack*)_stack;
if (stack->stack_depth >= STACK_SIZE - 1)
@@ -24,7 +24,7 @@
return 0;
}
-long vmprof_stack_pop(void *_stack)
+RPY_EXTERN long vmprof_stack_pop(void *_stack)
{
vmprof_stack* stack = (vmprof_stack*)_stack;
long res;
@@ -36,7 +36,7 @@
return res;
}
-void vmprof_stack_free(void* stack)
+RPY_EXTERN void vmprof_stack_free(void* stack)
{
free(stack);
}
\ No newline at end of file
More information about the pypy-commit
mailing list