Changeset 210735 in webkit
- Timestamp:
- Jan 13, 2017 10:30:09 AM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r210695 r210735 1 2017-01-13 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Reserve capacity for StringBuilder in unescape 4 https://bugs.webkit.org/show_bug.cgi?id=167008 5 6 Reviewed by Sam Weinig. 7 8 `unescape` function is frequently called in Kraken sha256-iterative. 9 This patch just reserves the capacity for the StringBuilder. 10 11 Currently, we select the length of the string for the reserved capacity. 12 It improves the performance 2.73%. 13 14 Benchmark report for Kraken on sakura-trick. 15 16 VMs tested: 17 "baseline" at /home/yusukesuzuki/dev/WebKit/WebKitBuild/untot/Release/bin/jsc 18 "patched" at /home/yusukesuzuki/dev/WebKit/WebKitBuild/un/Release/bin/jsc 19 20 Collected 100 samples per benchmark/VM, with 100 VM invocations per benchmark. Emitted a call to gc() between 21 sample measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the jsc-specific preciseTime() 22 function to get microsecond-level timing. Reporting benchmark execution times with 95% confidence intervals in 23 milliseconds. 24 25 baseline patched 26 27 stanford-crypto-sha256-iterative 51.609+-0.672 50.237+-0.860 might be 1.0273x faster 28 29 <arithmetic> 51.609+-0.672 50.237+-0.860 might be 1.0273x faster 30 31 * runtime/JSGlobalObjectFunctions.cpp: 32 (JSC::globalFuncUnescape): 33 1 34 2017-01-12 Saam Barati <sbarati@apple.com> 2 35 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r210522 r210735 815 815 { 816 816 return JSValue::encode(toStringView(exec, exec->argument(0), [&] (StringView view) { 817 unsigned k = 0; 818 unsigned length = view.length(); 819 817 820 StringBuilder builder; 818 int k = 0; 819 int len = view.length(); 821 builder.reserveCapacity(length); 820 822 821 823 if (view.is8Bit()) { 822 824 const LChar* characters = view.characters8(); 823 825 LChar convertedLChar; 824 while (k < len ) {826 while (k < length) { 825 827 const LChar* c = characters + k; 826 if (c[0] == '%' && k <= len - 6 && c[1] == 'u') {828 if (c[0] == '%' && k <= length - 6 && c[1] == 'u') { 827 829 if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) { 828 830 builder.append(Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5])); … … 830 832 continue; 831 833 } 832 } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {834 } else if (c[0] == '%' && k <= length - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) { 833 835 convertedLChar = LChar(Lexer<LChar>::convertHex(c[1], c[2])); 834 836 c = &convertedLChar; … … 841 843 const UChar* characters = view.characters16(); 842 844 843 while (k < len ) {845 while (k < length) { 844 846 const UChar* c = characters + k; 845 847 UChar convertedUChar; 846 if (c[0] == '%' && k <= len - 6 && c[1] == 'u') {848 if (c[0] == '%' && k <= length - 6 && c[1] == 'u') { 847 849 if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) { 848 850 convertedUChar = Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5]); … … 850 852 k += 5; 851 853 } 852 } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {854 } else if (c[0] == '%' && k <= length - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) { 853 855 convertedUChar = UChar(Lexer<UChar>::convertHex(c[1], c[2])); 854 856 c = &convertedUChar;
Note: See TracChangeset
for help on using the changeset viewer.