/home/travis/build/MoarVM/MoarVM/src/6model/reprs/MVMAsyncTask.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include "moar.h" |
2 | | |
3 | | /* This representation's function pointer table. */ |
4 | | static const MVMREPROps MVMAsyncTask_this_repr; |
5 | | |
6 | | /* Creates a new type object of this representation, and associates it with |
7 | | * the given HOW. */ |
8 | 144 | static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) { |
9 | 144 | MVMSTable *st = MVM_gc_allocate_stable(tc, &MVMAsyncTask_this_repr, HOW); |
10 | 144 | |
11 | 144 | MVMROOT(tc, st, { |
12 | 144 | MVMObject *obj = MVM_gc_allocate_type_object(tc, st); |
13 | 144 | MVM_ASSIGN_REF(tc, &(st->header), st->WHAT, obj); |
14 | 144 | st->size = sizeof(MVMAsyncTask); |
15 | 144 | }); |
16 | 144 | |
17 | 144 | return st->WHAT; |
18 | 144 | } |
19 | | |
20 | | /* Copies the body of one object to another. */ |
21 | 0 | static void copy_to(MVMThreadContext *tc, MVMSTable *st, void *src, MVMObject *dest_root, void *dest) { |
22 | 0 | MVM_exception_throw_adhoc(tc, "Cannot copy object with repr MVMAsyncTask"); |
23 | 0 | } |
24 | | |
25 | 0 | static void deserialize_stable_size(MVMThreadContext *tc, MVMSTable *st, MVMSerializationReader *reader) { |
26 | 0 | st->size = sizeof(MVMAsyncTask); |
27 | 0 | } |
28 | | |
29 | | /* Called by the VM to mark any GCable items. */ |
30 | 0 | static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorklist *worklist) { |
31 | 0 | MVMAsyncTaskBody *task = (MVMAsyncTaskBody *)data; |
32 | 0 | MVM_gc_worklist_add(tc, worklist, &task->queue); |
33 | 0 | MVM_gc_worklist_add(tc, worklist, &task->schedulee); |
34 | 0 | MVM_gc_worklist_add(tc, worklist, &task->cancel_notify_queue); |
35 | 0 | MVM_gc_worklist_add(tc, worklist, &task->cancel_notify_schedulee); |
36 | 0 | if (task->ops && task->ops->gc_mark) |
37 | 0 | task->ops->gc_mark(tc, task->data, worklist); |
38 | 0 | } |
39 | | |
40 | | /* Called by the VM in order to free memory associated with this object. */ |
41 | 0 | static void gc_free(MVMThreadContext *tc, MVMObject *obj) { |
42 | 0 | MVMAsyncTask *task = (MVMAsyncTask *)obj; |
43 | 0 | if (task->body.ops && task->body.ops->gc_free) |
44 | 0 | task->body.ops->gc_free(tc, obj, task->body.data); |
45 | 0 | } |
46 | | |
47 | | static const MVMStorageSpec storage_spec = { |
48 | | MVM_STORAGE_SPEC_REFERENCE, /* inlineable */ |
49 | | 0, /* bits */ |
50 | | 0, /* align */ |
51 | | MVM_STORAGE_SPEC_BP_NONE, /* boxed_primitive */ |
52 | | 0, /* can_box */ |
53 | | 0, /* is_unsigned */ |
54 | | }; |
55 | | |
56 | | |
57 | | /* Gets the storage specification for this representation. */ |
58 | 0 | static const MVMStorageSpec * get_storage_spec(MVMThreadContext *tc, MVMSTable *st) { |
59 | 0 | return &storage_spec; |
60 | 0 | } |
61 | | |
62 | | /* Compose the representation. */ |
63 | 0 | static void compose(MVMThreadContext *tc, MVMSTable *st, MVMObject *info) { |
64 | 0 | /* Nothing to do for this REPR. */ |
65 | 0 | } |
66 | | |
67 | | /* Initializes the representation. */ |
68 | 144 | const MVMREPROps * MVMAsyncTask_initialize(MVMThreadContext *tc) { |
69 | 144 | return &MVMAsyncTask_this_repr; |
70 | 144 | } |
71 | | |
72 | | static const MVMREPROps MVMAsyncTask_this_repr = { |
73 | | type_object_for, |
74 | | MVM_gc_allocate_object, |
75 | | NULL, /* initialize */ |
76 | | copy_to, |
77 | | MVM_REPR_DEFAULT_ATTR_FUNCS, |
78 | | MVM_REPR_DEFAULT_BOX_FUNCS, |
79 | | MVM_REPR_DEFAULT_POS_FUNCS, |
80 | | MVM_REPR_DEFAULT_ASS_FUNCS, |
81 | | MVM_REPR_DEFAULT_ELEMS, |
82 | | get_storage_spec, |
83 | | NULL, /* change_type */ |
84 | | NULL, /* serialize */ |
85 | | NULL, /* deserialize */ |
86 | | NULL, /* serialize_repr_data */ |
87 | | NULL, /* deserialize_repr_data */ |
88 | | deserialize_stable_size, |
89 | | gc_mark, |
90 | | gc_free, |
91 | | NULL, /* gc_cleanup */ |
92 | | NULL, /* gc_mark_repr_data */ |
93 | | NULL, /* gc_free_repr_data */ |
94 | | compose, |
95 | | NULL, /* spesh */ |
96 | | "AsyncTask", /* name */ |
97 | | MVM_REPR_ID_MVMAsyncTask, |
98 | | NULL, /* unmanaged_size */ |
99 | | NULL, /* describe_refs */ |
100 | | }; |