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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) 106 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
107 // __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro 107 // __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro
108 #if __GNUC_VERSION__ >= 29600 && __GNUC_VERSION__ < 40100 108 #if __GNUC_VERSION__ >= 29600 && __GNUC_VERSION__ < 40100
109 #include <limits> 109 #include <limits>
110 #undef V8_INFINITY 110 #undef V8_INFINITY
111 #define V8_INFINITY std::numeric_limits<double>::infinity() 111 #define V8_INFINITY std::numeric_limits<double>::infinity()
112 #endif 112 #endif
113 113
114 #endif // __GNUC__ 114 #endif // __GNUC__
115 115
116 #include "atomicops.h"
117
116 namespace v8 { 118 namespace v8 {
117 namespace internal { 119 namespace internal {
118 120
119 // Use AtomicWord for a machine-sized pointer. It is assumed that 121 // Use AtomicWord for a machine-sized pointer. It is assumed that
120 // reads and writes of naturally aligned values of this type are atomic. 122 // reads and writes of naturally aligned values of this type are atomic.
121 typedef intptr_t AtomicWord; 123 typedef intptr_t AtomicWord;
122 124
123 class Semaphore; 125 class Semaphore;
124 126
125 double ceiling(double x); 127 double ceiling(double x);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 431
430 // Locks the given mutex. If the mutex is currently unlocked, it becomes 432 // Locks the given mutex. If the mutex is currently unlocked, it becomes
431 // locked and owned by the calling thread, and immediately. If the mutex 433 // locked and owned by the calling thread, and immediately. If the mutex
432 // is already locked by another thread, suspends the calling thread until 434 // is already locked by another thread, suspends the calling thread until
433 // the mutex is unlocked. 435 // the mutex is unlocked.
434 virtual int Lock() = 0; 436 virtual int Lock() = 0;
435 437
436 // Unlocks the given mutex. The mutex is assumed to be locked and owned by 438 // Unlocks the given mutex. The mutex is assumed to be locked and owned by
437 // the calling thread on entrance. 439 // the calling thread on entrance.
438 virtual int Unlock() = 0; 440 virtual int Unlock() = 0;
441
442 // Tries to lock the given mutex. Returns whether the mutex was
443 // successfully locked.
444 virtual bool TryLock() = 0;
439 }; 445 };
440 446
441 447
442 // ---------------------------------------------------------------------------- 448 // ----------------------------------------------------------------------------
443 // ScopedLock 449 // ScopedLock/ScopedUnlock
444 // 450 //
445 // Stack-allocated ScopedLocks provide block-scoped locking and unlocking 451 // Stack-allocated ScopedLocks/ScopedUnlocks provide block-scoped
446 // of a mutex. 452 // locking and unlocking of a mutex.
447 class ScopedLock { 453 class ScopedLock {
448 public: 454 public:
449 explicit ScopedLock(Mutex* mutex): mutex_(mutex) { 455 explicit ScopedLock(Mutex* mutex): mutex_(mutex) {
456 ASSERT(mutex_ != NULL);
450 mutex_->Lock(); 457 mutex_->Lock();
451 } 458 }
452 ~ScopedLock() { 459 ~ScopedLock() {
453 mutex_->Unlock(); 460 mutex_->Unlock();
454 } 461 }
455 462
456 private: 463 private:
457 Mutex* mutex_; 464 Mutex* mutex_;
458 DISALLOW_COPY_AND_ASSIGN(ScopedLock); 465 DISALLOW_COPY_AND_ASSIGN(ScopedLock);
459 }; 466 };
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 Address function; // The last called JS function. 557 Address function; // The last called JS function.
551 static const int kMaxFramesCount = 64; 558 static const int kMaxFramesCount = 64;
552 Address stack[kMaxFramesCount]; // Call stack. 559 Address stack[kMaxFramesCount]; // Call stack.
553 int frames_count; // Number of captured frames. 560 int frames_count; // Number of captured frames.
554 }; 561 };
555 562
556 #ifdef ENABLE_LOGGING_AND_PROFILING 563 #ifdef ENABLE_LOGGING_AND_PROFILING
557 class Sampler { 564 class Sampler {
558 public: 565 public:
559 // Initialize sampler. 566 // Initialize sampler.
560 Sampler(Isolate* isolate, int interval, bool profiling); 567 Sampler(Isolate* isolate, int interval);
561 virtual ~Sampler(); 568 virtual ~Sampler();
562 569
570 int interval() const { return interval_; }
571
563 // Performs stack sampling. 572 // Performs stack sampling.
564 void SampleStack(TickSample* sample) { 573 void SampleStack(TickSample* sample) {
565 DoSampleStack(sample); 574 DoSampleStack(sample);
566 IncSamplesTaken(); 575 IncSamplesTaken();
567 } 576 }
568 577
569 // This method is called for each sampling period with the current 578 // This method is called for each sampling period with the current
570 // program counter. 579 // program counter.
571 virtual void Tick(TickSample* sample) = 0; 580 virtual void Tick(TickSample* sample) = 0;
572 581
573 // Start and stop sampler. 582 // Start and stop sampler.
574 void Start(); 583 void Start();
575 void Stop(); 584 void Stop();
576 585
577 // Is the sampler used for profiling? 586 // Is the sampler used for profiling?
578 bool IsProfiling() const { return profiling_; } 587 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; }
579 588 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
580 // Is the sampler running in sync with the JS thread? On platforms 589 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
581 // where the sampler is implemented with a thread that wakes up
582 // every now and then, having a synchronous sampler implies
583 // suspending/resuming the JS thread.
584 bool IsSynchronous() const { return synchronous_; }
585 590
586 // Whether the sampler is running (that is, consumes resources). 591 // Whether the sampler is running (that is, consumes resources).
587 bool IsActive() const { return active_; } 592 bool IsActive() const { return NoBarrier_Load(&active_); }
588 593
589 Isolate* isolate() { return isolate_; } 594 Isolate* isolate() { return isolate_; }
590 595
591 // Used in tests to make sure that stack sampling is performed. 596 // Used in tests to make sure that stack sampling is performed.
592 int samples_taken() const { return samples_taken_; } 597 int samples_taken() const { return samples_taken_; }
593 void ResetSamplesTaken() { samples_taken_ = 0; } 598 void ResetSamplesTaken() { samples_taken_ = 0; }
594 599
595 class PlatformData; 600 class PlatformData;
596 601
602 PlatformData* platform_data() { return data_; }
603
597 protected: 604 protected:
598 virtual void DoSampleStack(TickSample* sample) = 0; 605 virtual void DoSampleStack(TickSample* sample) = 0;
599 606
600 private: 607 private:
601 Isolate* isolate_; 608 void SetActive(bool value) { NoBarrier_Store(&active_, value); }
602
603 void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; } 609 void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; }
604 610
611 Isolate* isolate_;
605 const int interval_; 612 const int interval_;
606 const bool synchronous_; 613 Atomic32 profiling_;
607 const bool profiling_; 614 Atomic32 active_;
608 bool active_;
609 PlatformData* data_; // Platform specific data. 615 PlatformData* data_; // Platform specific data.
610 int samples_taken_; // Counts stack samples taken. 616 int samples_taken_; // Counts stack samples taken.
611 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 617 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
612 }; 618 };
613 619
620
614 #endif // ENABLE_LOGGING_AND_PROFILING 621 #endif // ENABLE_LOGGING_AND_PROFILING
615 622
616 } } // namespace v8::internal 623 } } // namespace v8::internal
617 624
618 #endif // V8_PLATFORM_H_ 625 #endif // V8_PLATFORM_H_
OLDNEW
« 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