Skip to content

Make sbrk() compatible with 2GB+ heaps - #10600

Merged
kripken merged 2 commits into
masterfrom
sbrk
Mar 3, 2020
Merged

kripken merged 2 commits into
masterfrom
sbrk

Conversation

@kripken

@kripken kripken commented Feb 28, 2020

Copy link
Copy Markdown
Member

This just removes the restriction. The check was not actually
necessary before as we check this when growing memory anyhow.

Turns out this save some code size.

Also rename a parameter that had a misleading name which
I noticed while doing this.

This is part of a set of 3+ PRs for #6566

@kripken
kripken merged commit 552b3b7 into master Mar 3, 2020
@kripken
kripken deleted the sbrk branch March 3, 2020 19:19
kripken added a commit that referenced this pull request Mar 26, 2020
…10601)

To support that mode add a JS optimizer pass that fixes up
pointers in JS libraries. Doing this as a pass is nice because
our JS libraries can still be written with signed pointers,
which is smaller and may be faster on some VMs (signed
values fit in 31-bit smis). This will fix up user code as well,
automatically.

The pass looks for HEAP8 etc. symbols on which we do
HEAP8[something] and ensures the pointer is unsigned. It
also fixes up .set() and other calls that receive pointers.

One compromise the pass makes is that it looks not just
for the canonical HEAP8 etc. names but also HEAP and
heap. Those are used in our JS library code a bunch, so
fixing those up too prevents a lot more work in that code, and
can help user code too. There is some risk to doing so, if
a user has code with that name but actually doesn't want
the unsigning; however, the risk is small (we just force their
indexes on an array to be non-negative; likely they don't
want that anyhow!), and I think the reverse risk (a user has
code that should be changed, but forgets) is much more
likely, so this seems safest. A later PR will add our JS library
fixes, which will show that even with this extension there is
still code that must be handled manually, so I think it's best
to do as much automatically as we can.

This also changes MAXIMUM_MEMORY to be 2GB. That
is effectively no change from the previous -1 (no limit)
since 2GB was the absolute limit anyhow. This has two benefits:
first, people must opt-in explicitly to getting 2GB+ heap support
with the code size downside, and also we expect only some
browsers will support 2GB+ heaps for now, so requiring explicit
opt-in from devs is safer to avoid web compat issues (i.e., only
users that really need such heaps will set them, and then they
may only work in some browsers, but at least that won't happen
for users that could actually run in all browsers).

Note that emmalloc is not designed to work with 2GB+ heaps,
so show a useful error in that case. This is a minor breaking
change for users in that building with emmalloc + memory growth
will hit the error, forcing the user to set a maximum to the growth.

This is part of a set of 3+ PRs for #6566, together with #10600
kripken added a commit that referenced this pull request Mar 26, 2020
Almost all of these are behind the new flag, but a handful would
require annoying refactoring, so I just use >>> for those.

This is part of a set of 3+ PRs for #6566, together with #10600, #10601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants