From 4d116e5dab7aebe49abd77dfca6c14f38dc049f7 Mon Sep 17 00:00:00 2001 From: sewardj Date: Thu, 15 Feb 2001 14:30:07 +0000 Subject: [PATCH] [project @ 2001-02-15 14:27:36 by sewardj] VoidRep call/return support for the interpreter. --- ghc/includes/StgMiscClosures.h | 5 +++-- ghc/rts/Interpreter.c | 24 ++++++++++++++++++------ ghc/rts/Printer.c | 5 ++++- ghc/rts/StgMiscClosures.hc | 31 ++++++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/ghc/includes/StgMiscClosures.h b/ghc/includes/StgMiscClosures.h index 0aaed9f..7d6058c 100644 --- a/ghc/includes/StgMiscClosures.h +++ b/ghc/includes/StgMiscClosures.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMiscClosures.h,v 1.36 2001/02/12 04:55:33 chak Exp $ + * $Id: StgMiscClosures.h,v 1.37 2001/02/15 14:27:36 sewardj Exp $ * * (c) The GHC Team, 1998-1999 * @@ -65,11 +65,12 @@ STGFUN(stg_interp_constr7_entry); STGFUN(stg_interp_constr8_entry); /* Magic glue code for when compiled code returns a value in R1/F1/D1 - to the interpreter. */ + or a VoidRep to the interpreter. */ extern DLL_IMPORT_RTS const vec_info_8 stg_ctoi_ret_R1p_info; extern DLL_IMPORT_RTS const vec_info_8 stg_ctoi_ret_R1n_info; extern DLL_IMPORT_RTS const vec_info_8 stg_ctoi_ret_F1_info; extern DLL_IMPORT_RTS const vec_info_8 stg_ctoi_ret_D1_info; +extern DLL_IMPORT_RTS const vec_info_8 stg_ctoi_ret_V_info; /* Used by the interpreter to return an unboxed value on the stack to compiled code. */ diff --git a/ghc/rts/Interpreter.c b/ghc/rts/Interpreter.c index c7500ef..2f04ad9 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.19 $ - * $Date: 2001/02/13 11:11:06 $ + * $Revision: 1.20 $ + * $Date: 2001/02/15 14:30:07 $ * ---------------------------------------------------------------------------*/ #include "Rts.h" @@ -706,7 +706,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,9 +721,20 @@ 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); + } } } diff --git a/ghc/rts/Printer.c b/ghc/rts/Printer.c index c6aa7a3..6bf7174 100644 --- a/ghc/rts/Printer.c +++ b/ghc/rts/Printer.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Printer.c,v 1.36 2001/02/11 17:51:08 simonmar Exp $ + * $Id: Printer.c,v 1.37 2001/02/15 14:30:07 sewardj Exp $ * * (c) The GHC Team, 1994-2000. * @@ -355,6 +355,9 @@ StgPtr printStackObj( StgPtr sp ) if (c == (StgClosure*)&stg_ctoi_ret_D1_info) { fprintf(stderr, "\t\t\tstg_ctoi_ret_D1_info\n" ); } else + if (c == (StgClosure*)&stg_ctoi_ret_V_info) { + fprintf(stderr, "\t\t\tstg_ctoi_ret_V_info\n" ); + } else if (get_itbl(c)->type == BCO) { fprintf(stderr, "\t\t\t"); fprintf(stderr, "BCO(...)\n"); diff --git a/ghc/rts/StgMiscClosures.hc b/ghc/rts/StgMiscClosures.hc index 93f4bc2..eadb097 100644 --- a/ghc/rts/StgMiscClosures.hc +++ b/ghc/rts/StgMiscClosures.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMiscClosures.hc,v 1.64 2001/02/11 17:51:08 simonmar Exp $ + * $Id: StgMiscClosures.hc,v 1.65 2001/02/15 14:30:07 sewardj Exp $ * * (c) The GHC Team, 1998-2000 * @@ -226,6 +226,35 @@ STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_7_entry); VEC_POLY_INFO_TABLE(stg_ctoi_ret_D1,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_); + +/* When the returned value a VoidRep ... */ +#define STG_CtoI_RET_V_Template(label) \ + IFN_(label) \ + { \ + StgPtr bco; \ + FB_ \ + bco = ((StgPtr*)Sp)[1]; \ + Sp -= 1; \ + ((StgPtr*)Sp)[0] = 0; /* VoidRep tag */ \ + Sp -= 1; \ + ((StgPtr*)Sp)[0] = bco; \ + JMP_(stg_yield_to_interpreter); \ + FE_ \ + } + +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_0_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_1_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_2_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_3_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_4_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_5_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_6_entry); +STG_CtoI_RET_V_Template(stg_ctoi_ret_V_7_entry); + +VEC_POLY_INFO_TABLE(stg_ctoi_ret_V,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_); + + /* The other way round: when the interpreter returns a value to compiled code. The stack looks like this: -- 1.7.10.4