Skip to content

Commit 1a9b0e1

Browse files
authored
Don't minify __stack_pointer import (#2219)
This is core import like __memory_base and __table_base.
1 parent 9838b39 commit 1a9b0e1

4 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/passes/MinifyImportsAndExports.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct MinifyImportsAndExports : public Pass {
145145
std::map<Name, Name> oldToNew;
146146
auto process = [&](Name& name) {
147147
// do not minifiy special imports, they must always exist
148-
if (name == MEMORY_BASE || name == TABLE_BASE) {
148+
if (name == MEMORY_BASE || name == TABLE_BASE || name == STACK_POINTER) {
149149
return;
150150
}
151151
auto newName = names.getName(soFar++);

src/shared-constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern Name GROW_WASM_MEMORY;
2525
extern Name WASM_CALL_CTORS;
2626
extern Name MEMORY_BASE;
2727
extern Name TABLE_BASE;
28+
extern Name STACK_POINTER;
2829
extern Name GET_TEMP_RET0;
2930
extern Name SET_TEMP_RET0;
3031
extern Name NEW_SIZE;

src/wasm/wasm-emscripten.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Global* EmscriptenGlueGenerator::getStackPointerGlobal() {
6565
// linker could export it by name?
6666
for (auto& g : wasm.globals) {
6767
if (g->imported()) {
68-
if (g->base == "__stack_pointer") {
68+
if (g->base == STACK_POINTER) {
6969
return g.get();
7070
}
7171
} else if (!isExported(wasm, g->name)) {

src/wasm/wasm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Name GROW_WASM_MEMORY("__growWasmMemory");
4848
Name WASM_CALL_CTORS("__wasm_call_ctors");
4949
Name MEMORY_BASE("__memory_base");
5050
Name TABLE_BASE("__table_base");
51+
Name STACK_POINTER("__stack_pointer");
5152
Name GET_TEMP_RET0("getTempRet0");
5253
Name SET_TEMP_RET0("setTempRet0");
5354
Name NEW_SIZE("newSize");

0 commit comments

Comments
 (0)