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

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 12377082: Recognize more list factories. Recognizing list factories (Array, Bytearrays, etc) allows the type … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 case kFloat32ArrayCid: 1134 case kFloat32ArrayCid:
1135 case kFloat64ArrayCid: 1135 case kFloat64ArrayCid:
1136 return MethodRecognizer::kByteArrayBaseLength; 1136 return MethodRecognizer::kByteArrayBaseLength;
1137 default: 1137 default:
1138 UNREACHABLE(); 1138 UNREACHABLE();
1139 return MethodRecognizer::kUnknown; 1139 return MethodRecognizer::kUnknown;
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 1143
1144 bool LoadFieldInstr::IsFixedLengthArrayCid(intptr_t cid) {
1145 switch (cid) {
1146 case kArrayCid:
1147 case kImmutableArrayCid:
1148 case kInt8ArrayCid:
1149 case kUint8ArrayCid:
1150 case kUint8ClampedArrayCid:
1151 case kInt16ArrayCid:
1152 case kUint16ArrayCid:
1153 case kInt32ArrayCid:
1154 case kUint32ArrayCid:
1155 case kInt64ArrayCid:
1156 case kUint64ArrayCid:
1157 case kFloat32ArrayCid:
1158 case kFloat64ArrayCid:
1159 return true;
1160 default:
1161 return false;
1162 }
1163 }
1164
1165
1144 Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) { 1166 Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
1145 if (!IsImmutableLengthLoad()) return this; 1167 if (!IsImmutableLengthLoad()) return this;
1146 1168
1147 // For fixed length arrays if the array is the result of a known constructor 1169 // For fixed length arrays if the array is the result of a known constructor
1148 // call we can replace the length load with the length argument passed to 1170 // call we can replace the length load with the length argument passed to
1149 // the constructor. 1171 // the constructor.
1150 StaticCallInstr* call = value()->definition()->AsStaticCall(); 1172 StaticCallInstr* call = value()->definition()->AsStaticCall();
1151 if (call != NULL && 1173 if ((call != NULL) &&
1152 call->is_known_constructor() && 1174 call->is_known_list_constructor() &&
1153 (call->Type()->ToCid() == kArrayCid)) { 1175 IsFixedLengthArrayCid(call->Type()->ToCid())) {
1154 return call->ArgumentAt(1); 1176 return call->ArgumentAt(1);
1155 } 1177 }
1156 return this; 1178 return this;
1157 } 1179 }
1158 1180
1159 1181
1160 Definition* AssertBooleanInstr::Canonicalize(FlowGraphOptimizer* optimizer) { 1182 Definition* AssertBooleanInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
1161 if (FLAG_eliminate_type_checks && (value()->Type()->ToCid() == kBoolCid)) { 1183 if (FLAG_eliminate_type_checks && (value()->Type()->ToCid() == kBoolCid)) {
1162 return value()->definition(); 1184 return value()->definition();
1163 } 1185 }
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 2110
2089 // Inclusive. 2111 // Inclusive.
2090 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const { 2112 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const {
2091 if (min().LowerBound().value() < min_int) return false; 2113 if (min().LowerBound().value() < min_int) return false;
2092 if (max().UpperBound().value() > max_int) return false; 2114 if (max().UpperBound().value() > max_int) return false;
2093 return true; 2115 return true;
2094 } 2116 }
2095 2117
2096 2118
2097 bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) { 2119 bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) {
2098 switch (cid) { 2120 return LoadFieldInstr::IsFixedLengthArrayCid(cid);
2099 case kArrayCid:
2100 case kImmutableArrayCid:
2101 case kInt8ArrayCid:
2102 case kUint8ArrayCid:
2103 case kUint8ClampedArrayCid:
2104 case kInt16ArrayCid:
2105 case kUint16ArrayCid:
2106 case kInt32ArrayCid:
2107 case kUint32ArrayCid:
2108 case kInt64ArrayCid:
2109 case kUint64ArrayCid:
2110 case kFloat32ArrayCid:
2111 case kFloat64ArrayCid:
2112 return true;
2113 default:
2114 return false;
2115 }
2116 } 2121 }
2117 2122
2118 2123
2119 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { 2124 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) {
2120 // Check that array has an immutable length. 2125 // Check that array has an immutable length.
2121 if (!IsFixedLengthArrayType(array_type())) { 2126 if (!IsFixedLengthArrayType(array_type())) {
2122 return false; 2127 return false;
2123 } 2128 }
2124 2129
2125 Range* index_range = index()->definition()->range(); 2130 Range* index_range = index()->definition()->range();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 default: 2272 default:
2268 UNREACHABLE(); 2273 UNREACHABLE();
2269 } 2274 }
2270 return kPowRuntimeEntry; 2275 return kPowRuntimeEntry;
2271 } 2276 }
2272 2277
2273 2278
2274 #undef __ 2279 #undef __
2275 2280
2276 } // namespace dart 2281 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698