[Git][ghc/ghc][master] JS: implement performMinorGC and performBlockingMajorGC (#28012)
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0c17201c by Sylvain Henry at 2026-10-22T21:38:23-04:00 JS: implement performMinorGC and performBlockingMajorGC (#28012) GHC.Internal.System.Mem imports three C entry points: performMajorGC, performGC (for performMinorGC) and performBlockingMajorGC. The JS RTS only defined h$performMajorGC, so calling performMinorGC or performBlockingMajorGC threw "ReferenceError: h$performGC is not defined" at runtime. The JS RTS has a single non-generational collector, so both missing entry points are now aliases of h$performMajorGC. Add a test that calls every GC entry point of System.Mem. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> - - - - - 5 changed files: - + changelog.d/28012 - rts/js/environment.js - + testsuite/tests/rts/T28012.hs - + testsuite/tests/rts/T28012.stdout - testsuite/tests/rts/all.T Changes: ===================================== changelog.d/28012 ===================================== @@ -0,0 +1,4 @@ +section: js-backend +synopsis: The JavaScript RTS now implements ``performMinorGC`` and ``performBlockingMajorGC``; calling them used to throw a JavaScript ``ReferenceError``. +issues: #28012 +mrs: !16847 ===================================== rts/js/environment.js ===================================== @@ -389,6 +389,13 @@ function h$performMajorGC() { if(err) throw err; } +function h$performGC() { + h$performMajorGC(); +} + +function h$performBlockingMajorGC() { + h$performMajorGC(); +} function h$ghczminternalZCSystemziCPUTimeZCgetrusage() { return 0; ===================================== testsuite/tests/rts/T28012.hs ===================================== @@ -0,0 +1,19 @@ +-- Test for #28012. +-- Check that every GC entry point exported by System.Mem can be called. +-- The JS RTS used to define only performMajorGC: performMinorGC and +-- performBlockingMajorGC were foreign imports of C symbols that had no +-- JS implementation, so calling them threw a ReferenceError at runtime. +module Main where + +import System.Mem + +main :: IO () +main = do + performGC + putStrLn "performGC ok" + performMinorGC + putStrLn "performMinorGC ok" + performMajorGC + putStrLn "performMajorGC ok" + performBlockingMajorGC + putStrLn "performBlockingMajorGC ok" ===================================== testsuite/tests/rts/T28012.stdout ===================================== @@ -0,0 +1,4 @@ +performGC ok +performMinorGC ok +performMajorGC ok +performBlockingMajorGC ok ===================================== testsuite/tests/rts/all.T ===================================== @@ -757,3 +757,5 @@ test('T27618', [req_target_smp, omit_ghci], compile_and_run, ['-O2 -threaded -with-rtsopts "-N4 -A32k"']) + +test('T28012', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c17201cd3a4aab2a22d83e1630c59d7... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c17201cd3a4aab2a22d83e1630c59d7... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Marge Bot (@marge-bot)