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

improve default argument const check #2768

Closed
wants to merge 2 commits into from

Conversation

HerrCai0907
Copy link
Member

Using binaryen provided ExpressionRunner to run compilesToConst for more accurate evaluation results.

Using binaryen provided `ExpressionRunner` to run compilesToConst for more accurate evaluation results.
src/compiler.ts Outdated
Comment on lines 6829 to 6841
let previousFlow = this.currentFlow;
this.currentFlow = instance.flow;
const expr = this.compileExpression(
initializer,
parameterTypes[i],
Constraints.ConvImplicit
);
this.currentFlow = previousFlow;
const precomp = module.runExpression(expr, ExpressionRunnerFlags.Default);
if (precomp) {
operands.push(precomp);
continue;
}
Copy link
Member

Choose a reason for hiding this comment

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

Previously, since the expression was checked before compiling it, its side effects (like updating local states) would only be applied when indeed using the expression. With this change, its side-effects occur always due to compiling it unconditionally, even when the expression is not used, which is likely undesirable.

Copy link
Member Author

Choose a reason for hiding this comment

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

With this change, its side-effects occur always due to compiling it unconditionally, even when the expression is not used, which is likely undesirable.

Which kind of side-effects do you mean?
If it is side effect for code, it can be detected by module.runExpression.
If it is side effect for compiler, here is in instance.flow, default argument definitely needs to be consider.

src/compiler.ts Outdated Show resolved Hide resolved
@HerrCai0907 HerrCai0907 deleted the improve-const branch November 15, 2023 23:39
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