Skip to content
Snippets Groups Projects
Commit bf8c7d6e authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

bytecode: Do not generate `SLIDE x 0` instructions

SLIDE x 0 is a no-op as it means to shift x elements of the stack by no
spaces. In the interpreter, this results in a loop which copies an array
element into the same place.

I have instrumented GHCi to count how many of these instructions are interpreted.
The workload was `ghc` compiling two simple modules.

Total no-op slides: 7793476
Total slides: 11413289
Percentage useless (slides): 68%
Percentage uselss of total instructions: 9%
parent 8847125f
No related branches found
No related tags found
No related merge requests found
Pipeline #106312 failed
......@@ -548,7 +548,7 @@ returnUnliftedReps d s szb reps = do
PUSH_BCO tuple_bco `consOL`
unitOL RETURN_TUPLE
return ( mkSlideB platform szb (d - s) -- clear to sequel
`consOL` ret) -- go
`appOL` ret) -- go
-- construct and return an unboxed tuple
returnUnboxedTuple
......@@ -812,7 +812,7 @@ doTailCall init_d s p fn args = do
platform <- profilePlatform <$> getProfile
assert (sz == wordSize platform) return ()
let slide = mkSlideB platform (d - init_d + wordSize platform) (init_d - s)
return (push_fn `appOL` (slide `consOL` unitOL ENTER))
return (push_fn `appOL` (slide `appOL` unitOL ENTER))
do_pushes !d args reps = do
let (push_apply, n, rest_of_reps) = findPushSeq reps
(these_args, rest_of_args) = splitAt n args
......@@ -1531,7 +1531,7 @@ generatePrimCall d s p target _mb_unit _result_ty args
(push_target `consOL`
push_info `consOL`
PUSH_BCO args_bco `consOL`
(mkSlideB platform szb (d - s) `consOL` unitOL PRIMCALL))
(mkSlideB platform szb (d - s) `appOL` unitOL PRIMCALL))
-- -----------------------------------------------------------------------------
-- Deal with a CCall.
......@@ -2266,8 +2266,8 @@ unsupportedCConvException = throwGhcException (ProgramError
("Error: bytecode compiler can't handle some foreign calling conventions\n"++
" Workaround: use -fobject-code, or compile this module to .o separately."))
mkSlideB :: Platform -> ByteOff -> ByteOff -> BCInstr
mkSlideB platform nb db = SLIDE n d
mkSlideB :: Platform -> ByteOff -> ByteOff -> OrdList BCInstr
mkSlideB platform nb db = mkSlideW n d
where
!n = bytesToWords platform nb
!d = bytesToWords platform db
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment