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

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

Issue 1105293004: Add mode to reduce memory usage in idle notification. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 5 years, 7 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
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 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 } 2234 }
2235 Handle<JSFunction> f = 2235 Handle<JSFunction> f =
2236 v8::Utils::OpenHandle( 2236 v8::Utils::OpenHandle(
2237 *v8::Handle<v8::Function>::Cast( 2237 *v8::Handle<v8::Function>::Cast(
2238 CcTest::global()->Get(v8_str("f")))); 2238 CcTest::global()->Get(v8_str("f"))));
2239 CHECK(f->IsOptimized()); 2239 CHECK(f->IsOptimized());
2240 2240
2241 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2241 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2242 marking->Abort(); 2242 marking->Abort();
2243 marking->Start(); 2243 marking->Start();
2244 2244 // The following calls will increment CcTest::heap()->global_ic_age().
2245 // The following two calls will increment CcTest::heap()->global_ic_age().
2246 const double kLongIdlePauseInSeconds = 1.0;
2247 CcTest::isolate()->ContextDisposedNotification(); 2245 CcTest::isolate()->ContextDisposedNotification();
2248 CcTest::isolate()->IdleNotificationDeadline( 2246 SimulateIncrementalMarking(CcTest::heap());
2249 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() / 2247 CcTest::heap()->CollectAllGarbage();
2250 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
2251 kLongIdlePauseInSeconds);
2252
2253 while (!marking->IsStopped() && !marking->IsComplete()) {
2254 marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
2255 }
2256 if (!marking->IsStopped() || marking->should_hurry()) {
2257 // We don't normally finish a GC via Step(), we normally finish by
2258 // setting the stack guard and then do the final steps in the stack
2259 // guard interrupt. But here we didn't ask for that, and there is no
2260 // JS code running to trigger the interrupt, so we explicitly finalize
2261 // here.
2262 CcTest::heap()->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask,
2263 "Test finalizing incremental mark-sweep");
2264 }
2265
2266 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2248 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2267 CHECK_EQ(0, f->shared()->opt_count()); 2249 CHECK_EQ(0, f->shared()->opt_count());
2268 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2250 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2269 } 2251 }
2270 2252
2271 2253
2272 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { 2254 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
2273 i::FLAG_stress_compaction = false; 2255 i::FLAG_stress_compaction = false;
2274 i::FLAG_allow_natives_syntax = true; 2256 i::FLAG_allow_natives_syntax = true;
2275 #ifdef VERIFY_HEAP 2257 #ifdef VERIFY_HEAP
(...skipping 18 matching lines...) Expand all
2294 } 2276 }
2295 Handle<JSFunction> f = 2277 Handle<JSFunction> f =
2296 v8::Utils::OpenHandle( 2278 v8::Utils::OpenHandle(
2297 *v8::Handle<v8::Function>::Cast( 2279 *v8::Handle<v8::Function>::Cast(
2298 CcTest::global()->Get(v8_str("f")))); 2280 CcTest::global()->Get(v8_str("f"))));
2299 CHECK(f->IsOptimized()); 2281 CHECK(f->IsOptimized());
2300 2282
2301 CcTest::heap()->incremental_marking()->Abort(); 2283 CcTest::heap()->incremental_marking()->Abort();
2302 2284
2303 // The following two calls will increment CcTest::heap()->global_ic_age(). 2285 // The following two calls will increment CcTest::heap()->global_ic_age().
2304 // Since incremental marking is off, IdleNotification will do full GC.
2305 const double kLongIdlePauseInSeconds = 1.0;
2306 CcTest::isolate()->ContextDisposedNotification(); 2286 CcTest::isolate()->ContextDisposedNotification();
2307 CcTest::isolate()->IdleNotificationDeadline( 2287 CcTest::heap()->CollectAllGarbage();
2308 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
2309 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
2310 kLongIdlePauseInSeconds);
2311 2288
2312 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2289 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2313 CHECK_EQ(0, f->shared()->opt_count()); 2290 CHECK_EQ(0, f->shared()->opt_count());
2314 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2291 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2315 } 2292 }
2316 2293
2317 2294
2318 TEST(IdleNotificationFinishMarking) { 2295 TEST(IdleNotificationFinishMarking) {
2319 i::FLAG_allow_natives_syntax = true; 2296 i::FLAG_allow_natives_syntax = true;
2320 CcTest::InitializeVM(); 2297 CcTest::InitializeVM();
(...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after
5405 CHECK(pos->IsSmi()); 5382 CHECK(pos->IsSmi());
5406 5383
5407 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); 5384 Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace);
5408 int array_length = Smi::cast(stack_trace_array->length())->value(); 5385 int array_length = Smi::cast(stack_trace_array->length())->value();
5409 for (int i = 0; i < array_length; i++) { 5386 for (int i = 0; i < array_length; i++) {
5410 Handle<Object> element = 5387 Handle<Object> element =
5411 Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); 5388 Object::GetElement(isolate, stack_trace, i).ToHandleChecked();
5412 CHECK(!element->IsCode()); 5389 CHECK(!element->IsCode());
5413 } 5390 }
5414 } 5391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698