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

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

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