X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FInterpreter.c;h=ad2790407391755ce0f0967067047da83eb6e1b0;hb=a36219092d7d700125f7b4952d969e1fbacb08d1;hp=ea0757d2c1f8e4eb6baea015e8c33d71417fd80d;hpb=6d35596c37601a9bf608e32034c390d516454c29;p=ghc-hetmet.git diff --git a/ghc/rts/Interpreter.c b/ghc/rts/Interpreter.c index ea0757d..ad27904 100644 --- a/ghc/rts/Interpreter.c +++ b/ghc/rts/Interpreter.c @@ -5,8 +5,8 @@ * Copyright (c) 1994-2000. * * $RCSfile: Interpreter.c,v $ - * $Revision: 1.17 $ - * $Date: 2001/02/11 17:51:07 $ + * $Revision: 1.25 $ + * $Date: 2001/08/02 17:01:33 $ * ---------------------------------------------------------------------------*/ #include "Rts.h" @@ -115,7 +115,7 @@ void interp_startup ( void ) 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", @@ -320,7 +320,7 @@ StgThreadReturnCode interpretBCO ( Capability* cap ) case SEQ_FRAME: /* Too complicated ... adopt the Usual Solution. */ - fprintf(stderr, "!!! SEQ frame in PAP update\n"); + /* fprintf(stderr, "!!! SEQ frame in PAP update\n"); */ goto defer_to_sched; case CATCH_FRAME: @@ -562,7 +562,7 @@ StgThreadReturnCode interpretBCO ( Capability* cap ) ap = (StgAP_UPD*)allocate_UPD(request); StackWord(-1) = (W_)ap; ap->n_args = n_payload; - SET_HDR(ap, &stg_AP_UPD_info, ??) + SET_HDR(ap, &stg_AP_UPD_info, CCS_SYSTEM/*ToDo*/) iSp --; goto nextInsn; } @@ -691,6 +691,30 @@ StgThreadReturnCode interpretBCO ( Capability* cap ) 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: { @@ -706,7 +730,8 @@ StgThreadReturnCode interpretBCO ( Capability* cap ) if (ret_itbl == (StgInfoTable*)&stg_ctoi_ret_R1p_info || ret_itbl == (StgInfoTable*)&stg_ctoi_ret_R1n_info || ret_itbl == (StgInfoTable*)&stg_ctoi_ret_F1_info - || ret_itbl == (StgInfoTable*)&stg_ctoi_ret_D1_info) { + || ret_itbl == (StgInfoTable*)&stg_ctoi_ret_D1_info + || ret_itbl == (StgInfoTable*)&stg_ctoi_ret_V_info) { /* Returning to interpreted code. Interpret the BCO immediately underneath the itbl. */ StgBCO* ret_bco = (StgBCO*)StackWord(tag +1+1); @@ -720,19 +745,37 @@ StgThreadReturnCode interpretBCO ( Capability* cap ) the TOS value into R1/F1/D1 and do a standard compiled-code return. */ StgInfoTable* magic_itbl = BCO_ITBL(o_itoc_itbl); - StackWord(0) = (W_)magic_itbl; - cap->rCurrentTSO->what_next = ThreadRunGHC; - RETURN(ThreadYielding); + if (magic_itbl != NULL) { + StackWord(0) = (W_)magic_itbl; + cap->rCurrentTSO->what_next = ThreadRunGHC; + RETURN(ThreadYielding); + } else { + /* Special case -- returning a VoidRep to + compiled code. T.O.S is the VoidRep tag, + and underneath is the return itbl. Zap the + tag and enter the itbl. */ + ASSERT(StackWord(0) == (W_)NULL); + iSp ++; + cap->rCurrentTSO->what_next = ThreadRunGHC; + RETURN(ThreadYielding); + } } } - + case bci_CCALL: { + int o_itbl = BCO_NEXT; + void(*marshall_fn)(void*) = BCO_LIT(o_itbl); + marshall_fn ( (void*)(& StackWord(0) ) ); + goto nextInsn; + } + case bci_JMP: { + /* BCO_NEXT modifies bciPtr, so be conservative. */ + int nextpc = BCO_NEXT; + bciPtr = nextpc; + goto nextInsn; + } 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");