Index: src/cpu-profiler.h |
=================================================================== |
--- src/cpu-profiler.h (revision 7267) |
+++ src/cpu-profiler.h (working copy) |
@@ -133,7 +133,8 @@ |
// methods called by event producers: VM and stack sampler threads. |
class ProfilerEventsProcessor : public Thread { |
public: |
- explicit ProfilerEventsProcessor(ProfileGenerator* generator); |
+ explicit ProfilerEventsProcessor(Isolate* isolate, |
+ ProfileGenerator* generator); |
virtual ~ProfilerEventsProcessor() {} |
// Thread control. |
@@ -196,21 +197,23 @@ |
} } // namespace v8::internal |
-#define PROFILE(Call) \ |
- LOG(Call); \ |
+#define PROFILE(isolate, Call) \ |
+ LOG(isolate, Call); \ |
do { \ |
if (v8::internal::CpuProfiler::is_profiling()) { \ |
v8::internal::CpuProfiler::Call; \ |
} \ |
} while (false) |
#else |
-#define PROFILE(Call) LOG(Call) |
+#define PROFILE(isolate, Call) LOG(isolate, Call) |
#endif // ENABLE_LOGGING_AND_PROFILING |
namespace v8 { |
namespace internal { |
+ |
+// TODO(isolates): isolatify this class. |
class CpuProfiler { |
public: |
static void Setup(); |
@@ -226,7 +229,7 @@ |
static CpuProfile* FindProfile(Object* security_token, unsigned uid); |
// Invoked from stack sampler (thread or signal handler.) |
- static TickSample* TickSampleEvent(); |
+ static TickSample* TickSampleEvent(Isolate* isolate); |
// Must be called via PROFILE macro, otherwise will crash when |
// profiling is not enabled. |
@@ -253,10 +256,17 @@ |
static void SetterCallbackEvent(String* name, Address entry_point); |
static void SharedFunctionInfoMoveEvent(Address from, Address to); |
+ // TODO(isolates): this doesn't have to use atomics anymore. |
+ |
static INLINE(bool is_profiling()) { |
- return NoBarrier_Load(&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_); |
+ } |
+ |
private: |
CpuProfiler(); |
~CpuProfiler(); |
@@ -273,10 +283,8 @@ |
ProfileGenerator* generator_; |
ProfilerEventsProcessor* processor_; |
int saved_logging_nesting_; |
+ Atomic32 is_profiling_; |
- static CpuProfiler* singleton_; |
- static Atomic32 is_profiling_; |
- |
#else |
static INLINE(bool is_profiling()) { return false; } |
#endif // ENABLE_LOGGING_AND_PROFILING |