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 5520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5531 // of the old buffer to both ends of the expanded buffer, along with | 5531 // of the old buffer to both ends of the expanded buffer, along with |
5532 // re-adjusting both start&end indices in terms of that expanded buffer. | 5532 // re-adjusting both start&end indices in terms of that expanded buffer. |
5533 EXPECT_EQ(80u, deque->size()); | 5533 EXPECT_EQ(80u, deque->size()); |
5534 i = 0; | 5534 i = 0; |
5535 for (const auto& intWrapper : *deque) { | 5535 for (const auto& intWrapper : *deque) { |
5536 EXPECT_EQ(i + 50, intWrapper->value()); | 5536 EXPECT_EQ(i + 50, intWrapper->value()); |
5537 i++; | 5537 i++; |
5538 } | 5538 } |
5539 } | 5539 } |
5540 | 5540 |
| 5541 namespace { |
| 5542 |
| 5543 enum GrowthDirection { |
| 5544 GrowsTowardsHigher, |
| 5545 GrowsTowardsLower, |
| 5546 }; |
| 5547 |
| 5548 NEVER_INLINE NO_SANITIZE_ADDRESS GrowthDirection stackGrowthDirection() |
| 5549 { |
| 5550 // Disable ASan, otherwise its stack checking (use-after-return) will |
| 5551 // confuse the direction check. |
| 5552 static char* previous = nullptr; |
| 5553 char dummy; |
| 5554 if (!previous) { |
| 5555 previous = &dummy; |
| 5556 GrowthDirection result = stackGrowthDirection(); |
| 5557 previous = nullptr; |
| 5558 return result; |
| 5559 } |
| 5560 ASSERT(&dummy != previous); |
| 5561 return &dummy < previous ? GrowsTowardsLower : GrowsTowardsHigher; |
| 5562 } |
| 5563 |
| 5564 } // namespace |
| 5565 |
| 5566 TEST(HeapTest, StackGrowthDirection) |
| 5567 { |
| 5568 // The implementation of marking probes stack usage as it runs, |
| 5569 // and has a builtin assumption that the stack grows towards |
| 5570 // lower addresses. |
| 5571 EXPECT_EQ(GrowsTowardsLower, stackGrowthDirection()); |
| 5572 } |
| 5573 |
5541 } // namespace blink | 5574 } // namespace blink |
OLD | NEW |