Author: infinoid
Date: Wed Dec 31 18:15:58 2008
New Revision: 34732
Modified:
trunk/compilers/imcc/symreg.c
trunk/src/inter_call.c
trunk/src/inter_misc.c
trunk/src/pmc.c
trunk/src/utils.c
Log:
[core] Add argument assertions to another 145 functions.
Modified: trunk/compilers/imcc/symreg.c
==============================================================================
--- trunk/compilers/imcc/symreg.c (original)
+++ trunk/compilers/imcc/symreg.c Wed Dec 31 18:15:58 2008
@@ -121,6 +121,7 @@
push_namespace(SHIM_INTERP, ARGIN(const char *name))
{
Namespace * const ns = mem_allocate_zeroed_typed(Namespace);
+ ASSERT_ARGS(push_namespace);
ns->parent = _namespace;
ns->name = str_dup(name);
@@ -143,6 +144,7 @@
pop_namespace(PARROT_INTERP, ARGIN(const char *name))
{
Namespace * const ns = _namespace;
+ ASSERT_ARGS(pop_namespace);
if (!ns)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR, "pop() on empty namespace
stack\n");
@@ -179,6 +181,7 @@
{
SymReg *p;
const unsigned int i = hash_str(name) % hsh->size;
+ ASSERT_ARGS(_get_sym_typed);
for (p = hsh->data[i]; p; p = p->next) {
if ((t == p->set) && STREQ(name, p->name))
@@ -207,6 +210,7 @@
_mk_symreg(ARGMOD(SymHash *hsh), ARGIN(const char *name), int t)
{
SymReg * r = _get_sym_typed(hsh, name, t);
+ ASSERT_ARGS(_mk_symreg);
if (!r) {
r = mem_allocate_zeroed_typed(SymReg);
@@ -239,6 +243,7 @@
mk_symreg(PARROT_INTERP, ARGIN(const char *name), int t)
{
IMC_Unit * const unit = IMCC_INFO(interp)->last_unit;
+ ASSERT_ARGS(mk_symreg);
return _mk_symreg(&unit->hash, name, t);
}
@@ -263,6 +268,7 @@
* may be included in the sprintf output (for now) */
char * const buf = (char *)mem_sys_allocate(250 + strlen(s->name));
const int t = s->type;
+ ASSERT_ARGS(symreg_to_str);
sprintf(buf, "symbol [%s] set [%c] color [" INTVAL_FMT "] type [",
s->name, s->set, s->color);
@@ -302,6 +308,7 @@
{
char buf[30];
static int temp;
+ ASSERT_ARGS(mk_temp_reg);
snprintf(buf, sizeof (buf), "__imcc_temp_%d", ++temp);
return mk_symreg(interp, buf, t);
@@ -326,6 +333,7 @@
{
IMC_Unit * const unit = IMCC_INFO(interp)->last_unit;
SymReg * const r = _mk_symreg(&unit->hash, name, proto);
+ ASSERT_ARGS(mk_pcc_sub);
r->type = VT_PCC_SUB;
r->pcc_sub = mem_allocate_zeroed_typed(pcc_sub_t);
@@ -348,6 +356,7 @@
add_namespace(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
{
SymReg * const ns = IMCC_INFO(interp)->cur_namespace;
+ ASSERT_ARGS(add_namespace);
if (!ns)
return;
@@ -386,6 +395,7 @@
{
pcc_sub_t * const sub = r->pcc_sub;
const int n = sub->nargs;
+ ASSERT_ARGS(add_pcc_arg);
mem_realloc_n_typed(sub->args, n + 1, SymReg *);
mem_realloc_n_typed(sub->arg_flags, n + 1, int);
@@ -414,6 +424,7 @@
{
pcc_sub_t * const sub = r->pcc_sub;
const int n = sub->nret;
+ ASSERT_ARGS(add_pcc_result);
mem_realloc_n_typed(sub->ret, n + 1, SymReg *);
mem_realloc_n_typed(sub->ret_flags, n + 1, int);
@@ -444,6 +455,7 @@
{
pcc_sub_t * const sub = r->pcc_sub;
const int n = sub->nmulti;
+ ASSERT_ARGS(add_pcc_multi);
mem_realloc_n_typed(sub->multi, n + 1, SymReg *);
sub->multi[n] = arg;
@@ -464,6 +476,7 @@
void
add_pcc_sub(ARGMOD(SymReg *r), ARGIN(SymReg *arg))
{
+ ASSERT_ARGS(add_pcc_sub);
r->pcc_sub->sub = arg;
}
@@ -481,6 +494,7 @@
void
add_pcc_cc(ARGMOD(SymReg *r), ARGIN(SymReg *arg))
{
+ ASSERT_ARGS(add_pcc_cc);
r->pcc_sub->cc = arg;
}
@@ -501,6 +515,7 @@
mk_pasm_reg(PARROT_INTERP, ARGIN(const char *name))
{
SymReg *r = _get_sym(&IMCC_INFO(interp)->cur_unit->hash, name);
+ ASSERT_ARGS(mk_pasm_reg);
if (!r) {
r = mk_symreg(interp, name, *name);
@@ -535,6 +550,7 @@
static char *
_mk_fullname(ARGIN_NULLOK(const Namespace *ns), ARGIN(const char *name))
{
+ ASSERT_ARGS(_mk_fullname);
if (ns) {
const size_t len = strlen(name) + strlen(ns->name) + 3;
char *result = (char *) mem_sys_allocate(len);
@@ -563,6 +579,7 @@
{
char * const fullname = _mk_fullname(_namespace, name);
SymReg *r = mk_symreg(interp, fullname, t);
+ ASSERT_ARGS(mk_ident);
r->type = VTIDENTIFIER;
@@ -601,6 +618,7 @@
mk_ident_ur(PARROT_INTERP, ARGIN(const char *name), int t)
{
SymReg * const r = mk_ident(interp, name, t);
+ ASSERT_ARGS(mk_ident_ur);
r->usage |= U_NON_VOLATILE;
return r;
@@ -627,6 +645,7 @@
SymReg *r[3];
char *name;
int len;
+ ASSERT_ARGS(mk_pmc_const_2);
if (IMCC_INFO(interp)->state->pasm_file)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR,
@@ -680,6 +699,7 @@
ARGMOD(SymReg *val), int global)
{
SymReg *r;
+ ASSERT_ARGS(mk_const_ident);
/*
* Forbid assigning a string to anything other than a string
@@ -730,6 +750,7 @@
_mk_const(ARGMOD(SymHash *hsh), ARGIN(const char *name), int t)
{
SymReg * const r = _mk_symreg(hsh, name, t);
+ ASSERT_ARGS(_mk_const);
r->type = VTCONST;
if (t == 'U') {
@@ -753,6 +774,7 @@
int_overflows(ARGIN(const SymReg *r))
{
INTVAL i;
+ ASSERT_ARGS(int_overflows);
errno = 0;
if (r->type & VT_CONSTP)
@@ -790,6 +812,7 @@
mk_const(PARROT_INTERP, ARGIN(const char *name), int t)
{
SymHash * const h = &IMCC_INFO(interp)->ghash;
+ ASSERT_ARGS(mk_const);
if (!h->data)
create_symhash(h);
@@ -816,6 +839,7 @@
{
size_t len, l;
char *ns_name, *p;
+ ASSERT_ARGS(add_ns);
if (!IMCC_INFO(interp)->cur_namespace
|| (l = strlen(IMCC_INFO(interp)->cur_namespace->name)) <= 2)
@@ -860,6 +884,7 @@
_mk_address(PARROT_INTERP, ARGMOD(SymHash *hsh), ARGIN(const char *name), int
uniq)
{
SymReg *r;
+ ASSERT_ARGS(_mk_address);
if (uniq == U_add_all) {
r = mem_allocate_zeroed_typed(SymReg);
@@ -920,6 +945,7 @@
{
SymReg * const s = _mk_address(interp, &IMCC_INFO(interp)->ghash,
name, U_add_uniq_sub);
+ ASSERT_ARGS(mk_sub_label);
s->usage |= U_FIXUP;
@@ -944,6 +970,7 @@
{
SymReg * const s = _mk_address(interp, &IMCC_INFO(interp)->ghash,
name, U_add_all);
+ ASSERT_ARGS(mk_sub_address);
s->usage |= U_FIXUP;
@@ -967,6 +994,7 @@
mk_local_label(PARROT_INTERP, ARGIN(const char *name))
{
IMC_Unit * const unit = IMCC_INFO(interp)->last_unit;
+ ASSERT_ARGS(mk_local_label);
return _mk_address(interp, &unit->hash, name, U_add_uniq_label);
}
@@ -987,6 +1015,7 @@
mk_label_address(PARROT_INTERP, ARGIN(const char *name))
{
IMC_Unit * const unit = IMCC_INFO(interp)->last_unit;
+ ASSERT_ARGS(mk_label_address);
return _mk_address(interp, &unit->hash, name, U_add_once);
}
@@ -1041,6 +1070,7 @@
dup_sym(ARGIN(const SymReg *r))
{
SymReg * const new_sym = mem_allocate_zeroed_typed(SymReg);
+ ASSERT_ARGS(dup_sym);
STRUCT_COPY(new_sym, r);
new_sym->name = str_dup(r->name);
@@ -1077,6 +1107,7 @@
SymHash * const h = IMCC_INFO(interp)->cur_unit
? &IMCC_INFO(interp)->cur_unit->hash
: &IMCC_INFO(interp)->ghash;
+ ASSERT_ARGS(link_keys);
if (nargs == 0)
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR, "link_keys: huh? no
keys\n");
@@ -1161,6 +1192,7 @@
free_sym(ARGMOD(SymReg *r))
{
pcc_sub_t * const sub = r->pcc_sub;
+ ASSERT_ARGS(free_sym);
if (sub) {
mem_sys_free(sub->multi);
@@ -1204,6 +1236,7 @@
void
create_symhash(ARGOUT(SymHash *hash))
{
+ ASSERT_ARGS(create_symhash);
hash->data = mem_allocate_n_zeroed_typed(16, SymReg *);
hash->size = 16;
hash->entries = 0;
@@ -1228,6 +1261,7 @@
SymReg **next_r = mem_allocate_n_zeroed_typed(n_next, SymReg *);
SymHash nh; /* new symbol table */
unsigned int i;
+ ASSERT_ARGS(resize_symhash);
nh.data = mem_allocate_n_zeroed_typed(new_size, SymReg *);
@@ -1283,6 +1317,7 @@
_store_symreg(ARGMOD(SymHash *hsh), ARGMOD(SymReg *r))
{
const int i = hash_str(r->name) % hsh->size;
+ ASSERT_ARGS(_store_symreg);
#if IMC_TRACE_HIGH
printf(" store [%s]\n", r->name);
#endif
@@ -1309,6 +1344,7 @@
void
store_symreg(PARROT_INTERP, ARGMOD(SymReg *r))
{
+ ASSERT_ARGS(store_symreg);
_store_symreg(&IMCC_INFO(interp)->cur_unit->hash, r);
}
@@ -1330,6 +1366,7 @@
{
SymReg *p;
const unsigned int i = hash_str(name) % hsh->size;
+ ASSERT_ARGS(_get_sym);
for (p = hsh->data[i]; p; p = p->next) {
#if IMC_TRACE_HIGH
@@ -1357,6 +1394,7 @@
SymReg *
get_sym(PARROT_INTERP, ARGIN(const char *name))
{
+ ASSERT_ARGS(get_sym);
return _get_sym(&IMCC_INFO(interp)->cur_unit->hash, name);
}
@@ -1379,6 +1417,7 @@
{
const Namespace *ns;
SymReg *p;
+ ASSERT_ARGS(_find_sym);
for (ns = nspace; ns; ns = ns->parent) {
char * const fullname = _mk_fullname(ns, name);
@@ -1420,6 +1459,7 @@
SymReg *
find_sym(PARROT_INTERP, ARGIN(const char *name))
{
+ ASSERT_ARGS(find_sym);
if (IMCC_INFO(interp)->cur_unit)
return _find_sym(interp, _namespace,
&IMCC_INFO(interp)->cur_unit->hash, name);
@@ -1442,6 +1482,7 @@
clear_sym_hash(ARGMOD(SymHash *hsh))
{
unsigned int i;
+ ASSERT_ARGS(clear_sym_hash);
if (!hsh->data)
return;
@@ -1479,6 +1520,7 @@
debug_dump_sym_hash(ARGIN(const SymHash *hsh))
{
unsigned int i;
+ ASSERT_ARGS(debug_dump_sym_hash);
for (i = 0; i < hsh->size; i++) {
const SymReg *p = hsh->data[i];
@@ -1505,6 +1547,7 @@
{
SymHash * const hsh = &unit->hash;
unsigned int i;
+ ASSERT_ARGS(clear_locals);
for (i = 0; i < hsh->size; i++) {
SymReg *p;
@@ -1540,6 +1583,7 @@
clear_globals(PARROT_INTERP)
{
SymHash * const hsh = &IMCC_INFO(interp)->ghash;
+ ASSERT_ARGS(clear_globals);
if (hsh->data)
clear_sym_hash(hsh);
@@ -1564,6 +1608,7 @@
{
unsigned long key = 0;
const char *s;
+ ASSERT_ARGS(hash_str);
for (s = str; *s; s++)
key = key * 65599 + *s;
Modified: trunk/src/inter_call.c
==============================================================================
--- trunk/src/inter_call.c (original)
+++ trunk/src/inter_call.c Wed Dec 31 18:15:58 2008
@@ -333,6 +333,7 @@
Parrot_init_arg_nci(PARROT_INTERP, ARGOUT(call_state *st),
ARGIN(const char *sig))
{
+ ASSERT_ARGS(Parrot_init_arg_nci);
init_call_stats(st);
if (PMC_IS_NULL(interp->args_signature))
@@ -363,6 +364,7 @@
{
Parrot_Context *ctx = CONTEXT(interp);
PMC * const current_cont = ctx->current_cont;
+ ASSERT_ARGS(Parrot_init_ret_nci);
/* if this NCI call was a taicall, return results to caller's get_results
* this also means that we pass the caller's register base pointer */
@@ -405,6 +407,7 @@
ARGIN_NULLOK(opcode_t *indexes), ARGIN_NULLOK(PMC *sig_pmc),
ARGMOD(call_state_item *sti))
{
+ ASSERT_ARGS(Parrot_init_arg_indexes_and_sig_pmc);
if (!sig_pmc && indexes) {
++indexes;
sig_pmc = ctx->constants[*indexes]->u.key;
@@ -452,6 +455,7 @@
ARGIN_NULLOK(opcode_t *pc), ARGIN(call_state_item *sti))
{
PMC *sig_pmc = PMCNULL;
+ ASSERT_ARGS(Parrot_init_arg_op);
if (pc) {
++pc;
@@ -481,6 +485,7 @@
ARGIN(const char *sig), ARGIN_NULLOK(void *ap),
ARGMOD(call_state_item *sti))
{
+ ASSERT_ARGS(Parrot_init_arg_sig);
sti->used = 1;
sti->i = 0;
sti->n = 0;
@@ -516,6 +521,7 @@
static void
start_flatten(PARROT_INTERP, ARGMOD(call_state *st), ARGIN(PMC *p_arg))
{
+ ASSERT_ARGS(start_flatten);
if (PARROT_ARG_NAME_ISSET(st->src.sig)) {
/* src ought to be an hash */
@@ -561,6 +567,7 @@
static void
next_arg_sig(ARGMOD(call_state_item *sti))
{
+ ASSERT_ARGS(next_arg_sig);
switch (sti->mode & CALL_S_D_MASK) {
case CALL_STATE_OP:
sti->sig = SIG_ITEM(sti->u.op.signature, sti->i);
@@ -604,6 +611,7 @@
fetch_arg_sig(PARROT_INTERP, ARGMOD(call_state *st))
{
va_list * const ap = (va_list *)(st->src.u.sig.ap);
+ ASSERT_ARGS(fetch_arg_sig);
switch (st->src.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
@@ -666,6 +674,7 @@
{
const int constant = PARROT_ARG_CONSTANT_ISSET(st->src.sig);
const INTVAL idx = st->src.u.op.pc[st->src.i];
+ ASSERT_ARGS(fetch_arg_op);
switch (PARROT_ARG_TYPE_MASK_MASK(st->src.sig)) {
case PARROT_ARG_INTVAL:
@@ -735,6 +744,7 @@
int
Parrot_fetch_arg(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(Parrot_fetch_arg);
if (!st->src.used)
return 1;
@@ -814,6 +824,7 @@
int
Parrot_fetch_arg_nci(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(Parrot_fetch_arg_nci);
next_arg_sig(&st->dest);
if (st->dest.sig & PARROT_ARG_SLURPY_ARRAY) {
@@ -854,6 +865,7 @@
static void
convert_arg_from_int(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(convert_arg_from_int);
switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_FLOATVAL:
UVal_num(st->val) = (FLOATVAL)UVal_int(st->val);
@@ -889,6 +901,7 @@
static void
convert_arg_from_num(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(convert_arg_from_num);
switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
UVal_int(st->val) = (INTVAL)UVal_num(st->val);
@@ -925,6 +938,7 @@
static void
convert_arg_from_str(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(convert_arg_from_str);
switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
UVal_int(st->val) = string_to_int(interp, UVal_str(st->val));
@@ -960,6 +974,7 @@
static void
convert_arg_from_pmc(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(convert_arg_from_pmc);
switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
UVal_int(st->val) = VTABLE_get_integer(interp, UVal_pmc(st->val));
@@ -992,6 +1007,7 @@
{
INTVAL idx;
call_state_item * const dest = &st->dest;
+ ASSERT_ARGS(check_for_opt_flag);
++st->optionals;
@@ -1034,6 +1050,7 @@
clone_key_arg(PARROT_INTERP, ARGMOD(call_state *st))
{
PMC *key = UVal_pmc(st->val);
+ ASSERT_ARGS(clone_key_arg);
if (!key)
return;
@@ -1070,6 +1087,7 @@
init_first_dest_named(PARROT_INTERP, ARGMOD(call_state *st))
{
int i, n_named;
+ ASSERT_ARGS(init_first_dest_named);
if (st->dest.mode & CALL_STATE_SIG)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1135,6 +1153,7 @@
{
int i;
int n_named = -1;
+ ASSERT_ARGS(locate_named_named);
for (i = st->first_named; i < st->dest.n; ++i) {
int idx;
@@ -1186,6 +1205,7 @@
static void
store_arg(ARGIN(const call_state *st), INTVAL idx)
{
+ ASSERT_ARGS(store_arg);
switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL:
CTX_REG_INT(st->dest.ctx, idx) = UVal_int(st->val);
@@ -1222,6 +1242,7 @@
Parrot_store_arg(SHIM_INTERP, ARGIN(const call_state *st))
{
INTVAL idx;
+ ASSERT_ARGS(Parrot_store_arg);
if (st->dest.i >= st->dest.n)
return 0;
@@ -1249,6 +1270,7 @@
{
const int max_expected_args = st->params;
const int min_expected_args = max_expected_args - st->optionals;
+ ASSERT_ARGS(too_few);
if (st->n_actual_args < min_expected_args) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1275,6 +1297,7 @@
{
const int max_expected_args = st->params;
const int min_expected_args = max_expected_args - st->optionals;
+ ASSERT_ARGS(too_many);
if (st->n_actual_args > max_expected_args) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1299,6 +1322,7 @@
static void
null_val(int sig, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(null_val);
switch (sig & PARROT_ARG_TYPE_MASK) {
case PARROT_ARG_INTVAL: UVal_int(st->val) = 0; break;
case PARROT_ARG_FLOATVAL: UVal_num(st->val) = 0.0; break;
@@ -1334,6 +1358,7 @@
{
int i;
int n_named = -1;
+ ASSERT_ARGS(check_named);
for (i = st->first_named; i < st->dest.n; ++i) {
/* verify that a name exists */
@@ -1415,6 +1440,7 @@
static void
init_call_stats(ARGMOD(call_state *st))
{
+ ASSERT_ARGS(init_call_stats);
/* initial guess, adjusted for :flat args */
st->n_actual_args = st->src.n;
@@ -1448,6 +1474,7 @@
const char * const action = (param_or_result == PARROT_PASS_RESULTS)
? "results" : "params";
+ ASSERT_ARGS(Parrot_process_args);
/* Check if we should be throwing errors. This can be configured separately
* for parameters and return values. */
@@ -1649,6 +1676,7 @@
void
Parrot_convert_arg(PARROT_INTERP, ARGMOD(call_state *st))
{
+ ASSERT_ARGS(Parrot_convert_arg);
/* register key args have to be cloned */
if ((st->src.sig & PARROT_ARG_TYPE_MASK) == PARROT_ARG_PMC)
clone_key_arg(interp, st);
@@ -1697,6 +1725,7 @@
{
call_state st;
PMC *src_signature, *dest_signature;
+ ASSERT_ARGS(parrot_pass_args);
if (param_or_result == PARROT_PASS_PARAMS) {
src_signature = interp->args_signature;
@@ -1744,6 +1773,7 @@
ARGMOD(opcode_t *dest), ARGIN(Parrot_Context *old_ctxp), va_list ap)
{
call_state st;
+ ASSERT_ARGS(parrot_pass_args_fromc);
Parrot_init_arg_op(interp, CONTEXT(interp), dest, &st.dest);
Parrot_init_arg_sig(interp, old_ctxp, sig, PARROT_VA_TO_VAPTR(ap),
&st.src);
@@ -1769,6 +1799,7 @@
{
opcode_t * const src_pc = interp->current_returns;
int todo = Parrot_init_arg_op(interp, ctx, src_pc,
&st->src);
+ ASSERT_ARGS(set_retval_util);
interp->current_returns = NULL;
@@ -1804,6 +1835,7 @@
set_retval(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
{
call_state st;
+ ASSERT_ARGS(set_retval);
if (!sig_ret || sig_ret == 'v')
return NULL;
@@ -1838,6 +1870,7 @@
set_retval_i(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
{
call_state st;
+ ASSERT_ARGS(set_retval_i);
if (sig_ret != 'I')
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1865,6 +1898,7 @@
set_retval_f(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
{
call_state st;
+ ASSERT_ARGS(set_retval_f);
if (sig_ret != 'N')
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1894,6 +1928,7 @@
set_retval_s(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
{
call_state st;
+ ASSERT_ARGS(set_retval_s);
if (sig_ret != 'S')
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1923,6 +1958,7 @@
set_retval_p(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
{
call_state st;
+ ASSERT_ARGS(set_retval_p);
if (sig_ret != 'P')
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
@@ -1953,6 +1989,7 @@
ARGIN_NULLOK(PMC *pmc), ARGIN(va_list *list))
{
int reg_offset = 0;
+ ASSERT_ARGS(commit_last_arg);
/* invocant already commited, just return */
if (seen_arrow == 0 && index == 0 && pmc)
@@ -2029,6 +2066,7 @@
/* # of args, # of results */
int arg_ret_cnt[2] = { 0, 0 };
+ ASSERT_ARGS(count_signature_elements);
/* Increment these values if we are not calling from a CallSignature
PMC */
@@ -2116,6 +2154,7 @@
ARGIN(PMC *sig_obj))
{
int reg_offset = 0;
+ ASSERT_ARGS(commit_last_arg_sig_object);
/* calculate arg's register offset */
switch (cur & PARROT_ARG_TYPE_MASK) { /* calc reg offset */
@@ -2182,6 +2221,7 @@
STRING *empty_string = CONST_STRING(interp, "");
unsigned int index = 0;
unsigned int seen_arrow = 1;
+ ASSERT_ARGS(set_context_sig_returns);
/* result_accessors perform the arg accessor function,
* assigning the corresponding registers to the result variables */
@@ -2252,6 +2292,7 @@
unsigned int index = 0;
unsigned int seen_arrow = 1;
const char *x;
+ ASSERT_ARGS(set_context_sig_returns_varargs);
/* result_accessors perform the arg accessor function,
* assigning the corresponding registers to the result variables */
@@ -2321,6 +2362,7 @@
int cur = 0;
const char *ret_x = 0;
const char *x;
+ ASSERT_ARGS(set_context_sig_params);
for (x = signature; *x != '\0'; x++) {
/* detect -> separator */
@@ -2416,6 +2458,7 @@
{
PMC *sig_obj;
va_list args;
+ ASSERT_ARGS(Parrot_pcc_invoke_sub_from_c_args);
va_start(args, sig);
sig_obj = Parrot_build_sig_object_from_varargs(interp, sig, args);
va_end(args);
@@ -2520,6 +2563,7 @@
int cur = 0;
va_list list;
+ ASSERT_ARGS(Parrot_PCCINVOKE);
va_start(list, signature);
indexes[0] = arg_indexes;
@@ -2696,6 +2740,7 @@
PMC *sigs[2];
const char *ret_x = NULL;
+ ASSERT_ARGS(Parrot_pcc_invoke_sub_from_sig_object);
indexes[0] = arg_indexes;
indexes[1] = result_indexes;
Modified: trunk/src/inter_misc.c
==============================================================================
--- trunk/src/inter_misc.c (original)
+++ trunk/src/inter_misc.c Wed Dec 31 18:15:58 2008
@@ -50,6 +50,7 @@
PMC * const method = pmc_new(interp, enum_class_NCI);
STRING * const method_name = string_make(interp, name, strlen(name),
NULL, PObj_constant_FLAG|PObj_external_FLAG);
+ ASSERT_ARGS(register_nci_method);
/* create call func */
VTABLE_set_pointer_keyed_str(interp, method,
@@ -81,6 +82,7 @@
PMC * const method = pmc_new(interp, enum_class_NCI);
STRING * const method_name = string_make(interp, name, strlen(name),
NULL, PObj_constant_FLAG|PObj_external_FLAG);
+ ASSERT_ARGS(register_raw_nci_method_in_ns);
/* setup call func */
VTABLE_set_pointer(interp, method, func);
@@ -108,6 +110,7 @@
PMC *const pmc_true = pmc_new(interp, enum_class_Integer);
PMC *const method = VTABLE_get_pmc_keyed_str(
interp, interp->vtables[type]->_namespace, str_name);
+ ASSERT_ARGS(Parrot_mark_method_writes);
VTABLE_set_integer_native(interp, pmc_true, 1);
VTABLE_setprop(interp, method, CONST_STRING(interp, "write"), pmc_true);
}
@@ -132,6 +135,7 @@
STRING *sc = CONST_STRING(interp, "PJt");
PMC *hash = VTABLE_get_pmc_keyed_int(interp, interp->iglobals,
IGLOBALS_COMPREG_HASH);
+ ASSERT_ARGS(Parrot_compreg);
if (!hash) {
hash = pmc_new_noinit(interp, enum_class_Hash);
@@ -163,6 +167,7 @@
Parrot_compile_string(PARROT_INTERP, ARGIN(STRING *type),
ARGIN(const char *code), ARGOUT(STRING **error))
{
+ ASSERT_ARGS(Parrot_compile_string);
if (string_compare(interp, CONST_STRING(interp, "PIR"), type) == 0)
return IMCC_compile_pir_s(interp, code, error);
@@ -188,6 +193,7 @@
void *
Parrot_compile_file(PARROT_INTERP, ARGIN(const char *fullname), ARGOUT(STRING
**error))
{
+ ASSERT_ARGS(Parrot_compile_file);
return IMCC_compile_file_s(interp, fullname, error);
}
@@ -228,6 +234,7 @@
INTVAL ret = 0;
int j;
Arenas *arena_base = interp->arena_base;
+ ASSERT_ARGS(interpinfo);
switch (what) {
case TOTAL_MEM_ALLOC:
@@ -315,6 +322,7 @@
PMC*
interpinfo_p(PARROT_INTERP, INTVAL what)
{
+ ASSERT_ARGS(interpinfo_p);
switch (what) {
case CURRENT_SUB:
return CONTEXT(interp)->current_sub;
@@ -357,6 +365,7 @@
STRING*
interpinfo_s(PARROT_INTERP, INTVAL what)
{
+ ASSERT_ARGS(interpinfo_s);
switch (what) {
case EXECUTABLE_FULLNAME:
{
@@ -427,6 +436,7 @@
INTVAL
sysinfo_i(SHIM_INTERP, INTVAL info_wanted)
{
+ ASSERT_ARGS(sysinfo_i);
switch (info_wanted) {
case PARROT_INTSIZE:
return sizeof (INTVAL);
@@ -468,6 +478,7 @@
STRING *
sysinfo_s(PARROT_INTERP, INTVAL info_wanted)
{
+ ASSERT_ARGS(sysinfo_s);
switch (info_wanted) {
case PARROT_OS:
return const_string(interp, BUILD_OS_NAME);
Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c (original)
+++ trunk/src/pmc.c Wed Dec 31 18:15:58 2008
@@ -79,6 +79,7 @@
INTVAL
PMC_is_null(SHIM_INTERP, ARGIN_NULLOK(const PMC *pmc))
{
+ ASSERT_ARGS(PMC_is_null);
#if PARROT_CATCH_NULL
return pmc == PMCNULL || pmc == NULL;
#else
@@ -105,6 +106,7 @@
PMC *
pmc_new(PARROT_INTERP, INTVAL base_type)
{
+ ASSERT_ARGS(pmc_new);
PARROT_ASSERT(interp->vtables[base_type]);
{
PMC *const classobj = interp->vtables[base_type]->pmc_class;
@@ -141,6 +143,7 @@
{
VTABLE *new_vtable;
INTVAL has_ext, new_flags;
+ ASSERT_ARGS(pmc_reuse);
if (pmc->vtable->base_type == new_type)
return pmc;
@@ -229,6 +232,7 @@
PMC *pmc;
VTABLE *vtable = interp->vtables[base_type];
UINTVAL vtable_flags;
+ ASSERT_ARGS(get_new_pmc_header);
/* This is usually because you either didn't call init_world early enough,
* you added a new PMC class without adding Parrot_(classname)_class_init
@@ -326,6 +330,7 @@
pmc_new_noinit(PARROT_INTERP, INTVAL base_type)
{
PMC *const classobj = interp->vtables[base_type]->pmc_class;
+ ASSERT_ARGS(pmc_new_noinit);
if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
return VTABLE_instantiate(interp, classobj, PMCNULL);
@@ -349,6 +354,7 @@
PMC *
constant_pmc_new_noinit(PARROT_INTERP, INTVAL base_type)
{
+ ASSERT_ARGS(constant_pmc_new_noinit);
return get_new_pmc_header(interp, base_type, PObj_constant_FLAG);
}
@@ -369,6 +375,7 @@
constant_pmc_new(PARROT_INTERP, INTVAL base_type)
{
PMC * const pmc = get_new_pmc_header(interp, base_type,
PObj_constant_FLAG);
+ ASSERT_ARGS(constant_pmc_new);
VTABLE_init(interp, pmc);
return pmc;
}
@@ -390,6 +397,7 @@
pmc_new_init(PARROT_INTERP, INTVAL base_type, ARGOUT(PMC *init))
{
PMC *const classobj = interp->vtables[base_type]->pmc_class;
+ ASSERT_ARGS(pmc_new_init);
if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
return VTABLE_instantiate(interp, classobj, init);
@@ -418,6 +426,7 @@
constant_pmc_new_init(PARROT_INTERP, INTVAL base_type, ARGIN_NULLOK(PMC *init))
{
PMC * const pmc = get_new_pmc_header(interp, base_type,
PObj_constant_FLAG);
+ ASSERT_ARGS(constant_pmc_new_init);
VTABLE_init_pmc(interp, pmc, init);
return pmc;
}
@@ -452,6 +461,7 @@
temporary_pmc_new(PARROT_INTERP, INTVAL base_type)
{
PMC * const pmc = get_new_pmc_header(interp, base_type,
PObj_constant_FLAG);
+ ASSERT_ARGS(temporary_pmc_new);
VTABLE_init(interp, pmc);
return pmc;
}
@@ -474,6 +484,7 @@
pmc_free_to_pool(PARROT_INTERP, ARGMOD(PMC *pmc),
ARGMOD(Small_Object_Pool *pool))
{
+ ASSERT_ARGS(pmc_free_to_pool);
if (PObj_active_destroy_TEST(pmc))
VTABLE_destroy(interp, pmc);
@@ -490,6 +501,7 @@
temporary_pmc_free(PARROT_INTERP, ARGMOD(PMC *pmc))
{
Small_Object_Pool *pool = interp->arena_base->constant_pmc_pool;
+ ASSERT_ARGS(temporary_pmc_free);
pmc_free_to_pool(interp, pmc, pool);
}
@@ -497,6 +509,7 @@
pmc_free(PARROT_INTERP, ARGMOD(PMC *pmc))
{
Small_Object_Pool *pool = interp->arena_base->pmc_pool;
+ ASSERT_ARGS(pmc_free);
pmc_free_to_pool(interp, pmc, pool);
}
@@ -506,6 +519,7 @@
get_new_vtable_index(PARROT_INTERP)
{
const INTVAL typeid = interp->n_vtable_max++;
+ ASSERT_ARGS(get_new_vtable_index);
/* Have we overflowed the table? */
if (typeid >= interp->n_vtable_alloced)
@@ -532,6 +546,7 @@
/* If they're looking to register an existing class, return that
class' type number */
INTVAL type = pmc_type(interp, name);
+ ASSERT_ARGS(pmc_register);
if (type > enum_type_undef)
return type;
@@ -564,6 +579,7 @@
INTVAL
pmc_type(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
{
+ ASSERT_ARGS(pmc_type);
if (!name)
return enum_type_undef;
else {
@@ -600,6 +616,7 @@
PMC * const classname_hash = interp->class_hash;
PMC * const item =
(PMC *)VTABLE_get_pointer_keyed(interp, classname_hash, name);
+ ASSERT_ARGS(pmc_type_p);
if (!PMC_IS_NULL(item))
return VTABLE_get_integer(interp, item);
@@ -632,6 +649,7 @@
*/
PMC * const _class = get_new_pmc_header(interp, type,
PObj_constant_FLAG);
+ ASSERT_ARGS(create_class_pmc);
/* If we are a second thread, we may get the same object as the
* original because we have a singleton. Just set the singleton to
@@ -676,6 +694,7 @@
VTABLE *vtable = interp->vtables[type];
PMC *mro_list = vtable->mro;
INTVAL i, count;
+ ASSERT_ARGS(Parrot_create_mro);
/* this should never be PMCNULL */
PARROT_ASSERT(!PMC_IS_NULL(mro_list));
@@ -742,6 +761,7 @@
void
dod_register_pmc(PARROT_INTERP, ARGIN(PMC *pmc))
{
+ ASSERT_ARGS(dod_register_pmc);
/* Better not trigger a DOD run with a potentially unanchored PMC */
Parrot_block_GC_mark(interp);
@@ -765,6 +785,7 @@
void
dod_unregister_pmc(PARROT_INTERP, ARGIN(PMC *pmc))
{
+ ASSERT_ARGS(dod_unregister_pmc);
PARROT_ASSERT(interp->DOD_registry);
VTABLE_delete_keyed(interp, interp->DOD_registry, pmc);
Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c (original)
+++ trunk/src/utils.c Wed Dec 31 18:15:58 2008
@@ -120,6 +120,7 @@
intval_mod(INTVAL i2, INTVAL i3)
{
INTVAL z = i3;
+ ASSERT_ARGS(intval_mod);
if (z == 0)
return i2;
@@ -171,6 +172,7 @@
* adding a temporary variable makes it pass the test.
*/
const FLOATVAL temp = n3 * floor(n2 / n3);
+ ASSERT_ARGS(floatval_mod);
return !FLOAT_IS_ZERO(n3)
? (n2 - temp)
@@ -233,6 +235,7 @@
{
unsigned short lo, mid, hi;
unsigned int t;
+ ASSERT_ARGS(next_rand);
/* 48 bit mul, one short at a time */
t = X[0] * a[0] + c;
@@ -264,6 +267,7 @@
_erand48(_rand_buf buf)
{
FLOATVAL r;
+ ASSERT_ARGS(_erand48);
next_rand(buf);
r = ((buf[0] / 65536.0 + buf[1]) / 65536.0 + buf[2]) / 65536.0;
return r;
@@ -282,6 +286,7 @@
static FLOATVAL
_drand48(void)
{
+ ASSERT_ARGS(_drand48);
return _erand48(last_rand);
}
@@ -299,6 +304,7 @@
_jrand48(_rand_buf buf)
{
long ret;
+ ASSERT_ARGS(_jrand48);
next_rand(buf);
ret = buf[2] << 16 | buf[1];
return ret;
@@ -317,6 +323,7 @@
static long
_nrand48(_rand_buf buf)
{
+ ASSERT_ARGS(_nrand48);
return _jrand48(buf) & 0x7fffffff;
}
@@ -333,6 +340,7 @@
static long
_lrand48(void)
{
+ ASSERT_ARGS(_lrand48);
return _nrand48(last_rand);
}
@@ -349,6 +357,7 @@
static long
_mrand48(void)
{
+ ASSERT_ARGS(_mrand48);
return _jrand48(last_rand);
}
@@ -366,6 +375,7 @@
static void
_srand48(long seed)
{
+ ASSERT_ARGS(_srand48);
last_rand[0] = SEED_LO;
last_rand[1] = (unsigned short)(seed & 0xffff);
last_rand[2] = (unsigned short)((seed >> 16) & 0xffff);
@@ -410,6 +420,7 @@
FLOATVAL
Parrot_float_rand(INTVAL how_random)
{
+ ASSERT_ARGS(Parrot_float_rand);
UNUSED(how_random);
return _drand48(); /* [0.0..1.0] */
@@ -431,6 +442,7 @@
INTVAL
Parrot_uint_rand(INTVAL how_random)
{
+ ASSERT_ARGS(Parrot_uint_rand);
UNUSED(how_random);
return _lrand48(); /* [0..2^31] */
@@ -452,6 +464,7 @@
INTVAL
Parrot_int_rand(INTVAL how_random)
{
+ ASSERT_ARGS(Parrot_int_rand);
UNUSED(how_random);
return _mrand48(); /* [-2^31..2^31] */
@@ -473,6 +486,7 @@
INTVAL
Parrot_range_rand(INTVAL from, INTVAL to, INTVAL how_random)
{
+ ASSERT_ARGS(Parrot_range_rand);
return (INTVAL)(from + ((double)(to - from))
* Parrot_float_rand(how_random));
}
@@ -491,6 +505,7 @@
void
Parrot_srand(INTVAL seed)
{
+ ASSERT_ARGS(Parrot_srand);
_srand48(seed);
}
@@ -525,8 +540,7 @@
tm_to_array(PARROT_INTERP, ARGIN(const struct tm *tm))
{
PMC * const Array = pmc_new(interp, enum_class_Array);
-
- PARROT_ASSERT(tm);
+ ASSERT_ARGS(tm_to_array);
VTABLE_set_integer_native(interp, Array, 9);
VTABLE_set_integer_keyed_int(interp, Array, 0, tm->tm_sec);
@@ -568,6 +582,7 @@
const char *str_pos = str_start + start_offset;
INTVAL len_remain = str_len - start_offset;
const char *search_pos;
+ ASSERT_ARGS(Parrot_byte_index);
/* find the next position of the first character in the search string
* Parrot strings can have NULLs, so strchr() won't work here */
@@ -612,6 +627,7 @@
const char * const search_start = search->strstart;
UINTVAL max_possible_offset = (base->strlen - search->strlen);
INTVAL current_offset;
+ ASSERT_ARGS(Parrot_byte_rindex);
if (start_offset && start_offset < max_possible_offset)
max_possible_offset = start_offset;
@@ -658,6 +674,7 @@
const int node = c->dest_regs[node_index];
const int pred = c->src_regs[node_index];
const int pred_index = c->reg_to_index[pred];
+ ASSERT_ARGS(rec_climb_back_and_mark);
if (pred_index < 0) { /* pred has no predecessor */
move_reg(pred, node, c);
@@ -703,6 +720,7 @@
c->mov_alt
? c->mov_alt(c->interp, c->dest_regs[node_index], pred, c->info)
: 0;
+ ASSERT_ARGS(process_cycle_without_exit);
if (0 == alt) { /* use temp reg */
move_reg(c->dest_regs[node_index], c->temp_reg, c);
@@ -784,6 +802,7 @@
int* backup = NULL;
int* reg_to_index = NULL;
parrot_prm_context c;
+ ASSERT_ARGS(Parrot_register_move);
if (n_regs == 0)
return;
@@ -865,6 +884,7 @@
static INTVAL
COMPARE(PARROT_INTERP, ARGIN(void *a), ARGIN(void *b), ARGIN(PMC *cmp))
{
+ ASSERT_ARGS(COMPARE);
if (PMC_IS_NULL(cmp))
return VTABLE_cmp(interp, (PMC *)a, (PMC *)b);
@@ -880,6 +900,7 @@
void
Parrot_quicksort(PARROT_INTERP, ARGMOD(void **data), UINTVAL n, ARGIN(PMC
*cmp))
{
+ ASSERT_ARGS(Parrot_quicksort);
while (n > 1) {
UINTVAL i, j, ln, rn;
void *temp;