Title: [210735] trunk/Source/_javascript_Core
- Revision
- 210735
- Author
- utatane....@gmail.com
- Date
- 2017-01-13 10:30:09 -0800 (Fri, 13 Jan 2017)
Log Message
Reserve capacity for StringBuilder in unescape
https://bugs.webkit.org/show_bug.cgi?id=167008
Reviewed by Sam Weinig.
`unescape` function is frequently called in Kraken sha256-iterative.
This patch just reserves the capacity for the StringBuilder.
Currently, we select the length of the string for the reserved capacity.
It improves the performance 2.73%.
Benchmark report for Kraken on sakura-trick.
VMs tested:
"baseline" at /home/yusukesuzuki/dev/WebKit/WebKitBuild/untot/Release/bin/jsc
"patched" at /home/yusukesuzuki/dev/WebKit/WebKitBuild/un/Release/bin/jsc
Collected 100 samples per benchmark/VM, with 100 VM invocations per benchmark. Emitted a call to gc() between
sample measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the jsc-specific preciseTime()
function to get microsecond-level timing. Reporting benchmark execution times with 95% confidence intervals in
milliseconds.
baseline patched
stanford-crypto-sha256-iterative 51.609+-0.672 50.237+-0.860 might be 1.0273x faster
<arithmetic> 51.609+-0.672 50.237+-0.860 might be 1.0273x faster
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncUnescape):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (210734 => 210735)
--- trunk/Source/_javascript_Core/ChangeLog 2017-01-13 18:09:34 UTC (rev 210734)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-01-13 18:30:09 UTC (rev 210735)
@@ -1,3 +1,36 @@
+2017-01-13 Yusuke Suzuki <utatane....@gmail.com>
+
+ Reserve capacity for StringBuilder in unescape
+ https://bugs.webkit.org/show_bug.cgi?id=167008
+
+ Reviewed by Sam Weinig.
+
+ `unescape` function is frequently called in Kraken sha256-iterative.
+ This patch just reserves the capacity for the StringBuilder.
+
+ Currently, we select the length of the string for the reserved capacity.
+ It improves the performance 2.73%.
+
+ Benchmark report for Kraken on sakura-trick.
+
+ VMs tested:
+ "baseline" at /home/yusukesuzuki/dev/WebKit/WebKitBuild/untot/Release/bin/jsc
+ "patched" at /home/yusukesuzuki/dev/WebKit/WebKitBuild/un/Release/bin/jsc
+
+ Collected 100 samples per benchmark/VM, with 100 VM invocations per benchmark. Emitted a call to gc() between
+ sample measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the jsc-specific preciseTime()
+ function to get microsecond-level timing. Reporting benchmark execution times with 95% confidence intervals in
+ milliseconds.
+
+ baseline patched
+
+ stanford-crypto-sha256-iterative 51.609+-0.672 50.237+-0.860 might be 1.0273x faster
+
+ <arithmetic> 51.609+-0.672 50.237+-0.860 might be 1.0273x faster
+
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::globalFuncUnescape):
+
2017-01-12 Saam Barati <sbar...@apple.com>
Add a slice intrinsic to the DFG/FTL
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (210734 => 210735)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2017-01-13 18:09:34 UTC (rev 210734)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2017-01-13 18:30:09 UTC (rev 210735)
@@ -814,22 +814,24 @@
EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)
{
return JSValue::encode(toStringView(exec, exec->argument(0), [&] (StringView view) {
+ unsigned k = 0;
+ unsigned length = view.length();
+
StringBuilder builder;
- int k = 0;
- int len = view.length();
+ builder.reserveCapacity(length);
if (view.is8Bit()) {
const LChar* characters = view.characters8();
LChar convertedLChar;
- while (k < len) {
+ while (k < length) {
const LChar* c = characters + k;
- if (c[0] == '%' && k <= len - 6 && c[1] == 'u') {
+ if (c[0] == '%' && k <= length - 6 && c[1] == 'u') {
if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) {
builder.append(Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5]));
k += 6;
continue;
}
- } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {
+ } else if (c[0] == '%' && k <= length - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {
convertedLChar = LChar(Lexer<LChar>::convertHex(c[1], c[2]));
c = &convertedLChar;
k += 2;
@@ -840,16 +842,16 @@
} else {
const UChar* characters = view.characters16();
- while (k < len) {
+ while (k < length) {
const UChar* c = characters + k;
UChar convertedUChar;
- if (c[0] == '%' && k <= len - 6 && c[1] == 'u') {
+ if (c[0] == '%' && k <= length - 6 && c[1] == 'u') {
if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) {
convertedUChar = Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5]);
c = &convertedUChar;
k += 5;
}
- } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {
+ } else if (c[0] == '%' && k <= length - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {
convertedUChar = UChar(Lexer<UChar>::convertHex(c[1], c[2]));
c = &convertedUChar;
k += 2;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes