Chromium Code Reviews| 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 5329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5340 Persistent<DeepEagerly> persistent(obj); | 5340 Persistent<DeepEagerly> persistent(obj); |
| 5341 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 5341 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 5342 | 5342 |
| 5343 // Verify that the DeepEagerly chain isn't completely unravelled | 5343 // Verify that the DeepEagerly chain isn't completely unravelled |
| 5344 // by performing eager trace() calls, but the explicit mark | 5344 // by performing eager trace() calls, but the explicit mark |
| 5345 // stack is switched once some nesting limit is exceeded. | 5345 // stack is switched once some nesting limit is exceeded. |
| 5346 EXPECT_GT(DeepEagerly::sTraceLazy, 2); | 5346 EXPECT_GT(DeepEagerly::sTraceLazy, 2); |
| 5347 #endif | 5347 #endif |
| 5348 } | 5348 } |
| 5349 | 5349 |
| 5350 TEST(HeapTest, DequeExpand) | |
| 5351 { | |
| 5352 // Test expansion of a HeapDeque<>'s buffer. | |
| 5353 | |
| 5354 typedef HeapDeque<Member<IntWrapper>> IntDeque; | |
| 5355 | |
| 5356 Persistent<IntDeque> deque = new IntDeque(); | |
| 5357 | |
| 5358 // Append a sequence, bringing about expansion of the | |
|
Nico
2014/12/31 01:21:38
of the…?
| |
| 5359 int i = 0; | |
| 5360 for (; i < 60; ++i) | |
| 5361 deque->append(IntWrapper::create(i)); | |
| 5362 | |
| 5363 EXPECT_EQ(60u, deque->size()); | |
| 5364 i = 0; | |
| 5365 for (const auto& intWrapper : *deque) { | |
| 5366 EXPECT_EQ(i, intWrapper->value()); | |
| 5367 i++; | |
| 5368 } | |
| 5369 | |
| 5370 // Remove most of the queued objects.. | |
| 5371 for (i = 0; i < 50; ++i) | |
| 5372 deque->takeFirst(); | |
| 5373 | |
| 5374 EXPECT_EQ(10u, deque->size()); | |
| 5375 i = 0; | |
| 5376 for (const auto& intWrapper : *deque) { | |
| 5377 EXPECT_EQ(50 + i, intWrapper->value()); | |
| 5378 i++; | |
| 5379 } | |
| 5380 | |
| 5381 // Append even more, eventually causing an expansion of the | |
| 5382 // underlying buffer. | |
| 5383 for (i = 0; i < 70; ++i) | |
| 5384 deque->append(IntWrapper::create(60 + i)); | |
| 5385 | |
| 5386 EXPECT_EQ(80u, deque->size()); | |
| 5387 i = 0; | |
| 5388 for (const auto& intWrapper : *deque) { | |
| 5389 EXPECT_EQ(i + 50, intWrapper->value()); | |
| 5390 i++; | |
| 5391 } | |
| 5392 } | |
| 5393 | |
| 5350 } // namespace blink | 5394 } // namespace blink |
| OLD | NEW |