Skip to content

Commit

Permalink
merge pbc_frozen_strings1 branch
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@46226 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
plobsing committed May 3, 2010
9 parents 4331f2c + 3ce1c9b + 810f510 + cb9dfd2 + 63a6921 + a4be6a8 + f1d26ee + 37015f1 + 537edfe commit 918e79a
Show file tree
Hide file tree
Showing 17 changed files with 671 additions and 86 deletions.
11 changes: 9 additions & 2 deletions MANIFEST
@@ -1,12 +1,12 @@
# ex: set ro:
# $Id$
#
# generated by ./tools/dev/mk_manifest_and_skip.pl Sun May 2 04:09:12 2010 UT
# generated by tools/dev/mk_manifest_and_skip.pl Mon May 3 04:04:08 2010 UT
#
# See below for documentation on the format of this file.
#
# See docs/submissions.pod and the documentation in
# ./tools/dev/mk_manifest_and_skip.pl on how to recreate this file after SVN
# tools/dev/mk_manifest_and_skip.pl on how to recreate this file after SVN
# has been told about new or deleted files.
.gitignore []
CREDITS [main]doc
Expand Down Expand Up @@ -245,6 +245,7 @@ config/gen/config_pm/myconfig.in []
config/gen/core_pmcs.pm []
config/gen/makefiles.pm []
config/gen/makefiles/docs.in []
config/gen/makefiles/dynpmc.in []
config/gen/makefiles/editor.in []
config/gen/makefiles/ext.in []
config/gen/makefiles/parrot_embed_pl.in []
Expand Down Expand Up @@ -1117,6 +1118,7 @@ lib/Pod/Simple/TranscodeDumb.pm []
lib/Pod/Simple/TranscodeSmart.pm []
lib/Pod/Simple/XHTML.pm []
lib/Pod/Simple/XMLOutStream.pm []
merge []
parrotbug []
runtime/parrot/dynext/README []doc
runtime/parrot/include/README []doc
Expand Down Expand Up @@ -1352,6 +1354,7 @@ src/pmc/hashiterator.pmc []
src/pmc/hashiteratorkey.pmc []
src/pmc/imageio.pmc []
src/pmc/imageiosize.pmc []
src/pmc/imageiostrings.pmc []
src/pmc/integer.pmc []
src/pmc/iterator.pmc []
src/pmc/key.pmc []
Expand Down Expand Up @@ -1380,6 +1383,7 @@ src/pmc/packfilerawsegment.pmc []
src/pmc/packfilesegment.pmc []
src/pmc/parrotinterpreter.pmc []
src/pmc/parrotlibrary.pmc []
src/pmc/parrotrunningthread.pmc []
src/pmc/parrotthread.pmc []
src/pmc/pmc.num []
src/pmc/pmcproxy.pmc []
Expand Down Expand Up @@ -1824,6 +1828,7 @@ t/pmc/hashiterator.t [test]
t/pmc/hashiteratorkey.t [test]
t/pmc/imageio.t [test]
t/pmc/imageiosize.t [test]
t/pmc/imageiostrings.t [test]
t/pmc/integer.t [test]
t/pmc/io.t [test]
t/pmc/io_iterator.t [test]
Expand Down Expand Up @@ -1863,6 +1868,7 @@ t/pmc/parrotinterpreter.t [test]
t/pmc/parrotio.t [test]
t/pmc/parrotlibrary.t [test]
t/pmc/parrotobject.t [test]
t/pmc/parrotrunningthread.t [test]
t/pmc/parrotthread.t [test]
t/pmc/pmc.t [test]
t/pmc/pmcproxy.t [test]
Expand Down Expand Up @@ -2119,6 +2125,7 @@ tools/dev/vgp []
tools/dev/vgp_darwin []
tools/dev/vms-patch []
tools/dev/vtablize.pl []
tools/docs/book-to-latex.pl []
tools/docs/filename_and_chapter.pl []
tools/docs/mk_chm.pl []
tools/docs/ops_summary.pl []
Expand Down
1 change: 1 addition & 0 deletions PBC_COMPAT
Expand Up @@ -27,6 +27,7 @@

# please insert tab separated entries at the top of the list

6.12 2010.05.02 plobsing store constant PMC strings as top level constant strings
6.11 2010.04.29 tewk remove ParrotRunningThread
6.10 2010.04.29 NotFound packfiledebug.pmc
6.9 2010.04.27 bacek remove deprecated in-place string ops (bitwise, charset, case change)
Expand Down
76 changes: 46 additions & 30 deletions compilers/imcc/pbc.c
Expand Up @@ -6,6 +6,7 @@
#include "imc.h"
#include "pbc.h"
#include "parrot/packfile.h"
#include "parrot/pmc_freeze.h"
#include "pmc/pmc_sub.h"
#include "pmc/pmc_callcontext.h"

Expand Down Expand Up @@ -78,7 +79,7 @@ add_const_pmc_sub(PARROT_INTERP,
FUNC_MODIFIES(*r);

PARROT_WARN_UNUSED_RESULT
static int add_const_str(PARROT_INTERP, ARGIN(const SymReg *r))
static int add_const_str(PARROT_INTERP, ARGIN(STRING *s))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

Expand Down Expand Up @@ -222,7 +223,7 @@ static void verify_signature(PARROT_INTERP,
, PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_add_const_str __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(r))
, PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_add_const_table __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_add_const_table_key __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Expand Down Expand Up @@ -832,7 +833,7 @@ fixup_globals(PARROT_INTERP)
interp->code->base.data[addr] = op;

if (nam->color < 0)
nam->color = add_const_str(interp, nam);
nam->color = add_const_str(interp, IMCC_string_from_reg(interp, nam));

interp->code->base.data[addr+2] = nam->color;

Expand Down Expand Up @@ -968,7 +969,7 @@ IMCC_string_from__STRINGC(PARROT_INTERP, ARGIN(char *buf))

/*
=item C<static int add_const_str(PARROT_INTERP, const SymReg *r)>
=item C<static int add_const_str(PARROT_INTERP, STRING *s)>
Adds a constant string to constant_table.
Expand All @@ -978,12 +979,11 @@ Adds a constant string to constant_table.

PARROT_WARN_UNUSED_RESULT
static int
add_const_str(PARROT_INTERP, ARGIN(const SymReg *r))
add_const_str(PARROT_INTERP, ARGIN(STRING *s))
{
ASSERT_ARGS(add_const_str)

PackFile_ConstTable *table = interp->code->const_table;
STRING * const s = IMCC_string_from_reg(interp, r);
int i;

for (i = 0; i < table->const_count; ++i) {
Expand Down Expand Up @@ -1264,9 +1264,7 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
PMC *sub_pmc;
Parrot_Sub_attributes *sub, *outer_sub;

const int k = add_const_table(interp);
PackFile_ConstTable * const ct = interp->code->const_table;
PackFile_Constant * const pfc = ct->constants[k];
IMC_Unit * const unit =
IMCC_INFO(interp)->globals->cs->subs->unit;

Expand All @@ -1277,8 +1275,6 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
int i;
int ns_const = -1;

IMCC_INFO(interp)->globals->cs->subs->pmc_const = k;

if (unit->_namespace) {
/* strip namespace off from front */
const char *real_name = strrchr(r->name, '@');
Expand Down Expand Up @@ -1328,7 +1324,7 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
PMC_get_sub(interp, sub_pmc, sub);
Sub_comp_get_FLAGS(sub) |= (r->pcc_sub->pragma & SUB_COMP_FLAG_MASK);

r->color = add_const_str(interp, r);
r->color = add_const_str(interp, IMCC_string_from_reg(interp, r));
sub->name = ct->constants[r->color]->u.string;

/* If the unit has no subid, set the subid to match the name. */
Expand All @@ -1342,7 +1338,7 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
mem_sys_free(oldname);

/* create string constant for it. */
unit->subid->color = add_const_str(interp, unit->subid);
unit->subid->color = add_const_str(interp, IMCC_string_from_reg(interp, unit->subid));
}

sub->subid = ct->constants[unit->subid->color]->u.string;
Expand Down Expand Up @@ -1444,29 +1440,49 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)

Parrot_store_sub_in_namespace(interp, sub_pmc);

pfc->type = PFC_PMC;
pfc->u.key = sub_pmc;
unit->sub_pmc = sub_pmc;

if (sub->outer_sub)
PMC_get_sub(interp, sub->outer_sub, outer_sub);

IMCC_debug(interp, DEBUG_PBC_CONST,
"add_const_pmc_sub '%s' flags %x color %d (%Ss) "
"lex_info %s :outer(%Ss)\n",
r->name, r->pcc_sub->pragma, k,
sub_pmc->vtable->whoami,
sub->lex_info ? "yes" : "no",
sub->outer_sub? outer_sub->name :
Parrot_str_new(interp, "*none*", 0));

/*
* create entry in our fixup (=symbol) table
* the offset is the index in the constant table of this Sub
* store the sub's strings
* XXX these need to occur before the sub to support thawing properly
*/
PackFile_FixupTable_new_entry(interp, r->name, enum_fixup_sub, k);
{
PMC *strings = Parrot_freeze_strings(interp, sub_pmc);
int n = VTABLE_elements(interp, strings);
for (i = 0; i < n; i++) {
int unused = add_const_str(interp, VTABLE_get_string_keyed_int(interp, strings, i));
}
}

