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