| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) | 108 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) |
| 109 | 109 |
| 110 size_t count() { return m_count; } | 110 size_t count() { return m_count; } |
| 111 void reset() { m_count = 0; } | 111 void reset() { m_count = 0; } |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 size_t m_count; | 114 size_t m_count; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 class SimpleObject : public GarbageCollected<SimpleObject> { | 117 class SimpleObject : public GarbageCollected<SimpleObject> { |
| 118 DECLARE_GC_INFO; | |
| 119 public: | 118 public: |
| 120 static SimpleObject* create() { return new SimpleObject(); } | 119 static SimpleObject* create() { return new SimpleObject(); } |
| 121 void trace(Visitor*) { } | 120 void trace(Visitor*) { } |
| 122 char getPayload(int i) { return payload[i]; } | 121 char getPayload(int i) { return payload[i]; } |
| 123 private: | 122 private: |
| 124 SimpleObject() { } | 123 SimpleObject() { } |
| 125 char payload[64]; | 124 char payload[64]; |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 #undef DEFINE_VISITOR_METHODS | 127 #undef DEFINE_VISITOR_METHODS |
| 129 | 128 |
| 130 class HeapTestSuperClass : public GarbageCollectedFinalized<HeapTestSuperClass>
{ | 129 class HeapTestSuperClass : public GarbageCollectedFinalized<HeapTestSuperClass>
{ |
| 131 DECLARE_GC_INFO | |
| 132 public: | 130 public: |
| 133 static HeapTestSuperClass* create() | 131 static HeapTestSuperClass* create() |
| 134 { | 132 { |
| 135 return new HeapTestSuperClass(); | 133 return new HeapTestSuperClass(); |
| 136 } | 134 } |
| 137 | 135 |
| 138 virtual ~HeapTestSuperClass() | 136 virtual ~HeapTestSuperClass() |
| 139 { | 137 { |
| 140 ++s_destructorCalls; | 138 ++s_destructorCalls; |
| 141 } | 139 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 private: | 172 private: |
| 175 | 173 |
| 176 HeapTestSubClass() : m_magic(classMagic) { } | 174 HeapTestSubClass() : m_magic(classMagic) { } |
| 177 | 175 |
| 178 const size_t m_magic; | 176 const size_t m_magic; |
| 179 }; | 177 }; |
| 180 | 178 |
| 181 int HeapTestSubClass::s_destructorCalls = 0; | 179 int HeapTestSubClass::s_destructorCalls = 0; |
| 182 | 180 |
| 183 class HeapAllocatedArray : public GarbageCollected<HeapAllocatedArray> { | 181 class HeapAllocatedArray : public GarbageCollected<HeapAllocatedArray> { |
| 184 DECLARE_GC_INFO | |
| 185 public: | 182 public: |
| 186 HeapAllocatedArray() | 183 HeapAllocatedArray() |
| 187 { | 184 { |
| 188 for (int i = 0; i < s_arraySize; ++i) { | 185 for (int i = 0; i < s_arraySize; ++i) { |
| 189 m_array[i] = i % 128; | 186 m_array[i] = i % 128; |
| 190 } | 187 } |
| 191 } | 188 } |
| 192 | 189 |
| 193 int8_t at(size_t i) { return m_array[i]; } | 190 int8_t at(size_t i) { return m_array[i]; } |
| 194 void trace(Visitor*) { } | 191 void trace(Visitor*) { } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 205 getHeapStats(heapStats); | 202 getHeapStats(heapStats); |
| 206 size_t used = heapStats->totalObjectSpace(); | 203 size_t used = heapStats->totalObjectSpace(); |
| 207 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 204 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 208 getHeapStats(heapStats); | 205 getHeapStats(heapStats); |
| 209 if (heapStats->totalObjectSpace() >= used) | 206 if (heapStats->totalObjectSpace() >= used) |
| 210 break; | 207 break; |
| 211 } | 208 } |
| 212 } | 209 } |
| 213 | 210 |
| 214 class IntWrapper : public GarbageCollectedFinalized<IntWrapper> { | 211 class IntWrapper : public GarbageCollectedFinalized<IntWrapper> { |
| 215 DECLARE_GC_INFO | |
| 216 public: | 212 public: |
| 217 static IntWrapper* create(int x) | 213 static IntWrapper* create(int x) |
| 218 { | 214 { |
| 219 return new IntWrapper(x); | 215 return new IntWrapper(x); |
| 220 } | 216 } |
| 221 | 217 |
| 222 virtual ~IntWrapper() | 218 virtual ~IntWrapper() |
| 223 { | 219 { |
| 224 ++s_destructorCalls; | 220 ++s_destructorCalls; |
| 225 } | 221 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // sizes. This is done in a different way on 32 bit and 64 bit, so we have to | 316 // sizes. This is done in a different way on 32 bit and 64 bit, so we have to |
| 321 // have some slack in the tests. | 317 // have some slack in the tests. |
| 322 template<typename T> | 318 template<typename T> |
| 323 void CheckWithSlack(T expected, T actual, int slack) | 319 void CheckWithSlack(T expected, T actual, int slack) |
| 324 { | 320 { |
| 325 EXPECT_LE(expected, actual); | 321 EXPECT_LE(expected, actual); |
| 326 EXPECT_GE((intptr_t)expected + slack, (intptr_t)actual); | 322 EXPECT_GE((intptr_t)expected + slack, (intptr_t)actual); |
| 327 } | 323 } |
| 328 | 324 |
| 329 class TraceCounter : public GarbageCollectedFinalized<TraceCounter> { | 325 class TraceCounter : public GarbageCollectedFinalized<TraceCounter> { |
| 330 DECLARE_GC_INFO | |
| 331 public: | 326 public: |
| 332 static TraceCounter* create() | 327 static TraceCounter* create() |
| 333 { | 328 { |
| 334 return new TraceCounter(); | 329 return new TraceCounter(); |
| 335 } | 330 } |
| 336 | 331 |
| 337 void trace(Visitor*) { m_traceCount++; } | 332 void trace(Visitor*) { m_traceCount++; } |
| 338 | 333 |
| 339 int traceCount() { return m_traceCount; } | 334 int traceCount() { return m_traceCount; } |
| 340 | 335 |
| 341 private: | 336 private: |
| 342 TraceCounter() | 337 TraceCounter() |
| 343 : m_traceCount(0) | 338 : m_traceCount(0) |
| 344 { | 339 { |
| 345 } | 340 } |
| 346 | 341 |
| 347 int m_traceCount; | 342 int m_traceCount; |
| 348 }; | 343 }; |
| 349 | 344 |
| 350 class ClassWithMember : public GarbageCollected<ClassWithMember> { | 345 class ClassWithMember : public GarbageCollected<ClassWithMember> { |
| 351 DECLARE_GC_INFO | |
| 352 public: | 346 public: |
| 353 static ClassWithMember* create() | 347 static ClassWithMember* create() |
| 354 { | 348 { |
| 355 return new ClassWithMember(); | 349 return new ClassWithMember(); |
| 356 } | 350 } |
| 357 | 351 |
| 358 void trace(Visitor* visitor) | 352 void trace(Visitor* visitor) |
| 359 { | 353 { |
| 360 EXPECT_TRUE(visitor->isMarked(this)); | 354 EXPECT_TRUE(visitor->isMarked(this)); |
| 361 if (!traceCount()) | 355 if (!traceCount()) |
| 362 EXPECT_FALSE(visitor->isMarked(m_traceCounter)); | 356 EXPECT_FALSE(visitor->isMarked(m_traceCounter)); |
| 363 else | 357 else |
| 364 EXPECT_TRUE(visitor->isMarked(m_traceCounter)); | 358 EXPECT_TRUE(visitor->isMarked(m_traceCounter)); |
| 365 | 359 |
| 366 visitor->trace(m_traceCounter); | 360 visitor->trace(m_traceCounter); |
| 367 } | 361 } |
| 368 | 362 |
| 369 int traceCount() { return m_traceCounter->traceCount(); } | 363 int traceCount() { return m_traceCounter->traceCount(); } |
| 370 | 364 |
| 371 private: | 365 private: |
| 372 ClassWithMember() | 366 ClassWithMember() |
| 373 : m_traceCounter(TraceCounter::create()) | 367 : m_traceCounter(TraceCounter::create()) |
| 374 { } | 368 { } |
| 375 | 369 |
| 376 Member<TraceCounter> m_traceCounter; | 370 Member<TraceCounter> m_traceCounter; |
| 377 }; | 371 }; |
| 378 | 372 |
| 379 class SimpleFinalizedObject : public GarbageCollectedFinalized<SimpleFinalizedOb
ject> { | 373 class SimpleFinalizedObject : public GarbageCollectedFinalized<SimpleFinalizedOb
ject> { |
| 380 DECLARE_GC_INFO | |
| 381 public: | 374 public: |
| 382 static SimpleFinalizedObject* create() | 375 static SimpleFinalizedObject* create() |
| 383 { | 376 { |
| 384 return new SimpleFinalizedObject(); | 377 return new SimpleFinalizedObject(); |
| 385 } | 378 } |
| 386 | 379 |
| 387 ~SimpleFinalizedObject() | 380 ~SimpleFinalizedObject() |
| 388 { | 381 { |
| 389 ++s_destructorCalls; | 382 ++s_destructorCalls; |
| 390 } | 383 } |
| 391 | 384 |
| 392 static int s_destructorCalls; | 385 static int s_destructorCalls; |
| 393 | 386 |
| 394 void trace(Visitor*) { } | 387 void trace(Visitor*) { } |
| 395 | 388 |
| 396 private: | 389 private: |
| 397 SimpleFinalizedObject() { } | 390 SimpleFinalizedObject() { } |
| 398 }; | 391 }; |
| 399 | 392 |
| 400 int SimpleFinalizedObject::s_destructorCalls = 0; | 393 int SimpleFinalizedObject::s_destructorCalls = 0; |
| 401 | 394 |
| 402 class TestTypedHeapClass : public GarbageCollected<TestTypedHeapClass> { | 395 class TestTypedHeapClass : public GarbageCollected<TestTypedHeapClass> { |
| 403 DECLARE_GC_INFO | |
| 404 public: | 396 public: |
| 405 static TestTypedHeapClass* create() | 397 static TestTypedHeapClass* create() |
| 406 { | 398 { |
| 407 return new TestTypedHeapClass(); | 399 return new TestTypedHeapClass(); |
| 408 } | 400 } |
| 409 | 401 |
| 410 void trace(Visitor*) { } | 402 void trace(Visitor*) { } |
| 411 | 403 |
| 412 private: | 404 private: |
| 413 TestTypedHeapClass() { } | 405 TestTypedHeapClass() { } |
| 414 }; | 406 }; |
| 415 | 407 |
| 416 class Bar : public GarbageCollectedFinalized<Bar> { | 408 class Bar : public GarbageCollectedFinalized<Bar> { |
| 417 DECLARE_GC_INFO | |
| 418 public: | 409 public: |
| 419 static Bar* create() | 410 static Bar* create() |
| 420 { | 411 { |
| 421 return new Bar(); | 412 return new Bar(); |
| 422 } | 413 } |
| 423 | 414 |
| 424 void finalize() | 415 void finalize() |
| 425 { | 416 { |
| 426 EXPECT_TRUE(m_magic == magic); | 417 EXPECT_TRUE(m_magic == magic); |
| 427 m_magic = 0; | 418 m_magic = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 438 Bar() | 429 Bar() |
| 439 : m_magic(magic) | 430 : m_magic(magic) |
| 440 { | 431 { |
| 441 s_live++; | 432 s_live++; |
| 442 } | 433 } |
| 443 }; | 434 }; |
| 444 | 435 |
| 445 unsigned Bar::s_live = 0; | 436 unsigned Bar::s_live = 0; |
| 446 | 437 |
| 447 class Baz : public GarbageCollected<Baz> { | 438 class Baz : public GarbageCollected<Baz> { |
| 448 DECLARE_GC_INFO | |
| 449 public: | 439 public: |
| 450 static Baz* create(Bar* bar) | 440 static Baz* create(Bar* bar) |
| 451 { | 441 { |
| 452 return new Baz(bar); | 442 return new Baz(bar); |
| 453 } | 443 } |
| 454 | 444 |
| 455 void trace(Visitor* visitor) | 445 void trace(Visitor* visitor) |
| 456 { | 446 { |
| 457 visitor->trace(m_bar); | 447 visitor->trace(m_bar); |
| 458 } | 448 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 m_bars[i] = Bar::create(); | 523 m_bars[i] = Bar::create(); |
| 534 m_width++; | 524 m_width++; |
| 535 } | 525 } |
| 536 } | 526 } |
| 537 | 527 |
| 538 unsigned m_width; | 528 unsigned m_width; |
| 539 Member<Bar> m_bars[width]; | 529 Member<Bar> m_bars[width]; |
| 540 }; | 530 }; |
| 541 | 531 |
| 542 class ConstructorAllocation : public GarbageCollected<ConstructorAllocation> { | 532 class ConstructorAllocation : public GarbageCollected<ConstructorAllocation> { |
| 543 DECLARE_GC_INFO | |
| 544 public: | 533 public: |
| 545 static ConstructorAllocation* create() { return new ConstructorAllocation();
} | 534 static ConstructorAllocation* create() { return new ConstructorAllocation();
} |
| 546 | 535 |
| 547 void trace(Visitor* visitor) { visitor->trace(m_intWrapper); } | 536 void trace(Visitor* visitor) { visitor->trace(m_intWrapper); } |
| 548 | 537 |
| 549 private: | 538 private: |
| 550 ConstructorAllocation() | 539 ConstructorAllocation() |
| 551 { | 540 { |
| 552 m_intWrapper = IntWrapper::create(42); | 541 m_intWrapper = IntWrapper::create(42); |
| 553 } | 542 } |
| 554 | 543 |
| 555 Member<IntWrapper> m_intWrapper; | 544 Member<IntWrapper> m_intWrapper; |
| 556 }; | 545 }; |
| 557 | 546 |
| 558 class LargeObject : public GarbageCollectedFinalized<LargeObject> { | 547 class LargeObject : public GarbageCollectedFinalized<LargeObject> { |
| 559 DECLARE_GC_INFO | |
| 560 public: | 548 public: |
| 561 ~LargeObject() | 549 ~LargeObject() |
| 562 { | 550 { |
| 563 s_destructorCalls++; | 551 s_destructorCalls++; |
| 564 } | 552 } |
| 565 static LargeObject* create() { return new LargeObject(); } | 553 static LargeObject* create() { return new LargeObject(); } |
| 566 char get(size_t i) { return m_data[i]; } | 554 char get(size_t i) { return m_data[i]; } |
| 567 void set(size_t i, char c) { m_data[i] = c; } | 555 void set(size_t i, char c) { m_data[i] = c; } |
| 568 size_t length() { return s_length; } | 556 size_t length() { return s_length; } |
| 569 void trace(Visitor* visitor) | 557 void trace(Visitor* visitor) |
| 570 { | 558 { |
| 571 visitor->trace(m_intWrapper); | 559 visitor->trace(m_intWrapper); |
| 572 } | 560 } |
| 573 static int s_destructorCalls; | 561 static int s_destructorCalls; |
| 574 | 562 |
| 575 private: | 563 private: |
| 576 static const size_t s_length = 1024*1024; | 564 static const size_t s_length = 1024*1024; |
| 577 LargeObject() | 565 LargeObject() |
| 578 { | 566 { |
| 579 m_intWrapper = IntWrapper::create(23); | 567 m_intWrapper = IntWrapper::create(23); |
| 580 } | 568 } |
| 581 Member<IntWrapper> m_intWrapper; | 569 Member<IntWrapper> m_intWrapper; |
| 582 char m_data[s_length]; | 570 char m_data[s_length]; |
| 583 }; | 571 }; |
| 584 | 572 |
| 585 int LargeObject::s_destructorCalls = 0; | 573 int LargeObject::s_destructorCalls = 0; |
| 586 | 574 |
| 587 class RefCountedAndGarbageCollected : public RefCountedGarbageCollected<RefCount
edAndGarbageCollected> { | 575 class RefCountedAndGarbageCollected : public RefCountedGarbageCollected<RefCount
edAndGarbageCollected> { |
| 588 DECLARE_GC_INFO | |
| 589 public: | 576 public: |
| 590 static PassRefPtr<RefCountedAndGarbageCollected> create() | 577 static PassRefPtr<RefCountedAndGarbageCollected> create() |
| 591 { | 578 { |
| 592 return adoptRef(new RefCountedAndGarbageCollected()); | 579 return adoptRef(new RefCountedAndGarbageCollected()); |
| 593 } | 580 } |
| 594 | 581 |
| 595 ~RefCountedAndGarbageCollected() | 582 ~RefCountedAndGarbageCollected() |
| 596 { | 583 { |
| 597 ++s_destructorCalls; | 584 ++s_destructorCalls; |
| 598 } | 585 } |
| 599 | 586 |
| 600 void trace(Visitor*) { } | 587 void trace(Visitor*) { } |
| 601 | 588 |
| 602 static int s_destructorCalls; | 589 static int s_destructorCalls; |
| 603 | 590 |
| 604 private: | 591 private: |
| 605 RefCountedAndGarbageCollected() | 592 RefCountedAndGarbageCollected() |
| 606 { | 593 { |
| 607 } | 594 } |
| 608 }; | 595 }; |
| 609 | 596 |
| 610 int RefCountedAndGarbageCollected::s_destructorCalls = 0; | 597 int RefCountedAndGarbageCollected::s_destructorCalls = 0; |
| 611 | 598 |
| 612 class RefCountedAndGarbageCollected2 : public HeapTestOtherSuperClass, public Re
fCountedGarbageCollected<RefCountedAndGarbageCollected2> { | 599 class RefCountedAndGarbageCollected2 : public HeapTestOtherSuperClass, public Re
fCountedGarbageCollected<RefCountedAndGarbageCollected2> { |
| 613 DECLARE_GC_INFO | |
| 614 public: | 600 public: |
| 615 static RefCountedAndGarbageCollected2* create() | 601 static RefCountedAndGarbageCollected2* create() |
| 616 { | 602 { |
| 617 return adoptRefCountedGarbageCollected(new RefCountedAndGarbageCollected
2()); | 603 return adoptRefCountedGarbageCollected(new RefCountedAndGarbageCollected
2()); |
| 618 } | 604 } |
| 619 | 605 |
| 620 ~RefCountedAndGarbageCollected2() | 606 ~RefCountedAndGarbageCollected2() |
| 621 { | 607 { |
| 622 ++s_destructorCalls; | 608 ++s_destructorCalls; |
| 623 } | 609 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 } | 749 } |
| 764 | 750 |
| 765 Member<Bar> m_strongBar; | 751 Member<Bar> m_strongBar; |
| 766 WeakMember<Bar> m_weakBar; | 752 WeakMember<Bar> m_weakBar; |
| 767 }; | 753 }; |
| 768 | 754 |
| 769 | 755 |
| 770 class SuperClass; | 756 class SuperClass; |
| 771 | 757 |
| 772 class PointsBack : public RefCountedWillBeGarbageCollectedFinalized<PointsBack>
{ | 758 class PointsBack : public RefCountedWillBeGarbageCollectedFinalized<PointsBack>
{ |
| 773 DECLARE_GC_INFO; | |
| 774 public: | 759 public: |
| 775 static PassRefPtrWillBeRawPtr<PointsBack> create() | 760 static PassRefPtrWillBeRawPtr<PointsBack> create() |
| 776 { | 761 { |
| 777 return adoptRefWillBeNoop(new PointsBack()); | 762 return adoptRefWillBeNoop(new PointsBack()); |
| 778 } | 763 } |
| 779 | 764 |
| 780 ~PointsBack() | 765 ~PointsBack() |
| 781 { | 766 { |
| 782 --s_aliveCount; | 767 --s_aliveCount; |
| 783 } | 768 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 802 { | 787 { |
| 803 ++s_aliveCount; | 788 ++s_aliveCount; |
| 804 } | 789 } |
| 805 | 790 |
| 806 RawPtrWillBeWeakMember<SuperClass> m_backPointer; | 791 RawPtrWillBeWeakMember<SuperClass> m_backPointer; |
| 807 }; | 792 }; |
| 808 | 793 |
| 809 int PointsBack::s_aliveCount = 0; | 794 int PointsBack::s_aliveCount = 0; |
| 810 | 795 |
| 811 class SuperClass : public RefCountedWillBeGarbageCollectedFinalized<SuperClass>
{ | 796 class SuperClass : public RefCountedWillBeGarbageCollectedFinalized<SuperClass>
{ |
| 812 DECLARE_GC_INFO; | |
| 813 public: | 797 public: |
| 814 static PassRefPtrWillBeRawPtr<SuperClass> create(PassRefPtrWillBeRawPtr<Poin
tsBack> pointsBack) | 798 static PassRefPtrWillBeRawPtr<SuperClass> create(PassRefPtrWillBeRawPtr<Poin
tsBack> pointsBack) |
| 815 { | 799 { |
| 816 return adoptRefWillBeNoop(new SuperClass(pointsBack)); | 800 return adoptRefWillBeNoop(new SuperClass(pointsBack)); |
| 817 } | 801 } |
| 818 | 802 |
| 819 virtual ~SuperClass() | 803 virtual ~SuperClass() |
| 820 { | 804 { |
| 821 #if !ENABLE_OILPAN | 805 #if !ENABLE_OILPAN |
| 822 m_pointsBack->setBackPointer(0); | 806 m_pointsBack->setBackPointer(0); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 849 m_pointsBack->setBackPointer(this); | 833 m_pointsBack->setBackPointer(this); |
| 850 ++s_aliveCount; | 834 ++s_aliveCount; |
| 851 } | 835 } |
| 852 | 836 |
| 853 private: | 837 private: |
| 854 RefPtrWillBeMember<PointsBack> m_pointsBack; | 838 RefPtrWillBeMember<PointsBack> m_pointsBack; |
| 855 }; | 839 }; |
| 856 | 840 |
| 857 int SuperClass::s_aliveCount = 0; | 841 int SuperClass::s_aliveCount = 0; |
| 858 class SubData : public NoBaseWillBeGarbageCollectedFinalized<SubData> { | 842 class SubData : public NoBaseWillBeGarbageCollectedFinalized<SubData> { |
| 859 DECLARE_GC_INFO | |
| 860 public: | 843 public: |
| 861 SubData() { ++s_aliveCount; } | 844 SubData() { ++s_aliveCount; } |
| 862 ~SubData() { --s_aliveCount; } | 845 ~SubData() { --s_aliveCount; } |
| 863 | 846 |
| 864 void trace(Visitor*) { } | 847 void trace(Visitor*) { } |
| 865 | 848 |
| 866 static int s_aliveCount; | 849 static int s_aliveCount; |
| 867 }; | 850 }; |
| 868 | 851 |
| 869 int SubData::s_aliveCount = 0; | 852 int SubData::s_aliveCount = 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 897 ++s_aliveCount; | 880 ++s_aliveCount; |
| 898 } | 881 } |
| 899 | 882 |
| 900 private: | 883 private: |
| 901 OwnPtrWillBeMember<SubData> m_data; | 884 OwnPtrWillBeMember<SubData> m_data; |
| 902 }; | 885 }; |
| 903 | 886 |
| 904 int SubClass::s_aliveCount = 0; | 887 int SubClass::s_aliveCount = 0; |
| 905 | 888 |
| 906 class TransitionRefCounted : public RefCountedWillBeRefCountedGarbageCollected<T
ransitionRefCounted> { | 889 class TransitionRefCounted : public RefCountedWillBeRefCountedGarbageCollected<T
ransitionRefCounted> { |
| 907 DECLARE_GC_INFO | |
| 908 public: | 890 public: |
| 909 static PassRefPtrWillBeRawPtr<TransitionRefCounted> create() | 891 static PassRefPtrWillBeRawPtr<TransitionRefCounted> create() |
| 910 { | 892 { |
| 911 return adoptRefCountedWillBeRefCountedGarbageCollected(new TransitionRef
Counted()); | 893 return adoptRefCountedWillBeRefCountedGarbageCollected(new TransitionRef
Counted()); |
| 912 } | 894 } |
| 913 | 895 |
| 914 ~TransitionRefCounted() | 896 ~TransitionRefCounted() |
| 915 { | 897 { |
| 916 --s_aliveCount; | 898 --s_aliveCount; |
| 917 } | 899 } |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 } | 1453 } |
| 1472 HeapStats backToInitial; | 1454 HeapStats backToInitial; |
| 1473 clearOutOldGarbage(&backToInitial); | 1455 clearOutOldGarbage(&backToInitial); |
| 1474 EXPECT_TRUE(initialHeapSize == backToInitial); | 1456 EXPECT_TRUE(initialHeapSize == backToInitial); |
| 1475 EXPECT_EQ(11, IntWrapper::s_destructorCalls); | 1457 EXPECT_EQ(11, IntWrapper::s_destructorCalls); |
| 1476 EXPECT_EQ(11, LargeObject::s_destructorCalls); | 1458 EXPECT_EQ(11, LargeObject::s_destructorCalls); |
| 1477 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 1459 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 1478 } | 1460 } |
| 1479 | 1461 |
| 1480 class Container : public GarbageCollected<Container> { | 1462 class Container : public GarbageCollected<Container> { |
| 1481 DECLARE_GC_INFO | |
| 1482 public: | 1463 public: |
| 1483 static Container* create() { return new Container(); } | 1464 static Container* create() { return new Container(); } |
| 1484 HeapHashMap<Member<IntWrapper>, Member<IntWrapper> > map; | 1465 HeapHashMap<Member<IntWrapper>, Member<IntWrapper> > map; |
| 1485 HeapHashSet<Member<IntWrapper> > set; | 1466 HeapHashSet<Member<IntWrapper> > set; |
| 1486 HeapHashSet<Member<IntWrapper> > set2; | 1467 HeapHashSet<Member<IntWrapper> > set2; |
| 1487 HeapVector<Member<IntWrapper>, 2> vector; | 1468 HeapVector<Member<IntWrapper>, 2> vector; |
| 1488 void trace(Visitor* visitor) | 1469 void trace(Visitor* visitor) |
| 1489 { | 1470 { |
| 1490 visitor->trace(map); | 1471 visitor->trace(map); |
| 1491 visitor->trace(set); | 1472 visitor->trace(set); |
| 1492 visitor->trace(set2); | 1473 visitor->trace(set2); |
| 1493 visitor->trace(vector); | 1474 visitor->trace(vector); |
| 1494 } | 1475 } |
| 1495 }; | 1476 }; |
| 1496 | 1477 |
| 1497 struct ShouldBeTraced { | 1478 struct ShouldBeTraced { |
| 1498 explicit ShouldBeTraced(IntWrapper* wrapper) : m_wrapper(wrapper) { } | 1479 explicit ShouldBeTraced(IntWrapper* wrapper) : m_wrapper(wrapper) { } |
| 1499 void trace(Visitor* visitor) { visitor->trace(m_wrapper); } | 1480 void trace(Visitor* visitor) { visitor->trace(m_wrapper); } |
| 1500 Member<IntWrapper> m_wrapper; | 1481 Member<IntWrapper> m_wrapper; |
| 1501 }; | 1482 }; |
| 1502 | 1483 |
| 1503 class OffHeapContainer : public GarbageCollectedFinalized<OffHeapContainer> { | 1484 class OffHeapContainer : public GarbageCollectedFinalized<OffHeapContainer> { |
| 1504 DECLARE_GC_INFO | |
| 1505 public: | 1485 public: |
| 1506 static OffHeapContainer* create() { return new OffHeapContainer(); } | 1486 static OffHeapContainer* create() { return new OffHeapContainer(); } |
| 1507 | 1487 |
| 1508 OffHeapContainer() | 1488 OffHeapContainer() |
| 1509 { | 1489 { |
| 1510 m_deque1.append(ShouldBeTraced(IntWrapper::create(1))); | 1490 m_deque1.append(ShouldBeTraced(IntWrapper::create(1))); |
| 1511 m_vector1.append(ShouldBeTraced(IntWrapper::create(2))); | 1491 m_vector1.append(ShouldBeTraced(IntWrapper::create(2))); |
| 1512 m_deque2.append(IntWrapper::create(3)); | 1492 m_deque2.append(IntWrapper::create(3)); |
| 1513 m_vector2.append(IntWrapper::create(4)); | 1493 m_vector2.append(IntWrapper::create(4)); |
| 1514 m_hashSet.add(IntWrapper::create(5)); | 1494 m_hashSet.add(IntWrapper::create(5)); |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2282 | 2262 |
| 2283 it->value.append(IntWrapper::create(42)); | 2263 it->value.append(IntWrapper::create(42)); |
| 2284 EXPECT_EQ(1u, map->get(key).size()); | 2264 EXPECT_EQ(1u, map->get(key).size()); |
| 2285 | 2265 |
| 2286 Persistent<HeapHashMap<void*, IntVector> > keepAlive(map); | 2266 Persistent<HeapHashMap<void*, IntVector> > keepAlive(map); |
| 2287 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 2267 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 2288 EXPECT_EQ(1u, map->get(key).size()); | 2268 EXPECT_EQ(1u, map->get(key).size()); |
| 2289 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 2269 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
| 2290 } | 2270 } |
| 2291 | 2271 |
| 2292 DEFINE_GC_INFO(Bar); | |
| 2293 DEFINE_GC_INFO(Baz); | |
| 2294 DEFINE_GC_INFO(ClassWithMember); | |
| 2295 DEFINE_GC_INFO(ConstructorAllocation); | |
| 2296 DEFINE_GC_INFO(Container); | |
| 2297 DEFINE_GC_INFO(HeapAllocatedArray); | |
| 2298 DEFINE_GC_INFO(HeapTestSuperClass); | |
| 2299 DEFINE_GC_INFO(IntWrapper); | |
| 2300 DEFINE_GC_INFO(LargeObject); | |
| 2301 DEFINE_GC_INFO(OffHeapContainer); | |
| 2302 DEFINE_GC_INFO(PointsBack); | |
| 2303 DEFINE_GC_INFO(RefCountedAndGarbageCollected); | |
| 2304 DEFINE_GC_INFO(RefCountedAndGarbageCollected2); | |
| 2305 DEFINE_GC_INFO(SimpleFinalizedObject); | |
| 2306 DEFINE_GC_INFO(SimpleObject); | |
| 2307 DEFINE_GC_INFO(SuperClass); | |
| 2308 DEFINE_GC_INFO(SubData); | |
| 2309 DEFINE_GC_INFO(TestTypedHeapClass); | |
| 2310 DEFINE_GC_INFO(TraceCounter); | |
| 2311 DEFINE_GC_INFO(TransitionRefCounted); | |
| 2312 | |
| 2313 } // namespace | 2272 } // namespace |
| OLD | NEW |