Commit abaece06 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Replace List with std::vector in cctests and d8.

Bug: v8:6333
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Iabaef0e63c81db503eb2f19bf63a1f77313f2a5a
Reviewed-on: https://chromium-review.googlesource.com/635591
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47681}
parent 5e6d9093
...@@ -10132,7 +10132,8 @@ unsigned CpuProfileNode::GetNodeId() const { ...@@ -10132,7 +10132,8 @@ unsigned CpuProfileNode::GetNodeId() const {
int CpuProfileNode::GetChildrenCount() const { int CpuProfileNode::GetChildrenCount() const {
return reinterpret_cast<const i::ProfileNode*>(this)->children()->length(); return static_cast<int>(
reinterpret_cast<const i::ProfileNode*>(this)->children()->size());
} }
...@@ -10356,7 +10357,7 @@ const HeapGraphNode* HeapSnapshot::GetNodeById(SnapshotObjectId id) const { ...@@ -10356,7 +10357,7 @@ const HeapGraphNode* HeapSnapshot::GetNodeById(SnapshotObjectId id) const {
int HeapSnapshot::GetNodesCount() const { int HeapSnapshot::GetNodesCount() const {
return ToInternal(this)->entries().length(); return static_cast<int>(ToInternal(this)->entries().size());
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "src/basic-block-profiler.h" #include "src/basic-block-profiler.h"
#include "src/debug/debug-interface.h" #include "src/debug/debug-interface.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/list-inl.h"
#include "src/msan.h" #include "src/msan.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects.h" #include "src/objects.h"
...@@ -452,7 +451,7 @@ const base::TimeTicks Shell::kInitialTicks = ...@@ -452,7 +451,7 @@ const base::TimeTicks Shell::kInitialTicks =
Global<Function> Shell::stringify_function_; Global<Function> Shell::stringify_function_;
base::LazyMutex Shell::workers_mutex_; base::LazyMutex Shell::workers_mutex_;
bool Shell::allow_new_workers_ = true; bool Shell::allow_new_workers_ = true;
i::List<Worker*> Shell::workers_; std::vector<Worker*> Shell::workers_;
std::vector<ExternalizedContents> Shell::externalized_contents_; std::vector<ExternalizedContents> Shell::externalized_contents_;
base::LazyMutex Shell::isolate_status_lock_; base::LazyMutex Shell::isolate_status_lock_;
std::map<v8::Isolate*, bool> Shell::isolate_status_; std::map<v8::Isolate*, bool> Shell::isolate_status_;
...@@ -1304,7 +1303,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1304,7 +1303,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
{ {
base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
if (workers_.length() >= kMaxWorkers) { if (workers_.size() >= kMaxWorkers) {
Throw(args.GetIsolate(), "Too many workers, I won't let you create more"); Throw(args.GetIsolate(), "Too many workers, I won't let you create more");
return; return;
} }
...@@ -1318,7 +1317,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1318,7 +1317,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
Worker* worker = new Worker; Worker* worker = new Worker;
args.Holder()->SetAlignedPointerInInternalField(0, worker); args.Holder()->SetAlignedPointerInInternalField(0, worker);
workers_.Add(worker); workers_.push_back(worker);
String::Utf8Value script(args.GetIsolate(), args[0]); String::Utf8Value script(args.GetIsolate(), args[0]);
if (!*script) { if (!*script) {
...@@ -3087,16 +3086,14 @@ void Shell::CleanupWorkers() { ...@@ -3087,16 +3086,14 @@ void Shell::CleanupWorkers() {
// Make a copy of workers_, because we don't want to call Worker::Terminate // Make a copy of workers_, because we don't want to call Worker::Terminate
// while holding the workers_mutex_ lock. Otherwise, if a worker is about to // while holding the workers_mutex_ lock. Otherwise, if a worker is about to
// create a new Worker, it would deadlock. // create a new Worker, it would deadlock.
i::List<Worker*> workers_copy; std::vector<Worker*> workers_copy;
{ {
base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
allow_new_workers_ = false; allow_new_workers_ = false;
workers_copy.AddAll(workers_); workers_copy.swap(workers_);
workers_.Clear();
} }
for (int i = 0; i < workers_copy.length(); ++i) { for (Worker* worker : workers_copy) {
Worker* worker = workers_copy[i];
worker->WaitForThread(); worker->WaitForThread();
delete worker; delete worker;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/base/hashmap.h" #include "src/base/hashmap.h"
#include "src/base/platform/time.h" #include "src/base/platform/time.h"
#include "src/list.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/base/once.h" #include "src/base/once.h"
...@@ -481,7 +480,7 @@ class Shell : public i::AllStatic { ...@@ -481,7 +480,7 @@ class Shell : public i::AllStatic {
static base::LazyMutex workers_mutex_; static base::LazyMutex workers_mutex_;
static bool allow_new_workers_; static bool allow_new_workers_;
static i::List<Worker*> workers_; static std::vector<Worker*> workers_;
static std::vector<ExternalizedContents> externalized_contents_; static std::vector<ExternalizedContents> externalized_contents_;
static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate); static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate);
......
...@@ -27,7 +27,7 @@ HeapSnapshot* HeapGraphEdge::snapshot() const { ...@@ -27,7 +27,7 @@ HeapSnapshot* HeapGraphEdge::snapshot() const {
int HeapEntry::index() const { int HeapEntry::index() const {
return static_cast<int>(this - &snapshot_->entries().first()); return static_cast<int>(this - &snapshot_->entries().front());
} }
......
...@@ -207,7 +207,7 @@ void HeapSnapshot::AddSyntheticRootEntries() { ...@@ -207,7 +207,7 @@ void HeapSnapshot::AddSyntheticRootEntries() {
HeapEntry* HeapSnapshot::AddRootEntry() { HeapEntry* HeapSnapshot::AddRootEntry() {
DCHECK(root_index_ == HeapEntry::kNoEntry); DCHECK(root_index_ == HeapEntry::kNoEntry);
DCHECK(entries_.is_empty()); // Root entry must be the first one. DCHECK(entries_.empty()); // Root entry must be the first one.
HeapEntry* entry = AddEntry(HeapEntry::kSynthetic, HeapEntry* entry = AddEntry(HeapEntry::kSynthetic,
"", "",
HeapObjectsMap::kInternalRootObjectId, HeapObjectsMap::kInternalRootObjectId,
...@@ -246,10 +246,9 @@ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type, ...@@ -246,10 +246,9 @@ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type,
SnapshotObjectId id, SnapshotObjectId id,
size_t size, size_t size,
unsigned trace_node_id) { unsigned trace_node_id) {
HeapEntry entry(this, type, name, id, size, trace_node_id); DCHECK(sorted_entries_.empty());
DCHECK(sorted_entries_.is_empty()); entries_.emplace_back(this, type, name, id, size, trace_node_id);
entries_.Add(entry); return &entries_.back();
return &entries_.last();
} }
...@@ -257,20 +256,18 @@ void HeapSnapshot::FillChildren() { ...@@ -257,20 +256,18 @@ void HeapSnapshot::FillChildren() {
DCHECK(children().empty()); DCHECK(children().empty());
children().resize(edges().size()); children().resize(edges().size());
int children_index = 0; int children_index = 0;
for (int i = 0; i < entries().length(); ++i) { for (HeapEntry& entry : entries()) {
HeapEntry* entry = &entries()[i]; children_index = entry.set_children_index(children_index);
children_index = entry->set_children_index(children_index);
} }
DCHECK_EQ(edges().size(), static_cast<size_t>(children_index)); DCHECK_EQ(edges().size(), static_cast<size_t>(children_index));
for (size_t i = 0; i < edges().size(); ++i) { for (HeapGraphEdge& edge : edges()) {
HeapGraphEdge* edge = &edges()[i]; edge.ReplaceToIndexWithEntry(this);
edge->ReplaceToIndexWithEntry(this); edge.from()->add_child(&edge);
edge->from()->add_child(edge);
} }
} }
HeapEntry* HeapSnapshot::GetEntryById(SnapshotObjectId id) { HeapEntry* HeapSnapshot::GetEntryById(SnapshotObjectId id) {
List<HeapEntry*>* entries_by_id = GetSortedEntriesList(); std::vector<HeapEntry*>* entries_by_id = GetSortedEntriesList();
auto it = std::lower_bound( auto it = std::lower_bound(
entries_by_id->begin(), entries_by_id->end(), id, entries_by_id->begin(), entries_by_id->end(), id,
...@@ -280,23 +277,19 @@ HeapEntry* HeapSnapshot::GetEntryById(SnapshotObjectId id) { ...@@ -280,23 +277,19 @@ HeapEntry* HeapSnapshot::GetEntryById(SnapshotObjectId id) {
return *it; return *it;
} }
struct SortByIds {
bool operator()(const HeapEntry* entry1_ptr, const HeapEntry* entry2_ptr) {
return entry1_ptr->id() < entry2_ptr->id();
}
};
template<class T> std::vector<HeapEntry*>* HeapSnapshot::GetSortedEntriesList() {
static int SortByIds(const T* entry1_ptr, if (sorted_entries_.empty()) {
const T* entry2_ptr) { sorted_entries_.reserve(entries_.size());
if ((*entry1_ptr)->id() == (*entry2_ptr)->id()) return 0; for (HeapEntry& entry : entries_) {
return (*entry1_ptr)->id() < (*entry2_ptr)->id() ? -1 : 1; sorted_entries_.push_back(&entry);
}
List<HeapEntry*>* HeapSnapshot::GetSortedEntriesList() {
if (sorted_entries_.is_empty()) {
sorted_entries_.Allocate(entries_.length());
for (int i = 0; i < entries_.length(); ++i) {
sorted_entries_[i] = &entries_[i];
} }
sorted_entries_.Sort<int (*)(HeapEntry* const*, HeapEntry* const*)>( std::sort(sorted_entries_.begin(), sorted_entries_.end(), SortByIds());
SortByIds);
} }
return &sorted_entries_; return &sorted_entries_;
} }
...@@ -322,7 +315,7 @@ HeapObjectsMap::HeapObjectsMap(Heap* heap) ...@@ -322,7 +315,7 @@ HeapObjectsMap::HeapObjectsMap(Heap* heap)
// an entry with zero value. Otherwise it's impossible to tell if // an entry with zero value. Otherwise it's impossible to tell if
// LookupOrInsert has added a new item or just returning exisiting one // LookupOrInsert has added a new item or just returning exisiting one
// having the value of zero. // having the value of zero.
entries_.Add(EntryInfo(0, nullptr, 0, true)); entries_.emplace_back(0, nullptr, 0, true);
} }
bool HeapObjectsMap::MoveObject(Address from, Address to, int object_size) { bool HeapObjectsMap::MoveObject(Address from, Address to, int object_size) {
...@@ -382,7 +375,7 @@ SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) { ...@@ -382,7 +375,7 @@ SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) {
if (entry == NULL) return 0; if (entry == NULL) return 0;
int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
EntryInfo& entry_info = entries_.at(entry_index); EntryInfo& entry_info = entries_.at(entry_index);
DCHECK(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy()); DCHECK(static_cast<uint32_t>(entries_.size()) > entries_map_.occupancy());
return entry_info.id; return entry_info.id;
} }
...@@ -390,7 +383,7 @@ SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) { ...@@ -390,7 +383,7 @@ SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) {
SnapshotObjectId HeapObjectsMap::FindOrAddEntry(Address addr, SnapshotObjectId HeapObjectsMap::FindOrAddEntry(Address addr,
unsigned int size, unsigned int size,
bool accessed) { bool accessed) {
DCHECK(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy()); DCHECK(static_cast<uint32_t>(entries_.size()) > entries_map_.occupancy());
base::HashMap::Entry* entry = base::HashMap::Entry* entry =
entries_map_.LookupOrInsert(addr, ComputePointerHash(addr)); entries_map_.LookupOrInsert(addr, ComputePointerHash(addr));
if (entry->value != NULL) { if (entry->value != NULL) {
...@@ -405,11 +398,11 @@ SnapshotObjectId HeapObjectsMap::FindOrAddEntry(Address addr, ...@@ -405,11 +398,11 @@ SnapshotObjectId HeapObjectsMap::FindOrAddEntry(Address addr,
entry_info.size = size; entry_info.size = size;
return entry_info.id; return entry_info.id;
} }
entry->value = reinterpret_cast<void*>(entries_.length()); entry->value = reinterpret_cast<void*>(entries_.size());
SnapshotObjectId id = next_id_; SnapshotObjectId id = next_id_;
next_id_ += kObjectIdStep; next_id_ += kObjectIdStep;
entries_.Add(EntryInfo(id, addr, size, accessed)); entries_.push_back(EntryInfo(id, addr, size, accessed));
DCHECK(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy()); DCHECK(static_cast<uint32_t>(entries_.size()) > entries_map_.occupancy());
return id; return id;
} }
...@@ -450,9 +443,9 @@ SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream, ...@@ -450,9 +443,9 @@ SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream,
time_intervals_.Add(TimeInterval(next_id_)); time_intervals_.Add(TimeInterval(next_id_));
int prefered_chunk_size = stream->GetChunkSize(); int prefered_chunk_size = stream->GetChunkSize();
List<v8::HeapStatsUpdate> stats_buffer; List<v8::HeapStatsUpdate> stats_buffer;
DCHECK(!entries_.is_empty()); DCHECK(!entries_.empty());
EntryInfo* entry_info = &entries_.first(); EntryInfo* entry_info = &entries_.front();
EntryInfo* end_entry_info = &entries_.last() + 1; EntryInfo* end_entry_info = &entries_.back() + 1;
for (int time_interval_index = 0; for (int time_interval_index = 0;
time_interval_index < time_intervals_.length(); time_interval_index < time_intervals_.length();
++time_interval_index) { ++time_interval_index) {
...@@ -496,11 +489,10 @@ SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream, ...@@ -496,11 +489,10 @@ SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream,
void HeapObjectsMap::RemoveDeadEntries() { void HeapObjectsMap::RemoveDeadEntries() {
DCHECK(entries_.length() > 0 && DCHECK(entries_.size() > 0 && entries_.at(0).id == 0 &&
entries_.at(0).id == 0 &&
entries_.at(0).addr == NULL); entries_.at(0).addr == NULL);
int first_free_entry = 1; size_t first_free_entry = 1;
for (int i = 1; i < entries_.length(); ++i) { for (size_t i = 1; i < entries_.size(); ++i) {
EntryInfo& entry_info = entries_.at(i); EntryInfo& entry_info = entries_.at(i);
if (entry_info.accessed) { if (entry_info.accessed) {
if (first_free_entry != i) { if (first_free_entry != i) {
...@@ -519,8 +511,9 @@ void HeapObjectsMap::RemoveDeadEntries() { ...@@ -519,8 +511,9 @@ void HeapObjectsMap::RemoveDeadEntries() {
} }
} }
} }
entries_.Rewind(first_free_entry); entries_.erase(entries_.begin() + first_free_entry, entries_.end());
DCHECK(static_cast<uint32_t>(entries_.length()) - 1 ==
DCHECK(static_cast<uint32_t>(entries_.size()) - 1 ==
entries_map_.occupancy()); entries_map_.occupancy());
} }
...@@ -2643,8 +2636,7 @@ void HeapSnapshotJSONSerializer::SerializeEdges() { ...@@ -2643,8 +2636,7 @@ void HeapSnapshotJSONSerializer::SerializeEdges() {
} }
} }
void HeapSnapshotJSONSerializer::SerializeNode(const HeapEntry* entry) {
void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) {
// The buffer needs space for 4 unsigned ints, 1 size_t, 5 commas, \n and \0 // The buffer needs space for 4 unsigned ints, 1 size_t, 5 commas, \n and \0
static const int kBufferSize = static const int kBufferSize =
5 * MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned // NOLINT 5 * MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned // NOLINT
...@@ -2673,9 +2665,9 @@ void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) { ...@@ -2673,9 +2665,9 @@ void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) {
void HeapSnapshotJSONSerializer::SerializeNodes() { void HeapSnapshotJSONSerializer::SerializeNodes() {
List<HeapEntry>& entries = snapshot_->entries(); std::vector<HeapEntry>& entries = snapshot_->entries();
for (int i = 0; i < entries.length(); ++i) { for (const HeapEntry& entry : entries) {
SerializeNode(&entries[i]); SerializeNode(&entry);
if (writer_->aborted()) return; if (writer_->aborted()) return;
} }
} }
...@@ -2751,7 +2743,7 @@ void HeapSnapshotJSONSerializer::SerializeSnapshot() { ...@@ -2751,7 +2743,7 @@ void HeapSnapshotJSONSerializer::SerializeSnapshot() {
#undef JSON_O #undef JSON_O
#undef JSON_A #undef JSON_A
writer_->AddString(",\"node_count\":"); writer_->AddString(",\"node_count\":");
writer_->AddNumber(snapshot_->entries().length()); writer_->AddNumber(static_cast<unsigned>(snapshot_->entries().size()));
writer_->AddString(",\"edge_count\":"); writer_->AddString(",\"edge_count\":");
writer_->AddNumber(static_cast<double>(snapshot_->edges().size())); writer_->AddNumber(static_cast<double>(snapshot_->edges().size()));
writer_->AddString(",\"trace_function_count\":"); writer_->AddString(",\"trace_function_count\":");
......
...@@ -107,11 +107,11 @@ class HeapEntry BASE_EMBEDDED { ...@@ -107,11 +107,11 @@ class HeapEntry BASE_EMBEDDED {
unsigned trace_node_id); unsigned trace_node_id);
HeapSnapshot* snapshot() { return snapshot_; } HeapSnapshot* snapshot() { return snapshot_; }
Type type() { return static_cast<Type>(type_); } Type type() const { return static_cast<Type>(type_); }
const char* name() { return name_; } const char* name() const { return name_; }
void set_name(const char* name) { name_ = name; } void set_name(const char* name) { name_ = name; }
SnapshotObjectId id() { return id_; } SnapshotObjectId id() const { return id_; }
size_t self_size() { return self_size_; } size_t self_size() const { return self_size_; }
unsigned trace_node_id() const { return trace_node_id_; } unsigned trace_node_id() const { return trace_node_id_; }
INLINE(int index() const); INLINE(int index() const);
int children_count() const { return children_count_; } int children_count() const { return children_count_; }
...@@ -163,7 +163,7 @@ class HeapSnapshot { ...@@ -163,7 +163,7 @@ class HeapSnapshot {
HeapEntry* gc_subroot(int index) { HeapEntry* gc_subroot(int index) {
return &entries_[gc_subroot_indexes_[index]]; return &entries_[gc_subroot_indexes_[index]];
} }
List<HeapEntry>& entries() { return entries_; } std::vector<HeapEntry>& entries() { return entries_; }
std::deque<HeapGraphEdge>& edges() { return edges_; } std::deque<HeapGraphEdge>& edges() { return edges_; }
std::deque<HeapGraphEdge*>& children() { return children_; } std::deque<HeapGraphEdge*>& children() { return children_; }
void RememberLastJSObjectId(); void RememberLastJSObjectId();
...@@ -178,7 +178,7 @@ class HeapSnapshot { ...@@ -178,7 +178,7 @@ class HeapSnapshot {
unsigned trace_node_id); unsigned trace_node_id);
void AddSyntheticRootEntries(); void AddSyntheticRootEntries();
HeapEntry* GetEntryById(SnapshotObjectId id); HeapEntry* GetEntryById(SnapshotObjectId id);
List<HeapEntry*>* GetSortedEntriesList(); std::vector<HeapEntry*>* GetSortedEntriesList();
void FillChildren(); void FillChildren();
void Print(int max_depth); void Print(int max_depth);
...@@ -192,10 +192,10 @@ class HeapSnapshot { ...@@ -192,10 +192,10 @@ class HeapSnapshot {
int root_index_; int root_index_;
int gc_roots_index_; int gc_roots_index_;
int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags];
List<HeapEntry> entries_; std::vector<HeapEntry> entries_;
std::deque<HeapGraphEdge> edges_; std::deque<HeapGraphEdge> edges_;
std::deque<HeapGraphEdge*> children_; std::deque<HeapGraphEdge*> children_;
List<HeapEntry*> sorted_entries_; std::vector<HeapEntry*> sorted_entries_;
SnapshotObjectId max_snapshot_js_object_id_; SnapshotObjectId max_snapshot_js_object_id_;
friend class HeapSnapshotTester; friend class HeapSnapshotTester;
...@@ -259,7 +259,7 @@ class HeapObjectsMap { ...@@ -259,7 +259,7 @@ class HeapObjectsMap {
SnapshotObjectId next_id_; SnapshotObjectId next_id_;
base::HashMap entries_map_; base::HashMap entries_map_;
List<EntryInfo> entries_; std::vector<EntryInfo> entries_;
List<TimeInterval> time_intervals_; List<TimeInterval> time_intervals_;
Heap* heap_; Heap* heap_;
...@@ -588,11 +588,11 @@ class HeapSnapshotJSONSerializer { ...@@ -588,11 +588,11 @@ class HeapSnapshotJSONSerializer {
} }
int GetStringId(const char* s); int GetStringId(const char* s);
int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } int entry_index(const HeapEntry* e) { return e->index() * kNodeFieldsCount; }
void SerializeEdge(HeapGraphEdge* edge, bool first_edge); void SerializeEdge(HeapGraphEdge* edge, bool first_edge);
void SerializeEdges(); void SerializeEdges();
void SerializeImpl(); void SerializeImpl();
void SerializeNode(HeapEntry* entry); void SerializeNode(const HeapEntry* entry);
void SerializeNodes(); void SerializeNodes();
void SerializeSnapshot(); void SerializeSnapshot();
void SerializeTraceTree(); void SerializeTraceTree();
......
...@@ -202,7 +202,7 @@ ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { ...@@ -202,7 +202,7 @@ ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) {
if (!node) { if (!node) {
node = new ProfileNode(tree_, entry, this); node = new ProfileNode(tree_, entry, this);
map_entry->value = node; map_entry->value = node;
children_list_.Add(node); children_list_.push_back(node);
} }
return node; return node;
} }
...@@ -348,7 +348,7 @@ class Position { ...@@ -348,7 +348,7 @@ class Position {
return node->children()->at(child_idx_); return node->children()->at(child_idx_);
} }
INLINE(bool has_current_child()) { INLINE(bool has_current_child()) {
return child_idx_ < node->children()->length(); return child_idx_ < static_cast<int>(node->children()->size());
} }
INLINE(void next_child()) { ++child_idx_; } INLINE(void next_child()) { ++child_idx_; }
......
...@@ -182,7 +182,7 @@ class ProfileNode { ...@@ -182,7 +182,7 @@ class ProfileNode {
CodeEntry* entry() const { return entry_; } CodeEntry* entry() const { return entry_; }
unsigned self_ticks() const { return self_ticks_; } unsigned self_ticks() const { return self_ticks_; }
const List<ProfileNode*>* children() const { return &children_list_; } const std::vector<ProfileNode*>* children() const { return &children_list_; }
unsigned id() const { return id_; } unsigned id() const { return id_; }
unsigned function_id() const; unsigned function_id() const;
ProfileNode* parent() const { return parent_; } ProfileNode* parent() const { return parent_; }
...@@ -212,7 +212,7 @@ class ProfileNode { ...@@ -212,7 +212,7 @@ class ProfileNode {
unsigned self_ticks_; unsigned self_ticks_;
// Mapping from CodeEntry* to ProfileNode* // Mapping from CodeEntry* to ProfileNode*
base::CustomMatcherHashMap children_; base::CustomMatcherHashMap children_;
List<ProfileNode*> children_list_; std::vector<ProfileNode*> children_list_;
ProfileNode* parent_; ProfileNode* parent_;
unsigned id_; unsigned id_;
base::CustomMatcherHashMap line_ticks_; base::CustomMatcherHashMap line_ticks_;
......
...@@ -114,7 +114,6 @@ v8_executable("cctest") { ...@@ -114,7 +114,6 @@ v8_executable("cctest") {
"test-api.cc", "test-api.cc",
"test-api.h", "test-api.h",
"test-array-list.cc", "test-array-list.cc",
"test-ast.cc",
"test-atomicops.cc", "test-atomicops.cc",
"test-bignum-dtoa.cc", "test-bignum-dtoa.cc",
"test-bignum.cc", "test-bignum.cc",
......
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
'test-api-accessors.cc', 'test-api-accessors.cc',
'test-api-interceptors.cc', 'test-api-interceptors.cc',
'test-array-list.cc', 'test-array-list.cc',
'test-ast.cc',
'test-atomicops.cc', 'test-atomicops.cc',
'test-bignum.cc', 'test-bignum.cc',
'test-bignum-dtoa.cc', 'test-bignum-dtoa.cc',
......
...@@ -217,7 +217,8 @@ TEST(CodeRange) { ...@@ -217,7 +217,8 @@ TEST(CodeRange) {
code_range.SetUp(code_range_size); code_range.SetUp(code_range_size);
size_t current_allocated = 0; size_t current_allocated = 0;
size_t total_allocated = 0; size_t total_allocated = 0;
List<Block> blocks(1000); std::vector<Block> blocks;
blocks.reserve(1000);
while (total_allocated < 5 * code_range_size) { while (total_allocated < 5 * code_range_size) {
if (current_allocated < code_range_size / 10) { if (current_allocated < code_range_size / 10) {
...@@ -236,19 +237,18 @@ TEST(CodeRange) { ...@@ -236,19 +237,18 @@ TEST(CodeRange) {
requested, requested - (2 * MemoryAllocator::CodePageGuardSize()), requested, requested - (2 * MemoryAllocator::CodePageGuardSize()),
&allocated); &allocated);
CHECK(base != NULL); CHECK(base != NULL);
blocks.Add(Block(base, static_cast<int>(allocated))); blocks.emplace_back(base, static_cast<int>(allocated));
current_allocated += static_cast<int>(allocated); current_allocated += static_cast<int>(allocated);
total_allocated += static_cast<int>(allocated); total_allocated += static_cast<int>(allocated);
} else { } else {
// Free a block. // Free a block.
int index = Pseudorandom() % blocks.length(); size_t index = Pseudorandom() % blocks.size();
code_range.FreeRawMemory(blocks[index].base, blocks[index].size); code_range.FreeRawMemory(blocks[index].base, blocks[index].size);
current_allocated -= blocks[index].size; current_allocated -= blocks[index].size;
if (index < blocks.length() - 1) { if (index < blocks.size() - 1) {
blocks[index] = blocks.RemoveLast(); blocks[index] = blocks.back();
} else {
blocks.RemoveLast();
} }
blocks.pop_back();
} }
} }
} }
......
// Copyright 2012 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.
#include <stdlib.h>
#include "src/v8.h"
#include "src/ast/ast.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/zone/accounting-allocator.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
TEST(List) {
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
List<AstNode*>* list = new List<AstNode*>(0);
CHECK_EQ(0, list->length());
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
AstValueFactory value_factory(&zone, isolate->ast_string_constants(),
isolate->heap()->HashSeed());
AstNodeFactory factory(&value_factory, &zone);
AstNode* node = factory.NewEmptyStatement(kNoSourcePosition);
list->Add(node);
CHECK_EQ(1, list->length());
CHECK_EQ(node, list->at(0));
CHECK_EQ(node, list->last());
const int kElements = 100;
for (int i = 0; i < kElements; i++) {
list->Add(node);
}
CHECK_EQ(1 + kElements, list->length());
list->Clear();
CHECK_EQ(0, list->length());
delete list;
}
} // namespace internal
} // namespace v8
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "src/factory.h" #include "src/factory.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/list.h"
#include "src/objects.h" #include "src/objects.h"
// FIXME(mstarzinger, marja): This is weird, but required because of the missing // FIXME(mstarzinger, marja): This is weird, but required because of the missing
// (disallowed) include: src/factory.h -> src/objects-inl.h // (disallowed) include: src/factory.h -> src/objects-inl.h
...@@ -52,11 +51,13 @@ TEST(CodeCache) { ...@@ -52,11 +51,13 @@ TEST(CodeCache) {
static const int kEntries = 150; static const int kEntries = 150;
// Prepare name/code pairs. // Prepare name/code pairs.
List<Handle<Name>> names(kEntries); std::vector<Handle<Name>> names;
List<Handle<Code>> codes(kEntries); std::vector<Handle<Code>> codes;
names.reserve(kEntries);
codes.reserve(kEntries);
for (int i = 0; i < kEntries; i++) { for (int i = 0; i < kEntries; i++) {
names.Add(isolate->factory()->NewSymbol()); names.push_back(isolate->factory()->NewSymbol());
codes.Add(GetDummyCode(isolate)); codes.push_back(GetDummyCode(isolate));
} }
Handle<Name> bad_name = isolate->factory()->NewSymbol(); Handle<Name> bad_name = isolate->factory()->NewSymbol();
Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState); Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState);
......
...@@ -265,21 +265,21 @@ TEST(TickEvents) { ...@@ -265,21 +265,21 @@ TEST(TickEvents) {
CHECK(profile); CHECK(profile);
// Check call trees. // Check call trees.
const i::List<ProfileNode*>* top_down_root_children = const std::vector<ProfileNode*>* top_down_root_children =
profile->top_down()->root()->children(); profile->top_down()->root()->children();
CHECK_EQ(1, top_down_root_children->length()); CHECK_EQ(1, top_down_root_children->size());
CHECK_EQ(0, strcmp("bbb", top_down_root_children->last()->entry()->name())); CHECK_EQ(0, strcmp("bbb", top_down_root_children->back()->entry()->name()));
const i::List<ProfileNode*>* top_down_bbb_children = const std::vector<ProfileNode*>* top_down_bbb_children =
top_down_root_children->last()->children(); top_down_root_children->back()->children();
CHECK_EQ(1, top_down_bbb_children->length()); CHECK_EQ(1, top_down_bbb_children->size());
CHECK_EQ(0, strcmp("5", top_down_bbb_children->last()->entry()->name())); CHECK_EQ(0, strcmp("5", top_down_bbb_children->back()->entry()->name()));
const i::List<ProfileNode*>* top_down_stub_children = const std::vector<ProfileNode*>* top_down_stub_children =
top_down_bbb_children->last()->children(); top_down_bbb_children->back()->children();
CHECK_EQ(1, top_down_stub_children->length()); CHECK_EQ(1, top_down_stub_children->size());
CHECK_EQ(0, strcmp("ddd", top_down_stub_children->last()->entry()->name())); CHECK_EQ(0, strcmp("ddd", top_down_stub_children->back()->entry()->name()));
const i::List<ProfileNode*>* top_down_ddd_children = const std::vector<ProfileNode*>* top_down_ddd_children =
top_down_stub_children->last()->children(); top_down_stub_children->back()->children();
CHECK_EQ(0, top_down_ddd_children->length()); CHECK(top_down_ddd_children->empty());
isolate->code_event_dispatcher()->RemoveListener(&profiler_listener); isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
} }
...@@ -337,8 +337,8 @@ TEST(Issue1398) { ...@@ -337,8 +337,8 @@ TEST(Issue1398) {
unsigned actual_depth = 0; unsigned actual_depth = 0;
const ProfileNode* node = profile->top_down()->root(); const ProfileNode* node = profile->top_down()->root();
while (node->children()->length() > 0) { while (!node->children()->empty()) {
node = node->children()->last(); node = node->children()->back();
++actual_depth; ++actual_depth;
} }
......
...@@ -66,11 +66,12 @@ class NamedEntriesDetector { ...@@ -66,11 +66,12 @@ class NamedEntriesDetector {
void CheckAllReachables(i::HeapEntry* root) { void CheckAllReachables(i::HeapEntry* root) {
v8::base::HashMap visited; v8::base::HashMap visited;
i::List<i::HeapEntry*> list(10); std::vector<i::HeapEntry*> list;
list.Add(root); list.push_back(root);
CheckEntry(root); CheckEntry(root);
while (!list.is_empty()) { while (!list.empty()) {
i::HeapEntry* entry = list.RemoveLast(); i::HeapEntry* entry = list.back();
list.pop_back();
for (int i = 0; i < entry->children_count(); ++i) { for (int i = 0; i < entry->children_count(); ++i) {
i::HeapGraphEdge* edge = entry->child(i); i::HeapGraphEdge* edge = entry->child(i);
if (edge->type() == i::HeapGraphEdge::kShortcut) continue; if (edge->type() == i::HeapGraphEdge::kShortcut) continue;
...@@ -81,7 +82,7 @@ class NamedEntriesDetector { ...@@ -81,7 +82,7 @@ class NamedEntriesDetector {
if (entry->value) if (entry->value)
continue; continue;
entry->value = reinterpret_cast<void*>(1); entry->value = reinterpret_cast<void*>(1);
list.Add(child); list.push_back(child);
CheckEntry(child); CheckEntry(child);
} }
} }
...@@ -159,14 +160,14 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) { ...@@ -159,14 +160,14 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) {
entry->value = reinterpret_cast<void*>(ref_count + 1); entry->value = reinterpret_cast<void*>(ref_count + 1);
} }
uint32_t unretained_entries_count = 0; uint32_t unretained_entries_count = 0;
i::List<i::HeapEntry>& entries = heap_snapshot->entries(); std::vector<i::HeapEntry>& entries = heap_snapshot->entries();
for (int i = 0; i < entries.length(); ++i) { for (i::HeapEntry& entry : entries) {
v8::base::HashMap::Entry* entry = visited.Lookup( v8::base::HashMap::Entry* map_entry = visited.Lookup(
reinterpret_cast<void*>(&entries[i]), reinterpret_cast<void*>(&entry),
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&entries[i]))); static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&entry)));
if (!entry && entries[i].id() != 1) { if (!map_entry && entry.id() != 1) {
entries[i].Print("entry with no retainer", "", depth, 0); entry.Print("entry with no retainer", "", depth, 0);
++unretained_entries_count; ++unretained_entries_count;
} }
} }
return unretained_entries_count == 0; return unretained_entries_count == 0;
...@@ -1424,7 +1425,7 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo { ...@@ -1424,7 +1425,7 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
label_(label), label_(label),
element_count_(element_count), element_count_(element_count),
size_(size) { size_(size) {
instances.Add(this); instances.push_back(this);
} }
virtual ~TestRetainedObjectInfo() {} virtual ~TestRetainedObjectInfo() {}
virtual void Dispose() { virtual void Dispose() {
...@@ -1462,7 +1463,7 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo { ...@@ -1462,7 +1463,7 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
return NULL; return NULL;
} }
static i::List<TestRetainedObjectInfo*> instances; static std::vector<TestRetainedObjectInfo*> instances;
private: private:
bool disposed_; bool disposed_;
...@@ -1473,8 +1474,7 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo { ...@@ -1473,8 +1474,7 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
intptr_t size_; intptr_t size_;
}; };
std::vector<TestRetainedObjectInfo*> TestRetainedObjectInfo::instances;
i::List<TestRetainedObjectInfo*> TestRetainedObjectInfo::instances;
} // namespace } // namespace
...@@ -1510,14 +1510,14 @@ TEST(HeapSnapshotRetainedObjectInfo) { ...@@ -1510,14 +1510,14 @@ TEST(HeapSnapshotRetainedObjectInfo) {
p_BBB.SetWrapperClassId(1); p_BBB.SetWrapperClassId(1);
v8::Persistent<v8::String> p_CCC(isolate, v8_str("CCC")); v8::Persistent<v8::String> p_CCC(isolate, v8_str("CCC"));
p_CCC.SetWrapperClassId(2); p_CCC.SetWrapperClassId(2);
CHECK_EQ(0, TestRetainedObjectInfo::instances.length()); CHECK(TestRetainedObjectInfo::instances.empty());
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot)); CHECK(ValidateSnapshot(snapshot));
CHECK_EQ(3, TestRetainedObjectInfo::instances.length()); CHECK_EQ(3, TestRetainedObjectInfo::instances.size());
for (int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) { for (TestRetainedObjectInfo* instance : TestRetainedObjectInfo::instances) {
CHECK(TestRetainedObjectInfo::instances[i]->disposed()); CHECK(instance->disposed());
delete TestRetainedObjectInfo::instances[i]; delete instance;
} }
const v8::HeapGraphNode* native_group_aaa = GetNode( const v8::HeapGraphNode* native_group_aaa = GetNode(
......
...@@ -700,9 +700,9 @@ TEST(CanonicalHandleScope) { ...@@ -700,9 +700,9 @@ TEST(CanonicalHandleScope) {
CanonicalHandleScope outer_canonical(isolate); CanonicalHandleScope outer_canonical(isolate);
// Deduplicate smi handles. // Deduplicate smi handles.
List<Handle<Object> > smi_handles; std::vector<Handle<Object>> smi_handles;
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
smi_handles.Add(Handle<Object>(Smi::FromInt(i), isolate)); smi_handles.push_back(Handle<Object>(Smi::FromInt(i), isolate));
} }
Object** next_handle = isolate->handle_scope_data()->next; Object** next_handle = isolate->handle_scope_data()->next;
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
......
...@@ -193,16 +193,16 @@ class IsolateLockingThreadWithLocalContext : public JoinableThread { ...@@ -193,16 +193,16 @@ class IsolateLockingThreadWithLocalContext : public JoinableThread {
v8::Isolate* isolate_; v8::Isolate* isolate_;
}; };
static void StartJoinAndDeleteThreads(
static void StartJoinAndDeleteThreads(const i::List<JoinableThread*>& threads) { const std::vector<JoinableThread*>& threads) {
for (int i = 0; i < threads.length(); i++) { for (const auto& thread : threads) {
threads[i]->Start(); thread->Start();
} }
for (int i = 0; i < threads.length(); i++) { for (const auto& thread : threads) {
threads[i]->Join(); thread->Join();
} }
for (int i = 0; i < threads.length(); i++) { for (const auto& thread : threads) {
delete threads[i]; delete thread;
} }
} }
...@@ -215,12 +215,13 @@ TEST(IsolateLockingStress) { ...@@ -215,12 +215,13 @@ TEST(IsolateLockingStress) {
#else #else
const int kNThreads = 100; const int kNThreads = 100;
#endif #endif
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new IsolateLockingThreadWithLocalContext(isolate)); threads.push_back(new IsolateLockingThreadWithLocalContext(isolate));
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
isolate->Dispose(); isolate->Dispose();
...@@ -262,9 +263,10 @@ TEST(IsolateNestedLocking) { ...@@ -262,9 +263,10 @@ TEST(IsolateNestedLocking) {
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new IsolateNestedLockingThread(isolate)); threads.push_back(new IsolateNestedLockingThread(isolate));
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
isolate->Dispose(); isolate->Dispose();
...@@ -308,10 +310,11 @@ TEST(SeparateIsolatesLocksNonexclusive) { ...@@ -308,10 +310,11 @@ TEST(SeparateIsolatesLocksNonexclusive) {
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate1 = v8::Isolate::New(create_params); v8::Isolate* isolate1 = v8::Isolate::New(create_params);
v8::Isolate* isolate2 = v8::Isolate::New(create_params); v8::Isolate* isolate2 = v8::Isolate::New(create_params);
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new SeparateIsolatesLocksNonexclusiveThread(isolate1, threads.push_back(
isolate2)); new SeparateIsolatesLocksNonexclusiveThread(isolate1, isolate2));
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
isolate2->Dispose(); isolate2->Dispose();
...@@ -388,12 +391,13 @@ TEST(LockerUnlocker) { ...@@ -388,12 +391,13 @@ TEST(LockerUnlocker) {
#else #else
const int kNThreads = 100; const int kNThreads = 100;
#endif #endif
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new LockerUnlockerThread(isolate)); threads.push_back(new LockerUnlockerThread(isolate));
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
isolate->Dispose(); isolate->Dispose();
...@@ -445,12 +449,13 @@ TEST(LockTwiceAndUnlock) { ...@@ -445,12 +449,13 @@ TEST(LockTwiceAndUnlock) {
#else #else
const int kNThreads = 100; const int kNThreads = 100;
#endif #endif
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new LockTwiceAndUnlockThread(isolate)); threads.push_back(new LockTwiceAndUnlockThread(isolate));
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
isolate->Dispose(); isolate->Dispose();
...@@ -574,15 +579,15 @@ TEST(LockUnlockLockMultithreaded) { ...@@ -574,15 +579,15 @@ TEST(LockUnlockLockMultithreaded) {
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
{ {
v8::Locker locker_(isolate); v8::Locker locker_(isolate);
v8::Isolate::Scope isolate_scope(isolate); v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new LockUnlockLockThread( threads.push_back(new LockUnlockLockThread(isolate, context));
isolate, context));
} }
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
...@@ -632,14 +637,15 @@ TEST(LockUnlockLockDefaultIsolateMultithreaded) { ...@@ -632,14 +637,15 @@ TEST(LockUnlockLockDefaultIsolateMultithreaded) {
const int kNThreads = 100; const int kNThreads = 100;
#endif #endif
Local<v8::Context> context; Local<v8::Context> context;
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
{ {
v8::Locker locker_(CcTest::isolate()); v8::Locker locker_(CcTest::isolate());
v8::Isolate::Scope isolate_scope(CcTest::isolate()); v8::Isolate::Scope isolate_scope(CcTest::isolate());
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
context = v8::Context::New(CcTest::isolate()); context = v8::Context::New(CcTest::isolate());
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new LockUnlockLockDefaultIsolateThread(context)); threads.push_back(new LockUnlockLockDefaultIsolateThread(context));
} }
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
...@@ -731,9 +737,10 @@ TEST(ExtensionsRegistration) { ...@@ -731,9 +737,10 @@ TEST(ExtensionsRegistration) {
const char* extension_names[] = { "test0", "test1", const char* extension_names[] = { "test0", "test1",
"test2", "test3", "test4", "test2", "test3", "test4",
"test5", "test6", "test7" }; "test5", "test6", "test7" };
i::List<JoinableThread*> threads(kNThreads); std::vector<JoinableThread*> threads;
threads.reserve(kNThreads);
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new IsolateGenesisThread(8, extension_names)); threads.push_back(new IsolateGenesisThread(8, extension_names));
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
} }
...@@ -407,11 +407,10 @@ TEST(RecordTickSample) { ...@@ -407,11 +407,10 @@ TEST(RecordTickSample) {
delete entry3; delete entry3;
} }
static void CheckNodeIds(const ProfileNode* node, unsigned* expectedId) {
static void CheckNodeIds(ProfileNode* node, unsigned* expectedId) {
CHECK_EQ((*expectedId)++, node->id()); CHECK_EQ((*expectedId)++, node->id());
for (int i = 0; i < node->children()->length(); i++) { for (const ProfileNode* child : *node->children()) {
CheckNodeIds(node->children()->at(i), expectedId); CheckNodeIds(child, expectedId);
} }
} }
...@@ -506,8 +505,7 @@ TEST(NoSamples) { ...@@ -506,8 +505,7 @@ TEST(NoSamples) {
static const ProfileNode* PickChild(const ProfileNode* parent, static const ProfileNode* PickChild(const ProfileNode* parent,
const char* name) { const char* name) {
for (int i = 0; i < parent->children()->length(); ++i) { for (const ProfileNode* child : *parent->children()) {
const ProfileNode* child = parent->children()->at(i);
if (strcmp(child->entry()->name(), name) == 0) return child; if (strcmp(child->entry()->name(), name) == 0) return child;
} }
return NULL; return NULL;
...@@ -554,11 +552,10 @@ TEST(RecordStackTraceAtStartProfiling) { ...@@ -554,11 +552,10 @@ TEST(RecordStackTraceAtStartProfiling) {
CHECK(const_cast<ProfileNode*>(current)); CHECK(const_cast<ProfileNode*>(current));
current = PickChild(current, "c"); current = PickChild(current, "c");
CHECK(const_cast<ProfileNode*>(current)); CHECK(const_cast<ProfileNode*>(current));
CHECK(current->children()->length() == 0 || CHECK(current->children()->empty() || current->children()->size() == 1);
current->children()->length() == 1); if (current->children()->size() == 1) {
if (current->children()->length() == 1) {
current = PickChild(current, "startProfiling"); current = PickChild(current, "startProfiling");
CHECK_EQ(0, current->children()->length()); CHECK(current->children()->empty());
} }
} }
......
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/list-inl.h"
class ThreadIdValidationThread : public v8::base::Thread { class ThreadIdValidationThread : public v8::base::Thread {
public: public:
ThreadIdValidationThread(v8::base::Thread* thread_to_start, ThreadIdValidationThread(v8::base::Thread* thread_to_start,
i::List<i::ThreadId>* refs, unsigned int thread_no, std::vector<i::ThreadId>* refs,
unsigned int thread_no,
v8::base::Semaphore* semaphore) v8::base::Semaphore* semaphore)
: Thread(Options("ThreadRefValidationThread")), : Thread(Options("ThreadRefValidationThread")),
refs_(refs), refs_(refs),
...@@ -57,7 +57,7 @@ class ThreadIdValidationThread : public v8::base::Thread { ...@@ -57,7 +57,7 @@ class ThreadIdValidationThread : public v8::base::Thread {
} }
private: private:
i::List<i::ThreadId>* refs_; std::vector<i::ThreadId>* refs_;
int thread_no_; int thread_no_;
v8::base::Thread* thread_to_start_; v8::base::Thread* thread_to_start_;
v8::base::Semaphore* semaphore_; v8::base::Semaphore* semaphore_;
...@@ -66,16 +66,18 @@ class ThreadIdValidationThread : public v8::base::Thread { ...@@ -66,16 +66,18 @@ class ThreadIdValidationThread : public v8::base::Thread {
TEST(ThreadIdValidation) { TEST(ThreadIdValidation) {
const int kNThreads = 100; const int kNThreads = 100;
i::List<ThreadIdValidationThread*> threads(kNThreads); std::vector<ThreadIdValidationThread*> threads;
i::List<i::ThreadId> refs(kNThreads); std::vector<i::ThreadId> refs;
threads.reserve(kNThreads);
refs.reserve(kNThreads);
v8::base::Semaphore semaphore(0); v8::base::Semaphore semaphore(0);
ThreadIdValidationThread* prev = NULL; ThreadIdValidationThread* prev = NULL;
for (int i = kNThreads - 1; i >= 0; i--) { for (int i = kNThreads - 1; i >= 0; i--) {
ThreadIdValidationThread* newThread = ThreadIdValidationThread* newThread =
new ThreadIdValidationThread(prev, &refs, i, &semaphore); new ThreadIdValidationThread(prev, &refs, i, &semaphore);
threads.Add(newThread); threads.push_back(newThread);
prev = newThread; prev = newThread;
refs.Add(i::ThreadId::Invalid()); refs.push_back(i::ThreadId::Invalid());
} }
prev->Start(); prev->Start();
for (int i = 0; i < kNThreads; i++) { for (int i = 0; i < kNThreads; i++) {
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include "src/v8.h" #include "src/v8.h"
#include "src/list.h"
#include "src/list-inl.h"
#include "test/cctest/cctest.h" #include "test/cctest/cctest.h"
#include "src/tracing/trace-event.h" #include "src/tracing/trace-event.h"
...@@ -34,16 +32,16 @@ struct MockTraceObject { ...@@ -34,16 +32,16 @@ struct MockTraceObject {
flags(flags) {} flags(flags) {}
}; };
typedef v8::internal::List<MockTraceObject*> MockTraceObjectList; typedef std::vector<MockTraceObject*> MockTraceObjectList;
class MockTracingController : public v8::TracingController { class MockTracingController : public v8::TracingController {
public: public:
MockTracingController() = default; MockTracingController() = default;
~MockTracingController() { ~MockTracingController() {
for (int i = 0; i < trace_object_list_.length(); ++i) { for (size_t i = 0; i < trace_object_list_.size(); ++i) {
delete trace_object_list_[i]; delete trace_object_list_[i];
} }
trace_object_list_.Clear(); trace_object_list_.clear();
} }
uint64_t AddTraceEvent( uint64_t AddTraceEvent(
...@@ -55,7 +53,7 @@ class MockTracingController : public v8::TracingController { ...@@ -55,7 +53,7 @@ class MockTracingController : public v8::TracingController {
unsigned int flags) override { unsigned int flags) override {
MockTraceObject* to = new MockTraceObject(phase, std::string(name), id, MockTraceObject* to = new MockTraceObject(phase, std::string(name), id,
bind_id, num_args, flags); bind_id, num_args, flags);
trace_object_list_.Add(to); trace_object_list_.push_back(to);
return 0; return 0;
} }
...@@ -107,7 +105,7 @@ TEST(TraceEventDisabledCategory) { ...@@ -107,7 +105,7 @@ TEST(TraceEventDisabledCategory) {
// Disabled category, will not add events. // Disabled category, will not add events.
TRACE_EVENT_BEGIN0("cat", "e1"); TRACE_EVENT_BEGIN0("cat", "e1");
TRACE_EVENT_END0("cat", "e1"); TRACE_EVENT_END0("cat", "e1");
CHECK_EQ(0, GET_TRACE_OBJECTS_LIST->length()); CHECK(GET_TRACE_OBJECTS_LIST->empty());
} }
...@@ -118,7 +116,7 @@ TEST(TraceEventNoArgs) { ...@@ -118,7 +116,7 @@ TEST(TraceEventNoArgs) {
TRACE_EVENT_BEGIN0("v8-cat", "e1"); TRACE_EVENT_BEGIN0("v8-cat", "e1");
TRACE_EVENT_END0("v8-cat", "e1"); TRACE_EVENT_END0("v8-cat", "e1");
CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ('B', GET_TRACE_OBJECT(0)->phase); CHECK_EQ('B', GET_TRACE_OBJECT(0)->phase);
CHECK_EQ("e1", GET_TRACE_OBJECT(0)->name); CHECK_EQ("e1", GET_TRACE_OBJECT(0)->name);
CHECK_EQ(0, GET_TRACE_OBJECT(0)->num_args); CHECK_EQ(0, GET_TRACE_OBJECT(0)->num_args);
...@@ -137,7 +135,7 @@ TEST(TraceEventWithOneArg) { ...@@ -137,7 +135,7 @@ TEST(TraceEventWithOneArg) {
TRACE_EVENT_BEGIN1("v8-cat", "e2", "arg1", "abc"); TRACE_EVENT_BEGIN1("v8-cat", "e2", "arg1", "abc");
TRACE_EVENT_END1("v8-cat", "e2", "arg1", "abc"); TRACE_EVENT_END1("v8-cat", "e2", "arg1", "abc");
CHECK_EQ(4, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(4, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(1, GET_TRACE_OBJECT(0)->num_args); CHECK_EQ(1, GET_TRACE_OBJECT(0)->num_args);
CHECK_EQ(1, GET_TRACE_OBJECT(1)->num_args); CHECK_EQ(1, GET_TRACE_OBJECT(1)->num_args);
...@@ -154,7 +152,7 @@ TEST(TraceEventWithTwoArgs) { ...@@ -154,7 +152,7 @@ TEST(TraceEventWithTwoArgs) {
TRACE_EVENT_BEGIN2("v8-cat", "e2", "arg1", "abc", "arg2", 43); TRACE_EVENT_BEGIN2("v8-cat", "e2", "arg1", "abc", "arg2", 43);
TRACE_EVENT_END2("v8-cat", "e2", "arg1", "abc", "arg2", 43); TRACE_EVENT_END2("v8-cat", "e2", "arg1", "abc", "arg2", 43);
CHECK_EQ(4, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(4, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(2, GET_TRACE_OBJECT(0)->num_args); CHECK_EQ(2, GET_TRACE_OBJECT(0)->num_args);
CHECK_EQ(2, GET_TRACE_OBJECT(1)->num_args); CHECK_EQ(2, GET_TRACE_OBJECT(1)->num_args);
...@@ -168,17 +166,17 @@ TEST(ScopedTraceEvent) { ...@@ -168,17 +166,17 @@ TEST(ScopedTraceEvent) {
{ TRACE_EVENT0("v8-cat", "e"); } { TRACE_EVENT0("v8-cat", "e"); }
CHECK_EQ(1, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(1, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(0, GET_TRACE_OBJECT(0)->num_args); CHECK_EQ(0, GET_TRACE_OBJECT(0)->num_args);
{ TRACE_EVENT1("v8-cat", "e1", "arg1", "abc"); } { TRACE_EVENT1("v8-cat", "e1", "arg1", "abc"); }
CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(1, GET_TRACE_OBJECT(1)->num_args); CHECK_EQ(1, GET_TRACE_OBJECT(1)->num_args);
{ TRACE_EVENT2("v8-cat", "e1", "arg1", "abc", "arg2", 42); } { TRACE_EVENT2("v8-cat", "e1", "arg1", "abc", "arg2", 42); }
CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(2, GET_TRACE_OBJECT(2)->num_args); CHECK_EQ(2, GET_TRACE_OBJECT(2)->num_args);
} }
...@@ -197,7 +195,7 @@ TEST(TestEventWithFlow) { ...@@ -197,7 +195,7 @@ TEST(TestEventWithFlow) {
} }
{ TRACE_EVENT_WITH_FLOW0("v8-cat", "f3", bind_id, TRACE_EVENT_FLAG_FLOW_IN); } { TRACE_EVENT_WITH_FLOW0("v8-cat", "f3", bind_id, TRACE_EVENT_FLAG_FLOW_IN); }
CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(bind_id, GET_TRACE_OBJECT(0)->bind_id); CHECK_EQ(bind_id, GET_TRACE_OBJECT(0)->bind_id);
CHECK_EQ(TRACE_EVENT_FLAG_FLOW_OUT, GET_TRACE_OBJECT(0)->flags); CHECK_EQ(TRACE_EVENT_FLAG_FLOW_OUT, GET_TRACE_OBJECT(0)->flags);
CHECK_EQ(bind_id, GET_TRACE_OBJECT(1)->bind_id); CHECK_EQ(bind_id, GET_TRACE_OBJECT(1)->bind_id);
...@@ -215,7 +213,7 @@ TEST(TestEventWithId) { ...@@ -215,7 +213,7 @@ TEST(TestEventWithId) {
TRACE_EVENT_ASYNC_BEGIN0("v8-cat", "a1", event_id); TRACE_EVENT_ASYNC_BEGIN0("v8-cat", "a1", event_id);
TRACE_EVENT_ASYNC_END0("v8-cat", "a1", event_id); TRACE_EVENT_ASYNC_END0("v8-cat", "a1", event_id);
CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_BEGIN, GET_TRACE_OBJECT(0)->phase); CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_BEGIN, GET_TRACE_OBJECT(0)->phase);
CHECK_EQ(event_id, GET_TRACE_OBJECT(0)->id); CHECK_EQ(event_id, GET_TRACE_OBJECT(0)->id);
CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_END, GET_TRACE_OBJECT(1)->phase); CHECK_EQ(TRACE_EVENT_PHASE_ASYNC_END, GET_TRACE_OBJECT(1)->phase);
...@@ -231,7 +229,7 @@ TEST(TestEventInContext) { ...@@ -231,7 +229,7 @@ TEST(TestEventInContext) {
TRACE_EVENT0("v8-cat", "e"); TRACE_EVENT0("v8-cat", "e");
} }
CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->length()); CHECK_EQ(3, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(TRACE_EVENT_PHASE_ENTER_CONTEXT, GET_TRACE_OBJECT(0)->phase); CHECK_EQ(TRACE_EVENT_PHASE_ENTER_CONTEXT, GET_TRACE_OBJECT(0)->phase);
CHECK_EQ("Isolate", GET_TRACE_OBJECT(0)->name); CHECK_EQ("Isolate", GET_TRACE_OBJECT(0)->name);
CHECK_EQ(isolate_id, GET_TRACE_OBJECT(0)->id); CHECK_EQ(isolate_id, GET_TRACE_OBJECT(0)->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