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

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

Issue 10629004: Adapt fragmentation heuristics for over reserved pages. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Erik Corry. Created 8 years, 6 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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 1892
1893 Handle<JSObject> root = 1893 Handle<JSObject> root =
1894 v8::Utils::OpenHandle( 1894 v8::Utils::OpenHandle(
1895 *v8::Handle<v8::Object>::Cast( 1895 *v8::Handle<v8::Object>::Cast(
1896 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 1896 v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
1897 1897
1898 // The root object should be in a sane state. 1898 // The root object should be in a sane state.
1899 CHECK(root->IsJSObject()); 1899 CHECK(root->IsJSObject());
1900 CHECK(root->map()->IsMap()); 1900 CHECK(root->map()->IsMap());
1901 } 1901 }
1902
1903
1904 // Implemented in the test-alloc.cc test suite.
1905 void SimulateFullSpace(PagedSpace* space);
1906
1907
1908 TEST(ReleaseOverReservedPages) {
1909 i::FLAG_trace_gc = true;
1910 InitializeVM();
1911 v8::HandleScope scope;
1912 static const int number_of_test_pages = 20;
1913
1914 // Prepare many pages with low live-bytes count.
1915 PagedSpace* old_pointer_space = HEAP->old_pointer_space();
1916 CHECK_EQ(1, old_pointer_space->CountTotalPages());
1917 for (int i = 0; i < number_of_test_pages; i++) {
1918 AlwaysAllocateScope always_allocate;
1919 SimulateFullSpace(old_pointer_space);
1920 FACTORY->NewFixedArray(1, TENURED);
1921 }
1922 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
1923
1924 // Triggering one GC will cause a lot of garbage to be discovered but
1925 // even spread across all allocated pages.
1926 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation");
1927 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
1928
1929 // Triggering subsequent GCs should cause at least half of the pages
1930 // to be released to the OS after at most two cycles.
1931 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1");
1932 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
1933 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2");
1934 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2);
1935
1936 // Triggering a last-resort GC should cause all pages to be released
1937 // to the OS so that other processes can seize the memory.
1938 HEAP->CollectAllAvailableGarbage("triggered really hard");
1939 CHECK_EQ(1, old_pointer_space->CountTotalPages());
1940 }
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