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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 } | 1192 } |
1193 break; | 1193 break; |
1194 default: | 1194 default: |
1195 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1195 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
1196 __ movl(result, element_address); | 1196 __ movl(result, element_address); |
1197 break; | 1197 break; |
1198 } | 1198 } |
1199 } | 1199 } |
1200 | 1200 |
1201 | 1201 |
| 1202 Representation LoadCodeUnitsInstr::representation() const { |
| 1203 switch (class_id()) { |
| 1204 case kOneByteStringCid: |
| 1205 case kExternalOneByteStringCid: |
| 1206 case kTwoByteStringCid: |
| 1207 case kExternalTwoByteStringCid: |
| 1208 // TODO(zerny): kUnboxedUint32 could be a better choice. |
| 1209 return can_pack_into_smi() ? kTagged : kUnboxedMint; |
| 1210 default: |
| 1211 UNIMPLEMENTED(); |
| 1212 return kTagged; |
| 1213 } |
| 1214 } |
| 1215 |
| 1216 |
| 1217 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, |
| 1218 bool opt) const { |
| 1219 const intptr_t kNumInputs = 2; |
| 1220 const intptr_t kNumTemps = 0; |
| 1221 LocationSummary* summary = new(isolate) LocationSummary( |
| 1222 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1223 summary->set_in(0, Location::RequiresRegister()); |
| 1224 // The smi index is either untagged (element size == 1), or it is left smi |
| 1225 // tagged (for all element sizes > 1). |
| 1226 summary->set_in(1, (index_scale() == 1) ? Location::WritableRegister() |
| 1227 : Location::RequiresRegister()); |
| 1228 |
| 1229 if (representation() == kUnboxedMint) { |
| 1230 summary->set_out(0, Location::Pair(Location::RequiresRegister(), |
| 1231 Location::RequiresRegister())); |
| 1232 } else { |
| 1233 ASSERT(representation() == kTagged); |
| 1234 summary->set_out(0, Location::RequiresRegister()); |
| 1235 } |
| 1236 |
| 1237 return summary; |
| 1238 } |
| 1239 |
| 1240 |
| 1241 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1242 const Register array = locs()->in(0).reg(); |
| 1243 const Location index = locs()->in(1); |
| 1244 |
| 1245 Address element_address = Assembler::ElementAddressForRegIndex( |
| 1246 IsExternal(), class_id(), index_scale(), array, index.reg()); |
| 1247 |
| 1248 if ((index_scale() == 1)) { |
| 1249 __ SmiUntag(index.reg()); |
| 1250 } |
| 1251 |
| 1252 if (representation() == kUnboxedMint) { |
| 1253 ASSERT(locs()->out(0).IsPairLocation()); |
| 1254 PairLocation* result_pair = locs()->out(0).AsPairLocation(); |
| 1255 Register result1 = result_pair->At(0).reg(); |
| 1256 Register result2 = result_pair->At(1).reg(); |
| 1257 switch (class_id()) { |
| 1258 case kOneByteStringCid: |
| 1259 case kExternalOneByteStringCid: |
| 1260 ASSERT(element_count() == 4); |
| 1261 __ movl(result1, element_address); |
| 1262 __ xorl(result2, result2); |
| 1263 break; |
| 1264 case kTwoByteStringCid: |
| 1265 case kExternalTwoByteStringCid: |
| 1266 ASSERT(element_count() == 2); |
| 1267 __ movl(result1, element_address); |
| 1268 __ xorl(result2, result2); |
| 1269 break; |
| 1270 default: |
| 1271 UNREACHABLE(); |
| 1272 } |
| 1273 } else { |
| 1274 ASSERT(representation() == kTagged); |
| 1275 Register result = locs()->out(0).reg(); |
| 1276 switch (class_id()) { |
| 1277 case kOneByteStringCid: |
| 1278 case kExternalOneByteStringCid: |
| 1279 switch (element_count()) { |
| 1280 case 1: __ movzxb(result, element_address); break; |
| 1281 case 2: __ movzxw(result, element_address); break; |
| 1282 default: UNREACHABLE(); |
| 1283 } |
| 1284 __ SmiTag(result); |
| 1285 break; |
| 1286 case kTwoByteStringCid: |
| 1287 case kExternalTwoByteStringCid: |
| 1288 switch (element_count()) { |
| 1289 case 1: __ movzxw(result, element_address); break; |
| 1290 default: UNREACHABLE(); |
| 1291 } |
| 1292 __ SmiTag(result); |
| 1293 break; |
| 1294 default: |
| 1295 UNREACHABLE(); |
| 1296 break; |
| 1297 } |
| 1298 } |
| 1299 } |
| 1300 |
| 1301 |
1202 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1302 Representation StoreIndexedInstr::RequiredInputRepresentation( |
1203 intptr_t idx) const { | 1303 intptr_t idx) const { |
1204 // Array can be a Dart object or a pointer to external data. | 1304 // Array can be a Dart object or a pointer to external data. |
1205 if (idx == 0) return kNoRepresentation; // Flexible input representation. | 1305 if (idx == 0) return kNoRepresentation; // Flexible input representation. |
1206 if (idx == 1) return kTagged; // Index is a smi. | 1306 if (idx == 1) return kTagged; // Index is a smi. |
1207 ASSERT(idx == 2); | 1307 ASSERT(idx == 2); |
1208 switch (class_id_) { | 1308 switch (class_id_) { |
1209 case kArrayCid: | 1309 case kArrayCid: |
1210 case kOneByteStringCid: | 1310 case kOneByteStringCid: |
1211 case kTypedDataInt8ArrayCid: | 1311 case kTypedDataInt8ArrayCid: |
(...skipping 3457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4669 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); | 4769 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); |
4670 __ CallRuntime(TargetFunction(), InputCount()); | 4770 __ CallRuntime(TargetFunction(), InputCount()); |
4671 __ fstpl(Address(ESP, 0)); | 4771 __ fstpl(Address(ESP, 0)); |
4672 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); | 4772 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); |
4673 // Restore ESP. | 4773 // Restore ESP. |
4674 __ movl(ESP, locs()->temp(0).reg()); | 4774 __ movl(ESP, locs()->temp(0).reg()); |
4675 } | 4775 } |
4676 } | 4776 } |
4677 | 4777 |
4678 | 4778 |
| 4779 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
| 4780 Isolate* isolate, bool opt) const { |
| 4781 const intptr_t kNumTemps = 0; |
| 4782 LocationSummary* summary = new(isolate) LocationSummary( |
| 4783 isolate, InputCount(), kNumTemps, LocationSummary::kCall); |
| 4784 summary->set_in(0, Location::RegisterLocation(EAX)); |
| 4785 summary->set_in(1, Location::RegisterLocation(ECX)); |
| 4786 summary->set_in(2, Location::RegisterLocation(EDX)); |
| 4787 summary->set_in(3, Location::RegisterLocation(EBX)); |
| 4788 summary->set_out(0, Location::RegisterLocation(EAX)); |
| 4789 return summary; |
| 4790 } |
| 4791 |
| 4792 |
| 4793 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( |
| 4794 FlowGraphCompiler* compiler) { |
| 4795 |
| 4796 // Save ESP. EDI is chosen because it is callee saved so we do not need to |
| 4797 // back it up before calling into the runtime. |
| 4798 static const Register kSavedSPReg = EDI; |
| 4799 __ movl(kSavedSPReg, ESP); |
| 4800 __ ReserveAlignedFrameSpace(kWordSize * TargetFunction().argument_count()); |
| 4801 |
| 4802 __ movl(Address(ESP, + 0 * kWordSize), locs()->in(0).reg()); |
| 4803 __ movl(Address(ESP, + 1 * kWordSize), locs()->in(1).reg()); |
| 4804 __ movl(Address(ESP, + 2 * kWordSize), locs()->in(2).reg()); |
| 4805 __ movl(Address(ESP, + 3 * kWordSize), locs()->in(3).reg()); |
| 4806 |
| 4807 // Call the function. |
| 4808 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); |
| 4809 |
| 4810 // Restore ESP. |
| 4811 __ movl(ESP, kSavedSPReg); |
| 4812 } |
| 4813 |
| 4814 |
4679 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 4815 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
4680 bool opt) const { | 4816 bool opt) const { |
4681 if (result_cid() == kDoubleCid) { | 4817 if (result_cid() == kDoubleCid) { |
4682 const intptr_t kNumInputs = 2; | 4818 const intptr_t kNumInputs = 2; |
4683 const intptr_t kNumTemps = 1; | 4819 const intptr_t kNumTemps = 1; |
4684 LocationSummary* summary = new(isolate) LocationSummary( | 4820 LocationSummary* summary = new(isolate) LocationSummary( |
4685 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4821 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
4686 summary->set_in(0, Location::RequiresFpuRegister()); | 4822 summary->set_in(0, Location::RequiresFpuRegister()); |
4687 summary->set_in(1, Location::RequiresFpuRegister()); | 4823 summary->set_in(1, Location::RequiresFpuRegister()); |
4688 // Reuse the left register so that code can be made shorter. | 4824 // Reuse the left register so that code can be made shorter. |
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6504 } | 6640 } |
6505 | 6641 |
6506 // We can fall through if the successor is the next block in the list. | 6642 // We can fall through if the successor is the next block in the list. |
6507 // Otherwise, we need a jump. | 6643 // Otherwise, we need a jump. |
6508 if (!compiler->CanFallThroughTo(successor())) { | 6644 if (!compiler->CanFallThroughTo(successor())) { |
6509 __ jmp(compiler->GetJumpLabel(successor())); | 6645 __ jmp(compiler->GetJumpLabel(successor())); |
6510 } | 6646 } |
6511 } | 6647 } |
6512 | 6648 |
6513 | 6649 |
| 6650 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, |
| 6651 bool opt) const { |
| 6652 const intptr_t kNumInputs = 1; |
| 6653 const intptr_t kNumTemps = 1; |
| 6654 |
| 6655 LocationSummary* summary = new(isolate) LocationSummary( |
| 6656 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 6657 |
| 6658 summary->set_in(0, Location::RequiresRegister()); |
| 6659 summary->set_temp(0, Location::RequiresRegister()); |
| 6660 |
| 6661 return summary; |
| 6662 } |
| 6663 |
| 6664 |
| 6665 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6666 Register target_address_reg = locs()->temp_slot(0)->reg(); |
| 6667 |
| 6668 // Load from [current frame pointer] + kPcMarkerSlotFromFp. |
| 6669 __ movl(target_address_reg, Address(EBP, kPcMarkerSlotFromFp * kWordSize)); |
| 6670 |
| 6671 // Add the offset. |
| 6672 Register offset_reg = locs()->in(0).reg(); |
| 6673 __ SmiUntag(offset_reg); |
| 6674 __ addl(target_address_reg, offset_reg); |
| 6675 |
| 6676 // Jump to the absolute address. |
| 6677 __ jmp(target_address_reg); |
| 6678 } |
| 6679 |
| 6680 |
6514 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 6681 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6515 bool opt) const { | 6682 bool opt) const { |
6516 const intptr_t kNumInputs = 2; | 6683 const intptr_t kNumInputs = 2; |
6517 const intptr_t kNumTemps = 0; | 6684 const intptr_t kNumTemps = 0; |
6518 if (needs_number_check()) { | 6685 if (needs_number_check()) { |
6519 LocationSummary* locs = new(isolate) LocationSummary( | 6686 LocationSummary* locs = new(isolate) LocationSummary( |
6520 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 6687 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6521 locs->set_in(0, Location::RegisterLocation(EAX)); | 6688 locs->set_in(0, Location::RegisterLocation(EAX)); |
6522 locs->set_in(1, Location::RegisterLocation(ECX)); | 6689 locs->set_in(1, Location::RegisterLocation(ECX)); |
6523 locs->set_out(0, Location::RegisterLocation(EAX)); | 6690 locs->set_out(0, Location::RegisterLocation(EAX)); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6757 #if defined(DEBUG) | 6924 #if defined(DEBUG) |
6758 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6925 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6759 #endif | 6926 #endif |
6760 } | 6927 } |
6761 | 6928 |
6762 } // namespace dart | 6929 } // namespace dart |
6763 | 6930 |
6764 #undef __ | 6931 #undef __ |
6765 | 6932 |
6766 #endif // defined TARGET_ARCH_IA32 | 6933 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |