threads icon indicating copy to clipboard operation
threads copied to clipboard

Rename WebAssembly.Global to something

Open titzer opened this issue 8 years ago • 20 comments

If a WebAssembly.Global represents what is, in effect, a thread-local variable, then it needs a better name. This is of course due to there being just one "thread" associated with a JavaScript context.

E.g. what about WebAssembly.Variable for a JS name?

We could as well rename the opcode (without changing its encoding), and there'd be no breaking change, other than to the text format.

titzer avatar Jul 18 '17 00:07 titzer

Yes, we discussed this at the last CG meeting and agreed that the name should change. Sorry that I forgot about this.

I'm OK with Variable. I think we were calling them ThreadLocal in the meeting, but that was just to make it clear that they aren't actually global across threads.

binji avatar Jul 18 '17 00:07 binji

"Variable" strikes me as a bit too unspecific. I'd prefer "XYGlobal", for some nice choice of XY (so that we leave the door open to also add YZGlobals of the non-TLS variety).

rossberg avatar Jul 18 '17 02:07 rossberg

So the only reason that WebAssembly.Global is effectively thread-local is b/c it can't be shared between threads. But I think at some point in the future we could make Global shreable (in the same way as Memorym w/ a flag) and then it would be truly global.

lukewagner avatar Jul 18 '17 16:07 lukewagner

But would we want to make a distinction between globals that are actually thread-local and globals that can be shared?

binji avatar Jul 18 '17 16:07 binji

@lukewagner which is why I think it shouldn't include its scope in its name, since its scope depends on its usage.

titzer avatar Jul 18 '17 18:07 titzer

@titzer, but the "global" refers to the lexical scope (as opposed to locals). Per-threadness is a different dimension.

rossberg avatar Jul 18 '17 18:07 rossberg

Sorry, I didn't mean "scope" in the PL sense, should have used a different term. "Accessibility" is closer to what I meant.

titzer avatar Jul 18 '17 20:07 titzer

Agree with @rossberg-chromium, I read "global" as w.r.t the module, and sharing between instances and/or threads is orthogonal.

lukewagner avatar Jul 18 '17 21:07 lukewagner

On the other hand, "thread local" is a commonly-used term, so it'd be odd to use a WebAssembly.Global as thread-local storage.

titzer avatar Jul 18 '17 21:07 titzer

No ThreadLocalGlobal then? :) How about PerThreadGlobal?

rossberg avatar Jul 18 '17 22:07 rossberg

Is a wasm runtime Module the unit of threading or can multiple of them belong to the same thread? Note: I specifically using "wasm runtime Mdoule" to differentiate using a linker to combile "wasm Modules" at compile time into a single "wasm runtime Module", I hope that makes sense?

On Tue, Jul 18, 2017 at 3:07 PM rossberg-chromium [email protected] wrote:

No ThreadLocalGlobal then? :) How about PerThreadGlobal?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/WebAssembly/threads/issues/49#issuecomment-316212628, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-hHGMqUCnNAaLuldkWF1RH7Qj5gUz7ks5sPSy3gaJpZM4OasD_ .

winksaville avatar Jul 18 '17 23:07 winksaville

@winksaville, I suppose you mean a module instance?

If I understand your question correctly, then no, threads are orthogonal to module boundaries.

rossberg avatar Jul 18 '17 23:07 rossberg

I always thought globals were scoped to the instance, not the thread. This distinction matters for non-JS implementations, where shared-memory threading can be a platform feature that WebAssembly gets for free.

RyanLamansky avatar Jul 19 '17 12:07 RyanLamansky

We discussed this briefly at the CG meeting, but came to the conclusion that further bikeshedding should happen on the GH issue. :-}

binji avatar Jul 25 '17 22:07 binji

@binji, any more bikeshedding from anyone?

The name 'global' is embedded pretty deeply elsewhere (text format, binary spec). IMO if we don't want WebAssembly.Global we should be prepared to fix those occurences too.

(I ask because I'm starting to implement this, and I'd prefer not to get into a situation where I have to do a massive renaming later...)

lars-t-hansen avatar Nov 22 '17 15:11 lars-t-hansen

I haven't heard any, but maybe now that you've poked this thread there will be some more... :-)

I got the impression that folks were not happy with the name Global but disliked everything else more.

binji avatar Nov 22 '17 16:11 binji

In the case of tables, memories and functions, the JS reflection's name matches the wasm core concept's name, so I really think we should stay consistent here and not invent something special.

lukewagner avatar Nov 22 '17 16:11 lukewagner

We polled this in the Nov 28 CG meeting. I'll update with the specific numbers when I have them, but the consensus was to stay with WebAssembly.Global.

binji avatar Nov 28 '17 18:11 binji

As I mentioned at meeting, there is also (non-cross-realm) global proposal to ECMAScript. It's on stage 3 now and it's blocked by some compatibility issues:

  • https://bugzilla.mozilla.org/show_bug.cgi?id=1325907
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1326032
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1328218
  • https://bugs.webkit.org/show_bug.cgi?id=165171

If this proposal will land we'll have global.WebAssembly.Global name which looks weird (it's not necessary to add global. prefix though). I think we should discuss WebAssembly.Global name with TC39.

chicoxyzzy avatar Nov 28 '17 18:11 chicoxyzzy

@chicoxyzzy, global as the standard name for the global object has been ruled out by TC39, because it would conflict with existing code. Either way, I don't think there would be any confusion.

rossberg avatar Nov 29 '17 09:11 rossberg