Index: vm/port/src/lil/ia32/pim/m2n_ia32.cpp =================================================================== --- vm/port/src/lil/ia32/pim/m2n_ia32.cpp (revision 569233) +++ vm/port/src/lil/ia32/pim/m2n_ia32.cpp (working copy) @@ -21,6 +21,7 @@ #include "open/types.h" #include "open/hythread.h" +#include "open/thread_helpers.h" #include "m2n.h" #include "m2n_ia32_internal.h" @@ -170,22 +171,33 @@ return 22; } + +// ashipile: fast TLS get generator char* m2n_gen_ts_to_register(char* buf, R_Opnd* reg) { + unsigned offset = + (unsigned) &(((HyThread_public *) (0))->thread_local_storage[0]); + +// Trap for the debugger +// buf = int3(buf); + if (reg!=&eax_opnd) buf = push(buf, eax_opnd); - buf = push(buf, ecx_opnd); - buf = push(buf, edx_opnd); - buf = call(buf, (char *)get_thread_ptr); - buf = pop(buf, edx_opnd); - buf = pop(buf, ecx_opnd); + + // get hythr tls in eax + buf = gen_hythread_self_helper(buf); + + // get vm_thread TLS from hythr + buf = mov(buf, *reg, M_Base_Opnd(eax_reg, offset)); + assert(buf); + if (reg!=&eax_opnd) { - buf = mov(buf, *reg, eax_opnd); buf = pop(buf, eax_opnd); } return buf; } + unsigned m2n_push_m2n_size(bool UNREF handles, unsigned num_callee_saves) { return 20+(4-num_callee_saves)+m2n_ts_to_register_size()+11+8;