ocaml style rooting macros
This commit is contained in:
@@ -1092,6 +1092,7 @@ struct JSContext {
|
||||
|
||||
JSGCRef *top_gc_ref; /* used to reference temporary GC roots (stack top) */
|
||||
JSGCRef *last_gc_ref; /* used to reference temporary GC roots (list) */
|
||||
JSLocalRef *top_local_ref; /* for JS_LOCAL macro - GC updates C locals through pointers */
|
||||
CCallRoot *c_call_root; /* stack of auto-rooted C call argv arrays */
|
||||
|
||||
int class_count; /* size of class_array and class_proto */
|
||||
@@ -1185,7 +1186,15 @@ static int ctx_gc (JSContext *ctx, int allow_grow, size_t alloc_size);
|
||||
|
||||
/* Helper to check if a pointer is in constant text pool memory */
|
||||
static inline int is_ct_ptr (JSContext *ctx, void *ptr) {
|
||||
return (uint8_t *)ptr >= ctx->ct_base && (uint8_t *)ptr < ctx->ct_end;
|
||||
uint8_t *p = (uint8_t *)ptr;
|
||||
if (p >= ctx->ct_base && p < ctx->ct_end) return 1;
|
||||
/* Also check overflow pages */
|
||||
CTPage *page = (CTPage *)ctx->ct_pages;
|
||||
while (page) {
|
||||
if (p >= page->data && p < page->data + page->size) return 1;
|
||||
page = page->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HEAP_CHECK
|
||||
|
||||
Reference in New Issue
Block a user