Commit bde82b06 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

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
parent 75cfdf24
......@@ -176,7 +176,10 @@ static Vector<const char> kRegexp = CStrVector("regexp");
bool CodeGenerator::ShouldGenerateLog(Expression* type) {
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());
if (FLAG_log_regexp) {
if (name->IsEqualTo(kRegexp))
......
......@@ -767,7 +767,8 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
// Log the code generation. If source information is available include
// script name and line number. Check explicitly whether logging is
// 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<Code> code = info->code();
if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))
......
......@@ -288,14 +288,16 @@ void CpuProfiler::StartProfiling(String* title) {
CpuProfile* CpuProfiler::StopProfiling(const char* title) {
return is_profiling() ?
Isolate::Current()->cpu_profiler()->StopCollectingProfile(title) : NULL;
Isolate* isolate = Isolate::Current();
return is_profiling(isolate) ?
isolate->cpu_profiler()->StopCollectingProfile(title) : NULL;
}
CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
return is_profiling() ?
Isolate::Current()->cpu_profiler()->StopCollectingProfile(
Isolate* isolate = Isolate::Current();
return is_profiling(isolate) ?
isolate->cpu_profiler()->StopCollectingProfile(
security_token, title) : NULL;
}
......@@ -336,8 +338,9 @@ TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) {
void CpuProfiler::DeleteAllProfiles() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate->cpu_profiler() != NULL);
if (is_profiling())
if (is_profiling(isolate)) {
isolate->cpu_profiler()->StopProcessor();
}
isolate->cpu_profiler()->ResetProfiles();
}
......
......@@ -197,12 +197,12 @@ class ProfilerEventsProcessor : public Thread {
} } // namespace v8::internal
#define PROFILE(isolate, Call) \
LOG(isolate, Call); \
do { \
if (v8::internal::CpuProfiler::is_profiling()) { \
v8::internal::CpuProfiler::Call; \
} \
#define PROFILE(isolate, Call) \
LOG(isolate, Call); \
do { \
if (v8::internal::CpuProfiler::is_profiling(isolate)) { \
v8::internal::CpuProfiler::Call; \
} \
} while (false)
#else
#define PROFILE(isolate, Call) LOG(isolate, Call)
......@@ -261,10 +261,6 @@ class CpuProfiler {
// 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)) {
CpuProfiler* profiler = isolate->cpu_profiler();
return profiler != NULL && NoBarrier_Load(&profiler->is_profiling_);
......@@ -292,7 +288,7 @@ class CpuProfiler {
Atomic32 is_profiling_;
#else
static INLINE(bool is_profiling()) { return false; }
static INLINE(bool is_profiling(Isolate* isolate)) { return false; }
#endif // ENABLE_LOGGING_AND_PROFILING
private:
......
......@@ -1347,7 +1347,7 @@ class ScavengingVisitor : public StaticVisitorBase {
#if defined(ENABLE_LOGGING_AND_PROFILING)
Isolate* isolate = heap->isolate();
if (isolate->logger()->is_logging() ||
isolate->cpu_profiler()->is_profiling()) {
CpuProfiler::is_profiling(isolate)) {
if (target->IsSharedFunctionInfo()) {
PROFILE(isolate, SharedFunctionInfoMoveEvent(
source->address(), target->address()));
......@@ -1522,8 +1522,8 @@ void Heap::SwitchScavengingVisitorsTableIfProfilingWasEnabled() {
return;
}
if (isolate()->logger()->is_logging() ||
isolate()->cpu_profiler()->is_profiling() ||
if (isolate()->logger()->is_logging() |
CpuProfiler::is_profiling(isolate()) ||
(isolate()->heap_profiler() != NULL &&
isolate()->heap_profiler()->is_profiling())) {
// If one of the isolates is doing scavenge at this moment of time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment