Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'sys_mem' into trunk

git-svn-id: https://svn.parrot.org/parrot/trunk@44291 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 4833868fa12303c224d31ce4cb760b4171fe62e2 1 parent c1e0a2a
@bacek bacek authored
Showing with 2,360 additions and 2,475 deletions.
  1. +77 −57 compilers/imcc/cfg.c
  2. +4 −2 compilers/imcc/cfg.h
  3. +10 −8 compilers/imcc/imc.c
  4. +2 −2 compilers/imcc/imcc.l
  5. +86 −70 compilers/imcc/imcc.y
  6. +2 −2 compilers/imcc/imclexer.c
  7. +943 −1,530 compilers/imcc/imcparser.c
  8. +19 −25 compilers/imcc/imcparser.h
  9. +1 −1  compilers/imcc/instructions.c
  10. +1 −1  compilers/imcc/optimizer.c
  11. +10 −10 compilers/imcc/parser_util.c
  12. +11 −11 compilers/imcc/pbc.c
  13. +19 −15 compilers/imcc/pcc.c
  14. +26 −18 compilers/imcc/reg_alloc.c
  15. +17 −17 compilers/imcc/sets.c
  16. +25 −13 compilers/imcc/sets.h
  17. +71 −62 compilers/imcc/symreg.c
  18. +34 −15 compilers/imcc/symreg.h
  19. +2 −2 config/gen/crypto/digest_pmc.in
  20. +1 −0  config/gen/makefiles/root.in
  21. +1 −1  config/gen/platform/generic/exec.c
  22. +3 −3 config/gen/platform/platform_interface.h
  23. +16 −8 include/parrot/charset.h
  24. +19 −9 include/parrot/debugger.h
  25. +9 −4 include/parrot/encoding.h
  26. +45 −0 include/parrot/gc_api.h
  27. +24 −7 include/parrot/memory.h
  28. +1 −1  include/parrot/oplib.h
  29. +37 −19 include/parrot/packfile.h
  30. +13 −13 lib/Parrot/Ops2c/Utils.pm
  31. +3 −2 src/call/args.c
  32. +1 −1  src/call/ops.c
  33. +48 −47 src/debug.c
  34. +2 −2 src/dynext.c
  35. +5 −9 src/dynpmc/gdbmhash.pmc
  36. +4 −7 src/dynpmc/rational.pmc
  37. +6 −5 src/embed.c
  38. +28 −27 src/events.c
  39. +2 −2 src/exit.c
  40. +2 −2 src/frame_builder.c
  41. +4 −8 src/gc/alloc_memory.c
  42. +120 −4 src/gc/api.c
  43. +5 −5 src/gc/gc_inf.c
  44. +104 −4 src/gc/gc_ms.c
  45. +7 −0 src/gc/gc_private.h
  46. +3 −3 src/interp/inter_create.c
  47. +2 −2 src/io/buffer.c
  48. +4 −4 src/io/core.c
  49. +6 −6 src/multidispatch.c
  50. +11 −12 src/oo.c
  51. +163 −131 src/packfile.c
  52. +4 −3 src/packfile/pf_items.c
  53. +2 −2 src/pbc_dump.c
  54. +38 −34 src/pbc_merge.c
  55. +5 −5 src/pmc/bigint.pmc
  56. +7 −7 src/pmc/bignum.pmc
  57. +1 −1  src/pmc/callcontext.pmc
  58. +6 −4 src/pmc/fixedbooleanarray.pmc
  59. +3 −3 src/pmc/fixedfloatarray.pmc
  60. +3 −3 src/pmc/fixedintegerarray.pmc
  61. +5 −5 src/pmc/fixedpmcarray.pmc
  62. +3 −3 src/pmc/fixedstringarray.pmc
  63. +19 −15 src/pmc/managedstruct.pmc
  64. +1 −1  src/pmc/nci.pmc
  65. +1 −1  src/pmc/opcode.pmc
  66. +2 −2 src/pmc/oplib.pmc
  67. +2 −3 src/pmc/orderedhash.pmc
  68. +1 −1  src/pmc/os.pmc
  69. +2 −2 src/pmc/packfile.pmc
  70. +8 −5 src/pmc/packfileannotations.pmc
  71. +3 −3 src/pmc/packfileconstanttable.pmc
  72. +1 −1  src/pmc/packfilefixupentry.pmc
  73. +3 −3 src/pmc/packfilefixuptable.pmc
  74. +2 −2 src/pmc/packfilerawsegment.pmc
  75. +6 −6 src/pmc/parrotinterpreter.pmc
  76. +13 −9 src/pmc/resizablebooleanarray.pmc
  77. +1 −2  src/pmc/resizablefloatarray.pmc
  78. +1 −1  src/pmc/resizableintegerarray.pmc
  79. +2 −1  src/pmc/resizablepmcarray.pmc
  80. +2 −2 src/pmc/resizablestringarray.pmc
  81. +2 −1  src/pmc/sockaddr.pmc
  82. +5 −3 src/pmc/sub.pmc
  83. +9 −17 src/runcore/cores.c
  84. +31 −28 src/runcore/main.c
  85. +5 −3 src/runcore/profiling.c
  86. +6 −6 src/string/api.c
  87. +30 −27 src/string/charset.c
  88. +16 −14 src/string/encoding.c
  89. +3 −3 src/string/encoding/utf16.c
  90. +3 −3 src/string/encoding/utf8.c
  91. +1 −1  src/string/primitives.c
  92. +8 −8 src/thread.c
  93. +1 −1  src/tsq.c
  94. +6 −6 src/utils.c
  95. +7 −7 src/vtables.c
  96. +21 −8 t/pmc/fixedbooleanarray.t
View
134 compilers/imcc/cfg.c
@@ -35,27 +35,30 @@ between blocks.
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void analyse_life_block(
+static void analyse_life_block(PARROT_INTERP,
ARGIN(const Basic_block* bb),
ARGMOD(SymReg *r))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*r);
-static void analyse_life_symbol(
+static void analyse_life_symbol(PARROT_INTERP,
ARGIN(const IMC_Unit *unit),
ARGMOD(SymReg* r))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(* r);
-static void bb_add_edge(
+static void bb_add_edge(PARROT_INTERP,
ARGMOD(IMC_Unit *unit),
ARGIN(Basic_block *from),
ARGMOD(Basic_block *to))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
+ __attribute__nonnull__(4)
FUNC_MODIFIES(*unit)
FUNC_MODIFIES(*to);
@@ -110,17 +113,19 @@ static void free_loops(ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
FUNC_MODIFIES(*unit);
-static void init_basic_blocks(ARGMOD(IMC_Unit *unit))
+static void init_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
+ __attribute__nonnull__(2)
FUNC_MODIFIES(*unit);
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
-static Basic_block* make_basic_block(
+static Basic_block* make_basic_block(PARROT_INTERP,
ARGMOD(IMC_Unit *unit),
ARGMOD(Instruction *ins))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*unit)
FUNC_MODIFIES(*ins);
@@ -145,13 +150,16 @@ static void sort_loops(PARROT_INTERP, ARGIN(IMC_Unit *unit))
__attribute__nonnull__(2);
#define ASSERT_ARGS_analyse_life_block __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(bb) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(bb) \
, PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_analyse_life_symbol __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_bb_add_edge __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(from) \
, PARROT_ASSERT_ARG(to))
#define ASSERT_ARGS_bb_check_set_addr __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -180,9 +188,11 @@ static void sort_loops(PARROT_INTERP, ARGIN(IMC_Unit *unit))
#define ASSERT_ARGS_free_loops __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_init_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_make_basic_block __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(ins))
#define ASSERT_ARGS_mark_loop __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -267,7 +277,7 @@ find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
unsigned int i;
IMCC_info(interp, 2, "find_basic_blocks\n");
- init_basic_blocks(unit);
+ init_basic_blocks(interp, unit);
for (i = 0; i < hsh->size; i++) {
SymReg *r;
@@ -288,7 +298,7 @@ find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
ins->index = i = 0;
- bb = make_basic_block(unit, ins);
+ bb = make_basic_block(interp, unit, ins);
if (ins->type & ITBRANCH) {
SymReg * const addr = get_branch_reg(bb->end);
@@ -326,7 +336,7 @@ find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
nu = 0;
else if (ins->type & ITLABEL) {
bb->end = ins->prev;
- bb = make_basic_block(unit, ins);
+ bb = make_basic_block(interp, unit, ins);
}
/* a branch is the end of a basic block
@@ -342,7 +352,7 @@ find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
continue;
if (ins->next)
- bb = make_basic_block(unit, ins->next);
+ bb = make_basic_block(interp, unit, ins->next);
nu = 1;
}
@@ -380,8 +390,8 @@ bb_check_set_addr(PARROT_INTERP, ARGMOD(IMC_Unit *unit),
ins->symregs[1]->name);
/* connect this block with first and last block */
- bb_add_edge(unit, unit->bb_list[0], bb);
- bb_add_edge(unit, unit->bb_list[unit->n_basic_blocks - 1], bb);
+ bb_add_edge(interp, unit, unit->bb_list[0], bb);
+ bb_add_edge(interp, unit, unit->bb_list[unit->n_basic_blocks - 1], bb);
/* and mark the instruction as being kind of a branch */
bb->start->type |= ITADDR;
@@ -419,7 +429,7 @@ build_cfg(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
/* if the block can fall-through */
if (i > 0 && ! (last->end->type & IF_goto))
- bb_add_edge(unit, last, bb);
+ bb_add_edge(interp, unit, last, bb);
/* check first ins, if label try to find a set_addr op */
if (bb->start->type & ITLABEL)
@@ -433,7 +443,7 @@ build_cfg(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
else if (STREQ(bb->start->opname, "invoke")
|| STREQ(bb->start->opname, "invokecc")) {
if (check_invoke_type(interp, unit, bb->start) == INVOKE_SUB_LOOP)
- bb_add_edge(unit, bb, unit->bb_list[0]);
+ bb_add_edge(interp, unit, bb, unit->bb_list[0]);
}
last = bb;
@@ -486,14 +496,14 @@ bb_findadd_edge(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(Basic_block *from),
const SymReg * const r = find_sym(interp, label->name);
if (r && (r->type & VTADDRESS) && r->first_ins)
- bb_add_edge(unit, from, unit->bb_list[r->first_ins->bbindex]);
+ bb_add_edge(interp, unit, from, unit->bb_list[r->first_ins->bbindex]);
else {
IMCC_debug(interp, DEBUG_CFG, "register branch %I ", from->end);
for (ins = from->end; ins; ins = ins->prev) {
if ((ins->type & ITBRANCH)
&& STREQ(ins->opname, "set_addr")
&& ins->symregs[1]->first_ins) {
- bb_add_edge(unit, from,
+ bb_add_edge(interp, unit, from,
unit-> bb_list[ins->symregs[1]->first_ins->bbindex]);
IMCC_debug(interp, DEBUG_CFG, "(%s) ", ins->symregs[1]->name);
break;
@@ -538,8 +548,8 @@ blocks_are_connected(ARGIN(const Basic_block *from),
/*
-=item C<static void bb_add_edge(IMC_Unit *unit, Basic_block *from, Basic_block
-*to)>
+=item C<static void bb_add_edge(PARROT_INTERP, IMC_Unit *unit, Basic_block
+*from, Basic_block *to)>
Adds an edge between the two given blocks.
@@ -548,8 +558,10 @@ Adds an edge between the two given blocks.
*/
static void
-bb_add_edge(ARGMOD(IMC_Unit *unit), ARGIN(Basic_block *from),
- ARGMOD(Basic_block *to))
+bb_add_edge(PARROT_INTERP,
+ ARGMOD(IMC_Unit *unit),
+ ARGIN(Basic_block *from),
+ ARGMOD(Basic_block *to))
{
ASSERT_ARGS(bb_add_edge)
Edge *e;
@@ -558,7 +570,7 @@ bb_add_edge(ARGMOD(IMC_Unit *unit), ARGIN(Basic_block *from),
/* we assume that the data is correct, and thus if the edge is not
* on the predecessors of 'from', it won't be on the successors of 'to' */
- e = mem_allocate_typed(Edge);
+ e = mem_gc_allocate_typed(interp, Edge);
e->succ_next = from->succ_list;
e->from = from;
@@ -708,13 +720,14 @@ life_analysis(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
IMCC_info(interp, 2, "life_analysis\n");
for (i = 0; i < unit->n_symbols; i++)
- analyse_life_symbol(unit, reglist[i]);
+ analyse_life_symbol(interp, unit, reglist[i]);
}
/*
-=item C<static void analyse_life_symbol(const IMC_Unit *unit, SymReg* r)>
+=item C<static void analyse_life_symbol(PARROT_INTERP, const IMC_Unit *unit,
+SymReg* r)>
Analyzes the lifetime for a given symbol.
@@ -723,7 +736,8 @@ Analyzes the lifetime for a given symbol.
*/
static void
-analyse_life_symbol(ARGIN(const IMC_Unit *unit), ARGMOD(SymReg* r))
+analyse_life_symbol(PARROT_INTERP,
+ ARGIN(const IMC_Unit *unit), ARGMOD(SymReg* r))
{
ASSERT_ARGS(analyse_life_symbol)
unsigned int i;
@@ -735,13 +749,13 @@ analyse_life_symbol(ARGIN(const IMC_Unit *unit), ARGMOD(SymReg* r))
if (r->life_info)
free_life_info(unit, r);
- r->life_info = mem_allocate_n_zeroed_typed(unit->n_basic_blocks,
+ r->life_info = mem_gc_allocate_n_zeroed_typed(interp, unit->n_basic_blocks,
Life_range *);
/* First we make a pass to each block to gather the information
* that can be obtained locally */
for (i = 0; i < unit->n_basic_blocks; i++) {
- analyse_life_block(unit->bb_list[i], r);
+ analyse_life_block(interp, unit->bb_list[i], r);
}
/* Now we need to consider the relations between blocks */
@@ -807,7 +821,8 @@ free_life_info(ARGIN(const IMC_Unit *unit), ARGMOD(SymReg *r))
/*
-=item C<static void analyse_life_block(const Basic_block* bb, SymReg *r)>
+=item C<static void analyse_life_block(PARROT_INTERP, const Basic_block* bb,
+SymReg *r)>
Studies the state of the var r in the block bb.
@@ -819,10 +834,10 @@ the block where the var is alive.
*/
static void
-analyse_life_block(ARGIN(const Basic_block* bb), ARGMOD(SymReg *r))
+analyse_life_block(PARROT_INTERP, ARGIN(const Basic_block* bb), ARGMOD(SymReg *r))
{
ASSERT_ARGS(analyse_life_block)
- Life_range * const l = make_life_range(r, bb->index);
+ Life_range * const l = make_life_range(interp, r, bb->index);
Instruction *special = NULL;
Instruction *ins;
@@ -985,19 +1000,19 @@ compute_dominators(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
const unsigned int n = unit->n_basic_blocks;
IMCC_info(interp, 2, "compute_dominators\n");
- unit->idoms = mem_allocate_n_zeroed_typed(n, int);
- dominators = mem_allocate_n_zeroed_typed(n, Set *);
+ unit->idoms = mem_gc_allocate_n_zeroed_typed(interp, n, int);
+ dominators = mem_gc_allocate_n_zeroed_typed(interp, n, Set *);
unit->dominators = dominators;
- dominators[0] = set_make(n);
+ dominators[0] = set_make(interp, n);
set_add(dominators[0], 0);
for (i = n - 1; i; --i) {
if (unit->bb_list[i]->pred_list) {
- dominators[i] = set_make_full(n);
+ dominators[i] = set_make_full(interp, n);
}
else {
- dominators[i] = set_make(n);
+ dominators[i] = set_make(interp, n);
set_add(dominators[i], i);
}
}
@@ -1034,7 +1049,7 @@ compute_dominators(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
/* TODO: This 'for' should be a breadth-first search for speed */
for (i = 1; i < n; i++) {
- Set * const s = set_copy(dominators[i]);
+ Set * const s = set_copy(interp, dominators[i]);
Edge *edge;
for (edge = unit->bb_list[i]->pred_list;
@@ -1113,12 +1128,12 @@ compute_dominance_frontiers(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
const int n = unit->n_basic_blocks;
Set ** const dominance_frontiers = unit->dominance_frontiers =
- mem_allocate_n_typed(n, Set *);
+ mem_gc_allocate_n_typed(interp, n, Set *);
IMCC_info(interp, 2, "compute_dominance_frontiers\n");
for (i = 0; i < n; i++) {
- dominance_frontiers[i] = set_make(n);
+ dominance_frontiers[i] = set_make(interp, n);
}
/* for all nodes, b */
@@ -1416,7 +1431,7 @@ mark_loop(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const Edge *e))
"\tcan't determine loop entry block (%d found)\n" , i);
}
- loop = set_make(unit->n_basic_blocks);
+ loop = set_make(interp, unit->n_basic_blocks);
set_add(loop, footer->index);
set_add(loop, header->index);
@@ -1427,7 +1442,7 @@ mark_loop(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const Edge *e))
search_predecessors_not_in(footer, loop);
}
- exits = set_make(unit->n_basic_blocks);
+ exits = set_make(interp, unit->n_basic_blocks);
for (i = 1; i < unit->n_basic_blocks; i++) {
if (set_contains(loop, i)) {
@@ -1443,9 +1458,10 @@ mark_loop(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const Edge *e))
/* now 'loop' contains the set of nodes inside the loop. */
n_loops = unit->n_loops;
- loop_info = mem_realloc_n_typed(unit->loop_info,
- n_loops + 1, Loop_info *);
- loop_info[n_loops] = mem_allocate_typed(Loop_info);
+ loop_info = mem_gc_realloc_n_typed(interp,
+ unit->loop_info,
+ n_loops + 1, Loop_info *);
+ loop_info[n_loops] = mem_gc_allocate_typed(interp, Loop_info);
loop_info[n_loops]->loop = loop;
loop_info[n_loops]->exits = exits;
loop_info[n_loops]->depth = footer->loop_depth;
@@ -1453,6 +1469,8 @@ mark_loop(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const Edge *e))
loop_info[n_loops]->header = header->index;
loop_info[n_loops]->preheader = natural_preheader(unit, loop_info[n_loops]);
+ unit->loop_info = loop_info;
+
unit->n_loops++;
}
@@ -1518,7 +1536,7 @@ search_predecessors_not_in(ARGIN(const Basic_block *node), ARGMOD(Set *s))
/*
-=item C<static void init_basic_blocks(IMC_Unit *unit)>
+=item C<static void init_basic_blocks(PARROT_INTERP, IMC_Unit *unit)>
Initializes the basic blocks memory for this unit.
@@ -1527,7 +1545,7 @@ Initializes the basic blocks memory for this unit.
*/
static void
-init_basic_blocks(ARGMOD(IMC_Unit *unit))
+init_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
{
ASSERT_ARGS(init_basic_blocks)
@@ -1537,8 +1555,8 @@ init_basic_blocks(ARGMOD(IMC_Unit *unit))
unit->n_basic_blocks = 0;
unit->edge_list = NULL;
unit->bb_list_size = 256;
- unit->bb_list = mem_allocate_n_zeroed_typed(unit->bb_list_size,
- Basic_block *);
+ unit->bb_list = mem_gc_allocate_n_zeroed_typed(interp,
+ unit->bb_list_size, Basic_block *);
}
@@ -1576,7 +1594,8 @@ clear_basic_blocks(ARGMOD(IMC_Unit *unit))
/*
-=item C<static Basic_block* make_basic_block(IMC_Unit *unit, Instruction *ins)>
+=item C<static Basic_block* make_basic_block(PARROT_INTERP, IMC_Unit *unit,
+Instruction *ins)>
Creates, initializes, and returns a new Basic_block.
@@ -1587,10 +1606,10 @@ Creates, initializes, and returns a new Basic_block.
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static Basic_block*
-make_basic_block(ARGMOD(IMC_Unit *unit), ARGMOD(Instruction *ins))
+make_basic_block(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGMOD(Instruction *ins))
{
ASSERT_ARGS(make_basic_block)
- Basic_block * const bb = mem_allocate_typed(Basic_block);
+ Basic_block * const bb = mem_gc_allocate_typed(interp, Basic_block);
int n = unit->n_basic_blocks;
bb->start = ins;
@@ -1605,7 +1624,8 @@ make_basic_block(ARGMOD(IMC_Unit *unit), ARGMOD(Instruction *ins))
if (n == unit->bb_list_size) {
unit->bb_list_size *= 2;
- mem_realloc_n_typed(unit->bb_list, unit->bb_list_size, Basic_block *);
+ unit->bb_list = mem_gc_realloc_n_typed(interp, unit->bb_list,
+ unit->bb_list_size, Basic_block *);
}
unit->bb_list[n] = bb;
@@ -1617,7 +1637,7 @@ make_basic_block(ARGMOD(IMC_Unit *unit), ARGMOD(Instruction *ins))
/*
-=item C<Life_range * make_life_range(SymReg *r, int idx)>
+=item C<Life_range * make_life_range(PARROT_INTERP, SymReg *r, int idx)>
Creates and returns a Life_range for the given register at the specified index.
@@ -1628,10 +1648,10 @@ Creates and returns a Life_range for the given register at the specified index.
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Life_range *
-make_life_range(ARGMOD(SymReg *r), int idx)
+make_life_range(PARROT_INTERP, ARGMOD(SymReg *r), int idx)
{
ASSERT_ARGS(make_life_range)
- Life_range * const l = mem_allocate_zeroed_typed(Life_range);
+ Life_range * const l = mem_gc_allocate_zeroed_typed(interp, Life_range);
r->life_info[idx] = l;
return l;
View
6 compilers/imcc/cfg.h
@@ -100,8 +100,9 @@ void life_analysis(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Life_range * make_life_range(ARGMOD(SymReg *r), int idx)
+Life_range * make_life_range(PARROT_INTERP, ARGMOD(SymReg *r), int idx)
__attribute__nonnull__(1)
+ __attribute__nonnull__(2)
FUNC_MODIFIES(*r);
PARROT_WARN_UNUSED_RESULT
@@ -147,7 +148,8 @@ void search_predecessors_not_in(
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_make_life_range __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(r))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_natural_preheader __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(loop_info))
View
18 compilers/imcc/imc.c
@@ -39,12 +39,14 @@ static void imc_free_unit(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
PARROT_CANNOT_RETURN_NULL
PARROT_MALLOC
-static IMC_Unit * imc_new_unit(IMC_Unit_Type t);
+static IMC_Unit * imc_new_unit(PARROT_INTERP, IMC_Unit_Type t)
+ __attribute__nonnull__(1);
#define ASSERT_ARGS_imc_free_unit __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit))
-#define ASSERT_ARGS_imc_new_unit __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_imc_new_unit __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -153,7 +155,7 @@ imc_cleanup(PARROT_INTERP, ARGIN_NULLOK(void *yyscanner))
/*
-=item C<static IMC_Unit * imc_new_unit(IMC_Unit_Type t)>
+=item C<static IMC_Unit * imc_new_unit(PARROT_INTERP, IMC_Unit_Type t)>
Creates a new IMC_Unit of the given IMC_Unit_Type C<t>.
@@ -164,11 +166,11 @@ Creates a new IMC_Unit of the given IMC_Unit_Type C<t>.
PARROT_CANNOT_RETURN_NULL
PARROT_MALLOC
static IMC_Unit *
-imc_new_unit(IMC_Unit_Type t)
+imc_new_unit(PARROT_INTERP, IMC_Unit_Type t)
{
ASSERT_ARGS(imc_new_unit)
- IMC_Unit * const unit = mem_allocate_zeroed_typed(IMC_Unit);
- create_symhash(&unit->hash);
+ IMC_Unit * const unit = mem_gc_allocate_zeroed_typed(interp, IMC_Unit);
+ create_symhash(interp, &unit->hash);
unit->type = t;
return unit;
}
@@ -191,14 +193,14 @@ IMC_Unit *
imc_open_unit(PARROT_INTERP, IMC_Unit_Type t)
{
ASSERT_ARGS(imc_open_unit)
- IMC_Unit * const unit = imc_new_unit(t);
+ IMC_Unit * const unit = imc_new_unit(interp, t);
imc_info_t * const imc_info = IMCC_INFO(interp);
if (!imc_info->imc_units)
imc_info->imc_units = unit;
if (!imc_info->ghash.data)
- create_symhash(&imc_info->ghash);
+ create_symhash(interp, &imc_info->ghash);
unit->prev = imc_info->last_unit;
View
4 compilers/imcc/imcc.l
@@ -787,7 +787,7 @@ int yywrap(void* yyscanner) {
static macro_frame_t *
new_frame(PARROT_INTERP) {
static int label = 0;
- macro_frame_t * const tmp = mem_allocate_zeroed_typed(macro_frame_t);
+ macro_frame_t * const tmp = mem_gc_allocate_zeroed_typed(interp, macro_frame_t);
tmp->label = ++label;
tmp->s.line = IMCC_INFO(interp)->line;
@@ -1107,7 +1107,7 @@ define_macro(PARROT_INTERP, ARGIN(const char *name), ARGIN(const params_t *param
m->expansion = NULL;
}
else {
- m = mem_allocate_zeroed_typed(macro_t);
+ m = mem_gc_allocate_zeroed_typed(interp, macro_t);
if (!IMCC_INFO(interp)->macros)
IMCC_INFO(interp)->macros = parrot_new_cstring_hash(interp);
View
156 compilers/imcc/imcc.y
@@ -43,57 +43,62 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void add_pcc_named_arg(
+static void add_pcc_named_arg(PARROT_INTERP,
ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
+ __attribute__nonnull__(4)
FUNC_MODIFIES(*cur_call)
FUNC_MODIFIES(*name)
FUNC_MODIFIES(*value);
-static void add_pcc_named_arg_var(
+static void add_pcc_named_arg_var(PARROT_INTERP,
ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
+ __attribute__nonnull__(4)
FUNC_MODIFIES(*cur_call)
FUNC_MODIFIES(*name)
FUNC_MODIFIES(*value);
-static void add_pcc_named_param(
+static void add_pcc_named_param(PARROT_INTERP,
ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
+ __attribute__nonnull__(4)
FUNC_MODIFIES(*cur_call)
FUNC_MODIFIES(*name)
FUNC_MODIFIES(*value);
-static void add_pcc_named_result(
+static void add_pcc_named_result(PARROT_INTERP,
ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
+ __attribute__nonnull__(4)
FUNC_MODIFIES(*cur_call)
FUNC_MODIFIES(*name)
FUNC_MODIFIES(*value);
-static void add_pcc_named_return(
+static void add_pcc_named_return(PARROT_INTERP,
ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
+ __attribute__nonnull__(4)
FUNC_MODIFIES(*cur_call)
FUNC_MODIFIES(*name)
FUNC_MODIFIES(*value);
@@ -251,23 +256,28 @@ static void set_lexical(PARROT_INTERP,
FUNC_MODIFIES(*name);
#define ASSERT_ARGS_add_pcc_named_arg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(cur_call) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(cur_call) \
, PARROT_ASSERT_ARG(name) \
, PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_add_pcc_named_arg_var __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(cur_call) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(cur_call) \
, PARROT_ASSERT_ARG(name) \
, PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_add_pcc_named_param __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(cur_call) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(cur_call) \
, PARROT_ASSERT_ARG(name) \
, PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_add_pcc_named_result __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(cur_call) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(cur_call) \
, PARROT_ASSERT_ARG(name) \
, PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_add_pcc_named_return __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(cur_call) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(cur_call) \
, PARROT_ASSERT_ARG(name) \
, PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_adv_named_set __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -648,7 +658,7 @@ iSUBROUTINE(PARROT_INTERP, ARGMOD_NULLOK(IMC_Unit *unit), ARGMOD(SymReg *r))
Instruction * const i = iLABEL(interp, unit, r);
r->type = (r->type & VT_ENCODED) ? VT_PCC_SUB|VT_ENCODED : VT_PCC_SUB;
- r->pcc_sub = mem_allocate_zeroed_typed(pcc_sub_t);
+ r->pcc_sub = mem_gc_allocate_zeroed_typed(interp, pcc_sub_t);
IMCC_INFO(interp)->cur_call = r;
i->line = IMCC_INFO(interp)->line;
@@ -899,105 +909,111 @@ set_lexical(PARROT_INTERP, ARGMOD(SymReg *r), ARGMOD(SymReg *name))
/*
-=item C<static void add_pcc_named_arg(SymReg *cur_call, SymReg *name, SymReg
-*value)>
+=item C<static void add_pcc_named_arg(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
=cut
*/
static void
-add_pcc_named_arg(ARGMOD(SymReg *cur_call),
+add_pcc_named_arg(PARROT_INTERP,
+ ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
{
ASSERT_ARGS(add_pcc_named_arg)
name->type |= VT_NAMED;
- add_pcc_arg(cur_call, name);
- add_pcc_arg(cur_call, value);
+ add_pcc_arg(interp, cur_call, name);
+ add_pcc_arg(interp, cur_call, value);
}
/*
-=item C<static void add_pcc_named_arg_var(SymReg *cur_call, SymReg *name, SymReg
-*value)>
+=item C<static void add_pcc_named_arg_var(PARROT_INTERP, SymReg *cur_call,
+SymReg *name, SymReg *value)>
=cut
*/
static void
-add_pcc_named_arg_var(ARGMOD(SymReg *cur_call),
- ARGMOD(SymReg *name), ARGMOD(SymReg *value))
+add_pcc_named_arg_var(PARROT_INTERP,
+ ARGMOD(SymReg *cur_call),
+ ARGMOD(SymReg *name),
+ ARGMOD(SymReg *value))
{
ASSERT_ARGS(add_pcc_named_arg_var)
name->type |= VT_NAMED;
- add_pcc_arg(cur_call, name);
- add_pcc_arg(cur_call, value);
+ add_pcc_arg(interp, cur_call, name);
+ add_pcc_arg(interp, cur_call, value);
}
/*
-=item C<static void add_pcc_named_result(SymReg *cur_call, SymReg *name, SymReg
-*value)>
+=item C<static void add_pcc_named_result(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
=cut
*/
static void
-add_pcc_named_result(ARGMOD(SymReg *cur_call),
+add_pcc_named_result(PARROT_INTERP,
+ ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
{
ASSERT_ARGS(add_pcc_named_result)
name->type |= VT_NAMED;
- add_pcc_result(cur_call, name);
- add_pcc_result(cur_call, value);
+ add_pcc_result(interp, cur_call, name);
+ add_pcc_result(interp, cur_call, value);
}
/*
-=item C<static void add_pcc_named_param(SymReg *cur_call, SymReg *name, SymReg
-*value)>
+=item C<static void add_pcc_named_param(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
=cut
*/
static void
-add_pcc_named_param(ARGMOD(SymReg *cur_call),
+add_pcc_named_param(PARROT_INTERP,
+ ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
{
ASSERT_ARGS(add_pcc_named_param)
name->type |= VT_NAMED;
- add_pcc_arg(cur_call, name);
- add_pcc_arg(cur_call, value);
+ add_pcc_arg(interp, cur_call, name);
+ add_pcc_arg(interp, cur_call, value);
}
/*
-=item C<static void add_pcc_named_return(SymReg *cur_call, SymReg *name, SymReg
-*value)>
+=item C<static void add_pcc_named_return(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
=cut
*/
static void
-add_pcc_named_return(ARGMOD(SymReg *cur_call),
+add_pcc_named_return(PARROT_INTERP,
+ ARGMOD(SymReg *cur_call),
ARGMOD(SymReg *name),
ARGMOD(SymReg *value))
{
ASSERT_ARGS(add_pcc_named_return)
name->type |= VT_NAMED;
- add_pcc_result(cur_call, name);
- add_pcc_result(cur_call, value);
+ add_pcc_result(interp, cur_call, name);
+ add_pcc_result(interp, cur_call, value);
}
/*
@@ -1387,12 +1403,12 @@ sub_params:
| sub_params sub_param '\n'
{
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_param(IMCC_INFO(interp)->cur_call,
+ add_pcc_named_param(interp, IMCC_INFO(interp)->cur_call,
IMCC_INFO(interp)->adv_named_id, $2);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_arg(IMCC_INFO(interp)->cur_call, $2);
+ add_pcc_arg(interp, IMCC_INFO(interp)->cur_call, $2);
}
;
@@ -1516,17 +1532,17 @@ subid:
multi_types:
/* empty */
{
- add_pcc_multi(IMCC_INFO(interp)->cur_call, NULL);
+ add_pcc_multi(interp, IMCC_INFO(interp)->cur_call, NULL);
}
| multi_types COMMA multi_type
{
$$ = 0;
- add_pcc_multi(IMCC_INFO(interp)->cur_call, $3);
+ add_pcc_multi(interp, IMCC_INFO(interp)->cur_call, $3);
}
| multi_type
{
$$ = 0;
- add_pcc_multi(IMCC_INFO(interp)->cur_call, $1);
+ add_pcc_multi(interp, IMCC_INFO(interp)->cur_call, $1);
}
;
@@ -1673,7 +1689,7 @@ pcc_call:
pcc_args:
/* empty */ { $$ = 0; }
- | pcc_args pcc_arg '\n' { add_pcc_arg(IMCC_INFO(interp)->cur_call, $2); }
+ | pcc_args pcc_arg '\n' { add_pcc_arg(interp, IMCC_INFO(interp)->cur_call, $2); }
;
pcc_arg:
@@ -1686,7 +1702,7 @@ pcc_results:
| pcc_results pcc_result '\n'
{
if ($2)
- add_pcc_result(IMCC_INFO(interp)->cur_call, $2);
+ add_pcc_result(interp, IMCC_INFO(interp)->cur_call, $2);
}
;
@@ -1745,12 +1761,12 @@ pcc_returns:
| pcc_returns '\n'
{
if ($1)
- add_pcc_result(IMCC_INFO(interp)->sr_return, $1);
+ add_pcc_result(interp, IMCC_INFO(interp)->sr_return, $1);
}
| pcc_returns pcc_return '\n'
{
if ($2)
- add_pcc_result(IMCC_INFO(interp)->sr_return, $2);
+ add_pcc_result(interp, IMCC_INFO(interp)->sr_return, $2);
}
;
@@ -1759,12 +1775,12 @@ pcc_yields:
| pcc_yields '\n'
{
if ($1)
- add_pcc_result(IMCC_INFO(interp)->sr_return, $1);
+ add_pcc_result(interp, IMCC_INFO(interp)->sr_return, $1);
}
| pcc_yields pcc_set_yield '\n'
{
if ($2)
- add_pcc_result(IMCC_INFO(interp)->sr_return, $2);
+ add_pcc_result(interp, IMCC_INFO(interp)->sr_return, $2);
}
;
@@ -1799,32 +1815,32 @@ var_returns:
| arg
{
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_return(IMCC_INFO(interp)->sr_return,
+ add_pcc_named_return(interp, IMCC_INFO(interp)->sr_return,
IMCC_INFO(interp)->adv_named_id, $1);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_result(IMCC_INFO(interp)->sr_return, $1);
+ add_pcc_result(interp, IMCC_INFO(interp)->sr_return, $1);
}
| STRINGC ADV_ARROW var
{
SymReg * const name = mk_const(interp, $1, 'S');
- add_pcc_named_return(IMCC_INFO(interp)->sr_return, name, $3);
+ add_pcc_named_return(interp, IMCC_INFO(interp)->sr_return, name, $3);
}
| var_returns COMMA arg
{
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_return(IMCC_INFO(interp)->sr_return,
+ add_pcc_named_return(interp, IMCC_INFO(interp)->sr_return,
IMCC_INFO(interp)->adv_named_id, $3);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_result(IMCC_INFO(interp)->sr_return, $3);
+ add_pcc_result(interp, IMCC_INFO(interp)->sr_return, $3);
}
| var_returns COMMA STRINGC ADV_ARROW var
{
SymReg * const name = mk_const(interp, $3, 'S');
- add_pcc_named_return(IMCC_INFO(interp)->sr_return, name, $5);
+ add_pcc_named_return(interp, IMCC_INFO(interp)->sr_return, name, $5);
}
;
@@ -1908,7 +1924,7 @@ id_list :
id_list_id :
IDENTIFIER opt_unique_reg
{
- IdList* const l = mem_allocate_n_zeroed_typed(1, IdList);
+ IdList* const l = mem_gc_allocate_n_zeroed_typed(interp, 1, IdList);
l->id = $1;
l->unique_reg = $2;
$$ = l;
@@ -2053,7 +2069,7 @@ assignment:
/* Subroutine call the short way */
| target '=' sub_call
{
- add_pcc_result($3->symregs[0], $1);
+ add_pcc_result(interp, $3->symregs[0], $1);
IMCC_INFO(interp)->cur_call = NULL;
$$ = 0;
}
@@ -2209,38 +2225,38 @@ arglist:
{
$$ = 0;
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_arg(IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $3);
+ add_pcc_named_arg(interp, IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $3);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_arg(IMCC_INFO(interp)->cur_call, $3);
+ add_pcc_arg(interp, IMCC_INFO(interp)->cur_call, $3);
}
| arg
{
$$ = 0;
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_arg(IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $1);
+ add_pcc_named_arg(interp, IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $1);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_arg(IMCC_INFO(interp)->cur_call, $1);
+ add_pcc_arg(interp, IMCC_INFO(interp)->cur_call, $1);
}
| arglist COMMA STRINGC ADV_ARROW var
{
$$ = 0;
- add_pcc_named_arg(IMCC_INFO(interp)->cur_call,
+ add_pcc_named_arg(interp, IMCC_INFO(interp)->cur_call,
mk_const(interp, $3, 'S'), $5);
mem_sys_free($3);
}
| var ADV_ARROW var
{
$$ = 0;
- add_pcc_named_arg_var(IMCC_INFO(interp)->cur_call, $1, $3);
+ add_pcc_named_arg_var(interp, IMCC_INFO(interp)->cur_call, $1, $3);
}
| STRINGC ADV_ARROW var
{
$$ = 0;
- add_pcc_named_arg(IMCC_INFO(interp)->cur_call,
+ add_pcc_named_arg(interp, IMCC_INFO(interp)->cur_call,
mk_const(interp, $1, 'S'), $3);
mem_sys_free($1);
}
@@ -2274,31 +2290,31 @@ targetlist:
{
$$ = 0;
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_result(IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $3);
+ add_pcc_named_result(interp, IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $3);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_result(IMCC_INFO(interp)->cur_call, $3);
+ add_pcc_result(interp, IMCC_INFO(interp)->cur_call, $3);
}
| targetlist COMMA STRINGC ADV_ARROW target
{
- add_pcc_named_result(IMCC_INFO(interp)->cur_call,
- mk_const(interp, $3, 'S'), $5);
+ add_pcc_named_result(interp, IMCC_INFO(interp)->cur_call,
+ mk_const(interp, $3, 'S'), $5);
mem_sys_free($3);
}
| result
{
$$ = 0;
if (IMCC_INFO(interp)->adv_named_id) {
- add_pcc_named_result(IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $1);
+ add_pcc_named_result(interp, IMCC_INFO(interp)->cur_call, IMCC_INFO(interp)->adv_named_id, $1);
IMCC_INFO(interp)->adv_named_id = NULL;
}
else
- add_pcc_result(IMCC_INFO(interp)->cur_call, $1);
+ add_pcc_result(interp, IMCC_INFO(interp)->cur_call, $1);
}
| STRINGC ADV_ARROW target
{
- add_pcc_named_result(IMCC_INFO(interp)->cur_call, mk_const(interp, $1, 'S'), $3);
+ add_pcc_named_result(interp, IMCC_INFO(interp)->cur_call, mk_const(interp, $1, 'S'), $3);
mem_sys_free($1);
}
| /* empty */ { $$ = 0; }
View
4 compilers/imcc/imclexer.c
@@ -5209,7 +5209,7 @@ int yywrap(void* yyscanner) {
static macro_frame_t *
new_frame(PARROT_INTERP) {
static int label = 0;
- macro_frame_t * const tmp = mem_allocate_zeroed_typed(macro_frame_t);
+ macro_frame_t * const tmp = mem_gc_allocate_zeroed_typed(interp, macro_frame_t);
tmp->label = ++label;
tmp->s.line = IMCC_INFO(interp)->line;
@@ -5529,7 +5529,7 @@ define_macro(PARROT_INTERP, ARGIN(const char *name), ARGIN(const params_t *param
m->expansion = NULL;
}
else {
- m = mem_allocate_zeroed_typed(macro_t);
+ m = mem_gc_allocate_zeroed_typed(interp, macro_t);
if (!IMCC_INFO(interp)->macros)
IMCC_INFO(interp)->macros = parrot_new_cstring_hash(interp);
View
2,473 compilers/imcc/imcparser.c
943 additions, 1,530 deletions not shown
View
44 compilers/imcc/imcparser.h
@@ -9,26 +9,27 @@
*/
/* HEADERIZER HFILE: none */
/* HEADERIZER STOP */
-
-/* A Bison parser, made by GNU Bison 2.4.1. */
+/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
+
+ This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -39,11 +40,10 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
-
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -297,27 +297,21 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
+#line 1075 "compilers/imcc/imcc.y"
{
-
-/* Line 1676 of yacc.c */
-#line 1059 "compilers/imcc/imcc.y"
-
IdList * idlist;
int t;
char * s;
SymReg * sr;
Instruction *i;
-
-
-
-/* Line 1676 of yacc.c */
-#line 304 "compilers/imcc/imcparser.h"
-} YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
+}
+/* Line 1489 of yacc.c. */
+#line 299 "compilers/imcc/imcparser.h"
+ YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
#endif
-
View
2  compilers/imcc/instructions.c
@@ -149,7 +149,7 @@ imcc_init_tables(PARROT_INTERP)
if (!w_special[0]) {
size_t i;
for (i = 0; i < N_ELEMENTS(writes); i++) {
- const int n = interp->op_lib->op_code(writes[i], 1);
+ const int n = interp->op_lib->op_code(interp, writes[i], 1);
PARROT_ASSERT(n);
w_special[i] = n;
}
View
2  compilers/imcc/optimizer.c
@@ -802,7 +802,7 @@ eval_ins(PARROT_INTERP, ARGIN(const char *op), size_t ops, ARGIN(SymReg **r))
int i;
op_info_t *op_info;
- opnum = interp->op_lib->op_code(op, 1);
+ opnum = interp->op_lib->op_code(interp, op, 1);
if (opnum < 0)
IMCC_fatal(interp, 1, "eval_ins: op '%s' not found\n", op);
op_info = interp->op_info_table + opnum;
View
20 compilers/imcc/parser_util.c
@@ -285,7 +285,7 @@ check_op(PARROT_INTERP, ARGOUT(char *fullname), ARGIN(const char *name),
ASSERT_ARGS(check_op)
op_fullname(fullname, name, r, narg, keyvec);
- return interp->op_lib->op_code(fullname, 1);
+ return interp->op_lib->op_code(interp, fullname, 1);
}
/*
@@ -303,8 +303,8 @@ int
is_op(PARROT_INTERP, ARGIN(const char *name))
{
ASSERT_ARGS(is_op)
- return interp->op_lib->op_code(name, 0) >= 0
- || interp->op_lib->op_code(name, 1) >= 0;
+ return interp->op_lib->op_code(interp, name, 0) >= 0
+ || interp->op_lib->op_code(interp, name, 1) >= 0;
}
/*
@@ -341,7 +341,7 @@ var_arg_ins(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const char *name),
r[0]->pmc_type = enum_class_FixedIntegerArray;
op_fullname(fullname, name, r, 1, 0);
- op = interp->op_lib->op_code(fullname, 1);
+ op = interp->op_lib->op_code(interp, fullname, 1);
PARROT_ASSERT(op >= 0);
@@ -404,11 +404,11 @@ INS(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const char *name),
return var_arg_ins(interp, unit, name, r, n, emit);
op_fullname(fullname, name, r, n, keyvec);
- op = interp->op_lib->op_code(fullname, 1);
+ op = interp->op_lib->op_code(interp, fullname, 1);
/* maybe we have a fullname */
if (op < 0)
- op = interp->op_lib->op_code(name, 1);
+ op = interp->op_lib->op_code(interp, name, 1);
/* still wrong, try reverse compare */
if (op < 0) {
@@ -416,7 +416,7 @@ INS(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const char *name),
if (n_name) {
name = n_name;
op_fullname(fullname, name, r, n, keyvec);
- op = interp->op_lib->op_code(fullname, 1);
+ op = interp->op_lib->op_code(interp, fullname, 1);
}
}
@@ -638,7 +638,7 @@ imcc_compile(PARROT_INTERP, ARGIN(const char *s), int pasm_file,
if (IMCC_INFO(interp)->last_unit) {
/* a reentrant compile */
- imc_info = mem_allocate_zeroed_typed(imc_info_t);
+ imc_info = mem_gc_allocate_zeroed_typed(interp, imc_info_t);
imc_info->ghash = IMCC_INFO(interp)->ghash;
imc_info->prev = IMCC_INFO(interp);
IMCC_INFO(interp) = imc_info;
@@ -907,7 +907,7 @@ imcc_compile_file(PARROT_INTERP, ARGIN(const char *fullname),
if (IMCC_INFO(interp)->last_unit) {
/* a reentrant compile */
- imc_info = mem_allocate_zeroed_typed(imc_info_t);
+ imc_info = mem_gc_allocate_zeroed_typed(interp, imc_info_t);
imc_info->prev = IMCC_INFO(interp);
imc_info->ghash = IMCC_INFO(interp)->ghash;
IMCC_INFO(interp) = imc_info;
@@ -1193,7 +1193,7 @@ try_find_op(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(const char *name),
if (changed) {
op_fullname(fullname, name, r, n, keyvec);
- return interp->op_lib->op_code(fullname, 1);
+ return interp->op_lib->op_code(interp, fullname, 1);
}
return -1;
View
22 compilers/imcc/pbc.c
@@ -357,11 +357,11 @@ add_const_table(PARROT_INTERP)
/* Update the constant count and reallocate */
if (interp->code->const_table->constants)
interp->code->const_table->constants =
- mem_realloc_n_typed(interp->code->const_table->constants,
+ mem_gc_realloc_n_typed(interp, interp->code->const_table->constants,
newcount, PackFile_Constant *);
else
interp->code->const_table->constants =
- mem_allocate_n_typed(newcount, PackFile_Constant *);
+ mem_gc_allocate_n_typed(interp, newcount, PackFile_Constant *);
interp->code->const_table->constants[oldcount] = new_constant;
interp->code->const_table->const_count = newcount;
@@ -432,10 +432,10 @@ int
e_pbc_open(PARROT_INTERP, SHIM(void *param))
{
ASSERT_ARGS(e_pbc_open)
- code_segment_t * const cs = mem_allocate_zeroed_typed(code_segment_t);
+ code_segment_t * const cs = mem_gc_allocate_zeroed_typed(interp, code_segment_t);
if (!IMCC_INFO(interp)->globals)
- IMCC_INFO(interp)->globals = mem_allocate_zeroed_typed(imcc_globals);
+ IMCC_INFO(interp)->globals = mem_gc_allocate_zeroed_typed(interp, imcc_globals);
if (IMCC_INFO(interp)->globals->cs)
clear_sym_hash(&IMCC_INFO(interp)->globals->cs->key_consts);
@@ -445,7 +445,7 @@ e_pbc_open(PARROT_INTERP, SHIM(void *param))
}
/* free previous cached key constants if any */
- create_symhash(&cs->key_consts);
+ create_symhash(interp, &cs->key_consts);
cs->next = NULL;
cs->prev = IMCC_INFO(interp)->globals->cs;
@@ -496,7 +496,7 @@ static void
make_new_sub(PARROT_INTERP, ARGIN(IMC_Unit *unit))
{
ASSERT_ARGS(make_new_sub)
- subs_t * const s = mem_allocate_zeroed_typed(subs_t);
+ subs_t * const s = mem_gc_allocate_zeroed_typed(interp, subs_t);
s->prev = IMCC_INFO(interp)->globals->cs->subs;
s->unit = unit;
@@ -510,7 +510,7 @@ make_new_sub(PARROT_INTERP, ARGIN(IMC_Unit *unit))
IMCC_INFO(interp)->globals->cs->subs = s;
- create_symhash(&s->fixup);
+ create_symhash(interp, &s->fixup);
}
@@ -615,7 +615,7 @@ store_key_const(PARROT_INTERP, ARGIN(const char *str), int idx)
{
ASSERT_ARGS(store_key_const)
SymReg * const c =
- _mk_const(&IMCC_INFO(interp)->globals->cs->key_consts, str, 0);
+ _mk_const(interp, &IMCC_INFO(interp)->globals->cs->key_consts, str, 0);
c->color = idx;
}
@@ -826,7 +826,7 @@ fixup_globals(PARROT_INTERP)
SymReg * const nam = mk_const(interp, fixup->name,
fixup->type & VT_ENCODED ? 'U' : 'S');
- const int op = interp->op_lib->op_code("find_sub_not_null_p_sc", 1);
+ const int op = interp->op_lib->op_code(interp, "find_sub_not_null_p_sc", 1);
PARROT_ASSERT(op);
interp->code->base.data[addr] = op;
@@ -1478,7 +1478,7 @@ add_const_key(PARROT_INTERP, ARGIN(const opcode_t *key), int size, ARGIN(const c
if (r)
return r->color;
- pfc = mem_allocate_typed(PackFile_Constant);
+ pfc = mem_gc_allocate_typed(interp, PackFile_Constant);
rc = PackFile_Constant_unpack_key(interp,
interp->code->const_table, pfc, key);
@@ -2188,7 +2188,7 @@ e_pbc_emit(PARROT_INTERP, SHIM(void *param), ARGIN(const IMC_Unit *unit),
/* need a dummy to hold register usage */
SymReg * const r = mk_sub_label(interp, "(null)");
r->type = VT_PCC_SUB;
- r->pcc_sub = mem_allocate_zeroed_typed(pcc_sub_t);
+ r->pcc_sub = mem_gc_allocate_zeroed_typed(interp, pcc_sub_t);
add_const_pmc_sub(interp, r, oldsize, oldsize + code_size);
}
View
34 compilers/imcc/pcc.c
@@ -108,9 +108,12 @@ static int recursive_tail_call(PARROT_INTERP,
__attribute__nonnull__(3)
__attribute__nonnull__(4);
-static void unshift_self(ARGIN(SymReg *sub), ARGIN(SymReg *obj))
+static void unshift_self(PARROT_INTERP,
+ ARGIN(SymReg *sub),
+ ARGIN(SymReg *obj))
__attribute__nonnull__(1)
- __attribute__nonnull__(2);
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
#define ASSERT_ARGS_insert_tail_call __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -143,7 +146,8 @@ static void unshift_self(ARGIN(SymReg *sub), ARGIN(SymReg *obj))
, PARROT_ASSERT_ARG(ins) \
, PARROT_ASSERT_ARG(sub))
#define ASSERT_ARGS_unshift_self __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(sub) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(sub) \
, PARROT_ASSERT_ARG(obj))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -267,15 +271,15 @@ pcc_get_args(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(Instruction *ins),
SymReg *regcache[PCC_GET_ARGS_LIMIT + 1];
char bufcache[sizeof (pref) + sizeof (item) * PCC_GET_ARGS_LIMIT + sizeof (subf)];
- SymReg ** const regs = n < PCC_GET_ARGS_LIMIT ?
- regcache :
- mem_allocate_n_zeroed_typed(n + 1, SymReg *);
+ SymReg ** const regs = n < PCC_GET_ARGS_LIMIT
+ ? regcache
+ : mem_gc_allocate_n_zeroed_typed(interp, n + 1, SymReg *);
unsigned int bufpos = 0;
unsigned int bufsize = lenpref + lenitem * n + lensubf;
- char *buf = n < PCC_GET_ARGS_LIMIT ?
- bufcache :
- mem_allocate_n_typed(bufsize, char);
+ char *buf = n < PCC_GET_ARGS_LIMIT
+ ? bufcache
+ : mem_gc_allocate_n_typed(interp, bufsize, char);
memcpy(buf, pref, lenpref);
bufpos += lenpref;
@@ -362,7 +366,7 @@ pcc_get_args(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(Instruction *ins),
/*
-=item C<static void unshift_self(SymReg *sub, SymReg *obj)>
+=item C<static void unshift_self(PARROT_INTERP, SymReg *sub, SymReg *obj)>
prepend the object to args or self to params
@@ -371,15 +375,15 @@ prepend the object to args or self to params
*/
static void
-unshift_self(ARGIN(SymReg *sub), ARGIN(SymReg *obj))
+unshift_self(PARROT_INTERP, ARGIN(SymReg *sub), ARGIN(SymReg *obj))
{
ASSERT_ARGS(unshift_self)
struct pcc_sub_t * const pcc_sub = sub->pcc_sub;
const int n = pcc_sub->nargs;
int i;
- mem_realloc_n_typed(pcc_sub->args, n + 1, SymReg *);
- mem_realloc_n_typed(pcc_sub->arg_flags, n + 1, int);
+ pcc_sub->args = mem_gc_realloc_n_typed(interp, pcc_sub->args, n + 1, SymReg *);
+ pcc_sub->arg_flags = mem_gc_realloc_n_typed(interp, pcc_sub->arg_flags, n + 1, int);
for (i = n; i; --i) {
pcc_sub->args[i] = pcc_sub->args[i - 1];
@@ -419,7 +423,7 @@ expand_pcc_sub(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(Instruction *ins))
self->type = VTIDENTIFIER;
}
- unshift_self(sub, self);
+ unshift_self(interp, sub, self);
}
/* Don't generate any parameter checking code if there
@@ -821,7 +825,7 @@ expand_pcc_sub_call(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGMOD(Instruction *i
}
if (sub->pcc_sub->object)
- unshift_self(sub, sub->pcc_sub->object);
+ unshift_self(interp, sub, sub->pcc_sub->object);
/* insert arguments */
n = sub->pcc_sub->nargs;
View
44 compilers/imcc/reg_alloc.c
@@ -59,7 +59,8 @@ static void build_interference_graph(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(2)
FUNC_MODIFIES(*unit);
-static void build_reglist(NULLOK_INTERP, ARGMOD(IMC_Unit *unit))
+static void build_reglist(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*unit);
@@ -73,11 +74,12 @@ static void compute_one_du_chain(ARGMOD(SymReg *r), ARGIN(IMC_Unit *unit))
FUNC_MODIFIES(*r);
PARROT_WARN_UNUSED_RESULT
-static unsigned int first_avail(
+static unsigned int first_avail(PARROT_INTERP,
ARGIN(const IMC_Unit *unit),
int reg_set,
ARGOUT_NULLOK(Set **avail))
__attribute__nonnull__(1)
+ __attribute__nonnull__(2)
FUNC_MODIFIES(*avail);
PARROT_WARN_UNUSED_RESULT
@@ -162,7 +164,8 @@ static void try_allocate(PARROT_INTERP, ARGIN(IMC_Unit *unit))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void vanilla_reg_alloc(SHIM_INTERP, ARGMOD(IMC_Unit *unit))
+static void vanilla_reg_alloc(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*unit);
@@ -179,14 +182,16 @@ static void vanilla_reg_alloc(SHIM_INTERP, ARGMOD(IMC_Unit *unit))
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_build_reglist __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_compute_du_chain __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_compute_one_du_chain __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(r) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_first_avail __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_ig_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_ig_find_color __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit) \
@@ -223,7 +228,8 @@ static void vanilla_reg_alloc(SHIM_INTERP, ARGMOD(IMC_Unit *unit))
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_vanilla_reg_alloc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(unit))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -636,7 +642,7 @@ sort_reglist(ARGMOD(IMC_Unit *unit))
/*
-=item C<static void build_reglist(NULLOK_INTERP, IMC_Unit *unit)>
+=item C<static void build_reglist(PARROT_INTERP, IMC_Unit *unit)>
make a linear list of IDENTs and VARs, set n_symbols
TODO
@@ -654,7 +660,7 @@ Run through them and allocate all that don't overlap in one bunch.
*/
static void
-build_reglist(NULLOK_INTERP, ARGMOD(IMC_Unit *unit))
+build_reglist(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
{
ASSERT_ARGS(build_reglist)
SymHash const *hsh = &unit->hash;
@@ -670,7 +676,7 @@ build_reglist(NULLOK_INTERP, ARGMOD(IMC_Unit *unit))
if (count == 0)
return;
- unit->reglist = mem_allocate_n_typed(count, SymReg *);
+ unit->reglist = mem_gc_allocate_n_typed(interp, count, SymReg *);
for (i = count = 0; i < hsh->size; i++) {
SymReg *r;
@@ -1043,7 +1049,7 @@ try_allocate(PARROT_INTERP, ARGIN(IMC_Unit *unit))
if (!n)
return;
- avail = mem_allocate_n_typed(n, char);
+ avail = mem_gc_allocate_n_typed(interp, n, char);
for (i = 0; i < unit->n_symbols; ++i) {
int already_allocated, color;
@@ -1122,8 +1128,8 @@ map_colors(ARGIN(const IMC_Unit* unit), int x, ARGIN(unsigned int *graph),
/*
-=item C<static unsigned int first_avail(const IMC_Unit *unit, int reg_set, Set
-**avail)>
+=item C<static unsigned int first_avail(PARROT_INTERP, const IMC_Unit *unit, int
+reg_set, Set **avail)>
find first available register of the given reg_set
@@ -1133,13 +1139,15 @@ find first available register of the given reg_set
PARROT_WARN_UNUSED_RESULT
static unsigned int
-first_avail(ARGIN(const IMC_Unit *unit), int reg_set, ARGOUT_NULLOK(Set **avail))
+first_avail(PARROT_INTERP,
+ ARGIN(const IMC_Unit *unit), int reg_set,
+ ARGOUT_NULLOK(Set **avail))
{
ASSERT_ARGS(first_avail)
int n = (int)unit->n_symbols > unit->max_color
? (int)unit->n_symbols
: unit->max_color;
- Set *allocated = set_make((unsigned int)n + 1);
+ Set *allocated = set_make(interp, (unsigned int)n + 1);
const SymHash * const hsh = &unit->hash;
@@ -1205,7 +1213,7 @@ allocate_uniq(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int usage)
Set *avail = sets[j];
unsigned int first_reg = avail
? set_first_zero(avail)
- : first_avail(unit, (int)r->set, &avail);
+ : first_avail(interp, unit, (int)r->set, &avail);
set_add(avail, first_reg);
r->color = first_reg++;
@@ -1244,7 +1252,7 @@ allocate_uniq(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int usage)
*/
static void
-vanilla_reg_alloc(SHIM_INTERP, ARGMOD(IMC_Unit *unit))
+vanilla_reg_alloc(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
{
ASSERT_ARGS(vanilla_reg_alloc)
const char type[] = "INSP";
@@ -1266,7 +1274,7 @@ vanilla_reg_alloc(SHIM_INTERP, ARGMOD(IMC_Unit *unit))
/* Assign new colors. */
for (j = 0; j < 4; j++) {
reg_set = type[j];
- first_reg = first_avail(unit, reg_set, &avail);
+ first_reg = first_avail(interp, unit, reg_set, &avail);
/* XXX Use a different loop variable that doesn't shadow outer i */
for (i = 0; i < hsh->size; i++) {
@@ -1276,7 +1284,7 @@ vanilla_reg_alloc(SHIM_INTERP, ARGMOD(IMC_Unit *unit))
continue;
if (REG_NEEDS_ALLOC(r) && (r->color == -1) && r->use_count) {
if (set_contains(avail, first_reg))
- first_reg = first_avail(unit, reg_set, NULL);
+ first_reg = first_avail(interp, unit, reg_set, NULL);
set_add(avail, first_reg);
r->color = first_reg++;
View
34 compilers/imcc/sets.c
@@ -38,7 +38,7 @@ An implementation of sets -- used for tracking register usage.
/*
-=item C<Set* set_make(unsigned int length)>
+=item C<Set* set_make(PARROT_INTERP, unsigned int length)>
Creates a new Set object.
@@ -49,13 +49,13 @@ Creates a new Set object.
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Set*
-set_make(unsigned int length)
+set_make(PARROT_INTERP, unsigned int length)
{
ASSERT_ARGS(set_make)
- Set * const s = mem_allocate_zeroed_typed(Set);
+ Set * const s = mem_gc_allocate_zeroed_typed(interp, Set);
s->length = length;
- s->bmp = mem_allocate_n_zeroed_typed(NUM_BYTES(length),
- unsigned char);
+ s->bmp = mem_gc_allocate_n_zeroed_typed(interp,
+ NUM_BYTES(length), unsigned char);
return s;
}
@@ -63,7 +63,7 @@ set_make(unsigned int length)
/*
-=item C<Set* set_make_full(unsigned int length)>
+=item C<Set* set_make_full(PARROT_INTERP, unsigned int length)>
Creates a new Set object of C<length> items, setting them all to full.
@@ -74,10 +74,10 @@ Creates a new Set object of C<length> items, setting them all to full.
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Set*
-set_make_full(unsigned int length)
+set_make_full(PARROT_INTERP, unsigned int length)
{
ASSERT_ARGS(set_make_full)
- Set * const s = set_make(length);
+ Set * const s = set_make(interp, length);
const size_t bytes = NUM_BYTES(length);
if (bytes)
@@ -128,7 +128,7 @@ set_clear(ARGMOD(Set *s))
/*
-=item C<Set* set_copy(const Set *s)>
+=item C<Set* set_copy(PARROT_INTERP, const Set *s)>
Copies the set C<s>, returning a new set pointer.
@@ -139,10 +139,10 @@ Copies the set C<s>, returning a new set pointer.
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Set*
-set_copy(ARGIN(const Set *s))
+set_copy(PARROT_INTERP, ARGIN(const Set *s))
{
ASSERT_ARGS(set_copy)
- Set * const d = set_make(s->length);
+ Set * const d = set_make(interp, s->length);
memcpy(d->bmp, s->bmp, NUM_BYTES(d->length));
return d;
@@ -286,7 +286,7 @@ set_contains(ARGIN(const Set *s), unsigned int element)
/*
-=item C<Set * set_union(const Set *s1, const Set *s2)>
+=item C<Set * set_union(PARROT_INTERP, const Set *s1, const Set *s2)>
Computes the union of the two Set arguments, returning it as a new Set.
@@ -299,11 +299,11 @@ Raises a fatal error if the two Sets have different lengths.
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Set *
-set_union(ARGIN(const Set *s1), ARGIN(const Set *s2))
+set_union(PARROT_INTERP, ARGIN(const Set *s1), ARGIN(const Set *s2))
{
ASSERT_ARGS(set_union)
unsigned int i;
- Set * const s = set_make(s1->length);
+ Set * const s = set_make(interp, s1->length);
if (s1->length != s2->length)
fatal(1, "set_union", "Sets don't have the same length\n");
@@ -318,7 +318,7 @@ set_union(ARGIN(const Set *s1), ARGIN(const Set *s2))
/*
-=item C<Set * set_intersec(const Set *s1, const Set *s2)>
+=item C<Set * set_intersec(PARROT_INTERP, const Set *s1, const Set *s2)>
Creates a new Set object that is the intersection of the Set arguments (defined
through the binary C<and> operator.)
@@ -332,11 +332,11 @@ Raises a fatal error if the two Sets have different lengths.
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Set *
-set_intersec(ARGIN(const Set *s1), ARGIN(const Set *s2))
+set_intersec(PARROT_INTERP, ARGIN(const Set *s1), ARGIN(const Set *s2))
{
ASSERT_ARGS(set_intersec)
unsigned int i;
- Set * const s = set_make(s1->length);
+ Set * const s = set_make(interp, s1->length);
if (s1->length != s2->length)
fatal(1, "set_intersec", "Sets don't have the same length\n");
View
38 compilers/imcc/sets.h
@@ -29,8 +29,9 @@ int set_contains(ARGIN(const Set *s), unsigned int element)
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Set* set_copy(ARGIN(const Set *s))
- __attribute__nonnull__(1);
+Set* set_copy(PARROT_INTERP, ARGIN(const Set *s))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
int set_equal(ARGIN(const Set *s1), ARGIN(const Set *s2))
__attribute__nonnull__(1)
@@ -47,9 +48,12 @@ void set_free(ARGMOD(Set *s))
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Set * set_intersec(ARGIN(const Set *s1), ARGIN(const Set *s2))
+Set * set_intersec(PARROT_INTERP,
+ ARGIN(const Set *s1),
+ ARGIN(const Set *s2))
__attribute__nonnull__(1)
- __attribute__nonnull__(2);
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
void set_intersec_inplace(ARGMOD(Set *s1), ARGIN(const Set *s2))
__attribute__nonnull__(1)
@@ -58,17 +62,20 @@ void set_intersec_inplace(ARGMOD(Set *s1), ARGIN(const Set *s2))
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Set* set_make(unsigned int length);
+Set* set_make(PARROT_INTERP, unsigned int length)
+ __attribute__nonnull__(1);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Set* set_make_full(unsigned int length);
+Set* set_make_full(PARROT_INTERP, unsigned int length)
+ __attribute__nonnull__(1);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Set * set_union(ARGIN(const Set *s1), ARGIN(const Set *s2))
+Set * set_union(PARROT_INTERP, ARGIN(const Set *s1), ARGIN(const Set *s2))
__attribute__nonnull__(1)
- __attribute__nonnull__(2);
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
#define ASSERT_ARGS_set_add __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s))
@@ -77,7 +84,8 @@ Set * set_union(ARGIN(const Set *s1), ARGIN(const Set *s2))
#define ASSERT_ARGS_set_contains __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_set_copy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(s))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_set_equal __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s1) \
, PARROT_ASSERT_ARG(s2))
@@ -86,15 +94,19 @@ Set * set_union(ARGIN(const Set *s1), ARGIN(const Set *s2))
#define ASSERT_ARGS_set_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_set_intersec __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(s1) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(s1) \
, PARROT_ASSERT_ARG(s2))
#define ASSERT_ARGS_set_intersec_inplace __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s1) \
, PARROT_ASSERT_ARG(s2))
-#define ASSERT_ARGS_set_make __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
-#define ASSERT_ARGS_set_make_full __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_set_make __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_set_make_full __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_set_union __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(s1) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(s1) \
, PARROT_ASSERT_ARG(s2))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: compilers/imcc/sets.c */
View
133 compilers/imcc/symreg.c
@@ -48,19 +48,21 @@ static SymReg * _get_sym_typed(
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PARROT_MALLOC
-static char * _mk_fullname(
+static char * _mk_fullname(PARROT_INTERP,
ARGIN_NULLOK(const Namespace *ns),
ARGIN(const char *name))
- __attribute__nonnull__(2);
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(3);
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static SymReg * _mk_symreg(
+static SymReg * _mk_symreg(PARROT_INTERP,
ARGMOD(SymHash *hsh),
ARGIN(const char *name),
int t)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*hsh);
PARROT_WARN_UNUSED_RESULT
@@ -95,17 +97,20 @@ static SymReg * mk_pmc_const_2(PARROT_INTERP,
FUNC_MODIFIES(*unit)
FUNC_MODIFIES(*rhs);
-static void resize_symhash(ARGMOD(SymHash *hsh))
+static void resize_symhash(PARROT_INTERP, ARGMOD(SymHash *hsh))
__attribute__nonnull__(1)
+ __attribute__nonnull__(2)
FUNC_MODIFIES(*hsh);
#define ASSERT_ARGS__get_sym_typed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(hsh) \
, PARROT_ASSERT_ARG(name))
#define ASSERT_ARGS__mk_fullname __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(name))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(name))
#define ASSERT_ARGS__mk_symreg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(hsh) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(hsh) \
, PARROT_ASSERT_ARG(name))
#define ASSERT_ARGS_add_ns __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -121,7 +126,8 @@ static void resize_symhash(ARGMOD(SymHash *hsh))
, PARROT_ASSERT_ARG(left) \
, PARROT_ASSERT_ARG(rhs))
#define ASSERT_ARGS_resize_symhash __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(hsh))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(hsh))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -139,7 +145,7 @@ void
push_namespace(PARROT_INTERP, ARGIN(const char *name))
{
ASSERT_ARGS(push_namespace)
- Namespace * const ns = mem_allocate_zeroed_typed(Namespace);
+ Namespace * const ns = mem_gc_allocate_zeroed_typed(interp, Namespace);
ns->parent = IMCC_INFO(interp)->namespace_stack;
ns->name = mem_sys_strdup(name);
@@ -244,7 +250,8 @@ get_sym_by_name(ARGIN(const SymHash *hsh), ARGIN(const char *name))
/*
-=item C<static SymReg * _mk_symreg(SymHash *hsh, const char *name, int t)>
+=item C<static SymReg * _mk_symreg(PARROT_INTERP, SymHash *hsh, const char
+*name, int t)>
Makes a new SymReg in the given SymHash from a varname and type.
@@ -255,20 +262,20 @@ Makes a new SymReg in the given SymHash from a varname and type.
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static SymReg *
-_mk_symreg(ARGMOD(SymHash *hsh), ARGIN(const char *name), int t)
+_mk_symreg(PARROT_INTERP, ARGMOD(SymHash *hsh), ARGIN(const char *name), int t)
{
ASSERT_ARGS(_mk_symreg)
SymReg * r = _get_sym_typed(hsh, name, t);
if (!r) {
- r = mem_allocate_zeroed_typed(SymReg);
+ r = mem_gc_allocate_zeroed_typed(interp, SymReg);
r->set = t;
r->type = VTREG;
r->name = mem_sys_strdup(name);
r->color = -1;
r->want_regno = -1;
- _store_symreg(hsh, r);
+ _store_symreg(interp, hsh, r);
}
return r;
@@ -296,7 +303,7 @@ mk_symreg(PARROT_INTERP, ARGIN(const char *name), int t)
/* Check for the condition that fires up a segfault in TT #162 */
PARROT_ASSERT(unit != NULL);
- return _mk_symreg(&unit->hash, name, t);
+ return _mk_symreg(interp, &unit->hash, name, t);
}
@@ -386,10 +393,10 @@ mk_pcc_sub(PARROT_INTERP, ARGIN(const char *name), int proto)
{
ASSERT_ARGS(mk_pcc_sub)
IMC_Unit * const unit = IMCC_INFO(interp)->last_unit;
- SymReg * const r = _mk_symreg(&unit->hash, name, proto);
+ SymReg * const r = _mk_symreg(interp, &unit->hash, name, proto);
r->type = VT_PCC_SUB;
- r->pcc_sub = mem_allocate_zeroed_typed(pcc_sub_t);
+ r->pcc_sub = mem_gc_allocate_zeroed_typed(interp, pcc_sub_t);
return r;
}
@@ -420,7 +427,7 @@ add_namespace(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
if (unit->prev && unit->prev->_namespace == ns)
unit->_namespace = ns;
else {
- SymReg * const g = dup_sym(ns);
+ SymReg * const g = dup_sym(interp, ns);
SymReg * const r = _get_sym(&IMCC_INFO(interp)->ghash, g->name);
unit->_namespace = g;
@@ -430,7 +437,7 @@ add_namespace(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
/* this unit should free its namespace only if it's the only thing
* holding onto it */
if (!r || r->type != VT_CONSTP) {
- _store_symreg(&IMCC_INFO(interp)->ghash, g);
+ _store_symreg(interp, &IMCC_INFO(interp)->ghash, g);
un