summaryrefslogtreecommitdiff
path: root/compiler/GHC/StgToJS
Commit message (Collapse)AuthorAgeFilesLines
* Replace GHCJS Objectable with GHC Binarywip/js-binaryJosh Meredith2022-06-168-486/+380
|
* Add primopSylvain Henry2022-06-151-0/+1
|
* Add primopsSylvain Henry2022-06-151-0/+7
|
* Temporarily wire-in base's shimSylvain Henry2022-06-152-23/+37
| | | | | | Use JS_BASE_PATH env var to set base's shim directory (js_base for now) Also minor other changes
* JS.Linker: remove dflags includePath workaround.doyougnu2022-06-141-8/+3
| | | | | | | | We implemented a workaround for shims that modified the dynflags includePaths so that the JS backend would find the rts.h file during CPP of shims. Since aebcca98 this is no longer required because we've removed the need for rts.h completely. Thus, this commit reverts that modification.
* Add some missing primops (Word32,Int32)Sylvain Henry2022-06-131-13/+53
| | | | | Also fix the rendering of missing primops (they must be z-encoded to avoid having a "#" in their JS name)
* Enhance and fix LinkerStatsSylvain Henry2022-06-132-86/+115
| | | | | | | | | | Document and refactor renderLinker Split collectDeps Fix collectDeps Fix linker stats rendering
* Linker: add more typesSylvain Henry2022-06-133-63/+85
| | | | Some cleanup
* JS.Linker: add shimsSylvain Henry2022-06-135-16/+319
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GHCJS uses JS files for primitive things like the GC and RTS. We call these JS files "shims". This sequence of commits adds shims from JS and includes them for linking. In addition the shim directory is controlled via an evironment variable JS_RTS_PATH...at least for now. Linker: implement tryReadShimFile Linker: link with shims provided via an env variable Use JS_RTS_PATH to provide a directory into which .js and .js.pp files will be linked into rts.js JS.Linker: add js dir at root, fix js cpp includes JS.gc.pp: remove variadic macro JS.RTS: add rts JS shims files, remove shim CPP RTS: remove the need for rts.h and add rts JS files rts.h only contained a few constants duplicated in the codegen. Let's use the Haskell version as the single source of truth and pass defined values explicitly to cpp command line ("-DXYZ=abc" arguments). Also switch from "raw" (use_cpp_and_not_cc_dash_E = True) to the opposite: in both case we call "cc -E" (meh), but with False the preprocessor doesn't choke one varargs in macros. RTS: remove integer.js.pp We use the native ghc-bignum backend, so we don't need the GMP compatible JS code. In addition, this code was failing to run as it requires the JSBN (https://www.npmjs.com/package/jsbn) "Javascript big number" library, which we don't necessarily have installed. RTS: fix typo in field name RTS: generate CPP macros in Haskell RTS: share common CPP def into CAFs
* JS: silence haddock warningsdoyougnu2022-06-136-11/+18
|
* JS-Backend: rebased to master 468f919bdoyougnu2022-06-131-2/+4
| | | | | | | | | | | | | | | First rebase of the JS-Backend. This rebase includes the JS backend combined with !7442 (new backend design). Unfortunately we have to short circuit the new backend design because the JS backend takes over after STG and not after StgToCmm. What's working: - hadrian builds JS backend - JS backend outputs .js files and "links" them What still has to be done: - JS backend is missing core js libraries as we add these we discover bugs in the linker and js rts.
* Linker: remove JS Shims,tiny GHC.Linker refactorSylvain Henry2022-06-131-10/+32
|
* Linker: force less efficient (but working) static encodingSylvain Henry2022-06-131-3/+8
|
* Linker: reenable packStrings (not yet implemented though)Sylvain Henry2022-06-131-6/+2
|
* Linker: deduplication + fixesSylvain Henry2022-06-133-498/+35
| | | | | | - deduplicate code that was copied from old GHC - explicitly add preloadUnits to the link - avoid calling getShims
* Rename u_env into unit_env (more common)Sylvain Henry2022-06-131-7/+8
|
* Docs: JS.Syntax, JS.Make docs donedoyougnu2022-06-134-15/+20
| | | | | | | | | | JS-backend: Add documentation headers Docs: JS.Syntax done Docs: JS.Make done Docs: JS.Make JS.Syntax refined a bit
* Add outputable instance for DepsSylvain Henry2022-06-131-0/+6
|
* Linker: remove wiring of ghcjs-prim and ghcjs-thSylvain Henry2022-06-132-95/+40
| | | | They will be replaced by ghc-prim, base, template-haskell, etc.
* Remove unused ghcjs unit related codeSylvain Henry2022-06-131-30/+0
|
* Linker: enhance debugging messageSylvain Henry2022-06-132-1/+8
|
* Codegen: fix symbol names pprSylvain Henry2022-06-131-1/+1
|
* fix duplicate module name in symbolsLuite Stegeman2022-06-131-6/+4
|
* fix package name in module name field of system dependenciesLuite Stegeman2022-06-131-3/+3
|
* CodeGen: handle proxy#Sylvain Henry2022-06-131-0/+6
|
* CodeGen: restore assignAll (instead of assignAllEqual)Sylvain Henry2022-06-131-1/+1
|
* CodeGen: remove useless importsSylvain Henry2022-06-131-2/+0
|
* CodeGen: better debug message for assignCoerce1Sylvain Henry2022-06-131-1/+6
|
* CodeGen: support StackSnapshot# in primTypeVtSylvain Henry2022-06-131-0/+1
|
* CodeGen: output LitRubbish as null JS valuesSylvain Henry2022-06-131-12/+13
|
* JS.Literals: Adapt genLit to new Literal domaindoyougnu2022-06-131-0/+12
|
* JS.Expr: Fix unhandled datacon for RuntimeRepdoyougnu2022-06-131-2/+8
|
* JS.CoreUtils: handle IOPort casedoyougnu2022-06-131-0/+1
|
* JS.Types: Add Outputable for TypedExprdoyougnu2022-06-131-2/+6
|
* CodeGen: cache LNE frame sizeSylvain Henry2022-06-131-5/+7
|
* CodeGen: refactor ExprCtx codeSylvain Henry2022-06-139-92/+212
|
* codegen: enhance genCon debug messageSylvain Henry2022-06-131-2/+2
|
* JS.Linker: Hook up to GHC.Driver.Pipelinedoyougnu2022-06-134-89/+155
| | | | | | | | | | JS.Linker.Types: Add newGhcjsEnv function JS.UnitUtils: fix encodeModule api JS.Linker: more removal of HscEnv JS.Linker: hooked into GHC.Driver.Pipeline
* Linker: fix stage2 buildSylvain Henry2022-06-131-22/+21
|
* JS.Backend: Add JS specific Linkerdoyougnu2022-06-1313-77/+4206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JS: initialize Linker, DynamicLinking JS.Printer: adapted to GHC Head JS.Printer: some cleanup and init Printer StgToJS.Printer: Compiles JS.Linker: Add types, expose JS keywords JS.Syntax: add Binary instance on Ident's JS.Linker: Migrate more Types to Data.Binary JS.Linker.Types: compiles and adapted to GHC Head JS.Linker.Types: compiles JS.Linker.Types: add UseBase type JS.Linker: Comments and Cleanup JS.Linker.Types: add TH types, Env type, DepsLoc JS.Linker: more FIXMEs numerous Linker fixes JS.Linker: removed Text references JS.UnitUtils: add package related helper functions JS.Linker: more DynFlags removal JS.Linker: Time for semantic errors JS.Linker: DynFlags finally removed JS.Linker: 107 compile errors to go JS.Linker.Utils: initialized, adapted to GHC Head JS.Linker.Utils: initialize Utils module JS.Linker.Utils: more utils JS.Rts: move rtsText to Rts JS.Linker: linkerStats implemented JS.Compactor: compiles, adapted to GHC Head JS.Compactor: have to retrofit compact for linker JS.Linker.Compactor: unwinding lenses JS.Linker.Compactor: comments over addItem JS.Linker.Compactor: Lenses removed JS.Linker.Compactor: SHA256 removed JS.Linker.Compactor: only missing instances left JS.Linker.Compactor: compiles JS.Linker: compiles, adapted to ghc Head JS.Linker: More progress JS.Linker: link in memory compiles JS.Linker: just shims left JS.Linker.DynamicLinking compiles: adapted to head JS.Linker.DynamicLinking: initialization JS.Linker.DynamicLinking: compiles up to Variants JS.Variants: initialize JS.Linker: numerous and various fixes JS.Linker.DynamicLinking: only small errors left JS.Linker.Archive: compiles, adapted to GHC Head JS.Linker: initialize Archive compat module JS.Linker.Archive: minor fixes JS.Linker.DynamicLinking: compiles JS.Linker: cleanup, remove Variants, add comments fixup: more cleanup JS.Linker: more cleanup and comments
* JS.Backend: add FFI code but don't implement yetSylvain Henry2022-06-131-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FFI: don't crash on JavaScript foreign imports Note that they are still not desugared properly!! But the following cmd doesn't crash anymore: ghc -fjavascript Test.hs -fforce-recomp -ddump-tc -fno-code -ddump-ds FFI: adapt GHCJS desugarer FFI: support direct application The following example: foo :: Int# -> Int# foo = add 50000# foreign import javascript "(function(x,y) { return (x + y) })" add :: Int# -> Int# -> Int# is compiled into an application like this: var h$mainZCMzifoozur2_e; h$mainZCMzifoozur2_e = (function() { var h$mainZCMziaddzur1; h$mainZCMziaddzur1 = h$r1.d1; var h$$mainZCMzietazuB0_8KXnScrCjF5; h$$mainZCMzietazuB0_8KXnScrCjF5 = h$r2; h$r3 = h$$mainZCMzietazuB0_8KXnScrCjF5; h$r2 = 50000; h$r1 = h$mainZCMziaddzur1; return h$ap_2_2_fast(); return h$rs(); }); var h$mainZCMziaddzur1_e; h$mainZCMziaddzur1_e = (function() { var h$$mainZCMzidszusAk_236l8r0P8S9; h$$mainZCMzidszusAk_236l8r0P8S9 = h$r2; var h$$mainZCMzids1zusAl_336l8r0P8S9; h$$mainZCMzids1zusAl_336l8r0P8S9 = h$r3; var h$$mainZCM_2; var h$$mainZCMziwildzusAn_536l8r0P8S9; try { h$$mainZCMziwildzusAn_536l8r0P8S9 = (function(x,y) { return (x + y) })(h$$mainZCMzidszusAk_236l8r0P8S9, h$$mainZCMzids1zusAl_336l8r0P8S9) } catch(except) { return h$throwJSException(except) }; var h$$mainZCMzids3zusAp_736l8r0P8S9; h$$mainZCMzids3zusAp_736l8r0P8S9 = h$$mainZCMziwildzusAn_536l8r0P8S9; h$r1 = h$$mainZCMzids3zusAp_736l8r0P8S9; return h$rs(); }); FFI: correctly dispatch for foreign exports too FFI: move C FFI desugaring into its own module FFI: avoid DynFlags in toJsName (copy of toCName)
* JS: cleanup, renaming, better module layoutSylvain Henry2022-06-1311-1051/+995
| | | | | | | | | | | | | | | | | Various degrees of cleanup adapting GHCJS to GHC. We move several functions to CoreUtils, remove duplication between the JS.Rts.Apply and Apply module and factor out closure related code into a Closure module for cohesion. Deduplicate code between Rts.Apply and Apply Move might_be_a_function into CoreUtils Factorize closure stuff into Closure module Rename closureExtra into closureField Minor renamings, comments...
* JS.Rts; refactoring and move to StgToJSSylvain Henry2022-06-135-14/+1654
| | | | | | | | | | | | * add closure manipulation helpers and use them in Apply * add cache (Array) for pre-generated PAP names * reduce line length: * use BlockArguments instead of parens * remove implicit mconcat in jVar's body Rts: more refactorings Rts: move into StgToJS hierarchy
* Doc has been moved into GHC.StgToJs top-level moduleSylvain Henry2022-06-131-66/+0
|
* Add JS.Rtsdoyougnu2022-06-1310-62/+304
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JS.Rts: compiles reword: progress on RtsTypes StgToJS.Config: add SDoc Context JSRts: move ppr, workaround def type JSRts.Types: compiles JS.Rts: closer to compiling JS.Rts: move jsIdIdent' to StgToJS.Monad JS.Rts: remove unused predicates JS: cleanup, comment sections, math funcs to Make JS.Rts.Types: compiles StgToJS.Expr: fix compilation errors StgToJS.DataCon: move initClosure JS.Rts: remove Alloc module JS.Rts: initalize Rts module, remove redundant fs JS: init Rts.Alloc move initClosure JS.Apply: unwinding combinators in progress JS: add helpers and fixmes JS.Rts.Apply: no more e's, add closure, reg helper StgToJS: add ToStat instance ClosureInfo JS.Rts.Apply: closer to compiling JS.Rts.Apply: more removal of # JS.Rts.Apply: (#) removed JS.Rts.Apply: compiles JS.Rts.Rts: just pretty printing left JS.Rts: Add Notes JS.Rts: add file headers and notes JS.Rts.Rts: fixing stringy issues JS.Rts.Rts: compiles JS.Rts.Rts: fix non-exhaustive patterns warnings
* Add JavaScript code generatordoyougnu2022-06-1321-0/+6520
Adapt code generator of GHCJS to GHC head. Currently it is only enabled with the hidden -fjavascript flag. It produces .o files that can't be used yet except by GHCJS's linker. Codegen: doc Codegen: correctly return linkable object Now we can build a static library (-staticlib) Codegen: doc genLit Codegen: use assignAll Codegen: introduce TypedExpr Refactor assignAll et al, add documentation Codegen: minor changes Doc