cvsuser 03/11/20 07:34:09
Modified: imcc pbc.c
src packfile.c packout.c pmc_freeze.c
Log:
PackFile-16
* set PF header information early in PF_new
* because unpacking during PF constant creation needs it
* Parrot_thaw_constants entry
Revision Changes Path
1.59 +1 -3 parrot/imcc/pbc.c
Index: pbc.c
===================================================================
RCS file: /cvs/public/parrot/imcc/pbc.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -w -r1.58 -r1.59
--- pbc.c 19 Nov 2003 07:26:55 -0000 1.58
+++ pbc.c 20 Nov 2003 15:34:06 -0000 1.59
@@ -81,7 +81,7 @@
SymReg **h;
UNUSED(ex);
- UNUSED(param);
+ UNUSED(interpreter);
cs = globals.cs;
while (cs) {
s = cs->subs;
@@ -611,8 +611,6 @@
sprintf(buf, "%s %s %d %d", "Sub", r->name, offs, len);
pfc = malloc(sizeof(struct PackFile_Constant));
- interpreter->code->const_table->base.pf->header->wordsize =
- sizeof(opcode_t);
rc = PackFile_Constant_unpack_pmc(interpreter,
interpreter->code->const_table, pfc, (opcode_t*)buf);
if (!rc)
1.117 +24 -1 parrot/src/packfile.c
Index: packfile.c
===================================================================
RCS file: /cvs/public/parrot/src/packfile.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -w -r1.116 -r1.117
--- packfile.c 13 Nov 2003 07:33:11 -0000 1.116
+++ packfile.c 20 Nov 2003 15:34:08 -0000 1.117
@@ -7,7 +7,7 @@
** This program is free software. It is subject to the same
** license as Parrot itself.
**
-** $Id: packfile.c,v 1.116 2003/11/13 07:33:11 mrjoltcola Exp $
+** $Id: packfile.c,v 1.117 2003/11/20 15:34:08 leo Exp $
**
** History:
** Rework by Melvin; new bytecode format, make bytecode portable.
@@ -818,6 +818,25 @@
=cut
*/
+/*
+ * fill a PF header with system specific data
+ */
+static void
+PackFile_set_header(struct PackFile *self)
+{
+ self->header->wordsize = sizeof(opcode_t);
+ self->header->byteorder = PARROT_BIGENDIAN;
+ self->header->major = PARROT_MAJOR_VERSION;
+ /* XXX during development, we check PATCH_LEVEL too */
+ self->header->minor = PARROT_MINOR_VERSION | PARROT_PATCH_VERSION;
+ self->header->flags = 0;
+ if (NUMVAL_SIZE == 8)
+ self->header->floattype = 0;
+ else /* if XXX */
+ self->header->floattype = 1;
+ /* write the fingerprint */
+ PackFile_write_fingerprint(self->header->pad);
+}
struct PackFile *
PackFile_new(INTVAL is_mapped)
@@ -837,6 +856,10 @@
PackFile_destroy(pf);
return NULL;
}
+ /*
+ * fill header with system specific data
+ */
+ PackFile_set_header(pf);
/* Other fields empty for now */
pf->byte_code = NULL;
1.28 +1 -15 parrot/src/packout.c
Index: packout.c
===================================================================
RCS file: /cvs/public/parrot/src/packout.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -w -r1.27 -r1.28
--- packout.c 23 Oct 2003 17:48:59 -0000 1.27
+++ packout.c 20 Nov 2003 15:34:08 -0000 1.28
@@ -7,7 +7,7 @@
** This program is free software. It is subject to the same
** license as Parrot itself.
**
-** $Id: packout.c,v 1.27 2003/10/23 17:48:59 robert Exp $
+** $Id: packout.c,v 1.28 2003/11/20 15:34:08 leo Exp $
** History:
** Rework by Melvin; new bytecode format, make bytecode portable.
** (Do endian conversion and wordsize transforms on the fly.)
@@ -65,20 +65,6 @@
struct PackFile_Segment *seg;
self->src = cursor;
-
- self->header->wordsize = sizeof(opcode_t);
- self->header->byteorder = PARROT_BIGENDIAN;
- self->header->major = PARROT_MAJOR_VERSION;
- /* XXX during development, we check PATCH_LEVEL too */
- self->header->minor = PARROT_MINOR_VERSION | PARROT_PATCH_VERSION;
- self->header->flags = 0;
- if (NUMVAL_SIZE == 8)
- self->header->floattype = 0;
- else /* if XXX */
- self->header->floattype = 1;
-
- /* write the fingerprint */
- PackFile_write_fingerprint(self->header->pad);
/* Pack the header */
mem_sys_memcopy(cursor, self->header, PACKFILE_HEADER_BYTES);
1.5 +55 -34 parrot/src/pmc_freeze.c
Index: pmc_freeze.c
===================================================================
RCS file: /cvs/public/parrot/src/pmc_freeze.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- pmc_freeze.c 20 Nov 2003 12:44:09 -0000 1.4
+++ pmc_freeze.c 20 Nov 2003 15:34:08 -0000 1.5
@@ -1,7 +1,7 @@
/* pmc_freeze.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: pmc_freeze.c,v 1.4 2003/11/20 12:44:09 leo Exp $
+ * $Id: pmc_freeze.c,v 1.5 2003/11/20 15:34:08 leo Exp $
* Overview:
* Freeze and thaw functionality
* Data Structure and Algorithms:
@@ -680,6 +680,49 @@
info->image = string_make(interpreter, NULL, len, NULL, 0, NULL);
}
+
+/*
+ * run_thaw - helper func
+ *
+ * thaw could use the next_for_GC pointers as todo-list too,
+ * but this would need 2 runs through the arenas to clean the
+ * next_for_GC pointers.
+ * For now it seems cheaper to use a list for remembering contained
+ * aggregates. We could of course decide dynamically, which strategy
+ * to use, e.g.: given a big image, the first thawed item is a small
+ * aggregate. This implies, it probably contains[1] more nested containers,
+ * for which the next_for_GC approach could be a win.
+ * [1] or some big strings :)
+ */
+
+static PMC*
+run_thaw(Parrot_Interp interpreter, STRING* image, visit_enum_type what)
+{
+ visit_info info;
+ PMC *n = NULL;
+ int dod_block = 0;
+
+ info.image = image;
+ if (string_length(image) > THAW_BLOCK_DOD_SIZE) {
+ Parrot_do_dod_run(interpreter, 1);
+ Parrot_block_DOD(interpreter);
+ Parrot_block_GC(interpreter);
+ dod_block = 1;
+ }
+
+ info.what = what; /* _NORMAL or _CONSTANTS */
+ todo_list_init(interpreter, &info);
+ info.visit_child_function = visit_todo_list_thaw;
+
+ n = new_pmc_header(interpreter);
+ visit_loop_todo_list(interpreter, n, &info);
+
+ if (dod_block) {
+ Parrot_unblock_DOD(interpreter);
+ Parrot_unblock_GC(interpreter);
+ }
+ return n;
+}
/*
* public interface
*/
@@ -740,45 +783,23 @@
}
/*
- * thaw could use the next_for_GC pointers as todo-list too,
- * but this would need 2 runs through the arenas to clean the
- * next_for_GC pointers.
- * For now it seems cheaper to use a list for remembering contained
- * aggregates. We could of course decide dynamically, which strategy
- * to use, e.g.: given a big image, the first thawed item is a small
- * aggregate. This implies, it probably contains[1] more nested containers,
- * for which the next_for_GC approach could be a win.
- * [1] or some big strings :)
+ * thaw a PMC, called from the thaw opcode
*/
-
PMC*
Parrot_thaw(Parrot_Interp interpreter, STRING* image)
{
- visit_info info;
- PMC *n = NULL;
- int dod_block = 0;
-
- info.image = image;
- if (string_length(image) > THAW_BLOCK_DOD_SIZE) {
- Parrot_do_dod_run(interpreter, 1);
- Parrot_block_DOD(interpreter);
- Parrot_block_GC(interpreter);
- dod_block = 1;
+ return run_thaw(interpreter, image, VISIT_THAW_NORMAL);
}
- info.what = VISIT_THAW_NORMAL;
- todo_list_init(interpreter, &info);
- info.visit_child_function = visit_todo_list_thaw;
-
- n = new_pmc_header(interpreter);
- visit_loop_todo_list(interpreter, n, &info);
-
- if (dod_block) {
- Parrot_unblock_DOD(interpreter);
- Parrot_unblock_GC(interpreter);
- }
- return n;
+/*
+ * thaw constants - used by packfile for unpacking PMC constants
+ */
+PMC*
+Parrot_thaw_constants(Parrot_Interp interpreter, STRING* image)
+{
+ return run_thaw(interpreter, image, VISIT_THAW_CONSTANTS);
}
+
/*
* there are for sure shortcuts to clone faster, e.g. allways