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

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

Issue 1190863003: Oilpan: Allocation should be allowed in pre-finalizers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 class Visitor; 65 class Visitor;
66 66
67 using Address = uint8_t*; 67 using Address = uint8_t*;
68 68
69 using FinalizationCallback = void (*)(void*); 69 using FinalizationCallback = void (*)(void*);
70 using VisitorCallback = void (*)(Visitor*, void* self); 70 using VisitorCallback = void (*)(Visitor*, void* self);
71 using TraceCallback = VisitorCallback; 71 using TraceCallback = VisitorCallback;
72 using WeakCallback = VisitorCallback; 72 using WeakCallback = VisitorCallback;
73 using EphemeronCallback = VisitorCallback; 73 using EphemeronCallback = VisitorCallback;
74 74
75 // Declare that a class has a pre-finalizer function. The function is called in 75 // Declare that a class has a pre-finalizer function. The function is called in
76 // the object's owner thread, and can access Member<>s to other 76 // the object's owner thread. The pre-finalizer is called before any object gets
77 // garbage-collected objects allocated in the thread. However we must not 77 // swept, so it is allowed to touch on-heap objects that may be collected in the
78 // allocate new garbage-collected objects, nor update Member<> and Persistent<> 78 // GC cycle. If you cannot avoid touching on-heap objects in a destructor (which
79 // pointers. 79 // is not allowed), you can consider using the pre-finalizer or
80 // EARGERY_FINALIZED. The only restriction is that the pre-finalizer must not
81 // resurrect dead objects (e.g., store unmarked objects into Members etc).
80 // 82 //
81 // This feature is similar to the HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>> 83 // This feature is similar to the HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>>
82 // idiom. The difference between this and the idiom is that pre-finalizer 84 // idiom. The difference between this and the idiom is that pre-finalizer
83 // function is called whenever an object is destructed with this feature. The 85 // function is called whenever an object is destructed with this feature. The
84 // HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>> idiom requires an assumption 86 // HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>> idiom requires an assumption
85 // that the HeapHashMap outlives objects pointed by WeakMembers. 87 // that the HeapHashMap outlives objects pointed by WeakMembers.
86 // FIXME: Replace all of the HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>> 88 // FIXME: Replace all of the HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>>
87 // idiom usages with the pre-finalizer if the replacement won't cause 89 // idiom usages with the pre-finalizer if the replacement won't cause
88 // performance regressions. 90 // performance regressions.
89 // 91 //
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 void incrementMarkedObjectsAge(); 524 void incrementMarkedObjectsAge();
523 525
524 void snapshotFreeListIfNecessary(); 526 void snapshotFreeListIfNecessary();
525 527
526 void collectAndReportMarkSweepStats() const; 528 void collectAndReportMarkSweepStats() const;
527 void reportMarkSweepStats(const char* statsName, const ClassAgeCountsMap&) c onst; 529 void reportMarkSweepStats(const char* statsName, const ClassAgeCountsMap&) c onst;
528 #endif 530 #endif
529 531
530 void pushThreadLocalWeakCallback(void*, WeakCallback); 532 void pushThreadLocalWeakCallback(void*, WeakCallback);
531 bool popAndInvokeThreadLocalWeakCallback(Visitor*); 533 bool popAndInvokeThreadLocalWeakCallback(Visitor*);
534 void threadLocalWeakProcessing();
532 535
533 size_t objectPayloadSizeForTesting(); 536 size_t objectPayloadSizeForTesting();
534 void prepareHeapForTermination(); 537 void prepareHeapForTermination();
535 538
536 // Request to call a pref-finalizer of the target object before the object 539 // Request to call a pref-finalizer of the target object before the object
537 // is destructed. The class T must have USING_PRE_FINALIZER(). The 540 // is destructed. The class T must have USING_PRE_FINALIZER(). The
538 // argument should be |*this|. Registering a lot of objects affects GC 541 // argument should be |*this|. Registering a lot of objects affects GC
539 // performance. We should register an object only if the object really 542 // performance. We should register an object only if the object really
540 // requires pre-finalizer, and we should unregister the object if 543 // requires pre-finalizer, and we should unregister the object if
541 // pre-finalizer is unnecessary. 544 // pre-finalizer is unnecessary.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 }; 775 };
773 776
774 template<> class ThreadStateFor<AnyThread> { 777 template<> class ThreadStateFor<AnyThread> {
775 public: 778 public:
776 static ThreadState* state() { return ThreadState::current(); } 779 static ThreadState* state() { return ThreadState::current(); }
777 }; 780 };
778 781
779 } // namespace blink 782 } // namespace blink
780 783
781 #endif // ThreadState_h 784 #endif // ThreadState_h
OLDNEW
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698