Branch: Tag:


2014-12-04 19:26:52 by Per Hedbor <>

Merged the const-marked pike_interpreter_pointer branch.

We now lie to the compiler about the const:ness of the
Pike_interpreter_pointer variable.

Most code now pretends that that variable is constant (it's not,
really, it's constant /per thread/, but not globally, however, the
only code that writes to it and expects anything but the same value
each time it is read is in thread.c)

This saves a lot of code when using the stack multiple times in a
function, and should be safe enough, albeit somewhat unconventional.

If nothing else the binary size shrunk by about 5%.

This _will_ cause issues if pike is compiled with link-time
optimization. A better solution would be an actual thread local
pointer, which is const marked. Or, perhaps the best solution, having
the whole pike_interpreter_struct structure be thread local. At least
on x86_64 accessing thread-local data is just about as fast as
accessing global data.

18:   /* #define PROFILE_CHECK_THREADS */      #ifndef CONFIGURE_TEST -  + #define IN_THREAD_CODE   #include "threads.h"   #include "array.h"   #include "mapping.h"
54:   #include <time.h>   #endif    + /* This is used for strapping the interpreter before the threads +  * are loaded, and when there's no support for threads. +  */ + static struct Pike_interpreter_struct static_pike_interpreter; +  + PMOD_EXPORT struct Pike_interpreter_struct *Pike_interpreter_pointer = +  &static_pike_interpreter; +    #else /* CONFIGURE_TEST */   #include "pike_threadlib.h"   #endif