Ignore:
Timestamp:
Aug 30, 2008, 11:58:07 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-08-30 Darin Adler <Darin Adler>

Reviewed by Maciej.

1.035x as fast on SunSpider overall.
1.127x as fast on SunSpider string tests.
1.910x as fast on SunSpider string-base64 test.

  • API/JSObjectRef.cpp: (JSObjectMakeFunction): Removed unneeded explicit construction of UString.
  • GNUmakefile.am: Added SmallStrings.h and SmallStrings.cpp.
  • JavaScriptCore.pri: Ditto.
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto.
  • JavaScriptCore.xcodeproj/project.pbxproj: Ditto.
  • JavaScriptCoreSources.bkl: Ditto.
  • VM/Machine.cpp: (KJS::jsAddSlowCase): Changed to use a code path that doesn't involve a UString constructor. This avoids an extra jump caused by the "in charge" vs. "not in charge" constructors. (KJS::jsAdd): Ditto. (KJS::jsTypeStringForValue): Adopted jsNontrivialString.
  • kjs/ArrayPrototype.cpp: (KJS::arrayProtoFuncToString): Adopted jsEmptyString. (KJS::arrayProtoFuncToLocaleString): Ditto. (KJS::arrayProtoFuncJoin): Ditto.
  • kjs/BooleanPrototype.cpp: (KJS::booleanProtoFuncToString): Adopted jsNontrivialString.
  • kjs/DateConstructor.cpp: (KJS::callDate): Ditto.
  • kjs/DatePrototype.cpp: (KJS::formatLocaleDate): Adopted jsEmptyString and jsNontrivialString. (KJS::dateProtoFuncToString): Ditto. (KJS::dateProtoFuncToUTCString): Ditto. (KJS::dateProtoFuncToDateString): Ditto. (KJS::dateProtoFuncToTimeString): Ditto. (KJS::dateProtoFuncToLocaleString): Ditto. (KJS::dateProtoFuncToLocaleDateString): Ditto. (KJS::dateProtoFuncToLocaleTimeString): Ditto. (KJS::dateProtoFuncToGMTString): Ditto.
  • kjs/ErrorPrototype.cpp: (KJS::ErrorPrototype::ErrorPrototype): Ditto. (KJS::errorProtoFuncToString): Ditto.
  • kjs/JSGlobalData.h: Added SmallStrings.
  • kjs/JSString.cpp: (KJS::jsString): Eliminated the overload that takes a const char*. Added code to use SmallStrings to get strings of small sizes rather than creating a new JSString every time. (KJS::jsSubstring): Added. Used when creating a string from a substring to avoid creating a JSString in cases where the substring will end up empty or as one character. (KJS::jsOwnedString): Added the same code as in jsString.
  • kjs/JSString.h: Added new functions jsEmptyString, jsSingleCharacterString, jsSingleCharacterSubstring, jsSubstring, and jsNontrivialString for various cases where we want to create JSString, and want special handling for small strings. (KJS::JSString::JSString): Added an overload that takes a PassRefPtr of a UString::Rep so you don't have to construct a UString; PassRefPtr can be more efficient. (KJS::jsEmptyString): Added. (KJS::jsSingleCharacterString): Added. (KJS::jsSingleCharacterSubstring): Added. (KJS::jsNontrivialString): Added. (KJS::JSString::getIndex): Adopted jsSingleCharacterSubstring. (KJS::JSString::getStringPropertySlot): Ditto.
  • kjs/NumberPrototype.cpp: (KJS::numberProtoFuncToFixed): Adopted jsNontrivialString. (KJS::numberProtoFuncToExponential): Ditto. (KJS::numberProtoFuncToPrecision): Ditto.
  • kjs/ObjectPrototype.cpp: (KJS::objectProtoFuncToLocaleString): Adopted toThisJSString. (KJS::objectProtoFuncToString): Adopted jsNontrivialString.
  • kjs/RegExpConstructor.cpp: Separated the lastInput value that's used with the lastOvector to return matches from the input value that can be changed via JavaScript. They will be equal in many cases, but not all. (KJS::RegExpConstructor::performMatch): Set input. (KJS::RegExpMatchesArray::RegExpMatchesArray): Ditto. (KJS::RegExpMatchesArray::fillArrayInstance): Adopted jsSubstring. Also, use input rather than lastInput in the appropriate place. (KJS::RegExpConstructor::getBackref): Adopted jsSubstring and jsEmptyString. Added code to handle the case where there is no backref -- before this depended on range checking in UString::substr which is not present in jsSubstring. (KJS::RegExpConstructor::getLastParen): Ditto. (KJS::RegExpConstructor::getLeftContext): Ditto. (KJS::RegExpConstructor::getRightContext): Ditto. (KJS::RegExpConstructor::getValueProperty): Use input rather than lastInput. Also adopt jsEmptyString. (KJS::RegExpConstructor::putValueProperty): Ditto. (KJS::RegExpConstructor::input): Ditto.
  • kjs/RegExpPrototype.cpp: (KJS::regExpProtoFuncToString): Adopt jsNonTrivialString. Also changed to use UString::append to append single characters rather than using += and a C-style string.
  • kjs/SmallStrings.cpp: Added. (KJS::SmallStringsStorage::SmallStringsStorage): Construct the buffer and UString::Rep for all 256 single-character strings for the U+0000 through U+00FF. This covers all the values used in the base64 test as well as most values seen elsewhere on the web as well. It's possible that later we might fix this to only work for U+0000 through U+007F but the others are used quite a bit in the current version of the base64 test. (KJS::SmallStringsStorage::~SmallStringsStorage): Free memory. (KJS::SmallStrings::SmallStrings): Create a set of small strings, initially not created; created later when they are used. (KJS::SmallStrings::~SmallStrings): Deallocate. Not left compiler generated because the SmallStringsStorage class's destructor needs to be visible. (KJS::SmallStrings::mark): Mark all the strings. (KJS::SmallStrings::createEmptyString): Create a cell for the empty string. Called only the first time. (KJS::SmallStrings::createSingleCharacterString): Create a cell for one of the single-character strings. Called only the first time.
  • kjs/SmallStrings.h: Added.
  • kjs/StringConstructor.cpp: (KJS::stringFromCharCodeSlowCase): Factored out of strinFromCharCode. Only used for cases where the caller does not pass exactly one argument. (KJS::stringFromCharCode): Adopted jsSingleCharacterString. (KJS::callStringConstructor): Adopted jsEmptyString.
  • kjs/StringObject.cpp: (KJS::StringObject::StringObject): Adopted jsEmptyString.
  • kjs/StringPrototype.cpp: (KJS::stringProtoFuncReplace): Adopted jsSubstring. (KJS::stringProtoFuncCharAt): Adopted jsEmptyString and jsSingleCharacterSubstring and also added a special case when the index is an immediate number to avoid conversion to and from floating point, since that's the common case. (KJS::stringProtoFuncCharCodeAt): Ditto. (KJS::stringProtoFuncMatch): Adopted jsSubstring and jsEmptyString. (KJS::stringProtoFuncSlice): Adopted jsSubstring and jsSingleCharacterSubstring. Also got rid of some unneeded locals and removed unneeded code to set the length property of the array, since it is automatically updated as values are added to the array. (KJS::stringProtoFuncSplit): Adopted jsEmptyString. (KJS::stringProtoFuncSubstr): Adopted jsSubstring. (KJS::stringProtoFuncSubstring): Ditto.
  • kjs/collector.cpp: (KJS::Heap::collect): Added a call to mark SmallStrings.
  • kjs/ustring.cpp: (KJS::UString::expandedSize): Made this a static member function since it doesn't need to look at any data members. (KJS::UString::expandCapacity): Use a non-inline function, makeNull, to set the rep to null in failure cases. This avoids adding a PIC branch for the normal case when there is no failure. (KJS::UString::expandPreCapacity): Ditto. (KJS::UString::UString): Ditto. (KJS::concatenate): Refactored the concatenation constructor into this separate function. Calling the concatenation constructor was leading to an extra branch because of the in-charge vs. not-in-charge versions not both being inlined, and this was showing up as nearly 1% on Shark. Also added a special case for when the second string is a single character, since it's a common idiom to build up a string that way and we can do things much more quickly, without involving memcpy for example. Also adopted the non-inline function, nullRep, for the same reason given for makeNull above. (KJS::UString::append): Adopted makeNull for failure cases. (KJS::UString::operator=): Ditto. (KJS::UString::toDouble): Added a special case for converting single character strings to numbers. We're doing this a ton of times while running the base64 test. (KJS::operator==): Added special cases so we can compare single-character strings without calling memcmp. Later we might want to special case other short lengths similarly. (KJS::UString::makeNull): Added. (KJS::UString::nullRep): Added.
  • kjs/ustring.h: Added declarations for the nullRep and makeNull. Changed expandedSize to be a static member function. Added a declaration of the concatenate function. Removed the concatenation constructor. Rewrote operator+ to use the concatenate function.

WebCore:

2008-08-30 Darin Adler <Darin Adler>

Reviewed by Maciej.

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::windowProtoFuncAToB): Adopted jsEmptyString. (WebCore::windowProtoFuncBToA): Ditto.
  • bindings/js/JSEventListener.cpp: (WebCore::JSLazyEventListener::eventParameterName): Adopted jsNontrivialString.
  • bindings/js/JSSVGLazyEventListener.cpp: (WebCore::JSSVGLazyEventListener::eventParameterName): Ditto.

LayoutTests:

2008-08-30 Darin Adler <Darin Adler>

Reviewed by Maciej.

  • updated incorrect results that reflected a bug in the RegExp object
  • fast/js/regexp-caching-expected.txt: Updated results to correctly show that $1 through $9, lastMatch, lastParen, leftContext, and rightContext are left alone both when a program changes the value of RegExp.input and when it performs an unsuccessful match. The new results match Gecko behavior (I tested both Firefox 2 and 3).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r35984 r36006  
    6868                14E0FF120DBAAED00007C0AB /* Machine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 149B15E70D81F986009CB8C7 /* Machine.cpp */; settings = {COMPILER_FLAGS = "-fno-tree-pre"; }; };
    6969                5D53726F0E1C54880021E549 /* Tracing.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D53726E0E1C54880021E549 /* Tracing.h */; };
    70                 5D53727E0E1C55EC0021E549 /* TracingDtrace.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D53727D0E1C55EC0021E549 /* TracingDtrace.h */; };
    7170                5D5D8AB60E0D0A7200F9C692 /* jsc in Copy Into Framework */ = {isa = PBXBuildFile; fileRef = 932F5BE10822A1C700736975 /* jsc */; };
    7271                5D5D8AD10E0D0EBE00F9C692 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */; };
     
    8988                932F5BDD0822A1C700736975 /* Shell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45E12D8806A49B0F00E9DF84 /* Shell.cpp */; };
    9089                932F5BEA0822A1C700736975 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; };
     90                933040040E6A749400786E6A /* SmallStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 93303FEA0E6A72C000786E6A /* SmallStrings.h */; settings = {ATTRIBUTES = (Private, ); }; };
     91                9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93303FE80E6A72B500786E6A /* SmallStrings.cpp */; };
    9192                937013480CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 937013470CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp */; settings = {COMPILER_FLAGS = "-Wno-sign-compare"; }; };
    9293                93E26BD408B1514100F85226 /* pcre_xclass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E26BD308B1514100F85226 /* pcre_xclass.cpp */; };
     
    577578                932F5BD90822A1C700736975 /* JavaScriptCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    578579                932F5BE10822A1C700736975 /* jsc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jsc; sourceTree = BUILT_PRODUCTS_DIR; };
     580                93303FE80E6A72B500786E6A /* SmallStrings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmallStrings.cpp; sourceTree = "<group>"; };
     581                93303FEA0E6A72C000786E6A /* SmallStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmallStrings.h; sourceTree = "<group>"; };
    579582                933A3499038AE7C6008635CE /* grammar.y */ = {isa = PBXFileReference; explicitFileType = sourcecode.yacc; fileEncoding = 4; indentWidth = 4; path = grammar.y; sourceTree = "<group>"; tabWidth = 8; };
    580583                933A349A038AE7C6008635CE /* identifier.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = identifier.h; sourceTree = "<group>"; tabWidth = 8; };
     
    12441247                                9374D3A7038D9D74008635CE /* ScopeChain.h */,
    12451248                                7E2C6C980D31C6B6002D44E2 /* ScopeChainMark.h */,
     1249                                93303FE80E6A72B500786E6A /* SmallStrings.cpp */,
     1250                                93303FEA0E6A72C000786E6A /* SmallStrings.h */,
    12461251                                65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */,
    12471252                                65E866EE0DD59AFA00A2B2A1 /* SourceRange.h */,
     
    15201525                                95CD45770E1C4FDD0085358E /* ProfileGenerator.h in Headers */,
    15211526                                5D53726F0E1C54880021E549 /* Tracing.h in Headers */,
    1522                                 5D53727E0E1C55EC0021E549 /* TracingDtrace.h in Headers */,
    15231527                                BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */,
    15241528                                BC3046070E1F497F003232CF /* Error.h in Headers */,
     
    15341538                                E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */,
    15351539                                9534AAFB0E5B7A9600B8A45B /* JSProfilerPrivate.h in Headers */,
     1540                                933040040E6A749400786E6A /* SmallStrings.h in Headers */,
    15361541                        );
    15371542                        runOnlyForDeploymentPostprocessing = 0;
     
    18401845                                E124A8F80E555775003091F1 /* OpaqueJSString.cpp in Sources */,
    18411846                                95F6E6950E5B5F970091E860 /* JSProfilerPrivate.cpp in Sources */,
     1847                                9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
    18421848                        );
    18431849                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.