diff options
author | Jason Evans <je@fb.com> | 2014-02-26 00:11:15 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2014-02-26 00:11:15 (GMT) |
commit | b037a55f365471002bac024ffa1a8392ddcd578f (patch) | |
tree | 9da499fce86bf9873b9e9207dea7354af34d7f15 | |
parent | 940fdfd5eef45f5425f9124e250fddde5c5c48bf (diff) | |
download | jemalloc-b037a55f365471002bac024ffa1a8392ddcd578f.zip jemalloc-b037a55f365471002bac024ffa1a8392ddcd578f.tar.gz jemalloc-b037a55f365471002bac024ffa1a8392ddcd578f.tar.bz2 |
Restore tail call optimization subversion.
Restore the essence of 898960247a8b2e6534738b7a3a244855f379faf9, which
sabotages tail call optimization. This is necessary even when the
mutually recursive functions are in separate compilation units.
-rw-r--r-- | test/unit/prof_accum.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/unit/prof_accum.h b/test/unit/prof_accum.h index de9cfea..109d86b 100644 --- a/test/unit/prof_accum.h +++ b/test/unit/prof_accum.h @@ -14,16 +14,22 @@ alloc_n_proto(1) void * \ alloc_##n(unsigned bits) \ { \ + void *p; \ \ - if (bits == 0) { \ - void *p = mallocx(1, 0); \ - assert_ptr_not_null(p, "Unexpected mallocx() failure"); \ - return (p); \ - } else { \ + if (bits == 0) \ + p = mallocx(1, 0); \ + else { \ switch (bits & 0x1U) { \ - case 0: return (alloc_0(bits >> 1)); \ - case 1: return (alloc_1(bits >> 1)); \ + case 0: \ + p = (alloc_0(bits >> 1)); \ + break; \ + case 1: \ + p = (alloc_1(bits >> 1)); \ + break; \ default: not_reached(); \ } \ } \ + /* Intentionally sabotage tail call optimization. */ \ + assert_ptr_not_null(p, "Unexpected mallocx() failure"); \ + return (p); \ } |