| 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 // 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 TEST(Promotion) { | 73 TEST(Promotion) { |
| 74 // This test requires compaction. If compaction is turned off, we | 74 // This test requires compaction. If compaction is turned off, we |
| 75 // skip the entire test. | 75 // skip the entire test. |
| 76 if (FLAG_never_compact) return; | 76 if (FLAG_never_compact) return; |
| 77 | 77 |
| 78 // Ensure that we get a compacting collection so that objects are promoted | 78 // Ensure that we get a compacting collection so that objects are promoted |
| 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, 4*MB); | 82 Heap::ConfigureHeap(2*256*KB, 8*MB, 8*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 = |
| 90 (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / | 90 (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / |
| 91 (kPointerSize * 4); | 91 (kPointerSize * 4); |
| 92 Object* obj = Heap::AllocateFixedArray(array_size)->ToObjectChecked(); | 92 Object* obj = Heap::AllocateFixedArray(array_size)->ToObjectChecked(); |
| 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 Heap::CollectGarbage(OLD_POINTER_SPACE); | 100 Heap::CollectGarbage(OLD_POINTER_SPACE); |
| 101 | 101 |
| 102 // Array now sits in the old space | 102 // Array now sits in the old space |
| 103 CHECK(Heap::InSpace(*array, OLD_POINTER_SPACE)); | 103 CHECK(Heap::InSpace(*array, OLD_POINTER_SPACE)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 | 106 |
| 107 TEST(NoPromotion) { | 107 TEST(NoPromotion) { |
| 108 Heap::ConfigureHeap(2*256*KB, 4*MB, 4*MB); | 108 Heap::ConfigureHeap(2*256*KB, 8*MB, 8*MB); |
| 109 | 109 |
| 110 // Test the situation that some objects in new space are promoted to | 110 // Test the situation that some objects in new space are promoted to |
| 111 // the old space | 111 // the old space |
| 112 InitializeVM(); | 112 InitializeVM(); |
| 113 | 113 |
| 114 v8::HandleScope sc; | 114 v8::HandleScope sc; |
| 115 | 115 |
| 116 // Do a mark compact GC to shrink the heap. | 116 // Do a mark compact GC to shrink the heap. |
| 117 Heap::CollectGarbage(OLD_POINTER_SPACE); | 117 Heap::CollectGarbage(OLD_POINTER_SPACE); |
| 118 | 118 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 363 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 364 GlobalHandles::AddGroup(g1_objects, 2, NULL); | 364 GlobalHandles::AddGroup(g1_objects, 2, NULL); |
| 365 GlobalHandles::AddGroup(g2_objects, 2, NULL); | 365 GlobalHandles::AddGroup(g2_objects, 2, NULL); |
| 366 } | 366 } |
| 367 | 367 |
| 368 Heap::CollectGarbage(OLD_POINTER_SPACE); | 368 Heap::CollectGarbage(OLD_POINTER_SPACE); |
| 369 | 369 |
| 370 // All objects should be gone. 5 global handles in total. | 370 // All objects should be gone. 5 global handles in total. |
| 371 CHECK_EQ(5, NumberOfWeakCalls); | 371 CHECK_EQ(5, NumberOfWeakCalls); |
| 372 } | 372 } |
| OLD | NEW |