| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 DeleteArray(non_ascii); | 739 DeleteArray(non_ascii); |
| 740 DeleteArray(ascii); | 740 DeleteArray(ascii); |
| 741 } | 741 } |
| 742 } | 742 } |
| 743 | 743 |
| 744 | 744 |
| 745 static int ObjectsFoundInHeap(Handle<Object> objs[], int size) { | 745 static int ObjectsFoundInHeap(Handle<Object> objs[], int size) { |
| 746 // Count the number of objects found in the heap. | 746 // Count the number of objects found in the heap. |
| 747 int found_count = 0; | 747 int found_count = 0; |
| 748 HeapIterator iterator; | 748 HeapIterator iterator; |
| 749 while (iterator.has_next()) { | 749 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 750 HeapObject* obj = iterator.next(); | |
| 751 CHECK(obj != NULL); | |
| 752 for (int i = 0; i < size; i++) { | 750 for (int i = 0; i < size; i++) { |
| 753 if (*objs[i] == obj) { | 751 if (*objs[i] == obj) { |
| 754 found_count++; | 752 found_count++; |
| 755 } | 753 } |
| 756 } | 754 } |
| 757 } | 755 } |
| 758 CHECK(!iterator.has_next()); | |
| 759 return found_count; | 756 return found_count; |
| 760 } | 757 } |
| 761 | 758 |
| 762 | 759 |
| 763 TEST(Iteration) { | 760 TEST(Iteration) { |
| 764 InitializeVM(); | 761 InitializeVM(); |
| 765 v8::HandleScope scope; | 762 v8::HandleScope scope; |
| 766 | 763 |
| 767 // Array of objects to scan haep for. | 764 // Array of objects to scan haep for. |
| 768 const int objs_count = 6; | 765 const int objs_count = 6; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 787 objs[next_objs_index++] = | 784 objs[next_objs_index++] = |
| 788 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 785 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
| 789 delete[] str; | 786 delete[] str; |
| 790 | 787 |
| 791 // Add a Map object to look for. | 788 // Add a Map object to look for. |
| 792 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 789 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
| 793 | 790 |
| 794 CHECK_EQ(objs_count, next_objs_index); | 791 CHECK_EQ(objs_count, next_objs_index); |
| 795 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 792 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
| 796 } | 793 } |
| OLD | NEW |