Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/StgToByteCode.hs
    ... ... @@ -748,12 +748,21 @@ doTailCall init_d s p fn args = do
    748 748
     
    
    749 749
       where
    
    750 750
       do_pushes !d [] reps = do
    
    751
    -        assert (null reps) return ()
    
    752
    -        (push_fn, sz) <- pushAtom d p (StgVarArg fn)
    
    753 751
             platform <- profilePlatform <$> getProfile
    
    754
    -        assert (sz == wordSize platform) return ()
    
    755
    -        let slide = mkSlideB platform (d - init_d + wordSize platform) (init_d - s)
    
    756
    -        return (push_fn `appOL` (slide `appOL` unitOL ENTER))
    
    752
    +        assert (null reps) return ()
    
    753
    +        case lookupBCEnv_maybe fn p of
    
    754
    +          Just d_v
    
    755
    +            | d - d_v == 0  -- shortcut; the first thing on the stack is what we want to enter,
    
    756
    +            , d_v <= init_d -- and it is between init_d and sequel (which will be dropped)
    
    757
    +            -> do
    
    758
    +              let slide = mkSlideB platform (d - init_d + wordSize platform)
    
    759
    +                                            (init_d - s - wordSize platform)
    
    760
    +              return (slide `appOL` unitOL ENTER)
    
    761
    +          _ -> do
    
    762
    +              (push_fn, sz) <- pushAtom d p (StgVarArg fn)
    
    763
    +              assert (sz == wordSize platform) return ()
    
    764
    +              let slide = mkSlideB platform (d - init_d + wordSize platform) (init_d - s)
    
    765
    +              return (push_fn `appOL` (slide `appOL` unitOL ENTER))
    
    757 766
       do_pushes !d args reps = do
    
    758 767
           let (push_apply, n, rest_of_reps) = findPushSeq reps
    
    759 768
               (these_args, rest_of_args) = splitAt n args