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 3457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4686 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); | 4786 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); |
4687 __ CallRuntime(TargetFunction(), InputCount()); | 4787 __ CallRuntime(TargetFunction(), InputCount()); |
4688 __ fstpl(Address(ESP, 0)); | 4788 __ fstpl(Address(ESP, 0)); |
4689 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); | 4789 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); |
4690 // Restore ESP. | 4790 // Restore ESP. |
4691 __ movl(ESP, locs()->temp(0).reg()); | 4791 __ movl(ESP, locs()->temp(0).reg()); |
4692 } | 4792 } |
4693 } | 4793 } |
4694 | 4794 |
4695 | 4795 |
| 4796 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
| 4797 Isolate* isolate, bool opt) const { |
| 4798 const intptr_t kNumTemps = 0; |
| 4799 LocationSummary* summary = new(isolate) LocationSummary( |
| 4800 isolate, InputCount(), kNumTemps, LocationSummary::kCall); |
| 4801 summary->set_in(0, Location::RegisterLocation(EAX)); |
| 4802 summary->set_in(1, Location::RegisterLocation(ECX)); |
| 4803 summary->set_in(2, Location::RegisterLocation(EDX)); |
| 4804 summary->set_in(3, Location::RegisterLocation(EBX)); |
| 4805 summary->set_out(0, Location::RegisterLocation(EAX)); |
| 4806 return summary; |
| 4807 } |
| 4808 |
| 4809 |
| 4810 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( |
| 4811 FlowGraphCompiler* compiler) { |
| 4812 |
| 4813 // Save ESP. EDI is chosen because it is callee saved so we do not need to |
| 4814 // back it up before calling into the runtime. |
| 4815 static const Register kSavedSPReg = EDI; |
| 4816 __ movl(kSavedSPReg, ESP); |
| 4817 __ ReserveAlignedFrameSpace(kWordSize * TargetFunction().argument_count()); |
| 4818 |
| 4819 __ movl(Address(ESP, + 0 * kWordSize), locs()->in(0).reg()); |
| 4820 __ movl(Address(ESP, + 1 * kWordSize), locs()->in(1).reg()); |
| 4821 __ movl(Address(ESP, + 2 * kWordSize), locs()->in(2).reg()); |
| 4822 __ movl(Address(ESP, + 3 * kWordSize), locs()->in(3).reg()); |
| 4823 |
| 4824 // Call the function. |
| 4825 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); |
| 4826 |
| 4827 // Restore ESP. |
| 4828 __ movl(ESP, kSavedSPReg); |
| 4829 } |
| 4830 |
| 4831 |
4696 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 4832 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
4697 bool opt) const { | 4833 bool opt) const { |
4698 if (result_cid() == kDoubleCid) { | 4834 if (result_cid() == kDoubleCid) { |
4699 const intptr_t kNumInputs = 2; | 4835 const intptr_t kNumInputs = 2; |
4700 const intptr_t kNumTemps = 1; | 4836 const intptr_t kNumTemps = 1; |
4701 LocationSummary* summary = new(isolate) LocationSummary( | 4837 LocationSummary* summary = new(isolate) LocationSummary( |
4702 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4838 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
4703 summary->set_in(0, Location::RequiresFpuRegister()); | 4839 summary->set_in(0, Location::RequiresFpuRegister()); |
4704 summary->set_in(1, Location::RequiresFpuRegister()); | 4840 summary->set_in(1, Location::RequiresFpuRegister()); |
4705 // Reuse the left register so that code can be made shorter. | 4841 // Reuse the left register so that code can be made shorter. |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6534 } | 6670 } |
6535 | 6671 |
6536 // We can fall through if the successor is the next block in the list. | 6672 // We can fall through if the successor is the next block in the list. |
6537 // Otherwise, we need a jump. | 6673 // Otherwise, we need a jump. |
6538 if (!compiler->CanFallThroughTo(successor())) { | 6674 if (!compiler->CanFallThroughTo(successor())) { |
6539 __ jmp(compiler->GetJumpLabel(successor())); | 6675 __ jmp(compiler->GetJumpLabel(successor())); |
6540 } | 6676 } |
6541 } | 6677 } |
6542 | 6678 |
6543 | 6679 |
| 6680 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, |
| 6681 bool opt) const { |
| 6682 const intptr_t kNumInputs = 1; |
| 6683 const intptr_t kNumTemps = 1; |
| 6684 |
| 6685 LocationSummary* summary = new(isolate) LocationSummary( |
| 6686 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 6687 |
| 6688 summary->set_in(0, Location::RequiresRegister()); |
| 6689 summary->set_temp(0, Location::RequiresRegister()); |
| 6690 |
| 6691 return summary; |
| 6692 } |
| 6693 |
| 6694 |
| 6695 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6696 Register target_address_reg = locs()->temp_slot(0)->reg(); |
| 6697 |
| 6698 // Load from [current frame pointer] + kPcMarkerSlotFromFp. |
| 6699 __ movl(target_address_reg, Address(EBP, kPcMarkerSlotFromFp * kWordSize)); |
| 6700 |
| 6701 // Add the offset. |
| 6702 Register offset_reg = locs()->in(0).reg(); |
| 6703 __ SmiUntag(offset_reg); |
| 6704 __ addl(target_address_reg, offset_reg); |
| 6705 |
| 6706 // Jump to the absolute address. |
| 6707 __ jmp(target_address_reg); |
| 6708 } |
| 6709 |
| 6710 |
6544 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 6711 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6545 bool opt) const { | 6712 bool opt) const { |
6546 const intptr_t kNumInputs = 2; | 6713 const intptr_t kNumInputs = 2; |
6547 const intptr_t kNumTemps = 0; | 6714 const intptr_t kNumTemps = 0; |
6548 if (needs_number_check()) { | 6715 if (needs_number_check()) { |
6549 LocationSummary* locs = new(isolate) LocationSummary( | 6716 LocationSummary* locs = new(isolate) LocationSummary( |
6550 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 6717 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6551 locs->set_in(0, Location::RegisterLocation(EAX)); | 6718 locs->set_in(0, Location::RegisterLocation(EAX)); |
6552 locs->set_in(1, Location::RegisterLocation(ECX)); | 6719 locs->set_in(1, Location::RegisterLocation(ECX)); |
6553 locs->set_out(0, Location::RegisterLocation(EAX)); | 6720 locs->set_out(0, Location::RegisterLocation(EAX)); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6788 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6955 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6789 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6956 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6790 #endif | 6957 #endif |
6791 } | 6958 } |
6792 | 6959 |
6793 } // namespace dart | 6960 } // namespace dart |
6794 | 6961 |
6795 #undef __ | 6962 #undef __ |
6796 | 6963 |
6797 #endif // defined TARGET_ARCH_IA32 | 6964 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |