Why is the memory ArrayBuffer called HEAP?

71 views
Skip to first unread message

Andrej Nosky

unread,
Oct 16, 2019, 2:32:35 PM10/16/19
to emscripten-discuss
Well, technically I get it. Because it's a heap, right? But heap only begins on certain offset, before which stack is located. In my opinion there could be more fitting name for this structure, like MEMORY8, MEMORY16 and so on. I think it's a little confusing, especially for people who care where and why data is stored.

Alon Zakai

unread,
Oct 16, 2019, 4:55:44 PM10/16/19
to emscripte...@googlegroups.com
Agreed, it isn't the best name. It could perhaps be MEM8 etc. (to keep it short).

If someone's interested to do this change, I'd be in favor of it.

On Wed, Oct 16, 2019 at 11:32 AM Andrej Nosky <andrej...@gmail.com> wrote:
Well, technically I get it. Because it's a heap, right? But heap only begins on certain offset, before which stack is located. In my opinion there could be more fitting name for this structure, like MEMORY8, MEMORY16 and so on. I think it's a little confusing, especially for people who care where and why data is stored.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/9aea0156-9464-4568-9beb-459cca5cc7fb%40googlegroups.com.

Sam Clegg

unread,
Oct 16, 2019, 10:58:25 PM10/16/19
to emscripte...@googlegroups.com
On Wed, Oct 16, 2019 at 1:55 PM Alon Zakai <alon...@gmail.com> wrote:
>
> Agreed, it isn't the best name. It could perhaps be MEM8 etc. (to keep it short).
>
> If someone's interested to do this change, I'd be in favor of it.

Isn't there at lot code out there in the wild that would be broken by
such as change?

>
> On Wed, Oct 16, 2019 at 11:32 AM Andrej Nosky <andrej...@gmail.com> wrote:
>>
>> Well, technically I get it. Because it's a heap, right? But heap only begins on certain offset, before which stack is located. In my opinion there could be more fitting name for this structure, like MEMORY8, MEMORY16 and so on. I think it's a little confusing, especially for people who care where and why data is stored.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/9aea0156-9464-4568-9beb-459cca5cc7fb%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpRDSvTq6GNgBsTYj4ciNRYfk5TYOb-k-WEJZvbFj7Dcbw%40mail.gmail.com.

Alon Zakai

unread,
Oct 16, 2019, 11:15:56 PM10/16/19
to emscripte...@googlegroups.com
I think we can do

var HEAP8 = MEM8;

etc. for a while, deprecate HEAP8, then after more time make using HEAP8 throw an error saying "use MEM8". We've done similar breaking changes in the past, they do cause temporary annoyance for users, but it's easy for them to fix, and we all end up in a better state later.

- Alon


J Decker

unread,
Oct 17, 2019, 12:05:14 AM10/17/19
to emscripten-discuss
On Wed, Oct 16, 2019 at 8:15 PM Alon Zakai <alon...@gmail.com> wrote:
I think we can do

var HEAP8 = MEM8;

etc. for a while, deprecate HEAP8, then after more time make using HEAP8 throw an error saying "use MEM8". We've done similar breaking changes in the past, they do cause temporary annoyance for users, but it's easy for them to fix, and we all end up in a better state later.

Better for who?  It's not mem, it's a/the heap.  
 
- Alon


On Wed, Oct 16, 2019 at 7:58 PM 'Sam Clegg' via emscripten-discuss <emscripte...@googlegroups.com> wrote:
On Wed, Oct 16, 2019 at 1:55 PM Alon Zakai <alon...@gmail.com> wrote:
>
> Agreed, it isn't the best name. It could perhaps be MEM8 etc. (to keep it short).
>
> If someone's interested to do this change, I'd be in favor of it.

Isn't there at lot code out there in the wild that would be broken by
such as change?

>
> On Wed, Oct 16, 2019 at 11:32 AM Andrej Nosky <andrej...@gmail.com> wrote:
>>
>> Well, technically I get it. Because it's a heap, right? But heap only begins on certain offset, before which stack is located. In my opinion there could be more fitting name for this structure, like MEMORY8, MEMORY16 and so on. I think it's a little confusing, especially for people who care where and why data is stored.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/9aea0156-9464-4568-9beb-459cca5cc7fb%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpRDSvTq6GNgBsTYj4ciNRYfk5TYOb-k-WEJZvbFj7Dcbw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29R3YSPGrHN01JD2ugA7BqyaE_wtZTKvM6UtAN8AD1xQw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Andrej Nosky

unread,
Oct 17, 2019, 2:27:51 AM10/17/19
to emscripten-discuss
It's not only heap. It just contains heap along with some other stuff. Don't underestimate naming conventions.

Dňa štvrtok, 17. októbra 2019 6:05:14 UTC+2 J Decker napísal(-a):


On Wed, Oct 16, 2019 at 8:15 PM Alon Zakai <alon...@gmail.com> wrote:
I think we can do

var HEAP8 = MEM8;

etc. for a while, deprecate HEAP8, then after more time make using HEAP8 throw an error saying "use MEM8". We've done similar breaking changes in the past, they do cause temporary annoyance for users, but it's easy for them to fix, and we all end up in a better state later.

