-
Notifications
You must be signed in to change notification settings - Fork 53
Add bytecode generate process that removing unused function parameters #1503
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
base: master
Are you sure you want to change the base?
Conversation
|
@kwonjeomsim |
718bb14 to
dd6bde3
Compare
@clover2123 |
| continue; | ||
| } | ||
|
|
||
| if (name == "eval" || name == "arguments") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added if (name == "eval" || name == "arguments") replaces the original check that used scopeCtx->m_hasEval and scopeCtx->m_allowArguments. This causes the function to mark parameters as used for the names "eval" or "arguments" even when the current scope does not actually allow eval or arguments, leading to incorrect parameter usage tracking. Restore the original flag-based check or add a guard that verifies scopeCtx->m_hasEval or scopeCtx->m_allowArguments before marking the parameter as used.
| if (!contains) { | ||
| this->currentBlockContext->m_usingNames.push_back(name); | ||
| #ifndef ESCARGOT_DEBUGGER | ||
| ASTScopeContext* scope = this->currentScopeContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the while loop with a for loop to make the traversal of the scope chain more idiomatic and reduce boilerplate. The for form for (auto* scope = this->currentScopeContext; scope; scope = scope->m_parent) expresses the same logic in a single line, improving readability. This change keeps the semantics identical and avoids the need for a separate assignment statement. It also aligns with common C++ style for simple pointer iteration.
This PR removes some bytecodes that generate function parameters which are not used during execution.
I add this feature in release mode only because there are some test failed in debug mode.