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

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

Issue 12217106: Don't use TLS for space iterators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed feedback. Created 7 years, 10 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-debug.cc ('k') | no next file » | 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 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "compilation-cache.h" 7 #include "compilation-cache.h"
8 #include "execution.h" 8 #include "execution.h"
9 #include "factory.h" 9 #include "factory.h"
10 #include "macro-assembler.h" 10 #include "macro-assembler.h"
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 Handle<String> ascii_str = 813 Handle<String> ascii_str =
814 FACTORY->NewStringFromUtf8(Vector<const char>(ascii, length)); 814 FACTORY->NewStringFromUtf8(Vector<const char>(ascii, length));
815 ascii_str->Hash(); 815 ascii_str->Hash();
816 CHECK_EQ(length, ascii_str->length()); 816 CHECK_EQ(length, ascii_str->length());
817 DeleteArray(non_ascii); 817 DeleteArray(non_ascii);
818 DeleteArray(ascii); 818 DeleteArray(ascii);
819 } 819 }
820 } 820 }
821 821
822 822
823 static int ObjectsFoundInHeap(Handle<Object> objs[], int size) { 823 static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) {
824 // Count the number of objects found in the heap. 824 // Count the number of objects found in the heap.
825 int found_count = 0; 825 int found_count = 0;
826 HeapIterator iterator; 826 HeapIterator iterator(heap);
827 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 827 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
828 for (int i = 0; i < size; i++) { 828 for (int i = 0; i < size; i++) {
829 if (*objs[i] == obj) { 829 if (*objs[i] == obj) {
830 found_count++; 830 found_count++;
831 } 831 }
832 } 832 }
833 } 833 }
834 return found_count; 834 return found_count;
835 } 835 }
836 836
(...skipping 25 matching lines...) Expand all
862 for (int i = 0; i < large_size - 1; ++i) str[i] = 'a'; 862 for (int i = 0; i < large_size - 1; ++i) str[i] = 'a';
863 str[large_size - 1] = '\0'; 863 str[large_size - 1] = '\0';
864 objs[next_objs_index++] = 864 objs[next_objs_index++] =
865 FACTORY->NewStringFromAscii(CStrVector(str), TENURED); 865 FACTORY->NewStringFromAscii(CStrVector(str), TENURED);
866 delete[] str; 866 delete[] str;
867 867
868 // Add a Map object to look for. 868 // Add a Map object to look for.
869 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); 869 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map());
870 870
871 CHECK_EQ(objs_count, next_objs_index); 871 CHECK_EQ(objs_count, next_objs_index);
872 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); 872 CHECK_EQ(objs_count, ObjectsFoundInHeap(HEAP, objs, objs_count));
873 } 873 }
874 874
875 875
876 TEST(EmptyHandleEscapeFrom) { 876 TEST(EmptyHandleEscapeFrom) {
877 InitializeVM(); 877 InitializeVM();
878 878
879 v8::HandleScope scope; 879 v8::HandleScope scope;
880 Handle<JSObject> runaway; 880 Handle<JSObject> runaway;
881 881
882 { 882 {
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 HEAP->old_pointer_space()->AdvanceSweeper(KB); 1458 HEAP->old_pointer_space()->AdvanceSweeper(KB);
1459 CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); 1459 CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
1460 } 1460 }
1461 } 1461 }
1462 1462
1463 1463
1464 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { 1464 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
1465 InitializeVM(); 1465 InitializeVM();
1466 HEAP->EnsureHeapIsIterable(); 1466 HEAP->EnsureHeapIsIterable();
1467 intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); 1467 intptr_t size_of_objects_1 = HEAP->SizeOfObjects();
1468 HeapIterator iterator; 1468 HeapIterator iterator(HEAP);
1469 intptr_t size_of_objects_2 = 0; 1469 intptr_t size_of_objects_2 = 0;
1470 for (HeapObject* obj = iterator.next(); 1470 for (HeapObject* obj = iterator.next();
1471 obj != NULL; 1471 obj != NULL;
1472 obj = iterator.next()) { 1472 obj = iterator.next()) {
1473 if (!obj->IsFreeSpace()) { 1473 if (!obj->IsFreeSpace()) {
1474 size_of_objects_2 += obj->Size(); 1474 size_of_objects_2 += obj->Size();
1475 } 1475 }
1476 } 1476 }
1477 // Delta must be within 5% of the larger result. 1477 // Delta must be within 5% of the larger result.
1478 // TODO(gc): Tighten this up by distinguishing between byte 1478 // TODO(gc): Tighten this up by distinguishing between byte
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 CHECK(2 * old_capacity == new_capacity); 1579 CHECK(2 * old_capacity == new_capacity);
1580 FillUpNewSpace(new_space); 1580 FillUpNewSpace(new_space);
1581 HEAP->CollectAllAvailableGarbage(); 1581 HEAP->CollectAllAvailableGarbage();
1582 new_capacity = new_space->Capacity(); 1582 new_capacity = new_space->Capacity();
1583 CHECK(old_capacity == new_capacity); 1583 CHECK(old_capacity == new_capacity);
1584 } 1584 }
1585 1585
1586 1586
1587 static int NumberOfGlobalObjects() { 1587 static int NumberOfGlobalObjects() {
1588 int count = 0; 1588 int count = 0;
1589 HeapIterator iterator; 1589 HeapIterator iterator(HEAP);
1590 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 1590 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
1591 if (obj->IsGlobalObject()) count++; 1591 if (obj->IsGlobalObject()) count++;
1592 } 1592 }
1593 return count; 1593 return count;
1594 } 1594 }
1595 1595
1596 1596
1597 // Test that we don't embed maps from foreign contexts into 1597 // Test that we don't embed maps from foreign contexts into
1598 // optimized code. 1598 // optimized code.
1599 TEST(LeakNativeContextViaMap) { 1599 TEST(LeakNativeContextViaMap) {
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 // Now optimize the function so that it is taken off the candidate list. 2830 // Now optimize the function so that it is taken off the candidate list.
2831 { 2831 {
2832 HandleScope inner_scope; 2832 HandleScope inner_scope;
2833 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); 2833 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);");
2834 } 2834 }
2835 2835
2836 // This cycle will bust the heap and subsequent cycles will go ballistic. 2836 // This cycle will bust the heap and subsequent cycles will go ballistic.
2837 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2837 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2838 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2838 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2839 } 2839 }
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698