From a36219092d7d700125f7b4952d969e1fbacb08d1 Mon Sep 17 00:00:00 2001 From: sewardj Date: Thu, 2 Aug 2001 17:01:33 +0000 Subject: [PATCH] [project @ 2001-08-02 17:01:33 by sewardj] C-side support for FFI in GHCi (foreign import only). --- ghc/includes/Bytecodes.h | 3 ++- ghc/rts/Disassembler.c | 8 ++++++-- ghc/rts/Interpreter.c | 11 ++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ghc/includes/Bytecodes.h b/ghc/includes/Bytecodes.h index 2e7842e..579998b 100644 --- a/ghc/includes/Bytecodes.h +++ b/ghc/includes/Bytecodes.h @@ -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, diff --git a/ghc/rts/Disassembler.c b/ghc/rts/Disassembler.c index 925d117..e0b27e9 100644 --- a/ghc/rts/Disassembler.c +++ b/ghc/rts/Disassembler.c @@ -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; diff --git a/ghc/rts/Interpreter.c b/ghc/rts/Interpreter.c index 7a382a4..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.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; -- 1.7.10.4