Commit 2ed3893b authored by mlippautz's avatar mlippautz Committed by Commit bot

[profiler] Move away from UnboundedQueue to LockedQueue for regular events.

Replaces the UnboundedQueue (SP/SC) with LockedQueue (MP/MC). This is necessary
as we can have multiple tasks (on multiple platform threads) reporting code move
events.

Note that the sampling queue is not affected by this change.

BUG=chromium:524425
LOG=N

Review URL: https://codereview.chromium.org/1457483002

Cr-Commit-Position: refs/heads/master@{#32086}
parent 10769948
......@@ -19,9 +19,10 @@ class AtomicNumber {
AtomicNumber() : value_(0) {}
explicit AtomicNumber(T initial) : value_(initial) {}
V8_INLINE void Increment(T increment) {
base::Barrier_AtomicIncrement(&value_,
static_cast<base::AtomicWord>(increment));
// Returns the newly set value.
V8_INLINE T Increment(T increment) {
return static_cast<T>(base::Barrier_AtomicIncrement(
&value_, static_cast<base::AtomicWord>(increment)));
}
V8_INLINE T Value() { return static_cast<T>(base::Acquire_Load(&value_)); }
......
......@@ -65,7 +65,7 @@ TickSample* ProfilerEventsProcessor::StartTickSample() {
void* address = ticks_buffer_.StartEnqueue();
if (address == NULL) return NULL;
TickSampleEventRecord* evt =
new(address) TickSampleEventRecord(last_code_event_id_);
new (address) TickSampleEventRecord(last_code_event_id_.Value());
return &evt->sample;
}
......
......@@ -6,6 +6,7 @@
#include "src/deoptimizer.h"
#include "src/frames-inl.h"
#include "src/locked-queue-inl.h"
#include "src/log-inl.h"
#include "src/profiler/cpu-profiler-inl.h"
#include "src/vm-state-inl.h"
......@@ -34,14 +35,14 @@ ProfilerEventsProcessor::~ProfilerEventsProcessor() {}
void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) {
event.generic.order = ++last_code_event_id_;
event.generic.order = last_code_event_id_.Increment(1);
events_buffer_.Enqueue(event);
}
void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from,
int fp_to_sp_delta) {
TickSampleEventRecord record(last_code_event_id_);
TickSampleEventRecord record(last_code_event_id_.Value());
RegisterState regs;
Address fp = isolate->c_entry_fp(isolate->thread_local_top());
regs.sp = fp - fp_to_sp_delta;
......@@ -53,7 +54,7 @@ void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from,
void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) {
TickSampleEventRecord record(last_code_event_id_);
TickSampleEventRecord record(last_code_event_id_.Value());
RegisterState regs;
StackFrameIterator it(isolate);
if (!it.done()) {
......@@ -95,9 +96,9 @@ bool ProfilerEventsProcessor::ProcessCodeEvent() {
ProfilerEventsProcessor::SampleProcessingResult
ProfilerEventsProcessor::ProcessOneSample() {
if (!ticks_from_vm_buffer_.IsEmpty()
&& ticks_from_vm_buffer_.Peek()->order ==
last_processed_code_event_id_) {
TickSampleEventRecord record1;
if (ticks_from_vm_buffer_.Peek(&record1) &&
(record1.order == last_processed_code_event_id_)) {
TickSampleEventRecord record;
ticks_from_vm_buffer_.Dequeue(&record);
generator_->RecordTickSample(record.sample);
......
......@@ -6,12 +6,13 @@
#define V8_PROFILER_CPU_PROFILER_H_
#include "src/allocation.h"
#include "src/atomic-utils.h"
#include "src/base/atomicops.h"
#include "src/base/platform/time.h"
#include "src/compiler.h"
#include "src/locked-queue.h"
#include "src/profiler/circular-queue.h"
#include "src/profiler/sampler.h"
#include "src/profiler/unbound-queue.h"
namespace v8 {
namespace internal {
......@@ -169,14 +170,14 @@ class ProfilerEventsProcessor : public base::Thread {
base::Atomic32 running_;
// Sampling period in microseconds.
const base::TimeDelta period_;
UnboundQueue<CodeEventsContainer> events_buffer_;
LockedQueue<CodeEventsContainer> events_buffer_;
static const size_t kTickSampleBufferSize = 1 * MB;
static const size_t kTickSampleQueueLength =
kTickSampleBufferSize / sizeof(TickSampleEventRecord);
SamplingCircularQueue<TickSampleEventRecord,
kTickSampleQueueLength> ticks_buffer_;
UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
unsigned last_code_event_id_;
LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
AtomicNumber<unsigned> last_code_event_id_;
unsigned last_processed_code_event_id_;
};
......
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