? log.9392.gz ? test.imc ? mprout.pl ? docs/core_ops.pod ? docs/io_ops.pod ? io/Makefile ? t/src/staticstring.t ? t/src/valgrind.t Index: build_nativecall.pl =================================================================== RCS file: /cvs/public/parrot/build_nativecall.pl,v retrieving revision 1.18 diff -u -r1.18 build_nativecall.pl --- build_nativecall.pl 28 Jul 2003 02:52:31 -0000 1.18 +++ build_nativecall.pl 30 Jul 2003 13:35:19 -0000 @@ -220,6 +220,9 @@ /I/ && do { return "interpreter"; }; + /P/ && do {my $regnum = $reg_ref->{p}++; + return "PMC_REG($regnum)"; + }; } Index: call_list.txt =================================================================== RCS file: /cvs/public/parrot/call_list.txt,v retrieving revision 1.8 diff -u -r1.8 call_list.txt --- call_list.txt 18 Jan 2003 09:14:30 -0000 1.8 +++ call_list.txt 30 Jul 2003 13:35:19 -0000 @@ -13,6 +13,7 @@ # t - character string # PMC reg stuff # p - data pointer from PMC (on store into a new UnManagedStruct PMC) +# P - pointer to a PMC-register # special stuff # I - Parrot_Interp param # @@ -39,3 +40,10 @@ i pppp i ppi p It +# These are needed for parrotio.pmc +i IP +v IP +i IPi +i IPii +i IPiii +i IPt Index: dod.c =================================================================== RCS file: /cvs/public/parrot/dod.c,v retrieving revision 1.66 diff -u -r1.66 dod.c --- dod.c 28 Jul 2003 13:37:55 -0000 1.66 +++ dod.c 30 Jul 2003 13:35:19 -0000 @@ -31,6 +31,7 @@ #endif static size_t find_common_mask(size_t val1, size_t val2); +static void trace_children(struct Parrot_Interp *interpreter, PMC *current); #if ARENA_DOD_FLAGS @@ -38,6 +39,7 @@ { struct Small_Object_Arena *arena = GET_ARENA(obj); + PMC *children = NULL; size_t n = GET_OBJ_N(arena, obj); size_t ns = n >> ARENA_FLAG_SHIFT; UINTVAL nm = (n & ARENA_FLAG_MASK) << 2; @@ -50,14 +52,22 @@ if (*dod_flags & (PObj_is_special_PMC_FLAG << nm)) { if (((PMC*)obj)->pmc_ext) { /* put it on the end of the list */ - interpreter->mark_ptr->next_for_GC = (PMC *)obj; + if (interpreter->mark_ptr) + interpreter->mark_ptr->next_for_GC = (PMC *)obj; + else + children = (PMC *)obj; /* Explicitly make the tail of the linked list be * self-referential */ interpreter->mark_ptr = ((PMC*)obj)->next_for_GC = (PMC *)obj; } else if (PObj_custom_mark_TEST(obj)) VTABLE_mark(interpreter, (PMC *) obj); - return; + } + + /* children is only set if there isn't already a children trace active */ + if (children) { + trace_children(interpreter, children); + interpreter->mark_ptr = NULL; } } @@ -68,6 +78,8 @@ * individual pieces if they have private ones */ void pobject_lives(struct Parrot_Interp *interpreter, PObj *obj) { + PMC *children = NULL; + /* if object is live or on free list return */ if (PObj_is_live_or_free_TESTALL(obj)) { return; @@ -90,7 +102,10 @@ if (PObj_is_special_PMC_TEST(obj)) { if (((PMC*)obj)->pmc_ext) { /* put it on the end of the list */ - interpreter->mark_ptr->next_for_GC = (PMC *)obj; + if (interpreter->mark_ptr) + interpreter->mark_ptr->next_for_GC = (PMC *)obj; + else + children = (PMC *)obj; /* Explicitly make the tail of the linked list be * self-referential */ interpreter->mark_ptr = ((PMC*)obj)->next_for_GC = (PMC *)obj; @@ -109,6 +124,12 @@ obj, ((Buffer*)obj)->bufstart); } #endif + + /* children is only set if there isn't already a children trace active */ + if (children) { + trace_children(interpreter, children); + interpreter->mark_ptr = NULL; + } } #endif @@ -118,7 +139,7 @@ static void trace_active_PMCs(struct Parrot_Interp *interpreter, int trace_stack) { - PMC *current, *prev = NULL; + PMC *current; /* Pointers to the currently being processed PMC, and * in the previously processed PMC in a loop. * @@ -129,14 +150,12 @@ unsigned int i = 0, j = 0; struct PRegChunk *cur_chunk = 0; struct Stash *stash = 0; - UINTVAL mask = PObj_is_PMC_ptr_FLAG | PObj_is_buffer_ptr_FLAG - | PObj_custom_mark_FLAG; /* We have to start somewhere, the interpreter globals is a good place */ interpreter->mark_ptr = current = interpreter->iglobals; /* mark it as used */ - pobject_lives(interpreter, (PObj *)current); + pobject_lives(interpreter, (PObj *)interpreter->iglobals); pobject_lives(interpreter, interpreter->ctx.warns); /* Now, go run through the PMC registers and mark them as live */ /* First mark the current set. */ @@ -182,14 +201,28 @@ mark_stack(interpreter, stacks[j]); } + + /* Walk the iodata */ + Parrot_IOData_mark(interpreter, interpreter->piodata); + /* Find important stuff on the system stack */ #if TRACE_SYSTEM_AREAS if (trace_stack) trace_system_areas(interpreter); #endif - /* Okay, we've marked the whole root set, and should have a good-sized * list 'o things to look at. Run through it */ + trace_children(interpreter, current); +} + +static void +trace_children(struct Parrot_Interp *interpreter, PMC *current) +{ + PMC *prev = NULL; + unsigned i = 0; + UINTVAL mask = PObj_is_PMC_ptr_FLAG | PObj_is_buffer_ptr_FLAG + | PObj_custom_mark_FLAG; + for (; current != prev; current = current->next_for_GC) { UINTVAL bits = PObj_get_FLAGS(current) & mask; Index: embed.c =================================================================== RCS file: /cvs/public/parrot/embed.c,v retrieving revision 1.78 diff -u -r1.78 embed.c --- embed.c 29 Jul 2003 23:31:06 -0000 1.78 +++ embed.c 30 Jul 2003 13:35:19 -0000 @@ -87,7 +87,7 @@ if (filename == NULL || strcmp(filename, "-") == 0) { /* read from STDIN */ - io = new_io_pmc(interpreter, PIO_STDIN(interpreter)); + io = PIO_STDIN(interpreter); /* read 1k at a time */ program_size = 0; } Index: interpreter.c =================================================================== RCS file: /cvs/public/parrot/interpreter.c,v retrieving revision 1.182 diff -u -r1.182 interpreter.c --- interpreter.c 28 Jul 2003 21:52:59 -0000 1.182 +++ interpreter.c 30 Jul 2003 13:35:19 -0000 @@ -688,7 +688,6 @@ SET_NULL(interpreter->piodata); PIO_init(interpreter); - if (is_env_var_set("PARROT_GC_DEBUG")) { #if ! DISABLE_GC_DEBUG Interp_flags_SET(interpreter, PARROT_GC_DEBUG_FLAG); @@ -826,6 +825,11 @@ * no DOD run, so everything is considered dead */ + /* XXX boe: This hack explicitly marks the piodata, these filehandles + * need to be open until PIO_finish is called + */ + Parrot_IOData_mark(interpreter, interpreter->piodata); + if (interpreter->has_early_DOD_PMCs) free_unused_pobjects(interpreter, interpreter->arena_base->pmc_pool); @@ -833,6 +837,9 @@ * if the --leak-test commandline was given */ + /* Now the PIOData gets also cleared */ + PIO_finish(interpreter); + if (! (interpreter->parent_interpreter || Interp_flags_TEST(interpreter, PARROT_DESTROY_FLAG))) return; @@ -888,8 +895,6 @@ stack_destroy(interpreter->ctx.control_stack); /* intstack */ intstack_free(interpreter, interpreter->ctx.intstack); - - PIO_finish(interpreter); mem_sys_free(interpreter); } Index: io.ops =================================================================== RCS file: /cvs/public/parrot/io.ops,v retrieving revision 1.29 diff -u -r1.29 io.ops --- io.ops 21 Jul 2003 18:00:24 -0000 1.29 +++ io.ops 30 Jul 2003 13:35:19 -0000 @@ -104,17 +104,17 @@ =cut inline op getstdin(out PMC) { - $1 = new_io_pmc(interpreter, PIO_STDIN(interpreter)); + $1 = PIO_STDIN(interpreter); goto NEXT(); } inline op getstdout(out PMC) { - $1 = new_io_pmc(interpreter, PIO_STDOUT(interpreter)); + $1 = PIO_STDOUT(interpreter); goto NEXT(); } inline op getstderr(out PMC) { - $1 = new_io_pmc(interpreter, PIO_STDERR(interpreter)); + $1 = PIO_STDERR(interpreter); goto NEXT(); } @@ -189,8 +189,7 @@ op print(in STR) { STRING *s = $1; if (s && string_length(s)) { - PIO_putps(interpreter, new_io_pmc(interpreter, PIO_STDOUT(interpreter)), - s); + PIO_putps(interpreter, PIO_STDOUT(interpreter), s); } goto NEXT(); } @@ -199,8 +198,7 @@ PMC *p = $1; STRING *s = (VTABLE_get_string(interpreter, p)); if (s) { - PIO_putps(interpreter, new_io_pmc(interpreter, PIO_STDOUT(interpreter)), - s); + PIO_putps(interpreter, PIO_STDOUT(interpreter), s); } goto NEXT(); } @@ -232,8 +230,7 @@ op printerr(in STR) { STRING *s = $1; if (s && string_length(s)) { - PIO_putps(interpreter, new_io_pmc(interpreter, PIO_STDERR(interpreter)), - s); + PIO_putps(interpreter, PIO_STDERR(interpreter), s); } goto NEXT(); } @@ -242,8 +239,7 @@ PMC *p = $1; STRING *s = (VTABLE_get_string(interpreter, p)); if (s) { - PIO_putps(interpreter, new_io_pmc(interpreter, PIO_STDOUT(interpreter)), - s); + PIO_putps(interpreter, PIO_STDOUT(interpreter), s); } goto NEXT(); } @@ -332,7 +328,7 @@ n = $2; $1 = string_make(interpreter, NULL, n, NULL, 0, NULL); memset(($1)->strstart, 0, n); - nr = PIO_read(interpreter, new_io_pmc(interpreter, PIO_STDIN(interpreter)), + nr = PIO_read(interpreter, PIO_STDIN(interpreter), ($1)->strstart, (size_t)n); if(nr > 0) ($1)->strlen = ($1)->bufused = nr; Index: trace.c =================================================================== RCS file: /cvs/public/parrot/trace.c,v retrieving revision 1.37 diff -u -r1.37 trace.c --- trace.c 21 Jul 2003 18:00:24 -0000 1.37 +++ trace.c 30 Jul 2003 13:35:19 -0000 @@ -247,7 +247,7 @@ } /* Flush *stderr* now that we've output the trace info */ - PIO_flush(interpreter, new_io_pmc(interpreter, PIO_STDERR(interpreter))); + PIO_flush(interpreter, PIO_STDERR(interpreter)); } Index: classes/parrotio.pmc =================================================================== RCS file: /cvs/public/parrot/classes/parrotio.pmc,v retrieving revision 1.5 diff -u -r1.5 parrotio.pmc --- classes/parrotio.pmc 21 Jul 2003 18:00:29 -0000 1.5 +++ classes/parrotio.pmc 30 Jul 2003 13:35:20 -0000 @@ -13,12 +13,62 @@ #include "parrot/parrot.h" +static void +enter_nci_method(struct Parrot_Interp *interpreter, PMC *method_table, + void *func, const char *name, const char *proto) +{ + PMC *method; + + method = pmc_new(interpreter, enum_class_NCI); + VTABLE_set_string_keyed(interpreter, method, func, + string_make(interpreter, proto, strlen(proto), + NULL, 0, NULL)); + VTABLE_set_pmc_keyed(interpreter, method_table, + key_new_string(interpreter, + string_make(interpreter, name, + strlen(name), NULL, + 0, NULL)), + method); +} + pmclass ParrotIO { STRING* name () { return whoami; } + void class_init () { + PMC *method_table;; + + /* These classes are needed now so make sure they are inited */ + Parrot_NCI_class_init(interp, enum_class_NCI); + Parrot_PerlHash_class_init(interp, enum_class_PerlHash); + Parrot_PerlUndef_class_init(interp, enum_class_PerlUndef); + + method_table = pmc_new(INTERP, enum_class_PerlHash); + + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_close), "close", "iIP"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_flush), "flush", "vIP"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_read), "read", "iIPii"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_write), "write", "iIPii"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_setbuf), "setbuf", "iIPi"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_setlinebuf), "setlinebuf", "iIP"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_puts), "puts", "iIPt"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_seek), "seek", "iIPiii"); + enter_nci_method(INTERP, method_table, + F2DPTR(PIO_eof), "eof", "iIP"); + + ((ParrotIOData *)(INTERP->piodata))->method_table = method_table; + } + void init () { PObj_active_destroy_SET(SELF); PObj_needs_early_DOD_SET(SELF); @@ -42,5 +92,12 @@ INTVAL get_bool() { return !PIO_eof(INTERP, SELF); + } + + PMC* find_method (STRING* name) { + PMC* method_table = ((ParrotIOData *)(INTERP->piodata))->method_table; + + return VTABLE_get_pmc_keyed(INTERP, method_table, + key_new_string(INTERP, name)); } } Index: include/parrot/io.h =================================================================== RCS file: /cvs/public/parrot/include/parrot/io.h,v retrieving revision 1.35 diff -u -r1.35 io.h --- include/parrot/io.h 21 Jul 2003 18:00:42 -0000 1.35 +++ include/parrot/io.h 30 Jul 2003 13:35:20 -0000 @@ -140,7 +140,7 @@ typedef struct _ParrotIOBuf ParrotIOBuf; typedef struct _ParrotIO ParrotIO; typedef struct _ParrotIOData ParrotIOData; -typedef struct _ParrotIO **ParrotIOTable; +typedef PMC **ParrotIOTable; struct _ParrotIO { PIOHANDLE fd; /* Low level OS descriptor */ @@ -166,6 +166,7 @@ struct _ParrotIOData { ParrotIOTable table; ParrotIOLayer *default_stack; + PMC *method_table; }; @@ -335,6 +336,8 @@ extern INTVAL PIO_eprintf(theINTERP, const char *s, ...); extern INTVAL PIO_getfd(theINTERP, PMC *io); extern PIOOFF_T PIO_tell(theINTERP, PMC *io); + +extern void Parrot_IOData_mark(theINTERP, ParrotIOData *piodata); /* Put platform specific macros here if you must */ #ifdef PIO_OS_WIN32 Index: io/io.c =================================================================== RCS file: /cvs/public/parrot/io/io.c,v retrieving revision 1.48 diff -u -r1.48 io.c --- io/io.c 21 Jul 2003 18:00:45 -0000 1.48 +++ io/io.c 30 Jul 2003 13:35:20 -0000 @@ -119,9 +119,21 @@ { /* Has interp been initialized already? */ if (interpreter->piodata) { - /* memsub system is up and running: - * TODO: create stdio PMCs and store them away for later - */ + /* memsub system is up and running: */ + /* Init IO stacks and handles for interp instance. */ + if (PIO_init_stacks(interpreter) != 0) { + internal_exception(PIO_ERROR, "PIO init stacks failed."); + } + + if (!PIO_STDIN(interpreter) || !PIO_STDOUT(interpreter) + || !PIO_STDERR(interpreter)) { + internal_exception(PIO_ERROR, "PIO init std handles failed."); + } + + if (Interp_flags_TEST(interpreter, PARROT_DEBUG_FLAG)) { + PIO_eprintf(NULL, "PIO: IO system initialized.\n"); + } + return; } @@ -133,19 +145,6 @@ if (GET_INTERP_IOD(interpreter)->table == NULL) internal_exception(PIO_ERROR, "PIO alloc table failure."); - /* Init IO stacks and handles for interp instance. */ - if (PIO_init_stacks(interpreter) != 0) { - internal_exception(PIO_ERROR, "PIO init stacks failed."); - } - - if (!PIO_STDIN(interpreter) || !PIO_STDOUT(interpreter) - || !PIO_STDERR(interpreter)) { - internal_exception(PIO_ERROR, "PIO init std handles failed."); - } - - if (Interp_flags_TEST(interpreter, PARROT_DEBUG_FLAG)) { - PIO_eprintf(NULL, "PIO: IO system initialized.\n"); - } } void @@ -733,8 +732,7 @@ if(interpreter) { str=Parrot_vsprintf_c(interpreter, s, args); - ret=PIO_putps(interpreter, - new_io_pmc(interpreter, PIO_STDOUT(interpreter)), str); + ret=PIO_putps(interpreter, PIO_STDOUT(interpreter), str); } else { /* Be nice about this... @@ -759,8 +757,7 @@ if(interpreter) { str=Parrot_vsprintf_c(interpreter, s, args); - ret=PIO_putps(interpreter, - new_io_pmc(interpreter, PIO_STDERR(interpreter)), str); + ret=PIO_putps(interpreter, PIO_STDERR(interpreter), str); } else { /* Be nice about this... @@ -778,20 +775,32 @@ PIO_getfd(theINTERP, PMC *pmc) { INTVAL i; - ParrotIO *io = PMC_data(pmc); ParrotIOTable table = ((ParrotIOData*)interpreter->piodata)->table; for(i = 0; i < PIO_NR_OPEN; i++) { - if (table[i] == io) return i; + if (table[i] == pmc) return i; if (table[i] == NULL) { - table[i] = io; + table[i] = pmc; return i; } } /* XXX boe: increase size of the fdtable */ return -1; +} + +void +Parrot_IOData_mark(theINTERP, ParrotIOData *piodata) +{ + INTVAL i; + ParrotIOTable table = piodata->table; + + for (i = 0; i < PIO_NR_OPEN; i++) { + if (table[i]) { + pobject_lives(interpreter, (PObj *)table[i]); + } + } } /* Index: io/io_buf.c =================================================================== RCS file: /cvs/public/parrot/io/io_buf.c,v retrieving revision 1.7 diff -u -r1.7 io_buf.c --- io/io_buf.c 29 Jul 2003 19:01:37 -0000 1.7 +++ io/io_buf.c 30 Jul 2003 13:35:20 -0000 @@ -69,9 +69,10 @@ PIO_buf_init(theINTERP, ParrotIOLayer *layer) { if (PIO_STDOUT(interpreter)) - PIO_buf_setlinebuf(interpreter, layer, PIO_STDOUT(interpreter)); + PIO_buf_setlinebuf(interpreter, layer, + PMC_data(PIO_STDOUT(interpreter))); if (PIO_STDIN(interpreter)) - PIO_buf_setbuf(interpreter, layer, PIO_STDIN(interpreter), + PIO_buf_setbuf(interpreter, layer, PMC_data(PIO_STDIN(interpreter)), PIO_UNBOUND); return 0; } Index: io/io_unix.c =================================================================== RCS file: /cvs/public/parrot/io/io_unix.c,v retrieving revision 1.26 diff -u -r1.26 io_unix.c --- io/io_unix.c 21 Jul 2003 18:00:45 -0000 1.26 +++ io/io_unix.c 30 Jul 2003 13:35:20 -0000 @@ -88,17 +88,28 @@ { ParrotIOData *d = GET_INTERP_IOD(interpreter); if (d != NULL && d->table != NULL) { - if ((PIO_STDIN(interpreter) = - PIO_unix_fdopen(interpreter, layer, STDIN_FILENO, - PIO_F_READ | PIO_F_SHARED)) - && (PIO_STDOUT(interpreter) = - PIO_unix_fdopen(interpreter, layer, STDOUT_FILENO, - PIO_F_WRITE | PIO_F_SHARED)) - && (PIO_STDERR(interpreter) = - PIO_unix_fdopen(interpreter, layer, STDERR_FILENO, - PIO_F_WRITE | PIO_F_SHARED)) - ) - return 0; + ParrotIO *io; + + INTVAL has_early = interpreter->has_early_DOD_PMCs; + + io = PIO_unix_fdopen(interpreter, layer, STDIN_FILENO, PIO_F_READ); + if (!io) return -1; + PIO_STDIN(interpreter) = new_io_pmc(interpreter, io); + PObj_needs_early_DOD_CLEAR(PIO_STDIN(interpreter)); + + io = PIO_unix_fdopen(interpreter, layer, STDOUT_FILENO, PIO_F_WRITE); + if (!io) return -1; + PIO_STDOUT(interpreter) = new_io_pmc(interpreter, io); + PObj_needs_early_DOD_CLEAR(PIO_STDOUT(interpreter)); + + io = PIO_unix_fdopen(interpreter, layer, STDERR_FILENO, PIO_F_WRITE); + if (!io) return -1; + PIO_STDERR(interpreter) = new_io_pmc(interpreter, io); + PObj_needs_early_DOD_CLEAR(PIO_STDERR(interpreter)); + + interpreter->has_early_DOD_PMCs = has_early; + + return 0; } return -1; } Index: jit/i386/jit_emit.h =================================================================== RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v retrieving revision 1.73 diff -u -r1.73 jit_emit.h --- jit/i386/jit_emit.h 29 Jul 2003 20:04:14 -0000 1.73 +++ jit/i386/jit_emit.h 30 Jul 2003 13:35:20 -0000 @@ -2659,7 +2659,7 @@ const char *typs[] = { "lisc", /* I */ "t", /* S */ - "p", /* P */ + "pP", /* P */ "fd" /* N */ }; int first_reg = 5; @@ -2764,6 +2764,11 @@ emitm_movl_m_r(pc, emit_EAX, emit_EAX, 0, 1, offsetof(struct PMC_EXT, data)); #endif + emitm_pushl_r(pc, emit_EAX); + break; + case 'P': /* push PMC * */ + jit_emit_mov_rm_i(pc, emit_EAX, + &PMC_REG(count_regs(sig, signature->strstart))); emitm_pushl_r(pc, emit_EAX); break; case 'v': Index: t/pmc/io.t =================================================================== RCS file: /cvs/public/parrot/t/pmc/io.t,v retrieving revision 1.7 diff -u -r1.7 io.t --- t/pmc/io.t 28 Jul 2003 19:31:47 -0000 1.7 +++ t/pmc/io.t 30 Jul 2003 13:35:20 -0000 @@ -1,6 +1,6 @@ #! perl -w -use Parrot::Test tests => 17; +use Parrot::Test tests => 18; use Test::More; output_is(<<'CODE', <<'OUTPUT', "open/close"); @@ -259,4 +259,14 @@ 1.000000 foo This is a test +OUTPUT + +output_is(<<'CODE', <<'OUTPUT', 'puts method'); + set S5, "ok\n" + getstdout P5 + find_method P0, P5, "puts" + invoke + end +CODE +ok OUTPUT
-- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47