[gambit-list] How JS backend GC:s?

Mikael mikael.rcv at gmail.com
Sat May 10 04:30:40 EDT 2014


Aha, awesome.

For the sake of practical overview on this environment, to get a grasp of
what it's like and how it behaves:


   1. What about Gambit's globals, are they JS variable references i.e.
   within JS' variable namespace, or does G. implement an internal by itself?

   Is there any overlapping of [global] variable namespaces with JS?

   For instance, refering to a global ABC in the Scheme code, what JS
   variable would that refer to.

   2. How would you export a function from Scheme for ordinary JS to be
   able to call it, by some name?

   Must any particular condition be met for a call from JS to Scm-JS code
   to be 'safe'?

   3. To get and set JS-native hashtable values aka JS object properties
   from Scheme, how do you do that?

   The keys would either be static (e.g. objectvariable.thisstaticname =
   newvalue;), or dynamic (e.g. var itsvalue =
   objectvariable[dynamickeyvalue];).

   4. Invoking a JS-native function would be just as an ordinary Scheme
   function i.e. (functionvalue) right ?

   5. May you be about to implement more sophisticated Scheme functionality
   / runtime such as (in descending order of usefulness)

   1. The numeric tower? (at least the basic typehandling for the op and
      its storage format, someone else could fill in the actual procedures)

      2. Ports?

      3. Real hashtable? (i.e. implement its own make-tabe + accessors, or,
      would your take on this partiuclar one be that one would be equally well
      off using some ordinary JS library for it)

      4. U8vector?

      6. Would there be any native access to JS' language features:

   1. object instanation form i.e.  new X(args);

      2. inline object creation form e.g. {key1: value1, key2: value2} etc

      3. regexps i.e. /regex here/

      ?


Thanks!
Mikael


2014-05-06 23:46 GMT+02:00 Marc Feeley <feeley at iro.umontreal.ca>:

>
> On May 6, 2014, at 5:40 PM, Mikael <mikael.rcv at gmail.com> wrote:
>
> >
> >
> >
> > 2014-05-06 23:32 GMT+02:00 Marc Feeley <feeley at iro.umontreal.ca>:
> >
> > On May 6, 2014, at 4:22 PM, Mikael <mikael.rcv at gmail.com> wrote:
> >
> > > Dear Marc,
> > >
> > > Just curious, Gambit's JS backend, it uses the JS VM:s GC right -
> > >
> > > How do you make the SCM to JS object mapping deliver that?
> > >
> > > I mean, say, a cons cell, a vector, a closure, a firstclass
> continuation and a stack frame, about how are those mapped to JS objects as
> for the JS VM to be able to GC them just as it does with ordinary values?
> > >
> > >  - Gambit uses numbers for object references ordinarily, so I guess
> the object mapping has been done deeper than that, so that actual JS object
> references are used as SCM object references by the JS backend.
> >
> > Scheme objects are mapped to JS objects.  So a pair is an instance of
> the "class" Gambit_Pair, and a vector is an instance of the class
> Gambit_Vector.  Scheme closures are JS closures.  A Scheme continuation is
> a chain of frames (each frame is a JS array).  So everything is garbage
> collectible by the JS GC.
> >
> > There is a bit of fanciness in how the continuations are created.  The
> Scheme stack is an extensible array and stack frames are allocated in this
> array contiguously.  When a continuation is captured the stack is emptied
> and each frame becomes an independent JS array.
> >
> > Aha. And then, when one stack frame (JS  array) refers to another stack
> frame (JS array), then this is done by the means of an actual object
> reference?
> >
> > E.g.
> >
> > var frame1 = [value, value ...... ];
> >
> > var frame2 [value, ........ frame1, ...];
> >
>
> Exactly.
>
> The details of how the chain of frames is created when the continuation is
> captured are given in the paper "
> http://users-cs.au.dk/danvy/sfp12/papers/thivierge-feeley-paper-sfp12.pdf
> ".
>
> Marc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20140510/e0c9c01b/attachment.htm>


More information about the Gambit-list mailing list