Skip to content

Remove makeStaticAlloc/String #12174

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

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
// object. For convenience, the short name appears here. Note that if you add a
// new function with an '_', it will not be found.

// Memory allocated during startup, in postsets, should only be static
// (using makeStaticAlloc)

LibraryManager.library = {
// ==========================================================================
// getTempRet0/setTempRet0: scratch space handling i64 return
Expand Down
13 changes: 0 additions & 13 deletions src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1481,19 +1481,6 @@ function makeEval(code) {
return ret;
}

function makeStaticAlloc(size) {
size = alignMemory(size);
var ret = alignMemory(GLOBAL_BASE + STATIC_BUMP);
STATIC_BUMP = ret + size - GLOBAL_BASE;
return ret;
}

function makeStaticString(string) {
var len = lengthBytesUTF8(string) + 1;
var ptr = makeStaticAlloc(len);
return '(stringToUTF8("' + string + '", ' + ptr + ', ' + len + '), ' + ptr + ')';
}

var ATINITS = [];

function addAtInit(code) {
Expand Down
25 changes: 0 additions & 25 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4190,31 +4190,6 @@ def test_dylink_jslib(self):
}
''', expected='other says 45.2', main_emcc_args=['--js-library', 'lib.js'])

@needs_dlfcn
def test_dylink_global_var_jslib(self):
create_test_file('lib.js', r'''
mergeInto(LibraryManager.library, {
jslib_x: '{{{ makeStaticAlloc(4) }}}',
jslib_x__postset: 'HEAP32[_jslib_x>>2] = 148;',
});
''')
self.dylink_test(main=r'''
#include <stdio.h>
extern "C" int jslib_x;
extern void call_side();
int main() {
printf("main: jslib_x is %d.\n", jslib_x);
call_side();
return 0;
}
''', side=r'''
#include <stdio.h>
extern "C" int jslib_x;
void call_side() {
printf("side: jslib_x is %d.\n", jslib_x);
}
''', expected=['main: jslib_x is 148.\nside: jslib_x is 148.\n'], main_emcc_args=['--js-library', 'lib.js'])

@needs_dlfcn
def test_dylink_many_postsets(self):
NUM = 1234
Expand Down