Skip to content

Conversation

KKiiim
Copy link

@KKiiim KKiiim commented Sep 17, 2025

  • Reduce unnecessary zero-initialization memory in the constructor

  • According to wasm-spec, grown memories should initialized with value 0x00

  • I've read the contributing guidelines

  • I've added my name and email to the NOTICE file

@KKiiim KKiiim changed the title feat: remove the active init operation of zero-initialized memory of makeFieldInitializationInConstructor feat: optimize the active init operation of zero-initialized memory of makeFieldInitializationInConstructor Sep 17, 2025
Copy link
Member

@HerrCai0907 HerrCai0907 left a comment

Choose a reason for hiding this comment

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

optimization goal LGTM. But I think we should only check whether the field is straightly initialized by zero and ignore it.

Comment on lines +10030 to +10035
canOptimizeZeroInitialization(valueExpr: ExpressionRef): bool {
if ((this.options.runtime != Runtime.Incremental) && (this.options.runtime != Runtime.Stub)) {
return false;
}
return isConstZero(valueExpr);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
canOptimizeZeroInitialization(valueExpr: ExpressionRef): bool {
if ((this.options.runtime != Runtime.Incremental) && (this.options.runtime != Runtime.Stub)) {
return false;
}
return isConstZero(valueExpr);
}
canOptimizeZeroInitialization(valueExpr: ExpressionRef): bool {
const runtime = this.options.runtime;
return runtime == Runtime.Incremental || runtime == Runtime.Stub
? isConstZero(valueExpr)
: false;
}

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.

3 participants