[project @ 2001-02-15 14:27:36 by sewardj]
authorsewardj <unknown>
Thu, 15 Feb 2001 14:30:07 +0000 (14:30 +0000)
committersewardj <unknown>
Thu, 15 Feb 2001 14:30:07 +0000 (14:30 +0000)
VoidRep call/return support for the interpreter.

ghc/includes/StgMiscClosures.h
ghc/rts/Interpreter.c
ghc/rts/Printer.c
ghc/rts/StgMiscClosures.hc

index 0aaed9f..7d6058c 100644 (file)
@@ -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. */
index c7500ef..2f04ad9 100644 (file)
@@ -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);
+                     }
                  }
               }
         
index c6aa7a3..6bf7174 100644 (file)
@@ -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"); 
index 93f4bc2..eadb097 100644 (file)
@@ -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: