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

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

Issue 10702059: Merged r11900, r11901, r11904 into 3.10 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.10
Patch Set: Fix presubmit Created 8 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-alloc.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 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "execution.h" 7 #include "execution.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 #include "global-handles.h" 10 #include "global-handles.h"
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 "f(1); f(2); f(3);" 1728 "f(1); f(2); f(3);"
1729 "%OptimizeFunctionOnNextCall(f);" 1729 "%OptimizeFunctionOnNextCall(f);"
1730 "f(4);"); 1730 "f(4);");
1731 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); 1731 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value());
1732 1732
1733 Handle<JSObject> o = 1733 Handle<JSObject> o =
1734 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 1734 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
1735 1735
1736 CHECK(HEAP->InNewSpace(*o)); 1736 CHECK(HEAP->InNewSpace(*o));
1737 } 1737 }
1738
1739
1740 // Implemented in the test-alloc.cc test suite.
1741 void SimulateFullSpace(PagedSpace* space);
1742
1743
1744 TEST(ReleaseOverReservedPages) {
1745 i::FLAG_trace_gc = true;
1746 InitializeVM();
1747 v8::HandleScope scope;
1748 static const int number_of_test_pages = 20;
1749
1750 // Prepare many pages with low live-bytes count.
1751 PagedSpace* old_pointer_space = HEAP->old_pointer_space();
1752 CHECK_EQ(1, old_pointer_space->CountTotalPages());
1753 for (int i = 0; i < number_of_test_pages; i++) {
1754 AlwaysAllocateScope always_allocate;
1755 SimulateFullSpace(old_pointer_space);
1756 FACTORY->NewFixedArray(1, TENURED);
1757 }
1758 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
1759
1760 // Triggering one GC will cause a lot of garbage to be discovered but
1761 // even spread across all allocated pages.
1762 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation");
1763 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
1764
1765 // Triggering subsequent GCs should cause at least half of the pages
1766 // to be released to the OS after at most two cycles.
1767 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1");
1768 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
1769 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2");
1770 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2);
1771
1772 // Triggering a last-resort GC should cause all pages to be released
1773 // to the OS so that other processes can seize the memory.
1774 HEAP->CollectAllAvailableGarbage("triggered really hard");
1775 CHECK_EQ(1, old_pointer_space->CountTotalPages());
1776 }
OLDNEW
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698