Skip to content

Commit

Permalink
Use UINTVAL to store/pass CallContext n_regs_used. jimmy++ for TT#1397.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@43375 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bacek committed Jan 2, 2010
1 parent 578b04c commit 1a52f3a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 48 deletions.
4 changes: 2 additions & 2 deletions compilers/imcc/parser_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ imcc_compile(PARROT_INTERP, ARGIN(const char *s), int pasm_file,
struct parser_state_t *next;
void *yyscanner;
PMC *ignored;
INTVAL regs_used[4] = {3, 3, 3, 3};
UINTVAL regs_used[4] = {3, 3, 3, 3};
INTVAL eval_number;

do_yylex_init(interp, &yyscanner);
Expand Down Expand Up @@ -912,7 +912,7 @@ imcc_compile_file(PARROT_INTERP, ARGIN(const char *fullname),

/* need at least 3 regs for compilation of constant math e.g.
* add_i_ic_ic - see also IMCC_subst_constants() */
INTVAL regs_used[4] = {3, 3, 3, 3};
UINTVAL regs_used[4] = {3, 3, 3, 3};

if (IMCC_INFO(interp)->last_unit) {
/* a reentrant compile */
Expand Down
4 changes: 4 additions & 0 deletions compilers/pirc/src/bcgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ opcode_t /*@alt void@*/
emit_opcode(ARGIN(bytecode * const bc), opcode_t op)
__attribute__nonnull__(1);

int emit_pbc_key(ARGIN(bytecode * const bc), ARGIN(key * const k))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

FLOATVAL get_num_const(ARGIN(bytecode * const bc), unsigned index)
__attribute__nonnull__(1);

Expand Down
8 changes: 4 additions & 4 deletions include/parrot/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void Parrot_pop_context(PARROT_INTERP)
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC * Parrot_push_context(PARROT_INTERP, ARGIN(const INTVAL *n_regs_used))
PMC * Parrot_push_context(PARROT_INTERP, ARGIN(const UINTVAL *n_regs_used))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

Expand All @@ -459,7 +459,7 @@ void create_initial_context(PARROT_INTERP)
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
PMC * Parrot_alloc_context(PARROT_INTERP,
ARGIN(const INTVAL *number_regs_used),
ARGIN(const UINTVAL *number_regs_used),
ARGIN_NULLOK(PMC *old))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
Expand All @@ -472,7 +472,7 @@ PMC * Parrot_pcc_allocate_empty_context(PARROT_INTERP,

void Parrot_pcc_allocate_registers(PARROT_INTERP,
ARGIN(PMC *pmcctx),
ARGIN(const INTVAL *number_regs_used))
ARGIN(const UINTVAL *number_regs_used))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);
Expand All @@ -491,7 +491,7 @@ PMC * Parrot_pcc_init_context(PARROT_INTERP,
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
PMC * Parrot_set_new_context(PARROT_INTERP,
ARGIN(const INTVAL *number_regs_used))
ARGIN(const UINTVAL *number_regs_used))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

Expand Down
24 changes: 12 additions & 12 deletions src/call/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ an available context is stored corresponds to the size of the context.

static void allocate_registers(PARROT_INTERP,
ARGIN(PMC *pmcctx),
ARGIN(const INTVAL *number_regs_used))
ARGIN(const UINTVAL *number_regs_used))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);
Expand Down Expand Up @@ -201,7 +201,7 @@ void
create_initial_context(PARROT_INTERP)
{
ASSERT_ARGS(create_initial_context)
static INTVAL num_regs[] = {32, 32, 32, 32};
static UINTVAL num_regs[] = {32, 32, 32, 32};
PMC *ignored;

/* Create some initial free_list slots. */
Expand Down Expand Up @@ -358,7 +358,7 @@ init_context(PARROT_INTERP, ARGMOD(PMC *pmcctx), ARGIN_NULLOK(PMC *pmcold))

/*
=item C<PMC * Parrot_push_context(PARROT_INTERP, const INTVAL *n_regs_used)>
=item C<PMC * Parrot_push_context(PARROT_INTERP, const UINTVAL *n_regs_used)>
Creates and sets the current context to a new context, remembering the old
context in C<caller_ctx>. Suitable to use with C<Parrot_pop_context>.
Expand All @@ -371,7 +371,7 @@ PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_push_context(PARROT_INTERP, ARGIN(const INTVAL *n_regs_used))
Parrot_push_context(PARROT_INTERP, ARGIN(const UINTVAL *n_regs_used))
{
ASSERT_ARGS(Parrot_push_context)
PMC * const old = CURRENT_CONTEXT(interp);
Expand Down Expand Up @@ -451,7 +451,7 @@ Parrot_pcc_calculate_registers_size(PARROT_INTERP, ARGIN(const UINTVAL *number_r

/*
=item C<static void allocate_registers(PARROT_INTERP, PMC *pmcctx, const INTVAL
=item C<static void allocate_registers(PARROT_INTERP, PMC *pmcctx, const UINTVAL
*number_regs_used)>
Allocate registers inside Context.
Expand All @@ -460,7 +460,7 @@ Allocate registers inside Context.
*/
static void
allocate_registers(PARROT_INTERP, ARGIN(PMC *pmcctx), ARGIN(const INTVAL *number_regs_used))
allocate_registers(PARROT_INTERP, ARGIN(PMC *pmcctx), ARGIN(const UINTVAL *number_regs_used))
{
ASSERT_ARGS(allocate_registers)
Parrot_CallContext_attributes *ctx = PARROT_CALLCONTEXT(pmcctx);
Expand Down Expand Up @@ -497,7 +497,7 @@ allocate_registers(PARROT_INTERP, ARGIN(PMC *pmcctx), ARGIN(const INTVAL *number
/*
=item C<void Parrot_pcc_allocate_registers(PARROT_INTERP, PMC *pmcctx, const
INTVAL *number_regs_used)>
UINTVAL *number_regs_used)>
Allocate registers in Context.
Expand All @@ -507,7 +507,7 @@ Allocate registers in Context.

void
Parrot_pcc_allocate_registers(PARROT_INTERP, ARGIN(PMC *pmcctx),
ARGIN(const INTVAL *number_regs_used))
ARGIN(const UINTVAL *number_regs_used))
{
ASSERT_ARGS(Parrot_pcc_allocate_registers)
allocate_registers(interp, pmcctx, number_regs_used);
Expand Down Expand Up @@ -546,7 +546,7 @@ Parrot_pcc_free_registers(PARROT_INTERP, ARGIN(PMC *pmcctx))

/*
=item C<PMC * Parrot_alloc_context(PARROT_INTERP, const INTVAL
=item C<PMC * Parrot_alloc_context(PARROT_INTERP, const UINTVAL
*number_regs_used, PMC *old)>
Allocates and returns a new context. Does not set this new context as the
Expand All @@ -563,7 +563,7 @@ TODO: Remove this function!
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
PMC *
Parrot_alloc_context(PARROT_INTERP, ARGIN(const INTVAL *number_regs_used),
Parrot_alloc_context(PARROT_INTERP, ARGIN(const UINTVAL *number_regs_used),
ARGIN_NULLOK(PMC *old))
{
ASSERT_ARGS(Parrot_alloc_context)
Expand Down Expand Up @@ -623,7 +623,7 @@ Parrot_pcc_init_context(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(PMC *old))

/*
=item C<PMC * Parrot_set_new_context(PARROT_INTERP, const INTVAL
=item C<PMC * Parrot_set_new_context(PARROT_INTERP, const UINTVAL
*number_regs_used)>
Allocates and returns a new context as the current context. Note that the
Expand All @@ -636,7 +636,7 @@ register usage C<n_regs_used> is copied.
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
PMC *
Parrot_set_new_context(PARROT_INTERP, ARGIN(const INTVAL *number_regs_used))
Parrot_set_new_context(PARROT_INTERP, ARGIN(const UINTVAL *number_regs_used))
{
ASSERT_ARGS(Parrot_set_new_context)
PMC *old = CURRENT_CONTEXT(interp);
Expand Down
2 changes: 1 addition & 1 deletion src/call/pcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Parrot_pcc_invoke_from_sig_object(PARROT_INTERP, ARGIN(PMC *sub_obj),
ASSERT_ARGS(Parrot_pcc_invoke_from_sig_object)

opcode_t *dest;
INTVAL n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
UINTVAL n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
PMC *ctx = Parrot_push_context(interp, n_regs_used);
PMC * const ret_cont = new_ret_continuation_pmc(interp, NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/dynext.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ run_init_lib(PARROT_INTERP, ARGIN(void *handle),
void (*init_func)(PARROT_INTERP, PMC *);
PMC *lib_pmc;

INTVAL regs_used[] = { 2, 2, 2, 2 }; /* Arbitrary values */
UINTVAL regs_used[] = { 2, 2, 2, 2 }; /* Arbitrary values */
const int parrot_hll_id = 0;
PMC * context = Parrot_push_context(interp, regs_used);
Parrot_pcc_set_HLL(interp, context, parrot_hll_id);
Expand Down
2 changes: 1 addition & 1 deletion src/packfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4669,7 +4669,7 @@ compile_or_load_file(PARROT_INTERP, ARGIN(STRING *path),
ASSERT_ARGS(compile_or_load_file)
char * const filename = Parrot_str_to_cstring(interp, path);

INTVAL regs_used[] = { 2, 2, 2, 2 }; /* Arbitrary values */
UINTVAL regs_used[] = { 2, 2, 2, 2 }; /* Arbitrary values */
const int parrot_hll_id = 0;
PMC * context = Parrot_push_context(interp, regs_used);
Parrot_pcc_set_HLL(interp, context, parrot_hll_id);
Expand Down
53 changes: 26 additions & 27 deletions src/pmc/sub.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,32 @@ print_sub_name(PARROT_INTERP, ARGIN_NULLOK(PMC *sub))
}

pmclass Sub auto_attrs {
ATTR PackFile_ByteCode *seg; /* bytecode segment */
ATTR size_t start_offs; /* sub entry in ops from seg->base.data */
ATTR size_t end_offs;

ATTR INTVAL HLL_id; /* see src/hll.c XXX or per segment? */
ATTR PMC *namespace_name; /* where this Sub is in - this is either
* a String or a [Key] and describes
* the relative path in the NameSpace
*/
ATTR PMC *namespace_stash; /* the actual hash, HLL::namespace */
ATTR STRING *name; /* name of the sub */
ATTR STRING *method_name; /* method name of the sub */
ATTR STRING *ns_entry_name; /* ns entry name of the sub */
ATTR STRING *subid; /* The ID of the sub. */
ATTR INTVAL vtable_index; /* index in Parrot_vtable_slot_names */
ATTR PMC *multi_signature; /* list of types for MMD */
ATTR INTVAL n_regs_used[4]; /* INSP in PBC */

ATTR PMC *lex_info; /* LexInfo PMC */
ATTR PMC *outer_sub; /* :outer for closures */
ATTR PMC *eval_pmc; /* eval container / NULL */
ATTR PMC *ctx; /* the context this sub is in */
ATTR UINTVAL comp_flags; /* compile time and additional flags */
ATTR Parrot_sub_arginfo *arg_info;/* Argument counts and flags. */

/* - end common */
ATTR PMC *outer_ctx; /* outer context, if a closure */
ATTR PackFile_ByteCode *seg; /* bytecode segment */
ATTR size_t start_offs; /* sub entry in ops from seg->base.data */
ATTR size_t end_offs;

ATTR INTVAL HLL_id; /* see src/hll.c XXX or per segment? */
ATTR PMC *namespace_name; /* where this Sub is in - this is either
* a String or a [Key] and describes
* the relative path in the NameSpace
*/
ATTR PMC *namespace_stash; /* the actual hash, HLL::namespace */
ATTR STRING *name; /* name of the sub */
ATTR STRING *method_name; /* method name of the sub */
ATTR STRING *ns_entry_name; /* ns entry name of the sub */
ATTR STRING *subid; /* The ID of the sub. */
ATTR INTVAL vtable_index; /* index in Parrot_vtable_slot_names */
ATTR PMC *multi_signature; /* list of types for MMD */
ATTR UINTVAL n_regs_used[4]; /* INSP in PBC */

ATTR PMC *lex_info; /* LexInfo PMC */
ATTR PMC *outer_sub; /* :outer for closures */
ATTR PMC *eval_pmc; /* eval container / NULL */
ATTR PMC *ctx; /* the context this sub is in */
ATTR UINTVAL comp_flags; /* compile time and additional flags */
ATTR Parrot_sub_arginfo *arg_info; /* Argument counts and flags. */

ATTR PMC *outer_ctx; /* outer context, if a closure */

/*

Expand Down

0 comments on commit 1a52f3a

Please sign in to comment.