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

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 136001: Changed allocation to allow large objects to be allocated in new space.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 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
« src/mark-compact.cc ('K') | « test/cctest/test-heap.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // from new space. 79 // from new space.
80 FLAG_gc_global = true; 80 FLAG_gc_global = true;
81 FLAG_always_compact = true; 81 FLAG_always_compact = true;
82 Heap::ConfigureHeap(2*256*KB, 4*MB); 82 Heap::ConfigureHeap(2*256*KB, 4*MB);
83 83
84 InitializeVM(); 84 InitializeVM();
85 85
86 v8::HandleScope sc; 86 v8::HandleScope sc;
87 87
88 // Allocate a fixed array in the new space. 88 // Allocate a fixed array in the new space.
89 int array_size = 89 int array_size = (Heap::MaxObjectSizeInPagedSpace() - Array::kHeaderSize) /
90 (Heap::MaxHeapObjectSize() - Array::kHeaderSize) / (kPointerSize * 4); 90 (kPointerSize * 4);
91 Object* obj = Heap::AllocateFixedArray(array_size); 91 Object* obj = Heap::AllocateFixedArray(array_size);
92 CHECK(!obj->IsFailure()); 92 CHECK(!obj->IsFailure());
93 93
94 Handle<FixedArray> array(FixedArray::cast(obj)); 94 Handle<FixedArray> array(FixedArray::cast(obj));
95 95
96 // Array should be in the new space. 96 // Array should be in the new space.
97 CHECK(Heap::InSpace(*array, NEW_SPACE)); 97 CHECK(Heap::InSpace(*array, NEW_SPACE));
98 98
99 // Call the m-c collector, so array becomes an old object. 99 // Call the m-c collector, so array becomes an old object.
100 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); 100 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE));
(...skipping 10 matching lines...) Expand all
111 // Test the situation that some objects in new space are promoted to 111 // Test the situation that some objects in new space are promoted to
112 // the old space 112 // the old space
113 InitializeVM(); 113 InitializeVM();
114 114
115 v8::HandleScope sc; 115 v8::HandleScope sc;
116 116
117 // Do a mark compact GC to shrink the heap. 117 // Do a mark compact GC to shrink the heap.
118 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); 118 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE));
119 119
120 // Allocate a big Fixed array in the new space. 120 // Allocate a big Fixed array in the new space.
121 int size = (Heap::MaxHeapObjectSize() - Array::kHeaderSize) / kPointerSize; 121 int size = (Heap::MaxObjectSizeInPagedSpace() - Array::kHeaderSize) /
122 kPointerSize;
122 Object* obj = Heap::AllocateFixedArray(size); 123 Object* obj = Heap::AllocateFixedArray(size);
123 124
124 Handle<FixedArray> array(FixedArray::cast(obj)); 125 Handle<FixedArray> array(FixedArray::cast(obj));
125 126
126 // Array still stays in the new space. 127 // Array still stays in the new space.
127 CHECK(Heap::InSpace(*array, NEW_SPACE)); 128 CHECK(Heap::InSpace(*array, NEW_SPACE));
128 129
129 // Allocate objects in the old space until out of memory. 130 // Allocate objects in the old space until out of memory.
130 FixedArray* host = *array; 131 FixedArray* host = *array;
131 while (true) { 132 while (true) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 306 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
306 GlobalHandles::AddGroup(g1_objects, 2); 307 GlobalHandles::AddGroup(g1_objects, 2);
307 GlobalHandles::AddGroup(g2_objects, 2); 308 GlobalHandles::AddGroup(g2_objects, 2);
308 } 309 }
309 310
310 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); 311 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE));
311 312
312 // All objects should be gone. 5 global handles in total. 313 // All objects should be gone. 5 global handles in total.
313 CHECK_EQ(5, NumberOfWeakCalls); 314 CHECK_EQ(5, NumberOfWeakCalls);
314 } 315 }
OLDNEW
« src/mark-compact.cc ('K') | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698