you know what's funny? VBScript had static/fixed classes and immutable
objects in 1999 and goddammit nobody ever thought that was cool!

I've also proposed [static/fixed/frozen classes](
https://code.google.com/p/vbclass/) a while ago and also asked why
`Object.freeze({})` makes the object slower, instead of faster, to deal
with, as it would/could be a `prototype` and maybe marked as static ...

In another recent thread I was (wrongly) asking about CTypes meaning binary
data where developers can devine their own static shapes "C struct like"
and apparently this is still an ES6 thing.

Interesting time in this "new" JS era ... :-)




On Sat, Jul 13, 2013 at 2:02 AM, Brian Di Palma <[email protected]> wrote:

> OK. So we have reached "Peak JavaScript" then.
>
> If people write JS code without triggering shape changes then the JIT
> should be able to produce code that can match a JVM?
> If there was something that I could do as a developer that could help
> the JIT I would do it.
>
> Would ES6 classes not make the creation of shapes a lot easier? From
> what I understand it takes time to figure out shapes/hidden-classes.
> Well I'm marking this object as a class, does that help?
>
> It would be interesting if engines provided feedback on when we
> developers break the optimistic optimizations.
>
> On Sat, Jul 13, 2013 at 9:43 AM, David Bruant <[email protected]> wrote:
> > Le 13/07/2013 10:21, Brian Di Palma a écrit :
> >
> >> I was just wondering
> >> if the 'const' keyword would help give JS another small performance
> >> boost.
> >
> > Unlikely. Const can be almost statically inferred (no assignment to a
> given
> > variable). The "almost" refers to cases where eval happens. Worst case,
> if
> > there is no assignment, a variable can be optimistically optimized as
> const.
> > If the value is changed via eval, then de-optimize (but in practice,
> eval is
> > rare, so the optimistic optimization will be worth it)
> >
> >
> >> As Andreas points out the major issue is that JS is highly dynamic,
> >> this can be very useful sometimes but for most code it's not required.
> >> Maybe if you mark everything as const or freeze/seal classes then
> >> maybe JS engines will optimize for that code.
> >
> > JS engines already optimistically optimize assuming code remains stable
> (for
> > objects, V8 has "hidden classes", SpiderMonkey has the equivalent "shape"
> > feature) and deoptimizes when the dynamic features are being used.
> >
> > It might be one of the reason why maps are better at being maps than
> objects
> > (since objects seem to have been optimized for cases where they are
> stable)
> >
> > David
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to