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

Issue 11360033: Inline native String.charCodeAt in optimized code. (Closed)

Created:
8 years, 1 month ago by Florian Schneider
Modified:
8 years, 1 month ago
Reviewers:
srdjan
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Inline native String.charCodeAt in optimized code and fix a bounds-check bug. Introduce a new IL instruction that does charCodeAt from 1- and 2-byte character strings. The existing CheckArrayBound instructions is extended to be used for string bounds checking. Also fix a bug with a missing compile-time bounds-check on constant arrays. TEST=tests/language/optimized_string_charcodeat.dart, tests/language/optimized_constant_array_string_access.dart Committed: https://code.google.com/p/dart/source/detail?r=14441

Patch Set 1 #

Patch Set 2 : added test and fixed typo bug for 2-byte strings #

Patch Set 3 : fixed a bug in indexed ops and added more tests #

Total comments: 8

Patch Set 4 : addressed comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+347 lines, -52 lines) Patch
M runtime/vm/code_generator.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/flow_graph_optimizer.cc View 1 2 3 3 chunks +59 lines, -4 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 5 chunks +42 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 3 chunks +37 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 3 3 chunks +53 lines, -24 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 3 3 chunks +53 lines, -24 lines 0 comments Download
M runtime/vm/object.h View 1 1 chunk +2 lines, -0 lines 0 comments Download
A tests/language/optimized_constant_array_string_access.dart View 1 2 3 1 chunk +49 lines, -0 lines 0 comments Download
A tests/language/optimized_string_charcodeat.dart View 1 2 1 chunk +51 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Florian Schneider
8 years, 1 month ago (2012-11-01 20:05:05 UTC) #1
srdjan
LGTM with comments https://codereview.chromium.org/11360033/diff/6003/runtime/vm/flow_graph_optimizer.cc File runtime/vm/flow_graph_optimizer.cc (right): https://codereview.chromium.org/11360033/diff/6003/runtime/vm/flow_graph_optimizer.cc#newcode483 runtime/vm/flow_graph_optimizer.cc:483: } I get a crash with ...
8 years, 1 month ago (2012-11-01 20:32:18 UTC) #2
Florian Schneider
8 years, 1 month ago (2012-11-01 22:58:55 UTC) #3
Landed. Thanks for the review.

http://codereview.chromium.org/11360033/diff/6003/runtime/vm/flow_graph_optim...
File runtime/vm/flow_graph_optimizer.cc (right):

http://codereview.chromium.org/11360033/diff/6003/runtime/vm/flow_graph_optim...
runtime/vm/flow_graph_optimizer.cc:483: }
On 2012/11/01 20:32:18, srdjan wrote:
> I get a crash with following code. Can you please check if it works and add it
> to your tests:
> 
> main() {
>   for (int i = 0; i < 10000; i++) { foo(1); }
>   foo(2);
> }
> 
> foo(a) {
>   if (a == 1) { return 2; }
>   var aa = const [1, 2];
>   return aa[2.3];
> }

Good point. I added the test and fixed the non-smi index case for strings and
arrays.

http://codereview.chromium.org/11360033/diff/6003/runtime/vm/intermediate_lan...
File runtime/vm/intermediate_language_ia32.cc (right):

http://codereview.chromium.org/11360033/diff/6003/runtime/vm/intermediate_lan...
runtime/vm/intermediate_language_ia32.cc:1110: __ SmiUntag(index);
On 2012/11/01 20:32:18, srdjan wrote:
> Is it better to tag/untag or to require a temporary? 

With a quick test, I found no noticable difference. On ia32 I always try to
minimize the number of temps. In many cases a temp would require an additional
mov-instruction which is why the difference will probably small if at all.

http://codereview.chromium.org/11360033/diff/6003/tests/language/optimized_co...
File tests/language/optimized_constant_array_string_access.dart (right):

http://codereview.chromium.org/11360033/diff/6003/tests/language/optimized_co...
tests/language/optimized_constant_array_string_access.dart:15: } catch(e) { }
On 2012/11/01 20:32:18, srdjan wrote:
> You may want to use Expect.throws instead.

Done.

http://codereview.chromium.org/11360033/diff/6003/tests/language/optimized_co...
tests/language/optimized_constant_array_string_access.dart:18: return
test(true);
On 2012/11/01 20:32:18, srdjan wrote:
> ditto and below

Done.

Powered by Google App Engine
This is Rietveld 408576698