| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 class ParkThreadsScope final { | 61 class ParkThreadsScope final { |
| 62 STACK_ALLOCATED(); | 62 STACK_ALLOCATED(); |
| 63 | 63 |
| 64 public: | 64 public: |
| 65 explicit ParkThreadsScope(ThreadState* state) | 65 explicit ParkThreadsScope(ThreadState* state) |
| 66 : m_state(state), m_shouldResumeThreads(false) {} | 66 : m_state(state), m_shouldResumeThreads(false) {} |
| 67 | 67 |
| 68 bool parkThreads() { | 68 bool parkThreads() { |
| 69 TRACE_EVENT0("blink_gc", "ThreadHeap::ParkThreadsScope"); | 69 TRACE_EVENT0("blink_gc", "ThreadHeap::ParkThreadsScope"); |
| 70 const char* samplingState = TRACE_EVENT_GET_SAMPLING_STATE(); | |
| 71 if (m_state->isMainThread()) | |
| 72 TRACE_EVENT_SET_SAMPLING_STATE("blink_gc", "BlinkGCWaiting"); | |
| 73 | 70 |
| 74 // TODO(haraken): In an unlikely coincidence that two threads decide | 71 // TODO(haraken): In an unlikely coincidence that two threads decide |
| 75 // to collect garbage at the same time, avoid doing two GCs in | 72 // to collect garbage at the same time, avoid doing two GCs in |
| 76 // a row and return false. | 73 // a row and return false. |
| 77 double startTime = WTF::currentTimeMS(); | 74 double startTime = WTF::currentTimeMS(); |
| 78 | 75 |
| 79 m_shouldResumeThreads = m_state->heap().park(); | 76 m_shouldResumeThreads = m_state->heap().park(); |
| 80 | 77 |
| 81 double timeForStoppingThreads = WTF::currentTimeMS() - startTime; | 78 double timeForStoppingThreads = WTF::currentTimeMS() - startTime; |
| 82 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 79 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
| 83 CustomCountHistogram, timeToStopThreadsHistogram, | 80 CustomCountHistogram, timeToStopThreadsHistogram, |
| 84 new CustomCountHistogram("BlinkGC.TimeForStoppingThreads", 1, 1000, | 81 new CustomCountHistogram("BlinkGC.TimeForStoppingThreads", 1, 1000, |
| 85 50)); | 82 50)); |
| 86 timeToStopThreadsHistogram.count(timeForStoppingThreads); | 83 timeToStopThreadsHistogram.count(timeForStoppingThreads); |
| 87 | 84 |
| 88 if (m_state->isMainThread()) | |
| 89 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState); | |
| 90 return m_shouldResumeThreads; | 85 return m_shouldResumeThreads; |
| 91 } | 86 } |
| 92 | 87 |
| 93 ~ParkThreadsScope() { | 88 ~ParkThreadsScope() { |
| 94 // Only cleanup if we parked all threads in which case the GC happened | 89 // Only cleanup if we parked all threads in which case the GC happened |
| 95 // and we need to resume the other threads. | 90 // and we need to resume the other threads. |
| 96 if (m_shouldResumeThreads) | 91 if (m_shouldResumeThreads) |
| 97 m_state->heap().resume(); | 92 m_state->heap().resume(); |
| 98 } | 93 } |
| 99 | 94 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); | 644 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); |
| 650 | 645 |
| 651 m_stats.reset(); | 646 m_stats.reset(); |
| 652 for (ThreadState* state : m_threads) | 647 for (ThreadState* state : m_threads) |
| 653 state->resetHeapCounters(); | 648 state->resetHeapCounters(); |
| 654 } | 649 } |
| 655 | 650 |
| 656 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; | 651 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; |
| 657 | 652 |
| 658 } // namespace blink | 653 } // namespace blink |
| OLD | NEW |