From 43c146794aab638924d2ab838d10f8af2ebf02a7 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 5 Jun 2020 18:20:09 -0400 Subject: ASTNodes use MemoryArena (#1376) * Add a ASTBuilder to a Module Only construct on valid ASTBuilder (was being called on nullptr on occassion) * Add nodes to ASTBuilder. * Compiles with RefPtr removed from AST node types. * Initialize all AST node pointer variables in headers to nullptr; * Initialize AST node variables as nullptr. Make ASTBuilder keep a ref on node types. Make SyntaxParseCallback returns a NodeBase * Don't release canonicalType on dtor (managed by ASTBuilder). * Give ASTBuilders a name and id, to help in debugging. For now destroy the session TypeCache, to stop it holding things released when the compile request destroys ASTBuilders. * Moved the TypeCheckingCache over to Linkage from Session. * NodeBase no longer derived from RefObject. * Only add/dtor nodes that need destruction. First pass compile on linux. --- source/slang/slang-type-layout.cpp | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'source/slang/slang-type-layout.cpp') diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index f26b8bda4..3b30e6ee0 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -1318,7 +1318,7 @@ TypeLayoutContext getInitialLayoutContextForTarget(TargetRequest* targetReq, Pro } -static LayoutSize GetElementCount(RefPtr val) +static LayoutSize GetElementCount(IntVal* val) { // Lack of a size indicates an unbounded array. if(!val) @@ -1365,7 +1365,7 @@ bool IsResourceKind(LayoutResourceKind kind) /// static TypeLayoutResult createSimpleTypeLayout( SimpleLayoutInfo info, - RefPtr type, + Type* type, LayoutRulesImpl* rules) { RefPtr typeLayout = new TypeLayout(); @@ -1381,7 +1381,7 @@ static TypeLayoutResult createSimpleTypeLayout( } static SimpleLayoutInfo getParameterGroupLayoutInfo( - RefPtr type, + ParameterGroupType* type, LayoutRulesImpl* rules) { if( as(type) ) @@ -1861,7 +1861,7 @@ static void _addUnmaskedResourceUsage( static RefPtr _createParameterGroupTypeLayout( TypeLayoutContext const& context, - RefPtr parameterGroupType, + ParameterGroupType* parameterGroupType, RefPtr rawElementTypeLayout) { // We are being asked to create a layout for a parameter group, @@ -2325,8 +2325,8 @@ RefPtr createConstantBufferTypeLayoutIfNeeded( static RefPtr _createParameterGroupTypeLayout( TypeLayoutContext const& context, - RefPtr parameterGroupType, - RefPtr elementType, + ParameterGroupType* parameterGroupType, + Type* elementType, LayoutRulesImpl* elementTypeRules) { // We will first compute a layout for the element type of @@ -2346,7 +2346,7 @@ static RefPtr _createParameterGroupTypeLayout( } LayoutRulesImpl* getParameterBufferElementTypeLayoutRules( - RefPtr parameterGroupType, + ParameterGroupType* parameterGroupType, LayoutRulesImpl* rules) { if( as(parameterGroupType) ) @@ -2376,13 +2376,13 @@ LayoutRulesImpl* getParameterBufferElementTypeLayoutRules( else { SLANG_UNEXPECTED("uhandled parameter block type"); - return nullptr; + //return nullptr; } } RefPtr createParameterGroupTypeLayout( TypeLayoutContext const& context, - RefPtr parameterGroupType) + ParameterGroupType* parameterGroupType) { auto parameterGroupRules = context.rules; @@ -2405,7 +2405,7 @@ RefPtr createStructuredBufferTypeLayout( TypeLayoutContext const& context, ShaderParameterKind kind, - RefPtr structuredBufferType, + Type* structuredBufferType, RefPtr elementTypeLayout) { auto rules = context.rules; @@ -2437,8 +2437,8 @@ RefPtr createStructuredBufferTypeLayout( TypeLayoutContext const& context, ShaderParameterKind kind, - RefPtr structuredBufferType, - RefPtr elementType) + Type* structuredBufferType, + Type* elementType) { // look up the appropriate rules via the `LayoutRulesFamily` auto structuredBufferLayoutRules = context.getRulesFamily()->getStructuredBufferRules(); @@ -2446,7 +2446,7 @@ createStructuredBufferTypeLayout( // Create and save type layout for the buffer contents. auto elementTypeLayout = createTypeLayout( context.with(structuredBufferLayoutRules), - elementType.Ptr()); + elementType); return createStructuredBufferTypeLayout( context, @@ -2504,13 +2504,13 @@ static TypeLayoutResult _createTypeLayout( return _createTypeLayout(subContext, type); } -RefPtr findGlobalGenericSpecializationArg( +Type* findGlobalGenericSpecializationArg( TypeLayoutContext const& context, GlobalGenericParamDecl* decl) { - RefPtr arg; + Val* arg = nullptr; context.programLayout->globalGenericArgs.TryGetValue(decl, arg); - return arg.as(); + return as(arg); } Index findGlobalGenericSpecializationParamIndex( @@ -2523,7 +2523,7 @@ Index findGlobalGenericSpecializationParamIndex( auto param = type->getSpecializationParam(pp); if(param.flavor != SpecializationParam::Flavor::GenericType) continue; - if(param.object.Ptr() != decl) + if(param.object != decl) continue; return pp; @@ -3128,7 +3128,7 @@ static TypeLayoutResult _createTypeLayout( context, \ ShaderParameterKind::KIND, \ type_##TYPE, \ - type_##TYPE->elementType.Ptr()); \ + type_##TYPE->elementType); \ return TypeLayoutResult(typeLayout, info); \ } while(0) @@ -3257,7 +3257,7 @@ static TypeLayoutResult _createTypeLayout( colStride = minorStride; } - rowTypeLayout->type = type; + rowTypeLayout->type = rowType; rowTypeLayout->rules = rules; rowTypeLayout->uniformAlignment = elementInfo.getUniformLayout().alignment; @@ -3283,7 +3283,7 @@ static TypeLayoutResult _createTypeLayout( { auto elementResult = _createTypeLayout( context, - arrayType->baseType.Ptr()); + arrayType->baseType); auto elementInfo = elementResult.info; auto elementTypeLayout = elementResult.layout; @@ -3463,7 +3463,7 @@ static TypeLayoutResult _createTypeLayout( TypeLayoutResult fieldResult = _createTypeLayout( fieldLayoutContext, - getType(context.astBuilder, field).Ptr(), + getType(context.astBuilder, field), field.getDecl()); auto fieldTypeLayout = fieldResult.layout; @@ -3574,7 +3574,7 @@ static TypeLayoutResult _createTypeLayout( if( context.specializationArgCount ) { auto& specializationArg = context.specializationArgs[0]; - RefPtr concreteType = specializationArg.val.as(); + Type* concreteType = as(specializationArg.val); SLANG_ASSERT(concreteType); RefPtr concreteTypeLayout = createTypeLayout(context, concreteType); @@ -3944,7 +3944,7 @@ RefPtr TypeLayout::unwrapArray() } -RefPtr GenericParamTypeLayout::getGlobalGenericParamDecl() +GlobalGenericParamDecl* GenericParamTypeLayout::getGlobalGenericParamDecl() { auto declRefType = as(type); SLANG_ASSERT(declRefType); -- cgit v1.2.3