Skip to content

Use absolute memory addresses for emasm string indexes.#2408

Merged
sbc100 merged 2 commits intomasterfrom
fix_pic_em_asm
Oct 31, 2019
Merged

Use absolute memory addresses for emasm string indexes.#2408
sbc100 merged 2 commits intomasterfrom
fix_pic_em_asm

Conversation

@sbc100
Copy link
Copy Markdown
Member

@sbc100 sbc100 commented Oct 30, 2019

Before we used 0-based indexes which meant that we needed to modify the
code calling the emask function to replace the first argument.

Now we use the string address itself as the index/code for the emasm
constant. This allows use code to go unmodifed as the emscripten side
will accept the memory address as the index/code.

See: emscripten-core/emscripten#9013

auto* value = arg->cast<Const>();
auto code = codeForConstAddr(wasm, segmentOffsets, value);
auto& asmConst = createAsmConst(code, sig, importName);
int32_t address = value->value.geti32();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason codeForConstAddr changed from taking a Const* to an int32_t? It seems like this was a partial change that didn't make it in to the final PR, so the effect was that we just outlined the value->value.geti32() bit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I outlines it because it need to use that address in two places now. Maybe I should just have both consumers call ->value.geti32()?

Before we used 0-based indexes which meant that we needed to modify the
code calling the emask function to replace the first argument.

Now we use the string address itself as the index/code for the emasm
constant.  This allows use code to go unmodifed as the emscripten side
will accept the memory address as the index/code.

See: emscripten-core/emscripten#9013
@sbc100 sbc100 requested a review from kripken October 30, 2019 22:40
@sbc100
Copy link
Copy Markdown
Member Author

sbc100 commented Oct 30, 2019

PTAL

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