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

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

Issue 337653002: Oilpan: GC_TRACING: Improve object path dump (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Skip WebCore::Persistent frames automatically 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 | Source/platform/heap/Heap.h » ('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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(Persistent); 287 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(Persistent);
288 WTF_DISALLOW_ZERO_ASSIGNMENT(Persistent); 288 WTF_DISALLOW_ZERO_ASSIGNMENT(Persistent);
289 public: 289 public:
290 Persistent() : m_raw(0) { } 290 Persistent() : m_raw(0) { }
291 291
292 Persistent(std::nullptr_t) : m_raw(0) { } 292 Persistent(std::nullptr_t) : m_raw(0) { }
293 293
294 Persistent(T* raw) : m_raw(raw) 294 Persistent(T* raw) : m_raw(raw)
295 { 295 {
296 ASSERT_IS_VALID_PERSISTENT_POINTER(m_raw); 296 ASSERT_IS_VALID_PERSISTENT_POINTER(m_raw);
297 recordBacktrace();
297 } 298 }
298 299
299 explicit Persistent(T& raw) : m_raw(&raw) 300 explicit Persistent(T& raw) : m_raw(&raw)
300 { 301 {
301 ASSERT_IS_VALID_PERSISTENT_POINTER(m_raw); 302 ASSERT_IS_VALID_PERSISTENT_POINTER(m_raw);
303 recordBacktrace();
302 } 304 }
303 305
304 Persistent(const Persistent& other) : m_raw(other) { } 306 Persistent(const Persistent& other) : m_raw(other) { recordBacktrace(); }
305 307
306 template<typename U> 308 template<typename U>
307 Persistent(const Persistent<U, RootsAccessor>& other) : m_raw(other) { } 309 Persistent(const Persistent<U, RootsAccessor>& other) : m_raw(other) { recor dBacktrace(); }
308 310
309 template<typename U> 311 template<typename U>
310 Persistent(const Member<U>& other) : m_raw(other) { } 312 Persistent(const Member<U>& other) : m_raw(other) { recordBacktrace(); }
311 313
312 template<typename U> 314 template<typename U>
313 Persistent(const RawPtr<U>& other) : m_raw(other.get()) { } 315 Persistent(const RawPtr<U>& other) : m_raw(other.get()) { recordBacktrace(); }
314 316
315 template<typename U> 317 template<typename U>
316 Persistent& operator=(U* other) 318 Persistent& operator=(U* other)
317 { 319 {
318 m_raw = other; 320 m_raw = other;
321 recordBacktrace();
319 return *this; 322 return *this;
320 } 323 }
321 324
322 Persistent& operator=(std::nullptr_t) 325 Persistent& operator=(std::nullptr_t)
323 { 326 {
324 m_raw = 0; 327 m_raw = 0;
325 return *this; 328 return *this;
326 } 329 }
327 330
328 void clear() { m_raw = 0; } 331 void clear() { m_raw = 0; }
329 332
330 virtual ~Persistent() 333 virtual ~Persistent()
331 { 334 {
332 m_raw = 0; 335 m_raw = 0;
333 } 336 }
334 337
335 template<typename U> 338 template<typename U>
336 U* as() const 339 U* as() const
337 { 340 {
338 return static_cast<U*>(m_raw); 341 return static_cast<U*>(m_raw);
339 } 342 }
340 343
341 void trace(Visitor* visitor) 344 void trace(Visitor* visitor)
342 { 345 {
343 COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInPersis tent); 346 COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInPersis tent);
344 #if ENABLE(GC_TRACING) 347 #if ENABLE(GC_TRACING)
345 visitor->setHostInfo(this, "Persistent"); 348 visitor->setHostInfo(this, m_tracingName.isEmpty() ? "Persistent" : m_tr acingName);
346 #endif 349 #endif
347 visitor->mark(m_raw); 350 visitor->mark(m_raw);
348 } 351 }
349 352
350 T* release() 353 T* release()
351 { 354 {
352 T* result = m_raw; 355 T* result = m_raw;
353 m_raw = 0; 356 m_raw = 0;
354 return result; 357 return result;
355 } 358 }
356 359
357 T& operator*() const { return *m_raw; } 360 T& operator*() const { return *m_raw; }
358 361
359 bool operator!() const { return !m_raw; } 362 bool operator!() const { return !m_raw; }
360 363
361 operator T*() const { return m_raw; } 364 operator T*() const { return m_raw; }
362 operator RawPtr<T>() const { return m_raw; } 365 operator RawPtr<T>() const { return m_raw; }
363 366
364 T* operator->() const { return *this; } 367 T* operator->() const { return *this; }
365 368
366 Persistent& operator=(const Persistent& other) 369 Persistent& operator=(const Persistent& other)
367 { 370 {
368 m_raw = other; 371 m_raw = other;
372 recordBacktrace();
369 return *this; 373 return *this;
370 } 374 }
371 375
372 template<typename U> 376 template<typename U>
373 Persistent& operator=(const Persistent<U, RootsAccessor>& other) 377 Persistent& operator=(const Persistent<U, RootsAccessor>& other)
374 { 378 {
375 m_raw = other; 379 m_raw = other;
380 recordBacktrace();
376 return *this; 381 return *this;
377 } 382 }
378 383
379 template<typename U> 384 template<typename U>
380 Persistent& operator=(const Member<U>& other) 385 Persistent& operator=(const Member<U>& other)
381 { 386 {
382 m_raw = other; 387 m_raw = other;
388 recordBacktrace();
383 return *this; 389 return *this;
384 } 390 }
385 391
386 template<typename U> 392 template<typename U>
387 Persistent& operator=(const RawPtr<U>& other) 393 Persistent& operator=(const RawPtr<U>& other)
388 { 394 {
389 m_raw = other; 395 m_raw = other;
396 recordBacktrace();
390 return *this; 397 return *this;
391 } 398 }
392 399
393 T* get() const { return m_raw; } 400 T* get() const { return m_raw; }
394 401
395 private: 402 private:
403 #if ENABLE(GC_TRACING)
404 void recordBacktrace()
405 {
406 if (m_raw)
407 m_tracingName = Heap::createBacktraceString();
408 }
409
410 String m_tracingName;
411 #else
412 inline void recordBacktrace() const { }
413 #endif
396 T* m_raw; 414 T* m_raw;
397 415
398 friend class CrossThreadPersistent<T>; 416 friend class CrossThreadPersistent<T>;
399 }; 417 };
400 418
401 // Unlike Persistent, we can destruct a CrossThreadPersistent in a thread 419 // Unlike Persistent, we can destruct a CrossThreadPersistent in a thread
402 // different from the construction thread. 420 // different from the construction thread.
403 template<typename T> 421 template<typename T>
404 class CrossThreadPersistent : public Persistent<T, GlobalPersistents> { 422 class CrossThreadPersistent : public Persistent<T, GlobalPersistents> {
405 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(CrossThreadPersistent); 423 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(CrossThreadPersistent);
(...skipping 12 matching lines...) Expand all
418 // We overload the various new and delete operators with using the WTF Defau ltAllocator to ensure persistent 436 // We overload the various new and delete operators with using the WTF Defau ltAllocator to ensure persistent
419 // heap collections are always allocated off-heap. This allows persistent co llections to be used in 437 // heap collections are always allocated off-heap. This allows persistent co llections to be used in
420 // DEFINE_STATIC_LOCAL et. al. 438 // DEFINE_STATIC_LOCAL et. al.
421 WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::DefaultAllocator); 439 WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::DefaultAllocator);
422 public: 440 public:
423 PersistentHeapCollectionBase() { } 441 PersistentHeapCollectionBase() { }
424 442
425 template<typename OtherCollection> 443 template<typename OtherCollection>
426 PersistentHeapCollectionBase(const OtherCollection& other) : Collection(othe r) { } 444 PersistentHeapCollectionBase(const OtherCollection& other) : Collection(othe r) { }
427 445
428 void trace(Visitor* visitor) { visitor->trace(*static_cast<Collection*>(this )); } 446 void trace(Visitor* visitor)
447 {
448 #if ENABLE(GC_TRACING)
449 visitor->setHostInfo(this, "PersistentHeapCollectionBase");
450 #endif
451 visitor->trace(*static_cast<Collection*>(this));
452 }
429 }; 453 };
430 454
431 template< 455 template<
432 typename KeyArg, 456 typename KeyArg,
433 typename MappedArg, 457 typename MappedArg,
434 typename HashArg = typename DefaultHash<KeyArg>::Hash, 458 typename HashArg = typename DefaultHash<KeyArg>::Hash,
435 typename KeyTraitsArg = HashTraits<KeyArg>, 459 typename KeyTraitsArg = HashTraits<KeyArg>,
436 typename MappedTraitsArg = HashTraits<MappedArg> > 460 typename MappedTraitsArg = HashTraits<MappedArg> >
437 class PersistentHeapHashMap : public PersistentHeapCollectionBase<HeapHashMap<Ke yArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> > { }; 461 class PersistentHeapHashMap : public PersistentHeapCollectionBase<HeapHashMap<Ke yArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> > { };
438 462
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is GarbageCollectedType<T>::value> { 1200 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is GarbageCollectedType<T>::value> {
1177 }; 1201 };
1178 1202
1179 template<typename T> 1203 template<typename T>
1180 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web Core::IsGarbageCollectedType<T>::value> { 1204 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web Core::IsGarbageCollectedType<T>::value> {
1181 }; 1205 };
1182 1206
1183 } // namespace WTF 1207 } // namespace WTF
1184 1208
1185 #endif 1209 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698