| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 static Foo* create(Bar* bar) | 355 static Foo* create(Bar* bar) |
| 356 { | 356 { |
| 357 return new Foo(bar); | 357 return new Foo(bar); |
| 358 } | 358 } |
| 359 | 359 |
| 360 static Foo* create(Foo* foo) | 360 static Foo* create(Foo* foo) |
| 361 { | 361 { |
| 362 return new Foo(foo); | 362 return new Foo(foo); |
| 363 } | 363 } |
| 364 | 364 |
| 365 virtual void trace(Visitor* visitor) | 365 virtual void trace(Visitor* visitor) OVERRIDE |
| 366 { | 366 { |
| 367 if (m_pointsToFoo) | 367 if (m_pointsToFoo) |
| 368 visitor->mark(static_cast<Foo*>(m_bar)); | 368 visitor->mark(static_cast<Foo*>(m_bar)); |
| 369 else | 369 else |
| 370 visitor->mark(m_bar); | 370 visitor->mark(m_bar); |
| 371 } | 371 } |
| 372 | 372 |
| 373 private: | 373 private: |
| 374 Foo(Bar* bar) | 374 Foo(Bar* bar) |
| 375 : Bar() | 375 : Bar() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 389 bool m_pointsToFoo; | 389 bool m_pointsToFoo; |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 class Bars : public Bar { | 392 class Bars : public Bar { |
| 393 public: | 393 public: |
| 394 static Bars* create() | 394 static Bars* create() |
| 395 { | 395 { |
| 396 return new Bars(); | 396 return new Bars(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 virtual void trace(Visitor* visitor) | 399 virtual void trace(Visitor* visitor) OVERRIDE |
| 400 { | 400 { |
| 401 for (unsigned i = 0; i < m_width; i++) | 401 for (unsigned i = 0; i < m_width; i++) |
| 402 visitor->trace(m_bars[i]); | 402 visitor->trace(m_bars[i]); |
| 403 } | 403 } |
| 404 | 404 |
| 405 unsigned getWidth() const | 405 unsigned getWidth() const |
| 406 { | 406 { |
| 407 return m_width; | 407 return m_width; |
| 408 } | 408 } |
| 409 | 409 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 int RefCountedAndGarbageCollected::s_destructorCalls = 0; | 492 int RefCountedAndGarbageCollected::s_destructorCalls = 0; |
| 493 | 493 |
| 494 | 494 |
| 495 class Weak : public Bar { | 495 class Weak : public Bar { |
| 496 public: | 496 public: |
| 497 static Weak* create(Bar* strong, Bar* weak) | 497 static Weak* create(Bar* strong, Bar* weak) |
| 498 { | 498 { |
| 499 return new Weak(strong, weak); | 499 return new Weak(strong, weak); |
| 500 } | 500 } |
| 501 | 501 |
| 502 virtual void trace(Visitor* visitor) | 502 virtual void trace(Visitor* visitor) OVERRIDE |
| 503 { | 503 { |
| 504 visitor->trace(m_strongBar); | 504 visitor->trace(m_strongBar); |
| 505 visitor->registerWeakMembers(this, zapWeakMembers); | 505 visitor->registerWeakMembers(this, zapWeakMembers); |
| 506 } | 506 } |
| 507 | 507 |
| 508 static void zapWeakMembers(Visitor* visitor, void* self) | 508 static void zapWeakMembers(Visitor* visitor, void* self) |
| 509 { | 509 { |
| 510 reinterpret_cast<Weak*>(self)->zapWeakMembers(visitor); | 510 reinterpret_cast<Weak*>(self)->zapWeakMembers(visitor); |
| 511 } | 511 } |
| 512 | 512 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 531 Bar* m_weakBar; | 531 Bar* m_weakBar; |
| 532 }; | 532 }; |
| 533 | 533 |
| 534 class WithWeakMember : public Bar { | 534 class WithWeakMember : public Bar { |
| 535 public: | 535 public: |
| 536 static WithWeakMember* create(Bar* strong, Bar* weak) | 536 static WithWeakMember* create(Bar* strong, Bar* weak) |
| 537 { | 537 { |
| 538 return new WithWeakMember(strong, weak); | 538 return new WithWeakMember(strong, weak); |
| 539 } | 539 } |
| 540 | 540 |
| 541 virtual void trace(Visitor* visitor) | 541 virtual void trace(Visitor* visitor) OVERRIDE |
| 542 { | 542 { |
| 543 visitor->trace(m_strongBar); | 543 visitor->trace(m_strongBar); |
| 544 visitor->trace(m_weakBar); | 544 visitor->trace(m_weakBar); |
| 545 } | 545 } |
| 546 | 546 |
| 547 bool strongIsThere() { return !!m_strongBar; } | 547 bool strongIsThere() { return !!m_strongBar; } |
| 548 bool weakIsThere() { return !!m_weakBar; } | 548 bool weakIsThere() { return !!m_weakBar; } |
| 549 | 549 |
| 550 private: | 550 private: |
| 551 WithWeakMember(Bar* strongBar, Bar* weakBar) | 551 WithWeakMember(Bar* strongBar, Bar* weakBar) |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 DEFINE_GC_INFO(ConstructorAllocation); | 1014 DEFINE_GC_INFO(ConstructorAllocation); |
| 1015 DEFINE_GC_INFO(HeapAllocatedArray); | 1015 DEFINE_GC_INFO(HeapAllocatedArray); |
| 1016 DEFINE_GC_INFO(IntWrapper); | 1016 DEFINE_GC_INFO(IntWrapper); |
| 1017 DEFINE_GC_INFO(LargeObject); | 1017 DEFINE_GC_INFO(LargeObject); |
| 1018 DEFINE_GC_INFO(RefCountedAndGarbageCollected); | 1018 DEFINE_GC_INFO(RefCountedAndGarbageCollected); |
| 1019 DEFINE_GC_INFO(SimpleFinalizedObject); | 1019 DEFINE_GC_INFO(SimpleFinalizedObject); |
| 1020 DEFINE_GC_INFO(TestTypedHeapClass); | 1020 DEFINE_GC_INFO(TestTypedHeapClass); |
| 1021 DEFINE_GC_INFO(TraceCounter); | 1021 DEFINE_GC_INFO(TraceCounter); |
| 1022 | 1022 |
| 1023 } // namespace | 1023 } // namespace |
| OLD | NEW |