[object-stats] Add unittest for clashing instance types
Bug: v8:7266 Change-Id: I1436d39281caa9daf33289840d19a4a5e1ba476d Reviewed-on: https://chromium-review.googlesource.com/880843 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#50795}
This commit is contained in:
parent
79e91f0c14
commit
dfa36e9fab
@ -12,6 +12,7 @@
|
||||
#include "src/counters.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/heap/mark-compact.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects/compilation-cache-inl.h"
|
||||
#include "src/utils.h"
|
||||
|
@ -8,10 +8,9 @@
|
||||
#include <set>
|
||||
|
||||
#include "src/base/ieee754.h"
|
||||
#include "src/heap/heap.h"
|
||||
#include "src/heap/mark-compact.h"
|
||||
#include "src/heap/objects-visiting.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/objects/code.h"
|
||||
|
||||
// These instance types do not exist for actual use but are merely introduced
|
||||
// for object stats tracing. In contrast to Code and FixedArray sub types
|
||||
@ -60,6 +59,9 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Heap;
|
||||
class Isolate;
|
||||
|
||||
class ObjectStats {
|
||||
public:
|
||||
static const size_t kNoOverAllocation = 0;
|
||||
|
@ -143,6 +143,7 @@ v8_source_set("unittests_sources") {
|
||||
"heap/item-parallel-job-unittest.cc",
|
||||
"heap/marking-unittest.cc",
|
||||
"heap/memory-reducer-unittest.cc",
|
||||
"heap/object-stats-unittest.cc",
|
||||
"heap/scavenge-job-unittest.cc",
|
||||
"heap/slot-set-unittest.cc",
|
||||
"heap/spaces-unittest.cc",
|
||||
|
38
test/unittests/heap/object-stats-unittest.cc
Normal file
38
test/unittests/heap/object-stats-unittest.cc
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2018 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.
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "src/heap/object-stats.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects/fixed-array-inl.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace heap {
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
bool Contains(const std::unordered_set<T>& set, T needle) {
|
||||
return set.find(needle) != set.end();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(ObjectStats, NoClashWithInstanceTypes) {
|
||||
std::unordered_set<const char*> virtual_types;
|
||||
#define ADD_VIRTUAL_INSTANCE_TYPE(type) virtual_types.insert(#type);
|
||||
VIRTUAL_INSTANCE_TYPE_LIST(ADD_VIRTUAL_INSTANCE_TYPE)
|
||||
#undef ADD_VIRTUAL_INSTANCE_TYPE
|
||||
#define CHECK_REGULARINSTANCE_TYPE(type) \
|
||||
EXPECT_FALSE(Contains(virtual_types, #type));
|
||||
INSTANCE_TYPE_LIST(CHECK_REGULARINSTANCE_TYPE)
|
||||
#undef CHECK_REGULARINSTANCE_TYPE
|
||||
}
|
||||
|
||||
} // namespace heap
|
||||
} // namespace internal
|
||||
} // namespace v8
|
@ -115,6 +115,7 @@
|
||||
'heap/item-parallel-job-unittest.cc',
|
||||
'heap/marking-unittest.cc',
|
||||
'heap/memory-reducer-unittest.cc',
|
||||
'heap/object-stats-unittest.cc',
|
||||
'heap/heap-unittest.cc',
|
||||
'heap/scavenge-job-unittest.cc',
|
||||
'heap/slot-set-unittest.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user