-
-
Notifications
You must be signed in to change notification settings - Fork 774
perf(semantic): calculate number of nodes, scopes, symbols, references before visiting AST #4328
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
Merged
+124
−0
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c4fbba1
test: visit
Dunqing 59e4c74
feat: reserve
Dunqing f573c34
feat: improve small file
Dunqing bbf8dc3
Merge remote-tracking branch 'origin/main' into test-visit
Dunqing a698196
fix
Dunqing dc6b249
Fix
Dunqing 53bc5f5
Fix
Dunqing e68d3fd
avoid reserve for symbols
Dunqing 221674f
U
Dunqing 753c64d
Update
Dunqing ad6aa55
Revert
Dunqing 88b4bdf
Correct
Dunqing b4a8d67
Update
Dunqing 2992c54
fix: stack overflow
Dunqing 9d58b6c
fix: stack overflow
Dunqing a615891
Merge remote-tracking branch 'origin/main' into test-visit
Dunqing d7b8072
fix: symbols less than collected by collector
Dunqing 1cec151
chore: add debug assert
Dunqing 062e3b3
Merge branch 'main' into test-visit
Dunqing 8a2971b
Merge branch 'main' into test-visit
Dunqing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update
- Loading branch information
commit b4a8d675e0dd9999f2098000fecbb4330470d45e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since you're counting
JSXIdentifieras a reference, shouldn't this branch also haveself.reference += 1;?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.
oxc/crates/oxc_semantic/src/builder.rs
Lines 1966 to 1975 in b4a8d67
JSXIdentifieris not always a reference. you can see my latest commit.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.
Two things:
In that case shouldn't it call
self.visit_jsx_identifier?I don't think we necessarily need to make the counts 100% accurate. Over-estimating is fine. It may be that the cost of complicating
Collectorto make an accurate count (and so making it a bit slower) is worse than the cost of allocating too much space in theVecs. It's under-estimating that we absolutely need to avoid.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.
If I call the
visit_jsx_identifier, the reference count will increase. But it's not areferenceThere 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.
Unless I'm reading
reference_jsx_identifierwrong, it does create a reference for aJSXIdentifierwhose parent is aJSXMemberExpressionObject.Some(AstKind::JSXMemberExpressionObject(_)) => {}lets execution fall through to next block of code which creates the reference.That would be correct behavior - in
<Foo.bar />,Foois a reference.But this isn't easy to reason about. #3528 would make it much simpler.