Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ghc/ghc
  • bgamari/ghc
  • syd/ghc
  • ggreif/ghc
  • watashi/ghc
  • RolandSenn/ghc
  • mpickering/ghc
  • DavidEichmann/ghc
  • carter/ghc
  • harpocrates/ghc
  • ethercrow/ghc
  • mijicd/ghc
  • adamse/ghc
  • alexbiehl/ghc
  • gridaphobe/ghc
  • trofi/ghc
  • supersven/ghc
  • ppk/ghc
  • ulysses4ever/ghc
  • AndreasK/ghc
  • ghuntley/ghc
  • shayne-fletcher-da/ghc
  • fgaz/ghc
  • yav/ghc
  • osa1/ghc
  • mbbx6spp/ghc
  • JulianLeviston/ghc
  • reactormonk/ghc
  • rae/ghc
  • takenobu-hs/ghc
  • michalt/ghc
  • andrewthad/ghc
  • hsyl20/ghc
  • scottgw/ghc
  • sjakobi/ghc
  • angerman/ghc
  • RyanGlScott/ghc
  • hvr/ghc
  • howtonotwin/ghc
  • chessai/ghc
  • m-renaud/ghc
  • brprice/ghc
  • stevehartdata/ghc
  • sighingnow/ghc
  • kgardas/ghc
  • ckoparkar/ghc
  • alp/ghc
  • smaeul/ghc
  • kakkun61/ghc
  • sykloid/ghc
  • newhoggy/ghc
  • toonn/ghc
  • nineonine/ghc
  • Phyx/ghc
  • ezyang/ghc
  • tweag/ghc
  • langston/ghc
  • ndmitchell/ghc
  • rockbmb/ghc
  • artempyanykh/ghc
  • mniip/ghc
  • mynguyenbmc/ghc
  • alexfmpe/ghc
  • crockeea/ghc
  • nh2/ghc
  • vaibhavsagar/ghc
  • phadej/ghc
  • Haskell-mouse/ghc
  • lolotp/ghc
  • spacekitteh/ghc
  • michaelpj/ghc
  • mgsloan/ghc
  • HPCohen/ghc
  • tmobile/ghc
  • radrow/ghc
  • simonmar/ghc
  • _deepfire/ghc
  • Ericson2314/ghc
  • leitao/ghc
  • fumieval/ghc
  • trac-isovector/ghc
  • cblp/ghc
  • xich/ghc
  • ciil/ghc
  • erthalion/ghc
  • xldenis/ghc
  • autotaker/ghc
  • haskell-wasm/ghc
  • kcsongor/ghc
  • agander/ghc
  • Baranowski/ghc
  • trac-dredozubov/ghc
  • 23Skidoo/ghc
  • iustin/ghc
  • ningning/ghc
  • josefs/ghc
  • kabuhr/ghc
  • gallais/ghc
  • dten/ghc
  • expipiplus1/ghc
  • Pluralia/ghc
  • rohanjr/ghc
  • intricate/ghc
  • kirelagin/ghc
  • Javran/ghc
  • DanielG/ghc
  • trac-mizunashi_mana/ghc
  • pparkkin/ghc
  • bollu/ghc
  • ntc2/ghc
  • jaspervdj/ghc
  • JoshMeredith/ghc
  • wz1000/ghc
  • zkourouma/ghc
  • code5hot/ghc
  • jdprice/ghc
  • tdammers/ghc
  • J-mie6/ghc
  • trac-lantti/ghc
  • ch1bo/ghc
  • cgohla/ghc
  • lucamolteni/ghc
  • acairncross/ghc
  • amerocu/ghc
  • chreekat/ghc
  • txsmith/ghc
  • trupill/ghc
  • typetetris/ghc
  • sergv/ghc
  • fryguybob/ghc
  • erikd/ghc
  • trac-roland/ghc
  • setupminimal/ghc
  • Friede80/ghc
  • SkyWriter/ghc
  • xplorld/ghc
  • abrar/ghc
  • obsidiansystems/ghc
  • Icelandjack/ghc
  • adinapoli/ghc
  • trac-matthewbauer/ghc
  • heatsink/ghc
  • dwijnand/ghc
  • Cmdv/ghc
  • alinab/ghc
  • pepeiborra/ghc
  • fommil/ghc
  • luochen1990/ghc
  • rlupton20/ghc
  • applePrincess/ghc
  • lehins/ghc
  • ronmrdechai/ghc
  • leeadam/ghc
  • harendra/ghc
  • mightymosquito1991/ghc
  • trac-gershomb/ghc
  • lucajulian/ghc
  • Rizary/ghc
  • VictorCMiraldo/ghc
  • jamesbrock/ghc
  • andrewdmeier/ghc
  • luke/ghc
  • pranaysashank/ghc
  • cocreature/ghc
  • hithroc/ghc
  • obreitwi/ghc
  • slrtbtfs/ghc
  • kaol/ghc
  • yairchu/ghc
  • Mathemagician98/ghc
  • trac-taylorfausak/ghc
  • leungbk/ghc
  • MichaWiedenmann/ghc
  • chris-martin/ghc
  • TDecki/ghc
  • adithyaov/ghc
  • trac-gelisam/ghc
  • Lysxia/ghc
  • complyue/ghc
  • bwignall/ghc
  • sternmull/ghc
  • sonika/ghc
  • leif/ghc
  • broadwaylamb/ghc
  • myszon/ghc
  • danbroooks/ghc
  • Mechachleopteryx/ghc
  • zardyh/ghc
  • trac-vdukhovni/ghc
  • OmarKhaledAbdo/ghc
  • arrowd/ghc
  • Bodigrim/ghc
  • matheus23/ghc
  • cardenaso11/ghc
  • trac-Athas/ghc
  • mb720/ghc
  • DylanZA/ghc
  • liff/ghc
  • typedrat/ghc
  • trac-claude/ghc
  • jbm/ghc
  • Gertjan423/ghc
  • PHO/ghc
  • JKTKops/ghc
  • kockahonza/ghc
  • msakai/ghc
  • Sir4ur0n/ghc
  • barambani/ghc
  • vishnu.c/ghc
  • dcoutts/ghc
  • trac-runeks/ghc
  • trac-MaxGabriel/ghc
  • lexi.lambda/ghc
  • strake/ghc
  • spavikevik/ghc
  • JakobBruenker/ghc
  • rmanne/ghc
  • gdziadkiewicz/ghc
  • ani/ghc
  • iliastsi/ghc
  • smunix/ghc
  • judah/ghc
  • blackgnezdo/ghc
  • emilypi/ghc
  • trac-bpfoley/ghc
  • muesli4/ghc
  • trac-gkaracha/ghc
  • Kleidukos/ghc
  • nek0/ghc
  • TristanCacqueray/ghc
  • dwulive/ghc
  • mbakke/ghc
  • arybczak/ghc
  • Yang123321/ghc
  • maksbotan/ghc
  • QuietMisdreavus/ghc
  • trac-olshanskydr/ghc
  • emekoi/ghc
  • samuela/ghc
  • josephcsible/ghc
  • dramforever/ghc
  • lpsmith/ghc
  • DenisFrezzato/ghc
  • michivi/ghc
  • jneira/ghc
  • jeffhappily/ghc
  • Ivan-Yudin/ghc
  • nakaji-dayo/ghc
  • gdevanla/ghc
  • galen/ghc
  • fendor/ghc
  • yaitskov/ghc
  • rcythr/ghc
  • awpr/ghc
  • jeremyschlatter/ghc
  • Aver1y/ghc
  • mitchellvitez/ghc
  • merijn/ghc
  • tomjaguarpaw1/ghc
  • trac-NoidedSuper/ghc
  • erewok/ghc
  • trac-junji.hashimoto/ghc
  • adamwespiser/ghc
  • bjaress/ghc
  • jhrcek/ghc
  • leonschoorl/ghc
  • lukasz-golebiewski/ghc
  • sheaf/ghc
  • last-g/ghc
  • carassius1014/ghc
  • eschwartz/ghc
  • dwincort/ghc
  • felixwiemuth/ghc
  • TimWSpence/ghc
  • marcusmonteirodesouza/ghc
  • WJWH/ghc
  • vtols/ghc
  • theobat/ghc
  • BinderDavid/ghc
  • ckoparkar0/ghc
  • alexander-kjeldaas/ghc
  • dme2/ghc
  • philderbeast/ghc
  • aaronallen8455/ghc
  • rayshih/ghc
  • benkard/ghc
  • mpardalos/ghc
  • saidelman/ghc
  • leiftw/ghc
  • ca333/ghc
  • bwroga/ghc
  • nmichael44/ghc
  • trac-crobbins/ghc
  • felixonmars/ghc
  • adityagupta1089/ghc
  • hgsipiere/ghc
  • treeowl/ghc
  • alexpeits/ghc
  • CraigFe/ghc
  • dnlkrgr/ghc
  • kerckhove_ts/ghc
  • cptwunderlich/ghc
  • eiais/ghc
  • hahohihu/ghc
  • sanchayan/ghc
  • lemmih/ghc
  • sehqlr/ghc
  • trac-dbeacham/ghc
  • luite/ghc
  • trac-f-a/ghc
  • vados/ghc
  • luntain/ghc
  • fatho/ghc
  • alexbiehl-gc/ghc
  • dcbdan/ghc
  • tvh/ghc
  • liam-ly/ghc
  • timbobbarnes/ghc
  • GovanifY/ghc
  • shanth2600/ghc
  • gliboc/ghc
  • duog/ghc
  • moxonsghost/ghc
  • zander/ghc
  • masaeedu/ghc
  • georgefst/ghc
  • guibou/ghc
  • nicuveo/ghc
  • mdebruijne/ghc
  • stjordanis/ghc
  • emiflake/ghc
  • wygulmage/ghc
  • frasertweedale/ghc
  • coot/ghc
  • aratamizuki/ghc
  • tsandstr/ghc
  • mrBliss/ghc
  • Anton-Latukha/ghc
  • tadfisher/ghc
  • vapourismo/ghc
  • Sorokin-Anton/ghc
  • basile-henry/ghc
  • trac-mightybyte/ghc
  • AbsoluteNikola/ghc
  • cobrien99/ghc
  • songzh/ghc
  • blamario/ghc
  • aj4ayushjain/ghc
  • trac-utdemir/ghc
  • tangcl/ghc
  • hdgarrood/ghc
  • maerwald/ghc
  • arjun/ghc
  • ratherforky/ghc
  • haskieLambda/ghc
  • EmilGedda/ghc
  • Bogicevic/ghc
  • eddiejessup/ghc
  • kozross/ghc
  • AlistairB/ghc
  • 3Rafal/ghc
  • christiaanb/ghc
  • trac-bit/ghc
  • matsumonkie/ghc
  • trac-parsonsmatt/ghc
  • chisui/ghc
  • jaro/ghc
  • trac-kmiyazato/ghc
  • davidsd/ghc
  • Tritlo/ghc
  • I-B-3/ghc
  • lykahb/ghc
  • AriFordsham/ghc
  • turion1/ghc
  • berberman/ghc
  • christiantakle/ghc
  • zyklotomic/ghc
  • trac-ocramz/ghc
  • CSEdd/ghc
  • doyougnu/ghc
  • mmhat/ghc
  • why-not-try-calmer/ghc
  • plutotulp/ghc
  • kjekac/ghc
  • Manvi07/ghc
  • teo/ghc
  • cactus/ghc
  • CarrieMY/ghc
  • abel/ghc
  • yihming/ghc
  • tsakki/ghc
  • jessicah/ghc
  • oliverbunting/ghc
  • meld/ghc
  • friedbrice/ghc
  • Joald/ghc
  • abarbu/ghc
  • DigitalBrains1/ghc
  • sterni/ghc
  • alexDarcy/ghc
  • hexchain/ghc
  • minimario/ghc
  • zliu41/ghc
  • tommd/ghc
  • jazcarate/ghc
  • peterbecich/ghc
  • alirezaghey/ghc
  • solomon/ghc
  • mikael.urankar/ghc
  • davjam/ghc
  • int-index/ghc
  • MorrowM/ghc
  • nrnrnr/ghc
  • Sonfamm/ghc-test-only
  • afzt1/ghc
  • nguyenhaibinh-tpc/ghc
  • trac-lierdakil/ghc
  • MichaWiedenmann1/ghc
  • jmorag/ghc
  • Ziharrk/ghc
  • trac-MitchellSalad/ghc
  • juampe/ghc
  • jwaldmann/ghc
  • snowleopard/ghc
  • juhp/ghc
  • normalcoder/ghc
  • ksqsf/ghc
  • trac-jberryman/ghc
  • roberth/ghc
  • 1ntEgr8/ghc
  • epworth/ghc
  • MrAdityaAlok/ghc
  • JunmingZhao42/ghc
  • jappeace/ghc
  • trac-Gabriel439/ghc
  • alt-romes/ghc
  • HugoPeters1024/ghc
  • 10ne1/ghc-fork
  • agentultra/ghc
  • Garfield1002/ghc
  • ChickenProp/ghc
  • clyring/ghc
  • MaxHearnden/ghc
  • jumper149/ghc
  • vem/ghc
  • ketzacoatl/ghc
  • Rosuavio/ghc
  • jackohughes/ghc
  • p4l1ly/ghc
  • konsumlamm/ghc
  • shlevy/ghc
  • torsten.schmits/ghc
  • andremarianiello/ghc
  • amesgen/ghc
  • googleson78/ghc
  • InfiniteVerma/ghc
  • uhbif19/ghc
  • yiyunliu/ghc
  • raehik/ghc
  • mrkun/ghc
  • telser/ghc
  • 1Jajen1/ghc
  • slotThe/ghc
  • WinstonHartnett/ghc
  • mpilgrem/ghc
  • dreamsmasher/ghc
  • schuelermine/ghc
  • trac-Viwor/ghc
  • undergroundquizscene/ghc
  • evertedsphere/ghc
  • coltenwebb/ghc
  • oberblastmeister/ghc
  • agrue/ghc
  • lf-/ghc
  • zacwood9/ghc
  • steshaw/ghc
  • high-cloud/ghc
  • SkamDart/ghc
  • PiDelport/ghc
  • maoif/ghc
  • RossPaterson/ghc
  • CharlesTaylor7/ghc
  • ribosomerocker/ghc
  • trac-ramirez7/ghc
  • daig/ghc
  • NicolasT/ghc
  • FinleyMcIlwaine/ghc
  • lawtonnichols/ghc
  • jmtd/ghc
  • ozkutuk/ghc
  • wildsebastian/ghc
  • nikshalark/ghc
  • lrzlin/ghc
  • tobias/ghc
  • fw/ghc
  • hawkinsw/ghc
  • type-dance/ghc
  • rui314/ghc
  • ocharles/ghc
  • wavewave/ghc
  • TheKK/ghc
  • nomeata/ghc
  • trac-csabahruska/ghc
  • jonathanjameswatson/ghc
  • L-as/ghc
  • Axman6/ghc
  • barracuda156/ghc
  • trac-jship/ghc
  • jake-87/ghc
  • meooow/ghc
  • rebeccat/ghc
  • hamana55/ghc
  • Enigmage/ghc
  • kokobd/ghc
  • agevelt/ghc
  • gshen42/ghc
  • chrismwendt/ghc
  • MangoIV/ghc
  • teto/ghc
  • Sookr1/ghc
  • trac-thomasjm/ghc
  • barci2/ghc-dev
  • trac-m4dc4p/ghc
  • dixonary/ghc
  • breakerzirconia/ghc
  • alexsio27444/ghc
  • glocq/ghc
  • sourabhxyz/ghc
  • ryantrinkle/ghc
  • Jade/ghc
  • scedfaliako/ghc
  • martijnbastiaan/ghc
  • trac-george.colpitts/ghc
  • ammarbinfaisal/ghc
  • mimi.vx/ghc
  • lortabac/ghc
  • trac-zyla/ghc
  • benbellick/ghc
  • aadaa-fgtaa/ghc
  • jvanbruegge/ghc
  • archbung/ghc
  • gilmi/ghc
  • mfonism/ghc
  • alex-mckenna/ghc
  • Ei30metry/ghc
  • DiegoDiverio/ghc
  • jorgecunhamendes/ghc
  • liesnikov/ghc
  • akrmn/ghc
  • trac-simplifierticks/ghc
  • jacco/ghc
  • rhendric/ghc
  • damhiya/ghc
  • ryndubei/ghc
  • DaveBarton/ghc
  • trac-Profpatsch/ghc
  • GZGavinZhao/ghc
  • ncfavier/ghc
  • jameshaydon/ghc
  • ajccosta/ghc
  • dschrempf/ghc
  • cydparser/ghc
  • LinuxUserGD/ghc
  • elodielander/ghc
  • facundominguez/ghc
  • psilospore/ghc
  • lachrimae/ghc
  • dylan-thinnes/ghc-type-errors-plugin
  • hamishmack/ghc
  • Leary/ghc
  • lzszt/ghc
  • lyokha/ghc
  • trac-glaubitz/ghc
  • Rewbert/ghc
  • andreabedini/ghc
  • Jasagredo/ghc
  • sol/ghc
  • OlegAlexander/ghc
  • trac-sthibaul/ghc
  • avdv/ghc
  • Wendaolee/ghc
  • ur4t/ghc
  • daylily/ghc
  • boltzmannrain/ghc
  • mmzk1526/ghc
  • trac-fizzixnerd/ghc
  • soulomoon/ghc
  • rwmjones/ghc
  • j14i/ghc
  • tracsis/ghc
  • gesh/ghc
  • flip101/ghc
  • eldritch-cookie/ghc
  • LemonjamesD/ghc
  • pgujjula/ghc
  • skeuchel/ghc
  • noteed/ghc
  • gulin.serge/ghc
  • Torrekie/ghc
  • jlwoodwa/ghc
  • ayanamists/ghc
  • husong998/ghc
  • trac-edmundnoble/ghc
  • josephf/ghc
  • contrun/ghc
  • baulig/ghc
  • edsko/ghc
  • mzschr/ghc-issue-24732
  • ulidtko/ghc
  • Arsen/ghc
  • trac-sjoerd_visscher/ghc
  • crumbtoo/ghc
  • L0neGamer/ghc
  • DrewFenwick/ghc
  • benz0li/ghc
  • MaciejWas/ghc
  • jordanrule/ghc
  • trac-qqwy/ghc
  • LiamGoodacre/ghc
  • isomorpheme/ghc
  • trac-danidiaz/ghc
  • Kariim/ghc
  • MTaimoorZaeem/ghc
  • hololeap/ghc
  • ticat-fp/ghc
  • meritamen/ghc
  • criskell/ghc
  • trac-kraai/ghc
  • aergus/ghc
  • jdral/ghc
  • SamB/ghc
  • Tristian/ghc
  • ywgrit/ghc
  • KatsuPatrick/ghc
  • OsePedro/ghc
  • mpscholten/ghc
  • fp/ghc
  • zaquest/ghc
  • fangyi-zhou/ghc
  • augyg/ghc
