diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-08-17 17:27:31 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-08-17 17:27:31 -0700 |
| commit | df51fe36f190ab8831549d7f8854372fa142f8b3 (patch) | |
| tree | 0697495ad032611a3824bb3050208f8397be4ebe /src/rt/rust_obstack.cpp | |
| parent | 49397b5af6cf72487c404b6be27394720cc46cce (diff) | |
| download | rust-df51fe36f190ab8831549d7f8854372fa142f8b3.tar.gz rust-df51fe36f190ab8831549d7f8854372fa142f8b3.zip | |
Revert "rt: Use obstacks in lieu of dynamically-sized frames"
This reverts commit cc5fcfce89312042e52401eb883160ebf289235f.
Diffstat (limited to 'src/rt/rust_obstack.cpp')
| -rw-r--r-- | src/rt/rust_obstack.cpp | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/rt/rust_obstack.cpp b/src/rt/rust_obstack.cpp index f76a80aada9..5ec996f4e32 100644 --- a/src/rt/rust_obstack.cpp +++ b/src/rt/rust_obstack.cpp @@ -14,12 +14,7 @@ #undef max #endif -//#define DPRINT(fmt,...) fprintf(stderr, fmt, ##__VA_ARGS__) -#define DPRINT(fmt,...) - -//const size_t DEFAULT_CHUNK_SIZE = 4096; -const size_t DEFAULT_CHUNK_SIZE = 300000; -const size_t DEFAULT_ALIGNMENT = 16; +const size_t DEFAULT_CHUNK_SIZE = 4096; struct rust_obstack_chunk { rust_obstack_chunk *prev; @@ -37,13 +32,8 @@ struct rust_obstack_chunk { void * rust_obstack_chunk::alloc(size_t len) { - alen = align_to(alen, DEFAULT_ALIGNMENT); - - if (len > size - alen) { - DPRINT("Not enough space, len=%lu!\n", len); - assert(0); + if (len > size - alen) return NULL; // Not enough space. - } void *result = data + alen; alen += len; return result; @@ -52,7 +42,7 @@ rust_obstack_chunk::alloc(size_t len) { bool rust_obstack_chunk::free(void *ptr) { uint8_t *p = (uint8_t *)ptr; - if (p < data || p > data + size) + if (p < data || p >= data + size) return false; assert(p <= data + alen); alen = (size_t)(p - data); @@ -64,7 +54,6 @@ void * rust_obstack::alloc_new(size_t len) { size_t chunk_size = std::max(len, DEFAULT_CHUNK_SIZE); void *ptr = task->malloc(sizeof(chunk) + chunk_size, "obstack"); - DPRINT("making new chunk at %p, len %lu\n", ptr, chunk_size); chunk = new(ptr) rust_obstack_chunk(chunk, chunk_size); return chunk->alloc(len); } @@ -81,12 +70,8 @@ void * rust_obstack::alloc(size_t len) { if (!chunk) return alloc_new(len); - - DPRINT("alloc sz %u", (uint32_t)len); - void *ptr = chunk->alloc(len); ptr = ptr ? ptr : alloc_new(len); - return ptr; } @@ -95,11 +80,8 @@ rust_obstack::free(void *ptr) { if (!ptr) return; - DPRINT("free ptr %p\n", ptr); - assert(chunk); while (!chunk->free(ptr)) { - DPRINT("deleting chunk at %p\n", chunk); rust_obstack_chunk *prev = chunk->prev; task->free(chunk); chunk = prev; |
