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

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

Issue 155687: Make Array::kHeaderSize protected, and only use kHeaderSize of its subclasses... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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-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 = (Heap::MaxObjectSizeInPagedSpace() - Array::kHeaderSize) / 89 int array_size =
90 (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) /
90 (kPointerSize * 4); 91 (kPointerSize * 4);
91 Object* obj = Heap::AllocateFixedArray(array_size); 92 Object* obj = Heap::AllocateFixedArray(array_size);
92 CHECK(!obj->IsFailure()); 93 CHECK(!obj->IsFailure());
93 94
94 Handle<FixedArray> array(FixedArray::cast(obj)); 95 Handle<FixedArray> array(FixedArray::cast(obj));
95 96
96 // Array should be in the new space. 97 // Array should be in the new space.
97 CHECK(Heap::InSpace(*array, NEW_SPACE)); 98 CHECK(Heap::InSpace(*array, NEW_SPACE));
98 99
99 // Call the m-c collector, so array becomes an old object. 100 // Call the m-c collector, so array becomes an old object.
(...skipping 11 matching lines...) Expand all
111 // Test the situation that some objects in new space are promoted to 112 // Test the situation that some objects in new space are promoted to
112 // the old space 113 // the old space
113 InitializeVM(); 114 InitializeVM();
114 115
115 v8::HandleScope sc; 116 v8::HandleScope sc;
116 117
117 // Do a mark compact GC to shrink the heap. 118 // Do a mark compact GC to shrink the heap.
118 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); 119 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE));
119 120
120 // Allocate a big Fixed array in the new space. 121 // Allocate a big Fixed array in the new space.
121 int size = (Heap::MaxObjectSizeInPagedSpace() - Array::kHeaderSize) / 122 int size = (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) /
122 kPointerSize; 123 kPointerSize;
123 Object* obj = Heap::AllocateFixedArray(size); 124 Object* obj = Heap::AllocateFixedArray(size);
124 125
125 Handle<FixedArray> array(FixedArray::cast(obj)); 126 Handle<FixedArray> array(FixedArray::cast(obj));
126 127
127 // Array still stays in the new space. 128 // Array still stays in the new space.
128 CHECK(Heap::InSpace(*array, NEW_SPACE)); 129 CHECK(Heap::InSpace(*array, NEW_SPACE));
129 130
130 // Allocate objects in the old space until out of memory. 131 // Allocate objects in the old space until out of memory.
131 FixedArray* host = *array; 132 FixedArray* host = *array;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 307 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
307 GlobalHandles::AddGroup(g1_objects, 2); 308 GlobalHandles::AddGroup(g1_objects, 2);
308 GlobalHandles::AddGroup(g2_objects, 2); 309 GlobalHandles::AddGroup(g2_objects, 2);
309 } 310 }
310 311
311 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); 312 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE));
312 313
313 // All objects should be gone. 5 global handles in total. 314 // All objects should be gone. 5 global handles in total.
314 CHECK_EQ(5, NumberOfWeakCalls); 315 CHECK_EQ(5, NumberOfWeakCalls);
315 } 316 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698