-
-
Save FROGGS/94c223c9d26c2e12a52b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/6model/reprs/CPPStruct.c:270 compute_allocation_strategy i=0 has CPointer | |
src/6model/reprs/CPPStruct.c:169 compute_allocation_strategy i=1 has int8 | |
src/6model/reprs/CPPStruct.c:169 compute_allocation_strategy i=2 has num32 | |
src/6model/reprs/CPPStruct.c:236 compute_allocation_strategy i=3 HAS CStruct | |
src/6model/reprs/CPPStruct.c:209 compute_allocation_strategy i=4 HAS CArray[8] | |
src/6model/reprs/CPPStruct.c:209 compute_allocation_strategy i=5 HAS CArray[8] | |
src/6model/reprs/CPPStruct.c:169 compute_allocation_strategy i=6 has int32 | |
WARNINGS for /home/froggs/dev/p6-Box2D/lib/Box2D/PolygonShape.pm: | |
Useless use of constant value b2_maxPolygonVertices in sink context (lines 15, 16) | |
src/6model/reprs/CPPStruct.c:405 initialize child_objs[4=>2]=0x7f942ff5ad88 | |
src/6model/reprs/CPPStruct.c:405 initialize child_objs[5=>3]=0x7f942ff5adc0 | |
8 | |
src/6model/reprs/CArray.c:187 expand min_size=8 body->managed=1 | |
src/6model/reprs/CPPStruct.c:585 bind_attribute child_objs[4=>2]=0x7f942ff5c910 | |
8 | |
src/6model/reprs/CArray.c:187 expand min_size=8 body->managed=1 | |
src/6model/reprs/CPPStruct.c:585 bind_attribute child_objs[5=>3]=0x7f942ff634f8 | |
src/6model/reprs/CPPStruct.c:679 gc_mark | |
src/6model/reprs/CPPStruct.c:681 gc_mark child_objs[0]=(nil) | |
src/6model/reprs/CPPStruct.c:681 gc_mark child_objs[1]=(nil) | |
src/6model/reprs/CPPStruct.c:681 gc_mark child_objs[2]=0x7f942ff5c910 | |
src/6model/reprs/CPPStruct.c:681 gc_mark child_objs[3]=0x7f942ff634f8 | |
*** Error in `/home/froggs/dev/nqp/install/bin/moar': free(): invalid pointer: 0x00000000056de848 *** | |
Abgebrochen (Speicherabzug geschrieben) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/6model/bootstrap.c b/src/6model/bootstrap.c | |
index 0add51b..26f7ba4 100644 | |
--- a/src/6model/bootstrap.c | |
+++ b/src/6model/bootstrap.c | |
@@ -570,6 +570,7 @@ static void string_consts(MVMThreadContext *tc) { | |
string_creator(dimensions, "dimensions"); | |
string_creator(ready, "ready"); | |
string_creator(multidim, "multidim"); | |
+ string_creator(shape, "shape"); | |
} | |
/* Drives the overall bootstrap process. */ | |
diff --git a/src/6model/reprs/CArray.c b/src/6model/reprs/CArray.c | |
index 6f29534..31bc9f3 100644 | |
--- a/src/6model/reprs/CArray.c | |
+++ b/src/6model/reprs/CArray.c | |
@@ -82,7 +82,8 @@ static void initialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, voi | |
if (!repr_data) | |
MVM_exception_throw_adhoc(tc, "CArray type must be composed before use"); | |
- body->storage = MVM_calloc(4, repr_data->elem_size); | |
+ if (!body->storage) | |
+ body->storage = MVM_calloc(4, repr_data->elem_size); | |
body->managed = 1; | |
/* Don't need child_objs for numerics. */ | |
diff --git a/src/6model/reprs/CPPStruct.c b/src/6model/reprs/CPPStruct.c | |
index 230b51d..3387225 100644 | |
--- a/src/6model/reprs/CPPStruct.c | |
+++ b/src/6model/reprs/CPPStruct.c | |
@@ -149,6 +149,13 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in | |
MVMint64 inlined = !MVM_is_null(tc, inlined_val) && MVM_repr_get_int(tc, inlined_val); | |
MVMint32 bits = sizeof(void *) * 8; | |
MVMint32 align = ALIGNOF(void *); | |
+ MVMObject *shape_val = MVM_repr_at_key_o(tc, attr, tc->instance->str_consts.shape); | |
+ MVMint64 shape = 0; | |
+ | |
+ if (!MVM_is_null(tc, shape_val) && REPR(shape_val)->name, REPR(shape_val)->ID == MVM_REPR_ID_MVMArray) { | |
+ shape = MVM_repr_at_pos_i(tc, shape_val, 0); | |
+ } | |
+ | |
if (!MVM_is_null(tc, type)) { | |
/* See if it's a type that we know how to handle in a C struct. */ | |
const MVMStorageSpec *spec = REPR(type)->get_storage_spec(tc, STABLE(type)); | |
@@ -188,9 +195,26 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in | |
} | |
else if (type_id == MVM_REPR_ID_MVMCArray) { | |
/* It's a CArray of some kind. */ | |
+ MVMCArrayREPRData *carray_repr_data = (MVMCArrayREPRData *)STABLE(type)->REPR_data; | |
repr_data->num_child_objs++; | |
repr_data->attribute_locations[i] = (cur_obj_attr++ << MVM_CPPSTRUCT_ATTR_SHIFT) | MVM_CPPSTRUCT_ATTR_CARRAY; | |
repr_data->member_types[i] = type; | |
+ repr_data->flattened_stables[i] = STABLE(type); | |
+ if (inlined) { | |
+ bits = carray_repr_data->elem_size * 8 * shape; | |
+ //~ align = carray_repr_data->struct_align; | |
+ repr_data->attribute_locations[i] |= MVM_CPPSTRUCT_ATTR_INLINED; | |
+ if (REPR(type)->initialize) { | |
+ if (!repr_data->initialize_slots) | |
+ repr_data->initialize_slots = (MVMint32 *) MVM_calloc(info_alloc + 1, sizeof(MVMint32)); | |
+ repr_data->initialize_slots[cur_init_slot] = i; | |
+ cur_init_slot++; | |
+ } | |
+ } | |
+ else { | |
+ bits = carray_repr_data->elem_size * 8 * shape; | |
+ //~ align = spec->align; | |
+ } | |
} | |
else if (type_id == MVM_REPR_ID_MVMCStruct) { | |
/* It's a CStruct. */ | |
@@ -345,11 +369,33 @@ static void initialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, voi | |
/* Initialize the slots. */ | |
if (repr_data->initialize_slots) { | |
MVMint32 i; | |
+ | |
+ MVM_gc_root_temp_push(tc, (MVMCollectable **)&root); | |
+ MVM_gc_root_temp_push(tc, (MVMCollectable **)&repr_data); | |
+ MVM_gc_root_temp_push(tc, (MVMCollectable **)&body); | |
+ | |
for (i = 0; repr_data->initialize_slots[i] >= 0; i++) { | |
- MVMint32 offset = repr_data->struct_offsets[repr_data->initialize_slots[i]]; | |
- MVMSTable *st = repr_data->flattened_stables[repr_data->initialize_slots[i]]; | |
- st->REPR->initialize(tc, st, root, (char *)body->cppstruct + offset); | |
+ MVMint32 slot = repr_data->initialize_slots[i]; | |
+ MVMint32 offset = repr_data->struct_offsets[slot]; | |
+ MVMSTable *st = repr_data->flattened_stables[slot]; | |
+ MVMObject *type = repr_data->member_types[slot]; | |
+ MVMint32 type_id = REPR(type)->ID; | |
+ | |
+ MVM_gc_root_temp_push(tc, (MVMCollectable **)&st); | |
+ MVM_gc_root_temp_push(tc, (MVMCollectable **)&type); | |
+ | |
+ if (type_id == MVM_REPR_ID_MVMCArray) { | |
+ MVMint32 real_slot = repr_data->attribute_locations[slot] >> MVM_CSTRUCT_ATTR_SHIFT; | |
+ MVMObject *obj = MVM_nativecall_make_carray(tc, type, (char *)body->cppstruct + offset); | |
+ MVMCArrayBody *carray_body = (MVMCArrayBody *)OBJECT_BODY(obj); | |
+ carray_body->elems = 4; // XXX shape; | |
+ MVM_ASSIGN_REF(tc, &(root->header), body->child_objs[real_slot], obj); | |
+ st->REPR->initialize(tc, st, obj, carray_body); | |
+ } | |
+ | |
+ MVM_gc_root_temp_pop_n(tc, 2); | |
} | |
+ MVM_gc_root_temp_pop_n(tc, 3); | |
} | |
} | |
@@ -399,13 +445,18 @@ static void get_attribute(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, | |
else { | |
MVMObject *typeobj = repr_data->member_types[slot]; | |
MVMObject *obj = body->child_objs[real_slot]; | |
+ | |
if (!obj) { | |
/* No cached object. */ | |
void *cobj = get_ptr_at_offset(body->cppstruct, repr_data->struct_offsets[slot]); | |
if (cobj) { | |
MVMObject **child_objs = body->child_objs; | |
if (type == MVM_CPPSTRUCT_ATTR_CARRAY) { | |
- obj = MVM_nativecall_make_carray(tc, typeobj, cobj); | |
+ if (repr_data->attribute_locations[slot] & MVM_CPPSTRUCT_ATTR_INLINED) | |
+ obj = MVM_nativecall_make_carray(tc, typeobj, | |
+ (char *)body->cppstruct + repr_data->struct_offsets[slot]); | |
+ else | |
+ obj = MVM_nativecall_make_carray(tc, typeobj, cobj); | |
} | |
else if(type == MVM_CPPSTRUCT_ATTR_CSTRUCT) { | |
if (repr_data->attribute_locations[slot] & MVM_CPPSTRUCT_ATTR_INLINED) | |
diff --git a/src/core/instance.h b/src/core/instance.h | |
index 63531bd..1ee94a8 100644 | |
--- a/src/core/instance.h | |
+++ b/src/core/instance.h | |
@@ -75,6 +75,7 @@ struct MVMStringConsts { | |
MVMString *dimensions; | |
MVMString *ready; | |
MVMString *multidim; | |
+ MVMString *shape; | |
}; | |
/* An entry in the representations registry. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment