Diff
Modified: trunk/Source/WebCore/ChangeLog (115388 => 115389)
--- trunk/Source/WebCore/ChangeLog 2012-04-27 00:07:11 UTC (rev 115388)
+++ trunk/Source/WebCore/ChangeLog 2012-04-27 00:48:39 UTC (rev 115389)
@@ -1,3 +1,27 @@
+2012-04-26 Ojan Vafai <[email protected]>
+
+ Delete dead code in Arena.h/cpp
+ https://bugs.webkit.org/show_bug.cgi?id=84997
+
+ Reviewed by Eric Seidel.
+
+ Also cleaned up some style issues. Renamed some single-letter variable names.
+ Avoided anything other than totally trivial style changes to be 100% sure
+ that there is no change in behavior.
+
+ No new tests. There's no non-style code changes except inlining CLEAR_UNUSED
+ and CLEAR_ARENA.
+
+ * platform/Arena.cpp:
+ (WebCore):
+ (WebCore::CeilingLog2):
+ (WebCore::InitArenaPool):
+ (WebCore::ArenaAllocate):
+ (WebCore::FreeArenaList):
+ (WebCore::FinishArenaPool):
+ * platform/Arena.h:
+ (WebCore):
+
2012-04-26 Shawn Singh <[email protected]>
Re-implement backFaceVisibility to avoid dealing with perspective w < 0 problem
Modified: trunk/Source/WebCore/platform/Arena.cpp (115388 => 115389)
--- trunk/Source/WebCore/platform/Arena.cpp 2012-04-27 00:07:11 UTC (rev 115388)
+++ trunk/Source/WebCore/platform/Arena.cpp 2012-04-27 00:48:39 UTC (rev 115389)
@@ -56,37 +56,33 @@
namespace WebCore {
-//#define DEBUG_ARENA_MALLOC
#ifdef DEBUG_ARENA_MALLOC
static int i = 0;
#endif
-#define FREELIST_MAX 30
-static Arena *arena_freelist;
-static int freelist_count = 0;
+#define ARENA_DEFAULT_ALIGN sizeof(double)
+#define BIT(n) ((unsigned int)1 << (n))
+#define BITMASK(n) (BIT(n) - 1)
+#define CEILING_LOG2(_log2, _n) \
+ unsigned int j_ = (unsigned int)(_n); \
+ (_log2) = 0; \
+ if ((j_) & ((j_)-1)) \
+ (_log2) += 1; \
+ if ((j_) >> 16) \
+ (_log2) += 16, (j_) >>= 16; \
+ if ((j_) >> 8) \
+ (_log2) += 8, (j_) >>= 8; \
+ if ((j_) >> 4) \
+ (_log2) += 4, (j_) >>= 4; \
+ if ((j_) >> 2) \
+ (_log2) += 2, (j_) >>= 2; \
+ if ((j_) >> 1) \
+ (_log2) += 1;
+#define FREE_PATTERN 0xDA
-#define ARENA_DEFAULT_ALIGN sizeof(double)
-#define BIT(n) ((unsigned int)1 << (n))
-#define BITMASK(n) (BIT(n) - 1)
-#define CEILING_LOG2(_log2,_n) \
- unsigned int j_ = (unsigned int)(_n); \
- (_log2) = 0; \
- if ((j_) & ((j_)-1)) \
- (_log2) += 1; \
- if ((j_) >> 16) \
- (_log2) += 16, (j_) >>= 16; \
- if ((j_) >> 8) \
- (_log2) += 8, (j_) >>= 8; \
- if ((j_) >> 4) \
- (_log2) += 4, (j_) >>= 4; \
- if ((j_) >> 2) \
- (_log2) += 2, (j_) >>= 2; \
- if ((j_) >> 1) \
- (_log2) += 1;
-
static int CeilingLog2(unsigned int i) {
int log2;
- CEILING_LOG2(log2,i);
+ CEILING_LOG2(log2, i);
return log2;
}
@@ -96,163 +92,98 @@
align = ARENA_DEFAULT_ALIGN;
pool->mask = BITMASK(CeilingLog2(align));
pool->first.next = NULL;
- pool->first.base = pool->first.avail = pool->first.limit =
- (uword)ARENA_ALIGN(&pool->first + 1);
+ pool->first.base = pool->first.avail = pool->first.limit = (uword)ARENA_ALIGN(&pool->first + 1);
pool->current = &pool->first;
pool->arenasize = size;
}
-
-/*
- ** ArenaAllocate() -- allocate space from an arena pool
- **
- ** Description: ArenaAllocate() allocates space from an arena
- ** pool.
- **
- ** First try to satisfy the request from arenas starting at
- ** pool->current.
- **
- ** If there is not enough space in the arena pool->current, try
- ** to claim an arena, on a first fit basis, from the global
- ** freelist (arena_freelist).
- **
- ** If no arena in arena_freelist is suitable, then try to
- ** allocate a new arena from the heap.
- **
- ** Returns: pointer to allocated space or NULL
- **
- */
-void* ArenaAllocate(ArenaPool *pool, unsigned int nb)
+void* ArenaAllocate(ArenaPool* pool, unsigned int numBytes)
{
- Arena *a;
- char *rp; /* returned pointer */
+ Arena* arena;
+ char* returnPointer;
- ASSERT((nb & pool->mask) == 0);
+ ASSERT((numBytes & pool->mask) == 0);
- nb = (uword)ARENA_ALIGN(nb); /* force alignment */
+ numBytes = (uword)ARENA_ALIGN(numBytes);
- /* attempt to allocate from arenas at pool->current */
+ // attempt to allocate from arenas at pool->current
{
- a = pool->current;
+ arena = pool->current;
do {
- if ( a->avail +nb <= a->limit ) {
- pool->current = a;
- rp = (char *)a->avail;
- a->avail += nb;
- return rp;
+ if (arena->avail + numBytes <= arena->limit) {
+ pool->current = arena;
+ returnPointer = (char *)arena->avail;
+ arena->avail += numBytes;
+ return returnPointer;
}
- } while( NULL != (a = a->next) );
+ } while (NULL != (arena = arena->next));
}
- /* attempt to allocate from arena_freelist */
- {
- Arena *p = NULL; /* previous pointer, for unlinking from freelist */
-
- for ( a = arena_freelist; a != NULL ; p = a, a = a->next ) {
- if ( a->base +nb <= a->limit ) {
- if ( p == NULL )
- arena_freelist = a->next;
- else
- p->next = a->next;
- a->avail = a->base;
- rp = (char *)a->avail;
- a->avail += nb;
- /* the newly allocated arena is linked after pool->current
- * and becomes pool->current */
- a->next = pool->current->next;
- pool->current->next = a;
- pool->current = a;
- if ( 0 == pool->first.next )
- pool->first.next = a;
- freelist_count--;
- return(rp);
- }
- }
- }
-
- /* attempt to allocate from the heap */
+ // attempt to allocate from the heap
{
- unsigned int sz = max(pool->arenasize, nb);
- sz += sizeof *a + pool->mask; /* header and alignment slop */
+ unsigned int size = max(pool->arenasize, numBytes);
+ size += sizeof *arena + pool->mask; /* header and alignment slop */
#ifdef DEBUG_ARENA_MALLOC
i++;
printf("Malloc: %d\n", i);
#endif
- a = (Arena*)fastMalloc(sz);
+ arena = (Arena*)fastMalloc(size);
// fastMalloc will abort() if it fails, so we are guaranteed that a is not 0.
- a->limit = (uword)a + sz;
- a->base = a->avail = (uword)ARENA_ALIGN(a + 1);
- rp = (char *)a->avail;
- a->avail += nb;
- /* the newly allocated arena is linked after pool->current
- * and becomes pool->current */
- a->next = pool->current->next;
- pool->current->next = a;
- pool->current = a;
- if ( !pool->first.next )
- pool->first.next = a;
- return(rp);
+ arena->limit = (uword)arena + size;
+ arena->base = arena->avail = (uword)ARENA_ALIGN(arena + 1);
+ returnPointer = (char *)arena->avail;
+ arena->avail += numBytes;
+ // the newly allocated arena is linked after pool->current and becomes pool->current.
+ arena->next = pool->current->next;
+ pool->current->next = arena;
+ pool->current = arena;
+ if (!pool->first.next)
+ pool->first.next = arena;
+ return(returnPointer);
}
-} /* --- end ArenaAllocate() --- */
+}
-/*
- * Free tail arenas linked after head, which may not be the true list head.
- * Reset pool->current to point to head in case it pointed at a tail arena.
- */
-static void FreeArenaList(ArenaPool *pool, Arena *head, bool reallyFree)
+// Free tail arenas linked after head, which may not be the true list head.
+// Reset pool->current to point to head in case it pointed at a tail arena.
+static void FreeArenaList(ArenaPool* pool, Arena* head)
{
- Arena **ap, *a;
-
- ap = &head->next;
- a = *ap;
- if (!a)
+ Arena** arenaPointer = &head->next;
+ Arena* arena = *arenaPointer;
+ if (!arena)
return;
#ifdef DEBUG
do {
- ASSERT(a->base <= a->avail && a->avail <= a->limit);
- a->avail = a->base;
- CLEAR_UNUSED(a);
- } while ((a = a->next) != 0);
- a = *ap;
+ ASSERT(arena->base <= arena->avail && arena->avail <= arena->limit);
+ arena->avail = arena->base;
+ memset((void*)(arena)->avail, FREE_PATTERN, (arena)->limit - (arena)->avail)
+ } while ((arena = arena->next) != 0);
+ arena = *arenaPointer;
#endif
- if (freelist_count >= FREELIST_MAX)
- reallyFree = true;
-
- if (reallyFree) {
- do {
- *ap = a->next;
- CLEAR_ARENA(a);
+ do {
+ *arenaPointer = arena->next;
+
+#ifdef DEBUG
+ memset((void*)(arena), FREE_PATTERN, (arena)->limit - (uword)(arena));
+#endif
+
#ifdef DEBUG_ARENA_MALLOC
- if (a) {
- i--;
- printf("Free: %d\n", i);
- }
+ if (arena) {
+ i--;
+ printf("Free: %d\n", i);
+ }
#endif
- fastFree(a); a = 0;
- } while ((a = *ap) != 0);
- } else {
- /* Insert the whole arena chain at the front of the freelist. */
- do {
- ap = &(*ap)->next;
- freelist_count++;
- } while (*ap);
- *ap = arena_freelist;
- arena_freelist = a;
- head->next = 0;
- }
+
+ fastFree(arena);
+ arena = 0;
+ } while ((arena = *arenaPointer) != 0);
pool->current = head;
}
-void FreeArenaPool(ArenaPool *pool)
+void FinishArenaPool(ArenaPool* pool)
{
- FreeArenaList(pool, &pool->first, false);
+ FreeArenaList(pool, &pool->first);
}
-void FinishArenaPool(ArenaPool *pool)
-{
- FreeArenaList(pool, &pool->first, true);
}
-
-}
Modified: trunk/Source/WebCore/platform/Arena.h (115388 => 115389)
--- trunk/Source/WebCore/platform/Arena.h 2012-04-27 00:07:11 UTC (rev 115388)
+++ trunk/Source/WebCore/platform/Arena.h 2012-04-27 00:48:39 UTC (rev 115389)
@@ -41,8 +41,6 @@
#ifndef Arena_h
#define Arena_h
-#include <wtf/FastMalloc.h>
-
// FIXME: We'd always like to use AllocAlignmentInteger for Arena alignment
// but there is concern over the memory growth this may cause.
#ifdef WTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER
@@ -69,71 +67,23 @@
uword mask; // Mask (power-of-2 - 1)
};
-void InitArenaPool(ArenaPool *pool, const char *name,
- unsigned int size, unsigned int align);
-void FinishArenaPool(ArenaPool *pool);
-void FreeArenaPool(ArenaPool *pool);
-void* ArenaAllocate(ArenaPool *pool, unsigned int nb);
+void InitArenaPool(ArenaPool*, const char* name, unsigned int size, unsigned int align);
+void FinishArenaPool(ArenaPool*);
+void* ArenaAllocate(ArenaPool*, unsigned int nb);
#define ARENA_ALIGN(n) (((uword)(n) + ARENA_ALIGN_MASK) & ~ARENA_ALIGN_MASK)
-#define INIT_ARENA_POOL(pool, name, size) \
- InitArenaPool(pool, name, size, ARENA_ALIGN_MASK + 1)
-
+#define INIT_ARENA_POOL(pool, name, size) InitArenaPool(pool, name, size, ARENA_ALIGN_MASK + 1)
#define ARENA_ALLOCATE(p, pool, nb) \
- Arena *_a = (pool)->current; \
- unsigned int _nb = ARENA_ALIGN(nb); \
- uword _p = _a->avail; \
- uword _q = _p + _nb; \
- if (_q > _a->limit) \
- _p = (uword)ArenaAllocate(pool, _nb); \
- else \
- _a->avail = _q; \
- p = (void *)_p;
+ Arena* _a = (pool)->current; \
+ unsigned int _nb = ARENA_ALIGN(nb); \
+ uword _p = _a->avail; \
+ uword _q = _p + _nb; \
+ if (_q > _a->limit) \
+ _p = (uword)ArenaAllocate(pool, _nb); \
+ else \
+ _a->avail = _q; \
+ p = (void*)_p;
-#define ARENA_GROW(p, pool, size, incr) \
- Arena *_a = (pool)->current; \
- unsigned int _incr = ARENA_ALIGN(incr); \
- uword _p = _a->avail; \
- uword _q = _p + _incr; \
- if (_p == (uword)(p) + ARENA_ALIGN(size) && \
- _q <= _a->limit) { \
- _a->avail = _q; \
- } else { \
- p = ArenaGrow(pool, p, size, incr); \
- }
-
-#define ARENA_MARK(pool) ((void *) (pool)->current->avail)
-#define UPTRDIFF(p,q) ((uword)(p) - (uword)(q))
-
-#ifdef DEBUG
-#define FREE_PATTERN 0xDA
-#define CLEAR_UNUSED(a) ASSERT((a)->avail <= (a)->limit); \
- memset((void*)(a)->avail, FREE_PATTERN, \
- (a)->limit - (a)->avail)
-#define CLEAR_ARENA(a) memset((void*)(a), FREE_PATTERN, \
- (a)->limit - (uword)(a))
-#else
-#define CLEAR_UNUSED(a)
-#define CLEAR_ARENA(a)
-#endif
-
-#define ARENA_RELEASE(pool, mark) \
- char *_m = (char *)(mark); \
- Arena *_a = (pool)->current; \
- if (UPTRDIFF(_m, _a->base) <= UPTRDIFF(_a->avail, _a->base)) { \
- _a->avail = (uword)ARENA_ALIGN(_m); \
- CLEAR_UNUSED(_a); \
- } else { \
- ArenaRelease(pool, _m); \
- }
-
-#define ARENA_DESTROY(pool, a, pnext) \
- if ((pool)->current == (a)) (pool)->current = &(pool)->first; \
- *(pnext) = (a)->next; \
- CLEAR_ARENA(a); \
- fastFree(a); \
- (a) = 0;
-
}
#endif