Skip to content

Commit

Permalink
better property names for gc roots
Browse files Browse the repository at this point in the history
  • Loading branch information
vilterp committed Sep 24, 2021
1 parent d4cf50f commit e9960d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/gc-heap-snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ void record_node_to_gc_snapshot(jl_value_t *a) JL_NOTSAFEPOINT {
g_snapshot->nodes.push_back(from_node);
}

void _gc_heap_snapshot_record_root(jl_value_t *root) {
void _gc_heap_snapshot_record_root(jl_value_t *root, char *name) {
record_node_to_gc_snapshot(root);

// TODO: just make record_node_to_gc_snapshot return this
auto to_node_idx = g_snapshot->node_ptr_to_index_map[root];

auto &internal_root = g_snapshot->nodes.front();
auto edge_type = g_snapshot->edge_types.find_or_create_string_id("internal");
auto edge_label = g_snapshot->names.find_or_create_string_id("internal_root to root");
auto edge_label = g_snapshot->names.find_or_create_string_id(name);

internal_root.edges.push_back(Edge{
edge_type,
Expand Down
6 changes: 3 additions & 3 deletions src/gc-heap-snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
// ---------------------------------------------------------------------
// Functions to call from GC when heap snapshot is enabled
// ---------------------------------------------------------------------
void _gc_heap_snapshot_record_root(jl_value_t *root);
void _gc_heap_snapshot_record_root(jl_value_t *root, char *name);
void _gc_heap_snapshot_record_array_edge(jl_value_t *from, jl_value_t *to, size_t index) JL_NOTSAFEPOINT;
void _gc_heap_snapshot_record_module_edge(jl_module_t *from, jl_value_t *to, char *name) JL_NOTSAFEPOINT;
void _gc_heap_snapshot_record_object_edge(jl_value_t *from, jl_value_t *to, size_t field_index) JL_NOTSAFEPOINT;
Expand All @@ -26,9 +26,9 @@ void _gc_heap_snapshot_record_hidden_edge(jl_value_t *from, size_t bytes) JL_NOT

extern int gc_heap_snapshot_enabled;

static inline void gc_heap_snapshot_record_root(jl_value_t *root) JL_NOTSAFEPOINT {
static inline void gc_heap_snapshot_record_root(jl_value_t *root, char *name) JL_NOTSAFEPOINT {
if (__unlikely(gc_heap_snapshot_enabled)) {
_gc_heap_snapshot_record_root(root);
_gc_heap_snapshot_record_root(root, name);
}
}
static inline void gc_heap_snapshot_record_array_edge(jl_value_t *from, jl_value_t *to, size_t index) JL_NOTSAFEPOINT {
Expand Down
8 changes: 4 additions & 4 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ static void mark_roots(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp)
{
// modules
gc_mark_queue_obj(gc_cache, sp, jl_main_module);
gc_heap_snapshot_record_root(jl_main_module);
gc_heap_snapshot_record_root(jl_main_module, "main_module");

// tasks
// TODO: add tasks as roots
Expand All @@ -2834,20 +2834,20 @@ static void mark_roots(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp)
for (size_t i = 0; i < jl_current_modules.size; i += 2) {
if (jl_current_modules.table[i + 1] != HT_NOTFOUND) {
gc_mark_queue_obj(gc_cache, sp, jl_current_modules.table[i]);
gc_heap_snapshot_record_root(jl_current_modules.table[i]);
gc_heap_snapshot_record_root(jl_current_modules.table[i], "current_module");
}
}
gc_mark_queue_obj(gc_cache, sp, jl_anytuple_type_type);
for (size_t i = 0; i < N_CALL_CACHE; i++) {
jl_typemap_entry_t *v = jl_atomic_load_relaxed(&call_cache[i]);
if (v != NULL) {
gc_mark_queue_obj(gc_cache, sp, v);
gc_heap_snapshot_record_root(v);
gc_heap_snapshot_record_root(v, "type_map");
}
}
if (jl_all_methods != NULL) {
gc_mark_queue_obj(gc_cache, sp, jl_all_methods);
gc_heap_snapshot_record_root(jl_all_methods);
gc_heap_snapshot_record_root(jl_all_methods, "all_methods");
}
if (_jl_debug_method_invalidation != NULL)
gc_mark_queue_obj(gc_cache, sp, _jl_debug_method_invalidation);
Expand Down

0 comments on commit e9960d5

Please sign in to comment.