Re: cvs: ZendEngine2(PHP_5_3) / zend.h zend_ptr_stack.h zend_types.h zend_vm_def.h zend_vm_execute.h

"Nuno Lopes" <[email protected]> Wed, 3 Jun 2009 22:11:29 +0100
Newsgroups gmane.comp.php.cvs.zend
Message-ID <C8CDE96FFAA948019026B2DAC062D33B@PC3EE1F19287>
>> So I'm not particularly happy this solution. First it relies on gcc: the
>> code is still broken for other compilers following C99 strict aliasing
>> rules.
>> Second you're using may_alias and restrict at the same time, which have
>> opposite meanings. They refer to different pointers, but it's still
>> confusing.
>
> may_alias means a particular type can alias any other type (like char
> does)
> restrict means a particular variable cannot be accessed through other
> variables in the current scope/block.
>
> So I used restrict to cancel the performance effect of may_alias on the
> function's code.

exactly my point: it's very confusing :)
The interplay of two variables with these two attributes is also tricky.


>> As these functions are only called from 2 sites, I think fixing the 
>> function
>> signature to the right types is the right solution.
>
> I agree, however there is some other potential problems that may need to
> be fixed, and which will not be fixable in this way.

like what? I haven't checked the code, but what are the other potential 
problems?


> So this fix is an attempt to do something generic and useable for other
> cases. I found this solution not too bad as this is still a pointer type
> which can be assigned to (as opposed to using a char type), and it is
> compatible with the original type.
>
> As you pointed, may_alias is gcc-specific, but is there other compiler
> with this level of strictness without such attribute ?

I don't know. I know that at least ICC and suncc have strict aliasing 
analysis, but I dunno what's their support for these attributes (or if they 
will be detected as gcc by the configure script).

Nuno 


-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php