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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 } | 1354 } |
1355 break; | 1355 break; |
1356 default: | 1356 default: |
1357 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1357 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
1358 __ ldr(result, element_address); | 1358 __ ldr(result, element_address); |
1359 break; | 1359 break; |
1360 } | 1360 } |
1361 } | 1361 } |
1362 | 1362 |
1363 | 1363 |
| 1364 Representation LoadCodeUnitsInstr::representation() const { |
| 1365 switch (class_id()) { |
| 1366 case kOneByteStringCid: |
| 1367 case kExternalOneByteStringCid: |
| 1368 case kTwoByteStringCid: |
| 1369 case kExternalTwoByteStringCid: |
| 1370 // TODO(jgruber): kUnboxedUint32 could be a better choice. |
| 1371 return can_pack_into_smi() ? kTagged : kUnboxedMint; |
| 1372 default: |
| 1373 UNIMPLEMENTED(); |
| 1374 return kTagged; |
| 1375 } |
| 1376 } |
| 1377 |
| 1378 |
| 1379 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, |
| 1380 bool opt) const { |
| 1381 const intptr_t kNumInputs = 2; |
| 1382 const intptr_t kNumTemps = 0; |
| 1383 LocationSummary* summary = new(isolate) LocationSummary( |
| 1384 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1385 summary->set_in(0, Location::RequiresRegister()); |
| 1386 summary->set_in(1, Location::RequiresRegister()); |
| 1387 |
| 1388 if (representation() == kUnboxedMint) { |
| 1389 summary->set_out(0, Location::Pair(Location::RequiresRegister(), |
| 1390 Location::RequiresRegister())); |
| 1391 } else { |
| 1392 ASSERT(representation() == kTagged); |
| 1393 summary->set_out(0, Location::RequiresRegister()); |
| 1394 } |
| 1395 |
| 1396 return summary; |
| 1397 } |
| 1398 |
| 1399 |
| 1400 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1401 const Register array = locs()->in(0).reg(); |
| 1402 const Location index = locs()->in(1); |
| 1403 |
| 1404 Address element_address = __ ElementAddressForRegIndex( |
| 1405 true, IsExternal(), class_id(), index_scale(), array, index.reg()); |
| 1406 // Warning: element_address may use register IP as base. |
| 1407 |
| 1408 if (representation() == kUnboxedMint) { |
| 1409 ASSERT(locs()->out(0).IsPairLocation()); |
| 1410 PairLocation* result_pair = locs()->out(0).AsPairLocation(); |
| 1411 Register result1 = result_pair->At(0).reg(); |
| 1412 Register result2 = result_pair->At(1).reg(); |
| 1413 switch (class_id()) { |
| 1414 case kOneByteStringCid: |
| 1415 case kExternalOneByteStringCid: |
| 1416 ASSERT(element_count() == 4); |
| 1417 __ ldr(result1, element_address); |
| 1418 __ eor(result2, result2, Operand(result2)); |
| 1419 break; |
| 1420 case kTwoByteStringCid: |
| 1421 case kExternalTwoByteStringCid: |
| 1422 ASSERT(element_count() == 2); |
| 1423 __ ldr(result1, element_address); |
| 1424 __ eor(result2, result2, Operand(result2)); |
| 1425 break; |
| 1426 default: |
| 1427 UNREACHABLE(); |
| 1428 } |
| 1429 } else { |
| 1430 ASSERT(representation() == kTagged); |
| 1431 Register result = locs()->out(0).reg(); |
| 1432 switch (class_id()) { |
| 1433 case kOneByteStringCid: |
| 1434 case kExternalOneByteStringCid: |
| 1435 switch (element_count()) { |
| 1436 case 1: __ ldrb(result, element_address); break; |
| 1437 case 2: __ ldrh(result, element_address); break; |
| 1438 default: UNREACHABLE(); |
| 1439 } |
| 1440 __ SmiTag(result); |
| 1441 break; |
| 1442 case kTwoByteStringCid: |
| 1443 case kExternalTwoByteStringCid: |
| 1444 ASSERT(element_count() == 1); |
| 1445 __ ldrh(result, element_address); |
| 1446 __ SmiTag(result); |
| 1447 break; |
| 1448 default: |
| 1449 UNREACHABLE(); |
| 1450 break; |
| 1451 } |
| 1452 } |
| 1453 } |
| 1454 |
| 1455 |
1364 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1456 Representation StoreIndexedInstr::RequiredInputRepresentation( |
1365 intptr_t idx) const { | 1457 intptr_t idx) const { |
1366 // Array can be a Dart object or a pointer to external data. | 1458 // Array can be a Dart object or a pointer to external data. |
1367 if (idx == 0) return kNoRepresentation; // Flexible input representation. | 1459 if (idx == 0) return kNoRepresentation; // Flexible input representation. |
1368 if (idx == 1) return kTagged; // Index is a smi. | 1460 if (idx == 1) return kTagged; // Index is a smi. |
1369 ASSERT(idx == 2); | 1461 ASSERT(idx == 2); |
1370 switch (class_id_) { | 1462 switch (class_id_) { |
1371 case kArrayCid: | 1463 case kArrayCid: |
1372 case kOneByteStringCid: | 1464 case kOneByteStringCid: |
1373 case kTypedDataInt8ArrayCid: | 1465 case kTypedDataInt8ArrayCid: |
(...skipping 3729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5103 __ vmovrrd(R0, R1, D0); | 5195 __ vmovrrd(R0, R1, D0); |
5104 __ vmovrrd(R2, R3, D1); | 5196 __ vmovrrd(R2, R3, D1); |
5105 __ CallRuntime(TargetFunction(), InputCount()); | 5197 __ CallRuntime(TargetFunction(), InputCount()); |
5106 __ vmovdrr(D0, R0, R1); | 5198 __ vmovdrr(D0, R0, R1); |
5107 __ vmovdrr(D1, R2, R3); | 5199 __ vmovdrr(D1, R2, R3); |
5108 } | 5200 } |
5109 } | 5201 } |
5110 } | 5202 } |
5111 | 5203 |
5112 | 5204 |
| 5205 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
| 5206 Isolate* isolate, bool opt) const { |
| 5207 const intptr_t kNumTemps = 0; |
| 5208 LocationSummary* summary = new(isolate) LocationSummary( |
| 5209 isolate, InputCount(), kNumTemps, LocationSummary::kCall); |
| 5210 summary->set_in(0, Location::RegisterLocation(R0)); |
| 5211 summary->set_in(1, Location::RegisterLocation(R1)); |
| 5212 summary->set_in(2, Location::RegisterLocation(R2)); |
| 5213 summary->set_in(3, Location::RegisterLocation(R3)); |
| 5214 summary->set_out(0, Location::RegisterLocation(R0)); |
| 5215 return summary; |
| 5216 } |
| 5217 |
| 5218 |
| 5219 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( |
| 5220 FlowGraphCompiler* compiler) { |
| 5221 |
| 5222 // Call the function. |
| 5223 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); |
| 5224 } |
| 5225 |
| 5226 |
5113 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 5227 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
5114 bool opt) const { | 5228 bool opt) const { |
5115 if (result_cid() == kDoubleCid) { | 5229 if (result_cid() == kDoubleCid) { |
5116 const intptr_t kNumInputs = 2; | 5230 const intptr_t kNumInputs = 2; |
5117 const intptr_t kNumTemps = 1; | 5231 const intptr_t kNumTemps = 1; |
5118 LocationSummary* summary = new(isolate) LocationSummary( | 5232 LocationSummary* summary = new(isolate) LocationSummary( |
5119 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5233 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
5120 summary->set_in(0, Location::RequiresFpuRegister()); | 5234 summary->set_in(0, Location::RequiresFpuRegister()); |
5121 summary->set_in(1, Location::RequiresFpuRegister()); | 5235 summary->set_in(1, Location::RequiresFpuRegister()); |
5122 // Reuse the left register so that code can be made shorter. | 5236 // Reuse the left register so that code can be made shorter. |
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6884 } | 6998 } |
6885 | 6999 |
6886 // We can fall through if the successor is the next block in the list. | 7000 // We can fall through if the successor is the next block in the list. |
6887 // Otherwise, we need a jump. | 7001 // Otherwise, we need a jump. |
6888 if (!compiler->CanFallThroughTo(successor())) { | 7002 if (!compiler->CanFallThroughTo(successor())) { |
6889 __ b(compiler->GetJumpLabel(successor())); | 7003 __ b(compiler->GetJumpLabel(successor())); |
6890 } | 7004 } |
6891 } | 7005 } |
6892 | 7006 |
6893 | 7007 |
| 7008 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, |
| 7009 bool opt) const { |
| 7010 const intptr_t kNumInputs = 1; |
| 7011 const intptr_t kNumTemps = 1; |
| 7012 |
| 7013 LocationSummary* summary = new(isolate) LocationSummary( |
| 7014 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 7015 |
| 7016 summary->set_in(0, Location::RequiresRegister()); |
| 7017 summary->set_temp(0, Location::RequiresRegister()); |
| 7018 |
| 7019 return summary; |
| 7020 } |
| 7021 |
| 7022 |
| 7023 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 7024 Register target_address_reg = locs()->temp_slot(0)->reg(); |
| 7025 |
| 7026 // Load from [current frame pointer] + kPcMarkerSlotFromFp. |
| 7027 __ ldr(target_address_reg, Address(FP, kPcMarkerSlotFromFp * kWordSize)); |
| 7028 |
| 7029 // Add the offset. |
| 7030 Register offset_reg = locs()->in(0).reg(); |
| 7031 __ add(target_address_reg, |
| 7032 target_address_reg, |
| 7033 Operand(offset_reg, ASR, kSmiTagSize)); |
| 7034 |
| 7035 // Jump to the absolute address. |
| 7036 __ bx(target_address_reg); |
| 7037 } |
| 7038 |
| 7039 |
6894 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 7040 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6895 bool opt) const { | 7041 bool opt) const { |
6896 const intptr_t kNumInputs = 2; | 7042 const intptr_t kNumInputs = 2; |
6897 const intptr_t kNumTemps = 0; | 7043 const intptr_t kNumTemps = 0; |
6898 if (needs_number_check()) { | 7044 if (needs_number_check()) { |
6899 LocationSummary* locs = new(isolate) LocationSummary( | 7045 LocationSummary* locs = new(isolate) LocationSummary( |
6900 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 7046 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6901 locs->set_in(0, Location::RegisterLocation(R0)); | 7047 locs->set_in(0, Location::RegisterLocation(R0)); |
6902 locs->set_in(1, Location::RegisterLocation(R1)); | 7048 locs->set_in(1, Location::RegisterLocation(R1)); |
6903 locs->set_out(0, Location::RegisterLocation(R0)); | 7049 locs->set_out(0, Location::RegisterLocation(R0)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7026 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 7172 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
7027 #if defined(DEBUG) | 7173 #if defined(DEBUG) |
7028 __ LoadImmediate(R4, kInvalidObjectPointer); | 7174 __ LoadImmediate(R4, kInvalidObjectPointer); |
7029 __ LoadImmediate(R5, kInvalidObjectPointer); | 7175 __ LoadImmediate(R5, kInvalidObjectPointer); |
7030 #endif | 7176 #endif |
7031 } | 7177 } |
7032 | 7178 |
7033 } // namespace dart | 7179 } // namespace dart |
7034 | 7180 |
7035 #endif // defined TARGET_ARCH_ARM | 7181 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |