* Copyright (c) 1994-2000.
*
* $RCSfile: Interpreter.c,v $
- * $Revision: 1.21 $
- * $Date: 2001/03/21 10:56:04 $
+ * $Revision: 1.30 $
+ * $Date: 2001/08/14 13:40:09 $
* ---------------------------------------------------------------------------*/
+#include "PosixSource.h"
#include "Rts.h"
#include "RtsAPI.h"
#include "RtsUtils.h"
#define BCO_LIT(n) (W_)literals[n]
#define BCO_ITBL(n) itbls[n]
-#define LOAD_STACK_POINTERS \
- iSp = cap->rCurrentTSO->sp; iSu = cap->rCurrentTSO->su;
+#define LOAD_STACK_POINTERS \
+ iSp = cap->rCurrentTSO->sp; \
+ iSu = cap->rCurrentTSO->su; \
+ /* We don't change this ... */ \
+ iSpLim = cap->rCurrentTSO->stack + RESERVED_STACK_WORDS;
+
-#define SAVE_STACK_POINTERS \
- cap->rCurrentTSO->sp = iSp; cap->rCurrentTSO->su = iSu;
+#define SAVE_STACK_POINTERS \
+ cap->rCurrentTSO->sp = iSp; \
+ cap->rCurrentTSO->su = iSu;
-#define RETURN(retcode) \
+#define RETURN(retcode) \
SAVE_STACK_POINTERS; return retcode;
void interp_shutdown ( void )
{
int i, j, k, o_max, i_max, j_max;
- fprintf(stderr, "%d constrs entered -> (%d BCO, %d UPD, %d ???)\n",
+ fprintf(stderr, "%d constrs entered -> (%d BCO, %d UPD, %d ??? )\n",
it_retto_BCO + it_retto_UPDATE + it_retto_other,
it_retto_BCO, it_retto_UPDATE, it_retto_other );
fprintf(stderr, "%d total entries, %d unknown entries \n",
LOAD_STACK_POINTERS;
- /* We don't change this ... */
- iSpLim = cap->rCurrentTSO->stack + RESERVED_STACK_WORDS;
-
/* Main object-entering loop. Object to be entered is on top of
stack. */
nextEnter:
bciPtr = failto;
goto nextInsn;
}
+ case bci_TESTLT_F: {
+ /* The top thing on the stack should be a tagged float. */
+ int discr = BCO_NEXT;
+ int failto = BCO_NEXT;
+ StgFloat stackFlt, discrFlt;
+ ASSERT(sizeofW(StgFloat) == StackWord(0));
+ stackFlt = PK_FLT( & StackWord(1) );
+ discrFlt = PK_FLT( & BCO_LIT(discr) );
+ if (stackFlt >= discrFlt)
+ bciPtr = failto;
+ goto nextInsn;
+ }
+ case bci_TESTEQ_F: {
+ /* The top thing on the stack should be a tagged float. */
+ int discr = BCO_NEXT;
+ int failto = BCO_NEXT;
+ StgFloat stackFlt, discrFlt;
+ ASSERT(sizeofW(StgFloat) == StackWord(0));
+ stackFlt = PK_FLT( & StackWord(1) );
+ discrFlt = PK_FLT( & BCO_LIT(discr) );
+ if (stackFlt != discrFlt)
+ bciPtr = failto;
+ goto nextInsn;
+ }
/* Control-flow ish things */
case bci_ENTER: {
}
}
}
-
+ case bci_SWIZZLE: {
+ int stkoff = BCO_NEXT;
+ signed short n = (signed short)(BCO_NEXT);
+ StackWord(stkoff) += (W_)n;
+ goto nextInsn;
+ }
+ case bci_CCALL: {
+ StgInt tok;
+ int o_itbl = BCO_NEXT;
+ void(*marshall_fn)(void*) = (void (*)(void*))BCO_LIT(o_itbl);
+ SAVE_STACK_POINTERS;
+ tok = suspendThread(cap);
+ marshall_fn ( (void*)(& StackWord(0) ) );
+ cap = resumeThread(tok);
+ LOAD_STACK_POINTERS;
+ goto nextInsn;
+ }
case bci_JMP: {
/* BCO_NEXT modifies bciPtr, so be conservative. */
int nextpc = BCO_NEXT;
case bci_CASEFAIL:
barf("interpretBCO: hit a CASEFAIL");
- /* As yet unimplemented */
- case bci_TESTLT_F:
- case bci_TESTEQ_F:
-
/* Errors */
default:
barf("interpretBCO: unknown or unimplemented opcode");