Eneboo - Documentación para desarrolladores
src/hoard/src/heaplayers/bins64k.h
Ir a la documentación de este archivo.
00001 // -*- C++ -*-
00002 
00003 #if !defined(_BINS64K_H_)
00004 #define _BINS64K_H_
00005 
00006 #include <cstdlib>
00007 #include <assert.h>
00008 
00009 #include "bins.h"
00010 #include "sassert.h"
00011 
00012 namespace HL {
00013 
00014 template <class Header>
00015 class bins<Header, 65536> {
00016 public:
00017 
00018   bins (void)
00019   {
00020 #ifndef NDEBUG
00021     for (int i = sizeof(double); i < BIG_OBJECT; i++) {
00022       int sc = getSizeClass(i);
00023       assert (getClassSize(sc) >= i);
00024       assert (getClassSize(sc-1) < i);
00025       assert (getSizeClass(getClassSize(sc)) == sc);
00026     }
00027 #endif
00028   }
00029 
00030   enum { BIG_OBJECT = 65536 / 2 - sizeof(Header) };
00031   
00032   enum { NUM_BINS = 55,
00033          NUM_LOOKUP = 508 };
00034 
00035   static const size_t _bins[NUM_BINS];
00036   static const int    _sizeclasses[NUM_LOOKUP];
00037 
00038   static inline int getSizeClass (size_t sz) {
00039     assert (sz <= _bins[NUM_BINS-1]);
00040     sz = (sz < sizeof(double)) ? sizeof(double) : sz;
00041     if (sz <= 80) {
00042       return (int) ((sz - 1) >> 3);
00043     } else {
00044       return slowGetSizeClass (sz);
00045     }
00046   }
00047 
00048   static inline size_t getClassSize (const int i) {
00049     assert (i >= 0);
00050     assert (i < NUM_BINS);
00051     assert (getSizeClass(_bins[i]) == i);
00052     return _bins[i];
00053   }
00054 
00055 private:
00056 
00057   static inline int slowGetSizeClass (size_t sz) {
00058     int ind = 0;
00059     while (sz > _bins[ind]) {
00060       ind++;
00061       assert (ind < NUM_BINS);
00062     }
00063     return ind;
00064   }
00065 
00066   sassert<(BIG_OBJECT > 0)> verifyHeaderSize;
00067 };
00068 
00069 }
00070 
00071 
00072 template <class Header>
00073 const size_t HL::bins<Header, 65536>::_bins[NUM_BINS] =
00074   { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 152, 176, 208, 248, 296, 352, 416, 496, 592, 704, 840, 1008, 1208, 1448, 1736, 2080, 2496, 2992, 3584, 4096 - sizeof(Header), 4912, 5888, 7064, 8192 - sizeof(Header), 9824, 11784, 12288 - sizeof(Header), 14744, 16384 - sizeof(Header), 19656, 20480 - sizeof(Header), 24576 - sizeof(Header), 28672 - sizeof(Header), 32768 - sizeof(Header), 36864 - sizeof(Header), 40960 - sizeof(Header), 45056 - sizeof(Header), 49152 - sizeof(Header), 53248 - sizeof(Header), 57344 - sizeof(Header), 61440 - sizeof(Header), 65536 - sizeof(Header) };
00075 
00076 template <class Header>
00077 const int HL::bins<Header, 65536>::_sizeclasses[NUM_LOOKUP] =
00078   {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
00079 
00080 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'