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

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

Issue 338533002: Fix null pointer crash with adjustAndMark (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | « no previous file | no next file » | 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 public: 213 public:
214 virtual ~Visitor() { } 214 virtual ~Visitor() { }
215 215
216 // One-argument templated mark method. This uses the static type of 216 // One-argument templated mark method. This uses the static type of
217 // the argument to get the TraceTrait. By default, the mark method 217 // the argument to get the TraceTrait. By default, the mark method
218 // of the TraceTrait just calls the virtual two-argument mark method on this 218 // of the TraceTrait just calls the virtual two-argument mark method on this
219 // visitor, where the second argument is the static trace method of the trai t. 219 // visitor, where the second argument is the static trace method of the trai t.
220 template<typename T> 220 template<typename T>
221 void mark(T* t) 221 void mark(T* t)
222 { 222 {
223 if (!t) 223 if (!t)
haraken 2014/06/13 09:14:16 I was thinking that this null check is enough. Isn
Erik Corry 2014/06/13 09:40:26 Not for members in vector backing.
224 return; 224 return;
225 #ifndef NDEBUG 225 #ifndef NDEBUG
226 TraceTrait<T>::checkGCInfo(this, t); 226 TraceTrait<T>::checkGCInfo(this, t);
227 #endif 227 #endif
228 TraceTrait<T>::mark(this, t); 228 TraceTrait<T>::mark(this, t);
229 } 229 }
230 230
231 // Member version of the one-argument templated trace method. 231 // Member version of the one-argument templated trace method.
232 template<typename T> 232 template<typename T>
233 void trace(const Member<T>& t) 233 void trace(const Member<T>& t)
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 visitor->checkGCInfo(const_cast<T*>(t), GCInfoTrait<T>::get()); 614 visitor->checkGCInfo(const_cast<T*>(t), GCInfoTrait<T>::get());
615 } 615 }
616 #endif 616 #endif
617 }; 617 };
618 618
619 template<typename T> 619 template<typename T>
620 class DefaultTraceTrait<T, true> { 620 class DefaultTraceTrait<T, true> {
621 public: 621 public:
622 static void mark(Visitor* visitor, const T* self) 622 static void mark(Visitor* visitor, const T* self)
623 { 623 {
624 self->adjustAndMark(visitor); 624 if (self)
sof 2014/06/13 09:12:54 Would it be possible move this "up" a bit? i.e., w
Erik Corry 2014/06/13 09:40:26 This is just for things that need adjustAndMark, s
sof 2014/06/13 09:49:35 alright, perhaps so.
625 self->adjustAndMark(visitor);
625 } 626 }
626 627
627 #ifndef NDEBUG 628 #ifndef NDEBUG
628 static void checkGCInfo(Visitor*, const T*) { } 629 static void checkGCInfo(Visitor*, const T*) { }
629 #endif 630 #endif
630 }; 631 };
631 632
632 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultObjectAli veTrait; 633 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultObjectAli veTrait;
633 634
634 template<typename T> 635 template<typename T>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 struct GCInfoTrait { 747 struct GCInfoTrait {
747 static const GCInfo* get() 748 static const GCInfo* get()
748 { 749 {
749 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); 750 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get();
750 } 751 }
751 }; 752 };
752 753
753 } 754 }
754 755
755 #endif 756 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698