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 657583004: Start with a maximally large new space reservation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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-constantpool.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 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 "function mkbar () { return new (new Function(\"\")) (); }" 1985 "function mkbar () { return new (new Function(\"\")) (); }"
1986 "function f (x) { return (x instanceof foo); }" 1986 "function f (x) { return (x instanceof foo); }"
1987 "function g () { f(mkbar()); }" 1987 "function g () { f(mkbar()); }"
1988 "f(new foo()); f(new foo());" 1988 "f(new foo()); f(new foo());"
1989 "%OptimizeFunctionOnNextCall(f);" 1989 "%OptimizeFunctionOnNextCall(f);"
1990 "f(new foo()); g();"); 1990 "f(new foo()); g();");
1991 } 1991 }
1992 1992
1993 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 1993 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
1994 marking->Abort(); 1994 marking->Abort();
1995 CcTest::heap()->mark_compact_collector()->ClearMarkbits();
1995 marking->Start(); 1996 marking->Start();
1996 1997
1997 Handle<JSFunction> f = 1998 Handle<JSFunction> f =
1998 v8::Utils::OpenHandle( 1999 v8::Utils::OpenHandle(
1999 *v8::Handle<v8::Function>::Cast( 2000 *v8::Handle<v8::Function>::Cast(
2000 CcTest::global()->Get(v8_str("f")))); 2001 CcTest::global()->Get(v8_str("f"))));
2001 2002
2002 CHECK(f->IsOptimized()); 2003 CHECK(f->IsOptimized());
2003 2004
2004 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && 2005 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) &&
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 "f();"); 2108 "f();");
2108 } 2109 }
2109 Handle<JSFunction> f = 2110 Handle<JSFunction> f =
2110 v8::Utils::OpenHandle( 2111 v8::Utils::OpenHandle(
2111 *v8::Handle<v8::Function>::Cast( 2112 *v8::Handle<v8::Function>::Cast(
2112 CcTest::global()->Get(v8_str("f")))); 2113 CcTest::global()->Get(v8_str("f"))));
2113 CHECK(f->IsOptimized()); 2114 CHECK(f->IsOptimized());
2114 2115
2115 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2116 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2116 marking->Abort(); 2117 marking->Abort();
2118 CcTest::heap()->mark_compact_collector()->ClearMarkbits();
2117 marking->Start(); 2119 marking->Start();
2118 2120
2119 // The following two calls will increment CcTest::heap()->global_ic_age(). 2121 // The following two calls will increment CcTest::heap()->global_ic_age().
2120 const int kLongIdlePauseInMs = 1000; 2122 const int kLongIdlePauseInMs = 1000;
2121 CcTest::isolate()->ContextDisposedNotification(); 2123 CcTest::isolate()->ContextDisposedNotification();
2122 CcTest::isolate()->IdleNotification(kLongIdlePauseInMs); 2124 CcTest::isolate()->IdleNotification(kLongIdlePauseInMs);
2123 2125
2124 while (!marking->IsStopped() && !marking->IsComplete()) { 2126 while (!marking->IsStopped() && !marking->IsComplete()) {
2125 marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 2127 marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
2126 } 2128 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 "%OptimizeFunctionOnNextCall(f);" 2165 "%OptimizeFunctionOnNextCall(f);"
2164 "f();"); 2166 "f();");
2165 } 2167 }
2166 Handle<JSFunction> f = 2168 Handle<JSFunction> f =
2167 v8::Utils::OpenHandle( 2169 v8::Utils::OpenHandle(
2168 *v8::Handle<v8::Function>::Cast( 2170 *v8::Handle<v8::Function>::Cast(
2169 CcTest::global()->Get(v8_str("f")))); 2171 CcTest::global()->Get(v8_str("f"))));
2170 CHECK(f->IsOptimized()); 2172 CHECK(f->IsOptimized());
2171 2173
2172 CcTest::heap()->incremental_marking()->Abort(); 2174 CcTest::heap()->incremental_marking()->Abort();
2175 CcTest::heap()->mark_compact_collector()->ClearMarkbits();
2173 2176
2174 // The following two calls will increment CcTest::heap()->global_ic_age(). 2177 // The following two calls will increment CcTest::heap()->global_ic_age().
2175 // Since incremental marking is off, IdleNotification will do full GC. 2178 // Since incremental marking is off, IdleNotification will do full GC.
2176 const int kLongIdlePauseInMs = 1000; 2179 const int kLongIdlePauseInMs = 1000;
2177 CcTest::isolate()->ContextDisposedNotification(); 2180 CcTest::isolate()->ContextDisposedNotification();
2178 CcTest::isolate()->IdleNotification(kLongIdlePauseInMs); 2181 CcTest::isolate()->IdleNotification(kLongIdlePauseInMs);
2179 2182
2180 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2183 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2181 CHECK_EQ(0, f->shared()->opt_count()); 2184 CHECK_EQ(0, f->shared()->opt_count());
2182 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2185 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2183 } 2186 }
2184 2187
2185 2188
2186 TEST(IdleNotificationFinishMarking) { 2189 TEST(IdleNotificationFinishMarking) {
2187 i::FLAG_allow_natives_syntax = true; 2190 i::FLAG_allow_natives_syntax = true;
2188 CcTest::InitializeVM(); 2191 CcTest::InitializeVM();
2189 SimulateFullSpace(CcTest::heap()->old_pointer_space()); 2192 SimulateFullSpace(CcTest::heap()->old_pointer_space());
2190 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2193 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2191 marking->Abort(); 2194 marking->Abort();
2195 CcTest::heap()->mark_compact_collector()->ClearMarkbits();
2192 marking->Start(); 2196 marking->Start();
2193 2197
2194 CHECK_EQ(CcTest::heap()->gc_count(), 0); 2198 CHECK_EQ(CcTest::heap()->gc_count(), 0);
2195 2199
2196 // TODO(hpayer): We cannot write proper unit test right now for heap. 2200 // TODO(hpayer): We cannot write proper unit test right now for heap.
2197 // The ideal test would call kMaxIdleMarkingDelayCounter to test the 2201 // The ideal test would call kMaxIdleMarkingDelayCounter to test the
2198 // marking delay counter. 2202 // marking delay counter.
2199 2203
2200 // Perform a huge incremental marking step but don't complete marking. 2204 // Perform a huge incremental marking step but don't complete marking.
2201 intptr_t bytes_processed = 0; 2205 intptr_t bytes_processed = 0;
(...skipping 25 matching lines...) Expand all
2227 2231
2228 // Test that HAllocateObject will always return an object in new-space. 2232 // Test that HAllocateObject will always return an object in new-space.
2229 TEST(OptimizedAllocationAlwaysInNewSpace) { 2233 TEST(OptimizedAllocationAlwaysInNewSpace) {
2230 i::FLAG_allow_natives_syntax = true; 2234 i::FLAG_allow_natives_syntax = true;
2231 CcTest::InitializeVM(); 2235 CcTest::InitializeVM();
2232 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2236 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2233 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2237 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2234 v8::HandleScope scope(CcTest::isolate()); 2238 v8::HandleScope scope(CcTest::isolate());
2235 2239
2236 SimulateFullSpace(CcTest::heap()->new_space()); 2240 SimulateFullSpace(CcTest::heap()->new_space());
2237 AlwaysAllocateScope always_allocate(CcTest::i_isolate());
2238 v8::Local<v8::Value> res = CompileRun( 2241 v8::Local<v8::Value> res = CompileRun(
2239 "function c(x) {" 2242 "function c(x) {"
2240 " this.x = x;" 2243 " this.x = x;"
2241 " for (var i = 0; i < 32; i++) {" 2244 " for (var i = 0; i < 32; i++) {"
2242 " this['x' + i] = x;" 2245 " this['x' + i] = x;"
2243 " }" 2246 " }"
2244 "}" 2247 "}"
2245 "function f(x) { return new c(x); };" 2248 "function f(x) { return new c(x); };"
2246 "f(1); f(2); f(3);" 2249 "f(1); f(2); f(3);"
2247 "%OptimizeFunctionOnNextCall(f);" 2250 "%OptimizeFunctionOnNextCall(f);"
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 // Ensure that the object allocated where we need it. 4597 // Ensure that the object allocated where we need it.
4595 Page* page = Page::FromAddress(o->address()); 4598 Page* page = Page::FromAddress(o->address());
4596 CHECK_EQ(desired_offset, page->Offset(o->address())); 4599 CHECK_EQ(desired_offset, page->Offset(o->address()));
4597 4600
4598 // Now we have an object right at the end of the page. 4601 // Now we have an object right at the end of the page.
4599 4602
4600 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes() 4603 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes()
4601 // that would cause crash. 4604 // that would cause crash.
4602 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 4605 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
4603 marking->Abort(); 4606 marking->Abort();
4607 CcTest::heap()->mark_compact_collector()->ClearMarkbits();
4604 marking->Start(); 4608 marking->Start();
4605 CHECK(marking->IsMarking()); 4609 CHECK(marking->IsMarking());
4606 4610
4607 // Now everything is set up for crashing in JSObject::MigrateFastToFast() 4611 // Now everything is set up for crashing in JSObject::MigrateFastToFast()
4608 // when it calls heap->AdjustLiveBytes(...). 4612 // when it calls heap->AdjustLiveBytes(...).
4609 JSObject::MigrateToMap(o, map2); 4613 JSObject::MigrateToMap(o, map2);
4610 } 4614 }
4611 4615
4612 4616
4613 #ifdef DEBUG 4617 #ifdef DEBUG
4614 TEST(PathTracer) { 4618 TEST(PathTracer) {
4615 CcTest::InitializeVM(); 4619 CcTest::InitializeVM();
4616 v8::HandleScope scope(CcTest::isolate()); 4620 v8::HandleScope scope(CcTest::isolate());
4617 4621
4618 v8::Local<v8::Value> result = CompileRun("'abc'"); 4622 v8::Local<v8::Value> result = CompileRun("'abc'");
4619 Handle<Object> o = v8::Utils::OpenHandle(*result); 4623 Handle<Object> o = v8::Utils::OpenHandle(*result);
4620 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4624 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4621 } 4625 }
4622 #endif // DEBUG 4626 #endif // DEBUG
OLDNEW
« no previous file with comments | « test/cctest/test-constantpool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698