| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 CHECK_EQ(length, ascii_str->length()); | 883 CHECK_EQ(length, ascii_str->length()); |
| 884 DeleteArray(non_ascii); | 884 DeleteArray(non_ascii); |
| 885 DeleteArray(ascii); | 885 DeleteArray(ascii); |
| 886 } | 886 } |
| 887 } | 887 } |
| 888 | 888 |
| 889 | 889 |
| 890 static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) { | 890 static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) { |
| 891 // Count the number of objects found in the heap. | 891 // Count the number of objects found in the heap. |
| 892 int found_count = 0; | 892 int found_count = 0; |
| 893 heap->EnsureHeapIsIterable(); | |
| 894 HeapIterator iterator(heap); | 893 HeapIterator iterator(heap); |
| 895 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 894 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 896 for (int i = 0; i < size; i++) { | 895 for (int i = 0; i < size; i++) { |
| 897 if (*objs[i] == obj) { | 896 if (*objs[i] == obj) { |
| 898 found_count++; | 897 found_count++; |
| 899 } | 898 } |
| 900 } | 899 } |
| 901 } | 900 } |
| 902 return found_count; | 901 return found_count; |
| 903 } | 902 } |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 // Waiting for sweeper threads should not change heap size. | 1621 // Waiting for sweeper threads should not change heap size. |
| 1623 if (collector->IsConcurrentSweepingInProgress()) { | 1622 if (collector->IsConcurrentSweepingInProgress()) { |
| 1624 collector->WaitUntilSweepingCompleted(); | 1623 collector->WaitUntilSweepingCompleted(); |
| 1625 } | 1624 } |
| 1626 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); | 1625 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); |
| 1627 } | 1626 } |
| 1628 | 1627 |
| 1629 | 1628 |
| 1630 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { | 1629 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { |
| 1631 CcTest::InitializeVM(); | 1630 CcTest::InitializeVM(); |
| 1632 CcTest::heap()->EnsureHeapIsIterable(); | 1631 HeapIterator iterator(CcTest::heap()); |
| 1633 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); | 1632 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); |
| 1634 HeapIterator iterator(CcTest::heap()); | |
| 1635 intptr_t size_of_objects_2 = 0; | 1633 intptr_t size_of_objects_2 = 0; |
| 1636 for (HeapObject* obj = iterator.next(); | 1634 for (HeapObject* obj = iterator.next(); |
| 1637 obj != NULL; | 1635 obj != NULL; |
| 1638 obj = iterator.next()) { | 1636 obj = iterator.next()) { |
| 1639 if (!obj->IsFreeSpace()) { | 1637 if (!obj->IsFreeSpace()) { |
| 1640 size_of_objects_2 += obj->Size(); | 1638 size_of_objects_2 += obj->Size(); |
| 1641 } | 1639 } |
| 1642 } | 1640 } |
| 1643 // Delta must be within 5% of the larger result. | 1641 // Delta must be within 5% of the larger result. |
| 1644 // TODO(gc): Tighten this up by distinguishing between byte | 1642 // TODO(gc): Tighten this up by distinguishing between byte |
| (...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4244 "array;"); | 4242 "array;"); |
| 4245 | 4243 |
| 4246 Handle<JSObject> o = | 4244 Handle<JSObject> o = |
| 4247 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4245 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
| 4248 CHECK(heap->InOldPointerSpace(o->elements())); | 4246 CHECK(heap->InOldPointerSpace(o->elements())); |
| 4249 CHECK(heap->InOldPointerSpace(*o)); | 4247 CHECK(heap->InOldPointerSpace(*o)); |
| 4250 Page* page = Page::FromAddress(o->elements()->address()); | 4248 Page* page = Page::FromAddress(o->elements()->address()); |
| 4251 CHECK(page->WasSwept() || | 4249 CHECK(page->WasSwept() || |
| 4252 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4250 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
| 4253 } | 4251 } |
| OLD | NEW |