| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 RELEASE_ASSERT(threadState()->isSweepingInProgress()); | 291 RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
| 292 | 292 |
| 293 // lazySweepPages() can be called recursively if finalizers invoked in | 293 // lazySweepPages() can be called recursively if finalizers invoked in |
| 294 // page->sweep() allocate memory and the allocation triggers | 294 // page->sweep() allocate memory and the allocation triggers |
| 295 // lazySweepPages(). This check prevents the sweeping from being executed | 295 // lazySweepPages(). This check prevents the sweeping from being executed |
| 296 // recursively. | 296 // recursively. |
| 297 if (threadState()->sweepForbidden()) | 297 if (threadState()->sweepForbidden()) |
| 298 return nullptr; | 298 return nullptr; |
| 299 | 299 |
| 300 TRACE_EVENT0("blink_gc", "BaseHeap::lazySweepPages"); | 300 TRACE_EVENT0("blink_gc", "BaseHeap::lazySweepPages"); |
| 301 ThreadState::SweepForbiddenScope scope(threadState()); | 301 ThreadState::SweepForbiddenScope sweepForbidden(threadState()); |
| 302 ScriptForbiddenIfMainThreadScope scriptForbidden; |
| 303 |
| 302 double startTime = WTF::currentTimeMS(); | 304 double startTime = WTF::currentTimeMS(); |
| 303 | |
| 304 if (threadState()->isMainThread()) | |
| 305 ScriptForbiddenScope::enter(); | |
| 306 | |
| 307 Address result = lazySweepPages(allocationSize, gcInfoIndex); | 305 Address result = lazySweepPages(allocationSize, gcInfoIndex); |
| 308 | |
| 309 if (threadState()->isMainThread()) | |
| 310 ScriptForbiddenScope::exit(); | |
| 311 | |
| 312 threadState()->accumulateSweepingTime(WTF::currentTimeMS() - startTime); | 306 threadState()->accumulateSweepingTime(WTF::currentTimeMS() - startTime); |
| 313 Heap::reportMemoryUsageForTracing(); | 307 Heap::reportMemoryUsageForTracing(); |
| 314 | 308 |
| 315 return result; | 309 return result; |
| 316 } | 310 } |
| 317 | 311 |
| 318 void BaseHeap::sweepUnsweptPage() | 312 void BaseHeap::sweepUnsweptPage() |
| 319 { | 313 { |
| 320 BasePage* page = m_firstUnsweptPage; | 314 BasePage* page = m_firstUnsweptPage; |
| 321 if (page->isEmpty()) { | 315 if (page->isEmpty()) { |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 | 1574 |
| 1581 m_hasEntries = true; | 1575 m_hasEntries = true; |
| 1582 size_t index = hash(address); | 1576 size_t index = hash(address); |
| 1583 ASSERT(!(index & 1)); | 1577 ASSERT(!(index & 1)); |
| 1584 Address cachePage = roundToBlinkPageStart(address); | 1578 Address cachePage = roundToBlinkPageStart(address); |
| 1585 m_entries[index + 1] = m_entries[index]; | 1579 m_entries[index + 1] = m_entries[index]; |
| 1586 m_entries[index] = cachePage; | 1580 m_entries[index] = cachePage; |
| 1587 } | 1581 } |
| 1588 | 1582 |
| 1589 } // namespace blink | 1583 } // namespace blink |
| OLD | NEW |