X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FByteCodeGen.lhs;h=479d35d51b35b94dd45f0396fdebe03118b37587;hp=ca66250c8b67b8785b101ef0e2c711e5b22cd72f;hb=26b80e2f7ae773c33067b7f259e2b83bfb08d6b6;hpb=cdce647711c0f46f5799b24de087622cb77e647f diff --git a/compiler/ghci/ByteCodeGen.lhs b/compiler/ghci/ByteCodeGen.lhs index ca66250..479d35d 100644 --- a/compiler/ghci/ByteCodeGen.lhs +++ b/compiler/ghci/ByteCodeGen.lhs @@ -298,6 +298,7 @@ schemeER_wrk d p rhs { breakInfo_module = tickInfo_module tickInfo , breakInfo_number = tickNumber , breakInfo_vars = idOffSets + , breakInfo_resty = exprType (deAnnotate' newRhs) } let breakInstr = case arr of (BA arr#) -> BRK_FUN arr# tickNumber breakInfo return $ breakInstr `consOL` code @@ -434,18 +435,24 @@ schemeE d s p (AnnLet binds (_,body)) thunk_codes <- sequence compile_binds return (alloc_code `appOL` concatOL thunk_codes `appOL` body_code) --- introduce a let binding for a ticked case expression. This rule *should* only fire when the --- expression was not already let-bound (the code gen for let bindings should take care of that). --- Todo: we call exprFreeVars on a deAnnotated expression, this may not be the best way --- to calculate the free vars but it seemed like the least intrusive thing to do +-- introduce a let binding for a ticked case expression. This rule +-- *should* only fire when the expression was not already let-bound +-- (the code gen for let bindings should take care of that). Todo: we +-- call exprFreeVars on a deAnnotated expression, this may not be the +-- best way to calculate the free vars but it seemed like the least +-- intrusive thing to do schemeE d s p exp@(AnnCase {}) - | Just (tickInfo, _exp) <- isTickedExp' exp = do - let fvs = exprFreeVars $ deAnnotate' exp - let ty = exprType $ deAnnotate' exp - id <- newId ty - -- Todo: is emptyVarSet correct on the next line? - let letExp = AnnLet (AnnNonRec id (fvs, exp)) (emptyVarSet, AnnVar id) - schemeE d s p letExp + | Just (tickInfo,rhs) <- isTickedExp' exp + = if isUnLiftedType ty + then schemeE d s p (snd rhs) + else do + id <- newId ty + -- Todo: is emptyVarSet correct on the next line? + let letExp = AnnLet (AnnNonRec id (fvs, exp)) (emptyVarSet, AnnVar id) + schemeE d s p letExp + where exp' = deAnnotate' exp + fvs = exprFreeVars exp' + ty = exprType exp' schemeE d s p (AnnCase scrut bndr _ [(DataAlt dc, [bind1, bind2], rhs)]) | isUnboxedTupleCon dc, VoidArg <- typeCgRep (idType bind1) @@ -1369,13 +1376,14 @@ lookupBCEnv_maybe = lookupFM idSizeW :: Id -> Int idSizeW id = cgRepSizeW (typeCgRep (idType id)) +-- See bug #1257 unboxedTupleException :: a unboxedTupleException = throwDyn - (Panic - ("Bytecode generator can't handle unboxed tuples. Possibly due\n" ++ - "\tto foreign import/export decls in source. Workaround:\n" ++ - "\tcompile this module to a .o file, then restart session.")) + (ProgramError + ("Error: bytecode compiler can't handle unboxed tuples.\n"++ + " Possibly due to foreign import/export decls in source.\n"++ + " Workaround: use -fobject-code, or compile this module to .o separately.")) mkSLIDE n d = if d == 0 then nilOL else unitOL (SLIDE n d) @@ -1446,7 +1454,7 @@ runBc :: UniqSupply -> ModBreaks -> BcM r -> IO (BcM_State, r) runBc us modBreaks (BcM m) = m (BcM_State us 0 [] breakArray) where - breakArray = modBreaks_array modBreaks + breakArray = modBreaks_flags modBreaks thenBc :: BcM a -> (a -> BcM b) -> BcM b thenBc (BcM expr) cont = BcM $ \st0 -> do