Repository navigation
Conversation
| // sections. | ||
| // This has no effect if DWARF is not being emitted. | ||
| var SEPARATE_DWARF = 0; | ||
| var SEPARATE_DWARF = 0; No newline at end of file |
There was a problem hiding this comment.
Oh, isn't this what @sbc100 prefers - no extra newline at the end?
There was a problem hiding this comment.
#10478 (comment) was a recent conversation around that
There was a problem hiding this comment.
Ah.. now I'm confused... but I'll remove this change 😄
|
Hmm, I am a bit torn on this, like I was on the other PR. It feels to me that this is fixing in the wrong place, but rather we should be fixing the inputs we get from wasm so that all the numbers have the right value in JS throughout. If we wanted to do an acorn pass, I'd rather have a pass that turns function requireUnsignedPointer(x) {
if (x < 0) abort('x should be an unsigned pointer!');
return x;
}that would prompt the actual code to be fixed so that values received from wasm are treated appropriately. That would avoid redundant shifts, e.g. in function _emscripten_webgl_do_create_context(target, attributes) {
var contextAttributes = {};
var a = attributes >> 2;
contextAttributes["alpha"] = !!HEAP32[a];
contextAttributes["depth"] = !!HEAP32[a + 1];
contextAttributes["stencil"] = !!HEAP32[a + 2];
contextAttributes["antialias"] = !!HEAP32[a + 3];
contextAttributes["premultipliedAlpha"] = !!HEAP32[a + 4];
contextAttributes["preserveDrawingBuffer"] = !!HEAP32[a + 5];
var powerPreference = HEAP32[a + 6];
contextAttributes["powerPreference"] = __emscripten_webgl_power_preferences[powerPreference];
contextAttributes["failIfMajorPerformanceCaveat"] = !!HEAP32[a + 7];
contextAttributes.majorVersion = HEAP32[a + 8];
contextAttributes.minorVersion = HEAP32[a + 9];
contextAttributes.enableExtensionsByDefault = HEAP32[a + 10];
contextAttributes.explicitSwapControl = HEAP32[a + 11];
contextAttributes.proxyContextToMainThread = HEAP32[a + 12];
contextAttributes.renderViaOffscreenBackBuffer = HEAP32[a + 13];one could have I think it is ok to land this, but it does feel like a temporary solution. Sidenote: I can look at making emmalloc support 4GB, that will not be a big change. Btw, which shells/browsers currently support 4GB addressing? |
The only thing we can maybe avoid is if there wasn't a shift at all earlier - good point there. But otherwise, we tend to have
Ah, good idea! Yeah, I can look into extending Overall, yeah, I see your point about avoiding extra casts later, as in your example. I suggest we leave that to further optimization, together with the SAFE_HEAP stuff - I'd like to land this first (and the dependent PR) to get any 2GB+ support working at all.
That might be nice, but if it increases emmalloc's size, it might not be worth it - I imagine the apps that want 2GB+ heaps are rare, and tend to be large, where emmalloc isn't a big help anyhow percentage wise.
V8 just landed this support about a week ago in trunk. It appears to work great! I know others are working on it, but there is no support outside of V8 AFAIK. |
|
Thinking some more on this, I had an idea: let's change
On the other hand, I did some more thinking about the Note how the shift goes away, replaced by In other words, >2GB heaps is the first time we care about the sign of pointers, and SAFE_HEAP isn't designed for that. We may need some other tool there, let's keep thinking about that separately from this PR. (Btw, another idea is to allow manual JS library code which shifts once and not later, and we can disable automatic But in any case, given the first part of this comment, I'm not that worried about code size myself: if we only add a little size to builds the user explicitly asked for >2GB heaps, that's likely ok as those builds are probably big applications anyhow. |
| shutil.copyfile(path_from_root('tests', 'screenshot.jpg'), 'screenshot.jpg') | ||
| Building.emcc(path_from_root('tests', 'jpeg_test.c'), ['--embed-file', 'screenshot.jpg', '-s', 'USE_LIBJPEG=1'], output_filename='a.out.js') | ||
| self.assertContained('Image is 600 by 450 with 3 components', run_process(JS_ENGINES[0] + ['a.out.js', 'screenshot.jpg'], stdout=PIPE, stderr=PIPE).stdout) | ||
| self.assertContained('Image is 600 by 450 with 3 components', run_js('a.out.js', args=['screenshot.jpg'], stdout=PIPE, stderr=PIPE)) |
There was a problem hiding this comment.
It's just a tiny cleanup/simplification I noticed while working on this.
It was previously possible for MAXIMUM_MEMORY to be set to -1. In fact it was the default. However since #10601, it is no longer the default and there is no way to set it to -1. Also, error out if MAXIMUM_MEMORY is specified without ALLOW_MEMORY_GROWTH.
It was previously possible for MAXIMUM_MEMORY to be set to -1. In fact it was the default. However since #10601, it is no longer the default and there is no way to set it to -1. Also, error out if MAXIMUM_MEMORY is specified without ALLOW_MEMORY_GROWTH.
It was previously possible for MAXIMUM_MEMORY to be set to -1. In fact it was the default. However since #10601, it is no longer the default and there is no way to set it to -1.
This test was originally used to test emmalloc for its initial limitations when it was added back in emscripten-core#10601. However, not it seems to basically do nothing. We have test_emmalloc in test core which runs in 2gb and 4gb modes and actually test allocations in the high region. This test just runs hello world and doesn't actually test any allocations.
This test was originally used to test emmalloc for its initial limitations when it was added back in #10601. However, not it seems to basically do nothing. We have test_emmalloc in test core which runs in 2gb and 4gb modes and actually test allocations in the high region. This test just runs hello world and doesn't actually test any allocations.
This test was originally used to test emmalloc for its initial limitations when it was added back in emscripten-core#10601. However, not it seems to basically do nothing. We have test_emmalloc in test core which runs in 2gb and 4gb modes and actually test allocations in the high region. This test just runs hello world and doesn't actually test any allocations.
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
HEAP8etc. symbols on which we doHEAP8[something]and ensures the pointer is unsigned. Italso fixes up
.set()and other calls that receive pointers.One compromise the pass makes is that it looks not just
for the canonical
HEAP8etc. names but alsoHEAPandheap. Those are used in our JS library code a bunch, sofixing 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_MEMORYto be 2GB. Thatis 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