[svn:parrot] r37016 - in trunk: compilers/imcc compilers/pirc/src config/gen/makefiles examples/compilers include/parrot src src/dynpmc src/gc src/jit/i386 src/pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Thu Feb 26 06:57:30 UTC 2009
Author: cotto
Date: Thu Feb 26 06:57:28 2009
New Revision: 37016
URL: https://trac.parrot.org/parrot/changeset/37016
Log:
[PMC] replace PMC_struct_val and derivatives with ATTR accessors for the Sub PMC
Modified:
trunk/compilers/imcc/parser_util.c
trunk/compilers/imcc/pbc.c
trunk/compilers/pirc/src/bcgen.c
trunk/config/gen/makefiles/pirc.in
trunk/config/gen/makefiles/root.in
trunk/examples/compilers/japhc.c
trunk/include/parrot/extend.h
trunk/include/parrot/global.h
trunk/include/parrot/pic.h
trunk/include/parrot/sub.h
trunk/src/dynpmc/subproxy.pmc
trunk/src/embed.c
trunk/src/extend.c
trunk/src/gc/register.c
trunk/src/global.c
trunk/src/jit.c
trunk/src/jit/i386/exec_dep.h
trunk/src/multidispatch.c
trunk/src/packdump.c
trunk/src/packfile.c
trunk/src/pbc_merge.c
trunk/src/pic_jit.c
trunk/src/pmc/continuation.pmc
trunk/src/pmc/coroutine.pmc
trunk/src/pmc/eval.pmc
trunk/src/pmc/exception.pmc
trunk/src/pmc/namespace.pmc
trunk/src/pmc/parrotinterpreter.pmc
trunk/src/pmc/sub.pmc
trunk/src/sub.c
trunk/src/thread.c
trunk/src/trace.c
Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/compilers/imcc/parser_util.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -21,6 +21,7 @@
#include "imc.h"
#include "parrot/dynext.h"
#include "parrot/embed.h"
+#include "../../src/pmc/pmc_sub.h"
#include "pbc.h"
#include "parser.h"
#include "optimizer.h"
@@ -694,7 +695,7 @@
* TODO if a sub was denoted :main return that instead
*/
sub = pmc_new(interp, enum_class_Eval);
- sub_data = PMC_sub(sub);
+ PMC_get_sub(interp, sub, sub_data);
sub_data->seg = new_cs;
sub_data->start_offs = 0;
sub_data->end_offs = new_cs->base.size;
Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/compilers/imcc/pbc.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -6,6 +6,7 @@
#include "imc.h"
#include "pbc.h"
#include "parrot/packfile.h"
+#include "../src/pmc/pmc_sub.h"
/* HEADERIZER HFILE: compilers/imcc/pbc.h */
@@ -101,7 +102,7 @@
PARROT_CANNOT_RETURN_NULL
static PMC* create_lexinfo(PARROT_INTERP,
ARGMOD(IMC_Unit *unit),
- ARGIN(PMC *sub),
+ ARGIN(PMC *sub_pmc),
int need_lex)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -238,7 +239,7 @@
#define ASSERT_ARGS_create_lexinfo __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(unit) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
#define ASSERT_ARGS_find_global_label __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(name) \
@@ -1146,7 +1147,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static PMC*
-create_lexinfo(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(PMC *sub),
+create_lexinfo(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(PMC *sub_pmc),
int need_lex)
{
ASSERT_ARGS(create_lexinfo)
@@ -1165,7 +1166,7 @@
SymReg *n;
if (!lex_info) {
lex_info = pmc_new_noinit(interp, lex_info_id);
- VTABLE_init_pmc(interp, lex_info, sub);
+ VTABLE_init_pmc(interp, lex_info, sub_pmc);
}
/* at least one lexical name */
@@ -1173,16 +1174,18 @@
PARROT_ASSERT(n);
while (n) {
- STRING *lex_name;
- const int k = n->color;
+ STRING *lex_name;
+ const int k = n->color;
+ Parrot_sub *sub;
PARROT_ASSERT(k >= 0);
lex_name = constants[k]->u.string;
PARROT_ASSERT(PObj_is_string_TEST(lex_name));
+ PMC_get_sub(interp, sub_pmc, sub);
IMCC_debug(interp, DEBUG_PBC_CONST,
"add lexical '%s' to sub name '%s'\n",
- n->name, (char*)PMC_sub(sub)->name->strstart);
+ n->name, (char*)sub->name->strstart);
Parrot_PCCINVOKE(interp, lex_info,
string_from_literal(interp, "declare_lex_preg"),
@@ -1197,7 +1200,7 @@
if (!lex_info && (unit->outer || need_lex)) {
lex_info = pmc_new_noinit(interp, lex_info_id);
- VTABLE_init_pmc(interp, lex_info, sub);
+ VTABLE_init_pmc(interp, lex_info, sub_pmc);
}
return lex_info;
@@ -1220,10 +1223,11 @@
find_outer(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
{
ASSERT_ARGS(find_outer)
- subs_t *s;
- PMC *current;
- STRING *cur_name;
- size_t len;
+ subs_t *s;
+ PMC *current;
+ STRING *cur_name;
+ Parrot_sub *sub;
+ size_t len;
if (!unit->outer)
return NULL;
@@ -1253,7 +1257,8 @@
IMCC_fatal(interp, 1, "Undefined :outer sub '%s'.\n",
unit->outer->name);
- cur_name = PMC_sub(current)->name;
+ PMC_get_sub(interp, current, sub);
+ cur_name = sub->name;
if (cur_name->strlen == len
&& (memcmp((char*)cur_name->strstart, unit->outer->name, len) == 0))
@@ -1286,7 +1291,7 @@
ASSERT_ARGS(add_const_pmc_sub)
PMC *ns_pmc;
PMC *sub_pmc;
- Parrot_sub *sub;
+ Parrot_sub *sub, *outer_sub;
const int k = add_const_table(interp);
PackFile_ConstTable *ct = interp->code->const_table;
@@ -1348,9 +1353,9 @@
}
/* Set flags and get the sub info. */
- PObj_get_FLAGS(sub_pmc) |= (r->pcc_sub->pragma & SUB_FLAG_PF_MASK);
- Sub_comp_get_FLAGS(sub_pmc) |= (r->pcc_sub->pragma & SUB_COMP_FLAG_MASK);
- sub = PMC_sub(sub_pmc);
+ PObj_get_FLAGS(sub_pmc) |= (r->pcc_sub->pragma & SUB_FLAG_PF_MASK);
+ 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);
sub->name = ct->constants[r->color]->u.string;
@@ -1471,6 +1476,9 @@
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 (%s) "
"lex_info %s :outer(%s)\n",
@@ -1478,7 +1486,7 @@
(char *) sub_pmc->vtable->whoami->strstart,
sub->lex_info ? "yes" : "no",
sub->outer_sub ?
- (char *)PMC_sub(sub->outer_sub)->name->strstart :
+ (char *)outer_sub->name->strstart :
"*none*");
/*
Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/compilers/pirc/src/bcgen.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -9,6 +9,7 @@
#include "parrot/parrot.h"
#include "parrot/interpreter.h"
+#include "../../../src/pmc/pmc_sub.h"
/* #include "parrot/embed.h" */
@@ -791,6 +792,7 @@
find_outer_sub(bytecode * const bc, char const * const outername, struct lexer_state * const lexer)
{
PMC *current;
+ Parrot_sub *sub;
STRING *cur_name;
size_t len;
global_label *outersub;
@@ -836,7 +838,8 @@
return NULL;
}
- cur_name = PMC_sub(current)->name;
+ PMC_get_sub(interp, current, sub);
+ cur_name = sub->name;
/* XXX can't this be a call to Parrot_str_compare() ? */
if (cur_name->strlen == len && (memcmp((char *)cur_name->strstart, outername, len) == 0))
@@ -1003,9 +1006,9 @@
interp = bc->interp;
sub_pmc = create_sub_pmc(bc, info->iscoroutine, info->instanceof);
- sub = PMC_sub(sub_pmc);
subname_index = add_string_const(bc, info->subname, "ascii");
subname_const = bc->interp->code->const_table->constants[subname_index];
+ PMC_get_sub(interp, sub_pmc, sub);
/* set start and end offset of this sub in the bytecode.
* This is calculated during the parsing phase.
@@ -1027,8 +1030,8 @@
sub->multi_signature = generate_multi_signature(bc, info->multi_types, info->num_multi_types);
/* copy sub pragma flags such as :immediate etc. */
- PObj_get_FLAGS(sub_pmc) |= subpragmas & SUB_FLAG_PF_MASK;
- Sub_comp_get_FLAGS(sub_pmc) |= subpragmas & SUB_COMP_FLAG_MASK;
+ PObj_get_FLAGS(sub_pmc) |= subpragmas & SUB_FLAG_PF_MASK;
+ Sub_comp_get_FLAGS(sub) |= subpragmas & SUB_COMP_FLAG_MASK;
/* store register usage of this sub. */
Modified: trunk/config/gen/makefiles/pirc.in
==============================================================================
--- trunk/config/gen/makefiles/pirc.in Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/config/gen/makefiles/pirc.in Thu Feb 26 06:57:28 2009 (r37016)
@@ -83,7 +83,7 @@
src/hdocprep$(O): src/hdocprep.c src/hdocprep.l
src/pirmacro$(O): src/pirmacro.c src/pirmacro.h
src/pirregalloc$(O): src/pirregalloc.c src/pirregalloc.h
-src/bcgen$(O): src/bcgen.c src/bcgen.h
+src/bcgen$(O): src/bcgen.c src/bcgen.h ../../src/pmc/pmc_sub.h
src/pirpcc$(O): src/pirpcc.c src/pirpcc.h
src/pirerr$(O): src/pirerr.c src/pirerr.h
src/pircapi$(O): src/pircapi.c src/pircapi.h
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/config/gen/makefiles/root.in Thu Feb 26 06:57:28 2009 (r37016)
@@ -609,7 +609,7 @@
.pmc.dump :
$(PMC2CD) $<
-.pmc.c :
+.pmc.c : $(SRC_DIR)/pmc/pmc_sub.h
$(PMC2CC) $<
# not all makes might understand this, so the rules are generated
@@ -913,6 +913,7 @@
#
# Parrot Dump
#
+$(SRC_DIR)/packdump$(O) : $(SRC_DIR)/pmc/pmc_sub.h
$(PDUMP) : $(SRC_DIR)/pbc_dump$(O) $(SRC_DIR)/packdump$(O) $(LIBPARROT)
$(LINK) @ld_out@$@ \
@@ -1013,7 +1014,8 @@
$(SRC_DIR)/global_setup$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global_setup.str
-$(SRC_DIR)/global$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global.str
+$(SRC_DIR)/global$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global.str \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/pmc$(O) : $(GENERAL_H_FILES)
@@ -1025,7 +1027,7 @@
$(SRC_DIR)/library$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/jit_emit.h
+$(SRC_DIR)/jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/jit_emit.h $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/jit_debug$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/debug.str
@@ -1072,12 +1074,13 @@
#IF(platform_asm):
$(SRC_DIR)/core_pmcs$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/trace$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/trace$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/debug$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h \
$(SRC_DIR)/debug.str
-$(SRC_DIR)/sub$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/sub.str
+$(SRC_DIR)/sub$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/sub.str \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/string/api$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/string/private_cstring.h
@@ -1091,9 +1094,10 @@
$(SRC_DIR)/events$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
-$(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h
+$(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/interpreter$(O) : $(SRC_DIR)/interpreter.c $(GENERAL_H_FILES)
@@ -1129,12 +1133,13 @@
$(SRC_DIR)/pic$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/multidispatch$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/multidispatch.str \
- $(SRC_DIR)/pmc/pmc_nci.h
+ $(SRC_DIR)/pmc/pmc_nci.h $(SRC_DIR)/pmc/pmc_sub.h
-$(SRC_DIR)/packfile$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/packfile.str
+$(SRC_DIR)/packfile$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/packfile.str \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(PF_DIR)/pf_items$(O) : $(GENERAL_H_FILES)
@@ -1142,7 +1147,7 @@
$(SRC_DIR)/parrot$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/gc/register$(O) : $(GENERAL_H_FILES)
+$(SRC_DIR)/gc/register$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/runops_cores$(O) : $(GENERAL_H_FILES)
@@ -1150,7 +1155,8 @@
$(SRC_DIR)/tsq$(O) : $(GENERAL_H_FILES)
-$(SRC_DIR)/embed$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h
+$(SRC_DIR)/embed$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(SRC_DIR)/dataypes$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/dataypes.c
@@ -1180,7 +1186,8 @@
$(SRC_DIR)/string/charset$(O) : $(SRC_DIR)/string/charset.c $(GENERAL_H_FILES)
-$(SRC_DIR)/pbc_merge$(O) : $(SRC_DIR)/pbc_merge.c $(GENERAL_H_FILES)
+$(SRC_DIR)/pbc_merge$(O) : $(SRC_DIR)/pbc_merge.c $(GENERAL_H_FILES) \
+ $(SRC_DIR)/pmc/pmc_sub.h
$(IO_DIR)/filehandle$(O) : $(SRC_DIR)/pmc/pmc_filehandle.h $(SRC_DIR)/io/io_private.h
Modified: trunk/examples/compilers/japhc.c
==============================================================================
--- trunk/examples/compilers/japhc.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/examples/compilers/japhc.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -30,6 +30,7 @@
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "../../src/pmc/pmc_sub.h"
#define C_DEBUG 0
@@ -230,7 +231,7 @@
* create sub PMC
*/
sub = pmc_new(interp, enum_class_Eval);
- sub_data = PMC_sub(sub);
+ PMC_get_sub(interp, sub, sub_data);
sub_data->seg = cur_cs;
sub_data->address = cur_cs->base.data;
sub_data->end = cur_cs->base.data + cur_cs->base.size;
Modified: trunk/include/parrot/extend.h
==============================================================================
--- trunk/include/parrot/extend.h Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/include/parrot/extend.h Thu Feb 26 06:57:28 2009 (r37016)
@@ -92,7 +92,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
void* Parrot_call_sub(PARROT_INTERP,
- Parrot_PMC sub,
+ Parrot_PMC sub_pmc,
ARGIN(const char *signature),
...)
__attribute__nonnull__(1)
@@ -100,7 +100,7 @@
PARROT_EXPORT
Parrot_Float Parrot_call_sub_ret_float(PARROT_INTERP,
- Parrot_PMC sub,
+ Parrot_PMC sub_pmc,
ARGIN(const char *signature),
...)
__attribute__nonnull__(1)
@@ -108,7 +108,7 @@
PARROT_EXPORT
Parrot_Int Parrot_call_sub_ret_int(PARROT_INTERP,
- Parrot_PMC sub,
+ Parrot_PMC sub_pmc,
ARGIN(const char *signature),
...)
__attribute__nonnull__(1)
Modified: trunk/include/parrot/global.h
==============================================================================
--- trunk/include/parrot/global.h Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/include/parrot/global.h Thu Feb 26 06:57:28 2009 (r37016)
@@ -153,7 +153,7 @@
__attribute__nonnull__(1);
PARROT_EXPORT
-void Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub))
+void Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub_pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -205,7 +205,7 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_store_sub_in_namespace __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/global.c */
Modified: trunk/include/parrot/pic.h
==============================================================================
--- trunk/include/parrot/pic.h Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/include/parrot/pic.h Thu Feb 26 06:57:28 2009 (r37016)
@@ -163,7 +163,7 @@
PARROT_WARN_UNUSED_RESULT
int parrot_pic_is_safe_to_jit(PARROT_INTERP,
- ARGIN(PMC *sub),
+ ARGIN(PMC *sub_pmc),
ARGIN(PMC *sig_args),
ARGIN(PMC *sig_results),
ARGOUT(int *flags))
@@ -174,19 +174,19 @@
__attribute__nonnull__(5)
FUNC_MODIFIES(*flags);
-funcptr_t parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub), int flags)
+funcptr_t parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc), int flags)
__attribute__nonnull__(1)
__attribute__nonnull__(2);
#define ASSERT_ARGS_parrot_pic_is_safe_to_jit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub) \
+ || PARROT_ASSERT_ARG(sub_pmc) \
|| PARROT_ASSERT_ARG(sig_args) \
|| PARROT_ASSERT_ARG(sig_results) \
|| PARROT_ASSERT_ARG(flags)
#define ASSERT_ARGS_parrot_pic_JIT_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/pic_jit.c */
Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/include/parrot/sub.h Thu Feb 26 06:57:28 2009 (r37016)
@@ -99,7 +99,7 @@
} sub_comp_flags_enum;
#undef SUB_FLAG
-#define Sub_comp_get_FLAGS(o) ((PMC_sub(o))->comp_flags)
+#define Sub_comp_get_FLAGS(o) ((o)->comp_flags)
#define Sub_comp_flag_TEST(flag, o) (Sub_comp_get_FLAGS(o) & SUB_COMP_FLAG_ ## flag)
#define Sub_comp_flag_SET(flag, o) (Sub_comp_get_FLAGS(o) |= SUB_COMP_FLAG_ ## flag)
#define Sub_comp_flag_CLEAR(flag, o) (Sub_comp_get_FLAGS(o) &= ~(UINTVAL)(SUB_COMP_FLAG_ ## flag))
@@ -167,11 +167,18 @@
struct Parrot_Context *outer_ctx; /* outer context, if a closure */
} Parrot_sub;
-#define PMC_sub(pmc) ((pmc)->vtable->base_type == enum_class_Sub || \
- (pmc)->vtable->base_type == enum_class_Coroutine || \
- (pmc)->vtable->base_type == enum_class_Eval ? \
- (Parrot_sub *)PMC_struct_val(pmc) : \
- Parrot_get_sub_pmc_from_subclass(interp, (pmc)))
+#define PMC_get_sub(interp, pmc, sub) \
+ do { \
+ if ((pmc)->vtable->base_type == enum_class_Sub || \
+ (pmc)->vtable->base_type == enum_class_Coroutine || \
+ (pmc)->vtable->base_type == enum_class_Eval) \
+ {\
+ GETATTR_Sub_sub((interp), (pmc), (sub)); \
+ } \
+ else { \
+ (sub) = Parrot_get_sub_pmc_from_subclass((interp), (pmc)); \
+ } \
+ } while (0);
/* the first entries must match Parrot_sub, so we can cast
* these two to the other type
@@ -209,8 +216,6 @@
struct Stack_Chunk *dynamic_state; /* next dynamic state */
} Parrot_coro;
-#define PMC_coro(pmc) ((Parrot_coro *)PMC_struct_val(pmc))
-
typedef struct Parrot_cont {
/* continuation destination */
PackFile_ByteCode *seg; /* bytecode segment */
@@ -267,7 +272,7 @@
PARROT_EXPORT
PARROT_CAN_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
-STRING* Parrot_full_sub_name(PARROT_INTERP, ARGIN_NULLOK(PMC* sub))
+STRING* Parrot_full_sub_name(PARROT_INTERP, ARGIN_NULLOK(PMC* sub_pmc))
__attribute__nonnull__(1);
PARROT_EXPORT
Modified: trunk/src/dynpmc/subproxy.pmc
==============================================================================
--- trunk/src/dynpmc/subproxy.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/dynpmc/subproxy.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -27,9 +27,11 @@
opcode_t* invoke(void* next) {
if (PObj_get_FLAGS(SELF) & PObj_private0_FLAG) {
- PMC *key = PMC_data_typed(SELF, PMC *);
- STRING *file;
- PMC *rsub, *sub;
+
+ PMC *key = PMC_data_typed(SELF, PMC *);
+ STRING *file;
+ PMC *rsub_pmc, *sub_pmc;
+ Parrot_sub *rsub, *my_sub;
if (!key)
Parrot_ex_throw_from_c_args(interp, NULL, 1, "SubProxy: no key");
@@ -38,22 +40,24 @@
if (!file)
Parrot_ex_throw_from_c_args(interp, NULL, 1, "SubProxy: no file");
- sub = key_next(interp, key);
- if (!sub)
+ sub_pmc = key_next(interp, key);
+ if (!sub_pmc)
Parrot_ex_throw_from_c_args(interp, NULL, 1, "SubProxy: no sub");
Parrot_load_bytecode(interp, file);
- rsub = VTABLE_get_pmc_keyed(interp,
- interp->root_namespace, sub);
+ rsub_pmc = VTABLE_get_pmc_keyed(interp,
+ interp->root_namespace, sub_pmc);
- if (!VTABLE_defined(interp, rsub))
+ if (!VTABLE_defined(interp, rsub_pmc))
Parrot_ex_throw_from_c_args(interp, NULL, 1,
"SubProxy: sub not found");
PObj_get_FLAGS(SELF) &= ~PObj_private0_FLAG;
- PMC_sub(SELF)->seg = PMC_sub(rsub)->seg;
- PMC_sub(SELF)->start_offs = PMC_sub(rsub)->start_offs;
- PMC_sub(SELF)->end_offs = PMC_sub(rsub)->end_offs;
+ PMC_get_sub(INTERP, SELF, my_sub);
+ PMC_get_sub(INTERP, rsub_pmc, rsub);
+ my_sub->seg = rsub->seg;
+ my_sub->start_offs = rsub->start_offs;
+ my_sub->end_offs = rsub->end_offs;
}
return SUPER(next);
}
Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/embed.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -21,6 +21,7 @@
#include "parrot/parrot.h"
#include "parrot/embed.h"
#include "parrot/oplib/ops.h"
+#include "pmc/pmc_sub.h"
#include "../compilers/imcc/imc.h"
@@ -869,8 +870,9 @@
set_current_sub(PARROT_INTERP)
{
ASSERT_ARGS(set_current_sub)
- opcode_t i;
- PMC *sub_pmc;
+ opcode_t i;
+ Parrot_sub *sub_pmc_sub;
+ PMC *sub_pmc;
PackFile_ByteCode * const cur_cs = interp->code;
PackFile_FixupTable * const ft = cur_cs->fixups;
@@ -885,8 +887,9 @@
if (ft->fixups[i]->type == enum_fixup_sub) {
const opcode_t ci = ft->fixups[i]->offset;
PMC *sub_pmc = ct->constants[ci]->u.key;
- Parrot_sub *sub = PMC_sub(sub_pmc);
+ Parrot_sub *sub;
+ PMC_get_sub(interp, sub_pmc, sub);
if (sub->seg == cur_cs) {
const size_t offs = sub->start_offs;
@@ -904,7 +907,8 @@
/* if we didn't find anything put a dummy PMC into current_sub */
sub_pmc = pmc_new(interp, enum_class_Sub);
- PMC_sub(sub_pmc)->start_offs = 0;
+ PMC_get_sub(interp, sub_pmc, sub_pmc_sub);
+ sub_pmc_sub->start_offs = 0;
CONTEXT(interp)->current_sub = sub_pmc;
return sub_pmc;
Modified: trunk/src/extend.c
==============================================================================
--- trunk/src/extend.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/extend.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -60,6 +60,7 @@
#include "parrot/parrot.h"
#include "parrot/extend.h"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/extend.h */
@@ -983,19 +984,20 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
void*
-Parrot_call_sub(PARROT_INTERP, Parrot_PMC sub,
+Parrot_call_sub(PARROT_INTERP, Parrot_PMC sub_pmc,
ARGIN(const char *signature), ...)
{
ASSERT_ARGS(Parrot_call_sub)
- va_list ap;
- void *result;
+ va_list ap;
+ void *result;
+ Parrot_sub *sub;
PARROT_CALLIN_START(interp);
va_start(ap, signature);
- CONTEXT(interp)->constants =
- PMC_sub(sub)->seg->const_table->constants;
- result = Parrot_runops_fromc_arglist(interp, sub, signature, ap);
+ PMC_get_sub(interp, sub_pmc, sub);
+ CONTEXT(interp)->constants = sub->seg->const_table->constants;
+ result = Parrot_runops_fromc_arglist(interp, sub_pmc, signature, ap);
va_end(ap);
PARROT_CALLIN_END(interp);
@@ -1014,19 +1016,20 @@
PARROT_EXPORT
Parrot_Int
-Parrot_call_sub_ret_int(PARROT_INTERP, Parrot_PMC sub,
+Parrot_call_sub_ret_int(PARROT_INTERP, Parrot_PMC sub_pmc,
ARGIN(const char *signature), ...)
{
ASSERT_ARGS(Parrot_call_sub_ret_int)
- va_list ap;
- Parrot_Int result;
+ va_list ap;
+ Parrot_Int result;
+ Parrot_sub *sub;
PARROT_CALLIN_START(interp);
va_start(ap, signature);
- CONTEXT(interp)->constants =
- PMC_sub(sub)->seg->const_table->constants;
- result = Parrot_runops_fromc_arglist_reti(interp, sub, signature, ap);
+ PMC_get_sub(interp, sub_pmc, sub);
+ CONTEXT(interp)->constants = sub->seg->const_table->constants;
+ result = Parrot_runops_fromc_arglist_reti(interp, sub_pmc, signature, ap);
va_end(ap);
PARROT_CALLIN_END(interp);
@@ -1045,19 +1048,20 @@
PARROT_EXPORT
Parrot_Float
-Parrot_call_sub_ret_float(PARROT_INTERP, Parrot_PMC sub,
+Parrot_call_sub_ret_float(PARROT_INTERP, Parrot_PMC sub_pmc,
ARGIN(const char *signature), ...)
{
ASSERT_ARGS(Parrot_call_sub_ret_float)
- va_list ap;
- Parrot_Float result;
+ va_list ap;
+ Parrot_Float result;
+ Parrot_sub *sub;
PARROT_CALLIN_START(interp);
va_start(ap, signature);
- CONTEXT(interp)->constants =
- PMC_sub(sub)->seg->const_table->constants;
- result = Parrot_runops_fromc_arglist_retf(interp, sub, signature, ap);
+ PMC_get_sub(interp, sub_pmc, sub);
+ CONTEXT(interp)->constants = sub->seg->const_table->constants;
+ result = Parrot_runops_fromc_arglist_retf(interp, sub_pmc, signature, ap);
va_end(ap);
PARROT_CALLIN_END(interp);
Modified: trunk/src/gc/register.c
==============================================================================
--- trunk/src/gc/register.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/gc/register.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -19,6 +19,7 @@
#include "parrot/parrot.h"
#include "parrot/register.h"
+#include "../pmc/pmc_sub.h"
/* set CTX_LEAK_DEBUG_FULL to 1 for enhanced context debugging.
@@ -574,7 +575,8 @@
if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)
&& ctx->current_sub) {
/* can't probably Parrot_io_eprintf here */
- const Parrot_sub * const doomed = PMC_sub(ctx->current_sub);
+ Parrot_sub *doomed;
+ PMC_get_sub(interp, ctx->current_sub, doomed);
if (doomed) {
fprintf(stderr, "[free ctx %p of sub '%s']\n",
@@ -655,9 +657,11 @@
ASSERT_ARGS(Parrot_context_ref_trace)
if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
const char *name = "unknown";
+ Parrot_sub *sub;
+ PMC_get_sub(interp, ctx->current_sub, sub);
if (ctx->current_sub)
- name = (char *)(PMC_sub(ctx->current_sub)->name->strstart);
+ name = (char *)(sub->name->strstart);
fprintf(stderr, "[reference to context %p ('%s') taken at %s:%d]\n",
(void *)ctx, name, file, line);
Modified: trunk/src/global.c
==============================================================================
--- trunk/src/global.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/global.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -18,6 +18,7 @@
#include "parrot/parrot.h"
#include "global.str"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/global.h */
/* HEADERIZER BEGIN: static */
@@ -25,7 +26,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
-static PMC * get_namespace_pmc(PARROT_INTERP, ARGIN(PMC *sub))
+static PMC * get_namespace_pmc(PARROT_INTERP, ARGIN(PMC *sub_pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -70,7 +71,7 @@
__attribute__nonnull__(3);
static void store_sub_in_multi(PARROT_INTERP,
- ARGIN(PMC *sub),
+ ARGIN(PMC *sub_pmc),
ARGIN(PMC *ns))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -78,7 +79,7 @@
#define ASSERT_ARGS_get_namespace_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
#define ASSERT_ARGS_internal_ns_keyed __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(base_ns) \
@@ -97,7 +98,7 @@
|| PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_store_sub_in_multi __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub) \
+ || PARROT_ASSERT_ARG(sub_pmc) \
|| PARROT_ASSERT_ARG(ns)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -769,11 +770,15 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
static PMC *
-get_namespace_pmc(PARROT_INTERP, ARGIN(PMC *sub))
+get_namespace_pmc(PARROT_INTERP, ARGIN(PMC *sub_pmc))
{
ASSERT_ARGS(get_namespace_pmc)
- PMC * const nsname = PMC_sub(sub)->namespace_name;
- PMC * const nsroot = Parrot_get_HLL_namespace(interp, PMC_sub(sub)->HLL_id);
+ Parrot_sub *sub;
+ PMC *nsname, *nsroot;
+
+ PMC_get_sub(interp, sub_pmc, sub);
+ nsname = sub->namespace_name;
+ nsroot = Parrot_get_HLL_namespace(interp, sub->HLL_id);
/* If we have a NULL, return the HLL namespace */
if (PMC_IS_NULL(nsname))
@@ -799,22 +804,27 @@
*/
static void
-store_sub_in_multi(PARROT_INTERP, ARGIN(PMC *sub), ARGIN(PMC *ns))
+store_sub_in_multi(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGIN(PMC *ns))
{
ASSERT_ARGS(store_sub_in_multi)
- STRING * const ns_entry_name = PMC_sub(sub)->ns_entry_name;
- PMC *multisub = VTABLE_get_pmc_keyed_str(interp, ns, ns_entry_name);
+ Parrot_sub *sub;
+ STRING *ns_entry_name;
+ PMC *multisub;
+
+ PMC_get_sub(interp, sub_pmc, sub);
+ ns_entry_name = sub->ns_entry_name;
+ multisub = VTABLE_get_pmc_keyed_str(interp, ns, ns_entry_name);
/* is there an existing MultiSub PMC? or do we need to create one? */
if (PMC_IS_NULL(multisub)) {
multisub = pmc_new(interp, enum_class_MultiSub);
/* we have to push the sub onto the MultiSub before we try to store
it because storing requires information from the sub */
- VTABLE_push_pmc(interp, multisub, sub);
+ VTABLE_push_pmc(interp, multisub, sub_pmc);
VTABLE_set_pmc_keyed_str(interp, ns, ns_entry_name, multisub);
}
else
- VTABLE_push_pmc(interp, multisub, sub);
+ VTABLE_push_pmc(interp, multisub, sub_pmc);
}
/*
@@ -830,34 +840,36 @@
PARROT_EXPORT
void
-Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub))
+Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub_pmc))
{
ASSERT_ARGS(Parrot_store_sub_in_namespace)
const INTVAL cur_id = CONTEXT(interp)->current_HLL;
- PMC *ns;
+ PMC *ns;
+ Parrot_sub *sub;
/* PF structures aren't fully constructed yet */
Parrot_block_GC_mark(interp);
/* store relative to HLL namespace */
- CONTEXT(interp)->current_HLL = PMC_sub(sub)->HLL_id;
+ PMC_get_sub(interp, sub_pmc, sub);
+ CONTEXT(interp)->current_HLL = sub->HLL_id;
- ns = get_namespace_pmc(interp, sub);
+ ns = get_namespace_pmc(interp, sub_pmc);
/* attach a namespace to the sub for lookups */
- PMC_sub(sub)->namespace_stash = ns;
+ sub->namespace_stash = ns;
/* store a :multi sub */
- if (!PMC_IS_NULL(PMC_sub(sub)->multi_signature))
- store_sub_in_multi(interp, sub, ns);
+ if (!PMC_IS_NULL(sub->multi_signature))
+ store_sub_in_multi(interp, sub_pmc, ns);
/* store other subs (as long as they're not :anon) */
- else if (!(PObj_get_FLAGS(sub) & SUB_FLAG_PF_ANON)) {
- STRING * const ns_entry_name = PMC_sub(sub)->ns_entry_name;
- PMC * const nsname = PMC_sub(sub)->namespace_name;
+ else if (!(PObj_get_FLAGS(sub_pmc) & SUB_FLAG_PF_ANON)) {
+ STRING * const ns_entry_name = sub->ns_entry_name;
+ PMC * const nsname = sub->namespace_name;
- Parrot_store_global_n(interp, ns, ns_entry_name, sub);
+ Parrot_store_global_n(interp, ns, ns_entry_name, sub_pmc);
/* TEMPORARY HACK - cache invalidation should be a namespace function */
if (!PMC_IS_NULL(nsname)) {
Modified: trunk/src/jit.c
==============================================================================
--- trunk/src/jit.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/jit.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -34,6 +34,7 @@
#include "jit_emit.h"
#include "parrot/packfile.h"
#include "parrot/oplib/ops.h"
+#include "pmc/pmc_sub.h"
#define JIT_SEGS 0
@@ -1294,8 +1295,11 @@
if (ft->fixups[i]->type == enum_fixup_sub) {
const int ci = ft->fixups[i]->offset;
PMC * const sub_pmc = ct->constants[ci]->u.key;
- Parrot_sub * const sub = PMC_sub(sub_pmc);
- const size_t offs = pc - sub->seg->base.data;
+ Parrot_sub *sub;
+ size_t offs;
+
+ PMC_get_sub(interp, sub_pmc, sub);
+ offs = pc - sub->seg->base.data;
if (offs >= sub->start_offs && offs < sub->end_offs) {
CONTEXT(interp)->n_regs_used = sub->n_regs_used;
Modified: trunk/src/jit/i386/exec_dep.h
==============================================================================
--- trunk/src/jit/i386/exec_dep.h Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/jit/i386/exec_dep.h Thu Feb 26 06:57:28 2009 (r37016)
@@ -19,50 +19,28 @@
/* HEADERIZER BEGIN: src/exec_dep.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-void offset_fixup(ARGMOD(Parrot_exec_objfile_t *obj))
- __attribute__nonnull__(1)
- FUNC_MODIFIES(*obj);
-
-void Parrot_exec_cpcf_op(ARGMOD(Parrot_jit_info_t *jit_info), PARROT_INTERP)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*jit_info);
-
-void Parrot_exec_normal_op(
- ARGMOD(Parrot_jit_info_t *jit_info),
- PARROT_INTERP)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*jit_info);
-
-void Parrot_exec_normal_op(
- ARGMOD(Parrot_jit_info_t *jit_info),
- PARROT_INTERP)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*jit_info);
-
-void Parrot_exec_restart_op(
- ARGMOD(Parrot_jit_info_t *jit_info),
- PARROT_INTERP)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*jit_info);
+void offset_fixup(Parrot_exec_objfile_t *obj);
+void Parrot_exec_cpcf_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+ __attribute__nonnull__(2);
-#define ASSERT_ARGS_offset_fixup __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(obj)
+void Parrot_exec_normal_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+ __attribute__nonnull__(2);
+
+void Parrot_exec_normal_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+ __attribute__nonnull__(2);
+
+void Parrot_exec_restart_op(Parrot_jit_info_t *jit_info, PARROT_INTERP)
+ __attribute__nonnull__(2);
+
+#define ASSERT_ARGS_offset_fixup __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_Parrot_exec_cpcf_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(jit_info) \
- || PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_exec_normal_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(jit_info) \
- || PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_exec_normal_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(jit_info) \
- || PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_exec_restart_op __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(jit_info) \
- || PARROT_ASSERT_ARG(interp)
+ PARROT_ASSERT_ARG(interp)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/exec_dep.c */
Modified: trunk/src/multidispatch.c
==============================================================================
--- trunk/src/multidispatch.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/multidispatch.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -46,6 +46,7 @@
#include "parrot/oplib/ops.h"
#include "multidispatch.str"
#include "pmc/pmc_nci.h"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/multidispatch.h */
@@ -141,7 +142,8 @@
__attribute__nonnull__(1);
PARROT_CANNOT_RETURN_NULL
-static PMC * Parrot_mmd_get_cached_multi_sig(PARROT_INTERP, ARGIN(PMC *sub))
+static PMC * Parrot_mmd_get_cached_multi_sig(PARROT_INTERP,
+ ARGIN(PMC *sub_pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -227,7 +229,7 @@
#define ASSERT_ARGS_Parrot_mmd_get_cached_multi_sig \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
#define ASSERT_ARGS_Parrot_mmd_maybe_candidate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc) \
@@ -857,11 +859,15 @@
PARROT_CANNOT_RETURN_NULL
static PMC *
-Parrot_mmd_get_cached_multi_sig(PARROT_INTERP, ARGIN(PMC *sub))
+Parrot_mmd_get_cached_multi_sig(PARROT_INTERP, ARGIN(PMC *sub_pmc))
{
ASSERT_ARGS(Parrot_mmd_get_cached_multi_sig)
- if (VTABLE_isa(interp, sub, CONST_STRING(interp, "Sub"))) {
- PMC *multi_sig = PMC_sub(sub)->multi_signature;
+ if (VTABLE_isa(interp, sub_pmc, CONST_STRING(interp, "Sub"))) {
+ Parrot_sub *sub;
+ PMC *multi_sig;
+
+ PMC_get_sub(interp, sub_pmc, sub);
+ multi_sig = sub->multi_signature;
if (multi_sig->vtable->base_type == enum_class_FixedPMCArray) {
PMC *converted_sig = mmd_cvt_to_types(interp, multi_sig);
@@ -869,7 +875,7 @@
if (PMC_IS_NULL(converted_sig))
return PMCNULL;
- multi_sig = PMC_sub(sub)->multi_signature = converted_sig;
+ multi_sig = sub->multi_signature = converted_sig;
}
return multi_sig;
@@ -896,8 +902,9 @@
mmd_distance(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(PMC *arg_tuple))
{
ASSERT_ARGS(mmd_distance)
- PMC *multi_sig, *mro;
- INTVAL i, n, args, dist, j, m;
+ PMC *multi_sig, *mro;
+ Parrot_sub *sub;
+ INTVAL args, dist, i, j, n, m;
/* has to be a builtin multi method */
if (pmc->vtable->base_type == enum_class_NCI) {
@@ -905,7 +912,8 @@
}
else {
/* not a multi; no distance */
- if (!PMC_sub(pmc)->multi_signature)
+ PMC_get_sub(interp, pmc, sub);
+ if (!sub->multi_signature)
return 0;
multi_sig = Parrot_mmd_get_cached_multi_sig(interp, pmc);
@@ -1287,10 +1295,11 @@
ARGIN(STRING *sub_name), ARGIN(STRING *long_sig), ARGIN(PMC *sub_obj))
{
ASSERT_ARGS(Parrot_mmd_add_multi_from_long_sig)
- PMC *type_list = Parrot_str_split(interp, CONST_STRING(interp, ","), long_sig);
- STRING *ns_name = VTABLE_get_string_keyed_int(interp, type_list, 0);
- STRING *sub_str = CONST_STRING(interp, "Sub");
- STRING *closure_str = CONST_STRING(interp, "Closure");
+ Parrot_sub *sub;
+ STRING *sub_str = CONST_STRING(interp, "Sub");
+ STRING *closure_str = CONST_STRING(interp, "Closure");
+ PMC *type_list = Parrot_str_split(interp, CONST_STRING(interp, ","), long_sig);
+ STRING *ns_name = VTABLE_get_string_keyed_int(interp, type_list, 0);
/* Attach a type tuple array to the sub for multi dispatch */
PMC *multi_sig = mmd_build_type_tuple_from_type_list(interp, type_list);
@@ -1300,7 +1309,8 @@
}
else if (VTABLE_isa(interp, sub_obj, sub_str)
|| VTABLE_isa(interp, sub_obj, closure_str)) {
- PMC_sub(sub_obj)->multi_signature = multi_sig;
+ PMC_get_sub(interp, sub_obj, sub);
+ sub->multi_signature = multi_sig;
}
mmd_add_multi_to_namespace(interp, ns_name, sub_name, sub_obj);
Modified: trunk/src/packdump.c
==============================================================================
--- trunk/src/packdump.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/packdump.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -22,6 +22,7 @@
#include "parrot/parrot.h"
#include "parrot/packfile.h"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/packfile.h */
@@ -289,7 +290,7 @@
break;
case enum_class_Sub:
case enum_class_Coroutine:
- sub = PMC_sub(pmc);
+ PMC_get_sub(interp, pmc, sub);
if (sub->namespace_name) {
switch (sub->namespace_name->vtable->base_type) {
case enum_class_String:
Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/packfile.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -30,6 +30,7 @@
#include "jit.h"
#include "../compilers/imcc/imc.h"
#include "packfile.str"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/packfile.h */
@@ -580,11 +581,12 @@
* These casts are a quick fix to allow parrot build with c++,
* a refactor of the macros will be a cleaner solution. */
DECL_CONST_CAST;
- int todo = 0;
- int pragmas = PObj_get_FLAGS(sub_pmc) & SUB_FLAG_PF_MASK
- & ~SUB_FLAG_IS_OUTER;
-
- if (!pragmas && !Sub_comp_INIT_TEST(PARROT_const_cast(PMC *, sub_pmc)))
+ Parrot_sub *sub;
+ int todo = 0;
+ int pragmas = PObj_get_FLAGS(sub_pmc) & SUB_FLAG_PF_MASK
+ & ~SUB_FLAG_IS_OUTER;
+ PMC_get_sub(interp, PARROT_const_cast(PMC *, sub_pmc), sub);
+ if (!pragmas && !Sub_comp_INIT_TEST(sub))
return 0;
switch (action) {
@@ -596,7 +598,7 @@
/* :init functions need to be called at MAIN time, so return 1 */
/* symreg.h:P_INIT */
- if (Sub_comp_INIT_TEST(PARROT_const_cast(PMC *, sub_pmc)))
+ if (Sub_comp_INIT_TEST(sub))
todo = 1;
break;
@@ -667,7 +669,8 @@
do_1_sub_pragma(PARROT_INTERP, ARGMOD(PMC *sub_pmc), pbc_action_enum_t action)
{
ASSERT_ARGS(do_1_sub_pragma)
- Parrot_sub const *sub = PMC_sub(sub_pmc);
+ Parrot_sub *sub;
+ PMC_get_sub(interp, sub_pmc, sub);
switch (action) {
case PBC_IMMEDIATE:
@@ -703,7 +706,7 @@
PObj_get_FLAGS(sub_pmc) &= ~SUB_FLAG_PF_LOAD;
/* if loaded no need for init */
- Sub_comp_INIT_CLEAR(sub_pmc);
+ Sub_comp_INIT_CLEAR(sub);
run_sub(interp, sub_pmc);
}
break;
@@ -727,9 +730,9 @@
}
/* run :init tagged functions */
- if (action == PBC_MAIN && Sub_comp_INIT_TEST(sub_pmc)) {
+ if (action == PBC_MAIN && Sub_comp_INIT_TEST(sub)) {
/* if loaded no need for init */
- Sub_comp_INIT_CLEAR(sub_pmc);
+ Sub_comp_INIT_CLEAR(sub);
/* if inited no need for load */
PObj_get_FLAGS(sub_pmc) &= ~SUB_FLAG_PF_LOAD;
@@ -861,17 +864,19 @@
{
/* offset is an index into const_table holding the Sub PMC */
PMC *sub_pmc;
+ Parrot_sub *sub;
const opcode_t ci = ft->fixups[i]->offset;
if (ci < 0 || ci >= ct->const_count)
Parrot_ex_throw_from_c_args(interp, NULL, 1,
"Illegal fixup offset (%d) in enum_fixup_sub");
- sub_pmc = ct->constants[ci]->u.key;
- PMC_sub(sub_pmc)->eval_pmc = eval_pmc;
+ sub_pmc = ct->constants[ci]->u.key;
+ PMC_get_sub(interp, sub_pmc, sub);
+ sub->eval_pmc = eval_pmc;
- if (((PObj_get_FLAGS(sub_pmc) & SUB_FLAG_PF_MASK)
- || (Sub_comp_get_FLAGS(sub_pmc) & SUB_COMP_FLAG_MASK))
+ if (((PObj_get_FLAGS(sub_pmc) & SUB_FLAG_PF_MASK)
+ || (Sub_comp_get_FLAGS(sub) & SUB_COMP_FLAG_MASK))
&& sub_pragma(interp, action, sub_pmc)) {
PMC * const result = do_1_sub_pragma(interp, sub_pmc,
action);
@@ -2967,22 +2972,24 @@
if (old_const->type == PFC_PMC
&& VTABLE_isa(interp, old_const->u.key, _sub)) {
- PMC *old_sub;
- PMC *new_sub;
+ PMC *old_sub_pmc, *new_sub_pmc;
+ Parrot_sub *old_sub, *new_sub;
PackFile_Constant * const ret = mem_allocate_typed(PackFile_Constant);
ret->type = old_const->type;
- old_sub = old_const->u.key;
- new_sub = Parrot_thaw_constants(interp, Parrot_freeze(interp, old_sub));
+ old_sub_pmc = old_const->u.key;
+ new_sub_pmc = Parrot_thaw_constants(interp, Parrot_freeze(interp, old_sub_pmc));
- PMC_sub(new_sub)->seg = PMC_sub(old_sub)->seg;
+ PMC_get_sub(interp, new_sub_pmc, new_sub);
+ PMC_get_sub(interp, old_sub_pmc, old_sub);
+ new_sub->seg = old_sub->seg;
/* Vtable overrides and methods were already cloned, so don't reclone them. */
- if (PMC_sub(new_sub)->vtable_index == -1
- && !(PMC_sub(old_sub)->comp_flags & SUB_COMP_FLAG_METHOD))
- Parrot_store_sub_in_namespace(interp, new_sub);
+ if (new_sub->vtable_index == -1
+ && !(old_sub->comp_flags & SUB_COMP_FLAG_METHOD))
+ Parrot_store_sub_in_namespace(interp, new_sub_pmc);
- ret->u.key = new_sub;
+ ret->u.key = new_sub_pmc;
return ret;
}
Modified: trunk/src/pbc_merge.c
==============================================================================
--- trunk/src/pbc_merge.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pbc_merge.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -40,6 +40,7 @@
#include "parrot/parrot.h"
#include "parrot/embed.h"
#include "parrot/oplib/ops.h"
+#include "pmc/pmc_sub.h"
/* This struct describes an input file. */
@@ -454,7 +455,8 @@
case enum_class_Sub:
case enum_class_Coroutine:
{
- Parrot_sub * const sub = PMC_sub(copy->u.key);
+ Parrot_sub *sub;
+ PMC_get_sub(interp, copy->u.key, sub);
sub->start_offs += inputs[i]->code_start;
sub->end_offs += inputs[i]->code_start;
}
Modified: trunk/src/pic_jit.c
==============================================================================
--- trunk/src/pic_jit.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pic_jit.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -33,6 +33,7 @@
#include "parrot/parrot.h"
#include "parrot/oplib/ops.h"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/pic.h */
@@ -51,7 +52,7 @@
PARROT_WARN_UNUSED_RESULT
static int call_is_safe(PARROT_INTERP,
- ARGIN(PMC *sub),
+ ARGIN(PMC *sub_pmc),
ARGMOD(opcode_t **set_args))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -59,7 +60,7 @@
FUNC_MODIFIES(*set_args);
PARROT_WARN_UNUSED_RESULT
-static int jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub))
+static int jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -104,11 +105,11 @@
|| PARROT_ASSERT_ARG(start)
#define ASSERT_ARGS_call_is_safe __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub) \
+ || PARROT_ASSERT_ARG(sub_pmc) \
|| PARROT_ASSERT_ARG(set_args)
#define ASSERT_ARGS_jit_can_compile_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(sub)
+ || PARROT_ASSERT_ARG(sub_pmc)
#define ASSERT_ARGS_ops_jittable __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(sub) \
@@ -204,12 +205,16 @@
PARROT_WARN_UNUSED_RESULT
static int
-jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub))
+jit_can_compile_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
{
ASSERT_ARGS(jit_can_compile_sub)
const jit_arch_info * const info = Parrot_jit_init(interp);
const jit_arch_regs * const regs = info->regs + JIT_CODE_SUB_REGS_ONLY;
- INTVAL * const n_regs_used = PMC_sub(sub)->n_regs_used;
+ INTVAL *n_regs_used;
+ Parrot_sub *sub;
+
+ PMC_get_sub(interp, sub_pmc, sub);
+ n_regs_used = sub->n_regs_used;
/* if the sub is using more regs than the arch has
* we don't JIT it at all
@@ -336,14 +341,16 @@
PARROT_WARN_UNUSED_RESULT
static int
-call_is_safe(PARROT_INTERP, ARGIN(PMC *sub), ARGMOD(opcode_t **set_args))
+call_is_safe(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGMOD(opcode_t **set_args))
{
ASSERT_ARGS(call_is_safe)
- PMC *called, *sig_results;
+ PMC *called, *sig_results;
+ Parrot_sub *sub;
+ PMC *sig_args;
+ opcode_t *pc = *set_args;
- opcode_t * pc = *set_args;
- PMC * const sig_args =
- PMC_sub(sub)->seg->const_table->constants[pc[1]]->u.key;
+ PMC_get_sub(interp, sub_pmc, sub);
+ sig_args = sub->seg->const_table->constants[pc[1]]->u.key;
/* ignore the signature for now */
pc += 2 + VTABLE_elements(interp, sig_args);
@@ -351,10 +358,10 @@
if (*pc != PARROT_OP_set_p_pc)
return 0;
- called = PMC_sub(sub)->seg->const_table->constants[pc[2]]->u.key;
+ called = sub->seg->const_table->constants[pc[2]]->u.key;
/* we can JIT just recursive subs for now */
- if (called != sub)
+ if (called != sub_pmc)
return 0;
pc += 3;
@@ -362,7 +369,7 @@
if (*pc != PARROT_OP_get_results_pc)
return 0;
- sig_results = PMC_sub(sub)->seg->const_table->constants[pc[1]]->u.key;
+ sig_results = sub->seg->const_table->constants[pc[1]]->u.key;
pc += 2 + VTABLE_elements(interp, sig_results);
if (*pc != PARROT_OP_invokecc_p)
@@ -463,12 +470,13 @@
PARROT_WARN_UNUSED_RESULT
int
-parrot_pic_is_safe_to_jit(PARROT_INTERP, ARGIN(PMC *sub), ARGIN(PMC *sig_args),
+parrot_pic_is_safe_to_jit(PARROT_INTERP, ARGIN(PMC *sub_pmc), ARGIN(PMC *sig_args),
ARGIN(PMC *sig_results), ARGOUT(int *flags))
{
ASSERT_ARGS(parrot_pic_is_safe_to_jit)
#ifdef HAS_JIT
- opcode_t *base, *start, *end;
+ opcode_t *base, *start, *end;
+ Parrot_sub *sub;
*flags = 0;
@@ -482,32 +490,32 @@
/* 1) if the JIT system can't JIT_CODE_SUB_REGS_ONLY
* or the sub is using too many registers
*/
- if (!jit_can_compile_sub(interp, sub))
+ if (!jit_can_compile_sub(interp, sub_pmc))
return 0;
/*
* 2) check if get_params is matching set_args
*/
- base = PMC_sub(sub)->seg->base.data;
- start = base + PMC_sub(sub)->start_offs;
- end = base + PMC_sub(sub)->end_offs;
+ PMC_get_sub(interp, sub_pmc, sub);
+ base = sub->seg->base.data;
+ start = base + sub->start_offs;
+ end = base + sub->end_offs;
- if (!args_match_params(interp, sig_args, PMC_sub(sub)->seg, start))
+ if (!args_match_params(interp, sig_args, sub->seg, start))
return 0;
/*
* 3) verify if all opcodes are JITtable, also check set_returns
* if it's reached
*/
- if (!ops_jittable(interp, sub, sig_results,
- PMC_sub(sub)->seg, start, end, flags))
+ if (!ops_jittable(interp, sub_pmc, sig_results, sub->seg, start, end, flags))
return 0;
return 1;
#else
UNUSED(interp);
- UNUSED(sub);
+ UNUSED(sub_pmc);
UNUSED(sig_args);
UNUSED(sig_results);
UNUSED(flags);
@@ -527,24 +535,31 @@
*/
funcptr_t
-parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub), int flags)
+parrot_pic_JIT_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc), int flags)
{
ASSERT_ARGS(parrot_pic_JIT_sub)
#ifdef HAS_JIT
# ifdef PIC_TEST
UNUSED(interp);
- UNUSED(sub);
+ UNUSED(sub_pmc);
return (funcptr_t) pic_test_func;
# else
/*
* create JIT code - just a test
*/
- opcode_t * const base = PMC_sub(sub)->seg->base.data;
- opcode_t * const start = base + PMC_sub(sub)->start_offs;
- opcode_t * const end = base + PMC_sub(sub)->end_offs;
+ Parrot_sub *sub;
+ opcode_t *base;
+ opcode_t *start;
+ opcode_t *end;
+ Parrot_jit_info_t *jit_info;
+
+ PMC_get_sub(interp, sub_pmc, sub);
+ base = sub->seg->base.data;
+ start = base + sub->start_offs;
+ end = base + sub->end_offs;
/* TODO pass Sub */
- Parrot_jit_info_t * jit_info = parrot_build_asm(interp,
+ jit_info = parrot_build_asm(interp,
start, end, NULL, JIT_CODE_SUB_REGS_ONLY | flags);
if (!jit_info)
@@ -554,7 +569,7 @@
# endif
#else
UNUSED(interp);
- UNUSED(sub);
+ UNUSED(sub_pmc);
UNUSED(flags);
return NULLfunc;
Modified: trunk/src/pmc/continuation.pmc
==============================================================================
--- trunk/src/pmc/continuation.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/continuation.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -23,6 +23,7 @@
#include "parrot/parrot.h"
#include "parrot/oplib/ops.h"
+#include "pmc_sub.h"
/*
@@ -289,8 +290,10 @@
METHOD caller() {
Parrot_cont *cc = PMC_cont(SELF);
PMC *caller = cc->to_ctx->current_sub;
+ Parrot_sub *sub;
- if (!caller || !PMC_sub(caller)->seg)
+ PMC_get_sub(INTERP, caller, sub);
+ if (!caller || !sub->seg)
caller = PMCNULL;
RETURN(PMC *caller);
Modified: trunk/src/pmc/coroutine.pmc
==============================================================================
--- trunk/src/pmc/coroutine.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/coroutine.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -34,19 +34,22 @@
#include "parrot/oplib/ops.h"
static void
-print_sub_name(PARROT_INTERP, PMC *sub)
+print_sub_name(PARROT_INTERP, PMC *sub_pmc)
{
- Parrot_coro * const co = PMC_coro(sub);
+ /* It's acually a Parrot_coro, but this avoids casting warnings. */
+ Parrot_sub *co;
Interp * const tracer = (interp->pdb && interp->pdb->debugger) ?
interp->pdb->debugger :
interp;
+ GETATTR_Coroutine_sub(interp, sub_pmc, co);
+
Parrot_io_eprintf(tracer, "# %s coro '%Ss'",
- !(PObj_get_FLAGS(sub) & SUB_FLAG_CORO_FF) ?
+ !(PObj_get_FLAGS(sub_pmc) & SUB_FLAG_CORO_FF) ?
"Calling" : "yielding from",
- Parrot_full_sub_name(interp, sub));
+ Parrot_full_sub_name(interp, sub_pmc));
- if (co->ctx && (PObj_get_FLAGS(sub) & SUB_FLAG_CORO_FF)) {
+ if (co->ctx && (PObj_get_FLAGS(sub_pmc) & SUB_FLAG_CORO_FF)) {
Parrot_io_eprintf(tracer, " to '%Ss'",
Parrot_full_sub_name(interp,
co->ctx->caller_ctx->current_sub));
@@ -73,7 +76,10 @@
*/
VTABLE void init() {
- PMC_struct_val(SELF) = new_coroutine(INTERP);
+ Parrot_Coroutine_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_Coroutine_attributes);
+ attrs->sub = (Parrot_sub*)new_coroutine(INTERP);
+ PMC_data(SELF) = attrs;
PObj_custom_mark_destroy_SETALL(SELF);
}
@@ -88,7 +94,8 @@
*/
VTABLE void destroy() {
- Parrot_coro * const sub = PMC_coro(SELF);
+ Parrot_Coroutine_attributes *attrs = PARROT_COROUTINE(SELF);
+ Parrot_sub *sub = attrs->sub;
if (sub->ctx)
Parrot_free_context(interp, sub->ctx, 1);
@@ -97,16 +104,18 @@
}
VTABLE PMC *clone() {
- Parrot_coro * const sub = mem_allocate_typed(Parrot_coro);
- PMC * const ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
+ Parrot_coro * const coro_sub = mem_allocate_typed(Parrot_coro);
+ PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
+ Parrot_sub *sub;
PObj_custom_mark_destroy_SETALL(ret);
- PMC_struct_val(ret) = sub;
+ SET_ATTR_sub(INTERP, ret, coro_sub);
- memcpy(sub, PMC_sub(SELF), sizeof (Parrot_coro));
+ PMC_get_sub(INTERP, SELF, sub);
+ memcpy(coro_sub, sub, sizeof (Parrot_coro));
- sub->name = Parrot_str_copy(INTERP, sub->name);
+ coro_sub->name = Parrot_str_copy(INTERP, coro_sub->name);
return ret;
}
@@ -123,7 +132,8 @@
VTABLE opcode_t *invoke(void *next) {
PackFile_ByteCode *wanted_seg;
- Parrot_coro * const co = PMC_coro(SELF);
+ Parrot_Coroutine_attributes *attrs = PARROT_COROUTINE(SELF);
+ Parrot_coro * const co = (Parrot_coro*)attrs->sub;
opcode_t * dest = co->address;
if (Interp_trace_TEST(INTERP, PARROT_TRACE_SUB_CALL_FLAG))
@@ -253,7 +263,8 @@
*/
VTABLE void mark() {
- Parrot_coro * const co = PMC_coro(SELF);
+ Parrot_Coroutine_attributes *attrs = PARROT_COROUTINE(SELF);
+ Parrot_coro * const co = (Parrot_coro *)attrs->sub;
if (co) {
if (co->ctx)
Modified: trunk/src/pmc/eval.pmc
==============================================================================
--- trunk/src/pmc/eval.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/eval.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -20,6 +20,7 @@
*/
#include "parrot/parrot.h"
+#include "pmc_sub.h"
static void
clear_fixups(PARROT_INTERP, Parrot_sub *sub_data)
@@ -56,10 +57,14 @@
get_sub(PARROT_INTERP, PMC *self, int idx)
{
INTVAL i, n;
- PackFile_ByteCode *seg = PMC_sub(self)->seg;
+ Parrot_sub *sub;
+ PackFile_ByteCode *seg;
PackFile_FixupTable *ft;
PackFile_ConstTable *ct;
+ PMC_get_sub(interp, self, sub);
+ seg = sub->seg;
+
if (!seg)
return PMCNULL;
@@ -88,11 +93,15 @@
static void
mark_subs(PARROT_INTERP, PMC *self)
{
- PackFile_ByteCode * const seg = PMC_sub(self)->seg;
+ Parrot_sub *sub;
+ PackFile_ByteCode *seg;
PackFile_FixupTable *ft;
PackFile_ConstTable *ct;
INTVAL i;
+ PMC_get_sub(interp, self, sub);
+ seg = sub->seg;
+
if (!seg)
return;
@@ -123,9 +132,9 @@
Parrot_sub *sub_data;
SUPER();
- sub_data = PMC_sub(SELF);
- PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_get_sub(INTERP, SELF, sub_data);
sub_data->seg = NULL;
+ PObj_custom_mark_destroy_SETALL(SELF);
}
/*
@@ -160,7 +169,9 @@
*/
PackFile_Segment *seg;
PackFile_ByteCode *cur_cs;
- Parrot_sub *sub_data = PMC_sub(SELF);
+ Parrot_sub *sub_data;
+
+ PMC_get_sub(INTERP, SELF, sub_data);
if (!sub_data) {
SUPER();
@@ -219,11 +230,15 @@
*/
VTABLE STRING *get_string() {
+ Parrot_sub *sub;
PackFile *pf = PackFile_new(INTERP, 0);
- PackFile_ByteCode *seg = PMC_sub(SELF)->seg;
+ PackFile_ByteCode *seg;
STRING *res;
size_t size, aligned_size;
+ PMC_get_sub(INTERP, SELF, sub);
+ seg = sub->seg;
+
PackFile_add_segment(INTERP, &pf->directory, (PackFile_Segment *)seg);
if (seg->const_table)
@@ -322,6 +337,7 @@
STRING *packed = VTABLE_shift_string(INTERP, io);
PackFile *pf;
PackFile_Segment *seg;
+ Parrot_sub *sub;
size_t i;
SUPER(info);
@@ -338,7 +354,8 @@
seg = pf->directory.segments[i];
if (seg->type == PF_BYTEC_SEG) {
- PMC_sub(SELF)->seg = (PackFile_ByteCode *)seg;
+ PMC_get_sub(INTERP, SELF, sub);
+ sub->seg = (PackFile_ByteCode *)seg;
break;
}
}
Modified: trunk/src/pmc/exception.pmc
==============================================================================
--- trunk/src/pmc/exception.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/exception.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -51,6 +51,7 @@
#include "parrot/parrot.h"
#include "parrot/exceptions.h"
+#include "pmc_sub.h"
pmclass Exception {
@@ -755,22 +756,28 @@
Parrot_cont *cont = PMC_cont(resume);
Parrot_Context *cur_ctx = cont->to_ctx;
while (cur_ctx) {
- PMC *frame = pmc_new(interp, enum_class_Hash);
- PMC *annotations;
+ PMC *frame = pmc_new(interp, enum_class_Hash);
+ PMC *annotations;
+ Parrot_sub *sub;
/* Get sub and put it in the hash. */
- PMC *sub = cur_ctx->current_sub;
- if (sub == NULL)
- sub = PMCNULL;
- VTABLE_set_pmc_keyed_str(interp, frame, CONST_STRING(interp, "sub"), sub);
+ PMC *sub_pmc = cur_ctx->current_sub;
+ if (sub_pmc == NULL)
+ sub_pmc = PMCNULL;
+ VTABLE_set_pmc_keyed_str(interp, frame, CONST_STRING(interp, "sub"), sub_pmc);
/* Look up any annotations and put them in the hash. */
- if (!PMC_IS_NULL(sub) && sub->vtable->base_type == enum_class_Sub &&
- PMC_sub(sub)->seg->annotations) {
- PackFile_ByteCode *seg = PMC_sub(sub)->seg;
- opcode_t *pc = cur_ctx == cont->to_ctx ? cont->address : cur_ctx->current_pc;
- annotations = PackFile_Annotations_lookup(interp, seg->annotations,
- pc - seg->base.data, NULL);
+ if (!PMC_IS_NULL(sub_pmc) && sub_pmc->vtable->base_type == enum_class_Sub) {
+
+ PMC_get_sub(interp, sub_pmc, sub);
+
+ if (sub->seg->annotations) {
+ PackFile_ByteCode *seg = sub->seg;
+ opcode_t *pc = cur_ctx == cont->to_ctx ?
+ cont->address : cur_ctx->current_pc;
+ annotations = PackFile_Annotations_lookup(interp, seg->annotations,
+ pc - seg->base.data, NULL);
+ }
}
else {
annotations = pmc_new(interp, enum_class_Hash);
Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/namespace.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -27,6 +27,7 @@
*/
#include "parrot/parrot.h"
+#include "pmc_sub.h"
static void add_to_class(
Interp *interp,
@@ -56,8 +57,10 @@
{
Parrot_NameSpace_attributes * const nsinfo = PARROT_NAMESPACE(self);
PMC * vtable = nsinfo->vtable;
- Parrot_sub * const sub = PMC_sub(value);
PMC * const classobj = VTABLE_get_class(interp, self);
+ Parrot_sub *sub;
+
+ PMC_get_sub(interp, value, sub);
/* Handle vtable methods with two underscores at the start. */
if (sub->vtable_index == -1) {
@@ -270,7 +273,8 @@
/* Extract the first alternate and check if it is a method */
PMC *pmc_sub = VTABLE_get_pmc_keyed_int(interp, value, 0);
- Parrot_sub * const sub = PMC_sub(pmc_sub);
+ Parrot_sub *sub;
+ PMC_get_sub(INTERP, pmc_sub, sub);
if (sub->comp_flags & SUB_COMP_FLAG_METHOD) {
STRING *method_name = key;
Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/parrotinterpreter.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -30,6 +30,7 @@
#include "parrot/dynext.h"
#include "parrot/io.h"
#include "pmc_class.h"
+#include "pmc_sub.h"
/*
@@ -459,7 +460,9 @@
s = CONST_STRING(interp, "annotations");
if (Parrot_str_not_equal(interp, item, s) == 0) {
- PMC *sub = ctx->current_sub;
+ Parrot_sub *sub;
+ PMC *sub_pmc = ctx->current_sub;
+ PMC_get_sub(interp, sub_pmc, sub);
if (ctx == CONTEXT(interp)) {
/* We can't know the current program counter for the currently
* executing sub, so can't return annotations for that. */
@@ -467,9 +470,9 @@
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Cannot get annotations at depth 0; use annotations op instead.");
}
- if (!PMC_IS_NULL(sub) && sub->vtable->base_type == enum_class_Sub &&
- PMC_sub(sub)->seg->annotations) {
- PackFile_ByteCode *seg = PMC_sub(sub)->seg;
+ if (!PMC_IS_NULL(sub_pmc) && sub_pmc->vtable->base_type == enum_class_Sub &&
+ sub->seg->annotations) {
+ PackFile_ByteCode *seg = sub->seg;
opcode_t *pc = ctx->current_pc;
return PackFile_Annotations_lookup(interp, seg->annotations,
pc - seg->base.data, NULL);
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/pmc/sub.pmc Thu Feb 26 06:57:28 2009 (r37016)
@@ -41,6 +41,7 @@
* effectively a container. Therefore need_ext has to be set
*/
pmclass Sub need_ext {
+ ATTR struct Parrot_sub * sub; /* the Parrot sub structure */
/*
@@ -65,14 +66,13 @@
* - private7 ... :postcomp (originally @POSTCOMP)
*
* see also the enum in include/parrot/sub.h
- *
- * Data used:
- * PMC_struct_val ... Parrot_sub structure
- * PMC_pmc_val ... unused / bound object in Bound_Meth PMC
*/
VTABLE void init() {
- PMC_struct_val(SELF) = new_sub(INTERP);
- PMC_pmc_val(SELF) = NULL;
+ Parrot_Sub_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_Sub_attributes);
+
+ attrs->sub = new_sub(INTERP);
+ PMC_data(SELF) = attrs;
PObj_custom_mark_destroy_SETALL(SELF);
}
@@ -87,7 +87,8 @@
*/
VTABLE void destroy() {
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+ GET_ATTR_sub(INTERP, SELF, sub);
if (!sub)
return;
@@ -99,7 +100,8 @@
Parrot_free_context(INTERP, sub->outer_ctx, 1);
mem_sys_free(sub);
- PMC_struct_val(SELF) = NULL;
+ mem_sys_free(PMC_data(SELF));
+ PMC_data(SELF) = NULL;
}
/*
@@ -117,12 +119,14 @@
*/
VTABLE STRING *get_string() {
- const Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+ PMC_get_sub(INTERP, SELF, sub);
return Parrot_str_copy(INTERP, sub->name);
}
VTABLE void set_string_native(STRING *subname) {
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+ PMC_get_sub(INTERP, SELF, sub);
sub->name = Parrot_str_copy(INTERP, subname);
}
@@ -154,7 +158,8 @@
*/
VTABLE void *get_pointer() {
- const Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+ PMC_get_sub(INTERP, SELF, sub);
return sub->seg->base.data + sub->start_offs;
}
@@ -171,7 +176,9 @@
*/
VTABLE INTVAL get_integer_keyed(PMC *key) {
- return (INTVAL) ((PMC_sub(SELF))->seg->base.data);
+ Parrot_sub *sub;
+ PMC_get_sub(INTERP, SELF, sub);
+ return (INTVAL) (sub->seg->base.data);
}
/*
@@ -205,13 +212,14 @@
*/
VTABLE opcode_t *invoke(void *next) {
- Parrot_sub * const sub = PMC_sub(SELF);
- Parrot_Context *caller_ctx;
- Parrot_Context *context;
- Parrot_Context *c;
- PMC *ccont;
- opcode_t *pc;
+ Parrot_sub *sub;
+ Parrot_Context *caller_ctx;
+ Parrot_Context *context;
+ Parrot_Context *c;
+ PMC *ccont;
+ opcode_t *pc;
+ PMC_get_sub(INTERP, SELF, sub);
if (Interp_trace_TEST(INTERP, PARROT_TRACE_SUB_CALL_FLAG))
print_sub_name(INTERP, SELF);
@@ -313,13 +321,17 @@
else {
/* autoclose */
for (c = context; !c->outer_ctx; c = c->outer_ctx) {
- PMC *outer_pmc = PMC_sub(c->current_sub)->outer_sub;
- Parrot_sub *outer_sub;
+
+ PMC *outer_pmc;
+ Parrot_sub *current_sub, *outer_sub;
+
+ PMC_get_sub(INTERP, c->current_sub, current_sub);
+ outer_pmc = current_sub->outer_sub;
if (PMC_IS_NULL(outer_pmc))
break;
- outer_sub = PMC_sub(outer_pmc);
+ PMC_get_sub(INTERP, outer_pmc, outer_sub);
if (!outer_sub->ctx) {
Parrot_Context *dummy = Parrot_alloc_context(INTERP,
@@ -377,16 +389,17 @@
*/
VTABLE PMC *clone() {
+ Parrot_sub *dest_sub;
Parrot_sub *sub = mem_allocate_typed(Parrot_sub);
- PMC * const ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
+ PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
/* we have to mark it ourselves */
PObj_custom_mark_destroy_SETALL(ret);
/* first set the sub struct, Parrot_str_copy may cause GC */
- PMC_struct_val(ret) = sub;
- PMC_pmc_val(ret) = NULL;
- memcpy(sub, PMC_sub(SELF), sizeof (Parrot_sub));
+ SET_ATTR_sub(INTERP, ret, sub);
+ PMC_get_sub(INTERP, SELF, dest_sub);
+ memcpy(sub, dest_sub, sizeof (Parrot_sub));
if (sub->name != NULL)
sub->name = Parrot_str_copy(INTERP, sub->name);
@@ -413,13 +426,16 @@
}
VTABLE void assign_pmc(PMC *other) {
+ Parrot_sub *my_sub, *other_sub;
/* only handle the case where the other PMC is the same type */
if (other->vtable->base_type == SELF->vtable->base_type) {
/* copy the sub struct */
- memcpy(PMC_sub(SELF), PMC_sub(other), sizeof (struct Parrot_sub));
+ PMC_get_sub(INTERP, SELF, my_sub);
+ PMC_get_sub(INTERP, other, other_sub);
+ memcpy(my_sub, other_sub, sizeof (struct Parrot_sub));
/* copy the name so it's a different string in memory */
- PMC_sub(SELF)->name = Parrot_str_copy(INTERP, PMC_sub(SELF)->name);
+ my_sub->name = Parrot_str_copy(INTERP, my_sub->name);
}
else
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
@@ -437,7 +453,8 @@
*/
VTABLE void mark() {
- const Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+ PMC_get_sub(INTERP, SELF, sub);
if (!sub)
return;
@@ -477,9 +494,15 @@
*/
VTABLE INTVAL is_equal(PMC *value) {
+
+ Parrot_sub *my_sub, *value_sub;
+
+ PMC_get_sub(INTERP, SELF, my_sub);
+ PMC_get_sub(INTERP, value, value_sub);
+
return SELF->vtable == value->vtable &&
- (PMC_sub(SELF))->start_offs == (PMC_sub(value))->start_offs &&
- (PMC_sub(SELF))->seg == (PMC_sub(value))->seg;
+ (my_sub)->start_offs == (value_sub)->start_offs &&
+ (my_sub)->seg == (value_sub)->seg;
}
/*
@@ -497,7 +520,9 @@
*/
VTABLE void visit(visit_info *info) {
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+
+ PMC_get_sub(INTERP, SELF, sub);
info->thaw_ptr = &sub->namespace_name;
(info->visit_pmc_now)(INTERP, sub->namespace_name, info);
@@ -523,10 +548,12 @@
VTABLE void freeze(visit_info *info) {
IMAGE_IO * const io = info->image_io;
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
STRING *hll_name;
int i;
+ PMC_get_sub(INTERP, SELF, sub);
+
SUPER(info);
/*
* we currently need to write these items:
@@ -592,10 +619,11 @@
SUPER(info);
if (info->extra_flags == EXTRA_IS_NULL) {
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
INTVAL flags;
int i;
+ PMC_get_sub(INTERP, SELF, sub);
/* we get relative offsets */
sub->start_offs = (size_t) VTABLE_shift_integer(INTERP, io);
sub->end_offs = (size_t) VTABLE_shift_integer(INTERP, io);
@@ -702,10 +730,11 @@
PMC *inspect_str(STRING *what)
{
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
INTVAL count_found = -1;
PMC *retval;
+ PMC_get_sub(INTERP, SELF, sub);
/* If the argument info hasn't been generated yet, generate it. */
if (sub->arg_info == NULL)
{
@@ -827,20 +856,25 @@
*/
METHOD get_namespace() {
- Parrot_sub * const sub = PMC_sub(SELF);
- PMC *_namespace = sub->namespace_stash;
+ Parrot_sub *sub;
+ PMC *_namespace;
+
+ PMC_get_sub(INTERP, SELF, sub);
+ _namespace = sub->namespace_stash;
RETURN(PMC *_namespace);
}
METHOD __get_regs_used(STRING *reg) {
- Parrot_sub * const sub = PMC_sub(SELF);
- char * const kind = Parrot_str_to_cstring(interp, reg);
- INTVAL regs_used;
/* TODO switch to canonical NiSP order
* see also imcc/reg_alloc.c */
static const char types[] = "INSP";
char *p;
+ Parrot_sub *sub;
+ char * const kind = Parrot_str_to_cstring(interp, reg);
+ INTVAL regs_used;
+
+ PMC_get_sub(INTERP, SELF, sub);
PARROT_ASSERT(sub->n_regs_used);
@@ -862,20 +896,28 @@
}
METHOD get_lexinfo() {
- const Parrot_sub * const sub = PMC_sub(SELF);
- PMC *lexinfo = sub->lex_info ? sub->lex_info : PMCNULL;
+ Parrot_sub *sub;
+ PMC *lexinfo;
+
+ PMC_get_sub(INTERP, SELF, sub);
+ lexinfo = sub->lex_info ? sub->lex_info : PMCNULL;
RETURN(PMC *lexinfo);
}
METHOD get_outer() {
- const Parrot_sub * const sub = PMC_sub(SELF);
- PMC *outersub = sub->outer_sub ? sub->outer_sub : PMCNULL;
+ Parrot_sub *sub;
+ PMC *outersub;
+
+ PMC_get_sub(INTERP, SELF, sub);
+ outersub = sub->outer_sub ? sub->outer_sub : PMCNULL;
RETURN(PMC *outersub);
}
METHOD set_outer(PMC *outer) {
/* Set outer sub. */
- Parrot_sub * const sub = PMC_sub(SELF);
+ Parrot_sub *sub;
+
+ PMC_get_sub(INTERP, SELF, sub);
sub->outer_sub = outer;
/* Make sure outer flag of that sub is set. */
@@ -890,8 +932,11 @@
}
METHOD get_multisig() {
- const Parrot_sub * const sub = PMC_sub(SELF);
- PMC *multisig = sub->multi_signature ? sub->multi_signature : PMCNULL;
+ Parrot_sub *sub;
+ PMC *multisig;
+
+ PMC_get_sub(INTERP, SELF, sub);
+ multisig = sub->multi_signature ? sub->multi_signature : PMCNULL;
RETURN(PMC *multisig);
}
Modified: trunk/src/sub.c
==============================================================================
--- trunk/src/sub.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/sub.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -21,6 +21,7 @@
#include "parrot/parrot.h"
#include "parrot/oplib/ops.h"
#include "sub.str"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/sub.h */
@@ -336,14 +337,16 @@
PARROT_CAN_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
STRING*
-Parrot_full_sub_name(PARROT_INTERP, ARGIN_NULLOK(PMC* sub))
+Parrot_full_sub_name(PARROT_INTERP, ARGIN_NULLOK(PMC* sub_pmc))
{
ASSERT_ARGS(Parrot_full_sub_name)
- if (sub && VTABLE_defined(interp, sub)) {
- Parrot_sub * const s = PMC_sub(sub);
+ if (sub_pmc && VTABLE_defined(interp, sub_pmc)) {
+ Parrot_sub *sub;
- if (PMC_IS_NULL(s->namespace_stash)) {
- return s->name;
+ PMC_get_sub(interp, sub_pmc, sub);
+
+ if (PMC_IS_NULL(sub->namespace_stash)) {
+ return sub->name;
}
else {
PMC *ns_array;
@@ -366,7 +369,7 @@
Parrot_block_GC_mark(interp);
- ns_array = Parrot_ns_get_name(interp, s->namespace_stash);
+ ns_array = Parrot_ns_get_name(interp, sub->namespace_stash);
/* Restore stuff that might have got overwritten */
interp->current_cont = saved_ccont;
@@ -377,8 +380,8 @@
interp->params_signature = params_signature;
interp->returns_signature = returns_signature;
- if (s->name)
- VTABLE_push_string(interp, ns_array, s->name);
+ if (sub->name)
+ VTABLE_push_string(interp, ns_array, sub->name);
res = Parrot_str_join(interp, j, ns_array);
Parrot_unblock_GC_mark(interp);
@@ -430,7 +433,7 @@
if (!VTABLE_isa(interp, ctx->current_sub, CONST_STRING(interp, "Sub")))
return 1;
- sub = PMC_sub(ctx->current_sub);
+ PMC_get_sub(interp, ctx->current_sub, sub);
/* set the sub name */
info->subname = sub->name;
@@ -574,20 +577,30 @@
Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc))
{
ASSERT_ARGS(Parrot_capture_lex)
- Parrot_Context * const ctx = CONTEXT(interp);
- Parrot_sub * const current_sub = PMC_sub(ctx->current_sub);
- Parrot_sub *sub;
- Parrot_Context *old;
+ Parrot_Context * const ctx = CONTEXT(interp);
+ Parrot_sub *current_sub, *outer_sub;
+ Parrot_sub *sub;
+ Parrot_Context *old;
+
+ PMC_get_sub(interp, ctx->current_sub, current_sub);
/* MultiSub gets special treatment */
if (VTABLE_isa(interp, sub_pmc, CONST_STRING(interp, "MultiSub"))) {
+
PMC * const iter = VTABLE_get_iter(interp, sub_pmc);
+
while (VTABLE_get_bool(interp, iter)) {
- PMC * const child_pmc = VTABLE_shift_pmc(interp, iter);
- Parrot_sub * const child_sub = PMC_sub(child_pmc);
+
+ PMC * const child_pmc = VTABLE_shift_pmc(interp, iter);
+ Parrot_sub *child_sub, *child_outer_sub;
+
+ PMC_get_sub(interp, child_pmc, child_sub);
+
if (!PMC_IS_NULL(child_sub->outer_sub))
+
+ PMC_get_sub(interp, child_sub->outer_sub, child_outer_sub);
if (0 == Parrot_str_not_equal(interp, current_sub->subid,
- PMC_sub(child_sub->outer_sub)->subid)) {
+ child_outer_sub->subid)) {
old = child_sub->outer_ctx;
child_sub->outer_ctx = Parrot_context_ref(interp, ctx);
if (old)
@@ -598,14 +611,15 @@
}
/* the sub_pmc has to have an outer_sub that is the caller */
- sub = PMC_sub(sub_pmc);
+ PMC_get_sub(interp, sub_pmc, sub);
if (PMC_IS_NULL(sub->outer_sub))
return;
#if 0
/* verify that the current sub is sub_pmc's :outer */
+ PMC_get_sub(interp, sub->outer_sub, outer_sub);
if (0 != Parrot_str_not_equal(interp, current_sub->subid,
- PMC_sub(sub->outer_sub)->subid)) {
+ outer_sub->subid)) {
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION, "'%Ss' isn't the :outer of '%Ss'",
current_sub->name, sub->name);
@@ -728,21 +742,26 @@
Parrot_sub *
Parrot_get_sub_pmc_from_subclass(PARROT_INTERP, ARGIN(PMC *subclass)) {
ASSERT_ARGS(Parrot_get_sub_pmc_from_subclass)
- PMC *key, *sub_pmc;
+ PMC *key, *sub_pmc;
+ Parrot_sub *sub;
/* Ensure we really do have a subclass of sub. */
if (VTABLE_isa(interp, subclass, CONST_STRING(interp, "Sub"))) {
/* If it's actually a PMC still, probably does the same structure
* underneath. */
- if (!PObj_is_object_TEST(subclass))
- return (Parrot_sub *)PMC_struct_val(subclass);
+ if (!PObj_is_object_TEST(subclass)) {
+ GETATTR_Sub_sub(interp, subclass, sub);
+ return sub;
+ }
/* Get the Sub PMC itself. */
key = pmc_new(interp, enum_class_String);
VTABLE_set_string_native(interp, key, CONST_STRING(interp, "Sub"));
sub_pmc = VTABLE_get_attr_keyed(interp, subclass, key, CONST_STRING(interp, "proxy"));
- if (sub_pmc->vtable->base_type == enum_class_Sub)
- return (Parrot_sub *)PMC_struct_val(sub_pmc);
+ if (sub_pmc->vtable->base_type == enum_class_Sub) {
+ GETATTR_Sub_sub(interp, sub_pmc, sub);
+ return sub;
+ }
}
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Attempting to do sub operation on non-Sub.");
Modified: trunk/src/thread.c
==============================================================================
--- trunk/src/thread.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/thread.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -20,6 +20,7 @@
#include "parrot/parrot.h"
#include "parrot/atomic.h"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: include/parrot/thread.h */
@@ -198,11 +199,15 @@
* working as one might expect mainly because the segment is
* not correctly copied
*/
+ Parrot_sub *ret_val_sub, *arg_sub;
+
ret_val = Parrot_clone(interp, arg);
- PMC_sub(ret_val)->seg = PMC_sub(arg)->seg;
+ PMC_get_sub(interp, ret_val, ret_val_sub);
+ PMC_get_sub(interp, arg, arg_sub);
+ ret_val_sub->seg = arg_sub->seg;
/* Skip vtable overrides and methods. */
- if (PMC_sub(ret_val)->vtable_index == -1
- && !(PMC_sub(ret_val)->comp_flags & SUB_COMP_FLAG_METHOD)) {
+ if (ret_val_sub->vtable_index == -1
+ && !(ret_val_sub->comp_flags & SUB_COMP_FLAG_METHOD)) {
Parrot_store_sub_in_namespace(interp, ret_val);
}
}
@@ -490,7 +495,7 @@
Parrot_runloop jump_point;
int lo_var_ptr;
UINTVAL tid;
- PMC *sub;
+ PMC *sub_pmc;
PMC *sub_arg;
PMC * const self = (PMC*) arg;
PMC *ret_val = NULL;
@@ -501,7 +506,7 @@
/* need to set it here because argument passing can trigger GC */
interp->lo_var_ptr = &lo_var_ptr;
- sub = (PMC *)PMC_struct_val(self);
+ sub_pmc = (PMC *)PMC_struct_val(self);
sub_arg = PMC_pmc_val(self);
if (setjmp(jump_point.resume)) {
@@ -523,7 +528,7 @@
Parrot_ex_add_c_handler(interp, &jump_point);
Parrot_unblock_GC_mark(interp);
Parrot_unblock_GC_sweep(interp);
- ret_val = Parrot_runops_fromc_args(interp, sub, "PF", sub_arg);
+ ret_val = Parrot_runops_fromc_args(interp, sub_pmc, "PF", sub_arg);
}
/* thread is finito */
@@ -622,11 +627,15 @@
if (PMC_IS_NULL(dval)) {
PMC * const copy = make_local_copy(d, s, val);
+ Parrot_sub *val_sub;
+
+ if (val->vtable->base_type == enum_class_Sub)
+ PMC_get_sub(interp, val, val_sub);
/* Vtable overrides and methods were already cloned, so don't reclone them. */
- if (!(val->vtable->base_type == enum_class_Sub
- && (PMC_sub(val)->vtable_index != -1
- || PMC_sub(val)->comp_flags & SUB_COMP_FLAG_METHOD))) {
+ if (! (val->vtable->base_type == enum_class_Sub
+ && ( val_sub->vtable_index != -1
+ || val_sub->comp_flags & SUB_COMP_FLAG_METHOD))) {
VTABLE_set_pmc_keyed_str(d, dest_ns, key, copy);
}
}
Modified: trunk/src/trace.c
==============================================================================
--- trunk/src/trace.c Thu Feb 26 03:58:42 2009 (r37015)
+++ trunk/src/trace.c Thu Feb 26 06:57:28 2009 (r37016)
@@ -24,6 +24,7 @@
#include "trace.h"
#include "parrot/oplib/ops.h"
+#include "pmc/pmc_sub.h"
/* HEADERIZER HFILE: src/trace.h */
@@ -84,6 +85,7 @@
{
ASSERT_ARGS(trace_pmc_dump)
Interp * const debugger = interp->pdb->debugger;
+ Parrot_sub *sub;
if (!pmc) {
Parrot_io_eprintf(debugger, "(null)");
@@ -142,9 +144,9 @@
else if (pmc->vtable->base_type == enum_class_RetContinuation
|| pmc->vtable->base_type == enum_class_Continuation
|| pmc->vtable->base_type == enum_class_Sub) {
+ PMC_get_sub(interp, pmc, sub);
Parrot_io_eprintf(debugger, "%S=PMC(%#p pc:%d)",
- VTABLE_name(interp, pmc), pmc,
- PMC_sub(pmc)->start_offs);
+ VTABLE_name(interp, pmc), pmc, sub->start_offs);
}
else if (PObj_is_object_TEST(pmc)) {
Parrot_io_eprintf(debugger, "Object(%Ss)=PMC(%#p)",
More information about the parrot-commits
mailing list