* src/pmc/multisub.pmc:
[parrot.git] / src / cpu_dep.c
blob19c3780702caa82c6682883c5fd3a5c16d4dd81a
1 /*
2 Copyright (C) 2001-2007, The Perl Foundation.
3 $Id$
5 =head1 NAME
7 src/cpu_dep.c - CPU-dependent functions
9 =head1 DESCRIPTION
11 These functions are called while stackwalking during dead object
12 destruction. They implement conditional CPU-specific behaviour related
13 to register windowing.
15 Register windowing is a technique which avoids having to empty registers
16 by moving a virtual window up/down the register stack restricting the
17 number of registers which are visible.
19 Remember you read something about it in F<docs/infant.dev>?
21 =head2 Functions
25 #include "parrot/parrot.h"
27 /* HEADERIZER HFILE: include/parrot/dod.h */
29 /* HEADERIZER BEGIN: static */
31 static void trace_system_stack( PARROT_INTERP )
32 __attribute__nonnull__(1);
34 /* HEADERIZER END: static */
36 #ifdef __ia64__
38 # include <ucontext.h>
39 extern void *flush_reg_store(void);
40 # define BACKING_STORE_BASE 0x80000fff80000000
42 #endif
46 FUNCDOC: trace_system_areas
48 Traces the system stack and any additional CPU-specific areas.
52 void
53 trace_system_areas(PARROT_INTERP)
55 #if defined(__sparc) /* Flush register windows */
56 static union {
57 unsigned int insns[4];
58 double align_hack[2];
59 } u = { {
60 # ifdef __sparcv9
61 0x81580000, /* flushw */
62 # else
63 0x91d02003, /* ta ST_FLUSH_WINDOWS */
64 # endif
65 0x81c3e008, /* retl */
66 0x01000000 /* nop */
67 } };
69 static void (*fn_ptr)(void) = (void (*)(void))&u.align_hack[0];
70 fn_ptr();
72 #elif defined(__ia64__)
74 struct ucontext ucp;
75 void *current_regstore_top;
77 getcontext(&ucp);
78 current_regstore_top = flush_reg_store();
80 trace_mem_block(interp, 0x80000fff80000000,
81 (size_t)current_regstore_top);
82 #else
84 # ifdef PARROT_HAS_HEADER_SETJMP
85 Parrot_jump_buff env;
87 /* Zero the Parrot_jump_buff, otherwise you will trace stale objects */
88 memset(&env, 0, sizeof (env));
90 /* this should put registers in env, which then get marked in
91 * trace_system_stack below
93 setjmp(env);
94 # endif
96 #endif
99 trace_system_stack(interp);
104 FUNCDOC: trace_system_stack
106 Traces the memory block starting at C<< interp->lo_var_ptr >>.
110 static void
111 trace_system_stack(PARROT_INTERP)
113 const size_t lo_var_ptr = (size_t)interp->lo_var_ptr;
115 trace_mem_block(interp, (size_t)lo_var_ptr,
116 (size_t)&lo_var_ptr);
121 =head1 SEE ALSO
123 F<src/dod.c>, F<include/parrot/dod.h> and F<docs/infant.dev>.
129 * Local variables:
130 * c-file-style: "parrot"
131 * End:
132 * vim: expandtab shiftwidth=4: