Explicit the order of evaluation for the select operation.#469
Explicit the order of evaluation for the select operation.#469jcbeyler wants to merge 1 commit intoWebAssembly:masterfrom jcbeyler:select
Conversation
AstSemantics.md
Outdated
There was a problem hiding this comment.
I think the order is already specified, where it says All nodes other than control flow constructs need to evaluate their child nodes in the order they appear in the serialized AST. I feel that specifying it here redundantly might be confusing (people might think, why is this specified here, and why don't other ops say their order of evaluation).
Perhaps remove the first added sentence, and keep the last, replacing "therefore" with "note that"?
|
Thanks! But wait, re-reading that now, I'm confused - isn't the condition evaluated first, then the two values? (Maybe I have that wrong, and if so, my interpreter is wrong too ;) |
|
Good point, I don't know. It just seemed logical to me to do it this way :) But maybe someone has an opinion here? |
|
It seems like translation to ASM.JS requires fewer temporaries if the condition is evaluated after the other two subexpressions. e.g. vs It seems like it also makes it easier to generate machine code that feed condition flags directly from the condition into However, if we change the order it would be nice to change the parameter order so it matches the general left-to-right rule. |
|
So do we want the first sentence to say:
|
|
The first section in this doc explicitly specifies left-to-right evaluation order. That sometimes requires additional temporaries, but that's not specific to |
|
I'm OK changing the evaluation order of select by defining the condition to On Mon, Nov 23, 2015 at 12:26 PM, rossberg-chromium <
|
|
@AndrewScheidecker's idea about putting the condition last to better set up condition codes makes sense to me at first glance. I also agree that if we do this, we should change the operand order to that we don't have to make select an exception to the left-to-right rule. |
|
Agreed with what @sunfishcode just said. |
|
I created #489 to propose reordering select's operands. |
|
This is superseded by #489. |
No description provided.