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

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

Issue 12263010: Optimize stores to ExternalUint8Array and ExternalUint8ClampedArray in the optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/intermediate_language_ia32.cc ('k') | tests/standalone/byte_array_test.dart » ('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) 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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 1136
1137 1137
1138 Representation StoreIndexedInstr::RequiredInputRepresentation( 1138 Representation StoreIndexedInstr::RequiredInputRepresentation(
1139 intptr_t idx) const { 1139 intptr_t idx) const {
1140 if ((idx == 0) || (idx == 1)) return kTagged; 1140 if ((idx == 0) || (idx == 1)) return kTagged;
1141 ASSERT(idx == 2); 1141 ASSERT(idx == 2);
1142 switch (class_id_) { 1142 switch (class_id_) {
1143 case kArrayCid: 1143 case kArrayCid:
1144 case kInt8ArrayCid: 1144 case kInt8ArrayCid:
1145 case kUint8ArrayCid: 1145 case kUint8ArrayCid:
1146 case kExternalUint8ArrayCid:
1146 case kUint8ClampedArrayCid: 1147 case kUint8ClampedArrayCid:
1148 case kExternalUint8ClampedArrayCid:
1147 case kInt16ArrayCid: 1149 case kInt16ArrayCid:
1148 case kUint16ArrayCid: 1150 case kUint16ArrayCid:
1149 case kInt32ArrayCid: 1151 case kInt32ArrayCid:
1150 case kUint32ArrayCid: 1152 case kUint32ArrayCid:
1151 return kTagged; 1153 return kTagged;
1152 case kFloat32ArrayCid : 1154 case kFloat32ArrayCid :
1153 case kFloat64ArrayCid : 1155 case kFloat64ArrayCid :
1154 return kUnboxedDouble; 1156 return kUnboxedDouble;
1155 default: 1157 default:
1156 UNIMPLEMENTED(); 1158 UNIMPLEMENTED();
(...skipping 13 matching lines...) Expand all
1170 locs->set_in(0, Location::RequiresRegister()); 1172 locs->set_in(0, Location::RequiresRegister());
1171 locs->set_in(1, CanBeImmediateIndex(index(), class_id()) 1173 locs->set_in(1, CanBeImmediateIndex(index(), class_id())
1172 ? Location::RegisterOrSmiConstant(index()) 1174 ? Location::RegisterOrSmiConstant(index())
1173 : Location::RequiresRegister()); 1175 : Location::RequiresRegister());
1174 switch (class_id()) { 1176 switch (class_id()) {
1175 case kArrayCid: 1177 case kArrayCid:
1176 locs->set_in(2, ShouldEmitStoreBarrier() 1178 locs->set_in(2, ShouldEmitStoreBarrier()
1177 ? Location::WritableRegister() 1179 ? Location::WritableRegister()
1178 : Location::RegisterOrConstant(value())); 1180 : Location::RegisterOrConstant(value()));
1179 break; 1181 break;
1182 case kExternalUint8ArrayCid:
1183 case kExternalUint8ClampedArrayCid:
1184 // Need temp register to load the external array's data array.
1185 locs->AddTemp(Location::RequiresRegister());
1186 // Fall through.
1180 case kInt8ArrayCid: 1187 case kInt8ArrayCid:
1181 case kUint8ArrayCid: 1188 case kUint8ArrayCid:
1182 case kUint8ClampedArrayCid: 1189 case kUint8ClampedArrayCid:
1183 // TODO(fschneider): Add location constraint for byte registers (RAX, 1190 // TODO(fschneider): Add location constraint for byte registers (RAX,
1184 // RBX, RCX, RDX) instead of using a fixed register. 1191 // RBX, RCX, RDX) instead of using a fixed register.
1185 locs->set_in(2, Location::FixedRegisterOrSmiConstant(value(), RAX)); 1192 locs->set_in(2, Location::FixedRegisterOrSmiConstant(value(), RAX));
1186 break; 1193 break;
1187 case kInt16ArrayCid: 1194 case kInt16ArrayCid:
1188 case kUint16ArrayCid: 1195 case kUint16ArrayCid:
1189 case kInt32ArrayCid: 1196 case kInt32ArrayCid:
(...skipping 15 matching lines...) Expand all
1205 } 1212 }
1206 return locs; 1213 return locs;
1207 } 1214 }
1208 1215
1209 1216
1210 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1217 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1211 Register array = locs()->in(0).reg(); 1218 Register array = locs()->in(0).reg();
1212 Location index = locs()->in(1); 1219 Location index = locs()->in(1);
1213 1220
1214 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id()); 1221 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id());
1215 1222 Address element_address(kNoRegister, 0);
1216 FieldAddress element_address = index.IsRegister() 1223 if ((class_id() == kExternalUint8ArrayCid) ||
1217 ? FlowGraphCompiler::ElementAddressForRegIndex( 1224 (class_id() == kExternalUint8ClampedArrayCid)) {
1218 class_id(), index_scale, array, index.reg()) 1225 Register temp = locs()->temp(0).reg();
1219 : FlowGraphCompiler::ElementAddressForIntIndex( 1226 element_address = index.IsRegister()
1220 class_id(), index_scale, array, 1227 ? FlowGraphCompiler::ExternalElementAddressForRegIndex(
1221 Smi::Cast(index.constant()).Value()); 1228 class_id(), index_scale, temp, index.reg())
1229 : FlowGraphCompiler::ExternalElementAddressForIntIndex(
1230 class_id(), index_scale, temp,
1231 Smi::Cast(index.constant()).Value());
1232 __ movq(temp,
1233 FieldAddress(array, ExternalUint8Array::data_offset()));
1234 } else {
1235 element_address = index.IsRegister()
1236 ? FlowGraphCompiler::ElementAddressForRegIndex(
1237 class_id(), index_scale, array, index.reg())
1238 : FlowGraphCompiler::ElementAddressForIntIndex(
1239 class_id(), index_scale, array,
1240 Smi::Cast(index.constant()).Value());
1241 }
1222 1242
1223 switch (class_id()) { 1243 switch (class_id()) {
1224 case kArrayCid: 1244 case kArrayCid:
1225 if (ShouldEmitStoreBarrier()) { 1245 if (ShouldEmitStoreBarrier()) {
1226 Register value = locs()->in(2).reg(); 1246 Register value = locs()->in(2).reg();
1227 __ StoreIntoObject(array, element_address, value); 1247 __ StoreIntoObject(array, element_address, value);
1228 } else if (locs()->in(2).IsConstant()) { 1248 } else if (locs()->in(2).IsConstant()) {
1229 const Object& constant = locs()->in(2).constant(); 1249 const Object& constant = locs()->in(2).constant();
1230 __ StoreObject(element_address, constant); 1250 __ StoreObject(element_address, constant);
1231 } else { 1251 } else {
1232 Register value = locs()->in(2).reg(); 1252 Register value = locs()->in(2).reg();
1233 __ StoreIntoObjectNoBarrier(array, element_address, value); 1253 __ StoreIntoObjectNoBarrier(array, element_address, value);
1234 } 1254 }
1235 break; 1255 break;
1236 case kInt8ArrayCid: 1256 case kInt8ArrayCid:
1237 case kUint8ArrayCid: 1257 case kUint8ArrayCid:
1258 case kExternalUint8ArrayCid:
1238 if (index.IsRegister()) { 1259 if (index.IsRegister()) {
1239 __ SmiUntag(index.reg()); 1260 __ SmiUntag(index.reg());
1240 } 1261 }
1241 if (locs()->in(2).IsConstant()) { 1262 if (locs()->in(2).IsConstant()) {
1242 const Smi& constant = Smi::Cast(locs()->in(2).constant()); 1263 const Smi& constant = Smi::Cast(locs()->in(2).constant());
1243 __ movb(element_address, 1264 __ movb(element_address,
1244 Immediate(static_cast<int8_t>(constant.Value()))); 1265 Immediate(static_cast<int8_t>(constant.Value())));
1245 } else { 1266 } else {
1246 ASSERT(locs()->in(2).reg() == RAX); 1267 ASSERT(locs()->in(2).reg() == RAX);
1247 __ SmiUntag(RAX); 1268 __ SmiUntag(RAX);
1248 __ movb(element_address, RAX); 1269 __ movb(element_address, RAX);
1249 } 1270 }
1250 if (index.IsRegister()) { 1271 if (index.IsRegister()) {
1251 __ SmiTag(index.reg()); // Re-tag. 1272 __ SmiTag(index.reg()); // Re-tag.
1252 } 1273 }
1253 break; 1274 break;
1254 case kUint8ClampedArrayCid: { 1275 case kUint8ClampedArrayCid:
1276 case kExternalUint8ClampedArrayCid: {
1255 if (index.IsRegister()) { 1277 if (index.IsRegister()) {
1256 __ SmiUntag(index.reg()); 1278 __ SmiUntag(index.reg());
1257 } 1279 }
1258 if (locs()->in(2).IsConstant()) { 1280 if (locs()->in(2).IsConstant()) {
1259 const Smi& constant = Smi::Cast(locs()->in(2).constant()); 1281 const Smi& constant = Smi::Cast(locs()->in(2).constant());
1260 intptr_t value = constant.Value(); 1282 intptr_t value = constant.Value();
1261 // Clamp to 0x0 or 0xFF respectively. 1283 // Clamp to 0x0 or 0xFF respectively.
1262 if (value > 0xFF) { 1284 if (value > 0xFF) {
1263 value = 0xFF; 1285 value = 0xFF;
1264 } else if (value < 0) { 1286 } else if (value < 0) {
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 PcDescriptors::kOther, 3068 PcDescriptors::kOther,
3047 locs()); 3069 locs());
3048 __ Drop(2); // Discard type arguments and receiver. 3070 __ Drop(2); // Discard type arguments and receiver.
3049 } 3071 }
3050 3072
3051 } // namespace dart 3073 } // namespace dart
3052 3074
3053 #undef __ 3075 #undef __
3054 3076
3055 #endif // defined TARGET_ARCH_X64 3077 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/standalone/byte_array_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698