Branch: Tag:


2014-07-21 13:01:44 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.

861:   struct callback;   PMOD_EXPORT extern struct callback_list evaluator_callbacks;    - /* Things to try: -  * we could reduce thread swapping to a pointer operation if -  * we do something like: -  * #define Pike_interpreter (*Pike_interpreter_pointer) -  * -  * Since global variables are usually accessed through indirection -  * anyways, it might not make any speed differance. -  * -  * The above define could also be used to facilitate dynamic loading -  * on Win32.. -  */ - PMOD_EXPORT extern struct Pike_interpreter_struct *Pike_interpreter_pointer; + PMOD_EXPORT extern struct Pike_interpreter_struct * + #ifndef IN_THREAD_CODE +  const + #endif +  Pike_interpreter_pointer;   #define Pike_interpreter (*Pike_interpreter_pointer)      #define Pike_sp Pike_interpreter.stack_pointer