Ignore:
Timestamp:
Apr 25, 2007, 1:25:06 PM (18 years ago)
Author:
darin
Message:

Reviewed by Geoff.

  • tweak the allocator for a small speedup -- Shark showed this was a win, but I can't measure an improvement right now, but it's also clear these changes do no harm
  • wtf/FastMalloc.cpp: (WTF::LgFloor): Use ALWAYS_INLINE here; in testing I did a while back this was necessary to get this single-instruction function to be inlined. (WTF::SizeClass): Use ALWAYS_INLINE here too for the same reason. Also change the special case for a size of 0 to work without a branch for a bit of extra speed. (WTF::ByteSizeForClass): Use ALWAYS_INLINE here too for the same reason.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r20351 r21096  
    286286// Return floor(log2(n)) for n > 0.
    287287#if PLATFORM(X86) && COMPILER(GCC)
    288 static inline int LgFloor(size_t n) {
     288static ALWAYS_INLINE int LgFloor(size_t n) {
    289289  // "ro" for the input spec means the input can come from either a
    290290  // register ("r") or offsetable memory ("o").
     
    299299
    300300#elif PLATFORM(PPC) && COMPILER(GCC)
    301 static inline int LgFloor(size_t n) {
     301static ALWAYS_INLINE int LgFloor(size_t n) {
    302302  // "r" for the input spec means the input must come from a
    303303  // register ("r")
     
    329329#endif
    330330
    331 static inline size_t SizeClass(size_t size) {
    332   if (size == 0) size = 1;
     331static ALWAYS_INLINE size_t SizeClass(size_t size) {
     332  size += !size; // change 0 to 1 (with no branches)
    333333  const int lg = LgFloor(size);
    334334  const int align = size_shift[lg];
     
    337337
    338338// Get the byte-size for a specified class
    339 static inline size_t ByteSizeForClass(size_t cl) {
     339static ALWAYS_INLINE size_t ByteSizeForClass(size_t cl) {
    340340  return class_to_size[cl];
    341341}
Note: See TracChangeset for help on using the changeset viewer.