OLD | NEW |
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_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 "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 } | 1202 } |
1203 break; | 1203 break; |
1204 default: | 1204 default: |
1205 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1205 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
1206 __ movl(result, element_address); | 1206 __ movl(result, element_address); |
1207 break; | 1207 break; |
1208 } | 1208 } |
1209 } | 1209 } |
1210 | 1210 |
1211 | 1211 |
| 1212 Representation LoadCodeUnitsInstr::representation() const { |
| 1213 switch (class_id()) { |
| 1214 case kOneByteStringCid: |
| 1215 case kExternalOneByteStringCid: |
| 1216 case kTwoByteStringCid: |
| 1217 case kExternalTwoByteStringCid: |
| 1218 // TODO(jgruber): kUnboxedUint32 could be a better choice. |
| 1219 return can_pack_into_smi() ? kTagged : kUnboxedMint; |
| 1220 default: |
| 1221 UNIMPLEMENTED(); |
| 1222 return kTagged; |
| 1223 } |
| 1224 } |
| 1225 |
| 1226 |
| 1227 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, |
| 1228 bool opt) const { |
| 1229 const intptr_t kNumInputs = 2; |
| 1230 const intptr_t kNumTemps = 0; |
| 1231 LocationSummary* summary = new(isolate) LocationSummary( |
| 1232 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1233 summary->set_in(0, Location::RequiresRegister()); |
| 1234 // The smi index is either untagged (element size == 1), or it is left smi |
| 1235 // tagged (for all element sizes > 1). |
| 1236 summary->set_in(1, (index_scale() == 1) ? Location::WritableRegister() |
| 1237 : Location::RequiresRegister()); |
| 1238 |
| 1239 if (representation() == kUnboxedMint) { |
| 1240 summary->set_out(0, Location::Pair(Location::RequiresRegister(), |
| 1241 Location::RequiresRegister())); |
| 1242 } else { |
| 1243 ASSERT(representation() == kTagged); |
| 1244 summary->set_out(0, Location::RequiresRegister()); |
| 1245 } |
| 1246 |
| 1247 return summary; |
| 1248 } |
| 1249 |
| 1250 |
| 1251 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1252 const Register array = locs()->in(0).reg(); |
| 1253 const Location index = locs()->in(1); |
| 1254 |
| 1255 Address element_address = Assembler::ElementAddressForRegIndex( |
| 1256 IsExternal(), class_id(), index_scale(), array, index.reg()); |
| 1257 |
| 1258 if ((index_scale() == 1)) { |
| 1259 __ SmiUntag(index.reg()); |
| 1260 } |
| 1261 |
| 1262 if (representation() == kUnboxedMint) { |
| 1263 ASSERT(locs()->out(0).IsPairLocation()); |
| 1264 PairLocation* result_pair = locs()->out(0).AsPairLocation(); |
| 1265 Register result1 = result_pair->At(0).reg(); |
| 1266 Register result2 = result_pair->At(1).reg(); |
| 1267 switch (class_id()) { |
| 1268 case kOneByteStringCid: |
| 1269 case kExternalOneByteStringCid: |
| 1270 ASSERT(element_count() == 4); |
| 1271 __ movl(result1, element_address); |
| 1272 __ xorl(result2, result2); |
| 1273 break; |
| 1274 case kTwoByteStringCid: |
| 1275 case kExternalTwoByteStringCid: |
| 1276 ASSERT(element_count() == 2); |
| 1277 __ movl(result1, element_address); |
| 1278 __ xorl(result2, result2); |
| 1279 break; |
| 1280 default: |
| 1281 UNREACHABLE(); |
| 1282 } |
| 1283 } else { |
| 1284 ASSERT(representation() == kTagged); |
| 1285 Register result = locs()->out(0).reg(); |
| 1286 switch (class_id()) { |
| 1287 case kOneByteStringCid: |
| 1288 case kExternalOneByteStringCid: |
| 1289 switch (element_count()) { |
| 1290 case 1: __ movzxb(result, element_address); break; |
| 1291 case 2: __ movzxw(result, element_address); break; |
| 1292 default: UNREACHABLE(); |
| 1293 } |
| 1294 __ SmiTag(result); |
| 1295 break; |
| 1296 case kTwoByteStringCid: |
| 1297 case kExternalTwoByteStringCid: |
| 1298 switch (element_count()) { |
| 1299 case 1: __ movzxw(result, element_address); break; |
| 1300 default: UNREACHABLE(); |
| 1301 } |
| 1302 __ SmiTag(result); |
| 1303 break; |
| 1304 default: |
| 1305 UNREACHABLE(); |
| 1306 break; |
| 1307 } |
| 1308 } |
| 1309 } |
| 1310 |
| 1311 |
1212 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1312 Representation StoreIndexedInstr::RequiredInputRepresentation( |
1213 intptr_t idx) const { | 1313 intptr_t idx) const { |
1214 // Array can be a Dart object or a pointer to external data. | 1314 // Array can be a Dart object or a pointer to external data. |
1215 if (idx == 0) return kNoRepresentation; // Flexible input representation. | 1315 if (idx == 0) return kNoRepresentation; // Flexible input representation. |
1216 if (idx == 1) return kTagged; // Index is a smi. | 1316 if (idx == 1) return kTagged; // Index is a smi. |
1217 ASSERT(idx == 2); | 1317 ASSERT(idx == 2); |
1218 switch (class_id_) { | 1318 switch (class_id_) { |
1219 case kArrayCid: | 1319 case kArrayCid: |
1220 case kOneByteStringCid: | 1320 case kOneByteStringCid: |
1221 case kTypedDataInt8ArrayCid: | 1321 case kTypedDataInt8ArrayCid: |
(...skipping 3457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4679 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); | 4779 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); |
4680 __ CallRuntime(TargetFunction(), InputCount()); | 4780 __ CallRuntime(TargetFunction(), InputCount()); |
4681 __ fstpl(Address(ESP, 0)); | 4781 __ fstpl(Address(ESP, 0)); |
4682 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); | 4782 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); |
4683 // Restore ESP. | 4783 // Restore ESP. |
4684 __ movl(ESP, locs()->temp(0).reg()); | 4784 __ movl(ESP, locs()->temp(0).reg()); |
4685 } | 4785 } |
4686 } | 4786 } |
4687 | 4787 |
4688 | 4788 |
| 4789 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
| 4790 Isolate* isolate, bool opt) const { |
| 4791 const intptr_t kNumTemps = 0; |
| 4792 LocationSummary* summary = new(isolate) LocationSummary( |
| 4793 isolate, InputCount(), kNumTemps, LocationSummary::kCall); |
| 4794 summary->set_in(0, Location::RegisterLocation(EAX)); |
| 4795 summary->set_in(1, Location::RegisterLocation(ECX)); |
| 4796 summary->set_in(2, Location::RegisterLocation(EDX)); |
| 4797 summary->set_in(3, Location::RegisterLocation(EBX)); |
| 4798 summary->set_out(0, Location::RegisterLocation(EAX)); |
| 4799 return summary; |
| 4800 } |
| 4801 |
| 4802 |
| 4803 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( |
| 4804 FlowGraphCompiler* compiler) { |
| 4805 |
| 4806 // Save ESP. EDI is chosen because it is callee saved so we do not need to |
| 4807 // back it up before calling into the runtime. |
| 4808 static const Register kSavedSPReg = EDI; |
| 4809 __ movl(kSavedSPReg, ESP); |
| 4810 __ ReserveAlignedFrameSpace(kWordSize * TargetFunction().argument_count()); |
| 4811 |
| 4812 __ movl(Address(ESP, + 0 * kWordSize), locs()->in(0).reg()); |
| 4813 __ movl(Address(ESP, + 1 * kWordSize), locs()->in(1).reg()); |
| 4814 __ movl(Address(ESP, + 2 * kWordSize), locs()->in(2).reg()); |
| 4815 __ movl(Address(ESP, + 3 * kWordSize), locs()->in(3).reg()); |
| 4816 |
| 4817 // Call the function. |
| 4818 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); |
| 4819 |
| 4820 // Restore ESP. |
| 4821 __ movl(ESP, kSavedSPReg); |
| 4822 } |
| 4823 |
| 4824 |
4689 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 4825 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
4690 bool opt) const { | 4826 bool opt) const { |
4691 if (result_cid() == kDoubleCid) { | 4827 if (result_cid() == kDoubleCid) { |
4692 const intptr_t kNumInputs = 2; | 4828 const intptr_t kNumInputs = 2; |
4693 const intptr_t kNumTemps = 1; | 4829 const intptr_t kNumTemps = 1; |
4694 LocationSummary* summary = new(isolate) LocationSummary( | 4830 LocationSummary* summary = new(isolate) LocationSummary( |
4695 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4831 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
4696 summary->set_in(0, Location::RequiresFpuRegister()); | 4832 summary->set_in(0, Location::RequiresFpuRegister()); |
4697 summary->set_in(1, Location::RequiresFpuRegister()); | 4833 summary->set_in(1, Location::RequiresFpuRegister()); |
4698 // Reuse the left register so that code can be made shorter. | 4834 // Reuse the left register so that code can be made shorter. |
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6514 } | 6650 } |
6515 | 6651 |
6516 // We can fall through if the successor is the next block in the list. | 6652 // We can fall through if the successor is the next block in the list. |
6517 // Otherwise, we need a jump. | 6653 // Otherwise, we need a jump. |
6518 if (!compiler->CanFallThroughTo(successor())) { | 6654 if (!compiler->CanFallThroughTo(successor())) { |
6519 __ jmp(compiler->GetJumpLabel(successor())); | 6655 __ jmp(compiler->GetJumpLabel(successor())); |
6520 } | 6656 } |
6521 } | 6657 } |
6522 | 6658 |
6523 | 6659 |
| 6660 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, |
| 6661 bool opt) const { |
| 6662 const intptr_t kNumInputs = 1; |
| 6663 const intptr_t kNumTemps = 1; |
| 6664 |
| 6665 LocationSummary* summary = new(isolate) LocationSummary( |
| 6666 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 6667 |
| 6668 summary->set_in(0, Location::RequiresRegister()); |
| 6669 summary->set_temp(0, Location::RequiresRegister()); |
| 6670 |
| 6671 return summary; |
| 6672 } |
| 6673 |
| 6674 |
| 6675 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6676 Register target_address_reg = locs()->temp_slot(0)->reg(); |
| 6677 |
| 6678 // Load from [current frame pointer] + kPcMarkerSlotFromFp. |
| 6679 __ movl(target_address_reg, Address(EBP, kPcMarkerSlotFromFp * kWordSize)); |
| 6680 |
| 6681 // Add the offset. |
| 6682 Register offset_reg = locs()->in(0).reg(); |
| 6683 __ SmiUntag(offset_reg); |
| 6684 __ addl(target_address_reg, offset_reg); |
| 6685 |
| 6686 // Jump to the absolute address. |
| 6687 __ jmp(target_address_reg); |
| 6688 } |
| 6689 |
| 6690 |
6524 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 6691 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6525 bool opt) const { | 6692 bool opt) const { |
6526 const intptr_t kNumInputs = 2; | 6693 const intptr_t kNumInputs = 2; |
6527 const intptr_t kNumTemps = 0; | 6694 const intptr_t kNumTemps = 0; |
6528 if (needs_number_check()) { | 6695 if (needs_number_check()) { |
6529 LocationSummary* locs = new(isolate) LocationSummary( | 6696 LocationSummary* locs = new(isolate) LocationSummary( |
6530 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 6697 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6531 locs->set_in(0, Location::RegisterLocation(EAX)); | 6698 locs->set_in(0, Location::RegisterLocation(EAX)); |
6532 locs->set_in(1, Location::RegisterLocation(ECX)); | 6699 locs->set_in(1, Location::RegisterLocation(ECX)); |
6533 locs->set_out(0, Location::RegisterLocation(EAX)); | 6700 locs->set_out(0, Location::RegisterLocation(EAX)); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6768 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6935 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6769 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6936 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6770 #endif | 6937 #endif |
6771 } | 6938 } |
6772 | 6939 |
6773 } // namespace dart | 6940 } // namespace dart |
6774 | 6941 |
6775 #undef __ | 6942 #undef __ |
6776 | 6943 |
6777 #endif // defined TARGET_ARCH_IA32 | 6944 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |