summaryrefslogtreecommitdiff
path: root/compiler/ghci/ByteCodeInstr.lhs
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2010-09-19 00:29:05 +0000
committerEdward Z. Yang <ezyang@mit.edu>2010-09-19 00:29:05 +0000
commit83d563cb9ede0ba792836e529b1e2929db926355 (patch)
tree1f9de77ebd24ca7a67894c51442b657d2f265630 /compiler/ghci/ByteCodeInstr.lhs
parent9fa96fc44a640014415e1588f50ab7689285e6cb (diff)
downloadhaskell-83d563cb9ede0ba792836e529b1e2929db926355.tar.gz
Interruptible FFI calls with pthread_kill and CancelSynchronousIO. v4
This is patch that adds support for interruptible FFI calls in the form of a new foreign import keyword 'interruptible', which can be used instead of 'safe' or 'unsafe'. Interruptible FFI calls act like safe FFI calls, except that the worker thread they run on may be interrupted. Internally, it replaces BlockedOnCCall_NoUnblockEx with BlockedOnCCall_Interruptible, and changes the behavior of the RTS to not modify the TSO_ flags on the event of an FFI call from a thread that was interruptible. It also modifies the bytecode format for foreign call, adding an extra Word16 to indicate interruptibility. The semantics of interruption vary from platform to platform, but the intent is that any blocking system calls are aborted with an error code. This is most useful for making function calls to system library functions that support interrupting. There is no support for pre-Vista Windows. There is a partner testsuite patch which adds several tests for this functionality.
Diffstat (limited to 'compiler/ghci/ByteCodeInstr.lhs')
-rw-r--r--compiler/ghci/ByteCodeInstr.lhs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/ghci/ByteCodeInstr.lhs b/compiler/ghci/ByteCodeInstr.lhs
index b83006bd45..d44a00bc14 100644
--- a/compiler/ghci/ByteCodeInstr.lhs
+++ b/compiler/ghci/ByteCodeInstr.lhs
@@ -127,6 +127,9 @@ data BCInstr
-- For doing calls to C (via glue code generated by ByteCodeFFI, or libffi)
| CCALL Word16 -- stack frame size
(Ptr ()) -- addr of the glue code
+ Word16 -- whether or not the call is interruptible
+ -- (XXX: inefficient, but I don't know
+ -- what the alignment constraints are.)
-- For doing magic ByteArray passing to foreign calls
| SWIZZLE Word16 -- to the ptr N words down the stack,
@@ -217,9 +220,12 @@ instance Outputable BCInstr where
ppr (TESTEQ_P i lab) = text "TESTEQ_P" <+> ppr i <+> text "__" <> ppr lab
ppr CASEFAIL = text "CASEFAIL"
ppr (JMP lab) = text "JMP" <+> ppr lab
- ppr (CCALL off marshall_addr) = text "CCALL " <+> ppr off
+ ppr (CCALL off marshall_addr int) = text "CCALL " <+> ppr off
<+> text "marshall code at"
<+> text (show marshall_addr)
+ <+> (if int == 1
+ then text "(interruptible)"
+ else empty)
ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff
<+> text "by" <+> ppr n
ppr ENTER = text "ENTER"