Title: [210766] trunk
- Revision
- 210766
- Author
- [email protected]
- Date
- 2017-01-14 08:19:33 -0800 (Sat, 14 Jan 2017)
Log Message
Reserve capacity for StringBuilder in unescape
https://bugs.webkit.org/show_bug.cgi?id=167008
Reviewed by Sam Weinig.
JSTests:
* stress/unescape.js: Added.
(shouldBe):
Source/_javascript_Core:
`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
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (210765 => 210766)
--- trunk/JSTests/ChangeLog 2017-01-14 09:01:11 UTC (rev 210765)
+++ trunk/JSTests/ChangeLog 2017-01-14 16:19:33 UTC (rev 210766)
@@ -1,3 +1,13 @@
+2017-01-14 Yusuke Suzuki <[email protected]>
+
+ Reserve capacity for StringBuilder in unescape
+ https://bugs.webkit.org/show_bug.cgi?id=167008
+
+ Reviewed by Sam Weinig.
+
+ * stress/unescape.js: Added.
+ (shouldBe):
+
2017-01-12 Saam Barati <[email protected]>
Add a slice intrinsic to the DFG/FTL
Added: trunk/JSTests/stress/unescape.js (0 => 210766)
--- trunk/JSTests/stress/unescape.js (rev 0)
+++ trunk/JSTests/stress/unescape.js 2017-01-14 16:19:33 UTC (rev 210766)
@@ -0,0 +1,7 @@
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+shouldBe(unescape("%0"), "%0");
+shouldBe(unescape("%a"), "%a");
Modified: trunk/Source/_javascript_Core/ChangeLog (210765 => 210766)
--- trunk/Source/_javascript_Core/ChangeLog 2017-01-14 09:01:11 UTC (rev 210765)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-01-14 16:19:33 UTC (rev 210766)
@@ -1,3 +1,36 @@
+2017-01-14 Yusuke Suzuki <[email protected]>
+
+ 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-13 Joseph Pecoraro <[email protected]>
Remove ENABLE(DETAILS_ELEMENT) guards
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (210765 => 210766)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2017-01-14 09:01:11 UTC (rev 210765)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2017-01-14 16:19:33 UTC (rev 210766)
@@ -814,22 +814,26 @@
EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)
{
return JSValue::encode(toStringView(exec, exec->argument(0), [&] (StringView view) {
- StringBuilder builder;
+ // We use int for k and length intentionally since we would like to evaluate
+ // the condition `k <= length -6` even if length is less than 6.
int k = 0;
- int len = view.length();
+ int length = view.length();
+ StringBuilder builder;
+ 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 +844,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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes