+ Update 052_Rob_Ennals.pdf, courtesy of Elizabeth Mattijsen.
[parrot.git] / src / cpu_dep.c
blob7e9d2b276225e6c38237a8359c09d4569c8e95aa
1 /*
2 Copyright (C) 2001-2003, 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
23 =over 4
25 =cut
29 #include "parrot/parrot.h"
31 #ifdef __ia64__
33 # include <ucontext.h>
34 extern void *flush_reg_store(void);
35 # define BACKING_STORE_BASE 0x80000fff80000000
37 #endif
39 static void trace_system_stack(Interp *interp);
43 =item C<void trace_system_areas(Interp *interp)>
45 Traces the system stack and any additional CPU-specific areas.
47 =cut
51 void
52 trace_system_areas(Interp *interp)
54 #if defined(__sparc) /* Flush register windows */
55 static union {
56 unsigned int insns[4];
57 double align_hack[2];
58 } u = { {
59 # ifdef __sparcv9
60 0x81580000, /* flushw */
61 # else
62 0x91d02003, /* ta ST_FLUSH_WINDOWS */
63 # endif
64 0x81c3e008, /* retl */
65 0x01000000 /* nop */
66 } };
68 static void (*fn_ptr)(void) = (void (*)(void))&u.align_hack[0];
69 fn_ptr();
71 #elif defined(__ia64__)
73 struct ucontext ucp;
74 void *current_regstore_top;
76 getcontext(&ucp);
77 current_regstore_top = flush_reg_store();
79 trace_mem_block(interp, 0x80000fff80000000,
80 (size_t)current_regstore_top);
81 #else
83 # ifdef PARROT_HAS_HEADER_SETJMP
84 Parrot_jump_buff env;
86 /* Zero the Parrot_jump_buff, otherwise you will trace stale objects */
87 memset(&env, 0, sizeof (env));
89 /* this should put registers in env, which then get marked in
90 * trace_system_stack below
92 setjmp(env);
93 # endif
95 #endif
98 trace_system_stack(interp);
103 =item C<static void
104 trace_system_stack(Interp *interp)>
106 Traces the memory block starting at C<< interp->lo_var_ptr >>.
108 =cut
112 static void
113 trace_system_stack(Interp *interp)
115 size_t lo_var_ptr = (size_t)interp->lo_var_ptr;
117 trace_mem_block(interp, (size_t)lo_var_ptr,
118 (size_t)&lo_var_ptr);
123 =back
125 =head1 SEE ALSO
127 F<src/dod.c>, F<include/parrot/dod.h> and F<docs/infant.dev>.
129 =cut
135 * Local variables:
136 * c-file-style: "parrot"
137 * End:
138 * vim: expandtab shiftwidth=4: