Internals: Further performance improvement of AstNode type tests, #2138. No functional change intended.

Replace the virtual type() method on AstNode with a non-virtual, inlined
accessor to a const member variable m_type.  This means that in order to be
able to use this for type testing, it needs to be initialized based on the
final type of the node. This is achieved by passing the relevant AstType
value back through the constructor call chain. Most of the boilerplate
involved is auto generated by first feeding V3AstNodes.h through astgen to
get V3AstNodes__gen.h, which is then included in V3Ast.h. No client code
needs to be aware and there is no functional change intended.

Eliminating the virtual function call to fetch the node type identifier
results in measured compilation speed improvement of 5-10% as it
eliminates up to 20% of all mispredicted branches from the execution.
This commit is contained in:
Geza Lore
2020-01-25 15:29:44 -05:00
committed by Wilson Snyder
parent eafed88a6e
commit ef5250f0ca
5 changed files with 680 additions and 594 deletions
+1 -1
View File
@@ -168,7 +168,7 @@ AstNodeBiop* AstEqWild::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) {
}
AstExecGraph::AstExecGraph(FileLine* fileline)
: AstNode(fileline) {
: AstNode(AstType::atExecGraph, fileline) {
m_depGraphp = new V3Graph;
}
AstExecGraph::~AstExecGraph() {