syg's comments

syg | 1 year ago | on: Proposal: JavaScript Structs

Only if your implementation holds doubles without boxing them. V8 boxes doubles, but JSC and SpiderMonkey do not.

syg | 1 year ago | on: Proposal: JavaScript Structs

To be more precise, aligned to whatever size such that you can guarantee field writes that don't tear. Pointer-aligned is a safe bet. 4-byte aligned should be okay too on 64bit architectures if you use pointer compression like V8 does.

What kind of types did you have in mind? Machine integers and "any" (i.e., a JS primitive or object)?

And yes, in browsers this will be gated by cross-origin isolation.

syg | 1 year ago | on: Proposal: JavaScript Structs

The ability to do unordered operations on shared memory is important in general to write performant multithreaded code. On x86, which is very close to sequentially consistent by default (it has something called TSO, not SC), there is less of a delta. But the world seems to be moving towards architectures with weaker memory models, in particular ARM, where the performance difference between ordinary operations and sequentially consistent operations is much larger.

For example, if you're protecting the internal state of some data structure with a mutex, the mutex lock and unlock operations are what ensures ordering and visibility of your memory writes. In the critical section, you don't need to do atomic, sequentially consistent accesses. Doing so has no additional safety and only introduces performance overhead, which can be significant on certain architectures.

syg | 1 year ago | on: Proposal: JavaScript Structs

Author here. I hear your feedback about unsafe blocks. Similar sentiment is shared by other delegates of the JS standards committee.

The main reason it is there today is to satisfy some delegates' requirement that we build in guardrails so as to naturally discourage authors from creating thread-unsafe public APIs and libraries by default. We're exploring other ideas to try to satisfy that requirement without unsafe blocks.

syg | 8 years ago | on: Towards a JavaScript Binary AST

Indeed it's a semantic change. Are you saying you'd like that change to be proposed separately? That can't be done for the text format for the obvious compat reasons. It also has very little value on its own, as it is only one of many things that prevents actually skipping inner functions during parsing.

syg | 8 years ago | on: Towards a JavaScript Binary AST

Early error behavior is proposed to be deferred (i.e. made lazy), not skipped. Additionally, it is one of many things that require frontends to look at every character of the source.

I contend that the text format for JS is no way easy to implement or extend, though I can only offer my personal experience as an engine hacker.

syg | 8 years ago | on: Towards a JavaScript Binary AST

The gzip point aside (which is not an apples-to-apples comparison as gzipping a big source does not diminish its parse time), I see the response of "JS devs need to stop shipping so much JS" often. My issue with this response is that multiple parties are all trying to work towards making JS apps load faster and run faster. It is easy enough to say "developers should do better", but that can be an umbrella response to any source of performance issues.

The browser and platform vendors do not have the luxury of fiat: they cannot will away the size of modern JS apps simply because they are causing slowdown. There can be engineering advocacy, to be sure, but that certainly shouldn't preclude those vendors from attempting technical solutions.

syg | 8 years ago | on: Towards a JavaScript Binary AST

This is important, as there seems to be a lot of misunderstanding in this thread.

What's proposed is structural compression of JS with JS-specific bits to speed things up even more. What's proposed is not compiled JS, in that the original JS is not meaningfully transformed at all. There is a very explicit design goal to retain the original syntactic structure.

OTOH WebAssembly is like a new low-level ISA accessible from web browsers. To use wasm, one does have to compile to it. As the parent here says, compiling JS -> wasm currently requires at least a GC but also much more. To engineer a performant VM and runtime for a dynamic programming language like JS is a time-consuming thing. It is curious to see so many folks think that JS can straightforwardly be compiled to wasm. Currently wasm and JS serve very different needs; and I also don't think JS will be going anywhere for many, many years.

Edit: formatting

syg | 9 years ago | on: A Simple Request: VLC.js

The current draft is available at http://tc39.github.io/ecmascript_sharedmem/shmem.html

The two strengths provided by the model are sequentially consistent atomics and something between the strengths of C++'s non-atomics and relaxed atomics. Races are fully defined, and there is no undefined behavior or undefined values.

I'm happy to discuss things more in a new thread or in private communication and would prefer to not derail this thread about VLC.

syg | 9 years ago | on: A Simple Request: VLC.js

Shu here. I'm the person drafting the memory model for the SharedArrayBuffer spec, and as Dave says, it'll be the basis for the wasm story as well.

Lars Hansen deserves most of the credit for the actual spec -- I'm just doing the memory model. :)

syg | 11 years ago | on: Show HN: Fast.js – faster reimplementations of native JavaScript functions

The slowness of functional methods like .map and .forEach for a time was due to their not being self-hosted. Since then, both V8 and SpiderMonkey self-host them, and bz has posted some numbers below [1].

But perf problems are more numerous still for these functional methods, because compilers in general have trouble inlining closures, especially for very polymorphic callsites like calls to the callback passed in via .map or .forEach. For an account of what's going on in SpiderMonkey, I wrote an explanation about a year ago [2]. Unfortunately, the problems still persist today.

[1] https://news.ycombinator.com/item?id=7938101 [2] http://rfrn.org/~shu/2013/03/20/two-reasons-functional-style...

syg | 13 years ago | on: Shumway: a SWF interpreter entirely in JavaScript

To be more precise, JITs on top of JITs. :)

We have both an interpreter for ActionScript bytecode as well as a compiler that compiles that bytecode method-at-a-time to JavaScript using a restructuring approach like emscripten's relooper.

Disclaimer: I work on Shumway.

syg | 14 years ago | on: *JS : Low-Level JavaScript

There's a CoffeeScript dialect with those features for use optionally. It also emits the typed array-style of JS code, though.
page 1