640 results
Show changes
Commits on Source (13)
  • jeffrey young's avatar
    JS: establish single source of truth for symbols · 6bd850e8
    jeffrey young authored and Marge Bot's avatar Marge Bot committed
    In pursuit of: #22736.
    
    This MR moves ad-hoc symbols used throughout the js backend into a
    single symbols file. Why? First, this cleans up the code by removing
    ad-hoc strings created on the fly and therefore makes the code more
    maintainable. Second, it makes it much easier to eventually type these
    identifiers.
    6bd850e8
  • Cheng Shao's avatar
    rts: replace ad-hoc MYTASK_USE_TLV with proper CC_SUPPORTS_TLS · f3017dd3
    Cheng Shao authored and Marge Bot's avatar Marge Bot committed
    This patch replaces the ad-hoc `MYTASK_USE_TLV` with the
    `CC_SUPPORTS_TLS` macro. If TLS support is detected by autoconf, then
    we should use that for managing `myTask` in the threaded RTS.
    f3017dd3
  • Duncan Coutts's avatar
    Permit ARR_WORDS closures outside HEAP_ALLOCED space · 43e7531b
    Duncan Coutts authored
    In the GC, evacuate() is prepared to deal with some heap objects that
    are not in the HEAP_ALLOCED() memory space. These are mainly the heap
    objects that GHC puts into the data sections of object files.
    
    It is also useful however to allow ByteArray# and MutableByteArray#
    heap objects to appear outside of the HEAP_ALLOCED() memory space. These
    have the ARR_WORDS closure type and contain no pointer should be easy to
    deal with. Indeed evacuate() already deals with closure types for
    constructors containing no pointers by doing nothing.
    
    So we just tack the ARR_WORDS case into this group of closure types that
    are permitted outside the HEAP_ALLOCED area but otherwise ignored.
    43e7531b
  • Duncan Coutts's avatar
    Add new primop placeByteArray# · 438dc732
    Duncan Coutts authored
    It places a byte array heap object header at the given address, which
    must be outside the heap. It also sets the byte array size.
    438dc732
  • Duncan Coutts's avatar
    Define HEAP_ALLOCED for CMM code · 4d4bddb4
    Duncan Coutts authored
    Allow rts/sm/HeapAlloc.h to be #included by CMM code and have it provide
    a suitable implementation of HEAP_ALLOCED.
    
    The HEAP_ALLOCED system has three implementations, the large address
    space case, two fallbakc impls, one for 32bit and one for 64bit. The
    first two are simple enough that we can provide a HEAP_ALLOCED macro
    that can be used in a CMM expression context.
    
    The 64bit fallback case is rather more tricky. We provide a different
    interface to HEAP_ALLOCED for this case, which has to be called in a
    statement/"callish" style.
    4d4bddb4
  • Duncan Coutts's avatar
    Fix isByteArrayPinned# for the !HEAP_ALLOCATED case · be9e4975
    Duncan Coutts authored
    The isByteArrayPinned# primop works by looking up the block descriptor
    for the byte array to see if it lives in a pinned area or not. This of
    course cannot work for byte arrays that are not HEAP_ALLOCATED since
    they don't have block descriptors.
    
    The solution is to check if it is HEAP_ALLOCATED first. Since this is
    done in CMM code we make use of the new HEAP_ALLOCATED support for CMM.
    It is a bit awkward since it does not have a uniform interface.
    be9e4975
  • Duncan Coutts's avatar
    Add test T17747 · 71b840b4
    Duncan Coutts authored
    Closes issue #17747
    
    Test that we can allocate ByteArray#s outside of the HEAP_ALLOCED()
    address space without upsetting the GC. To be extra sure we attach weak
    pointers with C finalizers to the ByteArray#s. We keep them alive and
    run a major GC so that the GC has to trace the live ByteArray#s.
    
    Prior to the first patch in this series, doing this would upset the GC
    because the GC does not expect heap objects with closure type ARR_WORDS
    to exist outside the GC heap.
    
    > internal error: evacuate(static): strange closure type 42
    
    Finally we allow everything to be GC'd again, and check that the C
    finalizers did run.
    
    This feature also required a change to the isByteArrayPinned# which
    itself required a CMM implementation of the HEAP_ALLOCED system. So we
    also add a check that the CMM and C implementations of HEAP_ALLOCED
    agree with each other.
    71b840b4
  • Duncan Coutts's avatar
    Update user guide for byte arrays outside of the heap · 7b06912a
    Duncan Coutts authored
    Add a sub-subsection in the chapter on GHC extensions to the FFI, under
    the existing Memory Allocation subsection.
    
    Explain that it's permitted to have {Mutable}ByteArray# outside the heap
    and the tricky associated constraints. Mention the new primop
    placeByteArray#.
    7b06912a
  • Duncan Coutts's avatar
    f810809f
  • Duncan Coutts's avatar
    Add Note [Byte arrays outside of the HEAP_ALLOCED space] · 7cdfb04e
    Duncan Coutts authored
    And refer to it from the various places involved in the scheme.
    7cdfb04e
  • Duncan Coutts's avatar
    2eef181f
  • davide's avatar
    45dcfc64
  • Reinier Maas's avatar
    70d3f785
Showing
with 563 additions and 424 deletions
...@@ -1852,6 +1852,70 @@ section "Byte Arrays" ...@@ -1852,6 +1852,70 @@ section "Byte Arrays"
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Note [Byte arrays outside of the HEAP_ALLOCED space]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- It is useful to be able to allocate byte arrays outside of the heap,
-- i.e. outside of the memory space covered by the HEAP_ALLOCED() test.
--
-- There are two major use cases (see issue #17747):
--
-- 1. Having foreign memory appear as a normal GHC byte array. This
-- are use cases similar to the use of a ForeignPtr, but where it
-- is useful to have the representation be a byte array type, for
-- easier interoperability with existing libraries.
--
-- 2. Static byte arrays in object files for constant values.
--
-- The second is not yet available as it requires additional support
-- from the code gen.
--
-- An example of the first category can be seen in GHC test T17747.
-- A concrete use-case is to memory map a file
-- but have it appear as a ByteArray# rather than a ForeignPtr. Doing
-- so of course requires that space is reserved immediately before the
-- file data for the byte array heap object header. See the
-- placeByteArray# primop documentation below and the FFI section of
-- the user guide for more details.
--
-- To have the first use-case work requires a few things:
--
-- * For the GC to not fail when it encounters byte arrays outside of
-- the HEAP_ALLOCED space. This is straightforward because the GC
-- has support for a number of different closure types to appear
-- outside the heap (primarily for statically allocated values), and
-- byte arrays are easy because they contain no heap pointers. See
-- the reference back to this note in `evacuate(StgClosure **p)` in
-- `rts/sm/Evac.c`
--
-- * For all other byte array primops (e.g. shrinkMutableByteArray#,
-- sameMutableByteArray#, isByteArrayPinned#, etc.) to not fail when
-- encountering byte arrays outside of the heap. Specifically
-- isByteArrayPinned# requires special support. This is currently the
-- only primop that needs special support.
-- See Note [isByteArrayPinned# support for off heap byte arrays].
--
-- * A mechanism to set up the heap object header for a byte array at
-- an address outside of the HEAP_ALLOCED space. This is needed to
-- make the foreign allocated memory look like a byte array. This is
-- provided by the placeByteArray# primop.
--
-- Note [isByteArrayPinned# support for off heap byte arrays]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- The isByteArrayPinned# primop is implemented by reading block descriptor
-- flags. Since off heap byte arrays don't have block descriptors,
-- isByteArrayPinned# must explicitly check if the byte array is HEAP_ALLOCED
-- or not. If not HEAP_ALLOCED then it is certainly pinned. This requires CMM
-- support for the HEAP_ALLOCED test, which is otherwise only called from C
-- code in the RTS. The current design is to provide full CMM
-- implementations of HEAP_ALLOCED enabled in `rts/storage/HeapAlloc.h` with the
-- CMINUSMINUS cpp flag. This includes HEAP_ALLOCED_CALLISH which essentially
-- duplicates what is already a complex C implementation. This is fast
-- but an alternative would be to use a CMM C call to a C function that use
-- the existing C implementation of HEAP_ALLOCED.
primtype ByteArray# primtype ByteArray#
{ {
A boxed, unlifted datatype representing a region of raw memory in the garbage-collected heap, A boxed, unlifted datatype representing a region of raw memory in the garbage-collected heap,
...@@ -1902,6 +1966,20 @@ primop NewByteArrayOp_Char "newByteArray#" GenPrimOp ...@@ -1902,6 +1966,20 @@ primop NewByteArrayOp_Char "newByteArray#" GenPrimOp
with out_of_line = True with out_of_line = True
effect = ReadWriteEffect effect = ReadWriteEffect
-- See [Byte arrays outside of the HEAP_ALLOCED space]
primop PlaceByteArrayOp_Char "placeByteArray#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
{Place a new byte array header at the specified address outside of the heap,
for the specified payload size (in bytes), in the specified state thread. In
C code with `#include "Rts.h"`, use `sizeOf(StgArrBytes)` or
`sizeOfW(StgArrBytes)` to get the size of a byte array header in bytes or
words respectively. The caller must ensure `sizeof(StgArrBytes) + n` bytes of
space is allocated at the give address for the heap object header followed by
n bytes of payload. See the FFI section of the user guide for more details
on how to use this primop.}
with out_of_line = True
effect = ReadWriteEffect
primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutableByteArray# s #) Int# -> State# s -> (# State# s, MutableByteArray# s #)
{Like 'newByteArray#' but GC guarantees not to move it.} {Like 'newByteArray#' but GC guarantees not to move it.}
......
...@@ -34,25 +34,29 @@ ...@@ -34,25 +34,29 @@
module GHC.JS.Ident module GHC.JS.Ident
( Ident(..) ( Ident(..)
, global , name
) where ) where
import Prelude import GHC.Prelude
import GHC.Data.FastString import GHC.Data.FastString
import GHC.Types.Unique import GHC.Types.Unique
import GHC.Utils.Outputable
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Identifiers -- Identifiers
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- We use FastString for identifiers in JS backend
-- | A newtype wrapper around 'FastString' for JS identifiers. -- | A newtype wrapper around 'FastString' for JS identifiers.
newtype Ident = TxtI { identFS :: FastString } newtype Ident = TxtI { identFS :: FastString }
deriving stock (Show, Eq) deriving stock (Show, Eq)
deriving newtype (Uniquable) deriving newtype (Uniquable, Outputable)
-- | A not-so-smart constructor for @Ident@s, used to indicate that this name is -- | To give a thing a name is to have power over it. This smart constructor
-- expected to be top-level -- serves two purposes: first, it isolates the JS backend from the rest of GHC.
global :: FastString -> Ident -- The backend should not explicitly use types provided by GHC but instead
global = TxtI -- should wrap them such as we do here. Second it creates a symbol in the JS
-- backend, but it does not yet give that symbols meaning. Giving the symbol
-- meaning only occurs once it is used with a combinator from @GHC.JS.Make@.
name :: FastString -> Ident
name = TxtI
...@@ -92,7 +92,7 @@ newIdent = do env <- get ...@@ -92,7 +92,7 @@ newIdent = do env <- get
return $ mk_ident tag id return $ mk_ident tag id
mk_ident :: FastString -> Unique -> Ident mk_ident :: FastString -> Unique -> Ident
mk_ident t i = global (mconcat [t, "_", mkFastString (show i)]) mk_ident t i = name (mconcat [t, "_", mkFastString (show i)])
-- | Set the tag for @Ident@s for all remaining computations. -- | Set the tag for @Ident@s for all remaining computations.
tag_names :: FastString -> JSM () tag_names :: FastString -> JSM ()
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
-- is written in. Nothing fancy, its just a straightforward deeply embedded -- is written in. Nothing fancy, its just a straightforward deeply embedded
-- DSL. -- DSL.
-- --
-- In general, one should not use these constructors explicitly in the JS
-- backend. Instead, prefer using the combinators in GHC.JS.Make, if those
-- are suitable then prefer using the patterns exported from this module
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module GHC.JS.JStg.Syntax module GHC.JS.JStg.Syntax
( -- * Deeply embedded JS datatypes ( -- * Deeply embedded JS datatypes
...@@ -63,7 +67,8 @@ module GHC.JS.JStg.Syntax ...@@ -63,7 +67,8 @@ module GHC.JS.JStg.Syntax
-- * Utility -- * Utility
, SaneDouble(..) , SaneDouble(..)
, pattern Func , pattern Func
, var , global
, local
) where ) where
import GHC.Prelude import GHC.Prelude
...@@ -233,7 +238,6 @@ pattern LOr x y = InfixExpr LOrOp x y ...@@ -233,7 +238,6 @@ pattern LOr x y = InfixExpr LOrOp x y
pattern LAnd :: JStgExpr -> JStgExpr -> JStgExpr pattern LAnd :: JStgExpr -> JStgExpr -> JStgExpr
pattern LAnd x y = InfixExpr LAndOp x y pattern LAnd x y = InfixExpr LAndOp x y
-- | pattern synonym to create integer values -- | pattern synonym to create integer values
pattern Int :: Integer -> JStgExpr pattern Int :: Integer -> JStgExpr
pattern Int x = ValExpr (JInt x) pattern Int x = ValExpr (JInt x)
...@@ -328,6 +332,10 @@ data AOp ...@@ -328,6 +332,10 @@ data AOp
instance NFData AOp instance NFData AOp
-- | construct a JS variable reference -- | construct a JS reference, intended to refer to a global name
var :: FastString -> JStgExpr global :: FastString -> JStgExpr
var = Var . global global = Var . name
-- | construct a JS reference, intended to refer to a local name
local :: FastString -> JStgExpr
local = Var . name
...@@ -107,11 +107,10 @@ module GHC.JS.Make ...@@ -107,11 +107,10 @@ module GHC.JS.Make
, off8, off16, off32, off64 , off8, off16, off32, off64
, mask8, mask16 , mask8, mask16
, signExtend8, signExtend16 , signExtend8, signExtend16
, typeof , typeOf
, returnStack, assignAllEqual, assignAll, assignAllReverseOrder , returnStack, assignAllEqual, assignAll, assignAllReverseOrder
, declAssignAll , declAssignAll
, nullStat, (.^) , nullStat, (.^)
, trace
-- ** Hash combinators -- ** Hash combinators
, jhEmpty , jhEmpty
, jhSingle , jhSingle
...@@ -182,8 +181,8 @@ instance ToJExpr () where ...@@ -182,8 +181,8 @@ instance ToJExpr () where
toJExpr _ = ValExpr $ JList [] toJExpr _ = ValExpr $ JList []
instance ToJExpr Bool where instance ToJExpr Bool where
toJExpr True = var "true" toJExpr True = global "true"
toJExpr False = var "false" toJExpr False = global "false"
instance ToJExpr JVal where instance ToJExpr JVal where
toJExpr = ValExpr toJExpr = ValExpr
...@@ -376,7 +375,7 @@ jTryCatchFinally :: (Ident -> JStgStat) -> (Ident -> JStgStat) -> (Ident -> JStg ...@@ -376,7 +375,7 @@ jTryCatchFinally :: (Ident -> JStgStat) -> (Ident -> JStgStat) -> (Ident -> JStg
jTryCatchFinally c f f2 = do i <- newIdent jTryCatchFinally c f f2 = do i <- newIdent
return $ TryStat (c i) i (f i) (f2 i) return $ TryStat (c i) i (f i) (f2 i)
-- | Convert a ShortText to a Javascript String -- | Convert a FastString to a Javascript String
jString :: FastString -> JStgExpr jString :: FastString -> JStgExpr
jString = toJExpr jString = toJExpr
...@@ -447,8 +446,8 @@ infixl 8 .||., .&&. ...@@ -447,8 +446,8 @@ infixl 8 .||., .&&.
infixl 9 .<<., .>>., .>>>. infixl 9 .<<., .>>., .>>>.
-- | Given a 'JStgExpr', return the its type. -- | Given a 'JStgExpr', return the its type.
typeof :: JStgExpr -> JStgExpr typeOf :: JStgExpr -> JStgExpr
typeof = UOpExpr TypeofOp typeOf = UOpExpr TypeofOp
-- | JS if-expression -- | JS if-expression
-- --
...@@ -494,15 +493,15 @@ if10 e = IfExpr e one_ zero_ ...@@ -494,15 +493,15 @@ if10 e = IfExpr e one_ zero_
if01 :: JStgExpr -> JStgExpr if01 :: JStgExpr -> JStgExpr
if01 e = IfExpr e zero_ one_ if01 e = IfExpr e zero_ one_
-- | an expression application, see related 'appS' -- | an application expression, see related 'appS'
-- --
-- > app f xs ==> f(xs) -- > app f xs ==> f(xs)
app :: FastString -> [JStgExpr] -> JStgExpr app :: FastString -> [JStgExpr] -> JStgExpr
app f xs = ApplExpr (var f) xs app f xs = ApplExpr (global f) xs
-- | A statement application, see the expression form 'app' -- | A statement application, see the expression form 'app'
appS :: FastString -> [JStgExpr] -> JStgStat appS :: FastString -> [JStgExpr] -> JStgStat
appS f xs = ApplStat (var f) xs appS f xs = ApplStat (global f) xs
-- | Return a 'JStgExpr' -- | Return a 'JStgExpr'
returnS :: JStgExpr -> JStgStat returnS :: JStgExpr -> JStgStat
...@@ -577,7 +576,7 @@ signExtend16 x = (BAnd x (Int 0x7FFF)) `Sub` (BAnd x (Int 0x8000)) ...@@ -577,7 +576,7 @@ signExtend16 x = (BAnd x (Int 0x7FFF)) `Sub` (BAnd x (Int 0x8000))
-- --
-- > obj .^ prop ==> obj.prop -- > obj .^ prop ==> obj.prop
(.^) :: JStgExpr -> FastString -> JStgExpr (.^) :: JStgExpr -> FastString -> JStgExpr
obj .^ prop = SelExpr obj (global prop) obj .^ prop = SelExpr obj (name prop)
infixl 8 .^ infixl 8 .^
-- | Assign a variable to an expression -- | Assign a variable to an expression
...@@ -614,9 +613,6 @@ assignAllReverseOrder xs ys = mconcat (reverse (zipWith (|=) xs ys)) ...@@ -614,9 +613,6 @@ assignAllReverseOrder xs ys = mconcat (reverse (zipWith (|=) xs ys))
declAssignAll :: [Ident] -> [JStgExpr] -> JStgStat declAssignAll :: [Ident] -> [JStgExpr] -> JStgStat
declAssignAll xs ys = mconcat (zipWith (||=) xs ys) declAssignAll xs ys = mconcat (zipWith (||=) xs ys)
trace :: ToJExpr a => a -> JStgStat
trace ex = appS "h$log" [toJExpr ex]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Literals -- Literals
...@@ -627,7 +623,7 @@ trace ex = appS "h$log" [toJExpr ex] ...@@ -627,7 +623,7 @@ trace ex = appS "h$log" [toJExpr ex]
-- | The JS literal 'null' -- | The JS literal 'null'
null_ :: JStgExpr null_ :: JStgExpr
null_ = var "null" null_ = global "null"
-- | The JS literal 0 -- | The JS literal 0
zero_ :: JStgExpr zero_ :: JStgExpr
...@@ -647,7 +643,7 @@ three_ = Int 3 ...@@ -647,7 +643,7 @@ three_ = Int 3
-- | The JS literal 'undefined' -- | The JS literal 'undefined'
undefined_ :: JStgExpr undefined_ :: JStgExpr
undefined_ = var "undefined" undefined_ = global "undefined"
-- | The JS literal 'true' -- | The JS literal 'true'
true_ :: JStgExpr true_ :: JStgExpr
...@@ -658,7 +654,7 @@ false_ :: JStgExpr ...@@ -658,7 +654,7 @@ false_ :: JStgExpr
false_ = ValExpr (JBool False) false_ = ValExpr (JBool False)
returnStack :: JStgStat returnStack :: JStgStat
returnStack = ReturnStat (ApplExpr (var "h$rs") []) returnStack = ReturnStat (ApplExpr (global "h$rs") [])
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
...@@ -669,7 +665,7 @@ returnStack = ReturnStat (ApplExpr (var "h$rs") []) ...@@ -669,7 +665,7 @@ returnStack = ReturnStat (ApplExpr (var "h$rs") [])
-- is the sole math introduction function. -- is the sole math introduction function.
math :: JStgExpr math :: JStgExpr
math = var "Math" math = global "Math"
math_ :: FastString -> [JStgExpr] -> JStgExpr math_ :: FastString -> [JStgExpr] -> JStgExpr
math_ op args = ApplExpr (math .^ op) args math_ op args = ApplExpr (math .^ op) args
......
...@@ -341,7 +341,7 @@ instance NFData AOp ...@@ -341,7 +341,7 @@ instance NFData AOp
-- | construct a JS variable reference -- | construct a JS variable reference
var :: FastString -> JExpr var :: FastString -> JExpr
var = Var . global var = Var . name
-- | The JS literal 'true' -- | The JS literal 'true'
true_ :: JExpr true_ :: JExpr
......
...@@ -1665,6 +1665,7 @@ emitPrimOp cfg primop = ...@@ -1665,6 +1665,7 @@ emitPrimOp cfg primop =
CasArrayOp -> alwaysExternal CasArrayOp -> alwaysExternal
UnsafeThawSmallArrayOp -> alwaysExternal UnsafeThawSmallArrayOp -> alwaysExternal
CasSmallArrayOp -> alwaysExternal CasSmallArrayOp -> alwaysExternal
PlaceByteArrayOp_Char -> alwaysExternal
NewPinnedByteArrayOp_Char -> alwaysExternal NewPinnedByteArrayOp_Char -> alwaysExternal
NewAlignedPinnedByteArrayOp_Char -> alwaysExternal NewAlignedPinnedByteArrayOp_Char -> alwaysExternal
MutableByteArrayIsPinnedOp -> alwaysExternal MutableByteArrayIsPinnedOp -> alwaysExternal
......
...@@ -11,6 +11,23 @@ import GHC.StgToJS.CodeGen ...@@ -11,6 +11,23 @@ import GHC.StgToJS.CodeGen
-- --
-- StgToJS ("JS backend") is adapted from GHCJS [GHCJS2013]. -- StgToJS ("JS backend") is adapted from GHCJS [GHCJS2013].
-- --
-- Implementation Big Picture
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- The big picture of the JS backend is roughly:
--
-- JS Backend --> JStgExpr ----> JExpr
-- |
-- V
-- STG -------------------------> JExpr --> Optimizations --> Code Gen
--
-- Why this design? Because we generate the RTS via an eDSL, if we accidentally
-- create a bug in the RTS we will not find out until we have completely
-- finished compiling and are running the testsuite. Thus having a typed eDSL
-- with which we can write the RTS is beneficial because a type error will have
-- a much faster turn around than building and then trying to debug a bunch of
-- generated, z-encoded code.
--
-- Haskell to JavaScript -- Haskell to JavaScript
-- ~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~
-- StgToJS converts STG into a JavaScript AST (in GHC.JS) that has been adapted -- StgToJS converts STG into a JavaScript AST (in GHC.JS) that has been adapted
......
...@@ -37,14 +37,15 @@ import GHC.StgToJS.Closure ...@@ -37,14 +37,15 @@ import GHC.StgToJS.Closure
import GHC.StgToJS.DataCon import GHC.StgToJS.DataCon
import GHC.StgToJS.ExprCtx import GHC.StgToJS.ExprCtx
import GHC.StgToJS.Heap import GHC.StgToJS.Heap
import GHC.StgToJS.Ids
import GHC.StgToJS.Monad import GHC.StgToJS.Monad
import GHC.StgToJS.Types
import GHC.StgToJS.Profiling import GHC.StgToJS.Profiling
import GHC.StgToJS.Regs import GHC.StgToJS.Regs
import GHC.StgToJS.Utils
import GHC.StgToJS.Rts.Types import GHC.StgToJS.Rts.Types
import GHC.StgToJS.Stack import GHC.StgToJS.Stack
import GHC.StgToJS.Ids import GHC.StgToJS.Symbols
import GHC.StgToJS.Types
import GHC.StgToJS.Utils
import GHC.Types.Id import GHC.Types.Id
import GHC.Types.Id.Info import GHC.Types.Id.Info
...@@ -161,7 +162,7 @@ genApp ctx i args ...@@ -161,7 +162,7 @@ genApp ctx i args
let ww = case concatMap typex_expr (ctxTarget ctx) of let ww = case concatMap typex_expr (ctxTarget ctx) of
[t] | csAssertRts settings -> [t] | csAssertRts settings ->
ifS (isObject t .&&. isThunk t) ifS (isObject t .&&. isThunk t)
(appS "throw" [String "unexpected thunk"]) -- yuck (appS throwStr [String "unexpected thunk"]) -- yuck
mempty mempty
_ -> mempty _ -> mempty
return (a `mappend` ww, ExprInline) return (a `mappend` ww, ExprInline)
...@@ -183,7 +184,7 @@ genApp ctx i args ...@@ -183,7 +184,7 @@ genApp ctx i args
_ -> panic "genApp: unexpected arg" _ -> panic "genApp: unexpected arg"
if isStrictId a' || ctxIsEvaluated a' if isStrictId a' || ctxIsEvaluated a'
then return (t |= ai, ExprInline) then return (t |= ai, ExprInline)
else return (returnS (app "h$e" [ai]), ExprCont) else return (returnS (app (identFS hdEntry) [ai]), ExprCont)
_ -> panic "genApp: invalid size" _ -> panic "genApp: invalid size"
-- no args and Id can't be a function: just enter it -- no args and Id can't be a function: just enter it
...@@ -196,7 +197,7 @@ genApp ctx i args ...@@ -196,7 +197,7 @@ genApp ctx i args
[x] -> return x [x] -> return x
xs -> pprPanic "genApp: unexpected multi-var argument" xs -> pprPanic "genApp: unexpected multi-var argument"
(vcat [ppr (length xs), ppr i]) (vcat [ppr (length xs), ppr i])
return (returnS (app "h$e" [enter_id]), ExprCont) return (returnS (app (identFS hdEntry) [enter_id]), ExprCont)
-- fully saturated global function: -- fully saturated global function:
-- - deals with arguments -- - deals with arguments
...@@ -285,12 +286,12 @@ data ApplyConv ...@@ -285,12 +286,12 @@ data ApplyConv
-- | Name of the generic apply function -- | Name of the generic apply function
genericApplyName :: ApplyConv -> FastString genericApplyName :: ApplyConv -> FastString
genericApplyName = \case genericApplyName = \case
RegsConv -> "h$ap_gen_fast" RegsConv -> identFS hdApGenFastStr
StackConv -> "h$ap_gen" StackConv -> identFS hdApGenStr
-- | Expr of the generic apply function -- | Expr of the generic apply function
genericApplyExpr :: ApplyConv -> JStgExpr genericApplyExpr :: ApplyConv -> JStgExpr
genericApplyExpr conv = var (genericApplyName conv) genericApplyExpr conv = global (genericApplyName conv)
-- | Return the name of the specialized apply function for the given number of -- | Return the name of the specialized apply function for the given number of
...@@ -327,7 +328,7 @@ specApplyName = \case ...@@ -327,7 +328,7 @@ specApplyName = \case
-- Warning: the returned function may not be generated! Use specApplyExprMaybe -- Warning: the returned function may not be generated! Use specApplyExprMaybe
-- if you want to ensure that it exists. -- if you want to ensure that it exists.
specApplyExpr :: ApplySpec -> JStgExpr specApplyExpr :: ApplySpec -> JStgExpr
specApplyExpr spec = var (specApplyName spec) specApplyExpr spec = global (specApplyName spec)
-- | Return the expression of the specialized apply function for the given -- | Return the expression of the specialized apply function for the given
-- number of args, number of arg variables, and calling convention. -- number of args, number of arg variables, and calling convention.
...@@ -377,7 +378,7 @@ applySpec = [ ApplySpec conv nargs nvars ...@@ -377,7 +378,7 @@ applySpec = [ ApplySpec conv nargs nvars
-- --
-- Warning: tag doesn't take into account the calling convention -- Warning: tag doesn't take into account the calling convention
specTag :: ApplySpec -> Int specTag :: ApplySpec -> Int
specTag spec = Bits.shiftL (specVars spec) 8 Bits..|. (specArgs spec) specTag spec = Bits.shiftL (specVars spec) 8 Bits..|. specArgs spec
-- | Generate a tag expression for the given ApplySpec -- | Generate a tag expression for the given ApplySpec
specTagExpr :: ApplySpec -> JStgExpr specTagExpr :: ApplySpec -> JStgExpr
...@@ -390,13 +391,13 @@ specTagExpr = toJExpr . specTag ...@@ -390,13 +391,13 @@ specTagExpr = toJExpr . specTag
mkApplyArr :: JSM JStgStat mkApplyArr :: JSM JStgStat
mkApplyArr = mkApplyArr =
do mk_ap_gens <- jFor (|= zero_) (.<. Int 65536) preIncrS do mk_ap_gens <- jFor (|= zero_) (.<. Int 65536) preIncrS
\j -> var "h$apply" .! j |= var "h$ap_gen" \j -> hdApply .! j |= hdApGen
mk_pap_gens <- jFor (|= zero_) (.<. Int 128) preIncrS mk_pap_gens <- jFor (|= zero_) (.<. Int 128) preIncrS
\j -> var "h$paps" .! j |= var "h$pap_gen" \j -> hdPaps .! j |= hdPapGen
return $ mconcat return $ mconcat
[ global "h$apply" ||= toJExpr (JList []) [ name hdApplyStr ||= toJExpr (JList [])
, global "h$paps" ||= toJExpr (JList []) , name hdPapsStr ||= toJExpr (JList [])
, ApplStat (var "h$initStatic" .^ "push") , ApplStat (hdInitStatic .^ "push")
[ jLam' $ [ jLam' $
mconcat mconcat
[ mk_ap_gens [ mk_ap_gens
...@@ -412,12 +413,13 @@ mkApplyArr = ...@@ -412,12 +413,13 @@ mkApplyArr =
-- both fast/slow (regs/stack) specialized apply functions have the same -- both fast/slow (regs/stack) specialized apply functions have the same
-- tags. We store the stack ones in the array because they are used as -- tags. We store the stack ones in the array because they are used as
-- continuation stack frames. -- continuation stack frames.
StackConv -> var "h$apply" .! specTagExpr spec |= specApplyExpr spec StackConv -> hdApply .! specTagExpr spec |= specApplyExpr spec
RegsConv -> mempty RegsConv -> mempty
hdPap_ = unpackFS hdPapStr_
assignPap :: Int -> JStgStat assignPap :: Int -> JStgStat
assignPap p = var "h$paps" .! toJExpr p |= assignPap p = hdPaps .! toJExpr p |= global (mkFastString (hdPap_ ++ show p))
(var (mkFastString $ ("h$pap_" ++ show p)))
-- | Push a continuation on the stack -- | Push a continuation on the stack
-- --
...@@ -453,7 +455,7 @@ genericStackApply cfg = closure info body ...@@ -453,7 +455,7 @@ genericStackApply cfg = closure info body
pap <- fun_case cf (papArity r1) pap <- fun_case cf (papArity r1)
return $ return $
mconcat $ mconcat $
[ traceRts cfg (jString "h$ap_gen") [ traceRts cfg (jString $ identFS hdApGenStr)
, cf |= closureInfo r1 , cf |= closureInfo r1
-- switch on closure type -- switch on closure type
, SwitchStat (infoClosureType cf) , SwitchStat (infoClosureType cf)
...@@ -467,16 +469,16 @@ genericStackApply cfg = closure info body ...@@ -467,16 +469,16 @@ genericStackApply cfg = closure info body
-- info table for h$ap_gen -- info table for h$ap_gen
info = ClosureInfo info = ClosureInfo
{ ciVar = global "h$ap_gen" { ciVar = hdApGenStr
, ciRegs = CIRegs 0 [PtrV] -- closure to apply to , ciRegs = CIRegs 0 [PtrV] -- closure to apply to
, ciName = "h$ap_gen" , ciName = identFS hdApGenStr
, ciLayout = CILayoutVariable , ciLayout = CILayoutVariable
, ciType = CIStackFrame , ciType = CIStackFrame
, ciStatic = mempty , ciStatic = mempty
} }
default_case cf = appS "throw" [jString "h$ap_gen: unexpected closure type " default_case cf = appS throwStr [jString "h$ap_gen: unexpected closure type "
+ (infoClosureType cf)] + (infoClosureType cf)]
thunk_case cfg cf = mconcat thunk_case cfg cf = mconcat
[ profStat cfg pushRestoreCCS [ profStat cfg pushRestoreCCS
...@@ -484,8 +486,8 @@ genericStackApply cfg = closure info body ...@@ -484,8 +486,8 @@ genericStackApply cfg = closure info body
] ]
blackhole_case cfg = mconcat blackhole_case cfg = mconcat
[ push' cfg [r1, var "h$return"] [ push' cfg [r1, hdReturn]
, returnS (app "h$blockOnBlackhole" [r1]) , returnS (app hdBlockOnBlackHoleStr [r1])
] ]
fun_case c arity = jVars \(tag, needed_args, needed_regs, given_args, given_regs, newTag, newAp, p, dat) -> fun_case c arity = jVars \(tag, needed_args, needed_regs, given_args, given_regs, newTag, newAp, p, dat) ->
...@@ -496,12 +498,12 @@ genericStackApply cfg = closure info body ...@@ -496,12 +498,12 @@ genericStackApply cfg = closure info body
load_reg_values <- loop 0 (.<. needed_regs) load_reg_values <- loop 0 (.<. needed_regs)
\i -> return $ \i -> return $
mconcat [ traceRts cfg (jString "h$ap_gen: loading register: " + i) mconcat [ traceRts cfg (jString "h$ap_gen: loading register: " + i)
, appS "h$setReg" [ i+2 , stack .! (sp-2-i)] , appS hdSetRegStr [ i+2 , stack .! (sp-2-i)]
, postIncrS i , postIncrS i
] ]
set_reg_values <- loop 0 (.<. given_regs) set_reg_values <- loop 0 (.<. given_regs)
\i -> return $ \i -> return $
mconcat [ appS "h$setReg" [ i+2, stack .! (sp-2-i)] mconcat [ appS hdSetRegStr [ i+2, stack .! (sp-2-i)]
, postIncrS i , postIncrS i
] ]
return $ return $
...@@ -537,12 +539,12 @@ genericStackApply cfg = closure info body ...@@ -537,12 +539,12 @@ genericStackApply cfg = closure info body
-- compute new tag with consumed register values and args removed -- compute new tag with consumed register values and args removed
, newTag |= ((given_regs-needed_regs).<<.8) .|. (given_args - needed_args) , newTag |= ((given_regs-needed_regs).<<.8) .|. (given_args - needed_args)
-- find application function for the remaining regs/args -- find application function for the remaining regs/args
, newAp |= var "h$apply" .! newTag , newAp |= hdApply .! newTag
, traceRts cfg (jString "h$ap_gen: next: " + (newAp .^ "n")) , traceRts cfg (jString "h$ap_gen: next: " + (newAp .^ "n"))
-- Drop used registers from the stack. -- Drop used registers from the stack.
-- Test if the application function needs a tag and push it. -- Test if the application function needs a tag and push it.
, ifS (newAp .===. var "h$ap_gen") , ifS (newAp .===. hdApGen )
((sp |= sp - needed_regs) <> (stack .! (sp - 1) |= newTag)) ((sp |= sp - needed_regs) <> (stack .! (sp - 1) |= newTag))
(sp |= sp - needed_regs - 1) (sp |= sp - needed_regs - 1)
...@@ -561,7 +563,7 @@ genericStackApply cfg = closure info body ...@@ -561,7 +563,7 @@ genericStackApply cfg = closure info body
----------------------------- -----------------------------
[ traceRts cfg (jString "h$ap_gen: undersat") [ traceRts cfg (jString "h$ap_gen: undersat")
-- find PAP entry function corresponding to given_regs count -- find PAP entry function corresponding to given_regs count
, p |= var "h$paps" .! given_regs , p |= hdPaps .! given_regs
-- build PAP payload: R1 + tag + given register values -- build PAP payload: R1 + tag + given register values
, newTag |= ((needed_regs-given_regs) .<<. 8) .|. (needed_args-given_args) , newTag |= ((needed_regs-given_regs) .<<. 8) .|. (needed_args-given_args)
...@@ -590,7 +592,7 @@ genericStackApply cfg = closure info body ...@@ -590,7 +592,7 @@ genericStackApply cfg = closure info body
-- --
genericFastApply :: StgToJSConfig -> JSM JStgStat genericFastApply :: StgToJSConfig -> JSM JStgStat
genericFastApply s = genericFastApply s =
jFunction (global "h$ap_gen_fast") jFunction (name "h$ap_gen_fast")
\(MkSolo tag) -> jVar $ \c -> \(MkSolo tag) -> jVar $ \c ->
do push_stk_app <- pushStackApply c tag do push_stk_app <- pushStackApply c tag
fast_fun <- jVar \farity -> fast_fun <- jVar \farity ->
...@@ -617,13 +619,13 @@ genericFastApply s = ...@@ -617,13 +619,13 @@ genericFastApply s =
, (toJExpr Pap, fast_pap) , (toJExpr Pap, fast_pap)
, (toJExpr Con, traceRts s (jString "h$ap_gen_fast: con") , (toJExpr Con, traceRts s (jString "h$ap_gen_fast: con")
<> jwhenS (tag .!=. 0) <> jwhenS (tag .!=. 0)
(appS "throw" [jString "h$ap_gen_fast: invalid apply"]) (appS throwStr [jString "h$ap_gen_fast: invalid apply"])
<> returnS c) <> returnS c)
, (toJExpr Blackhole, traceRts s (jString "h$ap_gen_fast: blackhole") , (toJExpr Blackhole, traceRts s (jString "h$ap_gen_fast: blackhole")
<> push_stk_app <> push_stk_app
<> push' s [r1, var "h$return"] <> push' s [r1, hdReturn]
<> returnS (app "h$blockOnBlackhole" [r1])) <> returnS (app hdBlockOnBlackHoleStr [r1]))
] $ appS "throw" [jString "h$ap_gen_fast: unexpected closure type: " + infoClosureType c] ] $ appS throwStr [jString "h$ap_gen_fast: unexpected closure type: " + infoClosureType c]
] ]
where where
...@@ -634,8 +636,8 @@ genericFastApply s = ...@@ -634,8 +636,8 @@ genericFastApply s =
do push_all_regs <- pushAllRegs tag do push_all_regs <- pushAllRegs tag
return $ mconcat $ return $ mconcat $
[ push_all_regs [ push_all_regs
, ap |= var "h$apply" .! tag , ap |= hdApply .! tag
, ifS (ap .===. var "h$ap_gen") , ifS (ap .===. hdApGen)
((sp |= sp + 2) <> (stack .! (sp-1) |= tag)) ((sp |= sp + 2) <> (stack .! (sp-1) |= tag))
(sp |= sp + 1) (sp |= sp + 1)
, stack .! sp |= ap , stack .! sp |= ap
...@@ -648,7 +650,7 @@ genericFastApply s = ...@@ -648,7 +650,7 @@ genericFastApply s =
do get_regs <- loop 0 (.<. myRegs) $ do get_regs <- loop 0 (.<. myRegs) $
\i -> return $ \i -> return $
(dat .^ "push") `ApplStat` [app "h$getReg" [i+2]] <> postIncrS i (dat .^ "push") `ApplStat` [app hdGetRegStr [i+2]] <> postIncrS i
push_args <- pushArgs regsStart myRegs push_args <- pushArgs regsStart myRegs
return $ mconcat $ return $ mconcat $
...@@ -668,8 +670,8 @@ genericFastApply s = ...@@ -668,8 +670,8 @@ genericFastApply s =
, traceRts s (jString "h$ap_gen_fast: oversat " + sp) , traceRts s (jString "h$ap_gen_fast: oversat " + sp)
, push_args , push_args
, newTag |= ((myRegs-( arity.>>.8)).<<.8).|.myAr-ar , newTag |= ((myRegs-( arity.>>.8)).<<.8).|.myAr-ar
, newAp |= var "h$apply" .! newTag , newAp |= hdApply .! newTag
, ifS (newAp .===. var "h$ap_gen") , ifS (newAp .===. hdApGen)
((sp |= sp + 2) <> (stack .! (sp - 1) |= newTag)) ((sp |= sp + 2) <> (stack .! (sp - 1) |= newTag))
(sp |= sp + 1) (sp |= sp + 1)
, stack .! sp |= newAp , stack .! sp |= newAp
...@@ -679,7 +681,7 @@ genericFastApply s = ...@@ -679,7 +681,7 @@ genericFastApply s =
-- else -- else
[traceRts s (jString "h$ap_gen_fast: undersat: " + myRegs + jString " " + tag) [traceRts s (jString "h$ap_gen_fast: undersat: " + myRegs + jString " " + tag)
, jwhenS (tag .!=. 0) $ mconcat , jwhenS (tag .!=. 0) $ mconcat
[ p |= var "h$paps" .! myRegs [ p |= hdPaps .! myRegs
, dat |= toJExpr [r1, ((arity .>>. 8)-myRegs)*256+ar-myAr] , dat |= toJExpr [r1, ((arity .>>. 8)-myRegs)*256+ar-myAr]
, get_regs , get_regs
, r1 |= initClosure s p dat jCurrentCCS , r1 |= initClosure s p dat jCurrentCCS
...@@ -705,7 +707,7 @@ genericFastApply s = ...@@ -705,7 +707,7 @@ genericFastApply s =
loop end (.>=.start) loop end (.>=.start)
\i -> return $ \i -> return $
traceRts s (jString "pushing register: " + i) traceRts s (jString "pushing register: " + i)
<> (stack .! (sp + start - i) |= app "h$getReg" [i+1]) <> (stack .! (sp + start - i) |= app hdGetRegStr [i+1])
<> postDecrS i <> postDecrS i
-- | Make specialized apply function for the given ApplySpec -- | Make specialized apply function for the given ApplySpec
...@@ -730,7 +732,7 @@ stackApply s fun_name nargs nvars = ...@@ -730,7 +732,7 @@ stackApply s fun_name nargs nvars =
else closure info body else closure info body
where where
info = ClosureInfo info = ClosureInfo
{ ciVar = global fun_name { ciVar = name fun_name
, ciRegs = CIRegs 0 [PtrV] , ciRegs = CIRegs 0 [PtrV]
, ciName = fun_name , ciName = fun_name
, ciLayout = CILayoutUnknown nvars , ciLayout = CILayoutUnknown nvars
...@@ -738,7 +740,7 @@ stackApply s fun_name nargs nvars = ...@@ -738,7 +740,7 @@ stackApply s fun_name nargs nvars =
, ciStatic = mempty , ciStatic = mempty
} }
info0 = ClosureInfo info0 = ClosureInfo
{ ciVar = global fun_name { ciVar = name fun_name
, ciRegs = CIRegs 0 [PtrV] , ciRegs = CIRegs 0 [PtrV]
, ciName = fun_name , ciName = fun_name
, ciLayout = CILayoutFixed 0 [] , ciLayout = CILayoutFixed 0 []
...@@ -762,8 +764,8 @@ stackApply s fun_name nargs nvars = ...@@ -762,8 +764,8 @@ stackApply s fun_name nargs nvars =
[ (toJExpr Thunk, traceRts s (toJExpr $ fun_name <> ": thunk") <> profStat s pushRestoreCCS <> returnS c) [ (toJExpr Thunk, traceRts s (toJExpr $ fun_name <> ": thunk") <> profStat s pushRestoreCCS <> returnS c)
, (toJExpr Fun, traceRts s (toJExpr $ fun_name <> ": fun") <> fun_case) , (toJExpr Fun, traceRts s (toJExpr $ fun_name <> ": fun") <> fun_case)
, (toJExpr Pap, traceRts s (toJExpr $ fun_name <> ": pap") <> pap_case) , (toJExpr Pap, traceRts s (toJExpr $ fun_name <> ": pap") <> pap_case)
, (toJExpr Blackhole, push' s [r1, var "h$return"] <> returnS (app "h$blockOnBlackhole" [r1])) , (toJExpr Blackhole, push' s [r1, hdReturn] <> returnS (app hdBlockOnBlackHoleStr [r1]))
] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (infoClosureType c)]) ] (appS throwStr [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (infoClosureType c)])
] ]
funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c
...@@ -824,7 +826,7 @@ stackApply s fun_name nargs nvars = ...@@ -824,7 +826,7 @@ stackApply s fun_name nargs nvars =
[ rs |= (arity .>>. 8) [ rs |= (arity .>>. 8)
, loadRegs rs , loadRegs rs
, sp |= sp - rs , sp |= sp - rs
, newAp |= (var "h$apply" .! ((toJExpr nargs-arity0).|.((toJExpr nvars-rs).<<.8))) , newAp |= (hdApply .! ((toJExpr nargs-arity0).|.((toJExpr nvars-rs).<<.8)))
, stack .! sp |= newAp , stack .! sp |= newAp
, profStat s pushRestoreCCS , profStat s pushRestoreCCS
, traceRts s (toJExpr (fun_name <> ": new stack frame: ") + (newAp .^ "n")) , traceRts s (toJExpr (fun_name <> ": new stack frame: ") + (newAp .^ "n"))
...@@ -846,7 +848,7 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0 ...@@ -846,7 +848,7 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0
-- general case -- general case
else jFunction' func body else jFunction' func body
where where
func = global fun_name func = name fun_name
ap_fast :: JSM JStgStat ap_fast :: JSM JStgStat
ap_fast = enter s r1 ap_fast = enter s r1
...@@ -869,8 +871,8 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0 ...@@ -869,8 +871,8 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0
<> fun_case_fun) <> fun_case_fun)
,(toJExpr Pap, traceRts s (toJExpr (fun_name <> ": pap")) <> (arity |= papArity r1) <> fun_case_pap) ,(toJExpr Pap, traceRts s (toJExpr (fun_name <> ": pap")) <> (arity |= papArity r1) <> fun_case_pap)
,(toJExpr Thunk, traceRts s (toJExpr (fun_name <> ": thunk")) <> push' s (reverse regArgs ++ mkAp nargs nvars) <> profStat s pushRestoreCCS <> returnS c) ,(toJExpr Thunk, traceRts s (toJExpr (fun_name <> ": thunk")) <> push' s (reverse regArgs ++ mkAp nargs nvars) <> profStat s pushRestoreCCS <> returnS c)
,(toJExpr Blackhole, traceRts s (toJExpr (fun_name <> ": blackhole")) <> push' s (reverse regArgs ++ mkAp nargs nvars) <> push' s [r1, var "h$return"] <> returnS (app "h$blockOnBlackhole" [r1]))] ,(toJExpr Blackhole, traceRts s (toJExpr (fun_name <> ": blackhole")) <> push' s (reverse regArgs ++ mkAp nargs nvars) <> push' s [r1, global "h$return"] <> returnS (app "h$blockOnBlackhole" [r1]))]
(appS "throw" [toJExpr (fun_name <> ": unexpected closure type: ") + infoClosureType c]) (appS throwStr [toJExpr (fun_name <> ": unexpected closure type: ") + infoClosureType c])
] ]
funCase :: JStgExpr -> JStgExpr -> JSM JStgStat funCase :: JStgExpr -> JStgExpr -> JSM JStgStat
...@@ -907,7 +909,7 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0 ...@@ -907,7 +909,7 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0
+ rsRemain) + rsRemain)
, saveRegs rs , saveRegs rs
, sp |= sp + rsRemain + 1 , sp |= sp + rsRemain + 1
, stack .! sp |= var "h$apply" .! ((rsRemain.<<.8).|. (toJExpr nargs - mask8 arity)) , stack .! sp |= hdApply .! ((rsRemain.<<.8).|. (toJExpr nargs - mask8 arity))
, profStat s pushRestoreCCS , profStat s pushRestoreCCS
, returnS c , returnS c
] ]
...@@ -917,7 +919,7 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0 ...@@ -917,7 +919,7 @@ fastApply s fun_name nargs nvars = if nargs == 0 && nvars == 0
switchAlts = map (\x -> (toJExpr x, stack .! (sp + toJExpr (nvars-x)) |= jsReg (x+2))) [0..nvars-1] switchAlts = map (\x -> (toJExpr x, stack .! (sp + toJExpr (nvars-x)) |= jsReg (x+2))) [0..nvars-1]
zeroApply :: StgToJSConfig -> JSM JStgStat zeroApply :: StgToJSConfig -> JSM JStgStat
zeroApply s = jFunction (global "h$e") zeroApply s = jFunction hdEntry
$ \(MkSolo c) -> fmap ((r1 |= c) <>) $ enter s c $ \(MkSolo c) -> fmap ((r1 |= c) <>) $ enter s c
-- carefully enter a closure that might be a thunk or a function -- carefully enter a closure that might be a thunk or a function
...@@ -926,15 +928,15 @@ zeroApply s = jFunction (global "h$e") ...@@ -926,15 +928,15 @@ zeroApply s = jFunction (global "h$e")
enter :: StgToJSConfig -> JStgExpr -> JSM JStgStat enter :: StgToJSConfig -> JStgExpr -> JSM JStgStat
enter s ex = jVar \c -> enter s ex = jVar \c ->
return $ mconcat $ return $ mconcat $
[ jwhenS (app "typeof" [ex] .!==. jTyObject) returnStack [ jwhenS (app typeof [ex] .!==. jTyObject) returnStack
, c |= closureInfo ex , c |= closureInfo ex
, jwhenS (c .===. var "h$unbox_e") ((r1 |= closureField1 ex) <> returnStack) , jwhenS (c .===. hdUnboxEntry) ((r1 |= closureField1 ex) <> returnStack)
, SwitchStat (infoClosureType c) , SwitchStat (infoClosureType c)
[ (toJExpr Con, mempty) [ (toJExpr Con, mempty)
, (toJExpr Fun, mempty) , (toJExpr Fun, mempty)
, (toJExpr Pap, returnStack) , (toJExpr Pap, returnStack)
, (toJExpr Blackhole, push' s [var "h$ap_0_0", ex, var "h$return"] , (toJExpr Blackhole, push' s [hdAp00, ex, hdReturn]
<> returnS (app "h$blockOnBlackhole" [ex])) <> returnS (app hdBlockOnBlackHoleStr [ex]))
] (returnS c) ] (returnS c)
] ]
...@@ -944,7 +946,7 @@ updates s = do ...@@ -944,7 +946,7 @@ updates s = do
upd_frm_lne <- update_frame_lne upd_frm_lne <- update_frame_lne
return $ BlockStat [upd_frm, upd_frm_lne] return $ BlockStat [upd_frm, upd_frm_lne]
where where
unbox_closure f1 = Closure { clInfo = var "h$unbox_e" unbox_closure f1 = Closure { clInfo = hdUnboxEntry -- global "h$unbox_e"
, clField1 = f1 , clField1 = f1
, clField2 = null_ , clField2 = null_
, clMeta = 0 , clMeta = 0
...@@ -961,9 +963,9 @@ updates s = do ...@@ -961,9 +963,9 @@ updates s = do
] ]
update_frame = closure update_frame = closure
(ClosureInfo (ClosureInfo
{ ciVar = global "h$upd_frame" { ciVar = hdUpdFrameStr
, ciRegs = CIRegs 0 [PtrV] , ciRegs = CIRegs 0 [PtrV]
, ciName = "h$upd_frame" , ciName = identFS hdUpdFrameStr
, ciLayout = CILayoutFixed 1 [PtrV] , ciLayout = CILayoutFixed 1 [PtrV]
, ciType = CIStackFrame , ciType = CIStackFrame
, ciStatic = mempty , ciStatic = mempty
...@@ -972,7 +974,7 @@ updates s = do ...@@ -972,7 +974,7 @@ updates s = do
do upd_loop <- upd_loop' ss si sir do upd_loop <- upd_loop' ss si sir
wake_thread_loop <- loop zero_ (.<. waiters .^ "length") wake_thread_loop <- loop zero_ (.<. waiters .^ "length")
\i -> return $ \i -> return $
appS "h$wakeupThread" [waiters .! i] appS hdWakeupThread [waiters .! i]
<> postIncrS i <> postIncrS i
let updateCC updatee = closureCC updatee |= jCurrentCCS let updateCC updatee = closureCC updatee |= jCurrentCCS
...@@ -983,11 +985,11 @@ updates s = do ...@@ -983,11 +985,11 @@ updates s = do
waiters |= closureField2 updatee waiters |= closureField2 updatee
, jwhenS (waiters .!==. null_) wake_thread_loop , jwhenS (waiters .!==. null_) wake_thread_loop
, -- update selectors , -- update selectors
jwhenS ((app "typeof" [closureMeta updatee] .===. jTyObject) .&&. (closureMeta updatee .^ "sel")) jwhenS ((app typeof [closureMeta updatee] .===. jTyObject) .&&. (closureMeta updatee .^ "sel"))
((ss |= closureMeta updatee .^ "sel") ((ss |= closureMeta updatee .^ "sel")
<> upd_loop) <> upd_loop)
, -- overwrite the object , -- overwrite the object
ifS (app "typeof" [r1] .===. jTyObject) ifS (app typeof [r1] .===. jTyObject)
(mconcat [ traceRts s (jString "$upd_frame: boxed: " + ((closureInfo r1) .^ "n")) (mconcat [ traceRts s (jString "$upd_frame: boxed: " + ((closureInfo r1) .^ "n"))
, copyClosure DontCopyCC updatee r1 , copyClosure DontCopyCC updatee r1
]) ])
...@@ -1006,7 +1008,7 @@ updates s = do ...@@ -1006,7 +1008,7 @@ updates s = do
update_frame_lne = closure update_frame_lne = closure
(ClosureInfo (ClosureInfo
{ ciVar = global "h$upd_frame_lne" { ciVar = name $ fsLit "h$upd_frame_lne"
, ciRegs = CIRegs 0 [PtrV] , ciRegs = CIRegs 0 [PtrV]
, ciName = "h$upd_frame_lne" , ciName = "h$upd_frame_lne"
, ciLayout = CILayoutFixed 1 [PtrV] , ciLayout = CILayoutFixed 1 [PtrV]
...@@ -1016,7 +1018,7 @@ updates s = do ...@@ -1016,7 +1018,7 @@ updates s = do
$ jVar \updateePos -> $ jVar \updateePos ->
return $ mconcat $ return $ mconcat $
[ updateePos |= stack .! (sp - 1) [ updateePos |= stack .! (sp - 1)
, (stack .! updateePos |= r1) , stack .! updateePos |= r1
, adjSpN' 2 , adjSpN' 2
, traceRts s (jString "h$upd_frame_lne: updating: " , traceRts s (jString "h$upd_frame_lne: updating: "
+ updateePos + updateePos
...@@ -1031,35 +1033,35 @@ selectors s = ...@@ -1031,35 +1033,35 @@ selectors s =
sel_one <- mkSel "1" closureField1 sel_one <- mkSel "1" closureField1
sel_twoA <- mkSel "2a" closureField2 sel_twoA <- mkSel "2a" closureField2
sel_twoB <- mkSel "2b" (closureField1 . closureField2) sel_twoB <- mkSel "2b" (closureField1 . closureField2)
rest <- mconcat <$> (mapM mkSelN [3..16]) rest <- mconcat <$> mapM mkSelN [3..16]
return $ return $
sel_one <> sel_twoA <> sel_twoB <> rest sel_one <> sel_twoA <> sel_twoB <> rest
where where
mkSelN :: Int -> JSM JStgStat mkSelN :: Int -> JSM JStgStat
mkSelN x = mkSel (mkFastString $ show x) mkSelN x = mkSel (mkFastString $ show x)
(\e -> SelExpr (closureField2 (toJExpr e)) (\e -> SelExpr (closureField2 (toJExpr e))
(global $ mkFastString ("d" ++ show (x-1)))) (name $ mkFastString ("d" ++ show (x-1))))
mkSel :: FastString -> (JStgExpr -> JStgExpr) -> JSM JStgStat mkSel :: FastString -> (JStgExpr -> JStgExpr) -> JSM JStgStat
mkSel name sel = mconcat <$> sequence mkSel name_ sel = mconcat <$> sequence
[jFunction (global createName) $ [jFunction (name createName) $
\(MkSolo r) -> return $ mconcat \(MkSolo r) -> return $ mconcat
[ traceRts s (toJExpr ("selector create: " <> name <> " for ") + (r .^ "alloc")) [ traceRts s (toJExpr ("selector create: " <> name_ <> " for ") + (r .^ "alloc"))
, ifS (isThunk r .||. isBlackhole r) , ifS (isThunk r .||. isBlackhole r)
(returnS (app "h$mkSelThunk" [r, toJExpr (v entryName), toJExpr (v resName)])) (returnS (app "h$mkSelThunk" [r, toJExpr (v entryName), toJExpr (v resName)]))
(returnS (sel r)) (returnS (sel r))
] ]
, jFunction (global resName) $ , jFunction (name resName) $
\(MkSolo r) -> return $ mconcat \(MkSolo r) -> return $ mconcat
[ traceRts s (toJExpr ("selector result: " <> name <> " for ") + (r .^ "alloc")) [ traceRts s (toJExpr ("selector result: " <> name_ <> " for ") + (r .^ "alloc"))
, returnS (sel r) , returnS (sel r)
] ]
, closure , closure
(ClosureInfo (ClosureInfo
{ ciVar = global entryName { ciVar = name entryName
, ciRegs = CIRegs 0 [PtrV] , ciRegs = CIRegs 0 [PtrV]
, ciName = "select " <> name , ciName = "select " <> name_
, ciLayout = CILayoutFixed 1 [PtrV] , ciLayout = CILayoutFixed 1 [PtrV]
, ciType = CIThunk , ciType = CIThunk
, ciStatic = mempty , ciStatic = mempty
...@@ -1067,32 +1069,32 @@ selectors s = ...@@ -1067,32 +1069,32 @@ selectors s =
(jVar $ \tgt -> (jVar $ \tgt ->
return $ mconcat $ return $ mconcat $
[ tgt |= closureField1 r1 [ tgt |= closureField1 r1
, traceRts s (toJExpr ("selector entry: " <> name <> " for ") + (tgt .^ "alloc")) , traceRts s (toJExpr ("selector entry: " <> name_ <> " for ") + (tgt .^ "alloc"))
, ifS (isThunk tgt .||. isBlackhole tgt) , ifS (isThunk tgt .||. isBlackhole tgt)
(preIncrS sp (preIncrS sp
<> (stack .! sp |= var frameName) <> (stack .! sp |= global frameName)
<> returnS (app "h$e" [tgt])) <> returnS (app "h$e" [tgt]))
(returnS (app "h$e" [sel tgt])) (returnS (app "h$e" [sel tgt]))
]) ])
, closure , closure
(ClosureInfo (ClosureInfo
{ ciVar = global frameName { ciVar = name frameName
, ciRegs = CIRegs 0 [PtrV] , ciRegs = CIRegs 0 [PtrV]
, ciName = "select " <> name <> " frame" , ciName = "select " <> name_ <> " frame"
, ciLayout = CILayoutFixed 0 [] , ciLayout = CILayoutFixed 0 []
, ciType = CIStackFrame , ciType = CIStackFrame
, ciStatic = mempty , ciStatic = mempty
}) })
$ return $ $ return $
mconcat [ traceRts s (toJExpr ("selector frame: " <> name)) mconcat [ traceRts s (toJExpr ("selector frame: " <> name_))
, postDecrS sp , postDecrS sp
, returnS (app "h$e" [sel r1]) , returnS (app "h$e" [sel r1])
] ]
] ]
where where
v x = JVar (global x) v x = JVar (name x)
n ext = "h$c_sel_" <> name <> ext n ext = "h$c_sel_" <> name_ <> ext
createName = n "" createName = n ""
resName = n "_res" resName = n "_res"
entryName = n "_e" entryName = n "_e"
...@@ -1116,7 +1118,7 @@ mkPap s tgt fun n values = ...@@ -1116,7 +1118,7 @@ mkPap s tgt fun n values =
values' | GHC.Prelude.null values = [null_] values' | GHC.Prelude.null values = [null_]
| otherwise = values | otherwise = values
entry | length values > numSpecPap = global "h$pap_gen" entry | length values > numSpecPap = name "h$pap_gen"
| otherwise = specPapIdents ! length values | otherwise = specPapIdents ! length values
-- | Number of specialized PAPs (pre-generated for a given number of args) -- | Number of specialized PAPs (pre-generated for a given number of args)
...@@ -1130,7 +1132,7 @@ specPap = [0..numSpecPap] ...@@ -1130,7 +1132,7 @@ specPap = [0..numSpecPap]
-- | Cache of specialized PAP idents -- | Cache of specialized PAP idents
specPapIdents :: Array Int Ident specPapIdents :: Array Int Ident
specPapIdents = listArray (0,numSpecPap) $ map (global . mkFastString . ("h$pap_"++) . show) specPap specPapIdents = listArray (0,numSpecPap) $ map (name . mkFastString . ("h$pap_"++) . show) specPap
pap :: StgToJSConfig pap :: StgToJSConfig
-> Int -> Int
...@@ -1144,7 +1146,7 @@ pap s r = closure (ClosureInfo ...@@ -1144,7 +1146,7 @@ pap s r = closure (ClosureInfo
, ciStatic = mempty , ciStatic = mempty
}) body }) body
where where
funcIdent = global funcName funcIdent = name funcName
funcName = mkFastString ("h$pap_" ++ show r) funcName = mkFastString ("h$pap_" ++ show r)
body = jVars $ \(c, d, f, extra) -> body = jVars $ \(c, d, f, extra) ->
...@@ -1166,7 +1168,7 @@ pap s r = closure (ClosureInfo ...@@ -1166,7 +1168,7 @@ pap s r = closure (ClosureInfo
moveCase m = (toJExpr m, jsReg (m+r+1) |= jsReg (m+1)) moveCase m = (toJExpr m, jsReg (m+r+1) |= jsReg (m+1))
loadOwnArgs d = mconcat $ map (\r -> loadOwnArgs d = mconcat $ map (\r ->
jsReg (r+1) |= dField d (r+2)) [1..r] jsReg (r+1) |= dField d (r+2)) [1..r]
dField d n = SelExpr d (global . mkFastString $ ('d':show (n-1))) dField d n = SelExpr d (name . mkFastString $ ('d':show (n-1)))
-- Construct a generic PAP -- Construct a generic PAP
papGen :: StgToJSConfig -> JSM JStgStat papGen :: StgToJSConfig -> JSM JStgStat
...@@ -1192,7 +1194,7 @@ papGen cfg = ...@@ -1192,7 +1194,7 @@ papGen cfg =
(jString "h$pap_gen: expected function or pap") (jString "h$pap_gen: expected function or pap")
, profStat cfg (enterCostCentreFun currentCCS) , profStat cfg (enterCostCentreFun currentCCS)
, traceRts cfg (jString "h$pap_gen: generic pap extra args moving: " + or) , traceRts cfg (jString "h$pap_gen: generic pap extra args moving: " + or)
, appS "h$moveRegs2" [or, r] , appS hdMoveRegs2 [or, r]
, loadOwnArgs d r , loadOwnArgs d r
, r1 |= c , r1 |= c
, returnS f , returnS f
...@@ -1200,8 +1202,8 @@ papGen cfg = ...@@ -1200,8 +1202,8 @@ papGen cfg =
where where
funcIdent = global funcName funcIdent = name funcName
funcName = "h$pap_gen" funcName = hdPapGenStr
loadOwnArgs d r = loadOwnArgs d r =
let prop n = d .^ ("d" <> mkFastString (show $ n+1)) let prop n = d .^ ("d" <> mkFastString (show $ n+1))
loadOwnArg n = (toJExpr n, jsReg (n+1) |= prop n) loadOwnArg n = (toJExpr n, jsReg (n+1) |= prop n)
...@@ -1210,7 +1212,7 @@ papGen cfg = ...@@ -1210,7 +1212,7 @@ papGen cfg =
-- general utilities -- general utilities
-- move the first n registers, starting at R2, m places up (do not use with negative m) -- move the first n registers, starting at R2, m places up (do not use with negative m)
moveRegs2 :: JSM JStgStat moveRegs2 :: JSM JStgStat
moveRegs2 = jFunction (global "h$moveRegs2") moveSwitch moveRegs2 = jFunction (name hdMoveRegs2) moveSwitch
where where
moveSwitch (n,m) = defaultCase n m >>= return . SwitchStat ((n .<<. 8) .|. m) switchCases moveSwitch (n,m) = defaultCase n m >>= return . SwitchStat ((n .<<. 8) .|. m) switchCases
-- fast cases -- fast cases
...@@ -1224,13 +1226,13 @@ moveRegs2 = jFunction (global "h$moveRegs2") moveSwitch ...@@ -1224,13 +1226,13 @@ moveRegs2 = jFunction (global "h$moveRegs2") moveSwitch
-- fallback -- fallback
defaultCase n m = defaultCase n m =
loop n (.>.0) (\i -> return $ loop n (.>.0) (\i -> return $
appS "h$setReg" [i+1+m, app "h$getReg" [i+1]] appS hdSetRegStr [i+1+m, app hdGetRegStr [i+1]]
<> postDecrS i) <> postDecrS i)
-- Initalize a variable sized object from an array of values -- Initalize a variable sized object from an array of values
initClosure :: StgToJSConfig -> JStgExpr -> JStgExpr -> JStgExpr -> JStgExpr initClosure :: StgToJSConfig -> JStgExpr -> JStgExpr -> JStgExpr -> JStgExpr
initClosure cfg info values ccs = app "h$init_closure" initClosure cfg info values ccs = app hdInitClosure
[ newClosure $ Closure [ newClosure $ Closure
{ clInfo = info { clInfo = info
, clField1 = null_ , clField1 = null_
......
...@@ -277,9 +277,9 @@ allocateStaticList _ _ = panic "allocateStaticList: unexpected literal in list" ...@@ -277,9 +277,9 @@ allocateStaticList _ _ = panic "allocateStaticList: unexpected literal in list"
jsStaticArg :: StaticArg -> JStgExpr jsStaticArg :: StaticArg -> JStgExpr
jsStaticArg = \case jsStaticArg = \case
StaticLitArg l -> toJExpr l StaticLitArg l -> toJExpr l
StaticObjArg t -> var t StaticObjArg t -> global t
StaticConArg c args -> StaticConArg c args ->
allocDynamicE False (var c) (map jsStaticArg args) Nothing allocDynamicE False (global c) (map jsStaticArg args) Nothing
-- | Generate JS code corresponding to a list of static args -- | Generate JS code corresponding to a list of static args
jsStaticArgs :: [StaticArg] -> JStgExpr jsStaticArgs :: [StaticArg] -> JStgExpr
......
...@@ -253,10 +253,10 @@ allocClsA i = toJExpr (global (clsName i)) ...@@ -253,10 +253,10 @@ allocClsA i = toJExpr (global (clsName i))
-- | Cache "xXXX" names -- | Cache "xXXX" names
varCache :: Array Int Ident varCache :: Array Int Ident
varCache = listArray (0,jsClosureCount) (fmap (global . mkFastString . ('x':) . show) [(0::Int)..jsClosureCount]) varCache = listArray (0,jsClosureCount) (fmap (name . mkFastString . ('x':) . show) [(0::Int)..jsClosureCount])
varName :: Int -> Ident varName :: Int -> Ident
varName i varName i
| i < 0 || i > jsClosureCount = global $ mkFastString ('x' : show i) | i < 0 || i > jsClosureCount = name $ mkFastString ('x' : show i)
| otherwise = varCache ! i | otherwise = varCache ! i
...@@ -40,19 +40,20 @@ import GHC.JS.Ident ...@@ -40,19 +40,20 @@ import GHC.JS.Ident
import GHC.StgToJS.Apply import GHC.StgToJS.Apply
import GHC.StgToJS.Arg import GHC.StgToJS.Arg
import GHC.StgToJS.Closure import GHC.StgToJS.Closure
import GHC.StgToJS.DataCon
import GHC.StgToJS.ExprCtx import GHC.StgToJS.ExprCtx
import GHC.StgToJS.FFI import GHC.StgToJS.FFI
import GHC.StgToJS.Heap import GHC.StgToJS.Heap
import GHC.StgToJS.Monad import GHC.StgToJS.Ids
import GHC.StgToJS.DataCon
import GHC.StgToJS.Types
import GHC.StgToJS.Literal import GHC.StgToJS.Literal
import GHC.StgToJS.Monad
import GHC.StgToJS.Prim import GHC.StgToJS.Prim
import GHC.StgToJS.Profiling import GHC.StgToJS.Profiling
import GHC.StgToJS.Regs import GHC.StgToJS.Regs
import GHC.StgToJS.Utils
import GHC.StgToJS.Stack import GHC.StgToJS.Stack
import GHC.StgToJS.Ids import GHC.StgToJS.Symbols
import GHC.StgToJS.Types
import GHC.StgToJS.Utils
import GHC.Types.CostCentre import GHC.Types.CostCentre
import GHC.Types.Tickish import GHC.Types.Tickish
...@@ -170,7 +171,7 @@ genBind ctx bndr = ...@@ -170,7 +171,7 @@ genBind ctx bndr =
the_fvjs <- varsForId the_fv the_fvjs <- varsForId the_fv
case (tgts, the_fvjs) of case (tgts, the_fvjs) of
([tgt], [the_fvj]) -> return $ Just ([tgt], [the_fvj]) -> return $ Just
(tgt ||= ApplExpr (var ("h$c_sel_" <> mkFastString sel_tag)) [the_fvj]) (tgt ||= ApplExpr (global (hdCSelStr <> mkFastString sel_tag)) [the_fvj])
_ -> panic "genBind.assign: invalid size" _ -> panic "genBind.assign: invalid size"
assign b (StgRhsClosure _ext _ccs _upd [] expr _typ) assign b (StgRhsClosure _ext _ccs _upd [] expr _typ)
| isInlineExpr expr = do | isInlineExpr expr = do
...@@ -233,7 +234,7 @@ genEntryLne ctx i rhs@(StgRhsClosure _ext _cc update args body typ) = ...@@ -233,7 +234,7 @@ genEntryLne ctx i rhs@(StgRhsClosure _ext _cc update args body typ) =
mk_bh | isUpdatable update = mk_bh | isUpdatable update =
do x <- freshIdent do x <- freshIdent
return $ mconcat return $ mconcat
[ x ||= ApplExpr (var "h$bh_lne") [Sub sp (toJExpr myOffset), toJExpr (payloadSize+1)] [ x ||= ApplExpr hdBlackHoleLNE [Sub sp (toJExpr myOffset), toJExpr (payloadSize+1)]
, IfStat (Var x) (ReturnStat (Var x)) mempty , IfStat (Var x) (ReturnStat (Var x)) mempty
] ]
| otherwise = pure mempty | otherwise = pure mempty
...@@ -242,7 +243,7 @@ genEntryLne ctx i rhs@(StgRhsClosure _ext _cc update args body typ) = ...@@ -242,7 +243,7 @@ genEntryLne ctx i rhs@(StgRhsClosure _ext _cc update args body typ) =
body <- genBody ctx R1 args body typ body <- genBody ctx R1 args body typ
ei@(identFS -> eii) <- identForEntryId i ei@(identFS -> eii) <- identForEntryId i
sr <- genStaticRefsRhs rhs sr <- genStaticRefsRhs rhs
let f = (blk_hl <> locals <> body) let f = blk_hl <> locals <> body
emitClosureInfo $ ClosureInfo emitClosureInfo $ ClosureInfo
{ ciVar = ei { ciVar = ei
, ciRegs = CIRegs 0 $ concatMap idJSRep args , ciRegs = CIRegs 0 $ concatMap idJSRep args
...@@ -388,7 +389,7 @@ verifyRuntimeReps xs = do ...@@ -388,7 +389,7 @@ verifyRuntimeReps xs = do
ver j DoubleV = v "h$verify_rep_double" [j] ver j DoubleV = v "h$verify_rep_double" [j]
ver j ArrV = v "h$verify_rep_arr" [j] ver j ArrV = v "h$verify_rep_arr" [j]
ver _ _ = mempty ver _ _ = mempty
v f as = ApplStat (var f) as v f as = ApplStat (global f) as
-- | Given a set of 'Id's, bind each 'Id' to the appropriate data fields in N -- | Given a set of 'Id's, bind each 'Id' to the appropriate data fields in N
-- registers. This assumes these data fields have already been populated in the -- registers. This assumes these data fields have already been populated in the
...@@ -416,7 +417,7 @@ loadLiveFun l = do ...@@ -416,7 +417,7 @@ loadLiveFun l = do
, l'' , l''
] ]
where where
loadLiveVar d n v = let ident = global (dataFieldName n) loadLiveVar d n v = let ident = name (dataFieldName n)
in v ||= SelExpr d ident in v ||= SelExpr d ident
-- | Pop a let-no-escape frame off the stack -- | Pop a let-no-escape frame off the stack
...@@ -458,7 +459,7 @@ genUpdFrame u i ...@@ -458,7 +459,7 @@ genUpdFrame u i
-- --
bhSingleEntry :: StgToJSConfig -> JStgStat bhSingleEntry :: StgToJSConfig -> JStgStat
bhSingleEntry _settings = mconcat bhSingleEntry _settings = mconcat
[ closureInfo r1 |= var "h$blackholeTrap" [ closureInfo r1 |= hdBlackHoleTrap
, closureField1 r1 |= undefined_ , closureField1 r1 |= undefined_
, closureField2 r1 |= undefined_ , closureField2 r1 |= undefined_
] ]
...@@ -784,7 +785,7 @@ verifyMatchRep x alt = do ...@@ -784,7 +785,7 @@ verifyMatchRep x alt = do
else case alt of else case alt of
AlgAlt tc -> do AlgAlt tc -> do
ix <- varsForId x ix <- varsForId x
pure $ ApplStat (var "h$verify_match_alg") (ValExpr(JStr(mkFastString (renderWithContext defaultSDocContext (ppr tc)))):ix) pure $ ApplStat (global "h$verify_match_alg") (ValExpr (JStr (mkFastString (renderWithContext defaultSDocContext (ppr tc)))):ix)
_ -> pure mempty _ -> pure mempty
-- | A 'Branch' represents a possible branching path of an Stg case statement, -- | A 'Branch' represents a possible branching path of an Stg case statement,
...@@ -946,7 +947,7 @@ loadParams from args = do ...@@ -946,7 +947,7 @@ loadParams from args = do
loadIfUsed _ _ _ = mempty loadIfUsed _ _ _ = mempty
loadConVarsIfUsed fr cs = mconcat $ zipWith f cs [(1::Int)..] loadConVarsIfUsed fr cs = mconcat $ zipWith f cs [(1::Int)..]
where f (x,u) n = loadIfUsed (SelExpr fr (global (dataFieldName n))) x u where f (x,u) n = loadIfUsed (SelExpr fr (name (dataFieldName n))) x u
-- | Determine if a branch will end in a continuation or not. If not the inline -- | Determine if a branch will end in a continuation or not. If not the inline
-- branch must be normalized. See 'normalizeBranches' -- branch must be normalized. See 'normalizeBranches'
...@@ -1021,7 +1022,7 @@ allocDynAll haveDecl middle cls = do ...@@ -1021,7 +1022,7 @@ allocDynAll haveDecl middle cls = do
, (closureMeta_ , zero_) , (closureMeta_ , zero_)
] ]
++ fmap (\cid -> ("cc", ValExpr (JVar cid))) ccs) ++ fmap (\cid -> ("cc", ValExpr (JVar cid))) ccs)
else ApplExpr (var "h$c") (f : fmap (ValExpr . JVar) ccs) else ApplExpr hdC (f : fmap (ValExpr . JVar) ccs)
] ]
fillObjs :: [JStgStat] fillObjs :: [JStgStat]
...@@ -1048,7 +1049,7 @@ allocDynAll haveDecl middle cls = do ...@@ -1048,7 +1049,7 @@ allocDynAll haveDecl middle cls = do
checkObjs :: [JStgStat] checkObjs :: [JStgStat]
checkObjs | csAssertRts settings = checkObjs | csAssertRts settings =
map (\(i,_,_,_) -> ApplStat (var "h$checkObj") [Var i]) cls map (\(i,_,_,_) -> ApplStat hdCheckObj [Var i]) cls
| otherwise = mempty | otherwise = mempty
objs <- makeObjs objs <- makeObjs
......
...@@ -11,17 +11,17 @@ where ...@@ -11,17 +11,17 @@ where
import GHC.Prelude import GHC.Prelude
import GHC.JS.JStg.Syntax import GHC.JS.JStg.Syntax
import GHC.JS.Ident
import GHC.JS.Make import GHC.JS.Make
import GHC.StgToJS.Arg import GHC.StgToJS.Arg
import GHC.StgToJS.ExprCtx import GHC.StgToJS.ExprCtx
import GHC.StgToJS.Monad import GHC.StgToJS.Ids
import GHC.StgToJS.Types
import GHC.StgToJS.Literal import GHC.StgToJS.Literal
import GHC.StgToJS.Monad
import GHC.StgToJS.Regs import GHC.StgToJS.Regs
import GHC.StgToJS.Symbols
import GHC.StgToJS.Types
import GHC.StgToJS.Utils import GHC.StgToJS.Utils
import GHC.StgToJS.Ids
import GHC.Types.RepType import GHC.Types.RepType
import GHC.Types.ForeignCall import GHC.Types.ForeignCall
...@@ -44,7 +44,7 @@ import qualified Data.List as L ...@@ -44,7 +44,7 @@ import qualified Data.List as L
genPrimCall :: ExprCtx -> PrimCall -> [StgArg] -> Type -> G (JStgStat, ExprResult) genPrimCall :: ExprCtx -> PrimCall -> [StgArg] -> Type -> G (JStgStat, ExprResult)
genPrimCall ctx (PrimCall lbl _) args t = do genPrimCall ctx (PrimCall lbl _) args t = do
j <- parseFFIPattern False False False ("h$" ++ unpackFS lbl) t (concatMap typex_expr $ ctxTarget ctx) args j <- parseFFIPattern False False False (unpackFS hdStr ++ unpackFS lbl) t (concatMap typex_expr $ ctxTarget ctx) args
return (j, ExprInline) return (j, ExprInline)
-- | generate the actual call -- | generate the actual call
...@@ -79,8 +79,7 @@ parseFFIPattern catchExcep async jscc pat t es as ...@@ -79,8 +79,7 @@ parseFFIPattern catchExcep async jscc pat t es as
-- } catch(except) { -- } catch(except) {
-- return h$throwJSException(except); -- return h$throwJSException(except);
-- } -- }
let ex = global "except" return (TryStat c exceptStr (ReturnStat (ApplExpr hdThrowJSException [except])) mempty)
return (TryStat c ex (ReturnStat (ApplExpr (var "h$throwJSException") [toJExpr ex])) mempty)
| otherwise = parseFFIPatternA async jscc pat t es as | otherwise = parseFFIPatternA async jscc pat t es as
parseFFIPatternA :: Bool -- ^ async parseFFIPatternA :: Bool -- ^ async
...@@ -98,18 +97,18 @@ parseFFIPatternA True True pat t es as = do ...@@ -98,18 +97,18 @@ parseFFIPatternA True True pat t es as = do
d <- freshIdent d <- freshIdent
stat <- parseFFIPattern' (Just (toJExpr cb)) True pat t es as stat <- parseFFIPattern' (Just (toJExpr cb)) True pat t es as
return $ mconcat return $ mconcat
[ x ||= (toJExpr (jhFromList [("mv", null_)])) [ x ||= (toJExpr (jhFromList [(mv, null_)]))
, cb ||= ApplExpr (var "h$mkForeignCallback") [toJExpr x] , cb ||= ApplExpr hdMkForeignCallback [toJExpr x]
, stat , stat
, IfStat (InfixExpr StrictEqOp (toJExpr x .^ "mv") null_) , IfStat (InfixExpr StrictEqOp (toJExpr x .^ mv) null_)
(mconcat (mconcat
[ toJExpr x .^ "mv" |= UOpExpr NewOp (ApplExpr (var "h$MVar") []) [ toJExpr x .^ mv |= UOpExpr NewOp (ApplExpr hdMVar [])
, sp |= Add sp one_ , sp |= Add sp one_
, (IdxExpr stack sp) |= var "h$unboxFFIResult" , (IdxExpr stack sp) |= hdUnboxFFIResult
, ReturnStat $ ApplExpr (var "h$takeMVar") [toJExpr x .^ "mv"] , ReturnStat $ ApplExpr hdTakeMVar [toJExpr x .^ mv]
]) ])
(mconcat (mconcat
[ d ||= toJExpr x .^ "mv" [ d ||= toJExpr x .^ mv
, copyResult (toJExpr d) , copyResult (toJExpr d)
]) ])
] ]
...@@ -155,7 +154,7 @@ parseFFIPattern' callback javascriptCc pat t ret args ...@@ -155,7 +154,7 @@ parseFFIPattern' callback javascriptCc pat t ret args
copyResult rs = mconcat $ zipWith (\t r -> toJExpr r |= toJExpr t) (enumFrom Ret1) rs copyResult rs = mconcat $ zipWith (\t r -> toJExpr r |= toJExpr t) (enumFrom Ret1) rs
traceCall cs as traceCall cs as
| csTraceForeign cs = ApplStat (var "h$traceForeign") [toJExpr pat, toJExpr as] | csTraceForeign cs = ApplStat hdTraceForeign [toJExpr pat, toJExpr as]
| otherwise = mempty | otherwise = mempty
-- generate arg to be passed to FFI call, with marshalling JStgStat to be run -- generate arg to be passed to FFI call, with marshalling JStgStat to be run
...@@ -189,7 +188,7 @@ genForeignCall _ctx ...@@ -189,7 +188,7 @@ genForeignCall _ctx
_t _t
[obj] [obj]
args args
| tgt == fsLit "h$buildObject" | tgt == hdBuildObjectStr
, Just pairs <- getObjectKeyValuePairs args = do , Just pairs <- getObjectKeyValuePairs args = do
pairs' <- mapM (\(k,v) -> genArg v >>= \vs -> return (k, head vs)) pairs pairs' <- mapM (\(k,v) -> genArg v >>= \vs -> return (k, head vs)) pairs
return ( (|=) obj (ValExpr (JHash $ listToUniqMap pairs')) return ( (|=) obj (ValExpr (JHash $ listToUniqMap pairs'))
...@@ -197,18 +196,19 @@ genForeignCall _ctx ...@@ -197,18 +196,19 @@ genForeignCall _ctx
) )
genForeignCall ctx (CCall (CCallSpec ccTarget cconv safety)) t tgt args = do genForeignCall ctx (CCall (CCallSpec ccTarget cconv safety)) t tgt args = do
emitForeign (ctxSrcSpan ctx) (mkFastString lbl) safety cconv (map showArgType args) (showType t) emitForeign (ctxSrcSpan ctx) lbl safety cconv (map showArgType args) (showType t)
(,exprResult) <$> parseFFIPattern catchExcep async isJsCc lbl t tgt' args (,exprResult) <$> parseFFIPattern catchExcep async isJsCc (unpackFS lbl) t tgt' args
where where
isJsCc = cconv == JavaScriptCallConv isJsCc = cconv == JavaScriptCallConv
lbl | (StaticTarget _ clbl _mpkg _isFunPtr) <- ccTarget lbl | (StaticTarget _ clbl _mpkg _isFunPtr) <- ccTarget
= let clbl' = unpackFS clbl = let clbl' = unpackFS clbl
in if | isJsCc -> clbl' hDollarS = unpackFS hdStr
in if | isJsCc -> clbl
| wrapperPrefix `L.isPrefixOf` clbl' -> | wrapperPrefix `L.isPrefixOf` clbl' ->
("h$" ++ (drop 2 $ dropWhile isDigit $ drop (length wrapperPrefix) clbl')) mkFastString (hDollarS ++ (drop 2 $ dropWhile isDigit $ drop (length wrapperPrefix) clbl'))
| otherwise -> "h$" ++ clbl' | otherwise -> mkFastString $ hDollarS ++ clbl'
| otherwise = "h$callDynamic" | otherwise = hdCallDynamicStr
exprResult | async = ExprCont exprResult | async = ExprCont
| otherwise = ExprInline | otherwise = ExprInline
...@@ -222,7 +222,7 @@ genForeignCall ctx (CCall (CCallSpec ccTarget cconv safety)) t tgt args = do ...@@ -222,7 +222,7 @@ genForeignCall ctx (CCall (CCallSpec ccTarget cconv safety)) t tgt args = do
tgt' | async = take (length tgt) jsRegsFromR1 tgt' | async = take (length tgt) jsRegsFromR1
| otherwise = tgt | otherwise = tgt
wrapperPrefix = "ghczuwrapperZC" wrapperPrefix = unpackFS wrapperColonStr
getObjectKeyValuePairs :: [StgArg] -> Maybe [(FastString, StgArg)] getObjectKeyValuePairs :: [StgArg] -> Maybe [(FastString, StgArg)]
getObjectKeyValuePairs [] = Just [] getObjectKeyValuePairs [] = Just []
...@@ -242,4 +242,4 @@ showType :: Type -> FastString ...@@ -242,4 +242,4 @@ showType :: Type -> FastString
showType t showType t
| Just tc <- tyConAppTyCon_maybe (unwrapType t) = | Just tc <- tyConAppTyCon_maybe (unwrapType t) =
mkFastString (renderWithContext defaultSDocContext (ppr tc)) mkFastString (renderWithContext defaultSDocContext (ppr tc))
| otherwise = "<unknown>" | otherwise = unknown
...@@ -90,7 +90,7 @@ closureType :: JStgExpr -> JStgExpr ...@@ -90,7 +90,7 @@ closureType :: JStgExpr -> JStgExpr
closureType = infoClosureType . closureInfo closureType = infoClosureType . closureInfo
isObject :: JStgExpr -> JStgExpr isObject :: JStgExpr -> JStgExpr
isObject c = typeof c .===. String "object" isObject c = typeOf c .===. String "object"
isThunk :: JStgExpr -> JStgExpr isThunk :: JStgExpr -> JStgExpr
isThunk c = closureType c .===. toJExpr Thunk isThunk c = closureType c .===. toJExpr Thunk
......
...@@ -78,9 +78,8 @@ freshIdent :: G Ident ...@@ -78,9 +78,8 @@ freshIdent :: G Ident
freshIdent = do freshIdent = do
i <- freshUnique i <- freshUnique
mod <- State.gets gsModule mod <- State.gets gsModule
let !name = mkFreshJsSymbol mod i let !sym_name = mkFreshJsSymbol mod i
return (global name) return (name sym_name)
-- | Generate unique Ident for the given ID (uncached!) -- | Generate unique Ident for the given ID (uncached!)
-- --
...@@ -100,19 +99,19 @@ freshIdent = do ...@@ -100,19 +99,19 @@ freshIdent = do
-- Int64#), Addr#, StablePtr#, unboxed tuples, etc. -- Int64#), Addr#, StablePtr#, unboxed tuples, etc.
-- --
makeIdentForId :: Id -> Maybe Int -> IdType -> Module -> Ident makeIdentForId :: Id -> Maybe Int -> IdType -> Module -> Ident
makeIdentForId i num id_type current_module = global ident makeIdentForId i num id_type current_module = name ident
where where
exported = isExportedId i exported = isExportedId i
name = getName i name' = getName i
mod mod
| exported | exported
, Just m <- nameModule_maybe name , Just m <- nameModule_maybe name'
= m = m
| otherwise | otherwise
= current_module = current_module
!ident = mkFastStringByteString $ mconcat !ident = mkFastStringByteString $ mconcat
[ mkJsSymbolBS exported mod (occNameMangledFS (nameOccName name)) [ mkJsSymbolBS exported mod (occNameMangledFS (nameOccName name'))
------------- -------------
-- suffixes -- suffixes
......
...@@ -1240,24 +1240,24 @@ staticInitStat :: StaticInfo -> JS.JStat ...@@ -1240,24 +1240,24 @@ staticInitStat :: StaticInfo -> JS.JStat
staticInitStat (StaticInfo i sv mcc) = staticInitStat (StaticInfo i sv mcc) =
jStgStatToJS $ jStgStatToJS $
case sv of case sv of
StaticData con args -> appS "h$sti" $ add_cc_arg StaticData con args -> appS hdStiStr $ add_cc_arg
[ var i [ global i
, var con , global con
, jsStaticArgs args , jsStaticArgs args
] ]
StaticFun f args -> appS "h$sti" $ add_cc_arg StaticFun f args -> appS hdStiStr $ add_cc_arg
[ var i [ global i
, var f , global f
, jsStaticArgs args , jsStaticArgs args
] ]
StaticList args mt -> appS "h$stl" $ add_cc_arg StaticList args mt -> appS hdStlStr $ add_cc_arg
[ var i [ global i
, jsStaticArgs args , jsStaticArgs args
, toJExpr $ maybe null_ (toJExpr . TxtI) mt , toJExpr $ maybe null_ (toJExpr . TxtI) mt
] ]
StaticThunk (Just (f,args)) -> appS "h$stc" $ add_cc_arg StaticThunk (Just (f,args)) -> appS hdStcStr $ add_cc_arg
[ var i [ global i
, var f , global f
, jsStaticArgs args , jsStaticArgs args
] ]
_ -> mempty _ -> mempty
...@@ -1271,19 +1271,19 @@ staticInitStat (StaticInfo i sv mcc) = ...@@ -1271,19 +1271,19 @@ staticInitStat (StaticInfo i sv mcc) =
staticDeclStat :: StaticInfo -> JS.JStat staticDeclStat :: StaticInfo -> JS.JStat
staticDeclStat (StaticInfo global_name static_value _) = jStgStatToJS decl staticDeclStat (StaticInfo global_name static_value _) = jStgStatToJS decl
where where
global_ident = global global_name global_ident = name global_name
decl_init v = global_ident ||= v decl_init v = global_ident ||= v
decl_no_init = appS "h$di" [toJExpr global_ident] decl_no_init = appS hdDiStr [toJExpr global_ident]
decl = case static_value of decl = case static_value of
StaticUnboxed u -> decl_init (unboxed_expr u) StaticUnboxed u -> decl_init (unboxed_expr u)
StaticThunk Nothing -> decl_no_init -- CAF initialized in an alternative way StaticThunk Nothing -> decl_no_init -- CAF initialized in an alternative way
_ -> decl_init (app "h$d" []) _ -> decl_init (app hdDStr [])
unboxed_expr = \case unboxed_expr = \case
StaticUnboxedBool b -> app "h$p" [toJExpr b] StaticUnboxedBool b -> app hdPStr [toJExpr b]
StaticUnboxedInt i -> app "h$p" [toJExpr i] StaticUnboxedInt i -> app hdPStr [toJExpr i]
StaticUnboxedDouble d -> app "h$p" [toJExpr (unSaneDouble d)] StaticUnboxedDouble d -> app hdPStr [toJExpr (unSaneDouble d)]
-- GHCJS used a function wrapper for this: -- GHCJS used a function wrapper for this:
-- StaticUnboxedString str -> ApplExpr (initStr str) [] -- StaticUnboxedString str -> ApplExpr (initStr str) []
-- But we are defining it statically for now. -- But we are defining it statically for now.
...@@ -1295,5 +1295,5 @@ staticDeclStat (StaticInfo global_name static_value _) = jStgStatToJS decl ...@@ -1295,5 +1295,5 @@ staticDeclStat (StaticInfo global_name static_value _) = jStgStatToJS decl
initStr :: BS.ByteString -> JStgExpr initStr :: BS.ByteString -> JStgExpr
initStr str = initStr str =
case decodeModifiedUTF8 str of case decodeModifiedUTF8 str of
Just t -> app "h$encodeModifiedUtf8" [ValExpr (JStr t)] Just t -> app hdEncodeModifiedUtf8Str [ValExpr (JStr t)]
Nothing -> app "h$rawStringData" [ValExpr $ to_byte_list str] Nothing -> app hdRawStringDataStr [ValExpr $ to_byte_list str]
...@@ -14,10 +14,10 @@ import GHC.JS.JStg.Syntax ...@@ -14,10 +14,10 @@ import GHC.JS.JStg.Syntax
import GHC.JS.Make import GHC.JS.Make
import GHC.JS.Ident import GHC.JS.Ident
import GHC.StgToJS.Types
import GHC.StgToJS.Monad
import GHC.StgToJS.Ids import GHC.StgToJS.Ids
import GHC.StgToJS.Monad
import GHC.StgToJS.Symbols import GHC.StgToJS.Symbols
import GHC.StgToJS.Types
import GHC.Data.FastString import GHC.Data.FastString
import GHC.Types.Literal import GHC.Types.Literal
...@@ -62,8 +62,8 @@ genLit = \case ...@@ -62,8 +62,8 @@ genLit = \case
LitFloat r -> return [ toJExpr (r2f r) ] LitFloat r -> return [ toJExpr (r2f r) ]
LitDouble r -> return [ toJExpr (r2d r) ] LitDouble r -> return [ toJExpr (r2d r) ]
LitLabel name fod LitLabel name fod
| fod == IsFunction -> return [ ApplExpr (var "h$mkFunctionPtr") | fod == IsFunction -> return [ ApplExpr hdMkFunctionPtr
[var (mkRawSymbol True name)] [global (mkRawSymbol True name)]
, ValExpr (JInt 0) , ValExpr (JInt 0)
] ]
| otherwise -> return [ toJExpr (global (mkRawSymbol True name)) | otherwise -> return [ toJExpr (global (mkRawSymbol True name))
......
...@@ -538,7 +538,7 @@ instance Binary Sat.JVal where ...@@ -538,7 +538,7 @@ instance Binary Sat.JVal where
instance Binary Ident where instance Binary Ident where
put_ bh (identFS -> xs) = put_ bh xs put_ bh (identFS -> xs) = put_ bh xs
get bh = global <$> get bh get bh = name <$> get bh
instance Binary ClosureInfo where instance Binary ClosureInfo where
put_ bh (ClosureInfo v regs name layo typ static) = do put_ bh (ClosureInfo v regs name layo typ static) = do
......
This diff is collapsed.
...@@ -28,14 +28,15 @@ where ...@@ -28,14 +28,15 @@ where
import GHC.Prelude import GHC.Prelude
import GHC.JS.Syntax import GHC.JS.Syntax
import GHC.JS.JStg.Syntax (JStgExpr)
import qualified GHC.JS.JStg.Syntax as JStg import qualified GHC.JS.JStg.Syntax as JStg
import GHC.JS.Make import GHC.JS.Make
import GHC.JS.Ident import GHC.JS.Ident
import GHC.StgToJS.Monad
import GHC.StgToJS.Regs import GHC.StgToJS.Regs
import GHC.StgToJS.Types
import GHC.StgToJS.Symbols import GHC.StgToJS.Symbols
import GHC.StgToJS.Monad import GHC.StgToJS.Types
import GHC.Types.CostCentre import GHC.Types.CostCentre
...@@ -46,6 +47,33 @@ import GHC.Utils.Outputable ...@@ -46,6 +47,33 @@ import GHC.Utils.Outputable
import GHC.Utils.Panic import GHC.Utils.Panic
import qualified Control.Monad.Trans.State.Strict as State import qualified Control.Monad.Trans.State.Strict as State
--------------------------------------------------------------------------------
-- Symbols
hdCC :: JStgExpr
hdCC = JStg.global "h$CC"
hdCCS :: JStgExpr
hdCCS = JStg.global "h$CCS"
hdEnterFunCCS :: JStgExpr
hdEnterFunCCS = JStg.global "h$enterFunCCS"
cc :: Ident
cc = name "cc"
ccs :: Ident
ccs = name "ccs"
hdPushCostCentre :: JStgExpr
hdPushCostCentre = JStg.global "h$pushCostCentre"
hdPushRestoreCCS :: JStgExpr
hdPushRestoreCCS = JStg.global "h$pushRestoreCCS"
hdEnterThunkCCS :: JStgExpr
hdEnterThunkCCS = JStg.global "h$enterThunkCCS"
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Initialization -- Initialization
...@@ -62,7 +90,7 @@ emitCostCentreDecl cc = do ...@@ -62,7 +90,7 @@ emitCostCentreDecl cc = do
modl = moduleNameString $ moduleName $ cc_mod cc modl = moduleNameString $ moduleName $ cc_mod cc
loc = renderWithContext defaultSDocContext (ppr (costCentreSrcSpan cc)) loc = renderWithContext defaultSDocContext (ppr (costCentreSrcSpan cc))
js = JStg.DeclStat ccsLbl js = JStg.DeclStat ccsLbl
(Just (JStg.UOpExpr JStg.NewOp (JStg.ApplExpr (JStg.var "h$CC") (Just (JStg.UOpExpr JStg.NewOp (JStg.ApplExpr hdCC
[ toJExpr label [ toJExpr label
, toJExpr modl , toJExpr modl
, toJExpr loc , toJExpr loc
...@@ -79,7 +107,7 @@ emitCostCentreStackDecl ccs = ...@@ -79,7 +107,7 @@ emitCostCentreStackDecl ccs =
let js = let js =
JStg.DeclStat ccsLbl JStg.DeclStat ccsLbl
(Just (JStg.UOpExpr JStg.NewOp (Just (JStg.UOpExpr JStg.NewOp
(JStg.ApplExpr (JStg.var "h$CCS") [null_, toJExpr ccLbl]))) (JStg.ApplExpr hdCCS [null_, toJExpr ccLbl])))
emitGlobal js emitGlobal js
Nothing -> pprPanic "emitCostCentreStackDecl" (ppr ccs) Nothing -> pprPanic "emitCostCentreStackDecl" (ppr ccs)
...@@ -88,37 +116,36 @@ emitCostCentreStackDecl ccs = ...@@ -88,37 +116,36 @@ emitCostCentreStackDecl ccs =
enterCostCentreFun :: CostCentreStack -> JStg.JStgStat enterCostCentreFun :: CostCentreStack -> JStg.JStgStat
enterCostCentreFun ccs enterCostCentreFun ccs
| isCurrentCCS ccs = JStg.ApplStat (JStg.var "h$enterFunCCS") | isCurrentCCS ccs = JStg.ApplStat hdEnterFunCCS [jCurrentCCS, JStg.SelExpr r1 cc]
[jCurrentCCS, JStg.SelExpr r1 (global "cc")]
| otherwise = mempty -- top-level function, nothing to do | otherwise = mempty -- top-level function, nothing to do
enterCostCentreThunk :: JStg.JStgStat enterCostCentreThunk :: JStg.JStgStat
enterCostCentreThunk = JStg.ApplStat (JStg.var "h$enterThunkCCS") [JStg.SelExpr r1 (global "cc")] enterCostCentreThunk = JStg.ApplStat hdEnterThunkCCS [JStg.SelExpr r1 cc]
setCC :: CostCentre -> Bool -> Bool -> G JStg.JStgStat setCC :: CostCentre -> Bool -> Bool -> G JStg.JStgStat
setCC cc _tick True = do setCC cc _tick True = do
ccI@(identFS -> _ccLbl) <- costCentreLbl cc ccI@(identFS -> _ccLbl) <- costCentreLbl cc
addDependency $ OtherSymb (cc_mod cc) addDependency $ OtherSymb (cc_mod cc)
(moduleGlobalSymbol $ cc_mod cc) (moduleGlobalSymbol $ cc_mod cc)
return $ jCurrentCCS |= JStg.ApplExpr (JStg.var "h$pushCostCentre") [ jCurrentCCS return $ jCurrentCCS |= JStg.ApplExpr hdPushCostCentre [ jCurrentCCS
, JStg.Var ccI , JStg.Var ccI
] ]
setCC _cc _tick _push = return mempty setCC _cc _tick _push = return mempty
pushRestoreCCS :: JStg.JStgStat pushRestoreCCS :: JStg.JStgStat
pushRestoreCCS = JStg.ApplStat (JStg.var "h$pushRestoreCCS") [] pushRestoreCCS = JStg.ApplStat hdPushRestoreCCS []
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Some cost-centre stacks to be used in generator -- Some cost-centre stacks to be used in generator
jCurrentCCS :: JStg.JStgExpr jCurrentCCS :: JStg.JStgExpr
jCurrentCCS = JStg.SelExpr (JStg.var "h$currentThread") (global "ccs") jCurrentCCS = JStg.SelExpr hdCurrentThread ccs
jCafCCS :: JStg.JStgExpr jCafCCS :: JStg.JStgExpr
jCafCCS = JStg.var "h$CAF" jCafCCS = JStg.global "h$CAF"
jSystemCCS :: JStg.JStgExpr jSystemCCS :: JStg.JStgExpr
jSystemCCS = JStg.var "h$CCS_SYSTEM" jSystemCCS = JStg.global "h$CCS_SYSTEM"
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Helpers for generating profiling related things -- Helpers for generating profiling related things
...@@ -138,6 +165,7 @@ ifProfilingM m = do ...@@ -138,6 +165,7 @@ ifProfilingM m = do
-- | If profiling is enabled, then use input JStgStat, else ignore -- | If profiling is enabled, then use input JStgStat, else ignore
profStat :: StgToJSConfig -> JStg.JStgStat -> JStg.JStgStat profStat :: StgToJSConfig -> JStg.JStgStat -> JStg.JStgStat
profStat cfg e = if csProf cfg then e else mempty profStat cfg e = if csProf cfg then e else mempty
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Generating cost-centre and cost-centre stack variables -- Generating cost-centre and cost-centre stack variables
...@@ -150,7 +178,7 @@ costCentreLbl' cc = do ...@@ -150,7 +178,7 @@ costCentreLbl' cc = do
moduleNameColons (moduleName curModl) ++ "_" ++ if isCafCC cc then "CAF_ccs" else lbl moduleNameColons (moduleName curModl) ++ "_" ++ if isCafCC cc then "CAF_ccs" else lbl
costCentreLbl :: CostCentre -> G Ident costCentreLbl :: CostCentre -> G Ident
costCentreLbl cc = global . mkFastString <$> costCentreLbl' cc costCentreLbl cc = name . mkFastString <$> costCentreLbl' cc
costCentreStackLbl' :: CostCentreStack -> G (Maybe String) costCentreStackLbl' :: CostCentreStack -> G (Maybe String)
costCentreStackLbl' ccs = do costCentreStackLbl' ccs = do
...@@ -164,7 +192,7 @@ costCentreStackLbl' ccs = do ...@@ -164,7 +192,7 @@ costCentreStackLbl' ccs = do
Nothing -> pure Nothing Nothing -> pure Nothing
costCentreStackLbl :: CostCentreStack -> G (Maybe Ident) costCentreStackLbl :: CostCentreStack -> G (Maybe Ident)
costCentreStackLbl ccs = fmap (global . mkFastString) <$> costCentreStackLbl' ccs costCentreStackLbl ccs = fmap (name . mkFastString) <$> costCentreStackLbl' ccs
singletonCCSLbl' :: CostCentre -> G String singletonCCSLbl' :: CostCentre -> G String
singletonCCSLbl' cc = do singletonCCSLbl' cc = do
...@@ -178,7 +206,7 @@ singletonCCSLbl' cc = do ...@@ -178,7 +206,7 @@ singletonCCSLbl' cc = do
] ]
singletonCCSLbl :: CostCentre -> G Ident singletonCCSLbl :: CostCentre -> G Ident
singletonCCSLbl cc = global . mkFastString <$> singletonCCSLbl' cc singletonCCSLbl cc = name . mkFastString <$> singletonCCSLbl' cc
ccsVarJ :: CostCentreStack -> G (Maybe JStg.JStgExpr) ccsVarJ :: CostCentreStack -> G (Maybe JStg.JStgExpr)
ccsVarJ ccs = do ccsVarJ ccs = do
......