OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |