Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: src/platform.h

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform.h
diff --git a/src/platform.h b/src/platform.h
index a9fd3ba9f3fb2318d842704911453232105e1e37..134acf6b2f6a88111650650ca9d1d061dcd69fd9 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -113,6 +113,8 @@ int signbit(double x);
#endif // __GNUC__
+#include "atomicops.h"
+
namespace v8 {
namespace internal {
@@ -436,17 +438,22 @@ class Mutex {
// Unlocks the given mutex. The mutex is assumed to be locked and owned by
// the calling thread on entrance.
virtual int Unlock() = 0;
+
+ // Tries to lock the given mutex. Returns whether the mutex was
+ // successfully locked.
+ virtual bool TryLock() = 0;
};
// ----------------------------------------------------------------------------
-// ScopedLock
+// ScopedLock/ScopedUnlock
//
-// Stack-allocated ScopedLocks provide block-scoped locking and unlocking
-// of a mutex.
+// Stack-allocated ScopedLocks/ScopedUnlocks provide block-scoped
+// locking and unlocking of a mutex.
class ScopedLock {
public:
explicit ScopedLock(Mutex* mutex): mutex_(mutex) {
+ ASSERT(mutex_ != NULL);
mutex_->Lock();
}
~ScopedLock() {
@@ -557,9 +564,11 @@ class TickSample {
class Sampler {
public:
// Initialize sampler.
- Sampler(Isolate* isolate, int interval, bool profiling);
+ Sampler(Isolate* isolate, int interval);
virtual ~Sampler();
+ int interval() const { return interval_; }
+
// Performs stack sampling.
void SampleStack(TickSample* sample) {
DoSampleStack(sample);
@@ -575,16 +584,12 @@ class Sampler {
void Stop();
// Is the sampler used for profiling?
- bool IsProfiling() const { return profiling_; }
-
- // Is the sampler running in sync with the JS thread? On platforms
- // where the sampler is implemented with a thread that wakes up
- // every now and then, having a synchronous sampler implies
- // suspending/resuming the JS thread.
- bool IsSynchronous() const { return synchronous_; }
+ bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; }
+ void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
+ void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
// Whether the sampler is running (that is, consumes resources).
- bool IsActive() const { return active_; }
+ bool IsActive() const { return NoBarrier_Load(&active_); }
Isolate* isolate() { return isolate_; }
@@ -594,23 +599,25 @@ class Sampler {
class PlatformData;
+ PlatformData* platform_data() { return data_; }
+
protected:
virtual void DoSampleStack(TickSample* sample) = 0;
private:
- Isolate* isolate_;
-
+ void SetActive(bool value) { NoBarrier_Store(&active_, value); }
void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; }
+ Isolate* isolate_;
const int interval_;
- const bool synchronous_;
- const bool profiling_;
- bool active_;
+ Atomic32 profiling_;
+ Atomic32 active_;
PlatformData* data_; // Platform specific data.
int samples_taken_; // Counts stack samples taken.
DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
};
+
#endif // ENABLE_LOGGING_AND_PROFILING
} } // namespace v8::internal
« no previous file with comments | « src/parser.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698