Author: leo
Date: Mon Oct 17 07:59:58 2005
New Revision: 9500
Removed:
trunk/src/generic_register.c
Modified:
trunk/MANIFEST
trunk/config/gen/makefiles/root.in
trunk/imcc/instructions.c
trunk/include/parrot/interpreter.h
trunk/include/parrot/regfuncs.h
trunk/include/parrot/register.h
trunk/include/parrot/sub.h
trunk/ops/stack.ops
trunk/src/inter_create.c
trunk/src/register.c
trunk/src/sub.c
Log:
Variable-sized reg frames 5 - reimplement saveall/restoreall
* remove register frame stacks
* create one register stack
* remove src/generic_register.c
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Mon Oct 17 07:59:58 2005
@@ -1731,7 +1731,6 @@ src/exit.c
src/extend.c []
src/gc_gms.c []
src/gc_ims.c []
-src/generic_register.c []
src/global.c []
src/global_setup.c []
src/hash.c []
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Mon Oct 17 07:59:58 2005
@@ -1000,7 +1000,7 @@ $(SRC_DIR)/packout$(O) : $(GENERAL_H_FIL
$(SRC_DIR)/parrot$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/register$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/generic_register.c
+$(SRC_DIR)/register$(O) : $(GENERAL_H_FILES)
$(SRC_DIR)/runops_cores$(O) : $(GENERAL_H_FILES)
Modified: trunk/imcc/instructions.c
==============================================================================
--- trunk/imcc/instructions.c (original)
+++ trunk/imcc/instructions.c Mon Oct 17 07:59:58 2005
@@ -95,12 +95,10 @@ imcc_init_tables(Interp * interpreter)
{
size_t i;
const char *reads[] = {
- "saveall",
- "pushi", "pushn", "pushp", "pushs"
+ "saveall"
};
const char *writes[] = {
"restoreall",
- "popi", "popn", "popp", "pops",
"cleari", "clearn", "clearp", "clears",
};
/* init opnums */
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h (original)
+++ trunk/include/parrot/interpreter.h Mon Oct 17 07:59:58 2005
@@ -179,10 +179,7 @@ typedef struct Parrot_Context {
INTVAL ref_count; /* how often refered to */
struct parrot_regs_t *bp; /* register base pointer */
Regs_ps *bp_ps; /* yet unused */
- struct Stack_Chunk *int_reg_stack; /* register frame stacks */
- struct Stack_Chunk *num_reg_stack;
- struct Stack_Chunk *string_reg_stack;
- struct Stack_Chunk *pmc_reg_stack;
+ struct Stack_Chunk *reg_stack; /* register stack */
struct Stack_Chunk *pad_stack; /* Base of the lex pad stack */
struct Stack_Chunk *user_stack; /* Base of the scratch stack */
Modified: trunk/include/parrot/regfuncs.h
==============================================================================
--- trunk/include/parrot/regfuncs.h (original)
+++ trunk/include/parrot/regfuncs.h Mon Oct 17 07:59:58 2005
@@ -14,27 +14,15 @@
#define PARROT_REGISTER_FUNCS_H_GUARD
#include "parrot/parrot.h"
+
+void Parrot_push_regs(Interp *);
+void Parrot_pop_regs(Interp *);
+
void Parrot_clear_i(Interp *);
void Parrot_clear_s(Interp *);
void Parrot_clear_p(Interp *);
void Parrot_clear_n(Interp *);
-void Parrot_push_i(Interp *, void *where);
-void Parrot_push_n(Interp *, void *where);
-void Parrot_push_s(Interp *, void *where);
-void Parrot_push_p(Interp *, void *where);
-
-/*
-void Parrot_clone_i(Interp *);
-void Parrot_clone_n(Interp *);
-void Parrot_clone_s(Interp *);
-void Parrot_clone_p(Interp *);
-*/
-void Parrot_pop_i(Interp *, void *where);
-void Parrot_pop_n(Interp *, void *where);
-void Parrot_pop_s(Interp *, void *where);
-void Parrot_pop_p(Interp *, void *where);
-
void Parrot_push_on_stack(void *thing, INTVAL size, INTVAL type);
void Parrot_pop_off_stack(void *thing, INTVAL type);
@@ -44,7 +32,7 @@ void Parrot_pop_off_stack(void *thing, I
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
- * indent-tabs-mode: nil
+ * indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
Modified: trunk/include/parrot/register.h
==============================================================================
--- trunk/include/parrot/register.h (original)
+++ trunk/include/parrot/register.h Mon Oct 17 07:59:58 2005
@@ -20,43 +20,23 @@ struct IReg {
INTVAL registers[NUM_REGISTERS];
};
-struct IRegFrame {
- INTVAL registers[NUM_REGISTERS/2];
-};
-
struct NReg {
FLOATVAL registers[NUM_REGISTERS];
};
-struct NRegFrame {
- FLOATVAL registers[NUM_REGISTERS/2];
-};
-
struct SReg {
STRING *registers[NUM_REGISTERS];
};
-struct SRegFrame {
- STRING *registers[NUM_REGISTERS/2];
-};
-
struct PReg {
PMC *registers[NUM_REGISTERS];
};
-struct PRegFrame {
- PMC *registers[NUM_REGISTERS/2];
-};
-
struct Stack_Chunk;
void setup_register_stacks(Interp*);
void mark_register_stack(Interp* interpreter,
struct Stack_Chunk* stack);
-void mark_pmc_register_stack(Interp* interpreter,
- struct Stack_Chunk* stack);
-void mark_string_register_stack(Interp* interpreter,
- struct Stack_Chunk* stack);
#endif /* PARROT_REGISTER_H_GUARD */
Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h (original)
+++ trunk/include/parrot/sub.h Mon Oct 17 07:59:58 2005
@@ -130,7 +130,6 @@ PMC * new_ret_continuation_pmc(Interp *,
void mark_context(Interp *, parrot_context_t *);
-void mark_reg_stack(Interp *, Stack_Chunk_t *);
void invalidate_retc_context(Interp *interpreter, PMC *cont);
STRING* Parrot_full_sub_name(Interp* interpreter, PMC* sub);
Modified: trunk/ops/stack.ops
==============================================================================
--- trunk/ops/stack.ops (original)
+++ trunk/ops/stack.ops Mon Oct 17 07:59:58 2005
@@ -37,26 +37,12 @@ Restore all the registers from the regis
=cut
inline op saveall() :base_core {
- Parrot_push_i(interpreter, ®_INT(0));
- Parrot_push_i(interpreter, ®_INT(16));
- Parrot_push_s(interpreter, ®_STR(0));
- Parrot_push_s(interpreter, ®_STR(16));
- Parrot_push_n(interpreter, ®_NUM(0));
- Parrot_push_n(interpreter, ®_NUM(16));
- Parrot_push_p(interpreter, ®_PMC(0));
- Parrot_push_p(interpreter, ®_PMC(16));
+ Parrot_push_regs(interpreter);
goto NEXT();
}
inline op restoreall() :base_core {
- Parrot_pop_i(interpreter, ®_INT(16));
- Parrot_pop_i(interpreter, ®_INT(0));
- Parrot_pop_s(interpreter, ®_STR(16));
- Parrot_pop_s(interpreter, ®_STR(0));
- Parrot_pop_n(interpreter, ®_NUM(16));
- Parrot_pop_n(interpreter, ®_NUM(0));
- Parrot_pop_p(interpreter, ®_PMC(16));
- Parrot_pop_p(interpreter, ®_PMC(0));
+ Parrot_pop_regs(interpreter);
goto NEXT();
}
Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c (original)
+++ trunk/src/inter_create.c Mon Oct 17 07:59:58 2005
@@ -546,11 +546,6 @@ make_interpreter(Parrot_Interp parent, I
/* Set up the initial register chunks */
setup_register_stacks(interpreter);
- Parrot_clear_s(interpreter);
- Parrot_clear_p(interpreter);
- Parrot_clear_i(interpreter);
- Parrot_clear_n(interpreter);
-
/* Stack for lexical pads */
CONTEXT(interpreter->ctx)->pad_stack = new_stack(interpreter, "Pad");
Modified: trunk/src/register.c
==============================================================================
--- trunk/src/register.c (original)
+++ trunk/src/register.c Mon Oct 17 07:59:58 2005
@@ -39,6 +39,14 @@ setup_register_stacks(Parrot_Interp, str
Sets up the register stacks.
+=item C<void Parrot_push_regs(Interp *)>
+
+Save all registers onto the register stack.
+
+=item C<void Parrot_pop_regs(Interp *)>
+
+Restore all registers from register stack.
+
=cut
*/
@@ -46,119 +54,93 @@ Sets up the register stacks.
void
setup_register_stacks(Parrot_Interp interpreter)
{
- CONTEXT(interpreter->ctx)->int_reg_stack = register_new_stack(interpreter,
- "IntReg_", sizeof(struct IRegFrame));
+ CONTEXT(interpreter->ctx)->reg_stack =
+ register_new_stack(interpreter,
+ "Regs_", sizeof(struct parrot_regs_t));
- CONTEXT(interpreter->ctx)->string_reg_stack =
register_new_stack(interpreter,
- "StringReg_", sizeof(struct SRegFrame));
-
- CONTEXT(interpreter->ctx)->num_reg_stack = register_new_stack(interpreter,
- "NumReg_", sizeof(struct NRegFrame));
-
- CONTEXT(interpreter->ctx)->pmc_reg_stack = register_new_stack(interpreter,
- "PMCReg_", sizeof(struct PRegFrame));
}
-
-/*
-
-=item C<void
-mark_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* stack)>
-
-Marks the INT or NUM register stack as live.
-
-=item C<void
-mark_pmc_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* stack)>
-
-Marks the PMC register stack as live.
-
-=cut
-
-*/
-
void
-mark_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* chunk)
+Parrot_push_regs(Interp *interpreter)
{
- for (; ; chunk = chunk->prev) {
- pobject_lives(interpreter, (PObj*)chunk);
- if (chunk == chunk->prev)
- break;
- }
+ struct parrot_regs_t *bp = stack_prepare_push(interpreter,
+ &CONTEXT(interpreter->ctx)->reg_stack);
+ memcpy(bp, interpreter->ctx.bp, sizeof(struct parrot_regs_t));
}
void
-mark_pmc_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* chunk)
+Parrot_pop_regs(Interp* interpreter)
{
- UINTVAL j;
- for ( ; ; chunk = chunk->prev) {
- struct PRegFrame *pf = (struct PRegFrame *)STACK_DATAP(chunk);
-
- pobject_lives(interpreter, (PObj*)chunk);
- if (chunk == chunk->prev)
- break;
- /* TODO for variable sized chunks use buflen */
- for (j = 0; j < NUM_REGISTERS/2; j++) {
- PObj* reg = (PObj*) pf->registers[j];
- if (reg)
- pobject_lives(interpreter, reg);
- }
- }
+ /*
+ * TODO just move the base pointer - no copying needed
+ */
+ struct parrot_regs_t *bp = stack_prepare_pop(interpreter,
+ &CONTEXT(interpreter->ctx)->reg_stack);
+ memcpy(interpreter->ctx.bp, bp, sizeof(struct parrot_regs_t));
}
-/*
-
-=item C<void
-mark_reg_stack(Inter*, Stack_Chunk_t* chunk)>
-
-Marks one chunk of the register frame stack. Previous chunks are marked
-by marking the continuation of this frame.
-
- */
void
-mark_reg_stack(Parrot_Interp interpreter, Stack_Chunk_t* chunk)
+Parrot_clear_i(Interp *interpreter)
{
- UINTVAL j;
- PObj *obj;
+ int i;
+ for (i = 0; i < NUM_REGISTERS; ++i)
+ REG_INT(i) = 0;
+}
- struct parrot_regs_t *regs = (struct parrot_regs_t *)STACK_DATAP(chunk);
+void
+Parrot_clear_s(Interp *interpreter)
+{
+ int i;
+ for (i = 0; i < NUM_REGISTERS; ++i)
+ REG_STR(i) = NULL;
+}
- pobject_lives(interpreter, (PObj*)chunk);
+void
+Parrot_clear_p(Interp *interpreter)
+{
+ int i;
+ for (i = 0; i < NUM_REGISTERS; ++i)
+ REG_PMC(i) = PMCNULL;
+}
- for (j = 0; j < NUM_REGISTERS; j++) {
- obj = (PObj*) BP_REG_PMC(regs, j);
- if (obj)
- pobject_lives(interpreter, obj);
- obj = (PObj*) BP_REG_STR(regs, j);
- if (obj)
- pobject_lives(interpreter, obj);
- }
+void
+Parrot_clear_n(Interp *interpreter)
+{
+ int i;
+ for (i = 0; i < NUM_REGISTERS; ++i)
+ REG_NUM(i) = 0.0;
}
/*
=item C<void
-mark_string_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* stack)>
+mark_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* stack)>
-Mark the contents of the string register stack as live.
+Marks the register stack and it's registers as live.
=cut
*/
void
-mark_string_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* chunk)
+mark_register_stack(Parrot_Interp interpreter, Stack_Chunk_t* chunk)
{
- UINTVAL j;
- for ( ; ; chunk = chunk->prev) {
- struct SRegFrame *sf = (struct SRegFrame *)STACK_DATAP(chunk);
+ struct parrot_regs_t *regs;
+ int i;
+ PObj *obj;
+ for (; ; chunk = chunk->prev) {
pobject_lives(interpreter, (PObj*)chunk);
if (chunk == chunk->prev)
break;
- for (j = 0; j < NUM_REGISTERS/2; j++) {
- PObj* reg = (PObj*) sf->registers[j];
- if (reg)
- pobject_lives(interpreter, reg);
+ regs = (struct parrot_regs_t *)STACK_DATAP(chunk);
+ for (i = 0; i < NUM_REGISTERS; ++i) {
+ obj = (PObj *)BP_REG_PMC(regs, i);
+ if (obj)
+ pobject_lives(interpreter, obj);
+ obj = (PObj *)BP_REG_STR(regs, i);
+ if (obj)
+ pobject_lives(interpreter, obj);
}
}
}
@@ -202,42 +184,6 @@ Parrot_pop_off_stack(void *thing, INTVAL
UNUSED(type);
}
-#define REG_PUSH Parrot_push_i
-#define REG_POP Parrot_pop_i
-#define REG_CLEAR Parrot_clear_i
-#define REG_STACK int_reg_stack
-#define REG_TYPE int_reg
-#define REG_FRAME IRegFrame
-#define REG_NULL 0
-#include "generic_register.c"
-
-#define REG_PUSH Parrot_push_s
-#define REG_POP Parrot_pop_s
-#define REG_CLEAR Parrot_clear_s
-#define REG_STACK string_reg_stack
-#define REG_TYPE string_reg
-#define REG_FRAME SRegFrame
-#define REG_NULL NULL
-#include "generic_register.c"
-
-#define REG_PUSH Parrot_push_n
-#define REG_POP Parrot_pop_n
-#define REG_CLEAR Parrot_clear_n
-#define REG_STACK num_reg_stack
-#define REG_TYPE num_reg
-#define REG_FRAME NRegFrame
-#define REG_NULL 0.0
-#include "generic_register.c"
-
-#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"
-
/*
Modified: trunk/src/sub.c
==============================================================================
--- trunk/src/sub.c (original)
+++ trunk/src/sub.c Mon Oct 17 07:59:58 2005
@@ -42,10 +42,7 @@ mark_context(Interp* interpreter, parrot
mark_stack(interpreter, ctx->pad_stack);
mark_stack(interpreter, ctx->user_stack);
mark_stack(interpreter, ctx->control_stack);
- mark_register_stack(interpreter, ctx->int_reg_stack);
- mark_register_stack(interpreter, ctx->num_reg_stack);
- mark_string_register_stack(interpreter, ctx->string_reg_stack);
- mark_pmc_register_stack(interpreter, ctx->pmc_reg_stack);
+ mark_register_stack(interpreter, ctx->reg_stack);
obj = (PObj*)ctx->current_sub;
if (obj)
pobject_lives(interpreter, obj);