MCPcopy Create free account
hub / github.com/beefytech/Beef / AlignmentForSize

Function AlignmentForSize

BeefRT/gperftools/src/tc_common.cc:75–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75int AlignmentForSize(size_t size) {
76 int alignment = kAlignment;
77 if (size > kMaxSize) {
78 // Cap alignment at kPageSize for large sizes.
79 alignment = kPageSize;
80 } else if (size >= 128) {
81 // Space wasted due to alignment is at most 1/8, i.e., 12.5%.
82 alignment = (1 << LgFloor(size)) / 8;
83 } else if (size >= kMinAlign) {
84 // We need an alignment of at least 16 bytes to satisfy
85 // requirements for some SSE types.
86 alignment = kMinAlign;
87 }
88 // Maximum alignment allowed is page size alignment.
89 if (alignment > kPageSize) {
90 alignment = kPageSize;
91 }
92 CHECK_CONDITION(size < kMinAlign || alignment >= kMinAlign);
93 CHECK_CONDITION((alignment & (alignment - 1)) == 0);
94 return alignment;
95}
96
97int SizeMap::NumMoveSize(size_t size) {
98 if (size == 0) return 0;

Callers 2

do_memalignFunction · 0.70
InitMethod · 0.70

Calls 1

LgFloorFunction · 0.70

Tested by

no test coverage detected