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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 1502093002: Improve ScriptForbiddenScope handling in cross-threaded code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased up past r363426 Created 5 years 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) 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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | third_party/WebKit/Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698