Chromium Code Reviews| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 // to trace through a part object with visitor->trace(m_partObject). This | 282 // to trace through a part object with visitor->trace(m_partObject). This |
| 283 // takes a const argument, because otherwise it will match too eagerly: a | 283 // takes a const argument, because otherwise it will match too eagerly: a |
| 284 // non-const argument would match a non-const Vector<T>& argument better | 284 // non-const argument would match a non-const Vector<T>& argument better |
| 285 // than the specialization that takes const Vector<T>&. For a similar reason , | 285 // than the specialization that takes const Vector<T>&. For a similar reason , |
| 286 // the other specializations take a const argument even though they are | 286 // the other specializations take a const argument even though they are |
| 287 // usually used with non-const arguments, otherwise this function would matc h | 287 // usually used with non-const arguments, otherwise this function would matc h |
| 288 // too well. | 288 // too well. |
| 289 template<typename T> | 289 template<typename T> |
| 290 void trace(const T& t) | 290 void trace(const T& t) |
| 291 { | 291 { |
| 292 if (WTF::IsPolymorphic<T>::value) { | |
| 293 intptr_t vtable = *reinterpret_cast<const intptr_t*>(&t); | |
| 294 if (!vtable) | |
|
haraken
2014/08/11 10:44:02
Can we merge this check with vTableInitialized() i
Mads Ager (chromium)
2014/08/11 12:17:36
These are two different checks:
The check that we
| |
| 295 return; | |
| 296 } | |
| 292 const_cast<T&>(t).trace(this); | 297 const_cast<T&>(t).trace(this); |
| 293 } | 298 } |
| 294 | 299 |
| 295 // The following trace methods are for off-heap collections. | 300 // The following trace methods are for off-heap collections. |
| 296 template<typename T, size_t inlineCapacity> | 301 template<typename T, size_t inlineCapacity> |
| 297 void trace(const Vector<T, inlineCapacity>& vector) | 302 void trace(const Vector<T, inlineCapacity>& vector) |
| 298 { | 303 { |
| 299 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca tor> >::trace(this, vector); | 304 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca tor> >::trace(this, vector); |
| 300 } | 305 } |
| 301 | 306 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 struct GCInfoTrait { | 639 struct GCInfoTrait { |
| 635 static const GCInfo* get() | 640 static const GCInfo* get() |
| 636 { | 641 { |
| 637 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 642 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
| 638 } | 643 } |
| 639 }; | 644 }; |
| 640 | 645 |
| 641 } | 646 } |
| 642 | 647 |
| 643 #endif | 648 #endif |
| OLD | NEW |