Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Unified Diff: Source/platform/heap/HeapTest.cpp

Issue 876603002: Add stack direction heap unit test. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/platform/heap/StackFrameDepth.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/HeapTest.cpp
diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp
index c87ee5076130bf93063de4c2a61d4c9e1f183b02..4826c00b3d577bc7caadac5c9d164754a937087e 100644
--- a/Source/platform/heap/HeapTest.cpp
+++ b/Source/platform/heap/HeapTest.cpp
@@ -5538,4 +5538,37 @@ TEST(HeapTest, DequeExpand)
}
}
+namespace {
+
+enum GrowthDirection {
+ GrowsTowardsHigher,
+ GrowsTowardsLower,
+};
+
+NEVER_INLINE NO_SANITIZE_ADDRESS GrowthDirection stackGrowthDirection()
+{
+ // Disable ASan, otherwise its stack checking (use-after-return) will
+ // confuse the direction check.
+ static char* previous = nullptr;
+ char dummy;
+ if (!previous) {
+ previous = &dummy;
+ GrowthDirection result = stackGrowthDirection();
+ previous = nullptr;
+ return result;
+ }
+ ASSERT(&dummy != previous);
+ return &dummy < previous ? GrowsTowardsLower : GrowsTowardsHigher;
+}
+
+} // namespace
+
+TEST(HeapTest, StackGrowthDirection)
+{
+ // The implementation of marking probes stack usage as it runs,
+ // and has a builtin assumption that the stack grows towards
+ // lower addresses.
+ EXPECT_EQ(GrowsTowardsLower, stackGrowthDirection());
+}
+
} // namespace blink
« no previous file with comments | « no previous file | Source/platform/heap/StackFrameDepth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698