return k;
/* store the sub */
{
const int k = add_const_table(interp);
PackFile_Constant * const pfc = ct->constants[k];

pfc->type = PFC_PMC;
pfc->u.key = sub_pmc;
unit->sub_pmc = sub_pmc;

IMCC_INFO(interp)->globals->cs->subs->pmc_const = k;

IMCC_debug(interp, DEBUG_PBC_CONST,
"add_const_pmc_sub '%s' flags %x color %d (%Ss) "
"lex_info %s :outer(%Ss)\n",
r->name, r->pcc_sub->pragma, k,
sub_pmc->vtable->whoami,
sub->lex_info ? "yes" : "no",
sub->outer_sub? outer_sub->name :
Parrot_str_new(interp, "*none*", 0));

/*
* create entry in our fixup (=symbol) table
* the offset is the index in the constant table of this Sub
*/
PackFile_FixupTable_new_entry(interp, r->name, enum_fixup_sub, k);

return k;
}
}


Expand Down Expand Up @@ -1874,7 +1890,7 @@ add_1_const(PARROT_INTERP, ARGMOD(SymReg *r))
case 'S':
if (r->type & VT_CONSTP)
r = r->reg;
r->color = add_const_str(interp, r);
r->color = add_const_str(interp, IMCC_string_from_reg(interp, r));
break;
case 'N':
r->color = add_const_num(interp, r->name);
Expand Down
2 changes: 1 addition & 1 deletion ext/nqp-rx/src/stage0/Regex-s0.pir
Expand Up @@ -1921,7 +1921,7 @@ An alternate dump output for a Match object and all of its subcaptures.
# vim: expandtab shiftwidth=4 ft=pir:

### .include 'src/PAST/Regex.pir'
# $Id: Regex.pir 41578 2009-09-30 14:45:23Z pmichaud $
# $Id$

=head1 NAME

Expand Down
9 changes: 6 additions & 3 deletions include/parrot/packfile.h
Expand Up @@ -501,9 +501,11 @@ PackFile_Constant * PackFile_Constant_new(PARROT_INTERP)
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
size_t PackFile_Constant_pack_size(PARROT_INTERP,
ARGIN(const PackFile_Constant *self))
ARGIN(const PackFile_Constant *self),
ARGIN(const PackFile_ConstTable *ct))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
__attribute__nonnull__(2)
__attribute__nonnull__(3);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
Expand Down Expand Up @@ -856,7 +858,8 @@ void Parrot_trace_eprintf(ARGIN(const char *s), ...)
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_PackFile_Constant_pack_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(self))
, PARROT_ASSERT_ARG(self) \
, PARROT_ASSERT_ARG(ct))
#define ASSERT_ARGS_PackFile_Constant_unpack __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(constt) \
Expand Down
50 changes: 50 additions & 0 deletions include/parrot/pmc_freeze.h
Expand Up @@ -13,6 +13,8 @@
#ifndef PARROT_PMC_FREEZE_H_GUARD
#define PARROT_PMC_FREEZE_H_GUARD

#include "parrot/packfile.h"

typedef enum {
VISIT_HOW_PMC_TO_VISITOR = 0x00, /* push to visitor */
VISIT_HOW_VISITOR_TO_PMC = 0x01, /* shift from visitor */
Expand Down Expand Up @@ -118,12 +120,36 @@ STRING* Parrot_freeze(PARROT_INTERP, ARGIN(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
STRING * Parrot_freeze_pbc(PARROT_INTERP,
ARGIN(PMC *pmc),
ARGIN(const PackFile_ConstTable *pf))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
UINTVAL Parrot_freeze_pbc_size(PARROT_INTERP,
ARGIN(PMC *pmc),
ARGIN(const PackFile_ConstTable *pf))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
UINTVAL Parrot_freeze_size(PARROT_INTERP, ARGIN(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC * Parrot_freeze_strings(PARROT_INTERP, PMC *pmc)
__attribute__nonnull__(1);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
Expand All @@ -138,6 +164,16 @@ PMC* Parrot_thaw_constants(PARROT_INTERP, ARGIN(STRING *image))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
PMC* Parrot_thaw_pbc(PARROT_INTERP,
ARGIN(STRING *image),
ARGIN(PackFile_ConstTable *pf))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);

void Parrot_visit_loop_thawfinish(PARROT_INTERP, ARGIN(PMC *info))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
Expand All @@ -152,15 +188,29 @@ void Parrot_visit_loop_visit(PARROT_INTERP, ARGIN(PMC *info))
#define ASSERT_ARGS_Parrot_freeze __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_freeze_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc) \
, PARROT_ASSERT_ARG(pf))
#define ASSERT_ARGS_Parrot_freeze_pbc_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc) \
, PARROT_ASSERT_ARG(pf))
#define ASSERT_ARGS_Parrot_freeze_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_freeze_strings __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_thaw __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(image))
#define ASSERT_ARGS_Parrot_thaw_constants __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(image))
#define ASSERT_ARGS_Parrot_thaw_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(image) \
, PARROT_ASSERT_ARG(pf))
#define ASSERT_ARGS_Parrot_visit_loop_thawfinish __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(info))
Expand Down

0 comments on commit 918e79a

Please sign in to comment.