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

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

Issue 2626923004: rewrite_to_chrome_style: Use constexpr as backdoor to get consistency (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TraceTraits_h 5 #ifndef TraceTraits_h
6 #define TraceTraits_h 6 #define TraceTraits_h
7 7
8 #include "platform/heap/GCInfo.h" 8 #include "platform/heap/GCInfo.h"
9 #include "platform/heap/Heap.h" 9 #include "platform/heap/Heap.h"
10 #include "platform/heap/InlinedGlobalMarkingVisitor.h" 10 #include "platform/heap/InlinedGlobalMarkingVisitor.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // weak pointers. 683 // weak pointers.
684 // Corner case: If there is weakness on both the key and value side, 684 // Corner case: If there is weakness on both the key and value side,
685 // and there are also strong pointers on the both sides then we could 685 // and there are also strong pointers on the both sides then we could
686 // unexpectedly leak. The scenario is that the weak pointer on the key 686 // unexpectedly leak. The scenario is that the weak pointer on the key
687 // side is alive, which causes the strong pointer on the key side to be 687 // side is alive, which causes the strong pointer on the key side to be
688 // marked. If that then results in the object pointed to by the weak 688 // marked. If that then results in the object pointed to by the weak
689 // pointer on the value side being marked live, then the whole 689 // pointer on the value side being marked live, then the whole
690 // key-value entry is leaked. To avoid unexpected leaking, we disallow 690 // key-value entry is leaked. To avoid unexpected leaking, we disallow
691 // this case, but if you run into this assert, please reach out to Blink 691 // this case, but if you run into this assert, please reach out to Blink
692 // reviewers, and we may relax it. 692 // reviewers, and we may relax it.
693 const bool keyIsWeak = 693 constexpr bool keyIsWeak =
694 Traits::KeyTraits::weakHandlingFlag == WeakHandlingInCollections; 694 Traits::KeyTraits::weakHandlingFlag == WeakHandlingInCollections;
695 const bool valueIsWeak = 695 constexpr bool valueIsWeak =
696 Traits::ValueTraits::weakHandlingFlag == WeakHandlingInCollections; 696 Traits::ValueTraits::weakHandlingFlag == WeakHandlingInCollections;
697 const bool keyHasStrongRefs = 697 const bool keyHasStrongRefs =
698 IsTraceableInCollectionTrait<typename Traits::KeyTraits>::value; 698 IsTraceableInCollectionTrait<typename Traits::KeyTraits>::value;
699 const bool valueHasStrongRefs = 699 const bool valueHasStrongRefs =
700 IsTraceableInCollectionTrait<typename Traits::ValueTraits>::value; 700 IsTraceableInCollectionTrait<typename Traits::ValueTraits>::value;
701 static_assert( 701 static_assert(
702 !keyIsWeak || !valueIsWeak || !keyHasStrongRefs || !valueHasStrongRefs, 702 !keyIsWeak || !valueIsWeak || !keyHasStrongRefs || !valueHasStrongRefs,
703 "this configuration is disallowed to avoid unexpected leaks"); 703 "this configuration is disallowed to avoid unexpected leaks");
704 if ((valueIsWeak && !keyIsWeak) || 704 if ((valueIsWeak && !keyIsWeak) ||
705 (valueIsWeak && keyIsWeak && !valueHasStrongRefs)) { 705 (valueIsWeak && keyIsWeak && !valueHasStrongRefs)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // since iterating over the hash table backing will find the whole 791 // since iterating over the hash table backing will find the whole
792 // chain. 792 // chain.
793 visitor->markNoTracing(node); 793 visitor->markNoTracing(node);
794 return false; 794 return false;
795 } 795 }
796 }; 796 };
797 797
798 } // namespace WTF 798 } // namespace WTF
799 799
800 #endif 800 #endif
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698