Skip to content

Commit c3f4075

Browse files
committed
Move hpy_trace_get_ctx to hpy_jni.c
1 parent 11014ff commit c3f4075

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

graalpython/com.oracle.graal.python.jni/src/hpy_jni.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ CUSTOM_UPCALLS
9797
#undef UPCALL
9898

9999
static jmethodID jniMethod_hpy_debug_get_context;
100+
static jmethodID jniMethod_hpy_trace_get_context;
100101

101102

102103
#define MAX_UNCLOSED_HANDLES 32
@@ -408,6 +409,12 @@ CUSTOM_UPCALLS
408409
return PTR_UP(NULL);
409410
}
410411

412+
jniMethod_hpy_trace_get_context = (*env)->GetMethodID(env, clazz, "getHPyTraceContext", "()" SIG_PTR);
413+
if (jniMethod_hpy_trace_get_context == NULL) {
414+
LOGS("ERROR: jni method getHPyTraceContext not found found !\n");
415+
return PTR_UP(NULL);
416+
}
417+
411418
return PTR_UP(ctx);
412419
}
413420

@@ -479,3 +486,13 @@ HPyContext * hpy_debug_get_ctx(HPyContext *uctx)
479486
}
480487
return dctx;
481488
}
489+
490+
HPyContext * hpy_trace_get_ctx(HPyContext *uctx)
491+
{
492+
HPyContext *tctx = (HPyContext *) DO_UPCALL_PTR_NOARGS(CONTEXT_INSTANCE(uctx), hpy_trace_get_context);
493+
if (uctx == tctx) {
494+
HPy_FatalError(uctx, "hpy_trace_get_ctx: expected an universal ctx, "
495+
"got a trace ctx");
496+
}
497+
return tctx;
498+
}

graalpython/com.oracle.graal.python.jni/src/trace/trace_ctx.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ int hpy_trace_ctx_free(HPyContext *tctx)
4242
return 0;
4343
}
4444

45-
HPyContext * hpy_trace_get_ctx(HPyContext *uctx)
46-
{
47-
HPyContext *tctx = &g_trace_ctx;
48-
if (uctx == tctx) {
49-
HPy_FatalError(uctx, "hpy_trace_get_ctx: expected an universal ctx, "
50-
"got a trace ctx");
51-
}
52-
if (hpy_trace_ctx_init(tctx, uctx) < 0)
53-
return NULL;
54-
return tctx;
55-
}
56-
5745
void hpy_trace_set_ctx(HPyContext *tctx)
5846
{
5947
g_trace_ctx = *tctx;

0 commit comments

Comments
 (0)