Rodrigo Mesquita pushed to branch wip/T26166 at Glasgow Haskell Compiler / GHC
Commits:
-
33772e41
by Ben Gamari at 2025-10-10T16:25:25+01:00
29 changed files:
- compiler/GHC/HsToCore/Foreign/C.hs
- compiler/GHC/Linker/Dynamic.hs
- compiler/GHC/Linker/Static.hs
- + libraries/ghc-internal/cbits/RtsIface.c
- libraries/ghc-internal/ghc-internal.cabal.in
- + libraries/ghc-internal/include/RtsIfaceSymbols.h
- rts/BuiltinClosures.c
- rts/CloneStack.h
- rts/Compact.cmm
- rts/ContinuationOps.cmm
- rts/Exception.cmm
- rts/Prelude.h
- rts/PrimOps.cmm
- rts/RtsAPI.c
- rts/RtsStartup.c
- rts/RtsSymbols.c
- + rts/RtsToHsIface.c
- rts/Schedule.c
- rts/StgStdThunks.cmm
- rts/configure.ac
- โ rts/external-symbols.list.in
- rts/include/Rts.h
- rts/include/RtsAPI.h
- + rts/include/rts/RtsToHsIface.h
- rts/posix/Signals.c
- โ rts/rts.buildinfo.in
- rts/rts.cabal
- rts/wasm/JSFFI.c
- utils/deriveConstants/Main.hs
Changes:
| ... | ... | @@ -517,8 +517,8 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc |
| 517 | 517 | text "rts_apply" <> parens (
|
| 518 | 518 | cap
|
| 519 | 519 | <> (if is_IO_res_ty
|
| 520 | - then text "runIO_closure"
|
|
| 521 | - else text "runNonIO_closure")
|
|
| 520 | + then text "ghc_hs_iface->runIO_closure"
|
|
| 521 | + else text "ghc_hs_iface->runNonIO_closure")
|
|
| 522 | 522 | <> comma
|
| 523 | 523 | <> expr_to_run
|
| 524 | 524 | ) <+> comma
|
| ... | ... | @@ -150,10 +150,6 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages |
| 150 | 150 | -- (and should) do without this for all libraries except
|
| 151 | 151 | -- the RTS; all we need to do is to pass the correct
|
| 152 | 152 | -- HSfoo_dyn.dylib files to the link command.
|
| 153 | - -- This feature requires Mac OS X 10.3 or later; there is
|
|
| 154 | - -- a similar feature, -flat_namespace -undefined suppress,
|
|
| 155 | - -- which works on earlier versions, but it has other
|
|
| 156 | - -- disadvantages.
|
|
| 157 | 153 | -- -single_module
|
| 158 | 154 | -- Build the dynamic library as a single "module", i.e. no
|
| 159 | 155 | -- dynamic binding nonsense when referring to symbols from
|
| ... | ... | @@ -250,6 +250,13 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do |
| 250 | 250 | ++ pkg_lib_path_opts
|
| 251 | 251 | ++ extraLinkObj
|
| 252 | 252 | ++ noteLinkObjs
|
| 253 | + -- See Note [RTS/ghc-internal interface]
|
|
| 254 | + -- (-u<sym> must come before -lghc-internal...!)
|
|
| 255 | + ++ (if ghcInternalUnitId `elem` map unitId pkgs
|
|
| 256 | + then [concat [ "-Wl,-u,"
|
|
| 257 | + , ['_' | platformLeadingUnderscore platform]
|
|
| 258 | + , "init_ghc_hs_iface" ]]
|
|
| 259 | + else [])
|
|
| 253 | 260 | ++ pkg_link_opts
|
| 254 | 261 | ++ pkg_framework_opts
|
| 255 | 262 | ++ (if platformOS platform == OSDarwin
|
| 1 | +/*
|
|
| 2 | + * (c) The GHC Team, 2025-2026
|
|
| 3 | + *
|
|
| 4 | + * RTS/ghc-internal interface
|
|
| 5 | + *
|
|
| 6 | + * See Note [RTS/ghc-internal interface].
|
|
| 7 | + */
|
|
| 8 | + |
|
| 9 | +#include "Rts.h"
|
|
| 10 | + |
|
| 11 | +void init_ghc_hs_iface(void) __attribute__((constructor));
|
|
| 12 | + |
|
| 13 | +// Forward declarations
|
|
| 14 | +#define CLOSURE(module, symbol) \
|
|
| 15 | + extern StgClosure ghczminternal_##module##_##symbol;
|
|
| 16 | + |
|
| 17 | +#define UNDEF_CLOSURE(module, symbol)
|
|
| 18 | + |
|
| 19 | +#define INFO_TBL(module, symbol) \
|
|
| 20 | + extern StgInfoTable ghczminternal_##module##_##symbol;
|
|
| 21 | + |
|
| 22 | +#include "RtsIfaceSymbols.h"
|
|
| 23 | + |
|
| 24 | +#undef CLOSURE
|
|
| 25 | +#undef UNDEF_CLOSURE
|
|
| 26 | +#undef INFO_TBL
|
|
| 27 | + |
|
| 28 | +// HsIface definition
|
|
| 29 | +#define CLOSURE(module, symbol) \
|
|
| 30 | + .symbol = &ghczminternal_##module##_##symbol,
|
|
| 31 | + |
|
| 32 | +#define UNDEF_CLOSURE(module, symbol) \
|
|
| 33 | + .symbol = NULL,
|
|
| 34 | + |
|
| 35 | +#define INFO_TBL(module, symbol) \
|
|
| 36 | + .symbol = &ghczminternal_##module##_##symbol,
|
|
| 37 | + |
|
| 38 | +static const HsIface the_ghc_hs_iface = {
|
|
| 39 | +#include "RtsIfaceSymbols.h"
|
|
| 40 | +};
|
|
| 41 | + |
|
| 42 | +void init_ghc_hs_iface(void)
|
|
| 43 | +{
|
|
| 44 | + /*
|
|
| 45 | + * N.B. ghc-internal may be load multiple times, e.g., when the
|
|
| 46 | + * RTS linker is in use. For this reason we explicitly refuse to
|
|
| 47 | + * override ghc_hs_iface if it has already been initialized.
|
|
| 48 | + */
|
|
| 49 | + if (ghc_hs_iface == NULL) {
|
|
| 50 | + ghc_hs_iface = &the_ghc_hs_iface;
|
|
| 51 | + }
|
|
| 52 | +} |
| ... | ... | @@ -43,6 +43,7 @@ extra-source-files: |
| 43 | 43 | include/winio_structs.h
|
| 44 | 44 | include/WordSize.h
|
| 45 | 45 | include/HsIntegerGmp.h.in
|
| 46 | + include/RtsIfaceSymbols.h
|
|
| 46 | 47 | install-sh
|
| 47 | 48 | |
| 48 | 49 | source-repository head
|
| ... | ... | @@ -444,6 +445,7 @@ Library |
| 444 | 445 | cbits/strerror.c
|
| 445 | 446 | cbits/debug.c
|
| 446 | 447 | cbits/Stack_c.c
|
| 448 | + cbits/RtsIface.c
|
|
| 447 | 449 | |
| 448 | 450 | cmm-sources:
|
| 449 | 451 | cbits/StackCloningDecoding.cmm
|
| 1 | +// See Note [RTS/ghc-internal interface].
|
|
| 2 | + |
|
| 3 | +#if defined(mingw32_HOST_OS)
|
|
| 4 | +CLOSURE(GHCziInternalziEventziWindows, processRemoteCompletion_closure)
|
|
| 5 | +#else
|
|
| 6 | +UNDEF_CLOSURE(GHCziInternalziEventziWindows, processRemoteCompletion_closure)
|
|
| 7 | +#endif
|
|
| 8 | +CLOSURE(GHCziInternalziTopHandler, runIO_closure)
|
|
| 9 | +CLOSURE(GHCziInternalziTopHandler, runNonIO_closure)
|
|
| 10 | +CLOSURE(GHCziInternalziTuple, Z0T_closure)
|
|
| 11 | +CLOSURE(GHCziInternalziTypes, True_closure)
|
|
| 12 | +CLOSURE(GHCziInternalziTypes, False_closure)
|
|
| 13 | +CLOSURE(GHCziInternalziPack, unpackCString_closure)
|
|
| 14 | +CLOSURE(GHCziInternalziWeakziFinalizze, runFinalizzerBatch_closure)
|
|
| 15 | +CLOSURE(GHCziInternalziIOziException, stackOverflow_closure)
|
|
| 16 | +CLOSURE(GHCziInternalziIOziException, heapOverflow_closure)
|
|
| 17 | +CLOSURE(GHCziInternalziIOziException, allocationLimitExceeded_closure)
|
|
| 18 | +CLOSURE(GHCziInternalziIOziException, blockedIndefinitelyOnMVar_closure)
|
|
| 19 | +CLOSURE(GHCziInternalziIOziException, blockedIndefinitelyOnSTM_closure)
|
|
| 20 | +CLOSURE(GHCziInternalziIOziException, cannotCompactFunction_closure)
|
|
| 21 | +CLOSURE(GHCziInternalziIOziException, cannotCompactPinned_closure)
|
|
| 22 | +CLOSURE(GHCziInternalziIOziException, cannotCompactMutable_closure)
|
|
| 23 | +CLOSURE(GHCziInternalziControlziExceptionziBase, nonTermination_closure)
|
|
| 24 | +CLOSURE(GHCziInternalziControlziExceptionziBase, nestedAtomically_closure)
|
|
| 25 | +CLOSURE(GHCziInternalziControlziExceptionziBase, noMatchingContinuationPrompt_closure)
|
|
| 26 | +CLOSURE(GHCziInternalziEventziThread, blockedOnBadFD_closure)
|
|
| 27 | +CLOSURE(GHCziInternalziConcziSync, runSparks_closure)
|
|
| 28 | +CLOSURE(GHCziInternalziConcziIO, ensureIOManagerIsRunning_closure)
|
|
| 29 | +CLOSURE(GHCziInternalziConcziIO, interruptIOManager_closure)
|
|
| 30 | +CLOSURE(GHCziInternalziConcziIO, ioManagerCapabilitiesChanged_closure)
|
|
| 31 | +CLOSURE(GHCziInternalziConcziSignal, runHandlersPtr_closure)
|
|
| 32 | +CLOSURE(GHCziInternalziTopHandler, flushStdHandles_closure)
|
|
| 33 | +CLOSURE(GHCziInternalziTopHandler, runMainIO_closure)
|
|
| 34 | +INFO_TBL(GHCziInternalziTypes, Czh_con_info)
|
|
| 35 | +INFO_TBL(GHCziInternalziTypes, Izh_con_info)
|
|
| 36 | +INFO_TBL(GHCziInternalziTypes, Fzh_con_info)
|
|
| 37 | +INFO_TBL(GHCziInternalziTypes, Dzh_con_info)
|
|
| 38 | +INFO_TBL(GHCziInternalziTypes, Wzh_con_info)
|
|
| 39 | +CLOSURE(GHCziInternalziPrimziPanic, absentSumFieldError_closure)
|
|
| 40 | +CLOSURE(GHCziInternalziAllocationLimitHandler, runAllocationLimitHandler_closure)
|
|
| 41 | +INFO_TBL(GHCziInternalziPtr, Ptr_con_info)
|
|
| 42 | +INFO_TBL(GHCziInternalziPtr, FunPtr_con_info)
|
|
| 43 | +INFO_TBL(GHCziInternalziInt, I8zh_con_info)
|
|
| 44 | +INFO_TBL(GHCziInternalziInt, I16zh_con_info)
|
|
| 45 | +INFO_TBL(GHCziInternalziInt, I32zh_con_info)
|
|
| 46 | +INFO_TBL(GHCziInternalziInt, I64zh_con_info)
|
|
| 47 | +INFO_TBL(GHCziInternalziWord, W8zh_con_info)
|
|
| 48 | +INFO_TBL(GHCziInternalziWord, W16zh_con_info)
|
|
| 49 | +INFO_TBL(GHCziInternalziWord, W32zh_con_info)
|
|
| 50 | +INFO_TBL(GHCziInternalziWord, W64zh_con_info)
|
|
| 51 | +INFO_TBL(GHCziInternalziStable, StablePtr_con_info)
|
|
| 52 | +CLOSURE(GHCziInternalziStackziCloneStack, StackSnapshot_closure)
|
|
| 53 | +CLOSURE(GHCziInternalziExceptionziType, divZZeroException_closure)
|
|
| 54 | +CLOSURE(GHCziInternalziExceptionziType, underflowException_closure)
|
|
| 55 | +CLOSURE(GHCziInternalziExceptionziType, overflowException_closure)
|
|
| 56 | +CLOSURE(GHCziInternalziCString, unpackCStringzh_closure)
|
|
| 57 | +INFO_TBL(GHCziInternalziCString, unpackCStringzh_info)
|
|
| 58 | +INFO_TBL(GHCziInternalziCString, unpackCStringUtf8zh_info)
|
|
| 59 | +#if defined(wasm32_HOST_ARCH)
|
|
| 60 | +CLOSURE(GHCziInternalziWasmziPrimziImports, raiseJSException_closure)
|
|
| 61 | +CLOSURE(GHCziInternalziWasmziPrim, JSVal_con_info)
|
|
| 62 | +CLOSURE(GHCziInternalziWasmziPrim, threadDelay_closure)
|
|
| 63 | +#else
|
|
| 64 | +UNDEF_CLOSURE(GHCziInternalziWasmziPrimziImports, raiseJSException_closure)
|
|
| 65 | +UNDEF_CLOSURE(GHCziInternalziWasmziPrim, JSVal_con_info)
|
|
| 66 | +UNDEF_CLOSURE(GHCziInternalziWasmziPrim, threadDelay_closure)
|
|
| 67 | +#endif |
| 1 | 1 | #include "Rts.h"
|
| 2 | -#include "Prelude.h"
|
|
| 3 | 2 | #include "BuiltinClosures.h"
|
| 4 | 3 | |
| 5 | 4 | /*
|
| ... | ... | @@ -17,14 +16,14 @@ void initBuiltinClosures(void) { |
| 17 | 16 | // INTLIKE closures
|
| 18 | 17 | for (int i = MIN_INTLIKE; i <= MAX_INTLIKE; i++) {
|
| 19 | 18 | StgIntCharlikeClosure *c = &stg_INTLIKE_closure[i - MIN_INTLIKE];
|
| 20 | - SET_HDR((StgClosure* ) c, Izh_con_info, CCS_SYSTEM_OR_NULL);
|
|
| 19 | + SET_HDR((StgClosure* ) c, ghc_hs_iface->Izh_con_info, CCS_SYSTEM_OR_NULL);
|
|
| 21 | 20 | c->data = i;
|
| 22 | 21 | }
|
| 23 | 22 | |
| 24 | 23 | // CHARLIKE closures
|
| 25 | 24 | for (int i = MIN_CHARLIKE; i <= MAX_CHARLIKE; i++) {
|
| 26 | 25 | StgIntCharlikeClosure *c = &stg_CHARLIKE_closure[i - MIN_CHARLIKE];
|
| 27 | - SET_HDR((StgClosure* ) c, Czh_con_info, CCS_SYSTEM_OR_NULL);
|
|
| 26 | + SET_HDR((StgClosure* ) c, ghc_hs_iface->Czh_con_info, CCS_SYSTEM_OR_NULL);
|
|
| 28 | 27 | c->data = i;
|
| 29 | 28 | }
|
| 30 | 29 | } |
| ... | ... | @@ -8,8 +8,7 @@ |
| 8 | 8 | |
| 9 | 9 | #pragma once
|
| 10 | 10 | |
| 11 | -extern StgClosure ghczminternal_GHCziInternalziStackziCloneStack_StackSnapshot_closure;
|
|
| 12 | -#define StackSnapshot_constructor_closure (&(ghczminternal_GHCziInternalziStackziCloneStack_StackSnapshot_closure))
|
|
| 11 | +#define StackSnapshot_constructor_closure ghc_hs_iface->StackSnapshot_closure
|
|
| 13 | 12 | |
| 14 | 13 | StgStack* cloneStack(Capability* capability, const StgStack* stack);
|
| 15 | 14 |
| ... | ... | @@ -10,9 +10,6 @@ |
| 10 | 10 | #include "Cmm.h"
|
| 11 | 11 | #include "sm/ShouldCompact.h"
|
| 12 | 12 | |
| 13 | -import CLOSURE ghczminternal_GHCziInternalziIOziException_cannotCompactFunction_closure;
|
|
| 14 | -import CLOSURE ghczminternal_GHCziInternalziIOziException_cannotCompactMutable_closure;
|
|
| 15 | -import CLOSURE ghczminternal_GHCziInternalziIOziException_cannotCompactPinned_closure;
|
|
| 16 | 13 | #if !defined(UnregisterisedCompiler)
|
| 17 | 14 | import CLOSURE g0;
|
| 18 | 15 | import CLOSURE large_alloc_lim;
|
| ... | ... | @@ -124,7 +121,7 @@ eval: |
| 124 | 121 | SMALL_MUT_ARR_PTRS_CLEAN,
|
| 125 | 122 | SMALL_MUT_ARR_PTRS_DIRTY,
|
| 126 | 123 | COMPACT_NFDATA: {
|
| 127 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_cannotCompactMutable_closure);
|
|
| 124 | + jump stg_raisezh(HsIface_cannotCompactMutable_closure(W_[ghc_hs_iface]));
|
|
| 128 | 125 | }
|
| 129 | 126 | |
| 130 | 127 | // We shouldn't see any functions, if this data structure was NFData.
|
| ... | ... | @@ -139,7 +136,7 @@ eval: |
| 139 | 136 | BCO,
|
| 140 | 137 | PAP,
|
| 141 | 138 | CONTINUATION: {
|
| 142 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_cannotCompactFunction_closure);
|
|
| 139 | + jump stg_raisezh(HsIface_cannotCompactFunction_closure(W_[ghc_hs_iface]));
|
|
| 143 | 140 | }
|
| 144 | 141 | |
| 145 | 142 | case ARR_WORDS: {
|
| ... | ... | @@ -147,7 +144,7 @@ eval: |
| 147 | 144 | (should) = ccall shouldCompact(compact "ptr", p "ptr");
|
| 148 | 145 | if (should == SHOULDCOMPACT_IN_CNF) { P_[pp] = p; return(); }
|
| 149 | 146 | if (should == SHOULDCOMPACT_PINNED) {
|
| 150 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_cannotCompactPinned_closure);
|
|
| 147 | + jump stg_raisezh(HsIface_cannotCompactPinned_closure(W_[ghc_hs_iface]));
|
|
| 151 | 148 | }
|
| 152 | 149 | |
| 153 | 150 | CHECK_HASH();
|
| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | #include "Cmm.h"
|
| 14 | 14 | |
| 15 | -import CLOSURE ghczminternal_GHCziInternalziControlziExceptionziBase_noMatchingContinuationPrompt_closure;
|
|
| 16 | 15 | #if !defined(UnregisterisedCompiler)
|
| 17 | 16 | import CLOSURE ALLOC_RTS_ctr;
|
| 18 | 17 | import CLOSURE ALLOC_RTS_tot;
|
| ... | ... | @@ -104,7 +103,7 @@ stg_control0zh_ll // explicit stack |
| 104 | 103 | |
| 105 | 104 | // see Note [When capturing the continuation fails] in Continuation.c
|
| 106 | 105 | if (cont == NULL) (likely: False) {
|
| 107 | - jump stg_raisezh(ghczminternal_GHCziInternalziControlziExceptionziBase_noMatchingContinuationPrompt_closure);
|
|
| 106 | + jump stg_raisezh(HsIface_noMatchingContinuationPrompt_closure(W_[ghc_hs_iface]));
|
|
| 108 | 107 | }
|
| 109 | 108 | |
| 110 | 109 | W_ apply_mask_frame;
|
| ... | ... | @@ -13,10 +13,6 @@ |
| 13 | 13 | #include "Cmm.h"
|
| 14 | 14 | #include "RaiseAsync.h"
|
| 15 | 15 | |
| 16 | -import CLOSURE ghczminternal_GHCziInternalziTypes_True_closure;
|
|
| 17 | -import CLOSURE ghczminternal_GHCziInternalziExceptionziType_divZZeroException_closure;
|
|
| 18 | -import CLOSURE ghczminternal_GHCziInternalziExceptionziType_underflowException_closure;
|
|
| 19 | -import CLOSURE ghczminternal_GHCziInternalziExceptionziType_overflowException_closure;
|
|
| 20 | 16 | #if !defined(UnregisterisedCompiler)
|
| 21 | 17 | import CLOSURE CATCHF_PUSHED_ctr;
|
| 22 | 18 | import CLOSURE RtsFlags;
|
| ... | ... | @@ -539,7 +535,7 @@ retry_pop_stack: |
| 539 | 535 | Sp(10) = exception;
|
| 540 | 536 | Sp(9) = stg_raise_ret_info;
|
| 541 | 537 | Sp(8) = exception;
|
| 542 | - Sp(7) = ghczminternal_GHCziInternalziTypes_True_closure; // True <=> an exception
|
|
| 538 | + Sp(7) = HsIface_True_closure(W_[ghc_hs_iface]); // True <=> an exception
|
|
| 543 | 539 | Sp(6) = stg_ap_ppv_info;
|
| 544 | 540 | Sp(5) = 0;
|
| 545 | 541 | Sp(4) = stg_ap_n_info;
|
| ... | ... | @@ -650,17 +646,17 @@ stg_raiseIOzh (P_ exception) |
| 650 | 646 | |
| 651 | 647 | stg_raiseDivZZerozh ()
|
| 652 | 648 | {
|
| 653 | - jump stg_raisezh(ghczminternal_GHCziInternalziExceptionziType_divZZeroException_closure);
|
|
| 649 | + jump stg_raisezh(HsIface_divZZeroException_closure(W_[ghc_hs_iface]));
|
|
| 654 | 650 | }
|
| 655 | 651 | |
| 656 | 652 | stg_raiseUnderflowzh ()
|
| 657 | 653 | {
|
| 658 | - jump stg_raisezh(ghczminternal_GHCziInternalziExceptionziType_underflowException_closure);
|
|
| 654 | + jump stg_raisezh(HsIface_underflowException_closure(W_[ghc_hs_iface]));
|
|
| 659 | 655 | }
|
| 660 | 656 | |
| 661 | 657 | stg_raiseOverflowzh ()
|
| 662 | 658 | {
|
| 663 | - jump stg_raisezh(ghczminternal_GHCziInternalziExceptionziType_overflowException_closure);
|
|
| 659 | + jump stg_raisezh(HsIface_overflowException_closure(W_[ghc_hs_iface]));
|
|
| 664 | 660 | }
|
| 665 | 661 | |
| 666 | 662 | /* The FFI doesn't support variadic C functions so we can't directly expose
|
| ... | ... | @@ -19,126 +19,69 @@ |
| 19 | 19 | #define PRELUDE_CLOSURE(i) extern StgClosure (i)
|
| 20 | 20 | #endif
|
| 21 | 21 | |
| 22 | -/* See Note [Wired-in exceptions are not CAFfy] in GHC.Core.Make. */
|
|
| 23 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziPrimziPanic_absentSumFieldError_closure);
|
|
| 24 | 22 | |
| 25 | 23 | /* Define canonical names so we can abstract away from the actual
|
| 26 | 24 | * modules these names are defined in.
|
| 27 | 25 | */
|
| 28 | 26 | |
| 29 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTuple_Z0T_closure);
|
|
| 30 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTypes_True_closure);
|
|
| 31 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTypes_False_closure);
|
|
| 32 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziPack_unpackCString_closure);
|
|
| 33 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziPack_unpackCStringUtf8_closure);
|
|
| 34 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziWeak_runFinalizzerBatch_closure);
|
|
| 35 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziWeakziFinalizze_runFinalizzerBatch_closure);
|
|
| 36 | - |
|
| 37 | 27 | #if defined(IN_STG_CODE)
|
| 38 | 28 | extern W_ ZCMain_main_closure[];
|
| 39 | 29 | #else
|
| 40 | 30 | extern StgClosure ZCMain_main_closure;
|
| 41 | 31 | #endif
|
| 42 | 32 | |
| 43 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_stackOverflow_closure);
|
|
| 44 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 45 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_allocationLimitExceeded_closure);
|
|
| 46 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnMVar_closure);
|
|
| 47 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnSTM_closure);
|
|
| 48 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_cannotCompactFunction_closure);
|
|
| 49 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_cannotCompactPinned_closure);
|
|
| 50 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziIOziException_cannotCompactMutable_closure);
|
|
| 51 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziControlziExceptionziBase_nonTermination_closure);
|
|
| 52 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziControlziExceptionziBase_nestedAtomically_closure);
|
|
| 53 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziThread_blockedOnBadFD_closure);
|
|
| 54 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziExceptionziType_divZZeroException_closure);
|
|
| 55 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziExceptionziType_underflowException_closure);
|
|
| 56 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziExceptionziType_overflowException_closure);
|
|
| 57 | - |
|
| 58 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziConcziSync_runSparks_closure);
|
|
| 59 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziConcziIO_ensureIOManagerIsRunning_closure);
|
|
| 60 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziConcziIO_interruptIOManager_closure);
|
|
| 61 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure);
|
|
| 62 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure);
|
|
| 63 | -#if defined(mingw32_HOST_OS)
|
|
| 64 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure);
|
|
| 65 | -#endif
|
|
| 66 | - |
|
| 67 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure);
|
|
| 68 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure);
|
|
| 69 | -PRELUDE_CLOSURE(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure);
|
|
| 70 | - |
|
| 71 | -PRELUDE_INFO(ghczminternal_GHCziInternalziCString_unpackCStringzh_info);
|
|
| 72 | -PRELUDE_INFO(ghczminternal_GHCziInternalziTypes_Czh_con_info);
|
|
| 73 | -PRELUDE_INFO(ghczminternal_GHCziInternalziTypes_Izh_con_info);
|
|
| 74 | -PRELUDE_INFO(ghczminternal_GHCziInternalziTypes_Fzh_con_info);
|
|
| 75 | -PRELUDE_INFO(ghczminternal_GHCziInternalziTypes_Dzh_con_info);
|
|
| 76 | -PRELUDE_INFO(ghczminternal_GHCziInternalziTypes_Wzh_con_info);
|
|
| 77 | - |
|
| 78 | -PRELUDE_INFO(ghczminternal_GHCziInternalziPtr_Ptr_con_info);
|
|
| 79 | -PRELUDE_INFO(ghczminternal_GHCziInternalziPtr_FunPtr_con_info);
|
|
| 80 | -PRELUDE_INFO(ghczminternal_GHCziInternalziInt_I8zh_con_info);
|
|
| 81 | -PRELUDE_INFO(ghczminternal_GHCziInternalziInt_I16zh_con_info);
|
|
| 82 | -PRELUDE_INFO(ghczminternal_GHCziInternalziInt_I32zh_con_info);
|
|
| 83 | -PRELUDE_INFO(ghczminternal_GHCziInternalziInt_I64zh_con_info);
|
|
| 84 | -PRELUDE_INFO(ghczminternal_GHCziInternalziWord_W8zh_con_info);
|
|
| 85 | -PRELUDE_INFO(ghczminternal_GHCziInternalziWord_W16zh_con_info);
|
|
| 86 | -PRELUDE_INFO(ghczminternal_GHCziInternalziWord_W32zh_con_info);
|
|
| 87 | -PRELUDE_INFO(ghczminternal_GHCziInternalziWord_W64zh_con_info);
|
|
| 88 | -PRELUDE_INFO(ghczminternal_GHCziInternalziStable_StablePtr_con_info);
|
|
| 89 | - |
|
| 90 | -#define Unit_closure (&(ghczminternal_GHCziInternalziTuple_Z0T_closure))
|
|
| 91 | -#define True_closure (&(ghczminternal_GHCziInternalziTypes_True_closure))
|
|
| 92 | -#define False_closure (&(ghczminternal_GHCziInternalziTypes_False_closure))
|
|
| 93 | -#define unpackCString_closure (&(ghczminternal_GHCziInternalziPack_unpackCString_closure))
|
|
| 94 | -#define runFinalizerBatch_closure (&(ghczminternal_GHCziInternalziWeakziFinalizze_runFinalizzerBatch_closure))
|
|
| 33 | +#define Unit_closure ghc_hs_iface->Z0T_closure
|
|
| 34 | +#define True_closure ghc_hs_iface->True_closure
|
|
| 35 | +#define False_closure ghc_hs_iface->False_closure
|
|
| 36 | +#define unpackCString_closure ghc_hs_iface->unpackCString_closure
|
|
| 37 | +#define runFinalizerBatch_closure ghc_hs_iface->runFinalizzerBatch_closure
|
|
| 95 | 38 | #define mainIO_closure (&ZCMain_main_closure)
|
| 96 | 39 | |
| 97 | -#define runSparks_closure (&(ghczminternal_GHCziInternalziConcziSync_runSparks_closure))
|
|
| 98 | -#define ensureIOManagerIsRunning_closure (&(ghczminternal_GHCziInternalziConcziIO_ensureIOManagerIsRunning_closure))
|
|
| 99 | -#define interruptIOManager_closure (&(ghczminternal_GHCziInternalziConcziIO_interruptIOManager_closure))
|
|
| 100 | -#define ioManagerCapabilitiesChanged_closure (&(ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure))
|
|
| 101 | -#define runHandlersPtr_closure (&(ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure))
|
|
| 40 | +#define runSparks_closure ghc_hs_iface->runSparks_closure
|
|
| 41 | +#define ensureIOManagerIsRunning_closure ghc_hs_iface->ensureIOManagerIsRunning_closure
|
|
| 42 | +#define interruptIOManager_closure ghc_hs_iface->interruptIOManager_closure
|
|
| 43 | +#define ioManagerCapabilitiesChanged_closure ghc_hs_iface->ioManagerCapabilitiesChanged_closure
|
|
| 44 | +#define runHandlersPtr_closure ghc_hs_iface->runHandlersPtr_closure
|
|
| 102 | 45 | #if defined(mingw32_HOST_OS)
|
| 103 | -#define processRemoteCompletion_closure (&(ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure))
|
|
| 46 | +#define processRemoteCompletion_closure ghc_hs_iface->processRemoteCompletion_closure
|
|
| 104 | 47 | #endif
|
| 105 | -#define runAllocationLimitHandler_closure (&(ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure))
|
|
| 106 | - |
|
| 107 | -#define flushStdHandles_closure (&(ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure))
|
|
| 108 | -#define runMainIO_closure (&(ghczminternal_GHCziInternalziTopHandler_runMainIO_closure))
|
|
| 109 | - |
|
| 110 | -#define stackOverflow_closure (&(ghczminternal_GHCziInternalziIOziException_stackOverflow_closure))
|
|
| 111 | -#define heapOverflow_closure (&(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure))
|
|
| 112 | -#define allocationLimitExceeded_closure (&(ghczminternal_GHCziInternalziIOziException_allocationLimitExceeded_closure))
|
|
| 113 | -#define blockedIndefinitelyOnMVar_closure (&(ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnMVar_closure))
|
|
| 114 | -#define blockedIndefinitelyOnSTM_closure (&(ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnSTM_closure))
|
|
| 115 | -#define cannotCompactFunction_closure (&(ghczminternal_GHCziInternalziIOziException_cannotCompactFunction_closure))
|
|
| 116 | -#define cannotCompactPinned_closure (&(ghczminternal_GHCziInternalziIOziException_cannotCompactPinned_closure))
|
|
| 117 | -#define cannotCompactMutable_closure (&(ghczminternal_GHCziInternalziIOziException_cannotCompactMutable_closure))
|
|
| 118 | -#define nonTermination_closure (&(ghczminternal_GHCziInternalziControlziExceptionziBase_nonTermination_closure))
|
|
| 119 | -#define nestedAtomically_closure (&(ghczminternal_GHCziInternalziControlziExceptionziBase_nestedAtomically_closure))
|
|
| 120 | -#define absentSumFieldError_closure (&(ghczminternal_GHCziInternalziPrimziPanic_absentSumFieldError_closure))
|
|
| 121 | -#define underflowException_closure (&(ghczminternal_GHCziInternalziExceptionziType_underflowException_closure))
|
|
| 122 | -#define overflowException_closure (&(ghczminternal_GHCziInternalziExceptionziType_overflowException_closure))
|
|
| 123 | -#define divZeroException_closure (&(ghczminternal_GHCziInternalziExceptionziType_divZZeroException_closure))
|
|
| 124 | - |
|
| 125 | -#define blockedOnBadFD_closure (&(ghczminternal_GHCziInternalziEventziThread_blockedOnBadFD_closure))
|
|
| 126 | - |
|
| 127 | -#define Czh_con_info (&(ghczminternal_GHCziInternalziTypes_Czh_con_info))
|
|
| 128 | -#define Izh_con_info (&(ghczminternal_GHCziInternalziTypes_Izh_con_info))
|
|
| 129 | -#define Fzh_con_info (&(ghczminternal_GHCziInternalziTypes_Fzh_con_info))
|
|
| 130 | -#define Dzh_con_info (&(ghczminternal_GHCziInternalziTypes_Dzh_con_info))
|
|
| 131 | -#define Wzh_con_info (&(ghczminternal_GHCziInternalziTypes_Wzh_con_info))
|
|
| 132 | -#define W8zh_con_info (&(ghczminternal_GHCziInternalziWord_W8zh_con_info))
|
|
| 133 | -#define W16zh_con_info (&(ghczminternal_GHCziInternalziWord_W16zh_con_info))
|
|
| 134 | -#define W32zh_con_info (&(ghczminternal_GHCziInternalziWord_W32zh_con_info))
|
|
| 135 | -#define W64zh_con_info (&(ghczminternal_GHCziInternalziWord_W64zh_con_info))
|
|
| 136 | -#define I8zh_con_info (&(ghczminternal_GHCziInternalziInt_I8zh_con_info))
|
|
| 137 | -#define I16zh_con_info (&(ghczminternal_GHCziInternalziInt_I16zh_con_info))
|
|
| 138 | -#define I32zh_con_info (&(ghczminternal_GHCziInternalziInt_I32zh_con_info))
|
|
| 139 | -#define I64zh_con_info (&(ghczminternal_GHCziInternalziInt_I64zh_con_info))
|
|
| 140 | -#define I64zh_con_info (&(ghczminternal_GHCziInternalziInt_I64zh_con_info))
|
|
| 141 | -#define Ptr_con_info (&(ghczminternal_GHCziInternalziPtr_Ptr_con_info))
|
|
| 142 | -#define FunPtr_con_info (&(ghczminternal_GHCziInternalziPtr_FunPtr_con_info))
|
|
| 143 | -#define StablePtr_static_info (&(ghczminternal_GHCziInternalziStable_StablePtr_static_info))
|
|
| 144 | -#define StablePtr_con_info (&(ghczminternal_GHCziInternalziStable_StablePtr_con_info)) |
|
| 48 | +#define runAllocationLimitHandler_closure ghc_hs_iface->runAllocationLimitHandler_closure
|
|
| 49 | + |
|
| 50 | +#define flushStdHandles_closure ghc_hs_iface->flushStdHandles_closure
|
|
| 51 | +#define runMainIO_closure ghc_hs_iface->runMainIO_closure
|
|
| 52 | + |
|
| 53 | +#define stackOverflow_closure ghc_hs_iface->stackOverflow_closure
|
|
| 54 | +#define heapOverflow_closure ghc_hs_iface->heapOverflow_closure
|
|
| 55 | +#define allocationLimitExceeded_closure ghc_hs_iface->allocationLimitExceeded_closure
|
|
| 56 | +#define blockedIndefinitelyOnMVar_closure ghc_hs_iface->blockedIndefinitelyOnMVar_closure
|
|
| 57 | +#define blockedIndefinitelyOnSTM_closure ghc_hs_iface->blockedIndefinitelyOnSTM_closure
|
|
| 58 | +#define cannotCompactFunction_closure ghc_hs_iface->cannotCompactFunction_closure
|
|
| 59 | +#define cannotCompactPinned_closure ghc_hs_iface->cannotCompactPinned_closure
|
|
| 60 | +#define cannotCompactMutable_closure ghc_hs_iface->cannotCompactMutable_closure
|
|
| 61 | +#define nonTermination_closure ghc_hs_iface->nonTermination_closure
|
|
| 62 | +#define nestedAtomically_closure ghc_hs_iface->nestedAtomically_closure
|
|
| 63 | +#define absentSumFieldError_closure ghc_hs_iface->absentSumFieldError_closure
|
|
| 64 | +#define underflowException_closure ghc_hs_iface->underflowException_closure
|
|
| 65 | +#define overflowException_closure ghc_hs_iface->overflowException_closure
|
|
| 66 | +#define divZeroException_closure ghc_hs_iface->divZZeroException_closure
|
|
| 67 | + |
|
| 68 | +#define blockedOnBadFD_closure ghc_hs_iface->blockedOnBadFD_closure
|
|
| 69 | + |
|
| 70 | +#define Czh_con_info ghc_hs_iface->Czh_con_info
|
|
| 71 | +#define Izh_con_info ghc_hs_iface->Izh_con_info
|
|
| 72 | +#define Fzh_con_info ghc_hs_iface->Fzh_con_info
|
|
| 73 | +#define Dzh_con_info ghc_hs_iface->Dzh_con_info
|
|
| 74 | +#define Wzh_con_info ghc_hs_iface->Wzh_con_info
|
|
| 75 | +#define W8zh_con_info ghc_hs_iface->W8zh_con_info
|
|
| 76 | +#define W16zh_con_info ghc_hs_iface->W16zh_con_info
|
|
| 77 | +#define W32zh_con_info ghc_hs_iface->W32zh_con_info
|
|
| 78 | +#define W64zh_con_info ghc_hs_iface->W64zh_con_info
|
|
| 79 | +#define I8zh_con_info ghc_hs_iface->I8zh_con_info
|
|
| 80 | +#define I16zh_con_info ghc_hs_iface->I16zh_con_info
|
|
| 81 | +#define I32zh_con_info ghc_hs_iface->I32zh_con_info
|
|
| 82 | +#define I64zh_con_info ghc_hs_iface->I64zh_con_info
|
|
| 83 | +#define I64zh_con_info ghc_hs_iface->I64zh_con_info
|
|
| 84 | +#define Ptr_con_info ghc_hs_iface->Ptr_con_info
|
|
| 85 | +#define FunPtr_con_info ghc_hs_iface->FunPtr_con_info
|
|
| 86 | +#define StablePtr_static_info ghc_hs_iface->StablePtr_static_info
|
|
| 87 | +#define StablePtr_con_info ghc_hs_iface->StablePtr_con_info |
| ... | ... | @@ -25,12 +25,8 @@ |
| 25 | 25 | #include "MachDeps.h"
|
| 26 | 26 | #include "SMPClosureOps.h"
|
| 27 | 27 | |
| 28 | -import CLOSURE ghczminternal_GHCziInternalziControlziExceptionziBase_nestedAtomically_closure;
|
|
| 29 | -import CLOSURE ghczminternal_GHCziInternalziIOziException_heapOverflow_closure;
|
|
| 30 | -import CLOSURE ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnMVar_closure;
|
|
| 31 | 28 | import AcquireSRWLockExclusive;
|
| 32 | 29 | import ReleaseSRWLockExclusive;
|
| 33 | -import CLOSURE ghczminternal_GHCziInternalziTypes_False_closure;
|
|
| 34 | 30 | #if defined(PROFILING)
|
| 35 | 31 | import CLOSURE CCS_MAIN;
|
| 36 | 32 | #endif
|
| ... | ... | @@ -118,7 +114,7 @@ stg_newByteArrayzh ( W_ n ) |
| 118 | 114 | |
| 119 | 115 | ("ptr" p) = ccall allocateArrBytes(MyCapability() "ptr", n, CCCS);
|
| 120 | 116 | if (p == NULL) (likely: False) {
|
| 121 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 117 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 122 | 118 | }
|
| 123 | 119 | return (p);
|
| 124 | 120 | }
|
| ... | ... | @@ -135,7 +131,7 @@ stg_newPinnedByteArrayzh ( W_ n ) |
| 135 | 131 | ("ptr" p) = ccall allocateArrBytesPinned(MyCapability() "ptr", n,
|
| 136 | 132 | BA_ALIGN, CCCS);
|
| 137 | 133 | if (p == NULL) (likely: False) {
|
| 138 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 134 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 139 | 135 | }
|
| 140 | 136 | return (p);
|
| 141 | 137 | }
|
| ... | ... | @@ -149,7 +145,7 @@ stg_newAlignedPinnedByteArrayzh ( W_ n, W_ alignment ) |
| 149 | 145 | ("ptr" p) = ccall allocateArrBytesPinned(MyCapability() "ptr", n,
|
| 150 | 146 | alignment, CCCS);
|
| 151 | 147 | if (p == NULL) (likely: False) {
|
| 152 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 148 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 153 | 149 | }
|
| 154 | 150 | return (p);
|
| 155 | 151 | }
|
| ... | ... | @@ -364,7 +360,7 @@ stg_newArrayzh ( W_ n /* words */, gcptr init ) |
| 364 | 360 | |
| 365 | 361 | ("ptr" arr) = ccall allocateMutArrPtrs(MyCapability() "ptr", n, CCCS);
|
| 366 | 362 | if (arr == NULL) (likely: False) {
|
| 367 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 363 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 368 | 364 | }
|
| 369 | 365 | |
| 370 | 366 | // Initialise all elements of the array with the value init
|
| ... | ... | @@ -474,7 +470,7 @@ stg_newSmallArrayzh ( W_ n /* words */, gcptr init ) |
| 474 | 470 | |
| 475 | 471 | ("ptr" arr) = ccall allocateSmallMutArrPtrs(MyCapability() "ptr", n, CCCS);
|
| 476 | 472 | if (arr == NULL) (likely: False) {
|
| 477 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 473 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 478 | 474 | }
|
| 479 | 475 | |
| 480 | 476 | // Initialise all elements of the array with the value init
|
| ... | ... | @@ -1090,7 +1086,7 @@ stg_listThreadszh () |
| 1090 | 1086 | ("ptr" arr) = ccall listThreads(MyCapability() "ptr");
|
| 1091 | 1087 | |
| 1092 | 1088 | if (arr == NULL) (likely: False) {
|
| 1093 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 1089 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 1094 | 1090 | }
|
| 1095 | 1091 | |
| 1096 | 1092 | return (arr);
|
| ... | ... | @@ -1360,7 +1356,7 @@ stg_atomicallyzh (P_ stm) |
| 1360 | 1356 | |
| 1361 | 1357 | /* Nested transactions are not allowed; raise an exception */
|
| 1362 | 1358 | if (old_trec != NO_TREC) (likely: False) {
|
| 1363 | - jump stg_raisezh(ghczminternal_GHCziInternalziControlziExceptionziBase_nestedAtomically_closure);
|
|
| 1359 | + jump stg_raisezh(HsIface_nestedAtomically_closure(W_[ghc_hs_iface]));
|
|
| 1364 | 1360 | }
|
| 1365 | 1361 | |
| 1366 | 1362 | code = stm;
|
| ... | ... | @@ -2231,7 +2227,7 @@ stg_unpackClosurezh ( P_ closure ) |
| 2231 | 2227 | dat_arr_sz = SIZEOF_StgArrBytes + WDS(len);
|
| 2232 | 2228 | ("ptr" dat_arr) = ccall allocateMightFail(MyCapability() "ptr", BYTES_TO_WDS(dat_arr_sz));
|
| 2233 | 2229 | if (dat_arr == NULL) (likely: False) {
|
| 2234 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 2230 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 2235 | 2231 | }
|
| 2236 | 2232 | TICK_ALLOC_PRIM(SIZEOF_StgArrBytes, WDS(len), 0);
|
| 2237 | 2233 | |
| ... | ... | @@ -2251,7 +2247,7 @@ for: |
| 2251 | 2247 | ("ptr" ptrArray) = foreign "C" heap_view_closurePtrs(MyCapability() "ptr", clos "ptr");
|
| 2252 | 2248 | |
| 2253 | 2249 | if (ptrArray == NULL) (likely: False) {
|
| 2254 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 2250 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 2255 | 2251 | }
|
| 2256 | 2252 | |
| 2257 | 2253 | return (info, dat_arr, ptrArray);
|
| ... | ... | @@ -2286,7 +2282,7 @@ stg_waitReadzh ( W_ fd ) |
| 2286 | 2282 | if (ok != 0::CBool) (likely: True) {
|
| 2287 | 2283 | jump stg_block_noregs();
|
| 2288 | 2284 | } else {
|
| 2289 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 2285 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 2290 | 2286 | }
|
| 2291 | 2287 | }
|
| 2292 | 2288 | |
| ... | ... | @@ -2299,7 +2295,7 @@ stg_waitWritezh ( W_ fd ) |
| 2299 | 2295 | if (ok != 0::CBool) (likely: True) {
|
| 2300 | 2296 | jump stg_block_noregs();
|
| 2301 | 2297 | } else {
|
| 2302 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 2298 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 2303 | 2299 | }
|
| 2304 | 2300 | }
|
| 2305 | 2301 | |
| ... | ... | @@ -2323,7 +2319,7 @@ stg_delayzh ( W_ us_delay ) |
| 2323 | 2319 | jump stg_block_noregs();
|
| 2324 | 2320 | #endif
|
| 2325 | 2321 | } else {
|
| 2326 | - jump stg_raisezh(ghczminternal_GHCziInternalziIOziException_heapOverflow_closure);
|
|
| 2322 | + jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
|
|
| 2327 | 2323 | }
|
| 2328 | 2324 | }
|
| 2329 | 2325 | |
| ... | ... | @@ -2518,13 +2514,13 @@ stg_getSparkzh () |
| 2518 | 2514 | W_ spark;
|
| 2519 | 2515 | |
| 2520 | 2516 | #if !defined(THREADED_RTS)
|
| 2521 | - return (0,ghczminternal_GHCziInternalziTypes_False_closure);
|
|
| 2517 | + return (0,HsIface_False_closure(W_[ghc_hs_iface]));
|
|
| 2522 | 2518 | #else
|
| 2523 | 2519 | ("ptr" spark) = ccall findSpark(MyCapability() "ptr");
|
| 2524 | 2520 | if (spark != 0) {
|
| 2525 | 2521 | return (1,spark);
|
| 2526 | 2522 | } else {
|
| 2527 | - return (0,ghczminternal_GHCziInternalziTypes_False_closure);
|
|
| 2523 | + return (0,HsIface_False_closure(W_[ghc_hs_iface]));
|
|
| 2528 | 2524 | }
|
| 2529 | 2525 | #endif
|
| 2530 | 2526 | }
|
| ... | ... | @@ -509,7 +509,7 @@ void rts_evalStableIOMain(/* inout */ Capability **cap, |
| 509 | 509 | SchedulerStatus stat;
|
| 510 | 510 | |
| 511 | 511 | p = (StgClosure *)deRefStablePtr(s);
|
| 512 | - w = rts_apply(*cap, &ghczminternal_GHCziInternalziTopHandler_runMainIO_closure, p);
|
|
| 512 | + w = rts_apply(*cap, runMainIO_closure, p);
|
|
| 513 | 513 | tso = createStrictIOThread(*cap, RtsFlags.GcFlags.initialStkSize, w);
|
| 514 | 514 | // async exceptions are always blocked by default in the created
|
| 515 | 515 | // thread. See #1048.
|
| ... | ... | @@ -961,7 +961,7 @@ void rts_done (void) |
| 961 | 961 | void hs_try_putmvar (/* in */ int capability,
|
| 962 | 962 | /* in */ HsStablePtr mvar)
|
| 963 | 963 | {
|
| 964 | - hs_try_putmvar_with_value(capability, mvar, TAG_CLOSURE(1, Unit_closure));
|
|
| 964 | + hs_try_putmvar_with_value(capability, mvar, TAG_CLOSURE(1, ghc_hs_iface->Z0T_closure));
|
|
| 965 | 965 | }
|
| 966 | 966 | |
| 967 | 967 | void hs_try_putmvar_with_value (/* in */ int capability,
|
| ... | ... | @@ -183,8 +183,8 @@ static void initBuiltinGcRoots(void) |
| 183 | 183 | * these closures `Id`s of these can be safely marked as non-CAFFY
|
| 184 | 184 | * in the compiler.
|
| 185 | 185 | */
|
| 186 | - getStablePtr((StgPtr)runIO_closure);
|
|
| 187 | - getStablePtr((StgPtr)runNonIO_closure);
|
|
| 186 | + getStablePtr((StgPtr)ghc_hs_iface->runIO_closure);
|
|
| 187 | + getStablePtr((StgPtr)ghc_hs_iface->runNonIO_closure);
|
|
| 188 | 188 | getStablePtr((StgPtr)flushStdHandles_closure);
|
| 189 | 189 | |
| 190 | 190 | getStablePtr((StgPtr)runFinalizerBatch_closure);
|
| ... | ... | @@ -263,6 +263,11 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config) |
| 263 | 263 | |
| 264 | 264 | setlocale(LC_CTYPE,"");
|
| 265 | 265 | |
| 266 | + if (ghc_hs_iface == NULL) {
|
|
| 267 | + errorBelch("hs_init_ghc: ghc_hs_iface is uninitialized");
|
|
| 268 | + stg_exit(1);
|
|
| 269 | + }
|
|
| 270 | + |
|
| 266 | 271 | /* Initialise the stats department, phase 0 */
|
| 267 | 272 | initStats0();
|
| 268 | 273 |
| ... | ... | @@ -464,6 +464,7 @@ extern char **environ; |
| 464 | 464 | RTS_PROF_SYMBOLS \
|
| 465 | 465 | RTS_LIBDW_SYMBOLS \
|
| 466 | 466 | SymI_HasProto(StgReturn) \
|
| 467 | + SymI_HasDataProto(ghc_hs_iface) \
|
|
| 467 | 468 | SymI_HasDataProto(stg_gc_noregs) \
|
| 468 | 469 | SymI_HasDataProto(stg_ret_v_info) \
|
| 469 | 470 | SymI_HasDataProto(stg_ret_p_info) \
|
| 1 | +/*
|
|
| 2 | + * (c) The GHC Team, 2025-2026
|
|
| 3 | + *
|
|
| 4 | + * RTS/ghc-internal interface
|
|
| 5 | + *
|
|
| 6 | + *
|
|
| 7 | + * Note [RTS/ghc-internal interface]
|
|
| 8 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 9 | + *
|
|
| 10 | + * The runtime system depends upon a variety of symbols defined by Haskell
|
|
| 11 | + * modules living in `ghc-internal`. To avoid cyclic dependencies between
|
|
| 12 | + * ghc-internal and the RTS, these symbols are referenced indirectly via the
|
|
| 13 | + * the `HsIface` structure (specifically `ghc_hs_iface`):
|
|
| 14 | + *
|
|
| 15 | + * struct HsIface {
|
|
| 16 | + * StgClosure *runIO; // GHC.Internal.TopHandler.runIO
|
|
| 17 | + * StgClosure *Z0T; // GHC.Internal.Tuple.()
|
|
| 18 | + * // etc.
|
|
| 19 | + * };
|
|
| 20 | + *
|
|
| 21 | + * `ghc_hs_iface` is initialized during program loading via the
|
|
| 22 | + * `init_ghc_hs_iface` constructor in `ghc-interface`
|
|
| 23 | + *
|
|
| 24 | + * const struct HsIface the_hs_iface = {
|
|
| 25 | + * .runIO = &ghczminternal_GHCziInternalziTopHandler_runIO_closure,
|
|
| 26 | + * .Z0T = &ghczminternal_GHCziInternalziTuple_Z0T_closure,
|
|
| 27 | + * // etc.
|
|
| 28 | + * };
|
|
| 29 | + *
|
|
| 30 | + * void __attribute__((constructor)) init_ghc_hs_iface() {
|
|
| 31 | + * ghc_hs_iface = &the_hs_iface;
|
|
| 32 | + * }
|
|
| 33 | + *
|
|
| 34 | + * This effectively breaks the RTS's link-time dependency, replacing it with a
|
|
| 35 | + * run-time dependency at the cost of an indirection. It also has the pleasant
|
|
| 36 | + * side-effect of making the interface between the RTS and `ghc-internal`
|
|
| 37 | + * explicit.
|
|
| 38 | + *
|
|
| 39 | + * Note that the ((constructor)) symbol is explicitly included in the final
|
|
| 40 | + * binary via the linker flag `-uinit_ghc_hs_iface`, when an executable is
|
|
| 41 | + * linked against ghc-internal by GHC.
|
|
| 42 | + *
|
|
| 43 | + * `-uinit_ghc_hs_iface` ensures that the `init_ghc_hs_iface` symbol is
|
|
| 44 | + * included in the final link, even when we link against `ghc-internal.a`
|
|
| 45 | + * (since, otherwise, only objects members which provide undefined symbols
|
|
| 46 | + * needed by the executable are included in the final object).
|
|
| 47 | + *
|
|
| 48 | + * When `ghc-internal` is a dynamic dependency of an executable, the
|
|
| 49 | + * constructor will run when the shared object for `ghc-internal` is loaded.
|
|
| 50 | + * When the executable is statically linked against `ghc-internal`, the
|
|
| 51 | + * constructor will be run when the program is loaded (since the constructor
|
|
| 52 | + * symbol was forcibly included as described in the paragraph above).
|
|
| 53 | + */
|
|
| 54 | + |
|
| 55 | +#include "Rts.h"
|
|
| 56 | + |
|
| 57 | +// This captures the symbols provided by ghc-internal which
|
|
| 58 | +// are needed by the RTS.
|
|
| 59 | +const HsIface *ghc_hs_iface = NULL; |
| ... | ... | @@ -1053,7 +1053,7 @@ scheduleProcessInbox (Capability **pcap USED_IF_THREADS) |
| 1053 | 1053 | while (p != NULL) {
|
| 1054 | 1054 | pnext = p->link;
|
| 1055 | 1055 | performTryPutMVar(cap, (StgMVar*)deRefStablePtr(p->mvar),
|
| 1056 | - Unit_closure);
|
|
| 1056 | + ghc_hs_iface->Z0T_closure);
|
|
| 1057 | 1057 | freeStablePtr(p->mvar);
|
| 1058 | 1058 | stgFree(p);
|
| 1059 | 1059 | p = pnext;
|
| ... | ... | @@ -13,8 +13,6 @@ |
| 13 | 13 | #include "Cmm.h"
|
| 14 | 14 | #include "Updates.h"
|
| 15 | 15 | |
| 16 | -import CLOSURE ghczminternal_GHCziInternalziCString_unpackCStringzh_info;
|
|
| 17 | -import CLOSURE ghczminternal_GHCziInternalziCString_unpackCStringUtf8zh_info;
|
|
| 18 | 16 | #if !defined(UnregisterisedCompiler)
|
| 19 | 17 | import CLOSURE STK_CHK_ctr;
|
| 20 | 18 | import CLOSURE stg_bh_upd_frame_info;
|
| ... | ... | @@ -348,7 +346,7 @@ stg_do_unpack_cstring(P_ node, P_ newCAF_ret) { |
| 348 | 346 | W_ str;
|
| 349 | 347 | str = StgThunk_payload(node, 2);
|
| 350 | 348 | push (UPDATE_FRAME_FIELDS(,,stg_bh_upd_frame_info, CCCS, 0, newCAF_ret)) {
|
| 351 | - jump %ENTRY_CODE(ghczminternal_GHCziInternalziCString_unpackCStringzh_info)(node, str);
|
|
| 349 | + jump %ENTRY_CODE(HsIface_unpackCStringzh_info(W_[ghc_hs_iface]))(node, str);
|
|
| 352 | 350 | }
|
| 353 | 351 | }
|
| 354 | 352 | |
| ... | ... | @@ -372,7 +370,7 @@ stg_do_unpack_cstring_utf8(P_ node, P_ newCAF_ret) { |
| 372 | 370 | W_ str;
|
| 373 | 371 | str = StgThunk_payload(node, 2);
|
| 374 | 372 | push (UPDATE_FRAME_FIELDS(,,stg_bh_upd_frame_info, CCCS, 0, newCAF_ret)) {
|
| 375 | - jump %ENTRY_CODE(ghczminternal_GHCziInternalziCString_unpackCStringUtf8zh_info)(node, str);
|
|
| 373 | + jump %ENTRY_CODE(HsIface_unpackCStringUtf8zh_info(W_[ghc_hs_iface]))(node, str);
|
|
| 376 | 374 | }
|
| 377 | 375 | }
|
| 378 | 376 |
| ... | ... | @@ -487,44 +487,3 @@ cat ghcautoconf.h.autoconf | sed \ |
| 487 | 487 | >> include/ghcautoconf.h
|
| 488 | 488 | echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h
|
| 489 | 489 | ] |
| 490 | - |
|
| 491 | -dnl ######################################################################
|
|
| 492 | -dnl Generate external symbol flags (-Wl,-u...)
|
|
| 493 | -dnl ######################################################################
|
|
| 494 | - |
|
| 495 | -dnl See Note [Undefined symbols in the RTS]
|
|
| 496 | - |
|
| 497 | -[
|
|
| 498 | -symbolExtraDefs=''
|
|
| 499 | -if [ "$CABAL_FLAG_find_ptr" = 1 ]; then
|
|
| 500 | - symbolExtraDefs+=' -DFIND_PTR'
|
|
| 501 | -fi
|
|
| 502 | - |
|
| 503 | -cat $srcdir/external-symbols.list.in \
|
|
| 504 | - | "$CC" $symbolExtraDefs -E -P -traditional -Iinclude - -o - \
|
|
| 505 | - | sed -e '/^ *$/d' \
|
|
| 506 | - > external-symbols.list \
|
|
| 507 | - || exit 1
|
|
| 508 | - |
|
| 509 | -if [ "$CABAL_FLAG_leading_underscore" = 1 ]; then
|
|
| 510 | - sedExpr='s/^(.*)$/ "-Wl,-u,_\1"/'
|
|
| 511 | -else
|
|
| 512 | - sedExpr='s/^(.*)$/ "-Wl,-u,\1"/'
|
|
| 513 | -fi
|
|
| 514 | -sed -E -e "${sedExpr}" external-symbols.list > external-symbols.flags
|
|
| 515 | -unset sedExpr
|
|
| 516 | -rm -f external-symbols.list
|
|
| 517 | -]
|
|
| 518 | - |
|
| 519 | -dnl ######################################################################
|
|
| 520 | -dnl Generate build-info
|
|
| 521 | -dnl ######################################################################
|
|
| 522 | - |
|
| 523 | -[
|
|
| 524 | -cat $srcdir/rts.buildinfo.in \
|
|
| 525 | - | "$CC" -E -P -traditional - -o - \
|
|
| 526 | - | sed -e '/^ *$/d' \
|
|
| 527 | - > rts.buildinfo \
|
|
| 528 | - || exit 1
|
|
| 529 | -rm -f external-symbols.flags
|
|
| 530 | -] |
| 1 | -#include "ghcautoconf.h"
|
|
| 2 | - |
|
| 3 | -#if 0
|
|
| 4 | -See Note [Undefined symbols in the RTS]
|
|
| 5 | -#endif
|
|
| 6 | - |
|
| 7 | -#if mingw32_HOST_OS
|
|
| 8 | -ghczminternal_GHCziInternalziEventziWindows_processRemoteCompletion_closure
|
|
| 9 | -#endif
|
|
| 10 | - |
|
| 11 | -#if FIND_PTR
|
|
| 12 | -findPtr
|
|
| 13 | -#endif
|
|
| 14 | - |
|
| 15 | -ghczminternal_GHCziInternalziTopHandler_runIO_closure
|
|
| 16 | -ghczminternal_GHCziInternalziTopHandler_runNonIO_closure
|
|
| 17 | -ghczminternal_GHCziInternalziTuple_Z0T_closure
|
|
| 18 | -ghczminternal_GHCziInternalziTypes_True_closure
|
|
| 19 | -ghczminternal_GHCziInternalziTypes_False_closure
|
|
| 20 | -ghczminternal_GHCziInternalziPack_unpackCString_closure
|
|
| 21 | -ghczminternal_GHCziInternalziWeakziFinalizze_runFinalizzerBatch_closure
|
|
| 22 | -ghczminternal_GHCziInternalziIOziException_stackOverflow_closure
|
|
| 23 | -ghczminternal_GHCziInternalziIOziException_heapOverflow_closure
|
|
| 24 | -ghczminternal_GHCziInternalziIOziException_allocationLimitExceeded_closure
|
|
| 25 | -ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnMVar_closure
|
|
| 26 | -ghczminternal_GHCziInternalziIOziException_blockedIndefinitelyOnSTM_closure
|
|
| 27 | -ghczminternal_GHCziInternalziIOziException_cannotCompactFunction_closure
|
|
| 28 | -ghczminternal_GHCziInternalziIOziException_cannotCompactPinned_closure
|
|
| 29 | -ghczminternal_GHCziInternalziIOziException_cannotCompactMutable_closure
|
|
| 30 | -ghczminternal_GHCziInternalziControlziExceptionziBase_nonTermination_closure
|
|
| 31 | -ghczminternal_GHCziInternalziControlziExceptionziBase_nestedAtomically_closure
|
|
| 32 | -ghczminternal_GHCziInternalziEventziThread_blockedOnBadFD_closure
|
|
| 33 | -ghczminternal_GHCziInternalziConcziSync_runSparks_closure
|
|
| 34 | -ghczminternal_GHCziInternalziConcziIO_ensureIOManagerIsRunning_closure
|
|
| 35 | -ghczminternal_GHCziInternalziConcziIO_interruptIOManager_closure
|
|
| 36 | -ghczminternal_GHCziInternalziConcziIO_ioManagerCapabilitiesChanged_closure
|
|
| 37 | -ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure
|
|
| 38 | -ghczminternal_GHCziInternalziTopHandler_flushStdHandles_closure
|
|
| 39 | -ghczminternal_GHCziInternalziTopHandler_runMainIO_closure
|
|
| 40 | -ghczminternal_GHCziInternalziTypes_Czh_con_info
|
|
| 41 | -ghczminternal_GHCziInternalziTypes_Izh_con_info
|
|
| 42 | -ghczminternal_GHCziInternalziTypes_Fzh_con_info
|
|
| 43 | -ghczminternal_GHCziInternalziTypes_Dzh_con_info
|
|
| 44 | -ghczminternal_GHCziInternalziTypes_Wzh_con_info
|
|
| 45 | -ghczminternal_GHCziInternalziAllocationLimitHandler_runAllocationLimitHandler_closure
|
|
| 46 | -ghczminternal_GHCziInternalziPtr_Ptr_con_info
|
|
| 47 | -ghczminternal_GHCziInternalziPtr_FunPtr_con_info
|
|
| 48 | -ghczminternal_GHCziInternalziInt_I8zh_con_info
|
|
| 49 | -ghczminternal_GHCziInternalziInt_I16zh_con_info
|
|
| 50 | -ghczminternal_GHCziInternalziInt_I32zh_con_info
|
|
| 51 | -ghczminternal_GHCziInternalziInt_I64zh_con_info
|
|
| 52 | -ghczminternal_GHCziInternalziWord_W8zh_con_info
|
|
| 53 | -ghczminternal_GHCziInternalziWord_W16zh_con_info
|
|
| 54 | -ghczminternal_GHCziInternalziWord_W32zh_con_info
|
|
| 55 | -ghczminternal_GHCziInternalziWord_W64zh_con_info
|
|
| 56 | -ghczminternal_GHCziInternalziStable_StablePtr_con_info
|
|
| 57 | -ghczminternal_GHCziInternalziStackziCloneStack_StackSnapshot_closure
|
|
| 58 | - |
|
| 59 | -#if 0
|
|
| 60 | -N.B. These symbols are defined in ghc-internal and may be referenced by the
|
|
| 61 | -unregisterised code-generator when compiling RTS Cmm sources.
|
|
| 62 | -#endif
|
|
| 63 | -hs_atomic_add8
|
|
| 64 | -hs_atomic_add16
|
|
| 65 | -hs_atomic_add32
|
|
| 66 | -hs_atomic_add64
|
|
| 67 | -hs_atomic_sub8
|
|
| 68 | -hs_atomic_sub16
|
|
| 69 | -hs_atomic_sub32
|
|
| 70 | -hs_atomic_sub64
|
|
| 71 | -hs_atomic_and8
|
|
| 72 | -hs_atomic_and16
|
|
| 73 | -hs_atomic_and32
|
|
| 74 | -hs_atomic_and64
|
|
| 75 | -hs_atomic_nand8
|
|
| 76 | -hs_atomic_nand16
|
|
| 77 | -hs_atomic_nand32
|
|
| 78 | -hs_atomic_nand64
|
|
| 79 | -hs_atomic_or8
|
|
| 80 | -hs_atomic_or16
|
|
| 81 | -hs_atomic_or32
|
|
| 82 | -hs_atomic_or64
|
|
| 83 | -hs_atomic_xor8
|
|
| 84 | -hs_atomic_xor16
|
|
| 85 | -hs_atomic_xor32
|
|
| 86 | -hs_atomic_xor64
|
|
| 87 | -hs_cmpxchg8
|
|
| 88 | -hs_cmpxchg16
|
|
| 89 | -hs_cmpxchg32
|
|
| 90 | -hs_cmpxchg64
|
|
| 91 | -hs_xchg8
|
|
| 92 | -hs_xchg16
|
|
| 93 | -hs_xchg32
|
|
| 94 | -hs_xchg64
|
|
| 95 | -hs_atomicread8
|
|
| 96 | -hs_atomicread16
|
|
| 97 | -hs_atomicread32
|
|
| 98 | -hs_atomicread64
|
|
| 99 | -hs_atomicwrite8
|
|
| 100 | -hs_atomicwrite16
|
|
| 101 | -hs_atomicwrite32
|
|
| 102 | -hs_atomicwrite64 |
| ... | ... | @@ -229,6 +229,7 @@ void _warnFail(const char *filename, unsigned int linenum); |
| 229 | 229 | #include "rts/storage/ClosureTypes.h"
|
| 230 | 230 | #include "rts/storage/TSO.h"
|
| 231 | 231 | #include "stg/MiscClosures.h" /* InfoTables, closures etc. defined in the RTS */
|
| 232 | + |
|
| 232 | 233 | #include "rts/storage/Block.h"
|
| 233 | 234 | #include "rts/storage/ClosureMacros.h"
|
| 234 | 235 | #include "rts/storage/MBlock.h"
|
| ... | ... | @@ -18,6 +18,7 @@ extern "C" { |
| 18 | 18 | #include "HsFFI.h"
|
| 19 | 19 | #include "rts/Time.h"
|
| 20 | 20 | #include "rts/Types.h"
|
| 21 | +#include "rts/RtsToHsIface.h"
|
|
| 21 | 22 | |
| 22 | 23 | /*
|
| 23 | 24 | * Running the scheduler
|
| ... | ... | @@ -584,11 +585,6 @@ void rts_done (void); |
| 584 | 585 | // Note that RtsAPI.h is also included by foreign export stubs in
|
| 585 | 586 | // the base package itself.
|
| 586 | 587 | //
|
| 587 | -extern StgClosure ghczminternal_GHCziInternalziTopHandler_runIO_closure;
|
|
| 588 | -extern StgClosure ghczminternal_GHCziInternalziTopHandler_runNonIO_closure;
|
|
| 589 | - |
|
| 590 | -#define runIO_closure (&(ghczminternal_GHCziInternalziTopHandler_runIO_closure))
|
|
| 591 | -#define runNonIO_closure (&(ghczminternal_GHCziInternalziTopHandler_runNonIO_closure))
|
|
| 592 | 588 | |
| 593 | 589 | /* ------------------------------------------------------------------------ */
|
| 594 | 590 |
| 1 | +/*
|
|
| 2 | + * (c) The GHC Team, 2025-2026
|
|
| 3 | + *
|
|
| 4 | + * RTS/ghc-internal interface
|
|
| 5 | + *
|
|
| 6 | + * See Note [RTS/ghc-internal interface].
|
|
| 7 | + */
|
|
| 8 | + |
|
| 9 | +typedef struct {
|
|
| 10 | + StgClosure *processRemoteCompletion_closure; // GHC.Internal.Event.Windows.processRemoteCompletion_closure
|
|
| 11 | + StgClosure *runIO_closure; // GHC.Internal.TopHandler.runIO_closure
|
|
| 12 | + StgClosure *runNonIO_closure; // GHC.Internal.TopHandler.runNonIO_closure
|
|
| 13 | + StgClosure *Z0T_closure; // GHC.Internal.Tuple.Z0T_closure
|
|
| 14 | + StgClosure *True_closure; // GHC.Internal.Types.True_closure
|
|
| 15 | + StgClosure *False_closure; // GHC.Internal.Types.False_closure
|
|
| 16 | + StgClosure *unpackCString_closure; // GHC.Internal.Pack.unpackCString_closure
|
|
| 17 | + StgClosure *runFinalizzerBatch_closure; // GHC.Internal.Weak.Finalizze.runFinalizzerBatch_closure
|
|
| 18 | + StgClosure *stackOverflow_closure; // GHC.Internal.IO.Exception.stackOverflow_closure
|
|
| 19 | + StgClosure *heapOverflow_closure; // GHC.Internal.IO.Exception.heapOverflow_closure
|
|
| 20 | + StgClosure *allocationLimitExceeded_closure; // GHC.Internal.IO.Exception.allocationLimitExceeded_closure
|
|
| 21 | + StgClosure *blockedIndefinitelyOnMVar_closure; // GHC.Internal.IO.Exception.blockedIndefinitelyOnMVar_closure
|
|
| 22 | + StgClosure *blockedIndefinitelyOnSTM_closure; // GHC.Internal.IO.Exception.blockedIndefinitelyOnSTM_closure
|
|
| 23 | + StgClosure *cannotCompactFunction_closure; // GHC.Internal.IO.Exception.cannotCompactFunction_closure
|
|
| 24 | + StgClosure *cannotCompactPinned_closure; // GHC.Internal.IO.Exception.cannotCompactPinned_closure
|
|
| 25 | + StgClosure *cannotCompactMutable_closure; // GHC.Internal.IO.Exception.cannotCompactMutable_closure
|
|
| 26 | + StgClosure *nonTermination_closure; // GHC.Internal.Control.Exception.Base.nonTermination_closure
|
|
| 27 | + StgClosure *nestedAtomically_closure; // GHC.Internal.Control.Exception.Base.nestedAtomically_closure
|
|
| 28 | + StgClosure *noMatchingContinuationPrompt_closure; // GHC.Internal.Control.Exception.Base.noMatchingContinuationPrompt_closure
|
|
| 29 | + StgClosure *blockedOnBadFD_closure; // GHC.Internal.Event.Thread.blockedOnBadFD_closure
|
|
| 30 | + StgClosure *runSparks_closure; // GHC.Internal.Conc.Sync.runSparks_closure
|
|
| 31 | + StgClosure *ensureIOManagerIsRunning_closure; // GHC.Internal.Conc.IO.ensureIOManagerIsRunning_closure
|
|
| 32 | + StgClosure *interruptIOManager_closure; // GHC.Internal.Conc.IO.interruptIOManager_closure
|
|
| 33 | + StgClosure *ioManagerCapabilitiesChanged_closure; // GHC.Internal.Conc.IO.ioManagerCapabilitiesChanged_closure
|
|
| 34 | + StgClosure *runHandlersPtr_closure; // GHC.Internal.Conc.Signal.runHandlersPtr_closure
|
|
| 35 | + StgClosure *flushStdHandles_closure; // GHC.Internal.TopHandler.flushStdHandles_closure
|
|
| 36 | + StgClosure *runMainIO_closure; // GHC.Internal.TopHandler.runMainIO_closure
|
|
| 37 | + StgInfoTable *Czh_con_info; // GHC.Internal.Types.Czh_con_info
|
|
| 38 | + StgInfoTable *Izh_con_info; // GHC.Internal.Types.Izh_con_info
|
|
| 39 | + StgInfoTable *Fzh_con_info; // GHC.Internal.Types.Fzh_con_info
|
|
| 40 | + StgInfoTable *Dzh_con_info; // GHC.Internal.Types.Dzh_con_info
|
|
| 41 | + StgInfoTable *Wzh_con_info; // GHC.Internal.Types.Wzh_con_info
|
|
| 42 | + StgClosure *absentSumFieldError_closure; // GHC.Internal.Prim.Panic.absentSumFieldError_closure
|
|
| 43 | + StgClosure *runAllocationLimitHandler_closure; // GHC.Internal.AllocationLimitHandler.runAllocationLimitHandler_closure
|
|
| 44 | + StgInfoTable *Ptr_con_info; // GHC.Internal.Ptr.Ptr_con_info
|
|
| 45 | + StgInfoTable *FunPtr_con_info; // GHC.Internal.Ptr.FunPtr_con_info
|
|
| 46 | + StgInfoTable *I8zh_con_info; // GHC.Internal.Int.I8zh_con_info
|
|
| 47 | + StgInfoTable *I16zh_con_info; // GHC.Internal.Int.I16zh_con_info
|
|
| 48 | + StgInfoTable *I32zh_con_info; // GHC.Internal.Int.I32zh_con_info
|
|
| 49 | + StgInfoTable *I64zh_con_info; // GHC.Internal.Int.I64zh_con_info
|
|
| 50 | + StgInfoTable *W8zh_con_info; // GHC.Internal.Word.W8zh_con_info
|
|
| 51 | + StgInfoTable *W16zh_con_info; // GHC.Internal.Word.W16zh_con_info
|
|
| 52 | + StgInfoTable *W32zh_con_info; // GHC.Internal.Word.W32zh_con_info
|
|
| 53 | + StgInfoTable *W64zh_con_info; // GHC.Internal.Word.W64zh_con_info
|
|
| 54 | + StgInfoTable *StablePtr_con_info; // GHC.Internal.Stable.StablePtr_con_info
|
|
| 55 | + StgClosure *StackSnapshot_closure; // GHC.Internal.Stack.CloneStack.StackSnapshot_closure
|
|
| 56 | + StgClosure *divZZeroException_closure; // GHC.Internal.Exception.Type.divZeroException_closure
|
|
| 57 | + StgClosure *underflowException_closure; // GHC.Internal.Exception.Type.underflowException_closure
|
|
| 58 | + StgClosure *overflowException_closure; // GHC.Internal.Exception.Type.overflowException_closure
|
|
| 59 | + StgClosure *unpackCStringzh_closure; // GHC.Internal.CString.unpackCStringzh_closure
|
|
| 60 | + StgInfoTable *unpackCStringzh_info; // GHC.Internal.CString.unpackCStringzh_info
|
|
| 61 | + StgInfoTable *unpackCStringUtf8zh_info; // GHC.Internal.CString.unpackCStringUtf8zh_info
|
|
| 62 | + StgClosure *raiseJSException_closure; // GHC.Internal.Wasm.Prim.Imports.raiseJSException_closure
|
|
| 63 | + StgClosure *JSVal_con_info; // GHC.Internal.Wasm.Prim.JSVal_con_info
|
|
| 64 | + StgClosure *threadDelay_closure; // GHC.Internal.Wasm.Prim.threadDelay_closure
|
|
| 65 | +} HsIface;
|
|
| 66 | + |
|
| 67 | +extern const HsIface *ghc_hs_iface; |
| ... | ... | @@ -222,7 +222,7 @@ ioManagerDie (void) |
| 222 | 222 | void
|
| 223 | 223 | ioManagerStartCap (Capability **cap)
|
| 224 | 224 | {
|
| 225 | - rts_evalIO(cap,&ghczminternal_GHCziInternalziConcziIO_ensureIOManagerIsRunning_closure,NULL);
|
|
| 225 | + rts_evalIO(cap,ensureIOManagerIsRunning_closure,NULL);
|
|
| 226 | 226 | }
|
| 227 | 227 | |
| 228 | 228 | void
|
| ... | ... | @@ -493,7 +493,7 @@ startSignalHandlers(Capability *cap) |
| 493 | 493 | RtsFlags.GcFlags.initialStkSize,
|
| 494 | 494 | rts_apply(cap,
|
| 495 | 495 | rts_apply(cap,
|
| 496 | - &ghczminternal_GHCziInternalziConcziSignal_runHandlersPtr_closure,
|
|
| 496 | + runHandlersPtr_closure,
|
|
| 497 | 497 | rts_mkPtr(cap, info)),
|
| 498 | 498 | rts_mkInt(cap, info->si_signo)));
|
| 499 | 499 | scheduleThread(cap, t);
|
| 1 | --- External symbols referenced by the RTS
|
|
| 2 | -ld-options:
|
|
| 3 | -#include "external-symbols.flags" |
| ... | ... | @@ -14,12 +14,9 @@ build-type: Configure |
| 14 | 14 | extra-source-files:
|
| 15 | 15 | configure
|
| 16 | 16 | configure.ac
|
| 17 | - external-symbols.list.in
|
|
| 18 | - rts.buildinfo.in
|
|
| 19 | 17 | |
| 20 | 18 | extra-tmp-files:
|
| 21 | 19 | autom4te.cache
|
| 22 | - rts.buildinfo
|
|
| 23 | 20 | config.log
|
| 24 | 21 | config.status
|
| 25 | 22 | |
| ... | ... | @@ -334,6 +331,7 @@ library |
| 334 | 331 | rts/storage/InfoTables.h
|
| 335 | 332 | rts/storage/MBlock.h
|
| 336 | 333 | rts/storage/TSO.h
|
| 334 | + rts/RtsToHsIface.h
|
|
| 337 | 335 | stg/MachRegs.h
|
| 338 | 336 | stg/MachRegs/arm32.h
|
| 339 | 337 | stg/MachRegs/arm64.h
|
| ... | ... | @@ -353,8 +351,6 @@ library |
| 353 | 351 | |
| 354 | 352 | if os(osx)
|
| 355 | 353 | ld-options: "-Wl,-search_paths_first"
|
| 356 | - -- See Note [Undefined symbols in the RTS]
|
|
| 357 | - "-Wl,-undefined,dynamic_lookup"
|
|
| 358 | 354 | if !arch(x86_64) && !arch(aarch64)
|
| 359 | 355 | ld-options: -read_only_relocs warning
|
| 360 | 356 | |
| ... | ... | @@ -449,6 +445,7 @@ library |
| 449 | 445 | RtsStartup.c
|
| 450 | 446 | RtsSymbolInfo.c
|
| 451 | 447 | RtsSymbols.c
|
| 448 | + RtsToHsIface.c
|
|
| 452 | 449 | RtsUtils.c
|
| 453 | 450 | STM.c
|
| 454 | 451 | Schedule.c
|
| ... | ... | @@ -588,33 +585,3 @@ library |
| 588 | 585 | -- ticker/*.c
|
| 589 | 586 | -- We don't want to compile posix/ticker/*.c, these will be #included
|
| 590 | 587 | -- from Ticker.c |
| 591 | - |
|
| 592 | --- Note [Undefined symbols in the RTS]
|
|
| 593 | --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 594 | --- The RTS is built with a number of `-u` flags. This is to handle cyclic
|
|
| 595 | --- dependencies between the RTS and other libraries which we normally think of as
|
|
| 596 | --- downstream from the RTS. "Regular" dependencies from usages in those libraries
|
|
| 597 | --- to definitions in the RTS are handled normally. "Reverse" dependencies from
|
|
| 598 | --- usages in the RTS to definitions in those libraries get the `-u` flag in the
|
|
| 599 | --- RTS.
|
|
| 600 | ---
|
|
| 601 | --- The symbols are specified literally, but follow C ABI conventions (as all 3 of
|
|
| 602 | --- C, C--, and Haskell do currently). Thus, we have to be careful to include a
|
|
| 603 | --- leading underscore or not based on those conventions for the given platform in
|
|
| 604 | --- question.
|
|
| 605 | ---
|
|
| 606 | --- A tricky part is that different linkers have different policies regarding
|
|
| 607 | --- undefined symbols (not defined in the current binary, or found in a shared
|
|
| 608 | --- library that could be loaded at run time). GNU Binutils' linker is fine with
|
|
| 609 | --- undefined symbols by default, but Apple's "cctools" linker is not. To appease
|
|
| 610 | --- that linker we either need to do a blanket `-undefined dynamic_lookup` or
|
|
| 611 | --- whitelist each such symbol with an additional `-U` (see the man page for more
|
|
| 612 | --- details).
|
|
| 613 | ---
|
|
| 614 | --- GHC already does `-undefined dynamic_lookup`, so we just do that for now, but
|
|
| 615 | --- we might try to get more precise with `-U` in the future.
|
|
| 616 | ---
|
|
| 617 | --- Note that the RTS also `-u`s some symbols for atomic operations that *are* defined
|
|
| 618 | --- by `ghc-internal`. This is needed when the RTS is compiled when the RTS is
|
|
| 619 | --- compiled with, e.g., the unregisterised backend since the code-generator will
|
|
| 620 | --- reference these symbols when compiling atomic primops in Cmm sources. |
| ... | ... | @@ -115,9 +115,9 @@ __attribute__((constructor(102))) static void __ghc_wasm_jsffi_init(void) { |
| 115 | 115 | // See Note [threadDelay on wasm] for details.
|
| 116 | 116 | rts_JSFFI_flag = HS_BOOL_TRUE;
|
| 117 | 117 | getStablePtr((
|
| 118 | - StgPtr)&ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure);
|
|
| 118 | + StgPtr)ghc_hs_iface->raiseJSException_closure);
|
|
| 119 | 119 | rts_threadDelay_impl = getStablePtr((
|
| 120 | - StgPtr)&ghczminternal_GHCziInternalziWasmziPrimziConcziInternal_threadDelay_closure);
|
|
| 120 | + StgPtr)ghc_hs_iface->threadDelay_closure);
|
|
| 121 | 121 | }
|
| 122 | 122 | |
| 123 | 123 | typedef __externref_t HsJSVal;
|
| ... | ... | @@ -159,7 +159,7 @@ HaskellObj rts_mkJSVal(Capability *cap, HsJSVal v) { |
| 159 | 159 | SET_HDR(w, &stg_WEAK_info, CCS_SYSTEM);
|
| 160 | 160 | w->cfinalizers = (StgClosure *)cfin;
|
| 161 | 161 | w->key = p;
|
| 162 | - w->value = Unit_closure;
|
|
| 162 | + w->value = ghc_hs_iface->Z0T_closure;
|
|
| 163 | 163 | w->finalizer = &stg_NO_FINALIZER_closure;
|
| 164 | 164 | w->link = cap->weak_ptr_list_hd;
|
| 165 | 165 | cap->weak_ptr_list_hd = w;
|
| ... | ... | @@ -170,7 +170,7 @@ HaskellObj rts_mkJSVal(Capability *cap, HsJSVal v) { |
| 170 | 170 | p->payload[0] = (HaskellObj)w;
|
| 171 | 171 | |
| 172 | 172 | HaskellObj box = (HaskellObj)allocate(cap, CONSTR_sizeW(1, 0));
|
| 173 | - SET_HDR(box, &ghczminternal_GHCziInternalziWasmziPrimziTypes_JSVal_con_info, CCS_SYSTEM);
|
|
| 173 | + SET_HDR(box, ghc_hs_iface->JSVal_con_info, CCS_SYSTEM);
|
|
| 174 | 174 | box->payload[0] = p;
|
| 175 | 175 | |
| 176 | 176 | return TAG_CLOSURE(1, box);
|
| ... | ... | @@ -186,7 +186,7 @@ STATIC_INLINE HsJSVal rts_getJSValzh(HaskellObj p) { |
| 186 | 186 | |
| 187 | 187 | HsJSVal rts_getJSVal(HaskellObj);
|
| 188 | 188 | HsJSVal rts_getJSVal(HaskellObj box) {
|
| 189 | - ASSERT(UNTAG_CLOSURE(box)->header.info == &ghczminternal_GHCziInternalziWasmziPrimziTypes_JSVal_con_info);
|
|
| 189 | + ASSERT(UNTAG_CLOSURE(box)->header.info == ghc_hs_iface->JSVal_con_info);
|
|
| 190 | 190 | return rts_getJSValzh(UNTAG_CLOSURE(box)->payload[0]);
|
| 191 | 191 | }
|
| 192 | 192 | |
| ... | ... | @@ -235,7 +235,7 @@ void rts_schedulerLoop(void) { |
| 235 | 235 | __attribute__((export_name("rts_promiseResolveUnit")))
|
| 236 | 236 | void rts_promiseResolveUnit(HsStablePtr);
|
| 237 | 237 | void rts_promiseResolveUnit(HsStablePtr sp)
|
| 238 | - mk_rtsPromiseCallback(TAG_CLOSURE(1, Unit_closure))
|
|
| 238 | + mk_rtsPromiseCallback(TAG_CLOSURE(1, ghc_hs_iface->Z0T_closure))
|
|
| 239 | 239 | |
| 240 | 240 | mk_rtsPromiseResolve(JSVal)
|
| 241 | 241 | mk_rtsPromiseResolve(Char)
|
| ... | ... | @@ -259,7 +259,7 @@ mk_rtsPromiseResolve(Bool) |
| 259 | 259 | __attribute__((export_name("rts_promiseReject")))
|
| 260 | 260 | void rts_promiseReject(HsStablePtr, HsJSVal);
|
| 261 | 261 | void rts_promiseReject(HsStablePtr sp, HsJSVal js_err)
|
| 262 | - mk_rtsPromiseCallback(rts_apply(cap, &ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure, rts_mkJSVal(cap, js_err)))
|
|
| 262 | + mk_rtsPromiseCallback(rts_apply(cap, ghc_hs_iface->raiseJSException_closure, rts_mkJSVal(cap, js_err)))
|
|
| 263 | 263 | |
| 264 | 264 | __attribute__((export_name("rts_promiseThrowTo")))
|
| 265 | 265 | void rts_promiseThrowTo(HsStablePtr, HsJSVal);
|
| ... | ... | @@ -276,7 +276,7 @@ void rts_promiseThrowTo(HsStablePtr sp, HsJSVal js_err) { |
| 276 | 276 | cap, tso,
|
| 277 | 277 | rts_apply(
|
| 278 | 278 | cap,
|
| 279 | - &ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure,
|
|
| 279 | + ghc_hs_iface->raiseJSException_closure,
|
|
| 280 | 280 | rts_mkJSVal(cap, js_err)));
|
| 281 | 281 | tryWakeupThread(cap, tso);
|
| 282 | 282 | rts_schedulerLoop();
|
| ... | ... | @@ -667,6 +667,59 @@ wanteds os = concat |
| 667 | 667 | ,structField C "StgAsyncIOResult" "errCode"]
|
| 668 | 668 | else []
|
| 669 | 669 | |
| 670 | + -- struct HsIface
|
|
| 671 | + ,structField C "HsIface" "processRemoteCompletion_closure"
|
|
| 672 | + ,structField C "HsIface" "runIO_closure"
|
|
| 673 | + ,structField C "HsIface" "runNonIO_closure"
|
|
| 674 | + ,structField C "HsIface" "Z0T_closure"
|
|
| 675 | + ,structField C "HsIface" "True_closure"
|
|
| 676 | + ,structField C "HsIface" "False_closure"
|
|
| 677 | + ,structField C "HsIface" "unpackCString_closure"
|
|
| 678 | + ,structField C "HsIface" "runFinalizzerBatch_closure"
|
|
| 679 | + ,structField C "HsIface" "stackOverflow_closure"
|
|
| 680 | + ,structField C "HsIface" "heapOverflow_closure"
|
|
| 681 | + ,structField C "HsIface" "allocationLimitExceeded_closure"
|
|
| 682 | + ,structField C "HsIface" "blockedIndefinitelyOnMVar_closure"
|
|
| 683 | + ,structField C "HsIface" "blockedIndefinitelyOnSTM_closure"
|
|
| 684 | + ,structField C "HsIface" "cannotCompactFunction_closure"
|
|
| 685 | + ,structField C "HsIface" "cannotCompactPinned_closure"
|
|
| 686 | + ,structField C "HsIface" "cannotCompactMutable_closure"
|
|
| 687 | + ,structField C "HsIface" "nonTermination_closure"
|
|
| 688 | + ,structField C "HsIface" "nestedAtomically_closure"
|
|
| 689 | + ,structField C "HsIface" "noMatchingContinuationPrompt_closure"
|
|
| 690 | + ,structField C "HsIface" "blockedOnBadFD_closure"
|
|
| 691 | + ,structField C "HsIface" "runSparks_closure"
|
|
| 692 | + ,structField C "HsIface" "ensureIOManagerIsRunning_closure"
|
|
| 693 | + ,structField C "HsIface" "interruptIOManager_closure"
|
|
| 694 | + ,structField C "HsIface" "ioManagerCapabilitiesChanged_closure"
|
|
| 695 | + ,structField C "HsIface" "runHandlersPtr_closure"
|
|
| 696 | + ,structField C "HsIface" "flushStdHandles_closure"
|
|
| 697 | + ,structField C "HsIface" "runMainIO_closure"
|
|
| 698 | + ,structField C "HsIface" "Czh_con_info"
|
|
| 699 | + ,structField C "HsIface" "Izh_con_info"
|
|
| 700 | + ,structField C "HsIface" "Fzh_con_info"
|
|
| 701 | + ,structField C "HsIface" "Dzh_con_info"
|
|
| 702 | + ,structField C "HsIface" "Wzh_con_info"
|
|
| 703 | + ,structField C "HsIface" "runAllocationLimitHandler_closure"
|
|
| 704 | + ,structField C "HsIface" "Ptr_con_info"
|
|
| 705 | + ,structField C "HsIface" "FunPtr_con_info"
|
|
| 706 | + ,structField C "HsIface" "I8zh_con_info"
|
|
| 707 | + ,structField C "HsIface" "I16zh_con_info"
|
|
| 708 | + ,structField C "HsIface" "I32zh_con_info"
|
|
| 709 | + ,structField C "HsIface" "I64zh_con_info"
|
|
| 710 | + ,structField C "HsIface" "W8zh_con_info"
|
|
| 711 | + ,structField C "HsIface" "W16zh_con_info"
|
|
| 712 | + ,structField C "HsIface" "W32zh_con_info"
|
|
| 713 | + ,structField C "HsIface" "W64zh_con_info"
|
|
| 714 | + ,structField C "HsIface" "StablePtr_con_info"
|
|
| 715 | + ,structField C "HsIface" "StackSnapshot_closure"
|
|
| 716 | + ,structField C "HsIface" "divZZeroException_closure"
|
|
| 717 | + ,structField C "HsIface" "underflowException_closure"
|
|
| 718 | + ,structField C "HsIface" "overflowException_closure"
|
|
| 719 | + ,structField C "HsIface" "unpackCStringzh_closure"
|
|
| 720 | + ,structField C "HsIface" "unpackCStringzh_info"
|
|
| 721 | + ,structField C "HsIface" "unpackCStringUtf8zh_info"
|
|
| 722 | + |
|
| 670 | 723 | -- pre-compiled thunk types
|
| 671 | 724 | ,constantWord Haskell "MAX_SPEC_SELECTEE_SIZE" "MAX_SPEC_SELECTEE_SIZE"
|
| 672 | 725 | ,constantWord Haskell "MAX_SPEC_AP_SIZE" "MAX_SPEC_AP_SIZE"
|