-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Initial new INITIAL_HEAP
setting
#21071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
b43181e
79bf8d7
4def2c7
5ddd199
d893b4d
79958b2
a4e3cfc
f994f46
1433dd8
c8b285e
eae41e0
3da94a8
0906505
a3786ec
3c76f5b
db45ed2
d71d239
47ec651
b443e06
0dc6457
9a885f1
d2cdd4e
a37cafe
1ce8cd6
a36cf25
d89c454
ea3b557
d688893
37eeea5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 567, | ||
"a.html.gz": 379, | ||
"a.js": 17790, | ||
"a.js.gz": 7987, | ||
"a.js": 18102, | ||
"a.js.gz": 8079, | ||
"a.mem": 3123, | ||
"a.mem.gz": 2693, | ||
"total": 21480, | ||
"total_gz": 11059 | ||
"total": 21792, | ||
"total_gz": 11151 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 567, | ||
"a.html.gz": 379, | ||
"a.js": 17263, | ||
"a.js.gz": 7819, | ||
"a.js": 17575, | ||
"a.js.gz": 7906, | ||
"a.mem": 3123, | ||
"a.mem.gz": 2693, | ||
"total": 20953, | ||
"total_gz": 10891 | ||
"total": 21265, | ||
"total_gz": 10978 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,72 @@ | ||
var c = Module, g, h, k = new TextDecoder("utf8"), l; | ||
|
||
function d(b) { | ||
this.exports = function(f) { | ||
function m(e) { | ||
e.set = function(a, n) { | ||
this[a] = n; | ||
function d(e) { | ||
this.exports = function(m) { | ||
function n(f) { | ||
f.set = function(a, p) { | ||
this[a] = p; | ||
}; | ||
e.get = function(a) { | ||
f.get = function(a) { | ||
return this[a]; | ||
}; | ||
return e; | ||
return f; | ||
} | ||
return function(e) { | ||
var a = new ArrayBuffer(16777216), n = e.a.a; | ||
e = m([]); | ||
return function(f) { | ||
var a = new ArrayBuffer(16908288), p = new Int8Array(a), r = Math.imul, t = f.a.a; | ||
f = n([]); | ||
return { | ||
b: Object.create(Object.prototype, { | ||
grow: {}, | ||
grow: { | ||
value: function(b) { | ||
var q = a.byteLength / 65536 | 0; | ||
b = q + (b | 0) | 0; | ||
q < b && 65536 > b && (b = new ArrayBuffer(r(b, 65536)), new Int8Array(b).set(p), | ||
p = new Int8Array(b), a = b); | ||
return q; | ||
} | ||
}, | ||
SingleAccretion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
buffer: { | ||
get: function() { | ||
return a; | ||
} | ||
} | ||
}), | ||
c: function() {}, | ||
d: function(p, q) { | ||
n(1024); | ||
d: function(b, q) { | ||
t(1024); | ||
return 0; | ||
}, | ||
e: e | ||
e: f | ||
}; | ||
}(f); | ||
}(b); | ||
}(m); | ||
}(e); | ||
} | ||
|
||
(function(b, f) { | ||
(function(e, m) { | ||
return { | ||
then: function(m) { | ||
m({ | ||
instance: new d(f) | ||
then: function(n) { | ||
n({ | ||
instance: new d(m) | ||
}); | ||
} | ||
}; | ||
})(c.wasm, { | ||
a: { | ||
a: b => { | ||
var f = console, m = f.log; | ||
if (b) { | ||
for (var e = b + void 0, a = b; !(a >= e) && g[a]; ) ++a; | ||
b = k.decode(g.subarray(b, a)); | ||
} else b = ""; | ||
m.call(f, b); | ||
a: e => { | ||
var m = console, n = m.log; | ||
if (e) { | ||
for (var f = e + void 0, a = e; !(a >= f) && g[a]; ) ++a; | ||
e = k.decode(g.subarray(e, a)); | ||
} else e = ""; | ||
n.call(m, e); | ||
} | ||
} | ||
}).then((b => { | ||
b = b.instance.exports; | ||
l = b.d; | ||
h = b.b; | ||
}).then((e => { | ||
e = e.instance.exports; | ||
l = e.d; | ||
h = e.b; | ||
g = new Uint8Array(h.buffer); | ||
g.set(new Uint8Array(c.mem), 1024); | ||
b.c(); | ||
e.c(); | ||
l(); | ||
})); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 671, | ||
"a.html.gz": 430, | ||
"a.js": 708, | ||
"a.js.gz": 444, | ||
"a.js": 898, | ||
"a.js.gz": 529, | ||
"a.mem": 6, | ||
"a.mem.gz": 32, | ||
"total": 1385, | ||
"total_gz": 906 | ||
"total": 1575, | ||
"total_gz": 991 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"a.html": 17279, | ||
"a.html.gz": 7541, | ||
"total": 17279, | ||
"total_gz": 7541 | ||
"a.html": 17576, | ||
"a.html.gz": 7653, | ||
"total": 17576, | ||
"total_gz": 7653 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6507,7 +6507,7 @@ def test_failing_alloc(self): | |
printf("managed another malloc!\n"); | ||
} | ||
''' % (pre_fail, post_fail)) | ||
args = [EMXX, 'main.cpp', '-sEXPORTED_FUNCTIONS=_main,_sbrk'] + opts + aborting_args | ||
args = [EMXX, 'main.cpp', '-sEXPORTED_FUNCTIONS=_main,_sbrk', '-sINITIAL_MEMORY=16MB'] + opts + aborting_args | ||
args += ['-sTEST_MEMORY_GROWTH_FAILS'] # In this test, force memory growing to fail | ||
if growth: | ||
args += ['-sALLOW_MEMORY_GROWTH'] | ||
|
@@ -8026,6 +8026,30 @@ def test_binaryen_warn_mem(self): | |
self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sALLOW_MEMORY_GROWTH', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY']) | ||
self.assertContained('hello, world!', self.run_js('a.out.js')) | ||
|
||
def test_initial_heap(self): | ||
for args, expected_initial_heap in [ | ||
([], 16 * 1024 * 1024), # Default behavior: 16MB initial heap | ||
(['-sINITIAL_MEMORY=40MB'], 0), # Backwards compatibility: no initial heap (we can't tell if it'll fit) | ||
(['-sMAXIMUM_MEMORY=40MB'], 0), # Backwards compatibility: no initial heap (we can't tell if it'll fit) | ||
(['-sINITIAL_HEAP=64KB'], 64 * 1024), # Explicitly set initial heap is passed | ||
(['-sINITIAL_HEAP=128KB', '-sINITIAL_MEMORY=20MB', '-sMAXIMUM_MEMORY=40MB'], 128 * 1024), | ||
(['-sINITIAL_HEAP=10MB', '-sINITIAL_MEMORY=10MB'], -1), # Not enough space for stack | ||
(['-sINITIAL_HEAP=5MB', '-sMAXIMUM_MEMORY=5MB'], -1), # Not enough space for stack | ||
]: | ||
SingleAccretion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cmd = [EMCC, test_file('hello_world.c'), '-v'] + args | ||
print(' '.join(cmd)) | ||
|
||
if expected_initial_heap < 0: | ||
out = self.expect_fail(cmd) | ||
self.assertContained('wasm-ld: error:', out) | ||
SingleAccretion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
continue | ||
|
||
out = self.run_process(cmd, stderr=PIPE) | ||
if expected_initial_heap != 0: | ||
self.assertContained('--initial-heap=' + str(expected_initial_heap), out.stderr) | ||
else: | ||
self.assertNotContained('--initial-heap=', out.stderr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If possible, I'd prefer not to test this by peeking inside like this but I guess there is no other easy way? I suppose we could compare There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was an intentional decision do this sort of "white box" testing. There were two reasons:
The upside is that it is more resilient against changes in the other parts of the system. The downside is that it assumes the process involves invoking the linker, but it seems unlikely that the linker will go away any time soon (interestingly, writing a test with |
||
|
||
def test_memory_size(self): | ||
for args, expect_initial, expect_max in [ | ||
([], 320, 320), | ||
|
@@ -8055,6 +8079,9 @@ def test_invalid_mem(self): | |
self.assertContained('hello, world!', self.run_js('a.out.js')) | ||
|
||
# Must be a multiple of 64KB | ||
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-sINITIAL_HEAP=32505857', '-sALLOW_MEMORY_GROWTH']) # 31MB + 1 byte | ||
self.assertContained('INITIAL_HEAP must be a multiple of WebAssembly page size (64KiB)', ret) | ||
|
||
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=33554433']) # 32MB + 1 byte | ||
self.assertContained('INITIAL_MEMORY must be a multiple of WebAssembly page size (64KiB)', ret) | ||
|
||
|
@@ -8505,7 +8532,7 @@ def run(args, expected): | |
result = self.run_js('a.out.js').strip() | ||
self.assertEqual(result, f'{expected}, errno: 0') | ||
|
||
run([], 256) | ||
run([], 258) | ||
run(['-sINITIAL_MEMORY=32MB'], 512) | ||
run(['-sINITIAL_MEMORY=32MB', '-sALLOW_MEMORY_GROWTH'], (2 * 1024 * 1024 * 1024) // webassembly.WASM_PAGE_SIZE) | ||
run(['-sINITIAL_MEMORY=32MB', '-sALLOW_MEMORY_GROWTH', '-sWASM=0'], (2 * 1024 * 1024 * 1024) // webassembly.WASM_PAGE_SIZE) | ||
|
Uh oh!
There was an error while loading. Please reload this page.