@@ -43,6 +43,26 @@ static INTVAL nqpdebflags_i = 0;
43
43
* may have multiple on the go due to compiling nested module dependencies. */
44
44
PMC *compiling_scs = NULL;
45
45
46
+ /* SC write barrier for objects. */
47
+ static void SC_write_barrier_obj(PARROT_INTERP, PMC *obj) {
48
+ if (VTABLE_get_bool(interp, compiling_scs)) {
49
+ if (VTABLE_get_pmc_keyed_int(interp, compiling_scs, 0) != SC_PMC(obj)) {
50
+ printf("SC OBJECT WRITE BARRIER HIT (%s)\n",
51
+ Parrot_str_cstring(interp, VTABLE_name(interp, obj)));
52
+ }
53
+ }
54
+ }
55
+
56
+ /* SC write barrier for STables. */
57
+ static void SC_write_barrier_st(PARROT_INTERP, STable *st) {
58
+ if (VTABLE_get_bool(interp, compiling_scs)) {
59
+ if (VTABLE_get_pmc_keyed_int(interp, compiling_scs, 0) != st->sc) {
60
+ printf("SC STABLE WRITE BARRIER HIT (%s)\n",
61
+ Parrot_str_cstring(interp, VTABLE_name(interp, st->WHAT)));
62
+ }
63
+ }
64
+ }
65
+
46
66
END_OPS_PREAMBLE
47
67
48
68
/*
@@ -56,7 +76,7 @@ Does various setup tasks for the benefit of the other dynops.
56
76
*/
57
77
inline op nqp_dynop_setup() :base_core {
58
78
if (!initialized) {
59
- initialized = 1 ;
79
+ PMC *obj_sc_barrier, *st_sc_barrier ;
60
80
61
81
/* Look up and cache some type IDs. */
62
82
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
@@ -69,6 +89,20 @@ inline op nqp_dynop_setup() :base_core {
69
89
/* Initialize compiling SCs list. */
70
90
compiling_scs = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
71
91
Parrot_pmc_gc_register(interp, compiling_scs);
92
+
93
+ /* Set up write barrier functions. */
94
+ /* XXX Really want a better, cheaper place to put them... */
95
+ obj_sc_barrier = Parrot_pmc_new(interp, enum_class_Pointer);
96
+ VTABLE_set_pointer(interp, obj_sc_barrier, SC_write_barrier_obj);
97
+ VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
98
+ Parrot_str_new_constant(interp, "_OBJ_SC_BARRIER"), obj_sc_barrier);
99
+ st_sc_barrier = Parrot_pmc_new(interp, enum_class_Pointer);
100
+ VTABLE_set_pointer(interp, st_sc_barrier, SC_write_barrier_st);
101
+ VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
102
+ Parrot_str_new_constant(interp, "_ST_SC_BARRIER"), st_sc_barrier);
103
+
104
+ /* Mark initialized. */
105
+ initialized = 1;
72
106
}
73
107
}
74
108
0 commit comments