Commit 8a23a3a2 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cpu-profiler] Clean up some includes

Remove unused includes and add includes that were indirect.

Remove UnboundQueue which was not used anywhere.

Change-Id: If47faac45fc9c16a27453ecabed927ea00df3045
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1557136
Auto-Submit: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60672}
parent c6574e4a
...@@ -2523,8 +2523,6 @@ v8_source_set("v8_base") { ...@@ -2523,8 +2523,6 @@ v8_source_set("v8_base") {
"src/profiler/tick-sample.h", "src/profiler/tick-sample.h",
"src/profiler/tracing-cpu-profiler.cc", "src/profiler/tracing-cpu-profiler.cc",
"src/profiler/tracing-cpu-profiler.h", "src/profiler/tracing-cpu-profiler.h",
"src/profiler/unbound-queue-inl.h",
"src/profiler/unbound-queue.h",
"src/property-descriptor.cc", "src/property-descriptor.cc",
"src/property-descriptor.h", "src/property-descriptor.h",
"src/property-details.h", "src/property-details.h",
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <new> #include <new>
#include "src/profiler/circular-queue-inl.h" #include "src/profiler/circular-queue-inl.h"
#include "src/profiler/profile-generator-inl.h" #include "src/profiler/profile-generator-inl.h"
#include "src/profiler/unbound-queue-inl.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "src/base/lazy-instance.h" #include "src/base/lazy-instance.h"
#include "src/base/template-utils.h" #include "src/base/template-utils.h"
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/deoptimizer.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/locked-queue-inl.h" #include "src/locked-queue-inl.h"
#include "src/log.h" #include "src/log.h"
......
...@@ -4,16 +4,11 @@ ...@@ -4,16 +4,11 @@
#include "src/profiler/profile-generator.h" #include "src/profiler/profile-generator.h"
#include "src/base/adapters.h" #include "src/objects/shared-function-info-inl.h"
#include "src/debug/debug.h"
#include "src/deoptimizer.h"
#include "src/global-handles.h"
#include "src/objects-inl.h"
#include "src/profiler/cpu-profiler.h" #include "src/profiler/cpu-profiler.h"
#include "src/profiler/profile-generator-inl.h" #include "src/profiler/profile-generator-inl.h"
#include "src/tracing/trace-event.h" #include "src/tracing/trace-event.h"
#include "src/tracing/traced-value.h" #include "src/tracing/traced-value.h"
#include "src/unicode.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -5,11 +5,15 @@ ...@@ -5,11 +5,15 @@
#include "src/profiler/profiler-listener.h" #include "src/profiler/profiler-listener.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/handles-inl.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/code-inl.h"
#include "src/objects/script-inl.h"
#include "src/objects/shared-function-info-inl.h"
#include "src/objects/string-inl.h"
#include "src/profiler/cpu-profiler.h" #include "src/profiler/cpu-profiler.h"
#include "src/profiler/profile-generator-inl.h" #include "src/profiler/profile-generator-inl.h"
#include "src/reloc-info.h" #include "src/reloc-info.h"
#include "src/snapshot/embedded-data.h"
#include "src/source-position-table.h" #include "src/source-position-table.h"
#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-code-manager.h"
......
// Copyright 2010 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_PROFILER_UNBOUND_QUEUE_INL_H_
#define V8_PROFILER_UNBOUND_QUEUE_INL_H_
#include "src/profiler/unbound-queue.h"
namespace v8 {
namespace internal {
template<typename Record>
struct UnboundQueue<Record>::Node: public Malloced {
explicit Node(const Record& value) : value(value), next(nullptr) {}
Record value;
Node* next;
};
template<typename Record>
UnboundQueue<Record>::UnboundQueue() {
first_ = new Node(Record());
divider_ = last_ = reinterpret_cast<base::AtomicWord>(first_);
}
template<typename Record>
UnboundQueue<Record>::~UnboundQueue() {
while (first_ != nullptr) DeleteFirst();
}
template<typename Record>
void UnboundQueue<Record>::DeleteFirst() {
Node* tmp = first_;
first_ = tmp->next;
delete tmp;
}
template<typename Record>
bool UnboundQueue<Record>::Dequeue(Record* rec) {
if (divider_ == base::Acquire_Load(&last_)) return false;
Node* next = reinterpret_cast<Node*>(divider_)->next;
*rec = next->value;
base::Release_Store(&divider_, reinterpret_cast<base::AtomicWord>(next));
return true;
}
template<typename Record>
void UnboundQueue<Record>::Enqueue(const Record& rec) {
Node*& next = reinterpret_cast<Node*>(last_)->next;
next = new Node(rec);
base::Release_Store(&last_, reinterpret_cast<base::AtomicWord>(next));
while (first_ != reinterpret_cast<Node*>(base::Acquire_Load(&divider_))) {
DeleteFirst();
}
}
template<typename Record>
bool UnboundQueue<Record>::IsEmpty() const {
return base::Relaxed_Load(&divider_) == base::Relaxed_Load(&last_);
}
template<typename Record>
Record* UnboundQueue<Record>::Peek() const {
if (divider_ == base::Acquire_Load(&last_)) return nullptr;
Node* next = reinterpret_cast<Node*>(divider_)->next;
return &next->value;
}
} // namespace internal
} // namespace v8
#endif // V8_PROFILER_UNBOUND_QUEUE_INL_H_
// Copyright 2010 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_PROFILER_UNBOUND_QUEUE_H_
#define V8_PROFILER_UNBOUND_QUEUE_H_
#include "src/allocation.h"
#include "src/base/atomicops.h"
namespace v8 {
namespace internal {
// Lock-free unbound queue for small records. Intended for
// transferring small records between a Single producer and a Single
// consumer. Doesn't have restrictions on the number of queued
// elements, so producer never blocks. Implemented after Herb
// Sutter's article:
// http://www.ddj.com/high-performance-computing/210604448
template <typename Record>
class UnboundQueue {
public:
inline UnboundQueue();
inline ~UnboundQueue();
V8_INLINE bool Dequeue(Record* rec);
V8_INLINE void Enqueue(const Record& rec);
V8_INLINE bool IsEmpty() const;
V8_INLINE Record* Peek() const;
private:
V8_INLINE void DeleteFirst();
struct Node;
Node* first_;
base::AtomicWord divider_; // Node*
base::AtomicWord last_; // Node*
DISALLOW_COPY_AND_ASSIGN(UnboundQueue);
};
} // namespace internal
} // namespace v8
#endif // V8_PROFILER_UNBOUND_QUEUE_H_
...@@ -241,7 +241,6 @@ v8_source_set("cctest_sources") { ...@@ -241,7 +241,6 @@ v8_source_set("cctest_sources") {
"test-transitions.h", "test-transitions.h",
"test-typedarrays.cc", "test-typedarrays.cc",
"test-types.cc", "test-types.cc",
"test-unbound-queue.cc",
"test-unboxed-doubles.cc", "test-unboxed-doubles.cc",
"test-unscopables-hidden-prototype.cc", "test-unscopables-hidden-prototype.cc",
"test-unwinder.cc", "test-unwinder.cc",
......
// Copyright 2010 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Tests of the unbound queue.
#include "src/v8.h"
#include "test/cctest/cctest.h"
#include "src/profiler/unbound-queue-inl.h"
using i::UnboundQueue;
TEST(SingleRecord) {
typedef int Record;
UnboundQueue<Record> cq;
CHECK(cq.IsEmpty());
cq.Enqueue(1);
CHECK(!cq.IsEmpty());
Record rec = 0;
cq.Dequeue(&rec);
CHECK_EQ(1, rec);
CHECK(cq.IsEmpty());
}
TEST(MultipleRecords) {
typedef int Record;
UnboundQueue<Record> cq;
CHECK(cq.IsEmpty());
cq.Enqueue(1);
CHECK(!cq.IsEmpty());
for (int i = 2; i <= 5; ++i) {
cq.Enqueue(i);
CHECK(!cq.IsEmpty());
}
Record rec = 0;
for (int i = 1; i <= 4; ++i) {
CHECK(!cq.IsEmpty());
cq.Dequeue(&rec);
CHECK_EQ(i, rec);
}
for (int i = 6; i <= 12; ++i) {
cq.Enqueue(i);
CHECK(!cq.IsEmpty());
}
for (int i = 5; i <= 12; ++i) {
CHECK(!cq.IsEmpty());
cq.Dequeue(&rec);
CHECK_EQ(i, rec);
}
CHECK(cq.IsEmpty());
}
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