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 CompileType LoadCodeUnitsInstr::ComputeType() const { |
| 1365 switch (class_id()) { |
| 1366 case kOneByteStringCid: |
| 1367 case kExternalOneByteStringCid: |
| 1368 return CompileType::FromCid(element_count() < 4 ? kSmiCid : kMintCid); |
| 1369 case kTwoByteStringCid: |
| 1370 case kExternalTwoByteStringCid: |
| 1371 return CompileType::FromCid(element_count() < 2 ? kSmiCid : kMintCid); |
| 1372 default: |
| 1373 UNIMPLEMENTED(); |
| 1374 return CompileType::Dynamic(); |
| 1375 } |
| 1376 } |
| 1377 |
| 1378 |
| 1379 Representation LoadCodeUnitsInstr::representation() const { |
| 1380 switch (class_id()) { |
| 1381 case kOneByteStringCid: |
| 1382 case kExternalOneByteStringCid: |
| 1383 return element_count() < 4 ? kTagged : kUnboxedMint; |
| 1384 case kTwoByteStringCid: |
| 1385 case kExternalTwoByteStringCid: |
| 1386 return element_count() < 2 ? kTagged : kUnboxedMint; |
| 1387 default: |
| 1388 UNIMPLEMENTED(); |
| 1389 return kTagged; |
| 1390 } |
| 1391 } |
| 1392 |
| 1393 |
| 1394 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, |
| 1395 bool opt) const { |
| 1396 const intptr_t kNumInputs = 2; |
| 1397 const intptr_t kNumTemps = 0; |
| 1398 LocationSummary* locs = new(isolate) LocationSummary( |
| 1399 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1400 locs->set_in(0, Location::RequiresRegister()); |
| 1401 bool needs_base = false; |
| 1402 if (CanBeImmediateIndex(index(), class_id(), IsExternal(), |
| 1403 true, // Load. |
| 1404 &needs_base)) { |
| 1405 // CanBeImmediateIndex must return false for unsafe smis. |
| 1406 locs->set_in(1, Location::Constant(index()->definition()->AsConstant())); |
| 1407 } else { |
| 1408 locs->set_in(1, Location::RequiresRegister()); |
| 1409 } |
| 1410 |
| 1411 if (representation() == kUnboxedMint) { |
| 1412 locs->set_out(0, Location::Pair(Location::RequiresRegister(), |
| 1413 Location::RequiresRegister())); |
| 1414 } else { |
| 1415 ASSERT(representation() == kTagged); |
| 1416 locs->set_out(0, Location::RequiresRegister()); |
| 1417 } |
| 1418 |
| 1419 return locs; |
| 1420 } |
| 1421 |
| 1422 |
| 1423 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1424 const Register array = locs()->in(0).reg(); |
| 1425 const Location index = locs()->in(1); |
| 1426 |
| 1427 Address element_address = index.IsRegister() |
| 1428 ? __ ElementAddressForRegIndex(true, // Load. |
| 1429 IsExternal(), class_id(), index_scale(), |
| 1430 array, |
| 1431 index.reg()) |
| 1432 : __ ElementAddressForIntIndex(true, // Load. |
| 1433 IsExternal(), class_id(), index_scale(), |
| 1434 array, Smi::Cast(index.constant()).Value(), |
| 1435 IP); // Temp register. |
| 1436 // Warning: element_address may use register IP as base. |
| 1437 |
| 1438 if (representation() == kUnboxedMint) { |
| 1439 ASSERT(locs()->out(0).IsPairLocation()); |
| 1440 PairLocation* result_pair = locs()->out(0).AsPairLocation(); |
| 1441 Register result1 = result_pair->At(0).reg(); |
| 1442 Register result2 = result_pair->At(1).reg(); |
| 1443 switch (class_id()) { |
| 1444 case kOneByteStringCid: |
| 1445 case kExternalOneByteStringCid: |
| 1446 ASSERT(element_count() == 4); |
| 1447 __ ldr(result1, element_address); |
| 1448 __ eor(result2, result2, Operand(result2)); |
| 1449 break; |
| 1450 case kTwoByteStringCid: |
| 1451 case kExternalTwoByteStringCid: |
| 1452 ASSERT(element_count() == 2); |
| 1453 __ ldr(result1, element_address); |
| 1454 __ eor(result2, result2, Operand(result2)); |
| 1455 break; |
| 1456 default: |
| 1457 UNREACHABLE(); |
| 1458 } |
| 1459 } else { |
| 1460 ASSERT(representation() == kTagged); |
| 1461 Register result = locs()->out(0).reg(); |
| 1462 switch (class_id()) { |
| 1463 case kOneByteStringCid: |
| 1464 case kExternalOneByteStringCid: |
| 1465 switch (element_count()) { |
| 1466 case 1: __ ldrb(result, element_address); break; |
| 1467 case 2: __ ldrsh(result, element_address); break; |
| 1468 default: UNREACHABLE(); |
| 1469 } |
| 1470 __ SmiTag(result); |
| 1471 break; |
| 1472 case kTwoByteStringCid: |
| 1473 case kExternalTwoByteStringCid: |
| 1474 ASSERT(element_count() == 1); |
| 1475 __ ldrsh(result, element_address); |
| 1476 __ SmiTag(result); |
| 1477 break; |
| 1478 default: |
| 1479 UNREACHABLE(); |
| 1480 break; |
| 1481 } |
| 1482 } |
| 1483 } |
| 1484 |
| 1485 |
1364 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1486 Representation StoreIndexedInstr::RequiredInputRepresentation( |
1365 intptr_t idx) const { | 1487 intptr_t idx) const { |
1366 // Array can be a Dart object or a pointer to external data. | 1488 // Array can be a Dart object or a pointer to external data. |
1367 if (idx == 0) return kNoRepresentation; // Flexible input representation. | 1489 if (idx == 0) return kNoRepresentation; // Flexible input representation. |
1368 if (idx == 1) return kTagged; // Index is a smi. | 1490 if (idx == 1) return kTagged; // Index is a smi. |
1369 ASSERT(idx == 2); | 1491 ASSERT(idx == 2); |
1370 switch (class_id_) { | 1492 switch (class_id_) { |
1371 case kArrayCid: | 1493 case kArrayCid: |
1372 case kOneByteStringCid: | 1494 case kOneByteStringCid: |
1373 case kTypedDataInt8ArrayCid: | 1495 case kTypedDataInt8ArrayCid: |
(...skipping 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5100 __ vmovrrd(R0, R1, D0); | 5222 __ vmovrrd(R0, R1, D0); |
5101 __ vmovrrd(R2, R3, D1); | 5223 __ vmovrrd(R2, R3, D1); |
5102 __ CallRuntime(TargetFunction(), InputCount()); | 5224 __ CallRuntime(TargetFunction(), InputCount()); |
5103 __ vmovdrr(D0, R0, R1); | 5225 __ vmovdrr(D0, R0, R1); |
5104 __ vmovdrr(D1, R2, R3); | 5226 __ vmovdrr(D1, R2, R3); |
5105 } | 5227 } |
5106 } | 5228 } |
5107 } | 5229 } |
5108 | 5230 |
5109 | 5231 |
| 5232 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( |
| 5233 Isolate* isolate, bool opt) const { |
| 5234 const intptr_t kNumTemps = 0; |
| 5235 LocationSummary* summary = new(isolate) LocationSummary( |
| 5236 isolate, InputCount(), kNumTemps, LocationSummary::kCall); |
| 5237 summary->set_in(0, Location::RegisterLocation(R0)); |
| 5238 summary->set_in(1, Location::RegisterLocation(R1)); |
| 5239 summary->set_in(2, Location::RegisterLocation(R2)); |
| 5240 summary->set_in(3, Location::RegisterLocation(R3)); |
| 5241 summary->set_out(0, Location::RegisterLocation(R0)); |
| 5242 return summary; |
| 5243 } |
| 5244 |
| 5245 |
| 5246 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( |
| 5247 FlowGraphCompiler* compiler) { |
| 5248 |
| 5249 // Call the function. |
| 5250 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); |
| 5251 } |
| 5252 |
| 5253 |
5110 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 5254 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
5111 bool opt) const { | 5255 bool opt) const { |
5112 if (result_cid() == kDoubleCid) { | 5256 if (result_cid() == kDoubleCid) { |
5113 const intptr_t kNumInputs = 2; | 5257 const intptr_t kNumInputs = 2; |
5114 const intptr_t kNumTemps = 1; | 5258 const intptr_t kNumTemps = 1; |
5115 LocationSummary* summary = new(isolate) LocationSummary( | 5259 LocationSummary* summary = new(isolate) LocationSummary( |
5116 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5260 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
5117 summary->set_in(0, Location::RequiresFpuRegister()); | 5261 summary->set_in(0, Location::RequiresFpuRegister()); |
5118 summary->set_in(1, Location::RequiresFpuRegister()); | 5262 summary->set_in(1, Location::RequiresFpuRegister()); |
5119 // Reuse the left register so that code can be made shorter. | 5263 // Reuse the left register so that code can be made shorter. |
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6844 } | 6988 } |
6845 | 6989 |
6846 | 6990 |
6847 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6991 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
6848 if (!compiler->CanFallThroughTo(normal_entry())) { | 6992 if (!compiler->CanFallThroughTo(normal_entry())) { |
6849 __ b(compiler->GetJumpLabel(normal_entry())); | 6993 __ b(compiler->GetJumpLabel(normal_entry())); |
6850 } | 6994 } |
6851 } | 6995 } |
6852 | 6996 |
6853 | 6997 |
| 6998 void IndirectEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6999 __ Bind(compiler->GetJumpLabel(this)); |
| 7000 if (!compiler->is_optimizing()) { |
| 7001 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, |
| 7002 deopt_id_, |
| 7003 Scanner::kNoSourcePos); |
| 7004 } |
| 7005 if (HasParallelMove()) { |
| 7006 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
| 7007 } |
| 7008 } |
| 7009 |
| 7010 |
6854 LocationSummary* GotoInstr::MakeLocationSummary(Isolate* isolate, | 7011 LocationSummary* GotoInstr::MakeLocationSummary(Isolate* isolate, |
6855 bool opt) const { | 7012 bool opt) const { |
6856 return new(isolate) LocationSummary(isolate, 0, 0, LocationSummary::kNoCall); | 7013 return new(isolate) LocationSummary(isolate, 0, 0, LocationSummary::kNoCall); |
6857 } | 7014 } |
6858 | 7015 |
6859 | 7016 |
6860 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 7017 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
6861 if (!compiler->is_optimizing()) { | 7018 if (!compiler->is_optimizing()) { |
6862 if (FLAG_emit_edge_counters) { | 7019 if (FLAG_emit_edge_counters) { |
6863 compiler->EmitEdgeCounter(); | 7020 compiler->EmitEdgeCounter(); |
(...skipping 12 matching lines...) Expand all Loading... |
6876 } | 7033 } |
6877 | 7034 |
6878 // We can fall through if the successor is the next block in the list. | 7035 // We can fall through if the successor is the next block in the list. |
6879 // Otherwise, we need a jump. | 7036 // Otherwise, we need a jump. |
6880 if (!compiler->CanFallThroughTo(successor())) { | 7037 if (!compiler->CanFallThroughTo(successor())) { |
6881 __ b(compiler->GetJumpLabel(successor())); | 7038 __ b(compiler->GetJumpLabel(successor())); |
6882 } | 7039 } |
6883 } | 7040 } |
6884 | 7041 |
6885 | 7042 |
| 7043 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, |
| 7044 bool opt) const { |
| 7045 const intptr_t kNumInputs = 1; |
| 7046 const intptr_t kNumTemps = 1; |
| 7047 |
| 7048 LocationSummary* locs = new(isolate) LocationSummary( |
| 7049 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 7050 |
| 7051 locs->set_in(0, Location::RequiresRegister()); |
| 7052 locs->set_temp(0, Location::RequiresRegister()); |
| 7053 |
| 7054 return locs; |
| 7055 } |
| 7056 |
| 7057 |
| 7058 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 7059 Register sum_reg = locs()->temp_slot(0)->reg(); |
| 7060 |
| 7061 // Load from [current frame pointer] + kPcMarkerSlotFromFp. |
| 7062 __ ldr(sum_reg, Address(FP, kPcMarkerSlotFromFp * kWordSize)); |
| 7063 |
| 7064 // Subtract the entrypoint offset. |
| 7065 __ AddImmediate(sum_reg, -Assembler::EntryPointToPcMarkerOffset()); |
| 7066 |
| 7067 // Add the offset. |
| 7068 Register offset_reg = locs()->in(0).reg(); |
| 7069 __ SmiUntag(offset_reg); |
| 7070 __ add(sum_reg, sum_reg, Operand(offset_reg)); |
| 7071 |
| 7072 // Jump to the absolute address. |
| 7073 __ bx(sum_reg); |
| 7074 } |
| 7075 |
| 7076 |
6886 LocationSummary* CurrentContextInstr::MakeLocationSummary(Isolate* isolate, | 7077 LocationSummary* CurrentContextInstr::MakeLocationSummary(Isolate* isolate, |
6887 bool opt) const { | 7078 bool opt) const { |
6888 return LocationSummary::Make(isolate, | 7079 return LocationSummary::Make(isolate, |
6889 0, | 7080 0, |
6890 Location::RequiresRegister(), | 7081 Location::RequiresRegister(), |
6891 LocationSummary::kNoCall); | 7082 LocationSummary::kNoCall); |
6892 } | 7083 } |
6893 | 7084 |
6894 | 7085 |
6895 void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 7086 void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7031 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 7222 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
7032 #if defined(DEBUG) | 7223 #if defined(DEBUG) |
7033 __ LoadImmediate(R4, kInvalidObjectPointer); | 7224 __ LoadImmediate(R4, kInvalidObjectPointer); |
7034 __ LoadImmediate(R5, kInvalidObjectPointer); | 7225 __ LoadImmediate(R5, kInvalidObjectPointer); |
7035 #endif | 7226 #endif |
7036 } | 7227 } |
7037 | 7228 |
7038 } // namespace dart | 7229 } // namespace dart |
7039 | 7230 |
7040 #endif // defined TARGET_ARCH_ARM | 7231 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |