rustc: Use obstacks in lieu of dynamically-allocated frames only when the frame is actually dynamically-sized

This commit is contained in:
Patrick Walton
2011-08-17 18:14:47 -07:00
parent 0b7af40384
commit f17edf9829
6 changed files with 57 additions and 24 deletions

View File

@@ -125,6 +125,16 @@ next_power_of_two(size_t s)
return tmp + 1;
}
// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power
// of two.
template<typename T>
static inline T
align_to(T size, size_t alignment) {
assert(alignment);
T x = (T)(((uintptr_t)size + alignment - 1) & ~(alignment - 1));
return x;
}
// Initialization helper for ISAAC RNG
template <typename sched_or_kernel>