[Git][ghc/ghc][wip/T23479] test
Serge S. Gulin (@gulin.serge)
gitlab at gitlab.haskell.org
Mon Oct 14 17:30:30 UTC 2024
Serge S. Gulin pushed to branch wip/T23479 at Glasgow Haskell Compiler / GHC
Commits:
a49fed26 by Serge S. Gulin at 2024-10-14T20:30:21+03:00
test
- - - - -
3 changed files:
- testsuite/tests/javascript/Makefile
- + testsuite/tests/javascript/T23479_2.hs
- + testsuite/tests/javascript/T23479_2.stdout
Changes:
=====================================
testsuite/tests/javascript/Makefile
=====================================
@@ -16,4 +16,12 @@ T23479_1:
grep -c "h\$$r1 = \"test_val_2\"" T23479_1.dump-js
grep -c "h\$$r1 = \"test_val_3\"" T23479_1.dump-js
grep -c "h\$$r1 = \"test_val_80_local" T23479_1.dump-js
- grep -c "h\$$r1 = \"test_val_80_global" T23479_1.dump-js
+ grep -c "h\$$r1 = \"test_val_80_global" T23479_1.dump-js || true
+
+T23479_2:
+ '$(TEST_HC)' $(TEST_HC_OPTS) T23479_2.hs -v0 -O2 -dsuppress-uniques -ddump-js -ddump-to-file
+ ./T23479_2
+ grep -c "h\$$r1 = \"test_val_1\"" T23479_2.dump-js
+ grep -c "h\$$r1 = \"test_val_80_local_once" T23479_2.dump-js
+ # check that the optimization occurred
+ grep -c "h\$$r1 = h\$$decodeUtf8z" T23479_2.dump-js
=====================================
testsuite/tests/javascript/T23479_2.hs
=====================================
@@ -0,0 +1,37 @@
+module Main where
+
+import GHC.Prim
+import GHC.JS.Prim
+
+foreign import javascript "((x) => { console.log(x); })"
+ js_log1 :: JSVal -> IO ()
+
+main :: IO ()
+main = do
+ -- When long string (>= 80) used once it is unfloatted
+ js_log1 (toJSString test_val_80_local_once)
+
+ -- When long string (>= 80) used more than once no unfloatting happened
+ js_log1 (toJSString test_val_80_local)
+ js_log1 (toJSString (testFn80 "testFn80:"))
+
+ -- Even if short string used more than once it is unfloatted anyway
+ js_log1 (toJSString test_val_1)
+ js_log1 (toJSString (testFn "testFn:"))
+ where
+ test_val_80_local_once :: String
+ test_val_80_local_once = "test_val_80_local_oncetest_val_80_local_oncetest_val_80_local_oncetest_val_80_lo"
+
+ test_val_80_local :: String
+ test_val_80_local = "test_val_80_localtest_val_80_localtest_val_80_localtest_val_80_localtest_val_80_"
+
+ testFn80 s = s ++ test_val_80_local
+ -- We should mark this function as NOINLINE to prevent deeper optimizations for the specific test case
+ {-# NOINLINE testFn80 #-}
+
+ test_val_1 :: String
+ test_val_1 = "test_val_1"
+
+ testFn s = s ++ test_val_1
+ -- We should mark this function as NOINLINE to prevent deeper optimizations for the specific test case
+ {-# NOINLINE testFn #-}
=====================================
testsuite/tests/javascript/T23479_2.stdout
=====================================
@@ -0,0 +1,8 @@
+test_val_80_local_oncetest_val_80_local_oncetest_val_80_local_oncetest_val_80_lo
+test_val_80_localtest_val_80_localtest_val_80_localtest_val_80_localtest_val_80_
+testFn80:test_val_80_localtest_val_80_localtest_val_80_localtest_val_80_localtest_val_80_
+test_val_1
+testFn:test_val_1
+1
+1
+1
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a49fed26637f85f92e7ae5a9a5c4217f74cd3c68
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a49fed26637f85f92e7ae5a9a5c4217f74cd3c68
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/20241014/d27580d4/attachment-0001.html>
More information about the ghc-commits
mailing list