Giter Site home page Giter Site logo

ghcjs / shims Goto Github PK

View Code? Open in Web Editor NEW
21.0 14.0 29.0 6.61 MB

GHCJS runtime system and JavaScript support code for packages - deprecated as of GHC 8.2

HTML 6.63% Python 0.36% Emacs Lisp 0.01% Shell 0.01% CSS 0.55% JavaScript 92.37% Haskell 0.07%

shims's People

Contributors

bergey avatar bitonic avatar halfwayman avatar hamishmack avatar kfigiela avatar lierdakil avatar luite avatar mgsloan avatar mmhelloworld avatar mtolly avatar osa1 avatar tolysz avatar werehamster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shims's Issues

remove hardcoding of closure layout

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.

Importing a Happy-generated parser causes crash due to a `fixme`

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

throw "string arg";

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

where to run finalizers

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.

catch missing foreign functions earlier

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:

  • Keep track of all ccall imports per module, save a list in the .js_o file
  • When linking shims, build a list of supplied symbols for each .js file (keep these in a cache)
  • Print a warning about all missing symbols
  • Add flag to avoid printing these warnings

Limitations:

  • Works only per module, not per package (I don't think this is a problem, although it makes it harder to check that everything in a package is shimmed)
  • Either limited to some particular styles of declarations (since accurately detecting top-level symbols provided would require running the code), or requires some extra annotation syntax to indicated what symbols are supplied

`h$processConstants` is divided in subobjects, but used as if it conains constants directly

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.

Function.apply stack limit

JavaScriptCore has a 64k argument limit for Function.apply, review the libs to find situations where this may lead to problems.

Bug in MVar reachability

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).

Variadic macros cause problems with cpphs

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?

reserved keyword `final` used as variable name in `typedarray.js`

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)

Error: h$runSyncAction: h$reschedule expected

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?

Use TypeScript

The usefulness of a static type system should be obvious.

Timezones getting wrong offset minutes

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.