ghcjs / shims Goto Github PK
View Code? Open in Web Editor NEWGHCJS runtime system and JavaScript support code for packages - deprecated as of GHC 8.2
GHCJS runtime system and JavaScript support code for packages - deprecated as of GHC 8.2
currently, lots of the code in here accesses closures directly, for example x.d1
, x.d2.d1
, we should change this to preprocessor macro's or similar, so we can still change the internal structure of closures.
new version of the text package requires this, implement it
I get a JS exception when I run a program that includes a Happy-generated parser, even if I don't call the parse function. Here's a short Parse.y to test:
{
module Parse (parse) where
}
%name parse
%tokentype { Bool }
%error { parseError }
%token
t { True }
f { False }
%%
int :: { Integer }
: { 0 }
| int t { 2 * $1 + 1 }
| int f { 2 * $1 }
{
parseError :: [Bool] -> a
parseError _ = error "Parse error"
}
And Main.hs:
module Main where
import Parse
main :: IO ()
main = print "ok!"
When I run this in Node I get:
/Users/mtolly/git/jshappy/dist/build/jshappy/jshappy.jsexe/all.js:5431
throw "string arg";
which appears to be from
Line 254 in 6ada4bf
I just installed a fresh GHCJS and I'm using the current Happy (1.19.5).
Here's the full Parse.hs generated by Happy: http://pastebin.com/ezVrjyNU
they added a bunch, support them
Causes cash in RTS when one tries to use syncCallback3
.
When I run GHCJS.Foreign.releaseAll
from ghcjs-base
:
uncaught exception in Haskell main thread: ReferenceError: Can't find variable: h$releaseAll
I assume it's supposed to be defined somewhere around https://github.com/ghcjs/shims/blob/5e11d33cb74f8522efca0ace8365c0dc994b10f6/src/mem.js#L1104-1128
when running finalizers for weak references, the garbage collector spawns a new thread every time it has finalizers to run, which means that finalizers can be run out of order (where finalizers from a later collection get run first).
should we run all finalizers in a single thread? (which should probably have some queue (MVar?) where it gets all the finalizers from.
currently when some package has ccall
imports that are not implemented in shims, GHCJS does not complain about any missing imports, but you get a runtime exception about undefined symbols, this is not a great user experience (especially since there are so many packages out there, and it's often unclear which packages use foreign code)
Proposal:
ccall
imports per module, save a list in the .js_o
file.js
file (keep these in a cache)Limitations:
On node v6.3.0 process['binding']('constants')
returns object that contains subobjects that in turn contain actual constants. But in code it is used as if it directly contained these constants. For example here https://github.com/ghcjs/shims/blob/master/pkg/base.js#L152.
It makes impossible opening files with any flags, which leads for example to build errors in build scripts that use openBinaryTempFileWithDefaultPermissions
.
JavaScriptCore has a 64k argument limit for Function.apply
, review the libs to find situations where this may lead to problems.
Arises form Data.Time.LocalTime.getZonedTime
uncaught exception in Haskell main thread: ReferenceError: h$get_current_timezone_seconds is not defined
The thread-ring
benchmark from the shootout will kill threads because the GHCJS RTS thinks that some MVars are unreachable, even though they clearly aren't (although it can require traversing a whole bunch of threads to find one).
I ran into a
setErrno not yet implemented: Error: ENOSPC, write
javascript exception...
I guess a new case along the lines of
if(es.indexOf('ENOSPC') !== -1) return CONST_ENOSPC;
in
Line 34 in 9b196ff
h$errorStrs
-mapping) addresses this?It seems that the variadic macros used in some of the shims cause... issues... with cpphs. Demonstration of the problem:
mithrandi@verdant /tmp> cpphs --cpp -P -C foo -o bar
mithrandi@verdant /tmp> cat foo
#define FOO(args...) f(args)
FOO(1)
FOO(1, 2)
FOO(1, 2, 3)
mithrandi@verdant /tmp> cat bar
FOO(1)
f(1)
FOO(1, 2, 3)
The good news is that there seem to be very few invocations of these macros that actually pass multiple arguments, so I think it should be fairly easy to make these macros non-variadic, which would avoid the problem. Would this be a reasonable solution?
See https://github.com/ghcjs/shims/blob/improved-base/lib/typedarray/typedarray.js
Here's what ccjs typedarray.js
complains:
typedarray.js:468: ERROR - Parse error. identifier is a reserved word
var final;
^
typedarray.js:470: ERROR - Parse error. identifier is a reserved word
final = max(len + relativeEnd, 0);
^
typedarray.js:472: ERROR - Parse error. identifier is a reserved word
final = min(relativeEnd, len);
^
typedarray.js:473: ERROR - Parse error. identifier is a reserved word
var count = min(final - from, len - to);
^
typedarray.js:528: ERROR - Parse error. identifier is a reserved word
var final;
^
typedarray.js:530: ERROR - Parse error. identifier is a reserved word
final = max((len + relativeEnd), 0);
^
typedarray.js:532: ERROR - Parse error. identifier is a reserved word
final = min(relativeEnd, len);
^
typedarray.js:533: ERROR - Parse error. identifier is a reserved word
while (k < final) {
^
typedarray.js:802: ERROR - Parse error. identifier is a reserved word
var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len);
^
typedarray.js:803: ERROR - Parse error. identifier is a reserved word
var count = final - k;
^
typedarray.js:807: ERROR - Parse error. identifier is a reserved word
while (k < final) {
^
11 error(s), 0 warning(s)
Websocket communication by ghcjs-generated code sometimes fails in the browser (firefox), giving:
Error: h$runSyncAction: h$reschedule expected
.
Any idea what is wrong here? This happens consistently for a given communication pattern, while other instances of websocket communication work fine.
This is with latest ghcjs from github.
The same error apparently surfaced before for someone else: see here. Maybe the fix applied then did not fix my particular case?
The usefulness of a static type system should be obvious.
There is a bug in the shim for getting timezone offset.
I created a pull request to fix it:
#33
but the build is failing with some kind of timeout on a job, can I help this in any way?
Martin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.