| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 | 2 |
| 3 #include <stdlib.h> | 3 #include <stdlib.h> |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "execution.h" | 7 #include "execution.h" |
| 8 #include "factory.h" | 8 #include "factory.h" |
| 9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
| 10 #include "global-handles.h" | 10 #include "global-handles.h" |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 InitializeVM(); | 1191 InitializeVM(); |
| 1192 HEAP->EnsureHeapIsIterable(); | 1192 HEAP->EnsureHeapIsIterable(); |
| 1193 intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); | 1193 intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); |
| 1194 HeapIterator iterator; | 1194 HeapIterator iterator; |
| 1195 intptr_t size_of_objects_2 = 0; | 1195 intptr_t size_of_objects_2 = 0; |
| 1196 for (HeapObject* obj = iterator.next(); | 1196 for (HeapObject* obj = iterator.next(); |
| 1197 obj != NULL; | 1197 obj != NULL; |
| 1198 obj = iterator.next()) { | 1198 obj = iterator.next()) { |
| 1199 size_of_objects_2 += obj->Size(); | 1199 size_of_objects_2 += obj->Size(); |
| 1200 } | 1200 } |
| 1201 // Delta must be within 5% of the larger result. | 1201 // Delta must be within 1% of the larger result. |
| 1202 // TODO(gc): Tighten this up by distinguishing between byte | |
| 1203 // arrays that are real and those that merely mark free space | |
| 1204 // on the heap. | |
| 1205 if (size_of_objects_1 > size_of_objects_2) { | 1202 if (size_of_objects_1 > size_of_objects_2) { |
| 1206 intptr_t delta = size_of_objects_1 - size_of_objects_2; | 1203 intptr_t delta = size_of_objects_1 - size_of_objects_2; |
| 1207 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " | 1204 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " |
| 1208 "Iterator: %" V8_PTR_PREFIX "d, " | 1205 "Iterator: %" V8_PTR_PREFIX "d, " |
| 1209 "delta: %" V8_PTR_PREFIX "d\n", | 1206 "delta: %" V8_PTR_PREFIX "d\n", |
| 1210 size_of_objects_1, size_of_objects_2, delta); | 1207 size_of_objects_1, size_of_objects_2, delta); |
| 1211 CHECK_GT(size_of_objects_1 / 20, delta); | 1208 CHECK_GT(size_of_objects_1 / 100, delta); |
| 1212 } else { | 1209 } else { |
| 1213 intptr_t delta = size_of_objects_2 - size_of_objects_1; | 1210 intptr_t delta = size_of_objects_2 - size_of_objects_1; |
| 1214 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " | 1211 PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " |
| 1215 "Iterator: %" V8_PTR_PREFIX "d, " | 1212 "Iterator: %" V8_PTR_PREFIX "d, " |
| 1216 "delta: %" V8_PTR_PREFIX "d\n", | 1213 "delta: %" V8_PTR_PREFIX "d\n", |
| 1217 size_of_objects_1, size_of_objects_2, delta); | 1214 size_of_objects_1, size_of_objects_2, delta); |
| 1218 CHECK_GT(size_of_objects_2 / 20, delta); | 1215 CHECK_GT(size_of_objects_2 / 20, delta); |
| 1219 } | 1216 } |
| 1220 } | 1217 } |
| 1221 | 1218 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 ctx2->Exit(); | 1466 ctx2->Exit(); |
| 1470 ctx1->Exit(); | 1467 ctx1->Exit(); |
| 1471 ctx1.Dispose(); | 1468 ctx1.Dispose(); |
| 1472 } | 1469 } |
| 1473 HEAP->CollectAllAvailableGarbage(); | 1470 HEAP->CollectAllAvailableGarbage(); |
| 1474 CHECK_EQ(2, NumberOfGlobalObjects()); | 1471 CHECK_EQ(2, NumberOfGlobalObjects()); |
| 1475 ctx2.Dispose(); | 1472 ctx2.Dispose(); |
| 1476 HEAP->CollectAllAvailableGarbage(); | 1473 HEAP->CollectAllAvailableGarbage(); |
| 1477 CHECK_EQ(0, NumberOfGlobalObjects()); | 1474 CHECK_EQ(0, NumberOfGlobalObjects()); |
| 1478 } | 1475 } |
| OLD | NEW |