[Git][ghc/ghc][wip/T23479] test
Serge S. Gulin (@gulin.serge)
gitlab at gitlab.haskell.org
Mon Oct 14 16:58:08 UTC 2024
Serge S. Gulin pushed to branch wip/T23479 at Glasgow Haskell Compiler / GHC
Commits:
e50ef194 by Serge S. Gulin at 2024-10-14T19:57:52+03:00
test
- - - - -
8 changed files:
- compiler/GHC/StgToJS/Apply.hs
- testsuite/tests/javascript/Makefile
- testsuite/tests/javascript/T23479_1.hs
- testsuite/tests/javascript/T23479_1.stdout
- − testsuite/tests/javascript/T23479_2.hs
- − testsuite/tests/javascript/T23479_2.stdout
- − testsuite/tests/javascript/T23479_3.hs
- − testsuite/tests/javascript/T23479_3.stdout
Changes:
=====================================
compiler/GHC/StgToJS/Apply.hs
=====================================
@@ -120,7 +120,6 @@ genApp ctx i args
= (,ExprInline) . (|=) top . app hdDecodeUtf8Z <$> varsForId v
-- Test case T23479_1
- -- Test case T23479_3 (rewrite required)
| [StgLitArg (LitString bs)] <- args
, Just d <- decodeModifiedUTF8 bs
, idName i == unsafeUnpackJSStringUtf8ShShName
=====================================
testsuite/tests/javascript/Makefile
=====================================
@@ -13,15 +13,7 @@ T23479_1:
./T23479_1
# check that the optimization occurred
grep -c "h\$$r1 = \"test_val_1\"" T23479_1.dump-js
-
-T23479_2:
- '$(TEST_HC)' $(TEST_HC_OPTS) T23479_2.hs -v0 -O2 -dsuppress-uniques -ddump-js -ddump-to-file
- ./T23479_2
- # check that the optimization occurred
- grep -c "h\$$r1 = \"test_val_2\"" T23479_2.dump-js
-
-T23479_3:
- '$(TEST_HC)' $(TEST_HC_OPTS) T23479_3.hs -v0 -O2 -dsuppress-uniques -ddump-js -ddump-to-file
- ./T23479_3
- # check that the optimization occurred
- grep -c "h\$$r1 = \"test_val_3\"" T23479_3.dump-js
+ 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
=====================================
testsuite/tests/javascript/T23479_1.hs
=====================================
@@ -1,15 +1,33 @@
{-# LANGUAGE MagicHash #-}
+module Main where
import GHC.Prim
-
import GHC.JS.Prim
foreign import javascript "((x) => { console.log(x); })"
js_log1 :: JSVal -> IO ()
+test_val_2 :: String
+test_val_2 = "test_val_2"
+
+test_val_80_global :: String
+test_val_80_global = "test_val_80_globaltest_val_80_globaltest_val_80_globaltest_val_80_globaltest_val"
+
main :: IO ()
main = do
- js_log1 (JSVal (unsafeUnpackJSStringUtf8## test_addr_1))
+ -- Direct usage
+ js_log1 (JSVal (unsafeUnpackJSStringUtf8## "test_val_1"#))
+ -- Requires string sinker hit for strings shorter 80 symbols
+ js_log1 (toJSString test_val_2)
+ -- Requires rewrite hit "toJSString/literal"
+ js_log1 (toJSString test_val_3)
+ -- Locally defined strings become unfloatted at any length
+ js_log1 (toJSString test_val_80_local)
+ -- Globally defined strings with length >= 80 should not be unfloatted
+ js_log1 (toJSString test_val_80_global)
where
- test_addr_1 :: Addr#
- test_addr_1 = "test_val_1"#
+ test_val_3 :: String
+ test_val_3 = "test_val_3"
+
+ test_val_80_local :: String
+ test_val_80_local = "test_val_80_localtest_val_80_localtest_val_80_localtest_val_80_localtest_val_80_"
=====================================
testsuite/tests/javascript/T23479_1.stdout
=====================================
@@ -1,2 +1,10 @@
test_val_1
+test_val_2
+test_val_3
+test_val_80_localtest_val_80_localtest_val_80_localtest_val_80_localtest_val_80_
+test_val_80_globaltest_val_80_globaltest_val_80_globaltest_val_80_globaltest_val
1
+1
+1
+1
+0
=====================================
testsuite/tests/javascript/T23479_2.hs deleted
=====================================
@@ -1,14 +0,0 @@
-module Main where
-
-import GHC.Prim
-import GHC.JS.Prim
-
-foreign import javascript "((x) => { console.log(x); })"
- js_log1 :: JSVal -> IO ()
-
-test_val_2 :: String
-test_val_2 = "test_val_2"
-
-main :: IO ()
-main = do
- js_log1 $ toJSString test_val_2
=====================================
testsuite/tests/javascript/T23479_2.stdout deleted
=====================================
@@ -1,2 +0,0 @@
-test_val_2
-1
=====================================
testsuite/tests/javascript/T23479_3.hs deleted
=====================================
@@ -1,14 +0,0 @@
-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
- js_log1 (toJSString test_val_3)
- where
- test_val_3 :: String
- test_val_3 = "test_val_3"
=====================================
testsuite/tests/javascript/T23479_3.stdout deleted
=====================================
@@ -1,2 +0,0 @@
-test_val_3
-1
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e50ef19474162b136ea594cfc8e593197efa0e46
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e50ef19474162b136ea594cfc8e593197efa0e46
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/3fca5757/attachment-0001.html>
More information about the ghc-commits
mailing list