« first day (1528 days earlier)      last day (3414 days later) » 

10:00 PM
@NikiC Why wouldn't const zend_string foobar = { "blah", 2 }; or something similar work?
 
strip C++, but I'd be impressed too if you find a way which works in C89. @AndreaFaulds
 
@JoeWatkins well then I'd have dead code that was untestable
 
@AndreaFaulds Because of the struct hack
 
@NikiC Ohh, right.
 
#define ZEND_STRING_CT(str) \
    (zend_string *) (struct { \
        uint32_t refcount; uint32_t type_info; \
        zend_ulong h; size_t len; \
        char val[sizeof(str)]; \
    }[1]) {{ 1, IS_STRING | (IS_STR_PERSISTENT << 8), 0, sizeof(str)-1, str }}
@AndreaFaulds ^-- that's the best I came up with, using C99 compound literals
 
10:03 PM
@NikiC please use good names... CT?
 
compound literals?
 
@ircmaxell Every kid knows CT means compile time :P
 
ed-zachery
or compiler toolkit
 
@ircmaxell in code context like php-src, CT is compile timeā€¦
 
@ircmaxell And WTF means Web Template Framework, yes
 
10:05 PM
@bwoebi
 
#define ZEND_STRING_CT(name, str) \
    struct { \
        uint32_t refcount; uint32_t type_info; \
        zend_ulong h; size_t len; \
        char val[sizeof(str)]; \
    } name = {1, IS_STRING | (IS_STR_PERSISTENT << 8), 0, sizeof(str)-1, str };
Is there some reason that wouldn't work?
 
@AndreaFaulds sadly that isn't enough for the most interesting case
 
@NikiC hm?
 
Not suitable for use in globals
 
OK, why not?
 
10:08 PM
(name) =...
 
?
It can't go in a struct
But it can be a constant
Right?
 
and then you can define it after the struct initialization
 
@ircmaxell You mean like CG(foobar) = &foobar_ct; ?
 
no, as in when you're initializing compiler globals, you can't define it in the initialization, but you can after
 
@AndreaFaulds Basically the question is: Where would you use that?
Your suggestion has the same limitations as STR_ALLOCA_ALLOC
 
10:12 PM
there are a few places where having literals defined would be nice
 
@NikiC to define a constant like "__toString", say
 
@AndreaFaulds Where?
 
Or really, to replace any constant string in sourcecode
@NikiC in a header maybe, at the top of a file...
 
You mean you want to make that structure a global?
 
Or static.
 
10:13 PM
Basically save an explicit string alloc in minit?
 
Right, save a function call
"foo" vs strdup("foo").
 
#define ZEND_STRING_CT(name, str) \
    static struct { \
        uint32_t refcount; uint32_t type_info; \
        zend_ulong h; size_t len; \
        char val[sizeof(str)]; \
    } name#_val = {1, IS_STRING | (IS_STR_PERSISTENT << 8), 0, sizeof(str)-1, str };
    static zend_string *name = (zend_string *) &name#_val;
 
@NikiC Yes, that.
Perhaps with a few consts :)
 
yes, that would work to save the explicit alloc for global strings
 
10:17 PM
But still doesn't solve the function-name/arg-name/ini-name problem :(
 
@NikiC Why not?
Ooh, ooh, I know.
Cheat.
Replace char val with a union of a value or a const char *
 
@AndreaFaulds that doesn't make sense
 
@NikiC It doesn't?
 
one is an embedded string, the other is a pointer to a string. They are incompatible
 
Yep.
You'd have to make zend_string be able to handle it
 
10:22 PM
@AndreaFaulds ...
 
which might hurt performance a bit, hmm...
OH.
I got it. It introduces a little indirection, but...
Redefine val to be a char*. For most zend_strings it points immediately beyond the struct. For constants it points to a string literal.
It'd work, but the performance price might not be worth paying.
 
and also memory usage, would be an extra 8 bytes per string
 
Yeah, an extra 8 bytes per string
 
:D
 
On the other hand
We also save a bit of memory from all those allocs we don't need to do now ^^
I can already hear Dmitry screaming.
It wouldn't be perfectly compatible ofc, since &str->val is now wrong and people abusing knowledge of the memory layout of zend_string would have problems.
kinda tempted to try it and see what breaks
 
11:31 PM
time make -j16 <-- 53 seconds...
 
MUCH cleaner in 7... Thanks @NikiC for the HashTable goodness: github.com/ircmaxell/php-src/compare/function-autoloading-7
 
Oh, great, you're reviving it
Hmm
 
not sure about globals, if they should be hash tables, or pointers... I like the lack of additional allocations needed for hash tables tho...
 
I could compete, or I could give up.
Neither feels particularly good.
I suppose my patch has the advantage of already working
 
11:39 PM
@AndreaFaulds can you explain?
 
@ircmaxell Well if I give up on my patch, I've wasted effort. If I don't, I'm wasting more effort as there's zero chance mine would win out, as it were.
 
collaborate
 
Alright, what can I do to help?
My patch covered all the places EG(functions_table) is searched
@ircmaxell By the way, your editor is producing spaces instead of tabs :/
 
I know
 
Would HT_MOVE_TAIL_TO_HEAD have any application beyond autoloading?
 
11:49 PM
I don't know
good question
 
What're you currently working on in the patch? I'd integrate my patch into yours so functions work, if you like.
Also, why'd you remove the validation of class name characters? Is that unimportant for some reason? I think that's there to prevent you doing $foo = "../blah"; new $foo();
(though I'm honestly unsure)
(sorry to badger you so)
 

« first day (1528 days earlier)      last day (3414 days later) »