On 12/03/2019 17:22, Vlad Khorsun wrote:

>>
>> Let me demonstrate it. With this (wrong) patch now the code compiles:
>>
>> --------------
>> diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp
>> index 4ff5253a2b..26f826ae09 100644
>> --- a/src/dsql/ExprNodes.cpp
>> +++ b/src/dsql/ExprNodes.cpp
>> @@ -10836,6 +10836,7 @@ void SubQueryNode::getChildren(NodeRefsHolder&
>> holder, bool dsql) const
>>            holder.add(value1);
>>          holder.add(value2);
>> +       holder.add(test);
>>   }
>>     string SubQueryNode::internalPrint(NodePrinter& printer) const
>> diff --git a/src/dsql/ExprNodes.h b/src/dsql/ExprNodes.h
>> index 3478e4056b..38469e826e 100644
>> --- a/src/dsql/ExprNodes.h
>> +++ b/src/dsql/ExprNodes.h
>> @@ -1860,6 +1860,7 @@ public:
>>          NestConst<ValueExprNode> value1;
>>          NestConst<ValueExprNode> value2;
>>          NestConst<SubQuery> subQuery;
>> +       NestConst<CastNode> test;
>>   };
>> --------------
>>
>> While previously it correctly detected the problem, as a specialized
>> node cannot become some other node not inherited from it.
> 
>   Please, define "specialized node". I assumed it is descendants of the
> ExprNode, but it seems it is not enough. What makes node "specialized" ?
> 
> ...

As the code demonstrate, "NestConst<CastNode> test" should always point
to a CastNode (or a possible descendant). CastNode::pass1 currently
returns this (a CastNode, but doesn't matter), but it declares return
type as ValueExprNode so it can return other things that is not a
CastNode descendant. Some other nodes does that.

And if does that, "NestConst<CastNode> test" will point to a wrong thing
without the compiler detect when doPass1 (or pass2, remap, etc) is
called. NodeRefImpl was there to detect that wrong cases.


>> If the change really increases performance, then I suppose it should be
>> conditionally defined based on DEBUG build, so debug could use NodeRef
>> with virtual method and NodeRefImpl, and release something like
>> currently (non-virtual method and no NodeRefImpl usage).
> 
>   According to profiler, new\delete of NodeRefImpl takes near 28% of
> request compilation time.
> 

It's should be possible to rewrite the code to have the checks and avoid
the performance problem.


Adriano


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to