/
generic_register.c
117 lines (80 loc) · 1.95 KB
/
generic_register.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
$Id$
=head1 NAME
src/generic_register.c - Generalized register handling routines
=head1 SYNOPSIS
#define REG_PUSH Parrot_push_p
#define REG_POP Parrot_pop_p
#define REG_CLEAR Parrot_clear_p
#define REG_STACK pmc_reg_stack
#define REG_TYPE pmc_reg
#define REG_FRAME PRegFrame
#define REG_NULL PMCNULL
#include "generic_register.c"
=head1 DESCRIPTION
This the generalized register handling routines, it uses macros to
define the things that are not common to all of the register stacks, and
then undefines the macros at the end of the file.
=head2 Functions
=over 4
=cut
*/
#include "parrot/parrot.h"
/*
=item C<void
REG_PUSH(Interp *interpreter, void *where)>
Pushes a new register frame onto the corresponding frame stack.
=cut
*/
void
REG_PUSH(Interp *interpreter, void *where)
{
void* top;
top = stack_prepare_push(interpreter, &interpreter->ctx.REG_STACK);
Parrot_memcpy_aligned(top, where, sizeof(struct REG_FRAME));
}
/*
=item C<void
REG_POP(Interp *interpreter, void *where)>
Pops a register frame from the corresponding frame stack.
=cut
*/
void
REG_POP(Interp *interpreter, void *where)
{
void* top;
top = stack_prepare_pop(interpreter, &interpreter->ctx.REG_STACK);
Parrot_memcpy_aligned(where, top, sizeof(struct REG_FRAME));
}
/*
=item C<void
REG_CLEAR(Interp *interpreter)>
Sets each register in the current set to C<REG_NULL>.
=cut
*/
void
REG_CLEAR(Interp *interpreter)
{
int i;
for (i = 0; i < NUM_REGISTERS; i++) {
#ifdef SLIDING_BP
interpreter->ctx.bp->registers[i].REG_TYPE = REG_NULL;
#else
interpreter->ctx.bp->REG_TYPE.registers[i] = REG_NULL;
#endif
}
}
#undef REG_PUSH
#undef REG_POP
#undef REG_CLEAR
#undef REG_STACK
#undef REG_TYPE
#undef REG_FRAME
#undef REG_NULL
/*
=back
=head1 SEE ALSO
F<include/parrot/register.h>, F<include/parrot/regfuncs.h> and F<src/register.c>.
=cut
*/