Skip to content

Commit 5180f3b

Browse files
committed
call pin function on AST ctx
1 parent 2b68949 commit 5180f3b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/ast.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ typedef struct _jl_ast_context_t {
139139
arraylist_t pinned_objects;
140140
} jl_ast_context_t;
141141

142+
// FIXME: Ugly hack to get a pointer to the pinned objects
143+
arraylist_t *extract_pinned_objects_from_ast_ctx(void *ctx)
144+
{
145+
// This is used to extract pinned objects from the context
146+
// for the purpose of pinning them in MMTk.
147+
if (ctx == NULL)
148+
return NULL;
149+
jl_ast_context_t *jl_ctx = (jl_ast_context_t*)ctx;
150+
return &jl_ctx->pinned_objects;
151+
}
152+
142153
static jl_ast_context_t jl_ast_main_ctx;
143154

144155
#ifdef __clang_gcanalyzer__

src/gc-mmtk.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ void gc_pin_objects_from_compiler_frontend(arraylist_t *objects_pinned_by_call)
263263
arraylist_push(objects_pinned_by_call, obj);
264264
}
265265
}
266+
for (size_t i = 0; i < jl_ast_ctx_used.len; i++) {
267+
void *ctx = jl_ast_ctx_used.items[i];
268+
arraylist_t *pinned_objects = extract_pinned_objects_from_ast_ctx(ctx);
269+
for (size_t j = 0; j < pinned_objects->len; j++) {
270+
void *obj = pinned_objects->items[j];
271+
unsigned char got_pinned = mmtk_pin_object(obj);
272+
if (got_pinned) {
273+
arraylist_push(objects_pinned_by_call, obj);
274+
}
275+
}
276+
}
266277
}
267278

268279
void gc_unpin_objects_from_compiler_frontend(arraylist_t *objects_pinned_by_call)

src/julia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,7 @@ JL_DLLEXPORT void jl_register_newmeth_tracer(void (*callback)(jl_method_t *trace
24392439

24402440
// AST access
24412441
JL_DLLEXPORT jl_value_t *jl_copy_ast(jl_value_t *expr JL_MAYBE_UNROOTED);
2442+
arraylist_t *extract_pinned_objects_from_ast_ctx(void *ctx);
24422443
extern arraylist_t jl_ast_ctx_used;
24432444

24442445
// IR representation

0 commit comments

Comments
 (0)