Internals: Use existing astgen type info for ASTGEN_MAX_NODE_SIZE (#7161)
This commit is contained in:
parent
e9dd6eaaf0
commit
26eac21432
|
|
@ -23,10 +23,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#ifdef VL_ALLOC_RANDOM_CHECKS
|
|
||||||
#include "V3Ast__gen_sizeof.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VL_DEFINE_DEBUG_FUNCTIONS;
|
VL_DEFINE_DEBUG_FUNCTIONS;
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
@ -998,6 +994,15 @@ void AstNode::operator delete(void* objp, size_t size) {
|
||||||
|
|
||||||
#ifdef VL_ALLOC_RANDOM_CHECKS
|
#ifdef VL_ALLOC_RANDOM_CHECKS
|
||||||
void* AstNode::operator new(size_t size) { // VL_MT_SAFE
|
void* AstNode::operator new(size_t size) { // VL_MT_SAFE
|
||||||
|
// Compute the maximum node size once and cache it
|
||||||
|
static const size_t ASTGEN_MAX_NODE_SIZE = []() {
|
||||||
|
size_t maxSize = 0;
|
||||||
|
for (size_t t = 0; t < VNType::NUM_TYPES(); ++t) {
|
||||||
|
maxSize = std::max(maxSize, VNType::typeInfo(static_cast<VNType::en>(t)).m_sizeof);
|
||||||
|
}
|
||||||
|
return maxSize;
|
||||||
|
}();
|
||||||
|
|
||||||
// Make the following small to debug this routine, larger for performance and better random
|
// Make the following small to debug this routine, larger for performance and better random
|
||||||
constexpr size_t POOL_SIZE = 65536; // Ideally large enough to fit all nodes used in tests
|
constexpr size_t POOL_SIZE = 65536; // Ideally large enough to fit all nodes used in tests
|
||||||
// Randomly select from a large pool (POOL_SIZE) of max-node sized (MAX_NODE_SIZE) pointers
|
// Randomly select from a large pool (POOL_SIZE) of max-node sized (MAX_NODE_SIZE) pointers
|
||||||
|
|
|
||||||
11
src/astgen
11
src/astgen
|
|
@ -935,16 +935,6 @@ def write_ast_type_info(filename):
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
def write_ast_sizeof(filename):
|
|
||||||
with open_file(filename) as fh:
|
|
||||||
fh.write("static constexpr size_t ASTGEN_MAX_NODE_SIZE =\n")
|
|
||||||
paren = ""
|
|
||||||
for node in AstNodeList:
|
|
||||||
fh.write(" std::max(sizeof(Ast{n}),\n".format(n=node.name))
|
|
||||||
paren += ")"
|
|
||||||
fh.write(" static_cast<size_t>(0)" + paren + ";\n")
|
|
||||||
|
|
||||||
|
|
||||||
def write_ast_impl(filename):
|
def write_ast_impl(filename):
|
||||||
with open_file(filename) as fh:
|
with open_file(filename) as fh:
|
||||||
|
|
||||||
|
|
@ -1594,7 +1584,6 @@ if Args.classes:
|
||||||
write_ast_impl("V3Ast__gen_impl.h")
|
write_ast_impl("V3Ast__gen_impl.h")
|
||||||
write_ast_macros("V3Ast__gen_macros.h")
|
write_ast_macros("V3Ast__gen_macros.h")
|
||||||
write_ast_yystype("V3Ast__gen_yystype.h")
|
write_ast_yystype("V3Ast__gen_yystype.h")
|
||||||
write_ast_sizeof("V3Ast__gen_sizeof.h")
|
|
||||||
# Write Dfg code
|
# Write Dfg code
|
||||||
write_forward_class_decls("Dfg", DfgVertexList)
|
write_forward_class_decls("Dfg", DfgVertexList)
|
||||||
write_visitor_decls("Dfg", DfgVertexList)
|
write_visitor_decls("Dfg", DfgVertexList)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue