Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/heap/HeapTest.cpp

Issue 189543014: Ensure proper finalization of garbage-collected types. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: removed dtor from HeapSupplement and derived classes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 bool isLastInArray() const { return m_isLast; } 1101 bool isLastInArray() const { return m_isLast; }
1102 void setLastInArray(bool value) { m_isLast = value; } 1102 void setLastInArray(bool value) { m_isLast = value; }
1103 1103
1104 IntWrapper* payload() const { return m_payload; } 1104 IntWrapper* payload() const { return m_payload; }
1105 1105
1106 private: 1106 private:
1107 Member<IntWrapper> m_payload; 1107 Member<IntWrapper> m_payload;
1108 bool m_isLast; 1108 bool m_isLast;
1109 }; 1109 };
1110 1110
1111 } // WebCore namespace
1112
1113 namespace WTF {
1114
1115 // We need the below vector trait specialization for the above HeapVectors to be have correctly wrt. memset, memcmp etc.
1116 template<> struct VectorTraits<WebCore::VectorObject> : public SimpleClassVector Traits<WebCore::VectorObject> { };
1117 template<> struct VectorTraits<WebCore::VectorObjectInheritedTrace> : public Sim pleClassVectorTraits<WebCore::VectorObjectInheritedTrace> { };
1118 template<> struct VectorTraits<WebCore::VectorObjectNoTrace> : public SimpleClas sVectorTraits<WebCore::VectorObjectNoTrace> { };
1119
1120 } // WTF namespace
1121
1122 namespace WebCore {
1123
1111 TEST(HeapTest, Transition) 1124 TEST(HeapTest, Transition)
1112 { 1125 {
1113 { 1126 {
1114 RefPtr<TransitionRefCounted> refCounted = TransitionRefCounted::create() ; 1127 RefPtr<TransitionRefCounted> refCounted = TransitionRefCounted::create() ;
1115 EXPECT_EQ(1, TransitionRefCounted::s_aliveCount); 1128 EXPECT_EQ(1, TransitionRefCounted::s_aliveCount);
1116 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 1129 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
1117 EXPECT_EQ(1, TransitionRefCounted::s_aliveCount); 1130 EXPECT_EQ(1, TransitionRefCounted::s_aliveCount);
1118 } 1131 }
1119 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 1132 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
1120 EXPECT_EQ(0, TransitionRefCounted::s_aliveCount); 1133 EXPECT_EQ(0, TransitionRefCounted::s_aliveCount);
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 for (size_t i = 0; i < prefixSize + suffixSize; i++) 2817 for (size_t i = 0; i < prefixSize + suffixSize; i++)
2805 EXPECT_EQ(i, static_cast<size_t>(arr->at(i).payload()->value())); 2818 EXPECT_EQ(i, static_cast<size_t>(arr->at(i).payload()->value()));
2806 } 2819 }
2807 2820
2808 arr = 0; 2821 arr = 0;
2809 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 2822 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
2810 EXPECT_EQ(8, IntWrapper::s_destructorCalls); 2823 EXPECT_EQ(8, IntWrapper::s_destructorCalls);
2811 } 2824 }
2812 2825
2813 } // WebCore namespace 2826 } // WebCore namespace
2814
2815 namespace WTF {
2816
2817 // We need the below vector trait specialization for the above HeapVectors to be have correctly wrt. memset, memcmp etc.
2818 template<> struct VectorTraits<WebCore::VectorObject> : public SimpleClassVector Traits<WebCore::VectorObject> { };
2819 template<> struct VectorTraits<WebCore::VectorObjectInheritedTrace> : public Sim pleClassVectorTraits<WebCore::VectorObjectInheritedTrace> { };
2820 template<> struct VectorTraits<WebCore::VectorObjectNoTrace> : public SimpleClas sVectorTraits<WebCore::VectorObjectNoTrace> { };
2821
2822 } // WTF namespace
2823
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698