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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 | 1248 |
1249 void setBackPointer(SuperClass* backPointer) | 1249 void setBackPointer(SuperClass* backPointer) |
1250 { | 1250 { |
1251 m_backPointer = backPointer; | 1251 m_backPointer = backPointer; |
1252 } | 1252 } |
1253 | 1253 |
1254 SuperClass* backPointer() const { return m_backPointer; } | 1254 SuperClass* backPointer() const { return m_backPointer; } |
1255 | 1255 |
1256 DEFINE_INLINE_TRACE() | 1256 DEFINE_INLINE_TRACE() |
1257 { | 1257 { |
1258 #if ENABLE_OILPAN | |
1259 visitor->trace(m_backPointer); | 1258 visitor->trace(m_backPointer); |
1260 #endif | |
1261 } | 1259 } |
1262 | 1260 |
1263 static int s_aliveCount; | 1261 static int s_aliveCount; |
1264 private: | 1262 private: |
1265 PointsBack() : m_backPointer(nullptr) | 1263 PointsBack() : m_backPointer(nullptr) |
1266 { | 1264 { |
1267 ++s_aliveCount; | 1265 ++s_aliveCount; |
1268 } | 1266 } |
1269 | 1267 |
1270 RawPtrWillBeWeakMember<SuperClass> m_backPointer; | 1268 RawPtrWillBeWeakMember<SuperClass> m_backPointer; |
1271 }; | 1269 }; |
1272 | 1270 |
1273 int PointsBack::s_aliveCount = 0; | 1271 int PointsBack::s_aliveCount = 0; |
1274 | 1272 |
1275 class SuperClass : public RefCountedWillBeGarbageCollectedFinalized<SuperClass>
{ | 1273 class SuperClass : public RefCountedWillBeGarbageCollectedFinalized<SuperClass>
{ |
1276 public: | 1274 public: |
1277 static PassRefPtrWillBeRawPtr<SuperClass> create(PassRefPtrWillBeRawPtr<Poin
tsBack> pointsBack) | 1275 static PassRefPtrWillBeRawPtr<SuperClass> create(PassRefPtrWillBeRawPtr<Poin
tsBack> pointsBack) |
1278 { | 1276 { |
1279 return adoptRefWillBeNoop(new SuperClass(pointsBack)); | 1277 return adoptRefWillBeNoop(new SuperClass(pointsBack)); |
1280 } | 1278 } |
1281 | 1279 |
1282 virtual ~SuperClass() | 1280 virtual ~SuperClass() |
1283 { | 1281 { |
1284 #if !ENABLE_OILPAN | 1282 #if !ENABLE(OILPAN) |
1285 m_pointsBack->setBackPointer(0); | 1283 m_pointsBack->setBackPointer(0); |
1286 #endif | 1284 #endif |
1287 --s_aliveCount; | 1285 --s_aliveCount; |
1288 } | 1286 } |
1289 | 1287 |
1290 void doStuff(PassRefPtrWillBeRawPtr<SuperClass> targetPass, PointsBack* poin
tsBack, int superClassCount) | 1288 void doStuff(PassRefPtrWillBeRawPtr<SuperClass> targetPass, PointsBack* poin
tsBack, int superClassCount) |
1291 { | 1289 { |
1292 RefPtrWillBeRawPtr<SuperClass> target = targetPass; | 1290 RefPtrWillBeRawPtr<SuperClass> target = targetPass; |
1293 Heap::collectGarbage(ThreadState::HeapPointersOnStack); | 1291 Heap::collectGarbage(ThreadState::HeapPointersOnStack); |
1294 EXPECT_EQ(pointsBack, target->pointsBack()); | 1292 EXPECT_EQ(pointsBack, target->pointsBack()); |
1295 EXPECT_EQ(superClassCount, SuperClass::s_aliveCount); | 1293 EXPECT_EQ(superClassCount, SuperClass::s_aliveCount); |
1296 } | 1294 } |
1297 | 1295 |
1298 DEFINE_INLINE_VIRTUAL_TRACE() | 1296 DEFINE_INLINE_VIRTUAL_TRACE() |
1299 { | 1297 { |
1300 #if ENABLE_OILPAN | |
1301 visitor->trace(m_pointsBack); | 1298 visitor->trace(m_pointsBack); |
1302 #endif | |
1303 } | 1299 } |
1304 | 1300 |
1305 PointsBack* pointsBack() const { return m_pointsBack.get(); } | 1301 PointsBack* pointsBack() const { return m_pointsBack.get(); } |
1306 | 1302 |
1307 static int s_aliveCount; | 1303 static int s_aliveCount; |
1308 protected: | 1304 protected: |
1309 explicit SuperClass(PassRefPtrWillBeRawPtr<PointsBack> pointsBack) | 1305 explicit SuperClass(PassRefPtrWillBeRawPtr<PointsBack> pointsBack) |
1310 : m_pointsBack(pointsBack) | 1306 : m_pointsBack(pointsBack) |
1311 { | 1307 { |
1312 m_pointsBack->setBackPointer(this); | 1308 m_pointsBack->setBackPointer(this); |
(...skipping 24 matching lines...) Expand all Loading... |
1337 return adoptRefWillBeNoop(new SubClass(pointsBack)); | 1333 return adoptRefWillBeNoop(new SubClass(pointsBack)); |
1338 } | 1334 } |
1339 | 1335 |
1340 virtual ~SubClass() | 1336 virtual ~SubClass() |
1341 { | 1337 { |
1342 --s_aliveCount; | 1338 --s_aliveCount; |
1343 } | 1339 } |
1344 | 1340 |
1345 DEFINE_INLINE_VIRTUAL_TRACE() | 1341 DEFINE_INLINE_VIRTUAL_TRACE() |
1346 { | 1342 { |
1347 #if ENABLE_OILPAN | 1343 visitor->trace(m_data); |
1348 SuperClass::trace(visitor); | 1344 SuperClass::trace(visitor); |
1349 visitor->trace(m_data); | |
1350 #endif | |
1351 } | 1345 } |
1352 | 1346 |
1353 static int s_aliveCount; | 1347 static int s_aliveCount; |
1354 private: | 1348 private: |
1355 explicit SubClass(PassRefPtrWillBeRawPtr<PointsBack> pointsBack) | 1349 explicit SubClass(PassRefPtrWillBeRawPtr<PointsBack> pointsBack) |
1356 : SuperClass(pointsBack) | 1350 : SuperClass(pointsBack) |
1357 , m_data(adoptPtrWillBeNoop(new SubData())) | 1351 , m_data(adoptPtrWillBeNoop(new SubData())) |
1358 { | 1352 { |
1359 ++s_aliveCount; | 1353 ++s_aliveCount; |
1360 } | 1354 } |
(...skipping 4205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5566 | 5560 |
5567 TEST(HeapTest, StackGrowthDirection) | 5561 TEST(HeapTest, StackGrowthDirection) |
5568 { | 5562 { |
5569 // The implementation of marking probes stack usage as it runs, | 5563 // The implementation of marking probes stack usage as it runs, |
5570 // and has a builtin assumption that the stack grows towards | 5564 // and has a builtin assumption that the stack grows towards |
5571 // lower addresses. | 5565 // lower addresses. |
5572 EXPECT_EQ(GrowsTowardsLower, stackGrowthDirection()); | 5566 EXPECT_EQ(GrowsTowardsLower, stackGrowthDirection()); |
5573 } | 5567 } |
5574 | 5568 |
5575 } // namespace blink | 5569 } // namespace blink |
OLD | NEW |