Author: fijal
Branch: vmprof-newstack
Changeset: r81618:894173dc749c
Date: 2016-01-08 11:02 +0200
http://bitbucket.org/pypy/pypy/changeset/894173dc749c/
Log: kill some irrelevant parts
diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -104,7 +104,7 @@
target = target.join('trampoline_%s_%s.vmprof.c' % (name, token))
target.write("""
#include "src/precommondefs.h"
-%(vmprof_stack_h)s
+#include "vmprof_stack.h"
%(type)s %(cont_name)s(%(llargs)s);
@@ -122,106 +122,18 @@
return result;
}
""" % locals())
- return finish_ll_trampoline(tramp_name, tramp_name, target, token,
- restok)
-
-def make_trampoline_function(name, func, token, restok):
- from rpython.jit.backend import detect_cpu
-
- cont_name = 'rpyvmprof_f_%s_%s' % (name, token)
- tramp_name = 'rpyvmprof_t_%s_%s' % (name, token)
- orig_tramp_name = tramp_name
-
- func.c_name = cont_name
- func._dont_inline_ = True
-
- if sys.platform == 'darwin':
- # according to internet "At the time UNIX was written in 1974...."
- # "... all C functions are prefixed with _"
- cont_name = '_' + cont_name
- tramp_name = '_' + tramp_name
- PLT = ""
- size_decl = ""
- type_decl = ""
- extra_align = ""
- else:
- PLT = "@PLT"
- type_decl = "\t.type\t%s, @function" % (tramp_name,)
- size_decl = "\t.size\t%s, .-%s" % (
- tramp_name, tramp_name)
- extra_align = "\t.cfi_def_cfa_offset 8"
-
- assert detect_cpu.autodetect().startswith(detect_cpu.MODEL_X86_64), (
- "rvmprof only supports x86-64 CPUs for now")
-
- # mapping of argument count (not counting the final uid argument) to
- # the register that holds this uid argument
- reg = {0: '%rdi',
- 1: '%rsi',
- 2: '%rdx',
- 3: '%rcx',
- 4: '%r8',
- 5: '%r9',
- }
- try:
- reg = reg[len(token)]
- except KeyError:
- raise NotImplementedError(
- "not supported: %r takes more than 5 arguments" % (func,))
-
- target = udir.join('module_cache')
- target.ensure(dir=1)
- target = target.join('trampoline_%s_%s.vmprof.s' % (name, token))
- # NOTE! the tabs in this file are absolutely essential, things
- # that don't start with \t are silently ignored (<arigato>: WAT!?)
- target.write("""\
-\t.text
-\t.globl\t%(tramp_name)s
-%(type_decl)s
-%(tramp_name)s:
-\t.cfi_startproc
-\tpushq\t%(reg)s
-\t.cfi_def_cfa_offset 16
-\tcall %(cont_name)s%(PLT)s
-\taddq\t$8, %%rsp
-%(extra_align)s
-\tret
-\t.cfi_endproc
-%(size_decl)s
-""" % locals())
- return finish_ll_trampoline(orig_tramp_name, tramp_name, target, token,
- restok)
-
-def finish_ll_trampoline(orig_tramp_name, tramp_name, target, token, restok):
-
- extra_args = ['long']
header = 'RPY_EXTERN %s %s(%s);\n' % (
- token2ctype(restok),
- orig_tramp_name,
- ', '.join([token2ctype(tok) for tok in token] + extra_args))
-
- header += """\
-static int cmp_%s(void *addr) {
- if (addr == %s) return 1;
-#ifdef VMPROF_ADDR_OF_TRAMPOLINE
- return VMPROF_ADDR_OF_TRAMPOLINE(addr);
-#undef VMPROF_ADDR_OF_TRAMPOLINE
-#else
- return 0;
-#endif
-#define VMPROF_ADDR_OF_TRAMPOLINE cmp_%s
-}
-""" % (tramp_name, orig_tramp_name, tramp_name)
+ token2ctype(restok), tramp_name,
+ ', '.join([token2ctype(tok) for tok in token] + ['long']))
eci = ExternalCompilationInfo(
post_include_bits = [header],
separate_module_files = [str(target)],
)
eci = eci.merge(global_eci)
-
ARGS = [token2lltype(tok) for tok in token] + [lltype.Signed]
return rffi.llexternal(
- orig_tramp_name, ARGS,
+ tramp_name, ARGS,
token2lltype(restok),
compilation_info=eci,
_nowrapper=True, sandboxsafe=True,
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
@@ -27,10 +27,7 @@
self._code_classes = set()
self._gather_all_code_objs = lambda: None
self._cleanup_()
- if sys.maxint == 2147483647:
- self._code_unique_id = 0 # XXX this is wrong, it won't work on
32bit
- else:
- self._code_unique_id = 0x7000000000000000
+ self._code_unique_id = 0
self.cintf = cintf.setup()
def _cleanup_(self):
diff --git a/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h
b/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h
--- a/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h
+++ b/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h
@@ -11,68 +11,6 @@
static void *tramp_start, *tramp_end;
#endif
-
-static ptrdiff_t vmprof_unw_get_custom_offset(void* ip, void *cp) {
-
-#if defined(PYPY_JIT_CODEMAP)
-
- intptr_t ip_l = (intptr_t)ip;
- return pypy_jit_stack_depth_at_loc(ip_l);
-
-#elif defined(CPYTHON_GET_CUSTOM_OFFSET)
-
- if (ip >= tramp_start && ip <= tramp_end) {
- // XXX the return value is wrong for all the places before push and
- // after pop, fix
- void *bp;
- void *sp;
-
- /* This is a stage2 trampoline created by hotpatch:
-
- push %rbx
- push %rbp
- mov %rsp,%rbp
- and $0xfffffffffffffff0,%rsp // make sure the stack is
aligned
- movabs $0x7ffff687bb10,%rbx
- callq *%rbx
- leaveq
- pop %rbx
- retq
-
- the stack layout is like this:
-
- +-----------+ high addresses
- | ret addr |
- +-----------+
- | saved rbx | start of the function frame
- +-----------+
- | saved rbp |
- +-----------+
- | ........ | <-- rbp
- +-----------+ low addresses
-
- So, the trampoline frame starts at rbp+16, and the return address,
- is at rbp+24. The vmprof API requires us to return the offset of
- the frame relative to sp, hence we have this weird computation.
-
- XXX (antocuni): I think we could change the API to return directly
- the frame address instead of the offset; however, this require a
- change in the PyPy code too
- */
-
- unw_get_reg (cp, UNW_REG_SP, (unw_word_t*)&sp);
- unw_get_reg (cp, UNW_X86_64_RBP, (unw_word_t*)&bp);
- return bp+16+8-sp;
- }
- return -1;
-
-#else
-
- return -1;
-
-#endif
-}
-
static long vmprof_write_header_for_jit_addr(void **result, long n,
void *ip, int max_depth)
{
diff --git a/rpython/rlib/rvmprof/src/vmprof_main.h
b/rpython/rlib/rvmprof/src/vmprof_main.h
--- a/rpython/rlib/rvmprof/src/vmprof_main.h
+++ b/rpython/rlib/rvmprof/src/vmprof_main.h
@@ -25,17 +25,14 @@
#include <sys/time.h>
#include <errno.h>
#include <unistd.h>
+#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <fcntl.h>
#include "vmprof_getpc.h"
-#ifdef __APPLE__
-#include "libunwind.h"
-#else
-#include "vmprof_unwind.h"
-#endif
#include "vmprof_mt.h"
#include "vmprof_stack.h"
@@ -58,14 +55,6 @@
static int opened_profile(char *interp_name);
static void flush_codes(void);
-#ifdef __APPLE__
-#define UNWIND_NAME "/usr/lib/system/libunwind.dylib"
-#define UNW_PREFIX "unw"
-#else
-#define UNWIND_NAME "libunwind.so"
-#define UNW_PREFIX "_ULx86_64"
-#endif
-
RPY_EXTERN
char *vmprof_init(int fd, double interval, char *interp_name)
{
@@ -73,22 +62,6 @@
return "bad value for 'interval'";
prepare_interval_usec = (int)(interval * 1000000.0);
-#ifndef __APPLE__
- if (!unw_get_reg) {
- void *libhandle;
-
- if (!(libhandle = dlopen(UNWIND_NAME, RTLD_LAZY | RTLD_LOCAL)))
- goto error;
- if (!(unw_get_reg = dlsym(libhandle, UNW_PREFIX "_get_reg")))
- goto error;
- if (!(unw_get_proc_info = dlsym(libhandle, UNW_PREFIX
"_get_proc_info")))
- goto error;
- if (!(unw_init_local = dlsym(libhandle, UNW_PREFIX "_init_local")))
- goto error;
- if (!(unw_step = dlsym(libhandle, UNW_PREFIX "_step")))
- goto error;
- }
-#endif
if (prepare_concurrent_bufs() < 0)
return "out of memory";
@@ -99,9 +72,6 @@
return strerror(errno);
}
return NULL;
-
- error:
- return dlerror();
}
/************************************************************/
@@ -158,55 +128,8 @@
static char atfork_hook_installed = 0;
-/* ******************************************************
- * libunwind workaround for process JIT frames correctly
- * ******************************************************
- */
-
#include "vmprof_get_custom_offset.h"
-typedef struct {
- void* _unused1;
- void* _unused2;
- void* sp;
- void* ip;
- void* _unused3[sizeof(unw_cursor_t)/sizeof(void*) - 4];
-} vmprof_hacked_unw_cursor_t;
-
-static int vmprof_unw_step(unw_cursor_t *cp, int first_run)
-{
- void* ip;
- void* sp;
- ptrdiff_t sp_offset;
- unw_get_reg (cp, UNW_REG_IP, (unw_word_t*)&ip);
- unw_get_reg (cp, UNW_REG_SP, (unw_word_t*)&sp);
- if (!first_run) {
- // make sure we're pointing to the CALL and not to the first
- // instruction after. If the callee adjusts the stack for us
- // it's not safe to be at the instruction after
- ip -= 1;
- }
- sp_offset = vmprof_unw_get_custom_offset(ip, cp);
-
- if (sp_offset == -1) {
- // it means that the ip is NOT in JITted code, so we can use the
- // stardard unw_step
- return unw_step(cp);
- }
- else {
- // this is a horrible hack to manually walk the stack frame, by
- // setting the IP and SP in the cursor
- vmprof_hacked_unw_cursor_t *cp2 = (vmprof_hacked_unw_cursor_t*)cp;
- void* bp = (void*)sp + sp_offset;
- cp2->sp = bp;
- bp -= sizeof(void*);
- cp2->ip = ((void**)bp)[0];
- // the ret is on the top of the stack minus WORD
- return 1;
- }
-}
-
-
/* *************************************************************
* functions to dump the stack trace
* *************************************************************
@@ -214,7 +137,6 @@
static int get_stack_trace(void **result, int max_depth, ucontext_t *ucontext)
{
- // read the first slot of shadowstack
struct vmprof_stack* stack = vmprof_global_stack;
int n = 0;
while (n < max_depth - 1 && stack) {
@@ -226,6 +148,7 @@
return n;
}
+#if 0
static int xxx_get_stack_trace(void** result, int max_depth, ucontext_t
*ucontext)
{
void *ip;
@@ -271,6 +194,7 @@
}
return n;
}
+#endif
static void *get_current_thread_id(void)
{
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
@@ -22,4 +22,4 @@
RPY_EXTERN void *vmprof_address_of_global_stack(void)
{
return (void*)&vmprof_global_stack;
-}
\ No newline at end of file
+}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit