summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* compiler: enforce cmm switch planning for wasm32Cheng Shao2022-11-111-1/+2
| | | | | | This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size.
* driver: pass -Wa,--no-type-check for wasm32 when runAsPhaseCheng Shao2022-11-111-0/+31
| | | | | This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation.
* compiler: allow big arith for wasm32Cheng Shao2022-11-111-1/+1
| | | | | This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes.
* driver: avoid -Wl,--no-as-needed for wasm32Cheng Shao2022-11-111-1/+1
| | | | | | The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32.
* compiler: add util functions for UniqFM and UniqMapCheng Shao2022-11-112-1/+41
| | | | | | This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG.
* autoconf: set CrossCompiling=YES in cross bindist configureCheng Shao2022-11-111-0/+8
| | | | | This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist.
* base: avoid using unsupported posix functionality on wasm32Cheng Shao2022-11-116-4/+104
| | | | | This base patch avoids using unsupported posix functionality on wasm32.
* base: more autoconf checks for wasm32Cheng Shao2022-11-111-0/+9
| | | | | | This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32.
* base: fall back to using monotonic clock to emulate cputime on wasm32Cheng Shao2022-11-114-0/+30
| | | | | On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id.
* rts: wasm32 specific logicCheng Shao2022-11-117-0/+214
| | | | This patch adds the rest of wasm32 specific logic in rts.
* Add register mapping for wasm32Cheng Shao2022-11-117-1/+237
| | | | | This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description.
* rts: OSThreads.h: stub types for wasm32Cheng Shao2022-11-111-0/+16
| | | | | | | This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32.
* rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on ↵Cheng Shao2022-11-111-1/+3
| | | | | | | | wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all.
* rts: make flushExec a no-op on wasm32Cheng Shao2022-11-111-0/+1
| | | | | This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place.
* rts: don't return memory to OS on wasm32Cheng Shao2022-11-112-0/+8
| | | | | | This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm].
* rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32Cheng Shao2022-11-111-10/+24
| | | | | | | libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality.
* rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32Cheng Shao2022-11-111-1/+1
| | | | | On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED.
* rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32Cheng Shao2022-11-111-1/+5
| | | | The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32.
* rts: no timer for wasm32Cheng Shao2022-11-112-0/+25
| | | | | | | Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads.
* rts: RtsStartup: chdir to PWD on wasm32Cheng Shao2022-11-111-0/+11
| | | | | | | | | | | | This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside.
* rts: wasm32 placeholder linkerCheng Shao2022-11-113-0/+15
| | | | | | This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32.
* rts: checkSuid: don't do it when not HAVE_GETUIDCheng Shao2022-11-111-1/+1
| | | | | When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target.
* rts: genericRaise: use exit() instead when not HAVE_RAISECheng Shao2022-11-111-1/+3
| | | | | We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise.
* rts: IPE.c: don't do mutex stuff when THREADED_RTS is not definedCheng Shao2022-11-111-0/+10
| | | | | This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c.
* rts: use HAVE_GETPID to guard subprocess related logicCheng Shao2022-11-113-2/+20
| | | | | | | We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all.
* rts: don't define RTS_USER_SIGNALS when signal.h is not presentCheng Shao2022-11-117-7/+32
| | | | | | | | In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals.
* rts: prefer ffi_type_void over FFI_TYPE_VOIDCheng Shao2022-11-111-1/+1
| | | | | | | | This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here.
* testsuite: correct sleep() signature in T5611Cheng Shao2022-11-112-4/+6
| | | | | In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm.
* rts: workaround cmm's improper variadic ccall breaking wasm32 typecheckingCheng Shao2022-11-116-10/+15
| | | | | | | | | | | | | | | | Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets.
* deriveConstants: parse .ll output for wasm32 due to broken nmCheng Shao2022-11-111-2/+21
| | | | | | | This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object.
* Add support for the wasm32-wasi target tupleCheng Shao2022-11-1116-4/+35
| | | | | | This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits.
* add new modules for reducibility and WebAssembly translationNorman Ramsey2022-11-115-0/+898
|
* add the two key graph modules from Martin Erwig's FGLNorman Ramsey2022-11-114-0/+1022
| | | | | | | | | | | | | | | | | | | | | | | | | | Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed.
* Fix Cmm symbol kindCheng Shao2022-11-1113-14/+237
|
* hadrian: add targetSupportsThreadedRts flagCheng Shao2022-11-119-18/+39
| | | | | | | | | | | | | | This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32.
* hadrian: add -Wwarn only for cross-compiling unixCheng Shao2022-11-111-1/+11
|
* autoconf: check getpid getuid raiseCheng Shao2022-11-111-0/+2
| | | | | This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked.
* Boxity: Handle argument budget of unboxed tuples correctly (#21737)Sebastian Graf2022-11-105-50/+252
| | | | | | | Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737.
* WorkWrap: Unboxing unboxed tuples is not always useful (#22388)Sebastian Graf2022-11-104-12/+136
| | | | | | See Note [Unboxing through unboxed tuples]. Fixes #22388.
* Fix DsUselessSpecialiseForClassMethodSelector msgwip/T21851Simon Peyton Jones2022-11-101-1/+1
| | | | | The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix
* Make indexError work betterSimon Peyton Jones2022-11-102-3/+24
| | | | | | | | | | | | | | | The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility.
* Fire RULES in the SpecialiserSimon Peyton Jones2022-11-1017-237/+521
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961
* GHCi tags generation phase 2Hécate Moonlight2022-11-091-1/+1
| | | | see #19884
* Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117)Giles Anderson2022-11-0948-110/+257
| | | | | | | | | | | | The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily
* Document what Alternative/MonadPlus instances actually doJade Lovelace2022-11-082-8/+26
|
* Add example for (<$)Jade Lovelace2022-11-081-0/+9
|
* Clarify msum/asum documentationJade Lovelace2022-11-081-2/+8
|
* Fix TypeData issues (fixes #22315 and #22332)Ross Paterson2022-11-0828-74/+261
| | | | | | | | | | | | | | | | | | | | | | | | There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ)
* Define `Infinite` list and use where appropriate.M Farkas-Dyck2022-11-0821-89/+300
| | | | | | | | Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].
* bump llvm upper boundCarter Schonwald2022-11-071-1/+1
|