WebKit Bugzilla
Attachment 373745 Details for
Bug 199636
: Optimize join of large empty arrays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199636-20190709214948.patch (text/plain), 3.56 KB, created by
Tadeu Zagallo
on 2019-07-09 12:49:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tadeu Zagallo
Created:
2019-07-09 12:49:49 PDT
Size:
3.56 KB
patch
obsolete
>Subversion Revision: 247166 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index e903e4fd97709af5acd3934d319f42049f6f6196..020801884e475b7881fd5a9ba60812f0049b85e6 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,27 @@ >+2019-07-09 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Optimize join of large empty arrays >+ https://bugs.webkit.org/show_bug.cgi?id=199636 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Replicate the behavior of `str.repeat(count)` when performing `new Array(count + 1).join(str)`. >+ I added a new microbenchmark, large-empty-array-join, which runs ~44x faster and uses ~18x less memory. >+ >+ baseline diff >+ large-empty-array-join 2713.9698+-72.7621 ^ 61.2335+-10.4836 ^ definitely 44.3217x faster >+ >+ Memory usage with baseline (dirty): >+ 733012 kB current_mem >+ 756824 kB lifetime_peak >+ >+ Memory usage with diff (dirty): >+ 41904 kB current_mem >+ 41972 kB lifetime_peak >+ >+ * runtime/ArrayPrototype.cpp: >+ (JSC::fastJoin): >+ > 2019-07-05 Tadeu Zagallo <tzagallo@apple.com> > > Unreviewed, change the value used to scribble Heap::m_worldState >diff --git a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp >index 7f0fc37dab699bd01f73f32b5822cba4d090e86d..1ba6107b71ab1a431a4cf60a890f1999aad8d368 100644 >--- a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp >+++ b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp >@@ -516,6 +516,21 @@ inline JSValue fastJoin(ExecState& state, JSObject* thisObject, StringView separ > if (separator.is8Bit()) > RELEASE_AND_RETURN(scope, repeatCharacter(state, separator.characters8()[0], length - 1)); > RELEASE_AND_RETURN(scope, repeatCharacter(state, separator.characters16()[0], length - 1)); >+ default: >+ JSString* result = jsEmptyString(&state); >+ JSString* operand = jsString(&vm, separator.toString()); >+ unsigned count = length - 1; >+ for (;;) { >+ if (count & 1) { >+ result = jsString(&state, result, operand); >+ RETURN_IF_EXCEPTION(scope, { }); >+ } >+ count >>= 1; >+ if (!count) >+ return result; >+ operand = jsString(&state, operand, operand); >+ RETURN_IF_EXCEPTION(scope, { }); >+ } > } > } > } >diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog >index c6d1889cbef5fd572fdbab9916559e3c80163af4..d1d5cec18ba51ac1dca0457ffd9f6e99209dc7c5 100644 >--- a/JSTests/ChangeLog >+++ b/JSTests/ChangeLog >@@ -1,3 +1,12 @@ >+2019-07-09 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Optimize join of large empty arrays >+ https://bugs.webkit.org/show_bug.cgi?id=199636 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * microbenchmarks/large-empty-array-join.js: Added. >+ > 2019-07-02 Michael Saboff <msaboff@apple.com> > > Exception from For..of loop assignment eliminates TDZ checks in subsequent code >diff --git a/JSTests/microbenchmarks/large-empty-array-join.js b/JSTests/microbenchmarks/large-empty-array-join.js >new file mode 100644 >index 0000000000000000000000000000000000000000..1a2ae07c6419f3c4b7f7ec5dafee9a47115f0a94 >--- /dev/null >+++ b/JSTests/microbenchmarks/large-empty-array-join.js >@@ -0,0 +1,3 @@ >+const array = []; >+for (let i = 0; i < 100; ++i) >+ array.push(new Array(1e6).join('â' + i));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199636
:
373745
|
373748
|
373754
|
373755
|
373758
|
373772
|
373824