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

Side by Side Diff: src/log.cc

Issue 23420004: Make sure semaphore used in Profiler is deleted (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 553
554 if (Succ(head_) == tail_) { 554 if (Succ(head_) == tail_) {
555 overflow_ = true; 555 overflow_ = true;
556 } else { 556 } else {
557 buffer_[head_] = *sample; 557 buffer_[head_] = *sample;
558 head_ = Succ(head_); 558 head_ = Succ(head_);
559 buffer_semaphore_->Signal(); // Tell we have an element. 559 buffer_semaphore_->Signal(); // Tell we have an element.
560 } 560 }
561 } 561 }
562 562
563 virtual void Run();
564
565 // Pause and Resume TickSample data collection.
566 bool paused() const { return paused_; }
567 void pause() { paused_ = true; }
568 void resume() { paused_ = false; }
569
570 private:
563 // Waits for a signal and removes profiling data. 571 // Waits for a signal and removes profiling data.
564 bool Remove(TickSample* sample) { 572 bool Remove(TickSample* sample) {
565 buffer_semaphore_->Wait(); // Wait for an element. 573 buffer_semaphore_->Wait(); // Wait for an element.
566 *sample = buffer_[tail_]; 574 *sample = buffer_[tail_];
567 bool result = overflow_; 575 bool result = overflow_;
568 tail_ = Succ(tail_); 576 tail_ = Succ(tail_);
569 overflow_ = false; 577 overflow_ = false;
570 return result; 578 return result;
571 } 579 }
572 580
573 void Run();
574
575 // Pause and Resume TickSample data collection.
576 bool paused() const { return paused_; }
577 void pause() { paused_ = true; }
578 void resume() { paused_ = false; }
579
580 private:
581 // Returns the next index in the cyclic buffer. 581 // Returns the next index in the cyclic buffer.
582 int Succ(int index) { return (index + 1) % kBufferSize; } 582 int Succ(int index) { return (index + 1) % kBufferSize; }
583 583
584 Isolate* isolate_; 584 Isolate* isolate_;
585 // Cyclic buffer for communicating profiling samples 585 // Cyclic buffer for communicating profiling samples
586 // between the signal handler and the worker thread. 586 // between the signal handler and the worker thread.
587 static const int kBufferSize = 128; 587 static const int kBufferSize = 128;
588 TickSample buffer_[kBufferSize]; // Buffer storage. 588 TickSample buffer_[kBufferSize]; // Buffer storage.
589 int head_; // Index to the buffer head. 589 int head_; // Index to the buffer head.
590 int tail_; // Index to the buffer tail. 590 int tail_; // Index to the buffer tail.
591 bool overflow_; // Tell whether a buffer overflow has occurred. 591 bool overflow_; // Tell whether a buffer overflow has occurred.
592 Semaphore* buffer_semaphore_; // Sempahore used for buffer synchronization. 592 // Sempahore used for buffer synchronization.
593 SmartPointer<Semaphore> buffer_semaphore_;
593 594
594 // Tells whether profiler is engaged, that is, processing thread is stated. 595 // Tells whether profiler is engaged, that is, processing thread is stated.
595 bool engaged_; 596 bool engaged_;
596 597
597 // Tells whether worker thread should continue running. 598 // Tells whether worker thread should continue running.
598 bool running_; 599 bool running_;
599 600
600 // Tells whether we are currently recording tick samples. 601 // Tells whether we are currently recording tick samples.
601 bool paused_; 602 bool paused_;
602 }; 603 };
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 if (jit_logger_) { 1950 if (jit_logger_) {
1950 removeCodeEventListener(jit_logger_); 1951 removeCodeEventListener(jit_logger_);
1951 delete jit_logger_; 1952 delete jit_logger_;
1952 jit_logger_ = NULL; 1953 jit_logger_ = NULL;
1953 } 1954 }
1954 1955
1955 return log_->Close(); 1956 return log_->Close();
1956 } 1957 }
1957 1958
1958 } } // namespace v8::internal 1959 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698