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

Side by Side Diff: test/cctest/test-heap.cc

Issue 285693006: Fix Heap::IsHeapIterable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleanup Created 6 years, 7 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 | « test/cctest/test-api.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698