Permalink
Browse files

Migrate to auto_attrs

  • Loading branch information...
1 parent 365279e commit cf14185690790f42bb511b0df1413805cdcacfe6 @sorear sorear committed Apr 4, 2010
Showing with 44 additions and 79 deletions.
  1. +0 −1 src/pmc/bkmarshal.c
  2. +1 −8 src/pmc/p5interpreter.pmc
  3. +9 −13 src/pmc/p5invocation.pmc
  4. +9 −26 src/pmc/p5namespace.pmc
  5. +1 −1 src/pmc/p5scalar.pmc
  6. +24 −30 src/pmc/p5sv.pmc
View
@@ -125,7 +125,6 @@ PMC *
blizkost_wrap_sv(PARROT_INTERP, PMC *p5i, SV *sv) {
PMC *pmc = Parrot_pmc_new_noinit(interp, pmc_type(interp,
string_from_literal(interp, "P5Scalar")));
- PMC_data(pmc) = mem_allocate_zeroed_typed(Parrot_P5Scalar_attributes);
PObj_custom_mark_SET(pmc);
PObj_custom_destroy_SET(pmc);
@@ -39,7 +39,7 @@ static int inited = 0;
*/
-pmclass P5Interpreter group blizkost_group dynpmc {
+pmclass P5Interpreter group blizkost_group dynpmc auto_attrs {
ATTR struct interpreter *my_perl;
/* These fields are here so that the callin code can use P5Interpreter
attribute blocks as a proxy. Possibly a bit hackish. */
@@ -63,7 +63,6 @@ Set up P5Interpreter PMC.
embedding_s[2] };
/* Set up the underlying structure. */
- PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_P5Interpreter_attributes);
PObj_custom_destroy_SET(SELF);
/* Inited before? */
@@ -114,10 +113,6 @@ Destructor for the P5Interpreter PMC.
* interpreter destroy. Skip doing it for now at all, but need to
* work out where to put this. */
/*PERL_SYS_TERM();*/
-
- /* Free underlying struct. */
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
}
/*
@@ -167,9 +162,7 @@ Acquire a namespace handle.
PMC *pmc = Parrot_pmc_new_noinit(interp, pmc_type(interp,
string_from_literal(interp, "P5Namespace")));
/* Set up the underlying structure. */
- PMC_data(pmc) = mem_allocate_zeroed_typed(Parrot_P5Namespace_attributes);
PObj_custom_mark_SET(pmc);
- PObj_custom_destroy_SET(pmc);
SETATTR_P5Namespace_p5i(interp, pmc, SELF);
SETATTR_P5Namespace_ns_name(interp, pmc, name);
View
@@ -17,7 +17,7 @@ invocation model and calling conventions.
#include "blizkost.h"
-pmclass P5Invocation group blizkost_group dynpmc {
+pmclass P5Invocation group blizkost_group dynpmc auto_attrs {
ATTR PMC *p5i;
ATTR STRING *name;
@@ -32,8 +32,6 @@ Set up P5Invocation PMC.
*/
VTABLE void init() {
- /* Set up the underlying structure. */
- PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_P5Invocation_attributes);
PObj_custom_mark_SET(SELF);
}
@@ -47,16 +45,14 @@ Mark GC-ables.
*/
VTABLE void mark() {
- if (PMC_data(SELF)) {
- PMC *p5i;
- STRING *name;
- GET_ATTR_p5i(interp, SELF, p5i);
- GET_ATTR_name(interp, SELF, name);
- if (p5i)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
- if (name)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)name);
- }
+ PMC *p5i;
+ STRING *name;
+ GET_ATTR_p5i(interp, SELF, p5i);
+ GET_ATTR_name(interp, SELF, name);
+ if (p5i)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
+ if (name)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)name);
}
/*
View
@@ -16,7 +16,7 @@ These are the vtable functions for the P5Namespace class.
#include "blizkost.h"
-pmclass P5Namespace group blizkost_group dynpmc {
+pmclass P5Namespace group blizkost_group dynpmc auto_attrs {
ATTR PMC *p5i;
ATTR STRING *ns_name;
@@ -35,31 +35,14 @@ Mark GC-ables.
*/
VTABLE void mark() {
- if (PMC_data(SELF)) {
- PMC *p5i;
- STRING *name;
- GET_ATTR_p5i(interp, SELF, p5i);
- GET_ATTR_ns_name(interp, SELF, name);
- if (p5i)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
- if (name)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)name);
- }
- }
-
-
-/*
-
-=item C<void destroy()>
-
-Free underlying structure.
-
-=cut
-
-*/
- VTABLE void destroy() {
- if (PMC_data(SELF))
- mem_sys_free(PMC_data(SELF));
+ PMC *p5i;
+ STRING *name;
+ GET_ATTR_p5i(interp, SELF, p5i);
+ GET_ATTR_ns_name(interp, SELF, name);
+ if (p5i)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
+ if (name)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)name);
}
/*
View
@@ -16,7 +16,7 @@ These are the vtable functions for the P5Scalar class.
#include "blizkost.h"
-pmclass P5Scalar extends P5SV group blizkost_group dynpmc {
+pmclass P5Scalar extends P5SV group blizkost_group dynpmc auto_attrs {
/*
View
@@ -16,7 +16,7 @@ These are the vtable functions for the P5SV class.
#include "blizkost.h"
-pmclass P5SV group blizkost_group dynpmc {
+pmclass P5SV group blizkost_group dynpmc auto_attrs {
ATTR PMC *p5i;
ATTR struct sv *sv;
@@ -45,12 +45,10 @@ Mark GC-ables.
*/
VTABLE void mark() {
- if (PMC_data(SELF)) {
- PMC *p5i;
- GET_ATTR_p5i(interp, SELF, p5i);
- if (p5i)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
- }
+ PMC *p5i;
+ GET_ATTR_p5i(interp, SELF, p5i);
+ if (p5i)
+ Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
}
@@ -64,36 +62,32 @@ Decrement reference count of held SV.
*/
VTABLE void destroy() {
- if (PMC_data(SELF)) {
- PMC *p5i;
- PerlInterpreter *my_perl;
- struct sv *sv;
- GET_ATTR_p5i(interp, SELF, p5i);
- /* There is a small destruction order issue here; Parrot
- may destroy the interpreter before the last SV references.
- But if the interpreter is destroyed, we have no need, the
- object is already free!
+ PMC *p5i;
+ PerlInterpreter *my_perl;
+ struct sv *sv;
+ GET_ATTR_p5i(interp, SELF, p5i);
+ /* There is a small destruction order issue here; Parrot
+ may destroy the interpreter before the last SV references.
+ But if the interpreter is destroyed, we have no need, the
+ object is already free!
01:34 < sorear> Austin: the specific question I care about is, given two
- objects A and B, if A is destroyed, can I assume that either B
- is alive or PMC_data(B) == NULL? This is true in all current
- collectors.
+objects A and B, if A is destroyed, can I assume that either B
+is alive or PMC_data(B) == NULL? This is true in all current
+collectors.
01:35 < sorear> bacek: VTABLE_mark(A) marks B
01:36 < sorear> so B is destroyed no earlier than in the same sweep phase as A
01:37 < sorear> I don't need ordered destruction - only a guarantee that all
- destruction occurs before all free()ing
+destruction occurs before all free()ing
01:38 < sorear> right now it [B] explicitly sets PMC_data(SELF) = NULL in
- destroy
+destroy
01:38 <@bacek> sorear, than answer is "yes"
- */
-
- if (PMC_data(p5i)) {
- GETATTR_P5Interpreter_my_perl(interp, p5i, my_perl);
- GET_ATTR_sv(interp, SELF, sv);
- SvREFCNT_dec(sv);
- }
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
+ */
+
+ if (PMC_data(p5i)) {
+ GETATTR_P5Interpreter_my_perl(interp, p5i, my_perl);
+ GET_ATTR_sv(interp, SELF, sv);
+ SvREFCNT_dec(sv);
}
}

0 comments on commit cf14185

Please sign in to comment.