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

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

Issue 2913303002: Avoid unsafe heap access from audio thread. (Closed)
Patch Set: Created 3 years, 6 months 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 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 void ThreadState::CollectGarbage(BlinkGC::StackState stack_state, 1433 void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
1434 BlinkGC::GCType gc_type, 1434 BlinkGC::GCType gc_type,
1435 BlinkGC::GCReason reason) { 1435 BlinkGC::GCReason reason) {
1436 // Nested collectGarbage() invocations aren't supported. 1436 // Nested collectGarbage() invocations aren't supported.
1437 CHECK(!IsGCForbidden()); 1437 CHECK(!IsGCForbidden());
1438 CompleteSweep(); 1438 CompleteSweep();
1439 1439
1440 GCForbiddenScope gc_forbidden_scope(this); 1440 GCForbiddenScope gc_forbidden_scope(this);
1441 1441
1442 { 1442 {
1443 // No access to GCing arenas is allowed by other threads while
1444 // a GC runs; grab a lock to indicate that GC is underway. Should
1445 // any other thread need to access object on the heap, it will have
1446 // to be while in a GCLockScope also.
1447 GCLockScope gc_lock(this);
1448
1443 // Access to the CrossThreadPersistentRegion has to be prevented while in 1449 // Access to the CrossThreadPersistentRegion has to be prevented while in
1444 // the marking phase because otherwise other threads may allocate or free 1450 // the marking phase because otherwise other threads may allocate or free
1445 // PersistentNodes and we can't handle that. 1451 // PersistentNodes and we can't handle that.
1446 CrossThreadPersistentRegion::LockScope persistent_lock( 1452 CrossThreadPersistentRegion::LockScope persistent_lock(
1447 ProcessHeap::GetCrossThreadPersistentRegion()); 1453 ProcessHeap::GetCrossThreadPersistentRegion());
1448 { 1454 {
1449 SafePointScope safe_point_scope(stack_state, this); 1455 SafePointScope safe_point_scope(stack_state, this);
1450 1456
1451 std::unique_ptr<Visitor> visitor; 1457 std::unique_ptr<Visitor> visitor;
1452 if (gc_type == BlinkGC::kTakeSnapshot) { 1458 if (gc_type == BlinkGC::kTakeSnapshot) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 CollectGarbage(BlinkGC::kNoHeapPointersOnStack, BlinkGC::kGCWithSweep, 1562 CollectGarbage(BlinkGC::kNoHeapPointersOnStack, BlinkGC::kGCWithSweep,
1557 BlinkGC::kForcedGC); 1563 BlinkGC::kForcedGC);
1558 size_t live_objects = Heap().HeapStats().MarkedObjectSize(); 1564 size_t live_objects = Heap().HeapStats().MarkedObjectSize();
1559 if (live_objects == previous_live_objects) 1565 if (live_objects == previous_live_objects)
1560 break; 1566 break;
1561 previous_live_objects = live_objects; 1567 previous_live_objects = live_objects;
1562 } 1568 }
1563 } 1569 }
1564 1570
1565 } // namespace blink 1571 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698