diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-06-27 10:26:01 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-06-27 12:55:06 -0400 |
commit | 9ef909db5ed3dc45fc1acdb608ad3f1896362966 (patch) | |
tree | 142e728dfb0c0a3a5519bb045d95f0e02dacc1e3 /compiler | |
parent | 914962ca23e407efdd3429dc89adcca7bee15f28 (diff) | |
download | haskell-9ef909db5ed3dc45fc1acdb608ad3f1896362966.tar.gz |
Allow bytecode interpreter to make unsafe foreign calls
Reviewers: austin, hvr, erikd, simonmar
Reviewed By: simonmar
Subscribers: rwbarton, thomie
GHC Trac Issues: #8281, #13730.
Differential Revision: https://phabricator.haskell.org/D3619
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ghci/ByteCodeGen.hs | 8 | ||||
-rw-r--r-- | compiler/ghci/ByteCodeInstr.hs | 15 |
2 files changed, 16 insertions, 7 deletions
diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs index 7ad51a7138..a7cd6da0e7 100644 --- a/compiler/ghci/ByteCodeGen.hs +++ b/compiler/ghci/ByteCodeGen.hs @@ -1164,8 +1164,12 @@ generateCCall d0 s p (CCallSpec target cconv safety) fn args_r_to_l let -- do the call - do_call = unitOL (CCALL stk_offset token - (fromIntegral (fromEnum (playInterruptible safety)))) + do_call = unitOL (CCALL stk_offset token flags) + where flags = case safety of + PlaySafe -> 0x0 + PlayInterruptible -> 0x1 + PlayRisky -> 0x2 + -- slide and return wrapup = mkSLIDE r_sizeW (d_after_r - fromIntegral r_sizeW - s) `snocOL` RETURN_UBX (toArgRep r_rep) diff --git a/compiler/ghci/ByteCodeInstr.hs b/compiler/ghci/ByteCodeInstr.hs index 43444321de..525280290f 100644 --- a/compiler/ghci/ByteCodeInstr.hs +++ b/compiler/ghci/ByteCodeInstr.hs @@ -132,7 +132,11 @@ data BCInstr -- For doing calls to C (via glue code generated by libffi) | CCALL Word16 -- stack frame size (RemotePtr C_ffi_cif) -- addr of the glue code - Word16 -- whether or not the call is interruptible + Word16 -- flags. + -- + -- 0x1: call is interruptible + -- 0x2: call is unsafe + -- -- (XXX: inefficient, but I don't know -- what the alignment constraints are.) @@ -235,12 +239,13 @@ 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 int) = text "CCALL " <+> ppr off + ppr (CCALL off marshall_addr flags) = text "CCALL " <+> ppr off <+> text "marshall code at" <+> text (show marshall_addr) - <+> (if int == 1 - then text "(interruptible)" - else empty) + <+> (case flags of + 0x1 -> text "(interruptible)" + 0x2 -> text "(unsafe)" + _ -> empty) ppr (SWIZZLE stkoff n) = text "SWIZZLE " <+> text "stkoff" <+> ppr stkoff <+> text "by" <+> ppr n ppr ENTER = text "ENTER" |