Skip to content

Commit

Permalink
Adjust cross-platform code for new disownVM/ownVM API.
Browse files Browse the repository at this point in the history
  • Loading branch information
marceltaeumel committed Apr 16, 2024
1 parent 8e5c04d commit d926670
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 31 deletions.
8 changes: 3 additions & 5 deletions platforms/Cross/plugins/IA32ABI/arm32abicc.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ thunkEntry(long r0, long r1, long r2, long r3,
void *thunkpPlus16, sqIntptr_t *stackp)
{
VMCallbackContext vmcc;
int flags;
int returnType;
long regArgs[NUM_REG_ARGS];
double dregArgs[NUM_DREG_ARGS];
Expand All @@ -141,8 +140,7 @@ thunkEntry(long r0, long r1, long r2, long r3,
dregArgs[6] = d6;
dregArgs[7] = d7;

flags = interpreterProxy->ownVM(0);
if (flags < 0) {
if (interpreterProxy->ownVM(NULL /* unidentified thread */) < 0) {
fprintf(stderr,"Warning; callback failed to own the VM\n");
return -1;
}
Expand All @@ -157,12 +155,12 @@ thunkEntry(long r0, long r1, long r2, long r3,
interpreterProxy->sendInvokeCallbackContext(&vmcc);
fprintf(stderr,"Warning; callback failed to invoke\n");
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);
return -1;
}

setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);

switch (returnType) {
case retword:
Expand Down
9 changes: 4 additions & 5 deletions platforms/Cross/plugins/IA32ABI/arm64abicc.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ thunkEntry(long x0, long x1, long x2, long x3,
void *thunkpPlus16, sqIntptr_t *stackp)
{
VMCallbackContext vmcc; /* See, e.g. spurstack64src/vm/vmCallback.h */
int flags, returnType;
int returnType;
sqIntptr_t regArgs[NUM_REG_ARGS];
double dregArgs[NUM_DREG_ARGS];

Expand All @@ -177,8 +177,7 @@ thunkEntry(long x0, long x1, long x2, long x3,
dregArgs[6] = d6;
dregArgs[7] = d7;

flags = interpreterProxy->ownVM(0);
if (flags < 0) {
if (interpreterProxy->ownVM(NULL /* unidentified thread */) < 0) {
fprintf(stderr,"Warning; callback failed to own the VM\n");
return -1;
}
Expand All @@ -193,12 +192,12 @@ thunkEntry(long x0, long x1, long x2, long x3,
interpreterProxy->sendInvokeCallbackContext(&vmcc);
fprintf(stderr,"Warning; callback failed to invoke\n");
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);
return -1;
}

setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);

switch (returnType) {
case retword:
Expand Down
8 changes: 4 additions & 4 deletions platforms/Cross/plugins/IA32ABI/ia32abicc.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ __attribute__((optimize("O0")))
thunkEntry(void *thunkp, sqIntptr_t *stackp)
{
VMCallbackContext vmcc;
int flags, returnType;
int returnType;

#if STACK_ALIGN_HACK
{ void *sp = getsp();
Expand All @@ -178,7 +178,7 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp)
}
#endif /* STACK_ALIGN_HACK */

if ((flags = interpreterProxy->ownVM(0)) < 0) {
if (interpreterProxy->ownVM(NULL /* unidentified thread */) < 0) {
fprintf(stderr,"Warning; callback failed to own the VM\n");
return -1;
}
Expand All @@ -193,11 +193,11 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp)
interpreterProxy->sendInvokeCallbackContext(&vmcc);
fprintf(stderr,"Warning; callback failed to invoke\n");
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);
return -1;
}
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);

switch (returnType) {

Expand Down
9 changes: 4 additions & 5 deletions platforms/Cross/plugins/IA32ABI/riscv64abicc.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ thunkEntry(long x0, long x1, long x2, long x3,
void *thunkp, sqIntptr_t *stackp)
{
VMCallbackContext vmcc; /* See src/spur64.stack/vmCallback.h */
int flags, returnType;
int returnType;
sqIntptr_t regArgs[NUM_REG_ARGS];
double dregArgs[NUM_DREG_ARGS];

Expand All @@ -200,8 +200,7 @@ thunkEntry(long x0, long x1, long x2, long x3,
dregArgs[6] = d6;
dregArgs[7] = d7;

flags = interpreterProxy->ownVM(0);
if (flags < 0) {
if (interpreterProxy->ownVM(NULL /* unidentified thread */) < 0) {
fprintf(stderr,"Warning; callback failed to own the VM\n");
return -1;
}
Expand All @@ -216,12 +215,12 @@ thunkEntry(long x0, long x1, long x2, long x3,
interpreterProxy->sendInvokeCallbackContext(&vmcc);
fprintf(stderr,"Warning; callback failed to invoke\n");
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);
return -1;
}

setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);

switch (returnType) {
case retword:
Expand Down
8 changes: 4 additions & 4 deletions platforms/Cross/plugins/IA32ABI/x64sysvabicc.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ thunkEntry(long a0, long a1, long a2, long a3, long a4, long a5,
void *thunkp, sqIntptr_t *stackp)
{
VMCallbackContext vmcc;
long flags, returnType;
long returnType;
long intargs[6];
double fpargs[8];

Expand All @@ -176,7 +176,7 @@ thunkEntry(long a0, long a1, long a2, long a3, long a4, long a5,
fpargs[7] = d7;


if ((flags = interpreterProxy->ownVM(0)) < 0) {
if (interpreterProxy->ownVM(NULL /* unidentified thread */) < 0) {
fprintf(stderr,"Warning; callback failed to own the VM\n");
return -1;
}
Expand All @@ -191,11 +191,11 @@ thunkEntry(long a0, long a1, long a2, long a3, long a4, long a5,
interpreterProxy->sendInvokeCallbackContext(&vmcc);
fprintf(stderr,"Warning; callback failed to invoke\n");
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);
return -1;
}
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);

switch (returnType) {

Expand Down
7 changes: 3 additions & 4 deletions platforms/Cross/plugins/IA32ABI/x64win64abicc.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ thunkEntry(long long rcx, long long rdx,
{
VMCallbackContext vmcc;
int returnType;
long long flags;
long long intargs[4];
double fpargs[4];

Expand All @@ -193,7 +192,7 @@ extern void saveFloatRegsWin64(long long xmm0,long long xmm1,long long xmm2, lon
extern double fakeReturnDouble(double xmm0); /* see below */
saveFloatRegsWin64(rcx,rdx,r8,r9,fpargs); /* the callee expects double parameters that it will retrieve thru registers */

if ((flags = interpreterProxy->ownVM(0)) < 0) {
if (interpreterProxy->ownVM(NULL /* unidentified thread */) < 0) {
fprintf(stderr,"Warning; callback failed to own the VM\n");
return -1;
}
Expand All @@ -208,12 +207,12 @@ extern double fakeReturnDouble(double xmm0); /* see below */
interpreterProxy->sendInvokeCallbackContext(&vmcc);
fprintf(stderr,"Warning; callback failed to invoke\n");
setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);
return -1;
}

setMRCC(vmcc.savedMostRecentCallbackContext);
interpreterProxy->disownVM(flags);
interpreterProxy->disownVM(DisownVMFromCallback);

switch (returnType) {

Expand Down
4 changes: 2 additions & 2 deletions platforms/Cross/vm/sqVirtualMachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ sqInt copyBits(void);
sqInt copyBitsFromtoat(sqInt leftX, sqInt rightX, sqInt yValue);

#if VM_PROXY_MINOR > 10
extern sqInt disownVM(sqInt flags);
extern sqInt ownVM(sqInt threadIdAndFlags);
extern void *disownVM(sqInt flags);
extern sqInt ownVM(void *vmThreadHandle);
#endif // VM_PROXY_MINOR > 10
extern sqInt isYoung(sqInt);

Expand Down
4 changes: 2 additions & 2 deletions platforms/Cross/vm/sqVirtualMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ typedef struct VirtualMachine {
#endif

#if VM_PROXY_MINOR > 10
sqInt (*disownVM)(sqInt flags);
sqInt (*ownVM) (sqInt threadIdAndFlags);
void *(*disownVM)(sqInt flags);
sqInt (*ownVM)(void *vmThreadHandle);
void (*addHighPriorityTickee)(void (*ticker)(void), unsigned periodms);
void (*addSynchronousTickee)(void (*ticker)(void), unsigned periodms, unsigned roundms);
usqLong (*utcMicroseconds)(void);
Expand Down

0 comments on commit d926670

Please sign in to comment.