| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 { | 51 { |
| 52 return new IntWrapper(x); | 52 return new IntWrapper(x); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual ~IntWrapper() | 55 virtual ~IntWrapper() |
| 56 { | 56 { |
| 57 ++s_destructorCalls; | 57 ++s_destructorCalls; |
| 58 } | 58 } |
| 59 | 59 |
| 60 static int s_destructorCalls; | 60 static int s_destructorCalls; |
| 61 void trace(Visitor*) { } | 61 static void trace(Visitor*) { } |
| 62 | 62 |
| 63 int value() const { return m_x; } | 63 int value() const { return m_x; } |
| 64 | 64 |
| 65 bool operator==(const IntWrapper& other) const { return other.value() == val
ue(); } | 65 bool operator==(const IntWrapper& other) const { return other.value() == val
ue(); } |
| 66 | 66 |
| 67 unsigned hash() { return IntHash<int>::hash(m_x); } | 67 unsigned hash() { return IntHash<int>::hash(m_x); } |
| 68 | 68 |
| 69 IntWrapper(int x) : m_x(x) { } | 69 IntWrapper(int x) : m_x(x) { } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 IntWrapper(); | 72 IntWrapper(); |
| 73 int m_x; | 73 int m_x; |
| 74 }; | 74 }; |
| 75 static_assert(WTF::NeedsTracing<IntWrapper>::value, "NeedsTracing macro failed t
o recognize trace method."); | |
| 76 | 75 |
| 77 class ThreadMarker { | 76 class ThreadMarker { |
| 78 public: | 77 public: |
| 79 ThreadMarker() : m_creatingThread(reinterpret_cast<ThreadState*>(0)), m_num(
0) { } | 78 ThreadMarker() : m_creatingThread(reinterpret_cast<ThreadState*>(0)), m_num(
0) { } |
| 80 ThreadMarker(unsigned i) : m_creatingThread(ThreadState::current()), m_num(i
) { } | 79 ThreadMarker(unsigned i) : m_creatingThread(ThreadState::current()), m_num(i
) { } |
| 81 ThreadMarker(WTF::HashTableDeletedValueType deleted) : m_creatingThread(rein
terpret_cast<ThreadState*>(-1)), m_num(0) { } | 80 ThreadMarker(WTF::HashTableDeletedValueType deleted) : m_creatingThread(rein
terpret_cast<ThreadState*>(-1)), m_num(0) { } |
| 82 ~ThreadMarker() | 81 ~ThreadMarker() |
| 83 { | 82 { |
| 84 EXPECT_TRUE((m_creatingThread == ThreadState::current()) | 83 EXPECT_TRUE((m_creatingThread == ThreadState::current()) |
| 85 || (m_creatingThread == reinterpret_cast<ThreadState*>(0)) | 84 || (m_creatingThread == reinterpret_cast<ThreadState*>(0)) |
| (...skipping 3457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3543 | 3542 |
| 3544 TEST(HeapTest, CollectionNesting) | 3543 TEST(HeapTest, CollectionNesting) |
| 3545 { | 3544 { |
| 3546 clearOutOldGarbage(); | 3545 clearOutOldGarbage(); |
| 3547 int* key = &IntWrapper::s_destructorCalls; | 3546 int* key = &IntWrapper::s_destructorCalls; |
| 3548 IntWrapper::s_destructorCalls = 0; | 3547 IntWrapper::s_destructorCalls = 0; |
| 3549 typedef HeapVector<Member<IntWrapper> > IntVector; | 3548 typedef HeapVector<Member<IntWrapper> > IntVector; |
| 3550 typedef HeapDeque<Member<IntWrapper> > IntDeque; | 3549 typedef HeapDeque<Member<IntWrapper> > IntDeque; |
| 3551 HeapHashMap<void*, IntVector>* map = new HeapHashMap<void*, IntVector>(); | 3550 HeapHashMap<void*, IntVector>* map = new HeapHashMap<void*, IntVector>(); |
| 3552 HeapHashMap<void*, IntDeque>* map2 = new HeapHashMap<void*, IntDeque>(); | 3551 HeapHashMap<void*, IntDeque>* map2 = new HeapHashMap<void*, IntDeque>(); |
| 3553 static_assert(WTF::NeedsTracing<IntVector>::value, "Failed to recognize Heap
Vector as NeedsTracing"); | |
| 3554 static_assert(WTF::NeedsTracing<IntDeque>::value, "Failed to recognize HeapD
eque as NeedsTracing"); | |
| 3555 | 3552 |
| 3556 map->add(key, IntVector()); | 3553 map->add(key, IntVector()); |
| 3557 map2->add(key, IntDeque()); | 3554 map2->add(key, IntDeque()); |
| 3558 | 3555 |
| 3559 HeapHashMap<void*, IntVector>::iterator it = map->find(key); | 3556 HeapHashMap<void*, IntVector>::iterator it = map->find(key); |
| 3560 EXPECT_EQ(0u, map->get(key).size()); | 3557 EXPECT_EQ(0u, map->get(key).size()); |
| 3561 | 3558 |
| 3562 HeapHashMap<void*, IntDeque>::iterator it2 = map2->find(key); | 3559 HeapHashMap<void*, IntDeque>::iterator it2 = map2->find(key); |
| 3563 EXPECT_EQ(0u, map2->get(key).size()); | 3560 EXPECT_EQ(0u, map2->get(key).size()); |
| 3564 | 3561 |
| (...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5344 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 5341 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 5345 | 5342 |
| 5346 // Verify that the DeepEagerly chain isn't completely unravelled | 5343 // Verify that the DeepEagerly chain isn't completely unravelled |
| 5347 // by performing eager trace() calls, but the explicit mark | 5344 // by performing eager trace() calls, but the explicit mark |
| 5348 // stack is switched once some nesting limit is exceeded. | 5345 // stack is switched once some nesting limit is exceeded. |
| 5349 EXPECT_GT(DeepEagerly::sTraceLazy, 2); | 5346 EXPECT_GT(DeepEagerly::sTraceLazy, 2); |
| 5350 #endif | 5347 #endif |
| 5351 } | 5348 } |
| 5352 | 5349 |
| 5353 } // namespace blink | 5350 } // namespace blink |
| OLD | NEW |