| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // See collectGarbageForTerminatingThread() comment on why a | 389 // See collectGarbageForTerminatingThread() comment on why a |
| 390 // safepoint scope isn't entered for it. | 390 // safepoint scope isn't entered for it. |
| 391 SafePointScope safePointScope(stackState, gcType != BlinkGC::ThreadTerminati
onGC ? state : nullptr); | 391 SafePointScope safePointScope(stackState, gcType != BlinkGC::ThreadTerminati
onGC ? state : nullptr); |
| 392 | 392 |
| 393 // Try to park the other threads. If we're unable to, bail out of the GC. | 393 // Try to park the other threads. If we're unable to, bail out of the GC. |
| 394 if (!gcScope.parkAllThreads(stackState, gcType)) | 394 if (!gcScope.parkAllThreads(stackState, gcType)) |
| 395 return; | 395 return; |
| 396 | 396 |
| 397 // Resume all parked threads upon leaving this scope. | 397 // Resume all parked threads upon leaving this scope. |
| 398 ResumeThreadScope resumeThreads(gcType); | 398 ResumeThreadScope resumeThreads(gcType); |
| 399 | 399 ScriptForbiddenIfMainThreadScope scriptForbidden; |
| 400 if (state->isMainThread()) | |
| 401 ScriptForbiddenScope::enter(); | |
| 402 | 400 |
| 403 TRACE_EVENT2("blink_gc", "Heap::collectGarbage", | 401 TRACE_EVENT2("blink_gc", "Heap::collectGarbage", |
| 404 "lazySweeping", gcType == BlinkGC::GCWithoutSweep, | 402 "lazySweeping", gcType == BlinkGC::GCWithoutSweep, |
| 405 "gcReason", gcReasonString(reason)); | 403 "gcReason", gcReasonString(reason)); |
| 406 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC"); | 404 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC"); |
| 407 double startTime = WTF::currentTimeMS(); | 405 double startTime = WTF::currentTimeMS(); |
| 408 | 406 |
| 409 if (gcType == BlinkGC::TakeSnapshot) | 407 if (gcType == BlinkGC::TakeSnapshot) |
| 410 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC(); | 408 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC(); |
| 411 | 409 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 WTF::Partitions::reportMemoryUsageHistogram(); | 452 WTF::Partitions::reportMemoryUsageHistogram(); |
| 455 | 453 |
| 456 postGC(gcType); | 454 postGC(gcType); |
| 457 | 455 |
| 458 #if ENABLE(ASSERT) | 456 #if ENABLE(ASSERT) |
| 459 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio
n. | 457 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio
n. |
| 460 if (++s_gcGeneration == 0) { | 458 if (++s_gcGeneration == 0) { |
| 461 s_gcGeneration = 1; | 459 s_gcGeneration = 1; |
| 462 } | 460 } |
| 463 #endif | 461 #endif |
| 464 | |
| 465 if (state->isMainThread()) | |
| 466 ScriptForbiddenScope::exit(); | |
| 467 } | 462 } |
| 468 | 463 |
| 469 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 464 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
| 470 { | 465 { |
| 471 { | 466 { |
| 472 // A thread-specific termination GC must not allow other global GCs to g
o | 467 // A thread-specific termination GC must not allow other global GCs to g
o |
| 473 // ahead while it is running, hence the termination GC does not enter a | 468 // ahead while it is running, hence the termination GC does not enter a |
| 474 // safepoint. GCScope will not enter also a safepoint scope for | 469 // safepoint. GCScope will not enter also a safepoint scope for |
| 475 // ThreadTerminationGC. | 470 // ThreadTerminationGC. |
| 476 GCScope gcScope(state, BlinkGC::NoHeapPointersOnStack, BlinkGC::ThreadTe
rminationGC); | 471 GCScope gcScope(state, BlinkGC::NoHeapPointersOnStack, BlinkGC::ThreadTe
rminationGC); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 size_t Heap::s_wrapperCount = 0; | 764 size_t Heap::s_wrapperCount = 0; |
| 770 size_t Heap::s_wrapperCountAtLastGC = 0; | 765 size_t Heap::s_wrapperCountAtLastGC = 0; |
| 771 size_t Heap::s_collectedWrapperCount = 0; | 766 size_t Heap::s_collectedWrapperCount = 0; |
| 772 size_t Heap::s_partitionAllocSizeAtLastGC = 0; | 767 size_t Heap::s_partitionAllocSizeAtLastGC = 0; |
| 773 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 768 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 774 #if ENABLE(ASSERT) | 769 #if ENABLE(ASSERT) |
| 775 uint16_t Heap::s_gcGeneration = 0; | 770 uint16_t Heap::s_gcGeneration = 0; |
| 776 #endif | 771 #endif |
| 777 | 772 |
| 778 } // namespace blink | 773 } // namespace blink |
| OLD | NEW |