[project @ 2001-08-02 17:01:33 by sewardj]
authorsewardj <unknown>
Thu, 2 Aug 2001 17:01:33 +0000 (17:01 +0000)
committersewardj <unknown>
Thu, 2 Aug 2001 17:01:33 +0000 (17:01 +0000)
C-side support for FFI in GHCi (foreign import only).

ghc/includes/Bytecodes.h
ghc/rts/Disassembler.c
ghc/rts/Interpreter.c

index 2e7842e..579998b 100644 (file)
@@ -1,6 +1,6 @@
 
 /* -----------------------------------------------------------------------------
- * $Id: Bytecodes.h,v 1.6 2001/03/21 10:56:04 sewardj Exp $
+ * $Id: Bytecodes.h,v 1.7 2001/08/02 17:01:33 sewardj Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -52,6 +52,7 @@
 #define bci_RETURN    25
 #define bci_STKCHECK  26
 #define bci_JMP       27
+#define bci_CCALL     28
 
 
 /* If a BCO definitely requires less than this many words of stack,
index 925d117..e0b27e9 100644 (file)
@@ -5,8 +5,8 @@
  * Copyright (c) 1994-1998.
  *
  * $RCSfile: Disassembler.c,v $
- * $Revision: 1.21 $
- * $Date: 2001/05/01 13:11:16 $
+ * $Revision: 1.22 $
+ * $Date: 2001/08/02 17:01:33 $
  * ---------------------------------------------------------------------------*/
 
 #ifdef DEBUG
@@ -44,6 +44,10 @@ int disInstr ( StgBCO *bco, int pc )
    StgInfoTable** itbls       = (StgInfoTable**)(&itbls_arr->payload[0]);
 
    switch (instrs[pc++]) {
+      case bci_CCALL:
+         fprintf(stderr, "CCALL    marshaller at 0x%x\n", 
+                         literals[instrs[pc+1]] );
+         pc += 1; break;
       case bci_STKCHECK: 
          fprintf(stderr, "STKCHECK %d\n", instrs[pc] );
          pc += 1; break;
index 7a382a4..ad27904 100644 (file)
@@ -5,8 +5,8 @@
  * Copyright (c) 1994-2000.
  *
  * $RCSfile: Interpreter.c,v $
- * $Revision: 1.24 $
- * $Date: 2001/05/27 06:08:24 $
+ * $Revision: 1.25 $
+ * $Date: 2001/08/02 17:01:33 $
  * ---------------------------------------------------------------------------*/
 
 #include "Rts.h"
@@ -761,7 +761,12 @@ StgThreadReturnCode interpretBCO ( Capability* cap )
                      }
                  }
               }
-        
+              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;