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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: Created 3 years, 11 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
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 void markHeader(HeapObjectHeader* header, TraceCallback callback) override { 330 void markHeader(HeapObjectHeader* header, TraceCallback callback) override {
331 ASSERT(header->payload()); 331 ASSERT(header->payload());
332 m_count++; 332 m_count++;
333 } 333 }
334 334
335 void registerDelayedMarkNoTracing(const void*) override {} 335 void registerDelayedMarkNoTracing(const void*) override {}
336 void registerWeakMembers(const void*, const void*, WeakCallback) override {} 336 void registerWeakMembers(const void*, const void*, WeakCallback) override {}
337 void registerWeakTable(const void*, 337 void registerWeakTable(const void*,
338 EphemeronCallback, 338 EphemeronCallback,
339 EphemeronCallback) override {} 339 EphemeronCallback) override {}
340 #if ENABLE(ASSERT) 340 #if DCHECK_IS_ON()
341 bool weakTableRegistered(const void*) override { return false; } 341 bool weakTableRegistered(const void*) override { return false; }
342 #endif 342 #endif
343 void registerWeakCellWithCallback(void**, WeakCallback) override {} 343 void registerWeakCellWithCallback(void**, WeakCallback) override {}
344 bool ensureMarked(const void* objectPointer) override { 344 bool ensureMarked(const void* objectPointer) override {
345 if (!objectPointer || 345 if (!objectPointer ||
346 HeapObjectHeader::fromPayload(objectPointer)->isMarked()) 346 HeapObjectHeader::fromPayload(objectPointer)->isMarked())
347 return false; 347 return false;
348 markNoTracing(objectPointer); 348 markNoTracing(objectPointer);
349 return true; 349 return true;
350 } 350 }
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 SimpleFinalizedObject::create(); 1825 SimpleFinalizedObject::create();
1826 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); 1826 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
1827 preciselyCollectGarbage(); 1827 preciselyCollectGarbage();
1828 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); 1828 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
1829 } 1829 }
1830 1830
1831 preciselyCollectGarbage(); 1831 preciselyCollectGarbage();
1832 EXPECT_EQ(1, SimpleFinalizedObject::s_destructorCalls); 1832 EXPECT_EQ(1, SimpleFinalizedObject::s_destructorCalls);
1833 } 1833 }
1834 1834
1835 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) 1835 #if DCHECK_IS_ON() || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER)
1836 TEST(HeapTest, FreelistReuse) { 1836 TEST(HeapTest, FreelistReuse) {
1837 clearOutOldGarbage(); 1837 clearOutOldGarbage();
1838 1838
1839 for (int i = 0; i < 100; i++) 1839 for (int i = 0; i < 100; i++)
1840 new IntWrapper(i); 1840 new IntWrapper(i);
1841 IntWrapper* p1 = new IntWrapper(100); 1841 IntWrapper* p1 = new IntWrapper(100);
1842 preciselyCollectGarbage(); 1842 preciselyCollectGarbage();
1843 // In non-production builds, we delay reusing freed memory for at least 1843 // In non-production builds, we delay reusing freed memory for at least
1844 // one GC cycle. 1844 // one GC cycle.
1845 for (int i = 0; i < 100; i++) { 1845 for (int i = 0; i < 100; i++) {
(...skipping 4053 matching lines...) Expand 10 before | Expand all | Expand 10 after
5899 static int sTraceLazy; 5899 static int sTraceLazy;
5900 }; 5900 };
5901 5901
5902 int DeepEagerly::sTraceCalls = 0; 5902 int DeepEagerly::sTraceCalls = 0;
5903 int DeepEagerly::sTraceLazy = 0; 5903 int DeepEagerly::sTraceLazy = 0;
5904 5904
5905 TEST(HeapTest, TraceDeepEagerly) { 5905 TEST(HeapTest, TraceDeepEagerly) {
5906 // The allocation & GC overhead is considerable for this test, 5906 // The allocation & GC overhead is considerable for this test,
5907 // straining debug builds and lower-end targets too much to be 5907 // straining debug builds and lower-end targets too much to be
5908 // worth running. 5908 // worth running.
5909 #if !ENABLE(ASSERT) && !OS(ANDROID) 5909 #if !DCHECK_IS_ON() && !OS(ANDROID)
5910 DeepEagerly* obj = nullptr; 5910 DeepEagerly* obj = nullptr;
5911 for (int i = 0; i < 10000000; i++) 5911 for (int i = 0; i < 10000000; i++)
5912 obj = new DeepEagerly(obj); 5912 obj = new DeepEagerly(obj);
5913 5913
5914 Persistent<DeepEagerly> persistent(obj); 5914 Persistent<DeepEagerly> persistent(obj);
5915 preciselyCollectGarbage(); 5915 preciselyCollectGarbage();
5916 5916
5917 // Verify that the DeepEagerly chain isn't completely unravelled 5917 // Verify that the DeepEagerly chain isn't completely unravelled
5918 // by performing eager trace() calls, but the explicit mark 5918 // by performing eager trace() calls, but the explicit mark
5919 // stack is switched once some nesting limit is exceeded. 5919 // stack is switched once some nesting limit is exceeded.
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
6567 "HeapVector"); 6567 "HeapVector");
6568 static_assert( 6568 static_assert(
6569 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, 6569 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value,
6570 "HeapDeque"); 6570 "HeapDeque");
6571 static_assert(WTF::IsGarbageCollectedType< 6571 static_assert(WTF::IsGarbageCollectedType<
6572 HeapTerminatedArray<Member<IntWrapper>>>::value, 6572 HeapTerminatedArray<Member<IntWrapper>>>::value,
6573 "HeapTerminatedArray"); 6573 "HeapTerminatedArray");
6574 } 6574 }
6575 6575
6576 } // namespace blink 6576 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698