mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user