Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reinier Maas
GHC
Commits
17e309d2
Commit
17e309d2
authored
1 year ago
by
John Ericson
Committed by
Marge Bot
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix reST in users guide
It appears that
aef587f6
wasn't valid syntax.
parent
486979b0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/users_guide/javascript.rst
+8
-5
8 additions, 5 deletions
docs/users_guide/javascript.rst
with
8 additions
and
5 deletions
docs/users_guide/javascript.rst
+
8
−
5
View file @
17e309d2
...
...
@@ -157,7 +157,7 @@ passed as an ``Int`` to a ``Callback`` that accepts a ``JSVal``:
releaseCallback add3
Callbacks as Foreign Exports
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
JavaScript callbacks allow for a sort of FFI exports via FFI imports. To do
this, a global JavaScript variable is set, and that global variable can then
...
...
@@ -331,7 +331,7 @@ Next, the JavaScript ``h$getcwd`` function demonstrates several details:
in the error case.
Writing JavaScript Functions to be NodeJS and Browser Aware
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In the above example of implementing ``getcwd``, the function we use in the JavaScript
implementation is from NodeJS, and the behaviour doesn't make sense to implement in a
...
...
@@ -434,7 +434,7 @@ C functions compiled with Emscripten get a "_" prepended to their name in
JavaScript. For example, C "malloc" becomes "_malloc" in JavaScript.
EMCC pragmas
~~~~~~~~~~~~
^^^^^^^^^^^^
By default the EMCC linker drops code considered dead and it has no way to know
which code is alive due to some call from Haskell or from a JavaScript wrapper.
...
...
@@ -470,16 +470,19 @@ passed once; the latter argument overrides the former ones).
This pragma allows additional options to be passed to Emscripten if need be. We
already pass:
- `-sSINGLE_FILE=1`: required to create a single `.js` file as artefact
(otherwise `.wasm` files corresponding to C codes need to be present in the
current working directory when invoking the resulting `.js` file).
- `-sALLOW_TABLE_GROWTH`: required to support `addFunction`
- `-sEXPORTED_RUNTIME_METHODS` and `-sEXPORTED_FUNCTIONS`: see above.
Be careful because some extra arguments may break the build in unsuspected ways.
Wrappers
~~~~~~~~
^^^^^^^^
The JavaScript backend doesn't generate wrappers for foreign imports to call
directly into the compiled C code. I.e. given the following foreign import:
...
...
@@ -513,7 +516,7 @@ GHC's JavaScript rts provides helper functions for this in `rts/js/mem.js`. See
`h$copyFromHeap`, `h$copyToHeap`, `h$initHeapBuffer`, etc.
Callbacks
~~~~~~~~~
^^^^^^^^^
Some C functions take function pointers as arguments (e.g. callbacks). This is
supported by the JavaScript backend but requires some work from the wrapper
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment