Ignore:
Timestamp:
Aug 20, 2009, 10:41:54 PM (16 years ago)
Author:
[email protected]
Message:

Added a number => string cache.

Patch by Geoffrey Garen <[email protected]> on 2009-08-20
Reviewed by Maciej Stachowiak.

1.07x faster on v8 (1.7x faster on v8-splay).
1.004x faster on SunSpider.

  • runtime/JSCell.h: Moved JSValue::toString to JSString.h.
  • runtime/JSGlobalData.h: Holds the cache.
  • runtime/JSNumberCell.cpp:

(JSC::JSNumberCell::toString):
(JSC::JSNumberCell::toThisString): Removed -0 special case.
UString handles this now, since too many clients were
special-casing it.

  • runtime/JSString.h:

(JSC::JSValue::toString): Use the cache when converting
an int or double to string.

  • runtime/Operations.h:

(JSC::concatenateStrings): Call toString to take advantage
of the cache.

  • runtime/SmallStrings.h:

(JSC::NumericStrings::add):
(JSC::NumericStrings::lookup): The cache.

  • runtime/UString.cpp:

(JSC::UString::from): Added -0 special case mentioned above.
Removed appendNumeric because it's mutually exclusive with the
cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Operations.h

    r46598 r47622  
    309309        UString result(resultRep);
    310310
    311         // Loop over the openards, writing them into the output buffer.
     311        // Loop over the operands, writing them into the output buffer.
    312312        for (unsigned i = 0; i < count; ++i) {
    313313            JSValue v = strings[i].jsValue();
    314314            if (LIKELY(v.isString()))
    315315                result.append(asString(v)->value());
    316             else if (v.isInt32())
    317                 result.appendNumeric(v.asInt32());
    318             else {
    319                 double d;
    320                 if (v.getNumber(d))
    321                     result.appendNumeric(d);
    322                 else
    323                     result.append(v.toString(callFrame));
    324             }
     316            else
     317                result.append(v.toString(callFrame));
    325318        }
    326319
Note: See TracChangeset for help on using the changeset viewer.