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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 __ SmiTag(result); | 1124 __ SmiTag(result); |
1125 break; | 1125 break; |
1126 default: | 1126 default: |
1127 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1127 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
1128 __ movq(result, element_address); | 1128 __ movq(result, element_address); |
1129 break; | 1129 break; |
1130 } | 1130 } |
1131 } | 1131 } |
1132 | 1132 |
1133 | 1133 |
| 1134 Representation LoadCodeUnitsInstr::representation() const { |
| 1135 switch (class_id()) { |
| 1136 case kOneByteStringCid: |
| 1137 case kTwoByteStringCid: |
| 1138 case kExternalOneByteStringCid: |
| 1139 case kExternalTwoByteStringCid: |
| 1140 return kTagged; |
| 1141 default: |
| 1142 UNIMPLEMENTED(); |
| 1143 return kTagged; |
| 1144 } |
| 1145 } |
| 1146 |
| 1147 |
| 1148 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, |
| 1149 bool opt) const { |
| 1150 const intptr_t kNumInputs = 2; |
| 1151 const intptr_t kNumTemps = 0; |
| 1152 LocationSummary* summary = new(isolate) LocationSummary( |
| 1153 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1154 summary->set_in(0, Location::RequiresRegister()); |
| 1155 // The smi index is either untagged (element size == 1), or it is left smi |
| 1156 // tagged (for all element sizes > 1). |
| 1157 summary->set_in(1, index_scale() == 1 ? Location::WritableRegister() |
| 1158 : Location::RequiresRegister()); |
| 1159 summary->set_out(0, Location::RequiresRegister()); |
| 1160 return summary; |
| 1161 } |
| 1162 |
| 1163 |
| 1164 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1165 const Register array = locs()->in(0).reg(); |
| 1166 const Location index = locs()->in(1); |
| 1167 |
| 1168 Address element_address = Assembler::ElementAddressForRegIndex( |
| 1169 IsExternal(), class_id(), index_scale(), array, index.reg()); |
| 1170 |
| 1171 if ((index_scale() == 1)) { |
| 1172 __ SmiUntag(index.reg()); |
| 1173 } |
| 1174 Register result = locs()->out(0).reg(); |
| 1175 switch (class_id()) { |
| 1176 case kOneByteStringCid: |
| 1177 case kExternalOneByteStringCid: |
| 1178 switch (element_count()) { |
| 1179 case 1: __ movzxb(result, element_address); break; |
| 1180 case 2: __ movzxw(result, element_address); break; |
| 1181 case 4: __ movl(result, element_address); break; |
| 1182 default: UNREACHABLE(); |
| 1183 } |
| 1184 __ SmiTag(result); |
| 1185 break; |
| 1186 case kTwoByteStringCid: |
| 1187 case kExternalTwoByteStringCid: |
| 1188 switch (element_count()) { |
| 1189 case 1: __ movzxw(result, element_address); break; |
| 1190 case 2: __ movl(result, element_address); break; |
| 1191 default: UNREACHABLE(); |
| 1192 } |
| 1193 __ SmiTag(result); |
| 1194 break; |
| 1195 default: |
| 1196 UNREACHABLE(); |
| 1197 break; |
| 1198 } |
| 1199 } |
| 1200 |
| 1201 |
1134 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1202 Representation StoreIndexedInstr::RequiredInputRepresentation( |
1135 intptr_t idx) const { | 1203 intptr_t idx) const { |
1136 if (idx == 0) return kNoRepresentation; | 1204 if (idx == 0) return kNoRepresentation; |
1137 if (idx == 1) return kTagged; | 1205 if (idx == 1) return kTagged; |
1138 ASSERT(idx == 2); | 1206 ASSERT(idx == 2); |
1139 switch (class_id_) { | 1207 switch (class_id_) { |
1140 case kArrayCid: | 1208 case kArrayCid: |
1141 case kOneByteStringCid: | 1209 case kOneByteStringCid: |
1142 case kTypedDataInt8ArrayCid: | 1210 case kTypedDataInt8ArrayCid: |
1143 case kTypedDataUint8ArrayCid: | 1211 case kTypedDataUint8ArrayCid: |
(...skipping 3410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4554 __ ReserveAlignedFrameSpace(0); | 4622 __ ReserveAlignedFrameSpace(0); |
4555 __ movaps(XMM0, locs()->in(0).fpu_reg()); | 4623 __ movaps(XMM0, locs()->in(0).fpu_reg()); |
4556 __ CallRuntime(TargetFunction(), InputCount()); | 4624 __ CallRuntime(TargetFunction(), InputCount()); |
4557 __ movaps(locs()->out(0).fpu_reg(), XMM0); | 4625 __ movaps(locs()->out(0).fpu_reg(), XMM0); |
4558 // Restore RSP. | 4626 // Restore RSP. |
4559 __ movq(RSP, locs()->temp(0).reg()); | 4627 __ movq(RSP, locs()->temp(0).reg()); |
4560 } | 4628 } |
4561 } | 4629 } |
4562 | 4630 |
4563 | 4631 |
| 4632 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
| 4633 Isolate* isolate, bool opt) const { |
| 4634 const intptr_t kNumTemps = 0; |
| 4635 LocationSummary* summary = new(isolate) LocationSummary( |
| 4636 isolate, InputCount(), kNumTemps, LocationSummary::kCall); |
| 4637 summary->set_in(0, Location::RegisterLocation(CallingConventions::kArg1Reg)); |
| 4638 summary->set_in(1, Location::RegisterLocation(CallingConventions::kArg2Reg)); |
| 4639 summary->set_in(2, Location::RegisterLocation(CallingConventions::kArg3Reg)); |
| 4640 summary->set_in(3, Location::RegisterLocation(CallingConventions::kArg4Reg)); |
| 4641 summary->set_out(0, Location::RegisterLocation(RAX)); |
| 4642 return summary; |
| 4643 } |
| 4644 |
| 4645 |
| 4646 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( |
| 4647 FlowGraphCompiler* compiler) { |
| 4648 |
| 4649 // Save RSP. R13 is chosen because it is callee saved so we do not need to |
| 4650 // back it up before calling into the runtime. |
| 4651 static const Register kSavedSPReg = R13; |
| 4652 __ movq(kSavedSPReg, RSP); |
| 4653 __ ReserveAlignedFrameSpace(0); |
| 4654 |
| 4655 // Call the function. Parameters are already in their correct spots. |
| 4656 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); |
| 4657 |
| 4658 // Restore RSP. |
| 4659 __ movq(RSP, kSavedSPReg); |
| 4660 } |
| 4661 |
| 4662 |
4564 LocationSummary* UnarySmiOpInstr::MakeLocationSummary(Isolate* isolate, | 4663 LocationSummary* UnarySmiOpInstr::MakeLocationSummary(Isolate* isolate, |
4565 bool opt) const { | 4664 bool opt) const { |
4566 const intptr_t kNumInputs = 1; | 4665 const intptr_t kNumInputs = 1; |
4567 return LocationSummary::Make(isolate, | 4666 return LocationSummary::Make(isolate, |
4568 kNumInputs, | 4667 kNumInputs, |
4569 Location::SameAsFirstInput(), | 4668 Location::SameAsFirstInput(), |
4570 LocationSummary::kNoCall); | 4669 LocationSummary::kNoCall); |
4571 } | 4670 } |
4572 | 4671 |
4573 | 4672 |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6077 } | 6176 } |
6078 | 6177 |
6079 // We can fall through if the successor is the next block in the list. | 6178 // We can fall through if the successor is the next block in the list. |
6080 // Otherwise, we need a jump. | 6179 // Otherwise, we need a jump. |
6081 if (!compiler->CanFallThroughTo(successor())) { | 6180 if (!compiler->CanFallThroughTo(successor())) { |
6082 __ jmp(compiler->GetJumpLabel(successor())); | 6181 __ jmp(compiler->GetJumpLabel(successor())); |
6083 } | 6182 } |
6084 } | 6183 } |
6085 | 6184 |
6086 | 6185 |
| 6186 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, |
| 6187 bool opt) const { |
| 6188 const intptr_t kNumInputs = 1; |
| 6189 const intptr_t kNumTemps = 1; |
| 6190 |
| 6191 LocationSummary* summary = new(isolate) LocationSummary( |
| 6192 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 6193 |
| 6194 summary->set_in(0, Location::RequiresRegister()); |
| 6195 summary->set_temp(0, Location::RequiresRegister()); |
| 6196 |
| 6197 return summary; |
| 6198 } |
| 6199 |
| 6200 |
| 6201 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6202 Register offset_reg = locs()->in(0).reg(); |
| 6203 Register target_address_reg = locs()->temp_slot(0)->reg(); |
| 6204 |
| 6205 // Load from [current frame pointer] + kPcMarkerSlotFromFp. |
| 6206 __ movq(target_address_reg, Address(RBP, kPcMarkerSlotFromFp * kWordSize)); |
| 6207 |
| 6208 // Calculate the final absolute address. |
| 6209 __ SmiUntag(offset_reg); |
| 6210 __ addq(target_address_reg, offset_reg); |
| 6211 |
| 6212 // Jump to the absolute address. |
| 6213 __ jmp(target_address_reg); |
| 6214 } |
| 6215 |
6087 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 6216 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6088 bool opt) const { | 6217 bool opt) const { |
6089 const intptr_t kNumInputs = 2; | 6218 const intptr_t kNumInputs = 2; |
6090 const intptr_t kNumTemps = 0; | 6219 const intptr_t kNumTemps = 0; |
6091 if (needs_number_check()) { | 6220 if (needs_number_check()) { |
6092 LocationSummary* locs = new(isolate) LocationSummary( | 6221 LocationSummary* locs = new(isolate) LocationSummary( |
6093 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 6222 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6094 locs->set_in(0, Location::RegisterLocation(RAX)); | 6223 locs->set_in(0, Location::RegisterLocation(RAX)); |
6095 locs->set_in(1, Location::RegisterLocation(RCX)); | 6224 locs->set_in(1, Location::RegisterLocation(RCX)); |
6096 locs->set_out(0, Location::RegisterLocation(RAX)); | 6225 locs->set_out(0, Location::RegisterLocation(RAX)); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6268 __ movq(R10, Immediate(kInvalidObjectPointer)); | 6397 __ movq(R10, Immediate(kInvalidObjectPointer)); |
6269 __ movq(RBX, Immediate(kInvalidObjectPointer)); | 6398 __ movq(RBX, Immediate(kInvalidObjectPointer)); |
6270 #endif | 6399 #endif |
6271 } | 6400 } |
6272 | 6401 |
6273 } // namespace dart | 6402 } // namespace dart |
6274 | 6403 |
6275 #undef __ | 6404 #undef __ |
6276 | 6405 |
6277 #endif // defined TARGET_ARCH_X64 | 6406 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |