OLD | NEW |
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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 return; | 1203 return; |
1204 } | 1204 } |
1205 | 1205 |
1206 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1206 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
1207 __ movl(result, element_address); | 1207 __ movl(result, element_address); |
1208 } | 1208 } |
1209 | 1209 |
1210 | 1210 |
1211 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { | 1211 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
1212 const intptr_t kNumInputs = 3; | 1212 const intptr_t kNumInputs = 3; |
1213 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0; | 1213 const intptr_t kNumTemps = 0; |
1214 LocationSummary* locs = | 1214 LocationSummary* locs = |
1215 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1215 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1216 if (class_id() == kFloat32ArrayCid) { | |
1217 locs->set_temp(0, Location::RequiresXmmRegister()); | |
1218 } | |
1219 locs->set_in(0, Location::RequiresRegister()); | 1216 locs->set_in(0, Location::RequiresRegister()); |
1220 locs->set_in(1, CanBeImmediateIndex(index()) | 1217 locs->set_in(1, CanBeImmediateIndex(index()) |
1221 ? Location::RegisterOrConstant(index()) | 1218 ? Location::RegisterOrConstant(index()) |
1222 : Location::RequiresRegister()); | 1219 : Location::RequiresRegister()); |
1223 if (RequiredInputRepresentation(2) == kUnboxedDouble) { | 1220 switch (class_id()) { |
1224 // TODO(srdjan): Support Float64 constants. | 1221 case kArrayCid: |
1225 locs->set_in(2, Location::RequiresXmmRegister()); | 1222 locs->set_in(2, ShouldEmitStoreBarrier() |
1226 } else { | 1223 ? Location::WritableRegister() |
1227 locs->set_in(2, ShouldEmitStoreBarrier() | 1224 : Location::RegisterOrConstant(value())); |
1228 ? Location::WritableRegister() | 1225 break; |
1229 : Location::RegisterOrConstant(value())); | 1226 case kUint8ArrayCid: |
| 1227 // TODO(fschneider): Add location constraint for byte registers (EAX, |
| 1228 // EBX, ECX, EDX) instead of using a fixed register. |
| 1229 locs->set_in(2, Location::FixedRegisterOrSmiConstant(value(), EAX)); |
| 1230 break; |
| 1231 case kFloat32ArrayCid: |
| 1232 // Need temp register for float-to-double conversion. |
| 1233 locs->AddTemp(Location::RequiresXmmRegister()); |
| 1234 // Fall through. |
| 1235 case kFloat64ArrayCid: |
| 1236 // TODO(srdjan): Support Float64 constants. |
| 1237 locs->set_in(2, Location::RequiresXmmRegister()); |
| 1238 break; |
| 1239 default: |
| 1240 UNREACHABLE(); |
| 1241 return NULL; |
1230 } | 1242 } |
1231 return locs; | 1243 return locs; |
1232 } | 1244 } |
1233 | 1245 |
1234 | 1246 |
1235 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1247 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1236 Register array = locs()->in(0).reg(); | 1248 Register array = locs()->in(0).reg(); |
1237 Location index = locs()->in(1); | 1249 Location index = locs()->in(1); |
1238 | 1250 |
1239 FieldAddress element_address = index.IsRegister() ? | 1251 FieldAddress element_address = index.IsRegister() ? |
1240 FlowGraphCompiler::ElementAddressForRegIndex( | 1252 FlowGraphCompiler::ElementAddressForRegIndex( |
1241 class_id(), array, index.reg()) : | 1253 class_id(), array, index.reg()) : |
1242 FlowGraphCompiler::ElementAddressForIntIndex( | 1254 FlowGraphCompiler::ElementAddressForIntIndex( |
1243 class_id(), array, Smi::Cast(index.constant()).Value()); | 1255 class_id(), array, Smi::Cast(index.constant()).Value()); |
1244 | 1256 |
1245 if (class_id() == kFloat32ArrayCid) { | 1257 switch (class_id()) { |
1246 // Convert to single precision. | 1258 case kArrayCid: |
1247 __ cvtsd2ss(locs()->temp(0).xmm_reg(), locs()->in(2).xmm_reg()); | 1259 if (ShouldEmitStoreBarrier()) { |
1248 // Store. | 1260 Register value = locs()->in(2).reg(); |
1249 __ movss(element_address, locs()->temp(0).xmm_reg()); | 1261 __ StoreIntoObject(array, element_address, value); |
1250 return; | 1262 } else if (locs()->in(2).IsConstant()) { |
1251 } | 1263 const Object& constant = locs()->in(2).constant(); |
1252 | 1264 __ StoreIntoObjectNoBarrier(array, element_address, constant); |
1253 if (class_id() == kFloat64ArrayCid) { | 1265 } else { |
1254 __ movsd(element_address, locs()->in(2).xmm_reg()); | 1266 Register value = locs()->in(2).reg(); |
1255 return; | 1267 __ StoreIntoObjectNoBarrier(array, element_address, value); |
1256 } | 1268 } |
1257 | 1269 break; |
1258 ASSERT(class_id() == kArrayCid); | 1270 case kUint8ArrayCid: |
1259 if (ShouldEmitStoreBarrier()) { | 1271 if (index.IsRegister()) { |
1260 Register value = locs()->in(2).reg(); | 1272 __ SmiUntag(index.reg()); |
1261 __ StoreIntoObject(array, element_address, value); | 1273 } |
1262 return; | 1274 if (locs()->in(2).IsConstant()) { |
1263 } | 1275 const Smi& constant = Smi::Cast(locs()->in(2).constant()); |
1264 | 1276 __ movb(element_address, |
1265 if (locs()->in(2).IsConstant()) { | 1277 Immediate(static_cast<int8_t>(constant.Value()))); |
1266 const Object& constant = locs()->in(2).constant(); | 1278 } else { |
1267 __ StoreIntoObjectNoBarrier(array, element_address, constant); | 1279 ASSERT(locs()->in(2).reg() == EAX); |
1268 } else { | 1280 __ SmiUntag(EAX); |
1269 Register value = locs()->in(2).reg(); | 1281 __ movb(element_address, AL); |
1270 __ StoreIntoObjectNoBarrier(array, element_address, value); | 1282 } |
| 1283 if (index.IsRegister()) { |
| 1284 __ SmiTag(index.reg()); // Re-tag. |
| 1285 } |
| 1286 break; |
| 1287 case kFloat32ArrayCid: |
| 1288 // Convert to single precision. |
| 1289 __ cvtsd2ss(locs()->temp(0).xmm_reg(), locs()->in(2).xmm_reg()); |
| 1290 // Store. |
| 1291 __ movss(element_address, locs()->temp(0).xmm_reg()); |
| 1292 break; |
| 1293 case kFloat64ArrayCid: |
| 1294 __ movsd(element_address, locs()->in(2).xmm_reg()); |
| 1295 break; |
| 1296 default: |
| 1297 UNREACHABLE(); |
1271 } | 1298 } |
1272 } | 1299 } |
1273 | 1300 |
1274 | 1301 |
1275 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const { | 1302 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary() const { |
1276 const intptr_t kNumInputs = 2; | 1303 const intptr_t kNumInputs = 2; |
1277 const intptr_t num_temps = 0; | 1304 const intptr_t num_temps = 0; |
1278 LocationSummary* summary = | 1305 LocationSummary* summary = |
1279 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); | 1306 new LocationSummary(kNumInputs, num_temps, LocationSummary::kNoCall); |
1280 summary->set_in(0, Location::RequiresRegister()); | 1307 summary->set_in(0, Location::RequiresRegister()); |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2798 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. | 2825 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. |
2799 __ pxor(value, XMM0); | 2826 __ pxor(value, XMM0); |
2800 } | 2827 } |
2801 | 2828 |
2802 | 2829 |
2803 } // namespace dart | 2830 } // namespace dart |
2804 | 2831 |
2805 #undef __ | 2832 #undef __ |
2806 | 2833 |
2807 #endif // defined TARGET_ARCH_X64 | 2834 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |