| 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 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 | 1446 |
| 1447 Optional<RuntimeCallTimerScope> timer_scope; | 1447 Optional<RuntimeCallTimerScope> timer_scope; |
| 1448 if (v8::Isolate* isolate = GetIsolate()) { | 1448 if (v8::Isolate* isolate = GetIsolate()) { |
| 1449 timer_scope.emplace(RuntimeCallStats::From(isolate), | 1449 timer_scope.emplace(RuntimeCallStats::From(isolate), |
| 1450 RuntimeCallStats::CounterId::kCollectGarbage); | 1450 RuntimeCallStats::CounterId::kCollectGarbage); |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 GCForbiddenScope gc_forbidden_scope(this); | 1453 GCForbiddenScope gc_forbidden_scope(this); |
| 1454 | 1454 |
| 1455 { | 1455 { |
| 1456 // Access to the CrossThreadPersistentRegion has to be prevented while in | 1456 // Access to the CrossThreadPersistentRegion has to be prevented |
| 1457 // the marking phase because otherwise other threads may allocate or free | 1457 // while in the marking phase because otherwise other threads may |
| 1458 // PersistentNodes and we can't handle that. | 1458 // allocate or free PersistentNodes and we can't handle |
| 1459 // that. Grabbing this lock also prevents non-attached threads |
| 1460 // from accessing any GCed heap while a GC runs. |
| 1459 CrossThreadPersistentRegion::LockScope persistent_lock( | 1461 CrossThreadPersistentRegion::LockScope persistent_lock( |
| 1460 ProcessHeap::GetCrossThreadPersistentRegion()); | 1462 ProcessHeap::GetCrossThreadPersistentRegion()); |
| 1461 { | 1463 { |
| 1462 SafePointScope safe_point_scope(stack_state, this); | 1464 SafePointScope safe_point_scope(stack_state, this); |
| 1463 | 1465 |
| 1464 std::unique_ptr<Visitor> visitor; | 1466 std::unique_ptr<Visitor> visitor; |
| 1465 if (gc_type == BlinkGC::kTakeSnapshot) { | 1467 if (gc_type == BlinkGC::kTakeSnapshot) { |
| 1466 visitor = Visitor::Create(this, Visitor::kSnapshotMarking); | 1468 visitor = Visitor::Create(this, Visitor::kSnapshotMarking); |
| 1467 } else { | 1469 } else { |
| 1468 DCHECK(gc_type == BlinkGC::kGCWithSweep || | 1470 DCHECK(gc_type == BlinkGC::kGCWithSweep || |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 CollectGarbage(BlinkGC::kNoHeapPointersOnStack, BlinkGC::kGCWithSweep, | 1571 CollectGarbage(BlinkGC::kNoHeapPointersOnStack, BlinkGC::kGCWithSweep, |
| 1570 BlinkGC::kForcedGC); | 1572 BlinkGC::kForcedGC); |
| 1571 size_t live_objects = Heap().HeapStats().MarkedObjectSize(); | 1573 size_t live_objects = Heap().HeapStats().MarkedObjectSize(); |
| 1572 if (live_objects == previous_live_objects) | 1574 if (live_objects == previous_live_objects) |
| 1573 break; | 1575 break; |
| 1574 previous_live_objects = live_objects; | 1576 previous_live_objects = live_objects; |
| 1575 } | 1577 } |
| 1576 } | 1578 } |
| 1577 | 1579 |
| 1578 } // namespace blink | 1580 } // namespace blink |
| OLD | NEW |