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

Unified Diff: runtime/lib/growable_array.dart

Issue 2971303002: VM(CoreLib): Work around JIT optimization issue revealed by cec963f028198ec5871840491ba78b096ad0b819 (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/growable_array.dart
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart
index 463214700e356ba0810b9d7ba4294226272cf31c..917950aac726a8987eab184e38e4506ee6e857a5 100644
--- a/runtime/lib/growable_array.dart
+++ b/runtime/lib/growable_array.dart
@@ -234,16 +234,27 @@ class _GrowableList<T> extends ListBase<T> {
void _grow(int new_capacity) {
var newData = _allocateData(new_capacity);
- for (int i = 0; i < length; i++) {
- newData[i] = this[i];
+ // This is a work-around for dartbug.com/30090: array-bound-check
+ // generalization causes excessive deoptimizations because it
+ // hoists CheckArrayBound(i, ...) out of the loop below and turns it
+ // into CheckArrayBound(length - 1, ...). Which deoptimizes
+ // if length == 0. However the loop itself does not execute
+ // if length == 0.
+ if (length > 0) {
+ for (int i = 0; i < length; i++) {
+ newData[i] = this[i];
+ }
}
_setData(newData);
}
void _shrink(int new_capacity, int new_length) {
var newData = _allocateData(new_capacity);
- for (int i = 0; i < new_length; i++) {
- newData[i] = this[i];
+ // This is a work-around for dartbug.com/30090. See the comment in _grow.
+ if (new_length > 0) {
+ for (int i = 0; i < new_length; i++) {
+ newData[i] = this[i];
+ }
}
_setData(newData);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698