Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,247
    • Issues 5,247
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 577
    • Merge requests 577
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Merge requests
  • !7577

Draft: Prim: Add Opaque prim type

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open doyougnu requested to merge doyougnu/ghc:wip/JavaScript-value-primtype into master Feb 14, 2022
  • Overview 34
  • Commits 3
  • Pipelines 2
  • Changes 14

Disclaimer

Please refrain from commenting further on this MR, see #21142 for a summary of this discussion and please comment there

Status

** ON HOLD **
This MR and related ghc-proposal is on hold until we have working code and tests in wip/javascript-backend. Until then we are using the hacked version of JSVal, i.e., data JSVal = JSVal ByteArray#

What

In pursuit of #21078 (closed) This MR does:

  • Adds Opaque# as a prim type. An Opaque# is an Addr# but one that does not support any pointer arithmetic. I'm open to any naming suggestions, perhaps OpaqueRef#?
  • Adds a runtime rep OpaqueRep that corresponds to the prim type
  • Add a single test case that is expected to fail but parses a javascript foreign import, dumps the ast, and checks it against .stderr (the golden file).

Why

For new backends we want a way to refer to things in the new runtime from Haskell land, but GHC cannot know too much about these things by definition, and hence they are Opaque. Pointers in JavaScript aren't normal pointers, instead they are pointers to a buffer and and offset into that buffer. Thus, we cannot use Addr# for the js backend but we still want a handle to things in JavaScript land from Haskell.

Other Stuff

This is the first time I have added a prim type and I may have (very likely) confused things. I believe this should be a known-key thing, not a wired-in thing because of the information GHC knows about it, i.e., not all that much. Similarly, I believe this should have a runtime rep to correspond to the prim type but I'm honestly not sure how it all hooks together.

This is a draft because

Marked as Draft because we want this MR to serve as common ground to discuss supporting this feature in other backends as well, specifically Asterius (cc @TerrorJack), and with everyone else of course :)

Edited Mar 22, 2022 by doyougnu
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: wip/JavaScript-value-primtype