Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: make variable types in simulate_unbind match OP_unbind #381

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/makefile-linux.x86_64-x
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
XFLAGS = -DXWINDOW

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
OPTFLAGS = -O0 -g3
DFLAGS = $(XFLAGS) -DRELEASE=351

LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm
Expand Down
8 changes: 4 additions & 4 deletions inc/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef struct fnhead {
typedef struct frameex1 {
unsigned flags : 3;
unsigned fast : 1;
unsigned nil2 : 1; /* not used, prev: This frame treats N-func */
unsigned mvscase : 1; /* was not used, prev: This frame treats N-func */
unsigned incall : 1;
unsigned validnametable : 1;
/* 0: look for FunctionHeader
Expand Down Expand Up @@ -109,7 +109,7 @@ typedef struct frameex1 {
typedef struct frameex2 {
unsigned flags : 3;
unsigned fast : 1;
unsigned nil2 : 1; /* not used, prev: This frame treats N-func */
unsigned mvscase : 1; /* not used, prev: This frame treats N-func */
unsigned incall : 1;
unsigned validnametable : 1;
/* 0: look for FunctionHeader
Expand Down Expand Up @@ -200,7 +200,7 @@ typedef struct frameex1 {
/* 0: look for FunctionHeader
1: look for NameTable on this FrameEx */
unsigned incall : 1;
unsigned nil2 : 1; /* not used, prev: This frame treats N-func */
unsigned mvscase : 1; /* not used, prev: This frame treats N-func */
unsigned fast : 1;
unsigned flags : 3; /* hi word */

Expand Down Expand Up @@ -235,7 +235,7 @@ typedef struct frameex2 {
/* 0: look for FunctionHeader
1: look for NameTable on this FrameEx */
unsigned incall : 1;
unsigned nil2 : 1; /* not used, prev: This frame treats N-func */
unsigned mvscase : 1; /* not used, prev: This frame treats N-func */
unsigned fast : 1;
unsigned flags : 3;

Expand Down
9 changes: 7 additions & 2 deletions src/hardrtn.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ int slowreturn(void) {
} else {
if (CURRENTFX->nopush) {
CURRENTFX->nopush = NIL;
CurrentStackPTR = next68k - 2;
TopOfStack = *((LispPTR *)CurrentStackPTR);
if (CURRENTFX->mvscase) {
CurrentStackPTR = next68k;
CURRENTFX->mvscase = NIL;
} else {
CurrentStackPTR = next68k - 2;
TopOfStack = *((LispPTR *)CurrentStackPTR);
}
CurrentStackPTR -= 2;

} else
Expand Down
43 changes: 23 additions & 20 deletions src/mvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ LispPTR values(int arg_count, register LispPTR *args) {
fnhead = (struct fnhead *)FuncObj;
pc = (ByteCode *)PC + 3; /* to skip the miscn opcode we're in now */
} else {
unbind_count = 0; /* different frame */

fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader));
pc = (ByteCode *)fnhead + (caller->pc);
}
Expand Down Expand Up @@ -98,9 +100,14 @@ LispPTR values(int arg_count, register LispPTR *args) {
/* BUT 3's not enough for big atoms, so add diff between FN op size & MISCN op size */
if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE - 3);
#endif /* BIGATOMS */

else
else {
caller->pc = (UNSIGNED)pc + FN_OPCODE_SIZE - (UNSIGNED)fnhead;
/* skip over FN opcode when we get there */
prevcaller->fast = 0;
caller->mvscase = 1;
caller->nopush = 1;
}

return (make_value_list(arg_count, args));
}
break;
Expand Down Expand Up @@ -271,26 +278,22 @@ LispPTR make_value_list(int argcount, LispPTR *argarray) {

void simulate_unbind(FX2 *frame, int unbind_count, FX2 *returner) {
int unbind;
LispPTR *stackptr = (LispPTR *)(Stackspace + frame->nextblock);
LispPTR *stack_pointer = (LispPTR *)(Stackspace + frame->nextblock);
for (unbind = 0; unbind < unbind_count; unbind++) {
register int value;
register LispPTR *lastpvar;
int bindnvalues;
for (; ((int)*--stackptr >= 0);)
; /* find the binding mark */
value = (int)*stackptr;
lastpvar = (LispPTR *)((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value));
;
bindnvalues = (~value) >> 16;
for (value = bindnvalues; --value >= 0;) { *--lastpvar = 0xffffffff; }
/* This line caused \NSMAIL.READ.HEADING to smash memory, */
/* so I removed it 21 Jul 91 --JDS. This was the only */
/* difference between this function and the UNWIND code */
/* in inlineC.h */
/* MAKEFREEBLOCK(stackptr, (DLword *)stackptr-nextblock); */
register int num;
register LispPTR *ppvar;
register int i;
register LispPTR value;

for (; (((int)*--(stack_pointer)) >= 0);)
;
value = *stack_pointer;
num = (~value) >> 16;
ppvar = (LispPTR *)((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value));
for (i = num; --i >= 0;) { *--ppvar = 0xffffffff; }
}
if (returner)
returner->fast = 0; /* since we've destroyed contiguity */
/* if (returner)
returner->fast = 0; since we've destroyed contiguity */
/* in the stack, but that only
matters if there's a return. */
}