From efdf568975cf38c2b711c3c9c6c2bb741bf89460 Mon Sep 17 00:00:00 2001 From: Timo Paulssen Date: Sun, 10 Feb 2019 12:12:49 +0100 Subject: [PATCH] Change CStruct For Compatibility With Native Call JIT Having the pointer to the actual data be first in the struct lets us handle a CStruct exactly like most other things in there. --- src/6model/reprs/CStruct.h | 6 +++--- src/core/nativecall.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/6model/reprs/CStruct.h b/src/6model/reprs/CStruct.h index 72386935cb..9e2bdc298f 100644 --- a/src/6model/reprs/CStruct.h +++ b/src/6model/reprs/CStruct.h @@ -19,13 +19,13 @@ * C-friendly bit of memory and a copy to the GC-able, 6model objects in * sync. */ struct MVMCStructBody { - /* GC-marked objects that our C structure points into. */ - MVMObject **child_objs; - /* Pointer to the actual C structure memory; we don't inline it * directly in the body, since it doesn't work so well if we get * something returned and are wrapping it. */ void *cstruct; + + /* GC-marked objects that our C structure points into. */ + MVMObject **child_objs; }; struct MVMCStruct { diff --git a/src/core/nativecall.c b/src/core/nativecall.c index 4f92eb7278..e7242f589a 100644 --- a/src/core/nativecall.c +++ b/src/core/nativecall.c @@ -535,6 +535,10 @@ MVMJitGraph *MVM_nativecall_jit_graph_for_caller_code( case MVM_NATIVECALL_ARG_UTF8STR: if (is_rw) goto fail; continue; /* already handled */ + case MVM_NATIVECALL_ARG_CSTRUCT: + if (is_rw) goto fail; + arg_type = dst == -1 ? MVM_JIT_ARG_PTR : MVM_JIT_PARAM_PTR; + break; default: goto fail; }