[Git][ghc/ghc][master] bytecode: Do not generate `SLIDE x 0` instructions
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Jan 29 07:33:00 UTC 2025
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
bf8c7d6e by Matthew Pickering at 2025-01-29T02:31:44-05:00
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%
- - - - -
1 changed file:
- compiler/GHC/StgToByteCode.hs
Changes:
=====================================
compiler/GHC/StgToByteCode.hs
=====================================
@@ -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
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf8c7d6edf224c083c90ab3ddac49979ac18ad39
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf8c7d6edf224c083c90ab3ddac49979ac18ad39
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250129/824ca346/attachment-0001.html>
More information about the ghc-commits
mailing list