Optimize string expression concatenation

Description

Now that we have function return type inference (CLJS-1997), we can see that functions like namespace return strings. Additionally, we can easily make it so that expressions involving str are inferred as returning strings. With those two in place, with a mild extension to CLJS-2314, we can eliminate unnecessary string coercions in str macro expansions where arguments are inferred to be strings.

This leads to performance gains which are akin to checked-if elimination (but perhaps even greater):

Yields these speedups under :advanced

V8: 3.2
SpiderMonkey: 1.3
JavaScriptCore: 4.2
Nashorn: 2.5
ChakraCore: 3.2
GraalVM: 1.3

This could be great for UIs that are heavy in string-concatenation, as well as for the self-hosted compiler.

Details:

Environment

None

Activity

Show:
Mike Fikes
November 9, 2018, 1:08 AM

CLJS-2865-5.patch rebaselines while also accommodating the changes in that are currently on master.

This revision of the patch passes CI, Canary, and shows no slowdown when compiling the Coal Mine corpus.

Mike Fikes
November 7, 2018, 1:40 PM

CLJS-2865-4.patch no longer applies

Mike Fikes
October 26, 2018, 12:52 PM

CLJS-2865-4.patch rebaselines

Mike Fikes
October 26, 2018, 12:41 PM

Patch no longer applies.

Completed

Assignee

David Nolen

Reporter

Mike Fikes

Approval

Accepted

Patch

Code and Test