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

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

Issue 2913303002: Avoid unsafe heap access from audio thread. (Closed)
Patch Set: bring back comment 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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 1444
1445 Optional<RuntimeCallTimerScope> timer_scope; 1445 Optional<RuntimeCallTimerScope> timer_scope;
1446 if (v8::Isolate* isolate = GetIsolate()) { 1446 if (v8::Isolate* isolate = GetIsolate()) {
1447 timer_scope.emplace(RuntimeCallStats::From(isolate), 1447 timer_scope.emplace(RuntimeCallStats::From(isolate),
1448 RuntimeCallStats::CounterId::kCollectGarbage); 1448 RuntimeCallStats::CounterId::kCollectGarbage);
1449 } 1449 }
1450 1450
1451 GCForbiddenScope gc_forbidden_scope(this); 1451 GCForbiddenScope gc_forbidden_scope(this);
1452 1452
1453 { 1453 {
1454 // No access to GCing arenas is allowed by other threads while
1455 // a GC runs; grab a lock to indicate that GC is underway. Should
1456 // any other thread need to access object on the heap, it will have
1457 // to be while in a GCLockScope also.
1458 GCLockScope gc_lock(this);
1459
1454 // Access to the CrossThreadPersistentRegion has to be prevented while in 1460 // Access to the CrossThreadPersistentRegion has to be prevented while in
1455 // the marking phase because otherwise other threads may allocate or free 1461 // the marking phase because otherwise other threads may allocate or free
1456 // PersistentNodes and we can't handle that. 1462 // PersistentNodes and we can't handle that.
1457 CrossThreadPersistentRegion::LockScope persistent_lock( 1463 CrossThreadPersistentRegion::LockScope persistent_lock(
1458 ProcessHeap::GetCrossThreadPersistentRegion()); 1464 ProcessHeap::GetCrossThreadPersistentRegion());
1459 { 1465 {
1460 SafePointScope safe_point_scope(stack_state, this); 1466 SafePointScope safe_point_scope(stack_state, this);
1461 1467
1462 std::unique_ptr<Visitor> visitor; 1468 std::unique_ptr<Visitor> visitor;
1463 if (gc_type == BlinkGC::kTakeSnapshot) { 1469 if (gc_type == BlinkGC::kTakeSnapshot) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 CollectGarbage(BlinkGC::kNoHeapPointersOnStack, BlinkGC::kGCWithSweep, 1573 CollectGarbage(BlinkGC::kNoHeapPointersOnStack, BlinkGC::kGCWithSweep,
1568 BlinkGC::kForcedGC); 1574 BlinkGC::kForcedGC);
1569 size_t live_objects = Heap().HeapStats().MarkedObjectSize(); 1575 size_t live_objects = Heap().HeapStats().MarkedObjectSize();
1570 if (live_objects == previous_live_objects) 1576 if (live_objects == previous_live_objects)
1571 break; 1577 break;
1572 previous_live_objects = live_objects; 1578 previous_live_objects = live_objects;
1573 } 1579 }
1574 } 1580 }
1575 1581
1576 } // namespace blink 1582 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698