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

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

Issue 203363003: Remove do-nothing trace traits on primitive types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/heap/Heap.h ('k') | Source/heap/Visitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 getHeapStats(&heapStats); 1436 getHeapStats(&heapStats);
1437 CheckWithSlack(baseLevel + total, heapStats.totalObjectSpace(), slack); 1437 CheckWithSlack(baseLevel + total, heapStats.totalObjectSpace(), slack);
1438 if (testPagesAllocated) 1438 if (testPagesAllocated)
1439 EXPECT_EQ(0ul, heapStats.totalAllocatedSpace() & (blinkPageSize - 1)); 1439 EXPECT_EQ(0ul, heapStats.totalAllocatedSpace() & (blinkPageSize - 1));
1440 1440
1441 for (size_t i = 0; i < persistentCount; i++) { 1441 for (size_t i = 0; i < persistentCount; i++) {
1442 delete persistents[i]; 1442 delete persistents[i];
1443 persistents[i] = 0; 1443 persistents[i] = 0;
1444 } 1444 }
1445 1445
1446 uint8_t* address = Heap::reallocate<uint8_t>(0, 100); 1446 uint8_t* address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySi zedObject>(0, 100));
1447 for (int i = 0; i < 100; i++) 1447 for (int i = 0; i < 100; i++)
1448 address[i] = i; 1448 address[i] = i;
1449 address = Heap::reallocate<uint8_t>(address, 100000); 1449 address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject >(address, 100000));
1450 for (int i = 0; i < 100; i++) 1450 for (int i = 0; i < 100; i++)
1451 EXPECT_EQ(address[i], i); 1451 EXPECT_EQ(address[i], i);
1452 address = Heap::reallocate<uint8_t>(address, 50); 1452 address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject >(address, 50));
1453 for (int i = 0; i < 50; i++) 1453 for (int i = 0; i < 50; i++)
1454 EXPECT_EQ(address[i], i); 1454 EXPECT_EQ(address[i], i);
1455 // This should be equivalent to free(address). 1455 // This should be equivalent to free(address).
1456 EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<uint8_t>(address, 0)) , 0ul); 1456 EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<DynamicallySizedObjec t>(address, 0)), 0ul);
1457 // This should be equivalent to malloc(0). 1457 // This should be equivalent to malloc(0).
1458 EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<uint8_t>(0, 0)), 0ul) ; 1458 EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<DynamicallySizedObjec t>(0, 0)), 0ul);
1459 } 1459 }
1460 1460
1461 TEST(HeapTest, SimpleAllocation) 1461 TEST(HeapTest, SimpleAllocation)
1462 { 1462 {
1463 HeapStats initialHeapStats; 1463 HeapStats initialHeapStats;
1464 clearOutOldGarbage(&initialHeapStats); 1464 clearOutOldGarbage(&initialHeapStats);
1465 EXPECT_EQ(0ul, initialHeapStats.totalObjectSpace()); 1465 EXPECT_EQ(0ul, initialHeapStats.totalObjectSpace());
1466 1466
1467 // Allocate an object in the heap. 1467 // Allocate an object in the heap.
1468 HeapAllocatedArray* array = new HeapAllocatedArray(); 1468 HeapAllocatedArray* array = new HeapAllocatedArray();
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 // swept away and zapped later in the same sweeping phase. 3006 // swept away and zapped later in the same sweeping phase.
3007 EXPECT_EQ(42, wrapper->value()); 3007 EXPECT_EQ(42, wrapper->value());
3008 3008
3009 wrapper.clear(); 3009 wrapper.clear();
3010 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 3010 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
3011 EXPECT_EQ(10, IntWrapper::s_destructorCalls); 3011 EXPECT_EQ(10, IntWrapper::s_destructorCalls);
3012 EXPECT_EQ(512, OneKiloByteObject::s_destructorCalls); 3012 EXPECT_EQ(512, OneKiloByteObject::s_destructorCalls);
3013 } 3013 }
3014 3014
3015 } // WebCore namespace 3015 } // WebCore namespace
OLDNEW
« no previous file with comments | « Source/heap/Heap.h ('k') | Source/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698