Currently PROFILER_MAIN_THREAD_LABEL is implemented as an assert that it really is on the main thread THEN it falls back to the non main thread. We should implement it to properly avoid the TLS lookup and replace PROFILER_LABEL where we can easily confirm that this code is main thread only (most of gecko/layout code). http://mxr.mozilla.org/mozilla-central/source/tools/profiler/GeckoProfilerImpl.h#233
If we call PROFILER_MAIN_THREAD_LABEL() in non-main-thread with release build, it stills save the data into TLS PseudoStack. Is my thought right? Should we assert when we call PROFILER_MAIN_THREAD_LABEL() in non-main-thread?
If we avoid the TLS and add this on the wrong thread then we'll be modifying the wrong thread' state and exposing ourself to data races. An assertion should be enough here.
Hi Benwa, In mozilla_sampler_init(), http://dxr.mozilla.org/mozilla-central/source/tools/profiler/platform.cpp#440 if we pass tls and non-tls pseudo stack to RegisterCurrentThread(), we also need to modify all series of profiler related function into two version(tls and non-tls version). For example, we should modify the set_tls_stack_top() function in RegisterCurrentThread() into two version. Is it true?