X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FClosureInfo.lhs;h=07a833f5af72f544ae20531f806d8f7d5a7772c5;hb=36104d7a0d66df895c8275e3aa7cfe35a322ff04;hp=23113d2afb55c42550b1516daeba129e8f2dea42;hpb=6273ef4138e164d7b68ef7bdfdd6b8ce468de3d4;p=ghc-hetmet.git diff --git a/compiler/codeGen/ClosureInfo.lhs b/compiler/codeGen/ClosureInfo.lhs index 23113d2..07a833f 100644 --- a/compiler/codeGen/ClosureInfo.lhs +++ b/compiler/codeGen/ClosureInfo.lhs @@ -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