Skip to content
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

Remove asmCoercion family of functions from parseTools.js. NFC #14436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jun 11, 2021

These don't have a role to play any longer in a non-asm.js world.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jun 11, 2021

I'm not sure about asmEnsureFloat.. is that doing anything useful anymore?

@sbc100 sbc100 force-pushed the remove_asmCoercion branch 3 times, most recently from 2999a68 to 1c5b605 Compare June 11, 2021 17:54
These don't have a role to play any longer in a non-asm.js world.
@sbc100 sbc100 force-pushed the remove_asmCoercion branch from 1c5b605 to a7e6159 Compare June 11, 2021 17:55
@sbc100 sbc100 requested a review from kripken June 11, 2021 17:59
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

asmEnsureFloat is probably not needed, yeah, that just affected asm.js validation back when that mattered.

@@ -894,7 +842,7 @@ function getHeapForType(type, unsigned) {
// case external JS library code uses this name.
function makeStructuralReturn(values) {
assert(values.length == 2);
return 'setTempRet0(' + values[1] + '); return ' + asmCoercion(values[0], 'i32');
return 'setTempRet0(' + values[1] + '); return ' + values[0];
Copy link
Member

Choose a reason for hiding this comment

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

There is a possible risk here, as this turns return x | 0 into return x, and maybe x was unsigned.

The risk is probably low, but I'm not sure how low?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this a risk just here for makeStructuralReturn? Or elsewhere too? I'm not sure I understand that the risk exactly.. maybe you could give an example of how it could break?

Internally makeStructuralReturn only has a single user __cxa_find_matching_catch and values[0] is always a pointer in that case.

Copy link
Member

Choose a reason for hiding this comment

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

It could be in the others as well.

If we used to have

function foo() {
  return x + y | 0;

but now we have

function foo() {
  return x + y;

Then the result may be different, if it overflows beyond a 32-bit integer. It seems unlikely, but it's still a risk. Leaving the coercion is probably safest.

Copy link
Member

Choose a reason for hiding this comment

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

It does sound like the single user here is fine, though. If you audit all the other code paths in the others as well, then sgtm.

asmEnsureFloat(4294967296, 'double') + ')', 'double') + ', ' +
asmEnsureFloat(4294967295, 'double') + ')', 'i32') + '>>>0' +
'Math.abs(VALUE) >= 1 ? (VALUE > 0 ? ' +
'Math.min(Math.floor((VALUE)/4294967296), 4294967295)>>>0' +
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is one place that I'm not sure I understand the implications of removing the coercions.

In this change I've removed all usage of asmCoercion. I think all the other ones looks safe, but I don't grok this enough to know if it might have and effect.

Copy link
Member

Choose a reason for hiding this comment

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

The double conversions (using +(x)) have no effect on doubles. But the i32 one might be important. It might be easiest to print out the output of this to see exactly what the |0 is on, for us to check.

@stale
Copy link

stale bot commented Jul 10, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Jul 10, 2022
@sbc100
Copy link
Collaborator Author

sbc100 commented Jul 13, 2022

ping

@stale stale bot removed the wontfix label Jul 13, 2022
@kripken
Copy link
Member

kripken commented Jul 13, 2022

Is the ping for me? The last two comments are questions from me to you: (1) to audit all other code paths, and (2) to print out the output from the one confusing location you mentioned.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jul 13, 2022

Sorry, no just a keepalive ping for the stalebot

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