[PATCH] D126337: [pseudo] WIP: GSS node refcounting (dumb pointers)
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 30 11:49:40 PDT 2022
hokein added inline comments.
================
Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:118
+ CheckRefcounts();
+ for (const auto *Head : NewHeads) {
AddSteps(Head, Terminal.symbol());
----------------
> The freelist works well (on AST.cpp, 35K nodes created but only 74 allocated),
The number of saving is quite promising! But as discussed, it didn't speed up the parser (mostly we're paying extra cost of updating nodes in dead branches, causing ~10% slowdown).
Wanted to explore an alternative (which we discussed briefly) -- for errory-recovery, the key point is that when there is no active head, we'd like to find a recovery state (retrieved from the most-recent live heads) and continue the parsing from there.
This main parsing for-loop can provide a global view of active heads:
- we can assume here the `NewHeads` is not empty (for-loop body always starts with active heads);
- if all heads die, we can detect it after the `glrReduce` (on Line130, by checking `PendingShift` is empty);
So the code is roughly like
```
for ( ... : Terminals) {
auto PreviousNewHeads = NewHeads;
....
glrReduce(...);
if (PendingShift.empty()) {
// run error-recovery from the PreviousNewHeads
} else {
glrShift(...);
}
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126337/new/
https://reviews.llvm.org/D126337
More information about the cfe-commits
mailing list