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

Side by Side Diff: test/cctest/test-heap.cc

Issue 396443004: Remove sequential sweeping mode and perform lazy sweeping when no sweeper threads are active. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « src/spaces.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 26 matching lines...) Expand all
37 #include "src/macro-assembler.h" 37 #include "src/macro-assembler.h"
38 #include "src/stub-cache.h" 38 #include "src/stub-cache.h"
39 #include "test/cctest/cctest.h" 39 #include "test/cctest/cctest.h"
40 40
41 using namespace v8::internal; 41 using namespace v8::internal;
42 42
43 // Go through all incremental marking steps in one swoop. 43 // Go through all incremental marking steps in one swoop.
44 static void SimulateIncrementalMarking() { 44 static void SimulateIncrementalMarking() {
45 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); 45 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
46 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 46 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
47 if (collector->IsConcurrentSweepingInProgress()) { 47 if (collector->sweeping_in_progress()) {
48 collector->WaitUntilSweepingCompleted(); 48 collector->EnsureSweepingCompleted();
49 } 49 }
50 CHECK(marking->IsMarking() || marking->IsStopped()); 50 CHECK(marking->IsMarking() || marking->IsStopped());
51 if (marking->IsStopped()) { 51 if (marking->IsStopped()) {
52 marking->Start(); 52 marking->Start();
53 } 53 }
54 CHECK(marking->IsMarking()); 54 CHECK(marking->IsMarking());
55 while (!marking->IsComplete()) { 55 while (!marking->IsComplete()) {
56 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 56 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
57 } 57 }
58 CHECK(marking->IsComplete()); 58 CHECK(marking->IsComplete());
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 v8::V8::Initialize(); 1584 v8::V8::Initialize();
1585 1585
1586 // Get initial heap size after several full GCs, which will stabilize 1586 // Get initial heap size after several full GCs, which will stabilize
1587 // the heap size and return with sweeping finished completely. 1587 // the heap size and return with sweeping finished completely.
1588 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1588 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1589 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1589 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1590 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1590 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1591 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1591 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1592 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1592 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1593 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); 1593 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
1594 if (collector->IsConcurrentSweepingInProgress()) { 1594 if (collector->sweeping_in_progress()) {
1595 collector->WaitUntilSweepingCompleted(); 1595 collector->EnsureSweepingCompleted();
1596 } 1596 }
1597 int initial_size = static_cast<int>(CcTest::heap()->SizeOfObjects()); 1597 int initial_size = static_cast<int>(CcTest::heap()->SizeOfObjects());
1598 1598
1599 { 1599 {
1600 // Allocate objects on several different old-space pages so that 1600 // Allocate objects on several different old-space pages so that
1601 // concurrent sweeper threads will be busy sweeping the old space on 1601 // concurrent sweeper threads will be busy sweeping the old space on
1602 // subsequent GC runs. 1602 // subsequent GC runs.
1603 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); 1603 AlwaysAllocateScope always_allocate(CcTest::i_isolate());
1604 int filler_size = static_cast<int>(FixedArray::SizeFor(8192)); 1604 int filler_size = static_cast<int>(FixedArray::SizeFor(8192));
1605 for (int i = 1; i <= 100; i++) { 1605 for (int i = 1; i <= 100; i++) {
1606 CcTest::test_heap()->AllocateFixedArray(8192, TENURED).ToObjectChecked(); 1606 CcTest::test_heap()->AllocateFixedArray(8192, TENURED).ToObjectChecked();
1607 CHECK_EQ(initial_size + i * filler_size, 1607 CHECK_EQ(initial_size + i * filler_size,
1608 static_cast<int>(CcTest::heap()->SizeOfObjects())); 1608 static_cast<int>(CcTest::heap()->SizeOfObjects()));
1609 } 1609 }
1610 } 1610 }
1611 1611
1612 // The heap size should go back to initial size after a full GC, even 1612 // The heap size should go back to initial size after a full GC, even
1613 // though sweeping didn't finish yet. 1613 // though sweeping didn't finish yet.
1614 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1614 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1615 1615
1616 // Normally sweeping would not be complete here, but no guarantees. 1616 // Normally sweeping would not be complete here, but no guarantees.
1617 1617
1618 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); 1618 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects()));
1619 1619
1620 // Waiting for sweeper threads should not change heap size. 1620 // Waiting for sweeper threads should not change heap size.
1621 if (collector->IsConcurrentSweepingInProgress()) { 1621 if (collector->sweeping_in_progress()) {
1622 collector->WaitUntilSweepingCompleted(); 1622 collector->EnsureSweepingCompleted();
1623 } 1623 }
1624 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); 1624 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects()));
1625 } 1625 }
1626 1626
1627 1627
1628 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { 1628 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
1629 CcTest::InitializeVM(); 1629 CcTest::InitializeVM();
1630 HeapIterator iterator(CcTest::heap()); 1630 HeapIterator iterator(CcTest::heap());
1631 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); 1631 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects();
1632 intptr_t size_of_objects_2 = 0; 1632 intptr_t size_of_objects_2 = 0;
(...skipping 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after
4404 #ifdef DEBUG 4404 #ifdef DEBUG
4405 TEST(PathTracer) { 4405 TEST(PathTracer) {
4406 CcTest::InitializeVM(); 4406 CcTest::InitializeVM();
4407 v8::HandleScope scope(CcTest::isolate()); 4407 v8::HandleScope scope(CcTest::isolate());
4408 4408
4409 v8::Local<v8::Value> result = CompileRun("'abc'"); 4409 v8::Local<v8::Value> result = CompileRun("'abc'");
4410 Handle<Object> o = v8::Utils::OpenHandle(*result); 4410 Handle<Object> o = v8::Utils::OpenHandle(*result);
4411 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4411 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4412 } 4412 }
4413 #endif // DEBUG 4413 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698