aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-heap-profiler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/test-heap-profiler.cc')
-rw-r--r--deps/v8/test/cctest/test-heap-profiler.cc109
1 files changed, 21 insertions, 88 deletions
diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc
index e4e5f4c8dc..257ef1c723 100644
--- a/deps/v8/test/cctest/test-heap-profiler.cc
+++ b/deps/v8/test/cctest/test-heap-profiler.cc
@@ -157,12 +157,9 @@ static Optional<SourceLocation> GetLocation(const v8::HeapSnapshot* s,
const v8::HeapGraphNode* node) {
const i::HeapSnapshot* snapshot = reinterpret_cast<const i::HeapSnapshot*>(s);
const std::vector<SourceLocation>& locations = snapshot->locations();
- const int index =
- const_cast<i::HeapEntry*>(reinterpret_cast<const i::HeapEntry*>(node))
- ->index();
-
+ const i::HeapEntry* entry = reinterpret_cast<const i::HeapEntry*>(node);
for (const auto& loc : locations) {
- if (loc.entry_index == index) {
+ if (loc.entry_index == entry->index()) {
return Optional<SourceLocation>(loc);
}
}
@@ -223,7 +220,7 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) {
entry->value = reinterpret_cast<void*>(ref_count + 1);
}
uint32_t unretained_entries_count = 0;
- std::vector<i::HeapEntry>& entries = heap_snapshot->entries();
+ std::deque<i::HeapEntry>& entries = heap_snapshot->entries();
for (i::HeapEntry& entry : entries) {
v8::base::HashMap::Entry* map_entry = visited.Lookup(
reinterpret_cast<void*>(&entry),
@@ -506,9 +503,6 @@ TEST(HeapSnapshotHeapNumbers) {
}
TEST(HeapSnapshotHeapBigInts) {
- // TODO(luoe): remove flag when it is on by default.
- v8::internal::FLAG_harmony_bigint = true;
-
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@@ -686,7 +680,7 @@ TEST(HeapSnapshotWeakCollection) {
++weak_entries;
}
}
- CHECK_EQ(1, weak_entries); // Key is the only weak.
+ CHECK_EQ(2, weak_entries); // Key and value are weak.
const v8::HeapGraphNode* wm_s =
GetProperty(env->GetIsolate(), wm, v8::HeapGraphEdge::kProperty, "str");
CHECK(wm_s);
@@ -1003,21 +997,6 @@ TEST(HeapEntryIdsAndGC) {
CHECK_EQ(b1->GetId(), b2->GetId());
}
-
-TEST(HeapSnapshotRootPreservedAfterSorting) {
- LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
- const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
- CHECK(ValidateSnapshot(snapshot));
- const v8::HeapGraphNode* root1 = snapshot->GetRoot();
- const_cast<i::HeapSnapshot*>(reinterpret_cast<const i::HeapSnapshot*>(
- snapshot))->GetSortedEntriesList();
- const v8::HeapGraphNode* root2 = snapshot->GetRoot();
- CHECK_EQ(root1, root2);
-}
-
-
namespace {
class TestJSONStream : public v8::OutputStream {
@@ -1025,9 +1004,9 @@ class TestJSONStream : public v8::OutputStream {
TestJSONStream() : eos_signaled_(0), abort_countdown_(-1) {}
explicit TestJSONStream(int abort_countdown)
: eos_signaled_(0), abort_countdown_(abort_countdown) {}
- virtual ~TestJSONStream() {}
- virtual void EndOfStream() { ++eos_signaled_; }
- virtual WriteResult WriteAsciiChunk(char* buffer, int chars_written) {
+ ~TestJSONStream() override = default;
+ void EndOfStream() override { ++eos_signaled_; }
+ WriteResult WriteAsciiChunk(char* buffer, int chars_written) override {
if (abort_countdown_ > 0) --abort_countdown_;
if (abort_countdown_ == 0) return kAbort;
CHECK_GT(chars_written, 0);
@@ -1053,8 +1032,9 @@ class OneByteResource : public v8::String::ExternalOneByteStringResource {
explicit OneByteResource(i::Vector<char> string) : data_(string.start()) {
length_ = string.length();
}
- virtual const char* data() const { return data_; }
- virtual size_t length() const { return length_; }
+ const char* data() const override { return data_; }
+ size_t length() const override { return length_; }
+
private:
const char* data_;
size_t length_;
@@ -1215,20 +1195,15 @@ class TestStatsStream : public v8::OutputStream {
intervals_count_(0),
first_interval_index_(-1) { }
TestStatsStream(const TestStatsStream& stream)
- : v8::OutputStream(stream),
- eos_signaled_(stream.eos_signaled_),
- updates_written_(stream.updates_written_),
- entries_count_(stream.entries_count_),
- entries_size_(stream.entries_size_),
- intervals_count_(stream.intervals_count_),
- first_interval_index_(stream.first_interval_index_) { }
- virtual ~TestStatsStream() {}
- virtual void EndOfStream() { ++eos_signaled_; }
- virtual WriteResult WriteAsciiChunk(char* buffer, int chars_written) {
+
+ = default;
+ ~TestStatsStream() override = default;
+ void EndOfStream() override { ++eos_signaled_; }
+ WriteResult WriteAsciiChunk(char* buffer, int chars_written) override {
UNREACHABLE();
}
- virtual WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* buffer,
- int updates_written) {
+ WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* buffer,
+ int updates_written) override {
++intervals_count_;
CHECK(updates_written);
updates_written_ += updates_written;
@@ -1533,7 +1508,7 @@ class TestActivityControl : public v8::ActivityControl {
total_(0),
abort_count_(abort_count),
reported_finish_(false) {}
- ControlOption ReportProgressValue(int done, int total) {
+ ControlOption ReportProgressValue(int done, int total) override {
done_ = done;
total_ = total;
CHECK_LE(done_, total_);
@@ -1610,7 +1585,7 @@ class EmbedderGraphBuilder : public v8::PersistentHandleVisitor {
public:
explicit Group(const char* name) : Node(name, 0) {}
// v8::EmbedderGraph::EmbedderNode
- bool IsRootNode() { return true; }
+ bool IsRootNode() override { return true; }
};
EmbedderGraphBuilder(v8::Isolate* isolate, v8::EmbedderGraph* graph)
@@ -1784,7 +1759,7 @@ TEST(DeleteHeapSnapshot) {
class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
public:
- virtual const char* GetName(v8::Local<v8::Object> object) {
+ const char* GetName(v8::Local<v8::Object> object) override {
return "Global object name";
}
};
@@ -3062,7 +3037,7 @@ class EmbedderRootNode : public EmbedderNode {
public:
explicit EmbedderRootNode(const char* name) : EmbedderNode(name, 0) {}
// Graph::Node override.
- bool IsRootNode() { return true; }
+ bool IsRootNode() override { return true; }
};
// Used to pass the global object to the BuildEmbedderGraph callback.
@@ -3900,45 +3875,3 @@ TEST(WeakReference) {
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot));
}
-
-TEST(Bug8373_1) {
- LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
-
- heap_profiler->StartSamplingHeapProfiler(100);
-
- heap_profiler->TakeHeapSnapshot();
- // Causes the StringsStorage to be deleted.
- heap_profiler->DeleteAllHeapSnapshots();
-
- // Triggers an allocation sample that tries to use the StringsStorage.
- for (int i = 0; i < 2 * 1024; ++i) {
- CompileRun(
- "new Array(64);"
- "new Uint8Array(16);");
- }
-
- heap_profiler->StopSamplingHeapProfiler();
-}
-
-TEST(Bug8373_2) {
- LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
-
- heap_profiler->StartTrackingHeapObjects(true);
-
- heap_profiler->TakeHeapSnapshot();
- // Causes the StringsStorage to be deleted.
- heap_profiler->DeleteAllHeapSnapshots();
-
- // Triggers an allocations that try to use the StringsStorage.
- for (int i = 0; i < 2 * 1024; ++i) {
- CompileRun(
- "new Array(64);"
- "new Uint8Array(16);");
- }
-
- heap_profiler->StopTrackingHeapObjects();
-}