Line data Source code
1 : // Copyright 2018 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include <unordered_set>
6 :
7 : #include "src/heap/object-stats.h"
8 : #include "src/objects-inl.h"
9 : #include "src/objects/fixed-array-inl.h"
10 : #include "testing/gtest/include/gtest/gtest.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 : namespace heap {
15 :
16 : namespace {
17 :
18 : template <typename T>
19 : bool Contains(const std::unordered_set<T>& set, T needle) {
20 : return set.find(needle) != set.end();
21 : }
22 :
23 : } // namespace
24 :
25 15418 : TEST(ObjectStats, NoClashWithInstanceTypes) {
26 : std::unordered_set<const char*> virtual_types;
27 : #define ADD_VIRTUAL_INSTANCE_TYPE(type) virtual_types.insert(#type);
28 79 : VIRTUAL_INSTANCE_TYPE_LIST(ADD_VIRTUAL_INSTANCE_TYPE)
29 : #undef ADD_VIRTUAL_INSTANCE_TYPE
30 : #define CHECK_REGULARINSTANCE_TYPE(type) \
31 : EXPECT_FALSE(Contains(virtual_types, #type));
32 364 : INSTANCE_TYPE_LIST(CHECK_REGULARINSTANCE_TYPE)
33 : #undef CHECK_REGULARINSTANCE_TYPE
34 1 : }
35 :
36 : } // namespace heap
37 : } // namespace internal
38 9249 : } // namespace v8
|