Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Issue 563973004: Call special VM interpolate for single element interpolation. (Closed)

Created:
6 years, 3 months ago by Lasse Reichstein Nielsen
Modified:
6 years, 3 months ago
Reviewers:
Florian Schneider
CC:
reviews_dartlang.org, vm-dev_dartlang.org, srdjan
Visibility:
Public.

Description

Call special VM interpolate for single element interpolation. Fixed at the intermediate language level. R=fschneider@google.com Committed: https://code.google.com/p/dart/source/detail?r=40232

Patch Set 1 #

Total comments: 10

Patch Set 2 : Address comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -5 lines) Patch
M runtime/lib/string_patch.dart View 1 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph_builder.cc View 1 1 chunk +10 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 2 chunks +5 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 2 chunks +26 lines, -1 line 0 comments Download
M runtime/vm/symbols.h View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 7 (1 generated)
Lasse Reichstein Nielsen
Attempt at optimizing single-element interpolation at the compiler-level. If this works, I can probably reduce ...
6 years, 3 months ago (2014-09-12 09:40:52 UTC) #2
Florian Schneider
LGTM. Please check that performance improvement for the single element case is as expected. https://codereview.chromium.org/563973004/diff/1/runtime/lib/string_patch.dart ...
6 years, 3 months ago (2014-09-12 10:33:37 UTC) #3
Lasse Reichstein Nielsen
Using the benchmark from the other CL, I get: Before: One-element interpolation ASCII: 3026.0 /ms ...
6 years, 3 months ago (2014-09-12 12:49:39 UTC) #4
Lasse Reichstein Nielsen
Committed patchset #2 (id:20001) manually as 40232 (presubmit successful).
6 years, 3 months ago (2014-09-15 07:19:31 UTC) #5
Ivan Posva
Do I read this CL correctly as: Dart developers do write s = "$myvalue"; instead ...
6 years, 3 months ago (2014-09-15 07:47:14 UTC) #6
Lasse Reichstein Nielsen
6 years, 3 months ago (2014-09-15 08:57:13 UTC) #7
Message was sent while issue was closed.
On 2014/09/15 07:47:14, Ivan Posva wrote:
> Do I read this CL correctly as:
> 
> Dart developers do write
> s = "$myvalue";
> 
> instead of
> s = myvalue.toString();

Yes. The former is shorter and safer (checks that the result is actually a
String).
There is no reason not to use it, except if it's implemented inefficiently, and
there is no reason to expect it to be so (or at least not to stay so).

> Except that in the second case we can optimize the toString() call based on
the
> dynamic type of the myvalue object at the call site. While in the string
> interpolation case the type feedback gets thrown under the bus because the
> toString() call in String._interpolateSingle becomes megamorphic?

Developers in general can't be expected to know the internals of the compiler.
The expression "$myvalue" is a very simple part of the core language, and I'd
not blame a developer for assuming that it is well optimized.

The current implementation goes megamorphic because it always calls a helper
function.
This CL just does away with a lot of unnecessary extra work for the one-element
case, but it doesn't avoid the megamorphism.
There is no reason why "$x" could not be optimized to be as efficient as an
inlined version of _interpolateSingle. All the information is available at the
call-site.

Powered by Google App Engine
This is Rietveld 408576698