-
Notifications
You must be signed in to change notification settings - Fork 47
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
Scope validation performance boost #656
Conversation
|
||
//do some file-based validations | ||
if (isEnumStatement(node)) { | ||
this.validateEnumDeclaration(node); |
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.
This was moved into the EnumStatement callback above.
|
||
public processEvent(event: OnScopeValidateEvent) { | ||
this.events.push(event); | ||
event.scope.linkSymbolTable(); |
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.
Symbol table linking/unlinking happens at the program event level, we don't need to do it here anymore.
private iterateFileExpressions(file: BrsFile) { | ||
const { scope } = this.event; | ||
//build an expression collection ONCE per file | ||
const expressionInfos = this.expressionsByFile.getOrAdd(file, () => { |
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.
This is the core of the performance improvement. The expression info is computed once for each file (previously this would happen once per scope per file).
Several fixes:
While this hasn't restored the original performance lost in 0.53.0, it's a step in the right direction.
Breaking changes:
removed
NamespaceStatement.symbolTable
in favor ofNamespaceStatement.getSymbolTable()
because the symbol table for namespaces actually reside within theNamespaceStatement.body
property. Since the symbolTable logic was only recently added, it's unlikely that many projects are referencing it.removed the
namespaceName
from several AstNodes, in favor of external consumers needing to call.findAncestor(isNamespaceStatement)
instead. Note, this relies heavily on theAstNode.parent
property which is set at the start ofonFileValidate
for each file. This is breaking because previously, the .namespaceName property was available immediately inafterFileParse
. However, that logic was unsustainable for plugins that manipulate AST, and it's unlikely that many plugins are leveraging that property, so it is worth the breaking change.Here are the nodes with the removed property:
VariableExpression
DottedGetExpression
CallExpression
FunctionStatement