| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 void gcPrologueForMajorGC(v8::Isolate* isolate, bool constructRetainedObjectInfo
s) | 256 void gcPrologueForMajorGC(v8::Isolate* isolate, bool constructRetainedObjectInfo
s) |
| 257 { | 257 { |
| 258 // TODO(hlopko): Collect retained object infos for heap profiler | 258 // TODO(hlopko): Collect retained object infos for heap profiler |
| 259 if (!RuntimeEnabledFeatures::traceWrappablesEnabled()) { | 259 if (!RuntimeEnabledFeatures::traceWrappablesEnabled()) { |
| 260 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); | 260 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace | 264 } // namespace |
| 265 | 265 |
| 266 double s_time = 0; |
| 267 |
| 266 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) | 268 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) |
| 267 { | 269 { |
| 268 if (isMainThread()) | 270 if (isMainThread()) |
| 269 ScriptForbiddenScope::enter(); | 271 ScriptForbiddenScope::enter(); |
| 270 | 272 |
| 271 // Attribute garbage collection to the all frames instead of a specific | 273 // Attribute garbage collection to the all frames instead of a specific |
| 272 // frame. | 274 // frame. |
| 273 if (BlameContext* blameContext = Platform::current()->topLevelBlameContext()
) | 275 if (BlameContext* blameContext = Platform::current()->topLevelBlameContext()
) |
| 274 blameContext->Enter(); | 276 blameContext->Enter(); |
| 275 | 277 |
| 276 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means | 278 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means |
| 277 // that it's unsafe to run Oilpan's GC in the GC callback because it may | 279 // that it's unsafe to run Oilpan's GC in the GC callback because it may |
| 278 // run finalizers that call into V8. To avoid the risk, we should post | 280 // run finalizers that call into V8. To avoid the risk, we should post |
| 279 // a task to schedule the Oilpan's GC. | 281 // a task to schedule the Oilpan's GC. |
| 280 // (In practice, there is no finalizer that calls into V8 and thus is safe.) | 282 // (In practice, there is no finalizer that calls into V8 and thus is safe.) |
| 281 | 283 |
| 284 s_time = WTF::currentTimeMS(); |
| 285 |
| 282 v8::HandleScope scope(isolate); | 286 v8::HandleScope scope(isolate); |
| 283 switch (type) { | 287 switch (type) { |
| 284 case v8::kGCTypeScavenge: | 288 case v8::kGCTypeScavenge: |
| 285 if (ThreadState::current()) | 289 if (ThreadState::current()) |
| 286 ThreadState::current()->willStartV8GC(BlinkGC::V8MinorGC); | 290 ThreadState::current()->willStartV8GC(BlinkGC::V8MinorGC); |
| 287 | 291 |
| 288 TRACE_EVENT_BEGIN1("devtools.timeline,v8", "MinorGC", "usedHeapSizeBefor
e", usedHeapSize(isolate)); | 292 TRACE_EVENT_BEGIN1("devtools.timeline,v8", "MinorGC", "usedHeapSizeBefor
e", usedHeapSize(isolate)); |
| 289 visitWeakHandlesForMinorGC(isolate); | 293 visitWeakHandlesForMinorGC(isolate); |
| 290 break; | 294 break; |
| 291 case v8::kGCTypeMarkSweepCompact: | 295 case v8::kGCTypeMarkSweepCompact: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 318 size_t count = isolate->NumberOfPhantomHandleResetsSinceLastCall(); | 322 size_t count = isolate->NumberOfPhantomHandleResetsSinceLastCall(); |
| 319 heapStats.decreaseWrapperCount(count); | 323 heapStats.decreaseWrapperCount(count); |
| 320 heapStats.increaseCollectedWrapperCount(count); | 324 heapStats.increaseCollectedWrapperCount(count); |
| 321 } | 325 } |
| 322 | 326 |
| 323 } // namespace | 327 } // namespace |
| 324 | 328 |
| 325 void V8GCController::gcEpilogue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) | 329 void V8GCController::gcEpilogue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) |
| 326 { | 330 { |
| 327 UpdateCollectedPhantomHandles(isolate); | 331 UpdateCollectedPhantomHandles(isolate); |
| 332 |
| 333 if (flags & v8::kGCCallbackFlagForced) { |
| 334 fprintf(stderr, "forced "); |
| 335 } |
| 336 switch (type) { |
| 337 case v8::kGCTypeScavenge: |
| 338 fprintf(stderr, "minor "); |
| 339 break; |
| 340 case v8::kGCTypeMarkSweepCompact: |
| 341 fprintf(stderr, "major "); |
| 342 break; |
| 343 case v8::kGCTypeIncrementalMarking: |
| 344 fprintf(stderr, "incremental "); |
| 345 break; |
| 346 case v8::kGCTypeProcessWeakCallbacks: |
| 347 fprintf(stderr, "weak-callback "); |
| 348 break; |
| 349 default: |
| 350 ASSERT_NOT_REACHED(); |
| 351 } |
| 352 fprintf(stderr, "V8 GC: %.2lf ms\n", WTF::currentTimeMS() - s_time); |
| 353 |
| 328 switch (type) { | 354 switch (type) { |
| 329 case v8::kGCTypeScavenge: | 355 case v8::kGCTypeScavenge: |
| 330 TRACE_EVENT_END1("devtools.timeline,v8", "MinorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); | 356 TRACE_EVENT_END1("devtools.timeline,v8", "MinorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); |
| 331 // TODO(haraken): Remove this. See the comment in gcPrologue. | 357 // TODO(haraken): Remove this. See the comment in gcPrologue. |
| 332 if (ThreadState::current()) | 358 if (ThreadState::current()) |
| 333 ThreadState::current()->scheduleV8FollowupGCIfNeeded(BlinkGC::V8Mino
rGC); | 359 ThreadState::current()->scheduleV8FollowupGCIfNeeded(BlinkGC::V8Mino
rGC); |
| 334 break; | 360 break; |
| 335 case v8::kGCTypeMarkSweepCompact: | 361 case v8::kGCTypeMarkSweepCompact: |
| 336 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); | 362 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); |
| 337 if (ThreadState::current()) | 363 if (ThreadState::current()) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); | 517 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); |
| 492 double startTime = WTF::currentTimeMS(); | 518 double startTime = WTF::currentTimeMS(); |
| 493 v8::HandleScope scope(isolate); | 519 v8::HandleScope scope(isolate); |
| 494 PendingActivityVisitor visitor(isolate, executionContext); | 520 PendingActivityVisitor visitor(isolate, executionContext); |
| 495 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 521 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
| 496 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); | 522 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); |
| 497 return visitor.pendingActivityFound(); | 523 return visitor.pendingActivityFound(); |
| 498 } | 524 } |
| 499 | 525 |
| 500 } // namespace blink | 526 } // namespace blink |
| OLD | NEW |