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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp

Issue 1402103004: Oilpan: Factor out GC-related enum definitions to BlinkGC.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // TODO(haraken): It would be nice if the GC callbacks passed the Isolate 424 // TODO(haraken): It would be nice if the GC callbacks passed the Isolate
425 // directly. 425 // directly.
426 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 426 v8::Isolate* isolate = v8::Isolate::GetCurrent();
427 switch (type) { 427 switch (type) {
428 case v8::kGCTypeScavenge: 428 case v8::kGCTypeScavenge:
429 TRACE_EVENT_END1("devtools.timeline,v8", "MinorGC", "usedHeapSizeAfter", usedHeapSize(isolate)); 429 TRACE_EVENT_END1("devtools.timeline,v8", "MinorGC", "usedHeapSizeAfter", usedHeapSize(isolate));
430 if (isMainThread()) { 430 if (isMainThread()) {
431 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState()); 431 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState());
432 } 432 }
433 if (ThreadState::current()) 433 if (ThreadState::current())
434 ThreadState::current()->scheduleV8FollowupGCIfNeeded(ThreadState::V8 MinorGC); 434 ThreadState::current()->scheduleV8FollowupGCIfNeeded(BlinkGC::V8Mino rGC);
435 break; 435 break;
436 case v8::kGCTypeMarkSweepCompact: 436 case v8::kGCTypeMarkSweepCompact:
437 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate)); 437 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate));
438 if (isMainThread()) { 438 if (isMainThread()) {
439 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState()); 439 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState());
440 } 440 }
441 break; 441 break;
442 case v8::kGCTypeIncrementalMarking: 442 case v8::kGCTypeIncrementalMarking:
443 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate)); 443 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate));
444 if (isMainThread()) { 444 if (isMainThread()) {
445 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState()); 445 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState());
446 } 446 }
447 break; 447 break;
448 case v8::kGCTypeProcessWeakCallbacks: 448 case v8::kGCTypeProcessWeakCallbacks:
449 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate)); 449 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate));
450 if (isMainThread()) { 450 if (isMainThread()) {
451 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState()); 451 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isola te)->previousSamplingState());
452 } 452 }
453 if (ThreadState::current()) 453 if (ThreadState::current())
454 ThreadState::current()->scheduleV8FollowupGCIfNeeded(ThreadState::V8 MajorGC); 454 ThreadState::current()->scheduleV8FollowupGCIfNeeded(BlinkGC::V8Majo rGC);
455 break; 455 break;
456 default: 456 default:
457 ASSERT_NOT_REACHED(); 457 ASSERT_NOT_REACHED();
458 } 458 }
459 459
460 if (isMainThread()) 460 if (isMainThread())
461 ScriptForbiddenScope::exit(); 461 ScriptForbiddenScope::exit();
462 462
463 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection 463 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection
464 // when a garbage collection was forced from V8. This is either used 464 // when a garbage collection was forced from V8. This is either used
465 // for tests that force GCs from JavaScript to verify that objects die 465 // for tests that force GCs from JavaScript to verify that objects die
466 // when expected, or when handling memory pressure notifications. 466 // when expected, or when handling memory pressure notifications.
467 if (flags & v8::kGCCallbackFlagForced) { 467 if (flags & v8::kGCCallbackFlagForced) {
468 // This single GC is not enough for two reasons: 468 // This single GC is not enough for two reasons:
469 // (1) The GC is not precise because the GC scans on-stack pointers co nservatively. 469 // (1) The GC is not precise because the GC scans on-stack pointers co nservatively.
470 // (2) One GC is not enough to break a chain of persistent handles. It 's possible that 470 // (2) One GC is not enough to break a chain of persistent handles. It 's possible that
471 // some heap allocated objects own objects that contain persistent handles 471 // some heap allocated objects own objects that contain persistent handles
472 // pointing to other heap allocated objects. To break the chain, w e need multiple GCs. 472 // pointing to other heap allocated objects. To break the chain, w e need multiple GCs.
473 // 473 //
474 // Regarding (1), we force a precise GC at the end of the current event loop. So if you want 474 // Regarding (1), we force a precise GC at the end of the current event loop. So if you want
475 // to collect all garbage, you need to wait until the next event loop. 475 // to collect all garbage, you need to wait until the next event loop.
476 // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because 476 // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because
477 // GCController.collectAll() forces 7 V8's GC. 477 // GCController.collectAll() forces 7 V8's GC.
478 Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::GCWi thSweep, Heap::ForcedGC); 478 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, Heap::ForcedGC);
479 479
480 // Forces a precise GC at the end of the current event loop. 480 // Forces a precise GC at the end of the current event loop.
481 if (ThreadState::current()) 481 if (ThreadState::current())
482 ThreadState::current()->setGCState(ThreadState::FullGCScheduled); 482 ThreadState::current()->setGCState(ThreadState::FullGCScheduled);
483 } 483 }
484 484
485 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 485 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
486 } 486 }
487 487
488 void V8GCController::collectGarbage(v8::Isolate* isolate) 488 void V8GCController::collectGarbage(v8::Isolate* isolate)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 Visitor* m_visitor; 541 Visitor* m_visitor;
542 }; 542 };
543 543
544 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) 544 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor)
545 { 545 {
546 DOMWrapperTracer tracer(visitor); 546 DOMWrapperTracer tracer(visitor);
547 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); 547 v8::V8::VisitHandlesWithClassIds(isolate, &tracer);
548 } 548 }
549 549
550 } // namespace blink 550 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698