Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
12 src/6model/serialization.c
@@ -11,6 +11,7 @@
#include "pmc_serializationcontext.h"
#include "pmc_nqplexinfo.h"
#include "pmc_ownedhash.h"
+#include "pmc_ownedresizablepmcarray.h"
#include "pmc/pmc_sub.h"
#include "base64.h"
@@ -56,6 +57,7 @@ static INTVAL nqp_lexpad_id = 0;
static INTVAL perl6_lexpad_id = 0;
static INTVAL ctmthunk_id = 0;
static INTVAL ownedhash_id = 0;
+static INTVAL ownedrpa_id = 0;
/* ***************************************************************************
* Serialization (writing related)
@@ -459,6 +461,9 @@ void write_ref_func(PARROT_INTERP, SerializationWriter *writer, PMC *ref) {
else if (ref->vtable->base_type == enum_class_ResizablePMCArray) {
discrim = REFVAR_VM_ARR_VAR;
}
+ else if (ref->vtable->base_type == ownedrpa_id) {
+ discrim = REFVAR_VM_ARR_VAR;
+ }
else if (ref->vtable->base_type == enum_class_ResizableIntegerArray) {
discrim = REFVAR_VM_ARR_INT;
}
@@ -984,6 +989,7 @@ STRING * Serialization_serialize(PARROT_INTERP, PMC *sc, PMC *empty_string_heap)
perl6_lexpad_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "Perl6LexInfo", 0));
ctmthunk_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "CTMThunk", 0));
ownedhash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));
+ ownedrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedResizablePMCArray", 0));
/* Initialize string heap so first entry is the NULL string. */
VTABLE_push_string(interp, empty_string_heap, STRINGNULL);
@@ -1123,7 +1129,7 @@ PMC * read_obj_ref(PARROT_INTERP, SerializationReader *reader) {
/* Reads in an array of variant references. */
PMC * read_ref_func(PARROT_INTERP, SerializationReader *reader);
static PMC * read_array_var(PARROT_INTERP, SerializationReader *reader) {
- PMC *result = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
+ PMC *result = Parrot_pmc_new(interp, ownedrpa_id);
Parrot_Int4 elems, i;
/* Read the element count. */
@@ -1135,6 +1141,9 @@ static PMC * read_array_var(PARROT_INTERP, SerializationReader *reader) {
for (i = 0; i < elems; i++)
VTABLE_set_pmc_keyed_int(interp, result, i, read_ref_func(interp, reader));
+ /* Set the owner. */
+ PARROT_OWNEDRESIZABLEPMCARRAY(result)->owner = reader->cur_object;
+
return result;
}
@@ -1735,6 +1744,7 @@ void Serialization_deserialize(PARROT_INTERP, PMC *sc, PMC *string_heap, PMC *st
/* Other init. */
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
ownedhash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));
+ ownedrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedResizablePMCArray", 0));
/* Read header and disect the data into its parts. */
check_and_disect_input(interp, reader, data);
View
228 src/pmc/ownedresizablepmcarray.pmc
@@ -0,0 +1,228 @@
+/* Represents a ResizablePMCArray that is owned by a serialization context.
+ * If it gets modified, we need to trigger the SC write barrier. */
+
+#include "../6model/sixmodelobject.h"
+
+pmclass OwnedResizablePMCArray extends ResizablePMCArray auto_attrs dynpmc group nqp {
+ /* The object that owns this RPA. */
+ ATTR PMC *owner;
+
+ VTABLE void set_integer_keyed(PMC* key, INTVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_integer_keyed_str(STRING* key, INTVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+
+ VTABLE void set_number_keyed(PMC* key, FLOATVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_number_keyed_str(STRING* key, FLOATVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+
+ VTABLE void set_string_keyed(PMC* key, STRING* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_string_keyed_int(INTVAL key, STRING* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_string_keyed_str(STRING* key, STRING* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+
+ VTABLE void set_pmc_keyed(PMC* key, PMC* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_pmc_keyed_int(INTVAL key, PMC* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+ VTABLE void set_pmc_keyed_str(STRING* key, PMC* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(key, value);
+ }
+
+ VTABLE INTVAL pop_integer() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+ VTABLE FLOATVAL pop_float() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+ VTABLE STRING* pop_string() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+ VTABLE PMC* pop_pmc() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+
+ VTABLE void push_integer(INTVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+ VTABLE void push_float(FLOATVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+ VTABLE void push_string(STRING* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+ VTABLE void push_pmc(PMC* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+
+ VTABLE INTVAL shift_integer() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+ VTABLE FLOATVAL shift_float() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+ VTABLE STRING* shift_string() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+ VTABLE PMC* shift_pmc() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ return SUPER();
+ }
+
+ VTABLE void unshift_integer(INTVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+ VTABLE void unshift_float(FLOATVAL value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+ VTABLE void unshift_string(STRING* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+ VTABLE void unshift_pmc(PMC* value) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value);
+ }
+
+ void splice(PMC* value, INTVAL offset, INTVAL count) {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ if (!PMC_IS_NULL(owner))
+ OBJ_SC_WRITE_BARRIER(owner);
+ SUPER(value, offset, count);
+ }
+
+ VTABLE void mark() {
+ PMC *owner;
+ GET_ATTR_owner(interp, SELF, owner);
+ Parrot_gc_mark_PMC_alive(INTERP, owner);
+ SUPER();
+ }
+}
View
4 tools/build/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2011, The Perl Foundation.
+# Copyright (C) 2006-2012, The Perl Foundation.
# $Id$
PARROT_ARGS =
@@ -173,7 +173,7 @@ DYNOPS = $(OPS_DIR)/$(OPS)$(LOAD_EXT)
PMC_SOURCES = $(PMC_DIR)/stable.pmc $(PMC_DIR)/sixmodelobject.pmc \
$(PMC_DIR)/dispatchersub.pmc $(PMC_DIR)/nqplexinfo.pmc \
$(PMC_DIR)/nqplexpad.pmc $(PMC_DIR)/serializationcontext.pmc \
- $(PMC_DIR)/ownedhash.pmc \
+ $(PMC_DIR)/ownedhash.pmc $(PMC_DIR)/ownedresizablepmcarray.pmc \
OPS_SOURCE = nqp.ops

No commit comments for this range

Something went wrong with that request. Please try again.