Index: src/embed.c =================================================================== --- src/embed.c (.../trunk) (revision 34776) +++ src/embed.c (.../branches/assert_args) (revision 34785) @@ -836,6 +836,7 @@ { opcode_t i; PMC *sub_pmc; + ASSERT_ARGS(set_current_sub); PackFile_ByteCode * const cur_cs = interp->code; PackFile_FixupTable * const ft = cur_cs->fixups; Index: src/pbc_merge.c =================================================================== --- src/pbc_merge.c (.../trunk) (revision 34776) +++ src/pbc_merge.c (.../branches/assert_args) (revision 34785) @@ -233,6 +233,7 @@ INTVAL program_size, wanted; char *program_code; PackFile *pf; + ASSERT_ARGS(pbc_merge_loadpbc); FILE * io = NULL; INTVAL is_mapped = 0; size_t chunk_size; @@ -321,9 +322,10 @@ pbc_merge_bytecode(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs), int num_inputs, ARGMOD(PackFile *pf)) { + int i; + ASSERT_ARGS(pbc_merge_bytecode); opcode_t *bc = mem_allocate_typed(opcode_t); opcode_t cursor = 0; - int i; /* Add a bytecode segment. */ PackFile_ByteCode * const bc_seg = @@ -385,9 +387,10 @@ pbc_merge_constants(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs), int num_inputs, ARGMOD(PackFile *pf), ARGMOD(PackFile_ByteCode *bc)) { + int i, j; + ASSERT_ARGS(pbc_merge_constants); PackFile_Constant **constants = mem_allocate_typed(PackFile_Constant *); opcode_t cursor = 0; - int i, j; /* Add a constant table segment. */ PackFile_ConstTable * const const_seg = (PackFile_ConstTable*)PackFile_Segment_new_seg( @@ -480,10 +483,11 @@ pbc_merge_fixups(PARROT_INTERP, ARGIN(pbc_merge_input **inputs), int num_inputs, ARGMOD(PackFile *pf), ARGMOD(PackFile_ByteCode *bc)) { + int i, j; + ASSERT_ARGS(pbc_merge_fixups); PackFile_FixupTable *fixup_seg; PackFile_FixupEntry **fixups = mem_allocate_typed(PackFile_FixupEntry *); opcode_t cursor = 0; - int i, j; /* Add a fixup table segment. */ fixup_seg = (PackFile_FixupTable*)PackFile_Segment_new_seg( @@ -575,13 +579,14 @@ pbc_merge_debugs(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs), int num_inputs, ARGMOD(PackFile *pf), ARGMOD(PackFile_ByteCode *bc)) { + int i, j; + ASSERT_ARGS(pbc_merge_debugs); PackFile_Debug *debug_seg; opcode_t *lines = mem_allocate_typed(opcode_t); PackFile_DebugMapping **mappings = mem_allocate_typed(PackFile_DebugMapping *); opcode_t num_mappings = 0; opcode_t num_lines = 0; - int i, j; /* We need to merge both the mappings and the list of line numbers. The line numbers can just be concatenated. The mappings must have @@ -648,6 +653,7 @@ int i; PackFile_Segment *pic_index; size_t size; + ASSERT_ARGS(pbc_merge_pic_index); opcode_t cursor = 0; opcode_t start = 0; opcode_t last = 0; @@ -697,11 +703,12 @@ pbc_merge_ctpointers(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs), int num_inputs, ARGMOD(PackFile_ByteCode *bc)) { + int cur_arg; opcode_t *op_ptr; + ASSERT_ARGS(pbc_merge_ctpointers); opcode_t *ops = bc->base.data; opcode_t cur_op = 0; int cur_input = 0; - int cur_arg; /* Loop over the ops in the merged bytecode. */ while (cur_op < (opcode_t)bc->base.size) { @@ -781,6 +788,7 @@ { PackFile_ByteCode *bc; PackFile_ConstTable *ct; + ASSERT_ARGS(pbc_merge_begin); /* Create a new empty packfile. */ PackFile * const merged = PackFile_new(interp, 0); @@ -819,6 +827,7 @@ static void pbc_merge_write(PARROT_INTERP, ARGMOD(PackFile *pf), ARGIN(const char *filename)) { + ASSERT_ARGS(pbc_merge_write); FILE *fp; /* Get size of packfile we'll write. */ Index: src/charset.c =================================================================== --- src/charset.c (.../trunk) (revision 34776) +++ src/charset.c (.../branches/assert_args) (revision 34785) @@ -96,6 +96,7 @@ CHARSET * Parrot_new_charset(SHIM_INTERP) { + ASSERT_ARGS(Parrot_new_charset); return mem_allocate_typed(CHARSET); } @@ -114,8 +115,9 @@ void Parrot_charsets_encodings_deinit(SHIM_INTERP) { + int i; + ASSERT_ARGS(Parrot_charsets_encodings_deinit); const int n = all_charsets->n_charsets; - int i; for (i = 0; i < n; ++i) { if (all_charsets->set[i].n_converters) @@ -146,6 +148,7 @@ Parrot_find_charset(SHIM_INTERP, ARGIN(const char *charsetname)) { int i; + ASSERT_ARGS(Parrot_find_charset); const int n = all_charsets->n_charsets; for (i = 0; i < n; ++i) { @@ -172,6 +175,7 @@ CHARSET * Parrot_load_charset(PARROT_INTERP, ARGIN(const char *charsetname)) { + ASSERT_ARGS(Parrot_load_charset); UNUSED(charsetname); Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, @@ -193,8 +197,9 @@ INTVAL Parrot_charset_number(PARROT_INTERP, ARGIN(const STRING *charsetname)) { + int i; + ASSERT_ARGS(Parrot_charset_number); const int n = all_charsets->n_charsets; - int i; for (i = 0; i < n; ++i) { if (!string_equal(interp, all_charsets->set[i].name, charsetname)) @@ -219,6 +224,7 @@ Parrot_charset_number_of_str(SHIM_INTERP, ARGIN(const STRING *src)) { int i; + ASSERT_ARGS(Parrot_charset_number_of_str); const int n = all_charsets->n_charsets; for (i = 0; i < n; ++i) { @@ -245,6 +251,7 @@ STRING* Parrot_charset_name(SHIM_INTERP, INTVAL number_of_charset) { + ASSERT_ARGS(Parrot_charset_name); if (number_of_charset < 0 || number_of_charset >= all_charsets->n_charsets) return NULL; return all_charsets->set[number_of_charset].name; @@ -266,6 +273,7 @@ const CHARSET * Parrot_get_charset(SHIM_INTERP, INTVAL number_of_charset) { + ASSERT_ARGS(Parrot_get_charset); if (number_of_charset < 0 || number_of_charset >= all_charsets->n_charsets) return NULL; return all_charsets->set[number_of_charset].charset; @@ -288,6 +296,7 @@ const char * Parrot_charset_c_name(SHIM_INTERP, INTVAL number_of_charset) { + ASSERT_ARGS(Parrot_charset_c_name); if (number_of_charset < 0 || number_of_charset >= all_charsets->n_charsets) return NULL; return all_charsets->set[number_of_charset].charset->name; @@ -309,8 +318,9 @@ register_charset(PARROT_INTERP, ARGIN(const char *charsetname), ARGIN(CHARSET *charset)) { + int i; + ASSERT_ARGS(register_charset); const int n = all_charsets->n_charsets; - int i; for (i = 0; i < n; ++i) { if (STREQ(all_charsets->set[i].charset->name, charsetname)) @@ -352,6 +362,7 @@ static void register_static_converters(PARROT_INTERP) { + ASSERT_ARGS(register_static_converters); Parrot_register_charset_converter(interp, Parrot_iso_8859_1_charset_ptr, Parrot_ascii_charset_ptr, charset_cvt_iso_8859_1_to_ascii); @@ -391,6 +402,7 @@ Parrot_register_charset(PARROT_INTERP, ARGIN(const char *charsetname), ARGIN(CHARSET *charset)) { + ASSERT_ARGS(Parrot_register_charset); if (!all_charsets) { all_charsets = mem_allocate_typed(All_charsets); all_charsets->n_charsets = 0; @@ -433,6 +445,7 @@ void Parrot_charsets_encodings_init(PARROT_INTERP) { + ASSERT_ARGS(Parrot_charsets_encodings_init); /* the order is crucial here: * 1) encodings, default = fixed_8 * 2) charsets default = ascii @@ -472,6 +485,7 @@ Parrot_make_default_charset(SHIM_INTERP, SHIM(const char *charsetname), ARGIN(CHARSET *charset)) { + ASSERT_ARGS(Parrot_make_default_charset); Parrot_default_charset_ptr = charset; return 1; } @@ -492,6 +506,7 @@ const CHARSET * Parrot_default_charset(SHIM_INTERP) { + ASSERT_ARGS(Parrot_default_charset); return Parrot_default_charset_ptr; } @@ -513,6 +528,7 @@ ARGIN(const CHARSET *lhs), ARGIN(const CHARSET *rhs)) { int i; + ASSERT_ARGS(Parrot_find_charset_converter); const int n = all_charsets->n_charsets; for (i = 0; i < n; ++i) { @@ -546,8 +562,9 @@ ARGIN(const CHARSET *lhs), ARGIN(CHARSET *rhs), ARGIN(charset_converter_t func)) { + int i; + ASSERT_ARGS(Parrot_register_charset_converter); const int n = all_charsets->n_charsets; - int i; for (i = 0; i < n; ++i) { if (lhs == all_charsets->set[i].charset) { Index: src/exec.c =================================================================== --- src/exec.c (.../trunk) (revision 34776) +++ src/exec.c (.../branches/assert_args) (revision 34785) @@ -49,6 +49,10 @@ __attribute__nonnull__(1) __attribute__nonnull__(2); +#define ASSERT_ARGS_add_data_member assert(obj); +#define ASSERT_ARGS_exec_init assert(obj); +#define ASSERT_ARGS_symbol_list_find assert(obj); \ + assert(symbol); /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* HEADERIZER END: static */ @@ -362,6 +366,7 @@ symbol_list_find(ARGIN(const Parrot_exec_objfile_t *obj), ARGIN(const char *symbol)) { int i; + ASSERT_ARGS(symbol_list_find); for (i = 0; i < obj->symbol_count; i++) if (STREQ(symbol, obj->symbol_table[i].symbol)) Index: src/inter_run.c =================================================================== --- src/inter_run.c (.../trunk) (revision 34776) +++ src/inter_run.c (.../branches/assert_args) (revision 34785) @@ -64,6 +64,7 @@ void runops(PARROT_INTERP, size_t offs) { + ASSERT_ARGS(runops); volatile size_t offset = offs; const int old_runloop_id = interp->current_runloop_id; const int our_runloop_level = ++interp->current_runloop_level; @@ -138,6 +139,7 @@ { opcode_t offset, *dest; Parrot_Context *ctx; + ASSERT_ARGS(Parrot_runops_fromc); /* we need one return continuation with a NULL offset */ PMC * const ret_c = new_ret_continuation_pmc(interp, NULL); @@ -195,6 +197,7 @@ char new_sig[10]; const char *sig_p; + ASSERT_ARGS(runops_args); Parrot_Context * const old_ctx = CONTEXT(interp); interp->current_cont = new_ret_continuation_pmc(interp, NULL); @@ -269,6 +272,7 @@ Parrot_Context *ctx; opcode_t offset, *dest; + ASSERT_ARGS(Parrot_run_meth_fromc); interp->current_cont = new_ret_continuation_pmc(interp, NULL); interp->current_object = obj; dest = VTABLE_invoke(interp, sub, (void *)1); @@ -304,6 +308,7 @@ va_list args; Parrot_Context *ctx; PMC *retval; + ASSERT_ARGS(Parrot_runops_fromc_args); va_start(args, sig); ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args); @@ -335,6 +340,7 @@ va_list args; Parrot_Context *ctx; void *retval; + ASSERT_ARGS(Parrot_runops_fromc_args_event); /* * running code from event handlers isn't fully reentrant due to * these interpreter variables - mainly related to calls @@ -379,6 +385,7 @@ va_list args; Parrot_Context *ctx; INTVAL retval; + ASSERT_ARGS(Parrot_runops_fromc_args_reti); va_start(args, sig); ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args); @@ -409,6 +416,7 @@ va_list args; Parrot_Context *ctx; FLOATVAL retval; + ASSERT_ARGS(Parrot_runops_fromc_args_retf); va_start(args, sig); ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args); @@ -440,6 +448,7 @@ va_list args; Parrot_Context *ctx; void* retval; + ASSERT_ARGS(Parrot_run_meth_fromc_args); va_start(args, sig); ctx = runops_args(interp, sub, obj, meth, sig, args); @@ -470,6 +479,7 @@ va_list args; Parrot_Context *ctx; INTVAL retval; + ASSERT_ARGS(Parrot_run_meth_fromc_args_reti); va_start(args, sig); ctx = runops_args(interp, sub, obj, meth, sig, args); @@ -500,6 +510,7 @@ va_list args; Parrot_Context *ctx; FLOATVAL retval; + ASSERT_ARGS(Parrot_run_meth_fromc_args_retf); va_start(args, sig); ctx = runops_args(interp, sub, obj, meth, sig, args); @@ -529,6 +540,7 @@ ARGIN(const char *sig), va_list args) { void* retval; + ASSERT_ARGS(Parrot_runops_fromc_arglist); Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args); retval = set_retval(interp, *sig, ctx); @@ -555,6 +567,7 @@ ARGIN(const char *sig), va_list args) { INTVAL retval; + ASSERT_ARGS(Parrot_runops_fromc_arglist_reti); Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args); retval = set_retval_i(interp, *sig, ctx); @@ -581,6 +594,7 @@ ARGIN(const char *sig), va_list args) { FLOATVAL retval; + ASSERT_ARGS(Parrot_runops_fromc_arglist_retf); Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args); retval = set_retval_f(interp, *sig, ctx); @@ -609,6 +623,7 @@ { Parrot_Context *ctx; void* retval; + ASSERT_ARGS(Parrot_run_meth_fromc_arglist); ctx = runops_args(interp, sub, obj, meth, sig, args); retval = set_retval(interp, *sig, ctx); @@ -637,6 +652,7 @@ ARGIN(STRING *meth), ARGIN(const char *sig), va_list args) { INTVAL retval; + ASSERT_ARGS(Parrot_run_meth_fromc_arglist_reti); Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig, args); retval = set_retval_i(interp, *sig, ctx); @@ -664,6 +680,7 @@ ARGIN(STRING *meth), ARGIN(const char *sig), va_list args) { FLOATVAL retval; + ASSERT_ARGS(Parrot_run_meth_fromc_arglist_retf); Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig, args); retval = set_retval_f(interp, *sig, ctx); @@ -693,6 +710,7 @@ new_runloop_jump_point(PARROT_INTERP) { Parrot_runloop *jump_point; + ASSERT_ARGS(new_runloop_jump_point); if (interp->runloop_jmp_free_list) { jump_point = interp->runloop_jmp_free_list; @@ -719,6 +737,7 @@ void free_runloop_jump_point(PARROT_INTERP) { + ASSERT_ARGS(free_runloop_jump_point); Parrot_runloop * const jump_point = interp->current_runloop; interp->current_runloop = jump_point->prev; jump_point->prev = interp->runloop_jmp_free_list; @@ -739,6 +758,7 @@ void destroy_runloop_jump_points(PARROT_INTERP) { + ASSERT_ARGS(destroy_runloop_jump_points); really_destroy_runloop_jump_points(interp->current_runloop); really_destroy_runloop_jump_points(interp->runloop_jmp_free_list); } @@ -758,6 +778,7 @@ void really_destroy_runloop_jump_points(ARGIN_NULLOK(Parrot_runloop *jump_point)) { + ASSERT_ARGS(really_destroy_runloop_jump_points); while (jump_point) { Parrot_runloop * const prev = jump_point->prev; mem_sys_free(jump_point); Index: include/parrot/atomic/gcc_x86.h =================================================================== --- include/parrot/atomic/gcc_x86.h (.../trunk) (revision 34776) +++ include/parrot/atomic/gcc_x86.h (.../branches/assert_args) (revision 34785) @@ -33,6 +33,10 @@ long parrot_i386_xadd(ARGIN(volatile long *l), long amount) __attribute__nonnull__(1); +#define ASSERT_ARGS_parrot_i386_cmpxchg assert(ptr); \ + assert(expect); \ + assert(update); +#define ASSERT_ARGS_parrot_i386_xadd assert(l); /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* HEADERIZER END: src/atomic/gcc_x86.c */ Index: include/parrot/exec.h =================================================================== --- include/parrot/exec.h (.../trunk) (revision 34776) +++ include/parrot/exec.h (.../branches/assert_args) (revision 34785) @@ -149,6 +149,21 @@ __attribute__nonnull__(2) FUNC_MODIFIES(*obj); +#define ASSERT_ARGS_Parrot_exec_add_text_rellocation assert(obj); \ + assert(nptr); \ + assert(symbol); +#define ASSERT_ARGS_Parrot_exec_add_text_rellocation_func assert(obj); \ + assert(nptr); \ + assert(func_name); +#define ASSERT_ARGS_Parrot_exec_add_text_rellocation_reg assert(obj); \ + assert(nptr); \ + assert(var); +#define ASSERT_ARGS_Parrot_exec assert(interp); \ + assert(pc); \ + assert(code_start); \ + assert(code_end); +#define ASSERT_ARGS_Parrot_exec_add_symbol assert(obj); \ + assert(symbol); /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ /* HEADERIZER END: src/exec.c */ Index: compilers/imcc/sets.c =================================================================== --- compilers/imcc/sets.c (.../trunk) (revision 34776) +++ compilers/imcc/sets.c (.../branches/assert_args) (revision 34785) @@ -51,6 +51,7 @@ Set* set_make(unsigned int length) { + ASSERT_ARGS(set_make); Set * const s = mem_allocate_zeroed_typed(Set); s->length = length; s->bmp = mem_allocate_n_zeroed_typed(NUM_BYTES(length), @@ -75,6 +76,7 @@ Set* set_make_full(unsigned int length) { + ASSERT_ARGS(set_make_full); Set * const s = set_make(length); const size_t bytes = NUM_BYTES(length); @@ -98,6 +100,7 @@ void set_free(ARGMOD(Set *s)) { + ASSERT_ARGS(set_free); if (s->bmp) mem_sys_free(s->bmp); @@ -118,6 +121,7 @@ void set_clear(ARGMOD(Set *s)) { + ASSERT_ARGS(set_clear); memset(s->bmp, 0, NUM_BYTES(s->length)); } @@ -137,6 +141,7 @@ Set* set_copy(ARGIN(const Set *s)) { + ASSERT_ARGS(set_copy); Set * const d = set_make(s->length); memcpy(d->bmp, s->bmp, NUM_BYTES(d->length)); @@ -161,6 +166,7 @@ set_equal(ARGIN(const Set *s1), ARGIN(const Set *s2)) { int mask; + ASSERT_ARGS(set_equal); const size_t bytes = s1->length / 8; if (s1->length != s2->length) @@ -195,6 +201,7 @@ void set_add(ARGMOD(Set *s), unsigned int element) { + ASSERT_ARGS(set_add); const int elem_byte_in_set = BYTE_IN_SET(element); const int bytes_in_set = BYTE_IN_SET(s->length); @@ -295,6 +302,7 @@ set_union(ARGIN(const Set *s1), ARGIN(const Set *s2)) { unsigned int i; + ASSERT_ARGS(set_union); Set * const s = set_make(s1->length); if (s1->length != s2->length) @@ -326,8 +334,9 @@ Set * set_intersec(ARGIN(const Set *s1), ARGIN(const Set *s2)) { + unsigned int i; + ASSERT_ARGS(set_intersec); Set * const s = set_make(s1->length); - unsigned int i; if (s1->length != s2->length) fatal(1, "set_intersec", "Sets don't have the same length\n"); @@ -355,6 +364,7 @@ set_intersec_inplace(ARGMOD(Set *s1), ARGIN(const Set *s2)) { unsigned int i; + ASSERT_ARGS(set_intersec_inplace); if (s1->length != s2->length) fatal(1, "set_intersec_inplace", "Sets don't have the same length\n");