X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FClosureInfo.lhs;h=07a833f5af72f544ae20531f806d8f7d5a7772c5;hb=178eeaa814ab8323a54024e4bb45b4629b7828c8;hp=056d0d81b515f322757d7d3dd5e4cf64a146b7ea;hpb=ad94d40948668032189ad22a0ad741ac1f645f50;p=ghc-hetmet.git diff --git a/compiler/codeGen/ClosureInfo.lhs b/compiler/codeGen/ClosureInfo.lhs index 056d0d8..07a833f 100644 --- a/compiler/codeGen/ClosureInfo.lhs +++ b/compiler/codeGen/ClosureInfo.lhs @@ -16,7 +16,7 @@ the STG paper. -- The above warning supression flag is a temporary kludge. -- While working on this module you are encouraged to remove it and fix -- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details module ClosureInfo ( @@ -139,7 +139,7 @@ needsSRT NoC_SRT = False needsSRT (C_SRT _ _ _) = True instance Outputable C_SRT where - ppr (NoC_SRT) = ptext SLIT("_no_srt_") + ppr (NoC_SRT) = ptext (sLit "_no_srt_") ppr (C_SRT label off bitmap) = parens (ppr label <> comma <> ppr off <> comma <> text (show bitmap)) \end{code} @@ -598,7 +598,8 @@ getCallMethod name (LFCon con) n_args ReturnCon con getCallMethod name (LFThunk _ _ updatable std_form_info is_fun) n_args - | is_fun -- *Might* be a function, so we must "call" it (which is always safe) + | is_fun -- it *might* be a function, so we must "call" it (which is + -- always safe) = SlowCall -- We cannot just enter it [in eval/apply, the entry code -- is the fast-entry code] @@ -622,11 +623,15 @@ getCallMethod name (LFThunk _ _ updatable std_form_info is_fun) n_args JumpToIt (thunkEntryLabel name std_form_info updatable) getCallMethod name (LFUnknown True) n_args - = SlowCall -- might be a function + = SlowCall -- Might be a function getCallMethod name (LFUnknown False) n_args - = ASSERT2 ( n_args == 0, ppr name <+> ppr n_args ) - EnterIt -- Not a function + | n_args > 0 + = WARN( True, ppr name <+> ppr n_args ) + SlowCall -- Note [Unsafe coerce complications] + + | otherwise + = EnterIt -- Not a function getCallMethod name (LFBlackHole _) n_args = SlowCall -- Presumably the black hole has by now @@ -676,6 +681,29 @@ isKnownFun (LFLetNoEscape _) = True isKnownFun _ = False \end{code} +Note [Unsafe coerce complications] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In some (badly-optimised) DPH code we see this + Module X: rr :: Int = error Int "Urk" + Module Y: ...((X.rr |> g) True) ... + where g is an (unsafe) coercion of kind (Int ~ Bool->Bool), say + +It's badly optimised, because knowing that 'X.rr' is bottom, we should +have dumped the application to True. But it should still work. These +strange unsafe coercions arise from the case-of-error transformation: + (case (error Int "foo") of { ... }) True +---> (error Int "foo" |> g) True + +Anyway, the net effect is that in STG-land, when casts are discarded, +we *can* see a value of type Int applied to an argument. This only happens +if (a) the programmer made a mistake, or (b) the value of type Int is +actually bottom. + +So it's wrong to trigger an ASSERT failure in this circumstance. Instead +we now emit a WARN -- mainly to draw attention to a probably-badly-optimised +program fragment -- and do the conservative thing which is SlowCall. + + ----------------------------------------------------------------------------- SRT-related stuff @@ -978,7 +1006,6 @@ getTyDescription ty AppTy fun _ -> getTyDescription fun FunTy _ res -> '-' : '>' : fun_result res TyConApp tycon _ -> getOccString tycon - NoteTy (FTVNote _) ty -> getTyDescription ty PredTy sty -> getPredTyDescription sty ForAllTy _ ty -> getTyDescription ty }