From 7b447bdad29c828b49ba63cefacc677bd7c58b28 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 9 Jul 2021 16:29:23 -0400 Subject: Make Scope non ref counted (#1904) * Add debug symbols for release build. * Hack to try and capture failing compilation. * Typo fix for capture hack. * Specify return type on lambdas. * Added const. * Try breakpoint. * Up count * Let's capture everything so we can valgrind. * Disable always writing repros. * Make Scope non RefCounted. * Fix issue with not serializing Scope. * More comments around changes to Scope. Remove Scope* from serialization. * Remove code used for testing original issue. --- source/slang/slang-check-shader.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-check-shader.cpp') diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp index b6ed0224a..025a47c1b 100644 --- a/source/slang/slang-check-shader.cpp +++ b/source/slang/slang-check-shader.cpp @@ -1297,7 +1297,7 @@ namespace Slang sink); } - RefPtr ComponentType::_createScopeForLegacyLookup() + Scope* ComponentType::_createScopeForLegacyLookup(ASTBuilder* astBuilder) { // The shape of this logic is dictated by the legacy // behavior for name-based lookup/parsing of types @@ -1308,7 +1308,8 @@ namespace Slang // definitions (that scope is necessary because // it defines keywords like `true` and `false`). // - RefPtr scope = new Scope(); + + Scope* scope = astBuilder->create(); scope->parent = getLinkage()->getSessionImpl()->slangLanguageScope; // // Next, the scope needs to include all of the @@ -1317,7 +1318,7 @@ namespace Slang // for( auto module : getModuleDependencies() ) { - RefPtr moduleScope = new Scope(); + Scope* moduleScope = astBuilder->create(); moduleScope->containerDecl = module->getModuleDecl(); moduleScope->nextSibling = scope->nextSibling; @@ -1339,8 +1340,12 @@ namespace Slang { auto unspecialiedProgram = endToEndReq->getUnspecializedGlobalComponentType(); - - RefPtr scope = unspecialiedProgram->_createScopeForLegacyLookup(); + // TODO(JS): + // + // We create the scopes on the linkages ASTBuilder. We might want to create a temporary ASTBuilder, + // and let that memory get freed, but is like this because it's not clear if the scopes in ASTNode members + // will dangle if we do. + Scope* scope = unspecialiedProgram->_createScopeForLegacyLookup(endToEndReq->getLinkage()->getASTBuilder()); // We are going to do some semantic checking, so we need to // set up a `SemanticsVistitor` that we can use. -- cgit v1.2.3