@@ -124,7 +124,7 @@ HeapSnapshot *g_snapshot = nullptr;
124
124
extern jl_mutex_t heapsnapshot_lock;
125
125
126
126
void serialize_heap_snapshot (ios_t *stream, HeapSnapshot &snapshot, char all_one);
127
- static inline void _record_gc_edge (const char *node_type, const char * edge_type,
127
+ static inline void _record_gc_edge (const char *edge_type,
128
128
jl_value_t *a, jl_value_t *b, size_t name_or_index) JL_NOTSAFEPOINT;
129
129
void _record_gc_just_edge (const char *edge_type, Node &from_node, size_t to_idx, size_t name_or_idx) JL_NOTSAFEPOINT;
130
130
void _add_internal_root (HeapSnapshot *snapshot);
@@ -185,45 +185,56 @@ size_t record_node_to_gc_snapshot(jl_value_t *a) JL_NOTSAFEPOINT
185
185
186
186
// Insert a new Node
187
187
size_t self_size = 0 ;
188
- std::string type_name;
189
188
StringRef name = " <missing>" ;
190
189
StringRef node_type = " object" ;
191
190
192
191
jl_datatype_t *type = (jl_datatype_t *)jl_typeof (a);
193
192
194
193
if (jl_is_string (a)) {
195
- node_type = " string " ;
194
+ node_type = " String " ;
196
195
name = jl_string_data (a);
197
196
self_size = jl_string_len (a);
198
197
}
199
198
else if (jl_is_symbol (a)) {
200
- node_type = " symbol " ;
199
+ node_type = " jl_sym_t " ;
201
200
name = jl_symbol_name ((jl_sym_t *)a);
202
201
self_size = name.size ();
203
202
}
204
203
else if (jl_is_simplevector (a)) {
205
- node_type = " array " ;
204
+ node_type = " jl_svec_t " ;
206
205
name = " SimpleVector" ;
207
206
self_size = sizeof (jl_svec_t ) + sizeof (void *) * jl_svec_len (a);
208
207
}
209
208
else if (jl_is_module (a)) {
209
+ node_type = " jl_module_t" ;
210
210
name = jl_symbol_name_ (((_jl_module_t *)a)->name );
211
211
self_size = sizeof (jl_module_t );
212
212
}
213
213
else if (jl_is_task (a)) {
214
+ node_type = " jl_task_t" ;
214
215
name = " Task" ;
215
216
self_size = sizeof (jl_task_t );
216
217
}
217
218
else if (jl_is_datatype (a)) {
218
- type_name = string (" Type{" ) + string (jl_symbol_name_ (((_jl_datatype_t *)a)->name ->name )) + string (" }" );
219
- name = StringRef (type_name);
220
- self_size = sizeof (jl_task_t );
219
+ ios_need_close = 1 ;
220
+ ios_mem (&str_, 0 );
221
+ JL_STREAM* str = (JL_STREAM*)&str_;
222
+ jl_static_show (str, a);
223
+ name = StringRef ((const char *)str_.buf , str_.size );
224
+ node_type = " jl_datatype_t" ;
225
+ self_size = sizeof (jl_datatype_t );
226
+ }
227
+ else if (jl_is_array (a)){
228
+ ios_need_close = 1 ;
229
+ ios_mem (&str_, 0 );
230
+ JL_STREAM* str = (JL_STREAM*)&str_;
231
+ jl_static_show (str, (jl_value_t *)type);
232
+ name = StringRef ((const char *)str_.buf , str_.size );
233
+ node_type = " jl_array_t" ;
234
+ self_size = sizeof (jl_array_t );
221
235
}
222
236
else {
223
- self_size = jl_is_array_type (type)
224
- ? sizeof (jl_array_t )
225
- : (size_t )jl_datatype_size (type);
226
-
237
+ self_size = (size_t )jl_datatype_size (type);
227
238
// print full type into ios buffer and get StringRef to it.
228
239
// The ios is cleaned up below.
229
240
ios_need_close = 1 ;
@@ -371,13 +382,13 @@ void _gc_heap_snapshot_record_frame_to_frame_edge(jl_gcframe_t *from, jl_gcframe
371
382
372
383
void _gc_heap_snapshot_record_array_edge (jl_value_t *from, jl_value_t *to, size_t index) JL_NOTSAFEPOINT
373
384
{
374
- _record_gc_edge (" array " , " element" , from, to, index);
385
+ _record_gc_edge (" element" , from, to, index);
375
386
}
376
387
377
388
void _gc_heap_snapshot_record_object_edge (jl_value_t *from, jl_value_t *to, void *slot) JL_NOTSAFEPOINT
378
389
{
379
390
string path = _fieldpath_for_slot (from, slot);
380
- _record_gc_edge (" object " , " property" , from, to,
391
+ _record_gc_edge (" property" , from, to,
381
392
g_snapshot->names .find_or_create_string_id (path));
382
393
}
383
394
@@ -395,7 +406,6 @@ void _gc_heap_snapshot_record_module_to_binding(jl_module_t* module, jl_binding_
395
406
396
407
auto &from_node = g_snapshot->nodes [from_node_idx];
397
408
auto &to_node = g_snapshot->nodes [to_node_idx];
398
- from_node.type = g_snapshot->node_types .find_or_create_string_id (" object" );
399
409
400
410
_record_gc_just_edge (" property" , from_node, to_node_idx, g_snapshot->names .find_or_create_string_id (" <native>" ));
401
411
if (value_idx) _record_gc_just_edge (" internal" , to_node, value_idx, g_snapshot->names .find_or_create_string_id (" value" ));
@@ -405,7 +415,7 @@ void _gc_heap_snapshot_record_module_to_binding(jl_module_t* module, jl_binding_
405
415
406
416
void _gc_heap_snapshot_record_internal_array_edge (jl_value_t *from, jl_value_t *to) JL_NOTSAFEPOINT
407
417
{
408
- _record_gc_edge (" object " , " internal" , from, to,
418
+ _record_gc_edge (" internal" , from, to,
409
419
g_snapshot->names .find_or_create_string_id (" <internal>" ));
410
420
}
411
421
@@ -432,19 +442,17 @@ void _gc_heap_snapshot_record_hidden_edge(jl_value_t *from, void* to, size_t byt
432
442
}
433
443
auto to_node_idx = record_pointer_to_gc_snapshot (to, bytes, alloc_kind);
434
444
auto &from_node = g_snapshot->nodes [from_node_idx];
435
- from_node.type = g_snapshot->node_types .find_or_create_string_id (" native" );
436
445
437
446
_record_gc_just_edge (" hidden" , from_node, to_node_idx, name_or_idx);
438
447
}
439
448
440
- static inline void _record_gc_edge (const char *node_type, const char *edge_type ,
441
- jl_value_t *a, jl_value_t *b, size_t name_or_idx) JL_NOTSAFEPOINT
449
+ static inline void _record_gc_edge (const char *edge_type, jl_value_t *a ,
450
+ jl_value_t *b, size_t name_or_idx) JL_NOTSAFEPOINT
442
451
{
443
452
auto from_node_idx = record_node_to_gc_snapshot (a);
444
453
auto to_node_idx = record_node_to_gc_snapshot (b);
445
454
446
455
auto &from_node = g_snapshot->nodes [from_node_idx];
447
- from_node.type = g_snapshot->node_types .find_or_create_string_id (node_type);
448
456
449
457
_record_gc_just_edge (edge_type, from_node, to_node_idx, name_or_idx);
450
458
}
0 commit comments