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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/ssa/types.dart

Issue 11280183: Grow type map exponentially. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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: dart/sdk/lib/_internal/compiler/implementation/ssa/types.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/ssa/types.dart b/dart/sdk/lib/_internal/compiler/implementation/ssa/types.dart
index 1974f8122e14b8c791e5804b1f58029eb305ff61..52a20e787d1ff747740bf137d3e3d5d6bb6bd75b 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/ssa/types.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/ssa/types.dart
@@ -929,7 +929,11 @@ class HBoundedPotentialPrimitiveString extends HBoundedPotentialPrimitiveType {
}
class HTypeMap {
- List<HType> _list = new List<HType>();
+ // Approximately 85% of methods in the sample "swarm" have less than
+ // 32 instructions.
+ static const int INITIAL_SIZE = 32;
+
+ List<HType> _list = new List<HType>()..length = INITIAL_SIZE;
operator [](HInstruction instruction) {
HType result;
@@ -939,9 +943,15 @@ class HTypeMap {
}
operator []=(HInstruction instruction, HType value) {
- if (_list.length <= instruction.id) {
- _list.length = instruction.id + 1;
+ int length = _list.length;
+ int id = instruction.id;
+ if (length <= id) {
+ if (id + 1 < length * 2) {
+ _list.length = length * 2;
+ } else {
+ _list.length = id + 1;
+ }
}
- _list[instruction.id] = value;
+ _list[id] = value;
}
}
« 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