Avoid hidden TLS access in CpuProfiler::is_profiling().

Review URL: http://codereview.chromium.org/6895014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7677 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vitalyr@chromium.org 2011-04-22 06:40:22 +00:00
parent 75cfdf24e1
commit bde82b06c0
5 changed files with 24 additions and 21 deletions

View File

@ -176,7 +176,10 @@ static Vector<const char> kRegexp = CStrVector("regexp");
bool CodeGenerator::ShouldGenerateLog(Expression* type) { bool CodeGenerator::ShouldGenerateLog(Expression* type) {
ASSERT(type != NULL); ASSERT(type != NULL);
if (!LOGGER->is_logging() && !CpuProfiler::is_profiling()) return false; Isolate* isolate = Isolate::Current();
if (!isolate->logger()->is_logging() && !CpuProfiler::is_profiling(isolate)) {
return false;
}
Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle()); Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle());
if (FLAG_log_regexp) { if (FLAG_log_regexp) {
if (name->IsEqualTo(kRegexp)) if (name->IsEqualTo(kRegexp))

View File

@ -767,7 +767,8 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
// Log the code generation. If source information is available include // Log the code generation. If source information is available include
// script name and line number. Check explicitly whether logging is // script name and line number. Check explicitly whether logging is
// enabled as finding the line number is not free. // enabled as finding the line number is not free.
if (info->isolate()->logger()->is_logging() || CpuProfiler::is_profiling()) { if (info->isolate()->logger()->is_logging() ||
CpuProfiler::is_profiling(info->isolate())) {
Handle<Script> script = info->script(); Handle<Script> script = info->script();
Handle<Code> code = info->code(); Handle<Code> code = info->code();
if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile)) if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))

View File

@ -288,14 +288,16 @@ void CpuProfiler::StartProfiling(String* title) {
CpuProfile* CpuProfiler::StopProfiling(const char* title) { CpuProfile* CpuProfiler::StopProfiling(const char* title) {
return is_profiling() ? Isolate* isolate = Isolate::Current();
Isolate::Current()->cpu_profiler()->StopCollectingProfile(title) : NULL; return is_profiling(isolate) ?
isolate->cpu_profiler()->StopCollectingProfile(title) : NULL;
} }
CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) { CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
return is_profiling() ? Isolate* isolate = Isolate::Current();
Isolate::Current()->cpu_profiler()->StopCollectingProfile( return is_profiling(isolate) ?
isolate->cpu_profiler()->StopCollectingProfile(
security_token, title) : NULL; security_token, title) : NULL;
} }
@ -336,8 +338,9 @@ TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) {
void CpuProfiler::DeleteAllProfiles() { void CpuProfiler::DeleteAllProfiles() {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
ASSERT(isolate->cpu_profiler() != NULL); ASSERT(isolate->cpu_profiler() != NULL);
if (is_profiling()) if (is_profiling(isolate)) {
isolate->cpu_profiler()->StopProcessor(); isolate->cpu_profiler()->StopProcessor();
}
isolate->cpu_profiler()->ResetProfiles(); isolate->cpu_profiler()->ResetProfiles();
} }

View File

@ -197,12 +197,12 @@ class ProfilerEventsProcessor : public Thread {
} } // namespace v8::internal } } // namespace v8::internal
#define PROFILE(isolate, Call) \ #define PROFILE(isolate, Call) \
LOG(isolate, Call); \ LOG(isolate, Call); \
do { \ do { \
if (v8::internal::CpuProfiler::is_profiling()) { \ if (v8::internal::CpuProfiler::is_profiling(isolate)) { \
v8::internal::CpuProfiler::Call; \ v8::internal::CpuProfiler::Call; \
} \ } \
} while (false) } while (false)
#else #else
#define PROFILE(isolate, Call) LOG(isolate, Call) #define PROFILE(isolate, Call) LOG(isolate, Call)
@ -261,10 +261,6 @@ class CpuProfiler {
// TODO(isolates): this doesn't have to use atomics anymore. // TODO(isolates): this doesn't have to use atomics anymore.
static INLINE(bool is_profiling()) {
return is_profiling(Isolate::Current());
}
static INLINE(bool is_profiling(Isolate* isolate)) { static INLINE(bool is_profiling(Isolate* isolate)) {
CpuProfiler* profiler = isolate->cpu_profiler(); CpuProfiler* profiler = isolate->cpu_profiler();
return profiler != NULL && NoBarrier_Load(&profiler->is_profiling_); return profiler != NULL && NoBarrier_Load(&profiler->is_profiling_);
@ -292,7 +288,7 @@ class CpuProfiler {
Atomic32 is_profiling_; Atomic32 is_profiling_;
#else #else
static INLINE(bool is_profiling()) { return false; } static INLINE(bool is_profiling(Isolate* isolate)) { return false; }
#endif // ENABLE_LOGGING_AND_PROFILING #endif // ENABLE_LOGGING_AND_PROFILING
private: private:

View File

@ -1347,7 +1347,7 @@ class ScavengingVisitor : public StaticVisitorBase {
#if defined(ENABLE_LOGGING_AND_PROFILING) #if defined(ENABLE_LOGGING_AND_PROFILING)
Isolate* isolate = heap->isolate(); Isolate* isolate = heap->isolate();
if (isolate->logger()->is_logging() || if (isolate->logger()->is_logging() ||
isolate->cpu_profiler()->is_profiling()) { CpuProfiler::is_profiling(isolate)) {
if (target->IsSharedFunctionInfo()) { if (target->IsSharedFunctionInfo()) {
PROFILE(isolate, SharedFunctionInfoMoveEvent( PROFILE(isolate, SharedFunctionInfoMoveEvent(
source->address(), target->address())); source->address(), target->address()));
@ -1522,8 +1522,8 @@ void Heap::SwitchScavengingVisitorsTableIfProfilingWasEnabled() {
return; return;
} }
if (isolate()->logger()->is_logging() || if (isolate()->logger()->is_logging() |
isolate()->cpu_profiler()->is_profiling() || CpuProfiler::is_profiling(isolate()) ||
(isolate()->heap_profiler() != NULL && (isolate()->heap_profiler() != NULL &&
isolate()->heap_profiler()->is_profiling())) { isolate()->heap_profiler()->is_profiling())) {
// If one of the isolates is doing scavenge at this moment of time // If one of the isolates is doing scavenge at this moment of time