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

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

Issue 11967012: Optimized loads/stores for scalar list: Uint8Clamped, Int8, Int16, Uint16. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 years, 11 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
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/flow_graph_compiler_ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/cha.h" 9 #include "vm/cha.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 1034
1035 intptr_t FlowGraphCompiler::ElementSizeFor(intptr_t cid) { 1035 intptr_t FlowGraphCompiler::ElementSizeFor(intptr_t cid) {
1036 switch (cid) { 1036 switch (cid) {
1037 case kArrayCid: 1037 case kArrayCid:
1038 case kImmutableArrayCid: 1038 case kImmutableArrayCid:
1039 return Array::kBytesPerElement; 1039 return Array::kBytesPerElement;
1040 case kFloat32ArrayCid: 1040 case kFloat32ArrayCid:
1041 return Float32Array::kBytesPerElement; 1041 return Float32Array::kBytesPerElement;
1042 case kFloat64ArrayCid: 1042 case kFloat64ArrayCid:
1043 return Float64Array::kBytesPerElement; 1043 return Float64Array::kBytesPerElement;
1044 case kInt8ArrayCid:
1045 return Int8Array::kBytesPerElement;
1044 case kUint8ArrayCid: 1046 case kUint8ArrayCid:
1045 return Uint8Array::kBytesPerElement; 1047 return Uint8Array::kBytesPerElement;
1046 case kUint8ClampedArrayCid: 1048 case kUint8ClampedArrayCid:
1047 return Uint8ClampedArray::kBytesPerElement; 1049 return Uint8ClampedArray::kBytesPerElement;
1050 case kInt16ArrayCid:
1051 return Int16Array::kBytesPerElement;
1052 case kUint16ArrayCid:
1053 return Uint16Array::kBytesPerElement;
1048 case kOneByteStringCid: 1054 case kOneByteStringCid:
1049 return OneByteString::kBytesPerElement; 1055 return OneByteString::kBytesPerElement;
1050 case kTwoByteStringCid: 1056 case kTwoByteStringCid:
1051 return TwoByteString::kBytesPerElement; 1057 return TwoByteString::kBytesPerElement;
1058 case kExternalUint8ArrayCid:
1059 return ExternalUint8Array::kBytesPerElement;
1052 default: 1060 default:
1053 UNIMPLEMENTED(); 1061 UNIMPLEMENTED();
1054 return 0; 1062 return 0;
1055 } 1063 }
1056 } 1064 }
1057 1065
1058 1066
1059 intptr_t FlowGraphCompiler::DataOffsetFor(intptr_t cid) { 1067 intptr_t FlowGraphCompiler::DataOffsetFor(intptr_t cid) {
1060 switch (cid) { 1068 switch (cid) {
1061 case kArrayCid: 1069 case kArrayCid:
1062 case kImmutableArrayCid: 1070 case kImmutableArrayCid:
1063 return Array::data_offset(); 1071 return Array::data_offset();
1064 case kFloat32ArrayCid: 1072 case kFloat32ArrayCid:
1065 return Float32Array::data_offset(); 1073 return Float32Array::data_offset();
1066 case kFloat64ArrayCid: 1074 case kFloat64ArrayCid:
1067 return Float64Array::data_offset(); 1075 return Float64Array::data_offset();
1076 case kInt8ArrayCid:
1077 return Int8Array::data_offset();
1068 case kUint8ArrayCid: 1078 case kUint8ArrayCid:
1069 return Uint8Array::data_offset(); 1079 return Uint8Array::data_offset();
1070 case kUint8ClampedArrayCid: 1080 case kUint8ClampedArrayCid:
1071 return Uint8ClampedArray::data_offset(); 1081 return Uint8ClampedArray::data_offset();
1082 case kInt16ArrayCid:
1083 return Int16Array::data_offset();
1084 case kUint16ArrayCid:
1085 return Uint16Array::data_offset();
1072 case kOneByteStringCid: 1086 case kOneByteStringCid:
1073 return OneByteString::data_offset(); 1087 return OneByteString::data_offset();
1074 case kTwoByteStringCid: 1088 case kTwoByteStringCid:
1075 return TwoByteString::data_offset(); 1089 return TwoByteString::data_offset();
1076 default: 1090 default:
1077 UNIMPLEMENTED(); 1091 UNIMPLEMENTED();
1078 return Array::data_offset(); 1092 return Array::data_offset();
1079 } 1093 }
1080 } 1094 }
1081 1095
(...skipping 17 matching lines...) Expand all
1099 ASSERT(kSmiTagShift == 1); 1113 ASSERT(kSmiTagShift == 1);
1100 switch (cid) { 1114 switch (cid) {
1101 case kArrayCid: 1115 case kArrayCid:
1102 case kImmutableArrayCid: 1116 case kImmutableArrayCid:
1103 return FieldAddress( 1117 return FieldAddress(
1104 array, index, TIMES_HALF_WORD_SIZE, Array::data_offset()); 1118 array, index, TIMES_HALF_WORD_SIZE, Array::data_offset());
1105 case kFloat32ArrayCid: 1119 case kFloat32ArrayCid:
1106 return FieldAddress(array, index, TIMES_2, Float32Array::data_offset()); 1120 return FieldAddress(array, index, TIMES_2, Float32Array::data_offset());
1107 case kFloat64ArrayCid: 1121 case kFloat64ArrayCid:
1108 return FieldAddress(array, index, TIMES_4, Float64Array::data_offset()); 1122 return FieldAddress(array, index, TIMES_4, Float64Array::data_offset());
1123 case kInt8ArrayCid:
1124 return FieldAddress(array, index, TIMES_1, Int8Array::data_offset());
1109 case kUint8ArrayCid: 1125 case kUint8ArrayCid:
1110 return FieldAddress(array, index, TIMES_1, Uint8Array::data_offset()); 1126 return FieldAddress(array, index, TIMES_1, Uint8Array::data_offset());
1111 case kUint8ClampedArrayCid: 1127 case kUint8ClampedArrayCid:
1112 return 1128 return
1113 FieldAddress(array, index, TIMES_1, Uint8ClampedArray::data_offset()); 1129 FieldAddress(array, index, TIMES_1, Uint8ClampedArray::data_offset());
1130 case kInt16ArrayCid:
1131 return FieldAddress(array, index, TIMES_1, Int16Array::data_offset());
1132 case kUint16ArrayCid:
1133 return FieldAddress(array, index, TIMES_1, Uint16Array::data_offset());
1114 case kOneByteStringCid: 1134 case kOneByteStringCid:
1115 return FieldAddress(array, index, TIMES_1, OneByteString::data_offset()); 1135 return FieldAddress(array, index, TIMES_1, OneByteString::data_offset());
1116 case kTwoByteStringCid: 1136 case kTwoByteStringCid:
1117 return FieldAddress(array, index, TIMES_1, TwoByteString::data_offset()); 1137 return FieldAddress(array, index, TIMES_1, TwoByteString::data_offset());
1118 default: 1138 default:
1119 UNIMPLEMENTED(); 1139 UNIMPLEMENTED();
1120 return FieldAddress(SPREG, 0); 1140 return FieldAddress(SPREG, 0);
1121 } 1141 }
1122 } 1142 }
1123 1143
1124 1144
1145 Address FlowGraphCompiler::ExternalElementAddressForIntIndex(intptr_t cid,
1146 Register array,
1147 intptr_t index) {
1148 return Address(array, index * ElementSizeFor(cid));
1149 }
1150
1151
1152 Address FlowGraphCompiler::ExternalElementAddressForRegIndex(intptr_t cid,
1153 Register array,
1154 Register index) {
1155 switch (cid) {
1156 case kExternalUint8ArrayCid:
1157 return Address(array, index, TIMES_1, 0);
1158 default:
1159 UNIMPLEMENTED();
1160 return Address(SPREG, 0);
1161 }
1162 }
1163
1164
1125 // Returns true if checking against this type is a direct class id comparison. 1165 // Returns true if checking against this type is a direct class id comparison.
1126 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) { 1166 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) {
1127 ASSERT(type.IsFinalized() && !type.IsMalformed()); 1167 ASSERT(type.IsFinalized() && !type.IsMalformed());
1128 // Requires CHA, which can be applied in optimized code only, 1168 // Requires CHA, which can be applied in optimized code only,
1129 if (!FLAG_use_cha || !is_optimizing()) return false; 1169 if (!FLAG_use_cha || !is_optimizing()) return false;
1130 if (!type.IsInstantiated()) return false; 1170 if (!type.IsInstantiated()) return false;
1131 const Class& type_class = Class::Handle(type.type_class()); 1171 const Class& type_class = Class::Handle(type.type_class());
1132 // Signature classes have different type checking rules. 1172 // Signature classes have different type checking rules.
1133 if (type_class.IsSignatureClass()) return false; 1173 if (type_class.IsSignatureClass()) return false;
1134 // Could be an interface check? 1174 // Could be an interface check?
1135 if (type_class.is_implemented()) return false; 1175 if (type_class.is_implemented()) return false;
1136 const intptr_t type_cid = type_class.id(); 1176 const intptr_t type_cid = type_class.id();
1137 if (CHA::HasSubclasses(type_cid)) return false; 1177 if (CHA::HasSubclasses(type_cid)) return false;
1138 if (type_class.HasTypeArguments()) { 1178 if (type_class.HasTypeArguments()) {
1139 // Only raw types can be directly compared, thus disregarding type 1179 // Only raw types can be directly compared, thus disregarding type
1140 // arguments. 1180 // arguments.
1141 const AbstractTypeArguments& type_arguments = 1181 const AbstractTypeArguments& type_arguments =
1142 AbstractTypeArguments::Handle(type.arguments()); 1182 AbstractTypeArguments::Handle(type.arguments());
1143 const bool is_raw_type = type_arguments.IsNull() || 1183 const bool is_raw_type = type_arguments.IsNull() ||
1144 type_arguments.IsRaw(type_arguments.Length()); 1184 type_arguments.IsRaw(type_arguments.Length());
1145 return is_raw_type; 1185 return is_raw_type;
1146 } 1186 }
1147 return true; 1187 return true;
1148 } 1188 }
1149 1189
1150 } // namespace dart 1190 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/flow_graph_compiler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698