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

Unified Diff: test/cctest/heap/test-mark-compact.cc

Issue 1999753002: [heap] Harden heap-related cctests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix for win Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/heap/test-incremental-marking.cc ('k') | test/cctest/heap/test-spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-mark-compact.cc
diff --git a/test/cctest/heap/test-mark-compact.cc b/test/cctest/heap/test-mark-compact.cc
index 2115f1cd23cf80f696eff3c3d421c426d6bcf927..1e5d30d0e7f56b738d0dd6fc1e87ab41d7c63763 100644
--- a/test/cctest/heap/test-mark-compact.cc
+++ b/test/cctest/heap/test-mark-compact.cc
@@ -43,8 +43,7 @@
#include "src/global-handles.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/heap-tester.h"
-#include "test/cctest/heap/utils-inl.h"
-
+#include "test/cctest/heap/heap-utils.h"
using namespace v8::internal;
using v8::Just;
@@ -76,58 +75,49 @@ TEST(MarkingDeque) {
DeleteArray(mem);
}
-
-HEAP_TEST(Promotion) {
+TEST(Promotion) {
CcTest::InitializeVM();
- Heap* heap = CcTest::heap();
- heap->ConfigureHeap(1, 1, 1, 0);
-
- v8::HandleScope sc(CcTest::isolate());
-
- // Allocate a fixed array in the new space.
- int array_length =
- (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) /
- (4 * kPointerSize);
- Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked();
- Handle<FixedArray> array(FixedArray::cast(obj));
+ Isolate* isolate = CcTest::i_isolate();
+ {
+ v8::HandleScope sc(CcTest::isolate());
+ Heap* heap = isolate->heap();
- // Array should be in the new space.
- CHECK(heap->InSpace(*array, NEW_SPACE));
+ heap::SealCurrentObjects(heap);
- // Call mark compact GC, so array becomes an old object.
- heap->CollectAllGarbage();
- heap->CollectAllGarbage();
+ int array_length =
+ heap::FixedArrayLenFromSize(Page::kMaxRegularHeapObjectSize);
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(array_length);
- // Array now sits in the old space
- CHECK(heap->InSpace(*array, OLD_SPACE));
+ // Array should be in the new space.
+ CHECK(heap->InSpace(*array, NEW_SPACE));
+ heap->CollectAllGarbage();
+ heap->CollectAllGarbage();
+ CHECK(heap->InSpace(*array, OLD_SPACE));
+ }
}
-
HEAP_TEST(NoPromotion) {
CcTest::InitializeVM();
- Heap* heap = CcTest::heap();
- heap->ConfigureHeap(1, 1, 1, 0);
-
- v8::HandleScope sc(CcTest::isolate());
-
- // Allocate a big fixed array in the new space.
- int array_length =
- (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) /
- (2 * kPointerSize);
- Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked();
- Handle<FixedArray> array(FixedArray::cast(obj));
+ Isolate* isolate = CcTest::i_isolate();
+ {
+ v8::HandleScope sc(CcTest::isolate());
+ Heap* heap = isolate->heap();
- // Array should be in the new space.
- CHECK(heap->InSpace(*array, NEW_SPACE));
+ heap::SealCurrentObjects(heap);
- // Simulate a full old space to make promotion fail.
- SimulateFullSpace(heap->old_space());
+ int array_length =
+ heap::FixedArrayLenFromSize(Page::kMaxRegularHeapObjectSize);
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(array_length);
- // Call mark compact GC, and it should pass.
- heap->CollectGarbage(OLD_SPACE);
+ heap->set_force_oom(true);
+ // Array should be in the new space.
+ CHECK(heap->InSpace(*array, NEW_SPACE));
+ heap->CollectAllGarbage();
+ heap->CollectAllGarbage();
+ CHECK(heap->InSpace(*array, NEW_SPACE));
+ }
}
-
HEAP_TEST(MarkCompactCollector) {
FLAG_incremental_marking = false;
FLAG_retain_maps_for_n_gc = 0;
« no previous file with comments | « test/cctest/heap/test-incremental-marking.cc ('k') | test/cctest/heap/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698