Add custom memory management for verilated classes (#3595)

This change introduces a custom reference-counting pointer class that
allows creating such pointers from 'this'. This lets us keep the
receiver object around even if all references to it outside of a class
method no longer exist. Useful for coroutine methods, which may outlive
all external references to the object.

The deletion of objects is deferred until the next time slot. This is to
make clearing the triggered flag on named events in classes safe
(otherwise freed memory could be accessed).
This commit is contained in:
Krzysztof Bieganski
2022-09-28 18:54:18 -04:00
committed by GitHub
parent b92173bf3d
commit 9c2ead90d5
14 changed files with 242 additions and 8 deletions
+2
View File
@@ -75,6 +75,7 @@ class EmitCGatherDependencies final : VNVisitor {
iterateChildrenConst(nodep);
}
void visit(AstCNew* nodep) override {
addSymsDependency();
addDTypeDependency(nodep->dtypep());
iterateChildrenConst(nodep);
}
@@ -83,6 +84,7 @@ class EmitCGatherDependencies final : VNVisitor {
iterateChildrenConst(nodep);
}
void visit(AstNewCopy* nodep) override {
addSymsDependency();
addDTypeDependency(nodep->dtypep());
iterateChildrenConst(nodep);
}