Better for who?  It's not mem, it's a/the heap.  
 
- Alon


On Wed, Oct 16, 2019 at 7:58 PM 'Sam Clegg' via emscripten-discuss <emscripte...@googlegroups.com> wrote:
On Wed, Oct 16, 2019 at 1:55 PM Alon Zakai <alon...@gmail.com> wrote:
>
> Agreed, it isn't the best name. It could perhaps be MEM8 etc. (to keep it short).
>
> If someone's interested to do this change, I'd be in favor of it.

Isn't there at lot code out there in the wild that would be broken by
such as change?

>
> On Wed, Oct 16, 2019 at 11:32 AM Andrej Nosky <andre...@gmail.com> wrote:
>>
>> Well, technically I get it. Because it's a heap, right? But heap only begins on certain offset, before which stack is located. In my opinion there could be more fitting name for this structure, like MEMORY8, MEMORY16 and so on. I think it's a little confusing, especially for people who care where and why data is stored.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/9aea0156-9464-4568-9beb-459cca5cc7fb%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpRDSvTq6GNgBsTYj4ciNRYfk5TYOb-k-WEJZvbFj7Dcbw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Floh

unread,
Oct 17, 2019, 10:51:25 AM10/17/19
to emscripten-discuss
Isn't there at lot code out there in the wild that would be broken by
such as change?

Yeah. TBH I'm not a fan of a name change even if the new name is slightly more fitting. That's one of those obscure things that suddenly breaks projects, usually at the worst possible time (even with a deprecation note and period, this stuff is usually ignored). If such a change would come with a real benefit (such as better performance, or less code maintenance in the future) I'd be all for it, but not when it's just one of the many "badly named things" in computing :)

Gabriel Cuvillier

unread,
Oct 17, 2019, 11:02:11 AM10/17/19
to emscripte...@googlegroups.com

100% agree with Floh there.     Changing such a thing is an open door to a very obscure, hard to find, and unwanted potential "project breaker", for a very minor added value...

Having to live with some minor technical debt due to badly named things is acceptable I suppose.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Beuc

unread,
Oct 17, 2019, 11:13:23 AM10/17/19
to emscripte...@googlegroups.com

While I regularly complain about unexpected/undocumented change, I think Alon's plan is pretty careful and reasonable.

Badly named variables are a perpetual mental hassle, and triggering a clear error message means the change won't be obscure.

Cheers!
Beuc

Gabriel Cuvillier

unread,
Oct 17, 2019, 11:27:17 AM10/17/19
to emscripte...@googlegroups.com

Hey, I definitively thought you'd say the opposite due to the various issues you had with unexpected changes. Well, just joking ;)

I admit I have the same issue than you: my projects often breaks on new releases of Emscripten. I have to tweak the Doom 3 port regularly (well on this project this is just for the fun. But I agree that for customers projects, moving on new versions of Emscripten is a bit more worrying). But I understand these recent breaking changes were done for good causes: the new LLVM backend, Asyncify, updates toward WASI compatibility, and so on...  as so, due to the long-term benefits of these new functionalities, I am happy with all that progress even at the price of short-term issues

Cheers,

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Jukka Jylänki

unread,
Oct 17, 2019, 12:14:11 PM10/17/19
to emscripte...@googlegroups.com
A very large big -1 in bold, in caps, if you could type a number in caps.

Very much appreciate the idea of this thread, though there are a
million things that will be invalidated in existing code all around,
not to mention references in communication threads, forum posts etc. A
"var HEAP8 = MEM8;" could cause confusion as well, and just increases
code size for no runtime benefit - one would have to remember to keep
both in track, and invalidate both to let JS engine reclaim. I think
this is very much in the bikeshedding territory.

to 17. lokak. 2019 klo 18.27 Gabriel Cuvillier
(gabriel....@gmail.com) kirjoitti:
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/4084a0ed-cc59-55c3-83e6-46660e2d1795%40gmail.com.

Andrej Nosky

unread,
Oct 17, 2019, 12:50:59 PM10/17/19
to emscripten-discuss
I would say the solution that Alon Zakai postponed is least invasive towards existing codebases. I still feel like people over here tend to underrate this problem. It's not heap and therefore we should not call it heap. Having stack variables in HEAP object is just confusing. Not to mention it takes some time to dig out the information that something like STACK_MAX exists in generated js file and it virtually splits the memory object.

Dňa štvrtok, 17. októbra 2019 18:14:11 UTC+2 jj napísal(-a):
> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/10c8a820-5a3a-d1a6-dec2-6694dd9631ea%40beuc.net.
>
> --
> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Oct 17, 2019, 1:46:14 PM10/17/19
to emscripte...@googlegroups.com
Good points on both sides here!

I'm convinced that given there isn't a tangible benefit aside from documentation, this is probably not worth pursuing at the moment.

I think eventually we may want to rethink our JS support more radically - in order to gain larger benefits like modularity and size wins - and at that time we should remember to use a better name, when it's a break point anyhow. But that's far off.

- Alon


> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/10c8a820-5a3a-d1a6-dec2-6694dd9631ea%40beuc.net.
>
> --
> You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/a8687478-2222-40b9-a358-1adfb27177e3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages