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

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

Issue 1411603007: [Oilpan] Add use-after-free detector in Member<> Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // makeConsistentForMutator() drops marks from marked objects and rebuild 286 // makeConsistentForMutator() drops marks from marked objects and rebuild
287 // free lists. This is called after taking a snapshot and before resuming 287 // free lists. This is called after taking a snapshot and before resuming
288 // the executions of mutators. 288 // the executions of mutators.
289 void makeConsistentForMutator(); 289 void makeConsistentForMutator();
290 290
291 // Support for disallowing allocation. Mainly used for sanity 291 // Support for disallowing allocation. Mainly used for sanity
292 // checks asserts. 292 // checks asserts.
293 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio nCount; } 293 bool isAllocationAllowed() const { return !isAtSafePoint() && !m_noAllocatio nCount; }
294 void enterNoAllocationScope() { m_noAllocationCount++; } 294 void enterNoAllocationScope() { m_noAllocationCount++; }
295 void leaveNoAllocationScope() { m_noAllocationCount--; } 295 void leaveNoAllocationScope() { m_noAllocationCount--; }
296 bool isGCForbidden() const { return m_gcForbiddenCount; } 296
297 // By entering a gc-forbidden scope, conservative GCs will not
298 // be allowed while handling an out-of-line allocation request.
299 // Intended used when constructing subclasses of GC mixins, where
300 // the object being constructed cannot be safely traced & marked
301 // fully should a GC be allowed while its subclasses are being
302 // constructed.
303 bool isGCForbidden() const { return m_gcForbiddenCount || isConstructingGCMi xin(); }
297 void enterGCForbiddenScope() { m_gcForbiddenCount++; } 304 void enterGCForbiddenScope() { m_gcForbiddenCount++; }
298 void leaveGCForbiddenScope() 305 void leaveGCForbiddenScope()
299 { 306 {
300 ASSERT(m_gcForbiddenCount > 0); 307 ASSERT(m_gcForbiddenCount > 0);
301 m_gcForbiddenCount--; 308 m_gcForbiddenCount--;
302 } 309 }
303 bool sweepForbidden() const { return m_sweepForbidden; } 310 bool sweepForbidden() const { return m_sweepForbidden; }
304 311
312 bool isConstructingGCMixin() const { return m_gcMixinMarker; }
313 void startConstructingGCMixin(GarbageCollectedMixinConstructorMarker* gcMixi nMarker)
314 {
315 ASSERT(checkThread());
316 if (!m_gcMixinMarker) {
317 m_gcMixinMarker = gcMixinMarker;
318 }
319 }
320 void finishConstructingGCMixin(GarbageCollectedMixinConstructorMarker* gcMix inMarker)
321 {
322 ASSERT(checkThread());
323 if (m_gcMixinMarker == gcMixinMarker) {
324 m_gcMixinMarker = nullptr;
325 }
326 }
327
305 void flushHeapDoesNotContainCacheIfNeeded(); 328 void flushHeapDoesNotContainCacheIfNeeded();
306 329
307 // Safepoint related functionality. 330 // Safepoint related functionality.
308 // 331 //
309 // When a thread attempts to perform GC it needs to stop all other threads 332 // When a thread attempts to perform GC it needs to stop all other threads
310 // that use the heap or at least guarantee that they will not touch any 333 // that use the heap or at least guarantee that they will not touch any
311 // heap allocated object until GC is complete. 334 // heap allocated object until GC is complete.
312 // 335 //
313 // We say that a thread is at a safepoint if this thread is guaranteed to 336 // We say that a thread is at a safepoint if this thread is guaranteed to
314 // not touch any heap allocated object or any heap related functionality unt il 337 // not touch any heap allocated object or any heap related functionality unt il
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 447 }
425 448
426 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC ache = true; } 449 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC ache = true; }
427 450
428 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers) (v8::Isolate*, Visitor*)) 451 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers) (v8::Isolate*, Visitor*))
429 { 452 {
430 m_isolate = isolate; 453 m_isolate = isolate;
431 m_traceDOMWrappers = traceDOMWrappers; 454 m_traceDOMWrappers = traceDOMWrappers;
432 } 455 }
433 456
434 // By entering a gc-forbidden scope, conservative GCs will not
435 // be allowed while handling an out-of-line allocation request.
436 // Intended used when constructing subclasses of GC mixins, where
437 // the object being constructed cannot be safely traced & marked
438 // fully should a GC be allowed while its subclasses are being
439 // constructed.
440 void enterGCForbiddenScopeIfNeeded(GarbageCollectedMixinConstructorMarker* g cMixinMarker)
441 {
442 ASSERT(checkThread());
443 if (!m_gcMixinMarker) {
444 enterGCForbiddenScope();
445 m_gcMixinMarker = gcMixinMarker;
446 }
447 }
448 void leaveGCForbiddenScopeIfNeeded(GarbageCollectedMixinConstructorMarker* g cMixinMarker)
449 {
450 ASSERT(checkThread());
451 if (m_gcMixinMarker == gcMixinMarker) {
452 leaveGCForbiddenScope();
453 m_gcMixinMarker = nullptr;
454 }
455 }
456
457 // vectorBackingHeap() returns a heap that the vector allocation should use. 457 // vectorBackingHeap() returns a heap that the vector allocation should use.
458 // We have four vector heaps and want to choose the best heap here. 458 // We have four vector heaps and want to choose the best heap here.
459 // 459 //
460 // The goal is to improve the succession rate where expand and 460 // The goal is to improve the succession rate where expand and
461 // promptlyFree happen at an allocation point. This is a key for reusing 461 // promptlyFree happen at an allocation point. This is a key for reusing
462 // the same memory as much as possible and thus improves performance. 462 // the same memory as much as possible and thus improves performance.
463 // To achieve the goal, we use the following heuristics: 463 // To achieve the goal, we use the following heuristics:
464 // 464 //
465 // - A vector that has been expanded recently is likely to be expanded 465 // - A vector that has been expanded recently is likely to be expanded
466 // again soon. 466 // again soon.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 }; 674 };
675 675
676 template<> class ThreadStateFor<AnyThread> { 676 template<> class ThreadStateFor<AnyThread> {
677 public: 677 public:
678 static ThreadState* state() { return ThreadState::current(); } 678 static ThreadState* state() { return ThreadState::current(); }
679 }; 679 };
680 680
681 } // namespace blink 681 } // namespace blink
682 682
683 #endif // ThreadState_h 683 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698