3 #include "sgen-protocol.h"
5 /* If not null, dump binary protocol to this file */
6 static FILE *binary_protocol_file = NULL;
8 #define BINARY_PROTOCOL_BUFFER_SIZE 65536
10 static unsigned char binary_protocol_buffer [BINARY_PROTOCOL_BUFFER_SIZE];
11 static int binary_protocol_buffer_index = 0;
14 flush_binary_protocol_buffer (void)
16 if (!binary_protocol_file)
18 if (binary_protocol_buffer_index == 0)
21 fwrite (binary_protocol_buffer, 1, binary_protocol_buffer_index, binary_protocol_file);
22 fflush (binary_protocol_file);
24 binary_protocol_buffer_index = 0;
28 protocol_entry (unsigned char type, gpointer data, int size)
30 if (!binary_protocol_file)
32 if (binary_protocol_buffer_index + 1 + size > BINARY_PROTOCOL_BUFFER_SIZE)
33 flush_binary_protocol_buffer ();
35 binary_protocol_buffer [binary_protocol_buffer_index++] = type;
36 memcpy (binary_protocol_buffer + binary_protocol_buffer_index, data, size);
37 binary_protocol_buffer_index += size;
39 g_assert (binary_protocol_buffer_index <= BINARY_PROTOCOL_BUFFER_SIZE);
43 binary_protocol_collection (int generation)
45 SGenProtocolCollection entry = { generation };
46 flush_binary_protocol_buffer ();
47 protocol_entry (SGEN_PROTOCOL_COLLECTION, &entry, sizeof (SGenProtocolCollection));
51 binary_protocol_alloc (gpointer obj, gpointer vtable, int size)
53 SGenProtocolAlloc entry = { obj, vtable, size };
54 protocol_entry (SGEN_PROTOCOL_ALLOC, &entry, sizeof (SGenProtocolAlloc));
58 binary_protocol_copy (gpointer from, gpointer to, gpointer vtable, int size)
60 SGenProtocolCopy entry = { from, to, vtable, size };
61 protocol_entry (SGEN_PROTOCOL_COPY, &entry, sizeof (SGenProtocolCopy));
65 binary_protocol_pin (gpointer obj, gpointer vtable, int size)
67 SGenProtocolPin entry = { obj, vtable, size };
68 protocol_entry (SGEN_PROTOCOL_PIN, &entry, sizeof (SGenProtocolPin));
72 binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable)
74 SGenProtocolWBarrier entry = { ptr, value, value_vtable };
75 protocol_entry (SGEN_PROTOCOL_WBARRIER, &entry, sizeof (SGenProtocolWBarrier));
79 binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable)
81 SGenProtocolGlobalRemset entry = { ptr, value, value_vtable };
82 protocol_entry (SGEN_PROTOCOL_GLOBAL_REMSET, &entry, sizeof (SGenProtocolGlobalRemset));
86 binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size)
88 SGenProtocolPtrUpdate entry = { ptr, old_value, new_value, vtable, size };
89 protocol_entry (SGEN_PROTOCOL_PTR_UPDATE, &entry, sizeof (SGenProtocolPtrUpdate));
93 binary_protocol_cleanup (gpointer ptr, gpointer vtable, int size)
95 SGenProtocolCleanup entry = { ptr, vtable, size };
96 protocol_entry (SGEN_PROTOCOL_CLEANUP, &entry, sizeof (SGenProtocolCleanup));
100 binary_protocol_empty (gpointer start, int size)
102 SGenProtocolEmpty entry = { start, size };
103 protocol_entry (SGEN_PROTOCOL_EMPTY, &entry, sizeof (SGenProtocolEmpty));
107 binary_protocol_thread_restart (gpointer thread)
109 SGenProtocolThreadRestart entry = { thread };
110 protocol_entry (SGEN_PROTOCOL_THREAD_RESTART, &entry, sizeof (SGenProtocolThreadRestart));
115 binary_protocol_thread_register (gpointer thread)
117 SGenProtocolThreadRegister entry = { thread };
118 protocol_entry (SGEN_PROTOCOL_THREAD_REGISTER, &entry, sizeof (SGenProtocolThreadRegister));
123 binary_protocol_thread_unregister (gpointer thread)
125 SGenProtocolThreadUnregister entry = { thread };
126 protocol_entry (SGEN_PROTOCOL_THREAD_UNREGISTER, &entry, sizeof (SGenProtocolThreadUnregister));
131 binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset, gpointer value, gpointer value_vtable, int value_pinned)
133 SGenProtocolMissingRemset entry = { obj, obj_vtable, offset, value, value_vtable, value_pinned };
134 protocol_entry (SGEN_PROTOCOL_MISSING_REMSET, &entry, sizeof (SGenProtocolMissingRemset));
140 #define binary_protocol_collection(generation)
141 #define binary_protocol_alloc(obj, vtable, size)
142 #define binary_protocol_copy(from, to, vtable, size)
143 #define binary_protocol_pin(obj, vtable, size)
144 #define binary_protocol_wbarrier(ptr, value, value_vtable)
145 #define binary_protocol_global_remset(ptr, value, value_vtable)
146 #define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
147 #define binary_protocol_cleanup(ptr, vtable, size)
148 #define binary_protocol_empty(start, size)
149 #define binary_protocol_thread_restart(thread)
150 #define binary_protocol_thread_register(thread)
151 #define binary_protocol_thread_unregister(thread)
152 #define binary_protocol_missing_remset(obj, obj_vtable, offset, value, value_vtable, value_pinned)