Browse files

eliminate default.freeze and default.thaw

The presence of these vtables masks the fact that many types of PMCs don't
really implement serialization and performing these operations leaves them in
an inconsistent state at best.

Also fixup a number of PMC types that were dutifully calling SUPER() (which in
fact did nothing) in their implementations of these vtables.
  • Loading branch information...
1 parent bfa7f50 commit d44c2a2b98ae0baa834833fb032db68fcfc60329 @plobsing plobsing committed Sep 23, 2011
View
2 src/pmc/boolean.pmc
@@ -192,12 +192,10 @@ Used to unarchive the C<Boolean>.
*/
VTABLE void freeze(PMC *info) {
- SUPER(info);
VTABLE_push_integer(INTERP, info, SELF.get_bool());
}
VTABLE void thaw(PMC *info) {
- SUPER(info);
SELF.set_bool(VTABLE_shift_integer(INTERP, info));
}
View
4 src/pmc/complex.pmc
@@ -394,8 +394,6 @@ Serialize/deserialize this object for bytecode.
VTABLE void freeze(PMC *visit) {
FLOATVAL re, im;
- SUPER(visit);
-
GET_ATTR_re(INTERP, SELF, re);
VTABLE_push_float(INTERP, visit, re);
@@ -406,8 +404,6 @@ Serialize/deserialize this object for bytecode.
VTABLE void thaw(PMC *visit) {
FLOATVAL re, im;
- SUPER(visit);
-
re = VTABLE_shift_float(INTERP, visit);
SET_ATTR_re(INTERP, SELF, re);
View
30 src/pmc/default.pmc
@@ -1143,36 +1143,6 @@ Clones this PMC. By default, this just does a freeze and thaw.
/*
-=item C<void freeze(PMC *info)>
-
-Does nothing.
-
-=cut
-
-*/
-
- VTABLE void freeze(PMC *info) {
- UNUSED(info)
- /* default - no action */
- }
-
-/*
-
-=item C<void thaw(PMC *info)>
-
-Initializes the PMC during unarchiving.
-
-=cut
-
-*/
-
- VTABLE void thaw(PMC *info) {
- /* default - initialize the PMC */
- SELF.init();
- }
-
-/*
-
=item C<void thawfinish(PMC *info)>
Does nothing.
View
24 src/pmc/fixedbooleanarray.pmc
@@ -576,23 +576,19 @@ Used to unarchive the string.
*/
VTABLE void thaw(PMC *info) {
- SUPER(info);
+ const INTVAL size = VTABLE_shift_integer(INTERP, info);
+ STRING * const s = VTABLE_shift_string(INTERP, info);
+ const size_t size_in_bytes = get_size_in_bytes(size);
+ unsigned char *bit_array;
- {
- const INTVAL size = VTABLE_shift_integer(INTERP, info);
- STRING * const s = VTABLE_shift_string(INTERP, info);
- const size_t size_in_bytes = get_size_in_bytes(size);
- unsigned char *bit_array;
+ SELF.set_integer_native(size);
- SELF.set_integer_native(size);
+ if (s->bufused < size_in_bytes)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_BAD_BUFFER_SIZE,
+ "FixedBooleanArray: invalid buffer size during thaw");
- if (s->bufused < size_in_bytes)
- Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_BAD_BUFFER_SIZE,
- "FixedBooleanArray: invalid buffer size during thaw");
-
- GET_ATTR_bit_array(INTERP, SELF, bit_array);
- memcpy(bit_array, s->strstart, size_in_bytes);
- }
+ GET_ATTR_bit_array(INTERP, SELF, bit_array);
+ memcpy(bit_array, s->strstart, size_in_bytes);
}
/*
View
2 src/pmc/fixedintegerarray.pmc
@@ -588,8 +588,6 @@ C<*info> is the visit info, (see F<include/parrot/pmc_freeze.h>).
INTVAL *int_array;
INTVAL i, n;
- SUPER(info);
-
GET_ATTR_size(INTERP, SELF, n);
VTABLE_push_integer(INTERP, info, n);
GET_ATTR_int_array(INTERP, SELF, int_array);
View
2 src/pmc/float.pmc
@@ -363,7 +363,6 @@ Used to archive the number.
*/
VTABLE void freeze(PMC *info) {
- SUPER(info);
VTABLE_push_float(INTERP, info, SELF.get_number());
}
@@ -377,7 +376,6 @@ Used to unarchive the number.
*/
VTABLE void thaw(PMC *info) {
- SUPER(info);
SET_ATTR_fv(INTERP, SELF, VTABLE_shift_float(INTERP, info));
}
/*
View
2 src/pmc/integer.pmc
@@ -1261,7 +1261,6 @@ Used to archive the integer.
*/
VTABLE void freeze(PMC *info) {
- SUPER(info);
VTABLE_push_integer(INTERP, info, SELF.get_integer());
}
@@ -1276,7 +1275,6 @@ Used to unarchive the integer.
*/
VTABLE void thaw(PMC *info) {
- SUPER(info);
SELF.set_integer_native(VTABLE_shift_integer(INTERP, info));
}
}
View
14 src/pmc/orderedhash.pmc
@@ -791,6 +791,20 @@ Used to unarchive the hash.
*/
+ /*
+ * freeze and thaw need to be defined to avoid falling back to default.pmc's throwing versions
+ * the fact that they're no-ops and the real work is done by visit speaks to the fact that these
+ * two systems are redundant (see TT #1916)
+ */
+
+ VTABLE void freeze(PMC *info) {
+ UNUSED(info);
+ }
+
+ VTABLE void thaw(PMC *info) {
+ UNUSED(info);
+ }
+
VTABLE void visit(PMC *info) {
VISIT_PMC_ATTR(INTERP, info, SELF, OrderedHash, hash);
SUPER(info);
View
2 src/pmc/socket.pmc
@@ -68,7 +68,7 @@ Create a copy of the socket handle.
*/
VTABLE PMC *clone() {
- PMC * const copy = SUPER();
+ PMC * const copy = Parrot_pmc_new(interp, SELF->vtable->base_type);
const Parrot_Socket_attributes * const old_struct = PARROT_SOCKET(SELF);
Parrot_Socket_attributes * const data_struct = PARROT_SOCKET(copy);
View
2 src/pmc/string.pmc
@@ -593,7 +593,6 @@ Used to archive the string.
*/
VTABLE void freeze(PMC *info) {
STRING *str_val;
- SUPER(info);
GET_ATTR_str_val(INTERP, SELF, str_val);
VTABLE_push_string(INTERP, info, str_val);
}
@@ -608,7 +607,6 @@ Used to unarchive the string.
*/
VTABLE void thaw(PMC *info) {
- SUPER(info);
SET_ATTR_str_val(INTERP, SELF, VTABLE_shift_string(INTERP, info));
}
/*
View
1 src/pmc/sub.pmc
@@ -691,7 +691,6 @@ Archives the subroutine.
STRING *hll_name;
int i;
- SUPER(info);
PMC_get_sub(INTERP, SELF, sub);
/*
* we currently need to write these items:

0 comments on commit d44c2a2

Please sign in to comment.