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 // TODO(jgruber): kUnboxedUint32 could be a better choice. | |
1369 return element_count() < 4 ? kTagged : kUnboxedMint; | |
1370 case kTwoByteStringCid: | |
1371 case kExternalTwoByteStringCid: | |
1372 return element_count() < 2 ? kTagged : kUnboxedMint; | |
1373 default: | |
1374 UNIMPLEMENTED(); | |
1375 return kTagged; | |
1376 } | |
1377 } | |
1378 | |
1379 | |
1380 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, | |
1381 bool opt) const { | |
1382 const intptr_t kNumInputs = 2; | |
1383 const intptr_t kNumTemps = 0; | |
1384 LocationSummary* locs = new(isolate) LocationSummary( | |
1385 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
1386 locs->set_in(0, Location::RequiresRegister()); | |
1387 locs->set_in(1, Location::RequiresRegister()); | |
1388 | |
1389 if (representation() == kUnboxedMint) { | |
1390 locs->set_out(0, Location::Pair(Location::RequiresRegister(), | |
1391 Location::RequiresRegister())); | |
1392 } else { | |
1393 ASSERT(representation() == kTagged); | |
1394 locs->set_out(0, Location::RequiresRegister()); | |
1395 } | |
1396 | |
1397 return locs; | |
1398 } | |
1399 | |
1400 | |
1401 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
1402 const Register array = locs()->in(0).reg(); | |
1403 const Location index = locs()->in(1); | |
1404 | |
1405 Address element_address = __ ElementAddressForRegIndex( | |
1406 true, IsExternal(), class_id(), index_scale(), array, index.reg()); | |
1407 // Warning: element_address may use register IP as base. | |
1408 | |
1409 if (representation() == kUnboxedMint) { | |
1410 ASSERT(locs()->out(0).IsPairLocation()); | |
1411 PairLocation* result_pair = locs()->out(0).AsPairLocation(); | |
1412 Register result1 = result_pair->At(0).reg(); | |
1413 Register result2 = result_pair->At(1).reg(); | |
1414 switch (class_id()) { | |
1415 case kOneByteStringCid: | |
1416 case kExternalOneByteStringCid: | |
1417 ASSERT(element_count() == 4); | |
1418 __ ldr(result1, element_address); | |
1419 __ eor(result2, result2, Operand(result2)); | |
1420 break; | |
1421 case kTwoByteStringCid: | |
1422 case kExternalTwoByteStringCid: | |
1423 ASSERT(element_count() == 2); | |
1424 __ ldr(result1, element_address); | |
1425 __ eor(result2, result2, Operand(result2)); | |
1426 break; | |
1427 default: | |
1428 UNREACHABLE(); | |
1429 } | |
1430 } else { | |
1431 ASSERT(representation() == kTagged); | |
1432 Register result = locs()->out(0).reg(); | |
1433 switch (class_id()) { | |
1434 case kOneByteStringCid: | |
1435 case kExternalOneByteStringCid: | |
1436 switch (element_count()) { | |
1437 case 1: __ ldrb(result, element_address); break; | |
1438 case 2: __ ldrh(result, element_address); break; | |
zerny-google
2014/10/07 12:18:35
Nit: the fact that case 3 is not missing would be
jgruber1
2014/10/07 15:00:25
Acknowledged.
| |
1439 default: UNREACHABLE(); | |
1440 } | |
1441 __ SmiTag(result); | |
1442 break; | |
1443 case kTwoByteStringCid: | |
1444 case kExternalTwoByteStringCid: | |
1445 ASSERT(element_count() == 1); | |
1446 __ ldrh(result, element_address); | |
1447 __ SmiTag(result); | |
1448 break; | |
1449 default: | |
1450 UNREACHABLE(); | |
1451 break; | |
1452 } | |
1453 } | |
1454 } | |
1455 | |
1456 | |
1364 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1457 Representation StoreIndexedInstr::RequiredInputRepresentation( |
1365 intptr_t idx) const { | 1458 intptr_t idx) const { |
1366 // Array can be a Dart object or a pointer to external data. | 1459 // Array can be a Dart object or a pointer to external data. |
1367 if (idx == 0) return kNoRepresentation; // Flexible input representation. | 1460 if (idx == 0) return kNoRepresentation; // Flexible input representation. |
1368 if (idx == 1) return kTagged; // Index is a smi. | 1461 if (idx == 1) return kTagged; // Index is a smi. |
1369 ASSERT(idx == 2); | 1462 ASSERT(idx == 2); |
1370 switch (class_id_) { | 1463 switch (class_id_) { |
1371 case kArrayCid: | 1464 case kArrayCid: |
1372 case kOneByteStringCid: | 1465 case kOneByteStringCid: |
1373 case kTypedDataInt8ArrayCid: | 1466 case kTypedDataInt8ArrayCid: |
(...skipping 3713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5087 __ vmovrrd(R0, R1, D0); | 5180 __ vmovrrd(R0, R1, D0); |
5088 __ vmovrrd(R2, R3, D1); | 5181 __ vmovrrd(R2, R3, D1); |
5089 __ CallRuntime(TargetFunction(), InputCount()); | 5182 __ CallRuntime(TargetFunction(), InputCount()); |
5090 __ vmovdrr(D0, R0, R1); | 5183 __ vmovdrr(D0, R0, R1); |
5091 __ vmovdrr(D1, R2, R3); | 5184 __ vmovdrr(D1, R2, R3); |
5092 } | 5185 } |
5093 } | 5186 } |
5094 } | 5187 } |
5095 | 5188 |
5096 | 5189 |
5190 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( | |
5191 Isolate* isolate, bool opt) const { | |
5192 const intptr_t kNumTemps = 0; | |
5193 LocationSummary* summary = new(isolate) LocationSummary( | |
5194 isolate, InputCount(), kNumTemps, LocationSummary::kCall); | |
5195 summary->set_in(0, Location::RegisterLocation(R0)); | |
5196 summary->set_in(1, Location::RegisterLocation(R1)); | |
5197 summary->set_in(2, Location::RegisterLocation(R2)); | |
5198 summary->set_in(3, Location::RegisterLocation(R3)); | |
5199 summary->set_out(0, Location::RegisterLocation(R0)); | |
5200 return summary; | |
5201 } | |
5202 | |
5203 | |
5204 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( | |
5205 FlowGraphCompiler* compiler) { | |
5206 | |
5207 // Call the function. | |
5208 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); | |
5209 } | |
5210 | |
5211 | |
5097 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 5212 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
5098 bool opt) const { | 5213 bool opt) const { |
5099 if (result_cid() == kDoubleCid) { | 5214 if (result_cid() == kDoubleCid) { |
5100 const intptr_t kNumInputs = 2; | 5215 const intptr_t kNumInputs = 2; |
5101 const intptr_t kNumTemps = 1; | 5216 const intptr_t kNumTemps = 1; |
5102 LocationSummary* summary = new(isolate) LocationSummary( | 5217 LocationSummary* summary = new(isolate) LocationSummary( |
5103 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5218 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
5104 summary->set_in(0, Location::RequiresFpuRegister()); | 5219 summary->set_in(0, Location::RequiresFpuRegister()); |
5105 summary->set_in(1, Location::RequiresFpuRegister()); | 5220 summary->set_in(1, Location::RequiresFpuRegister()); |
5106 // Reuse the left register so that code can be made shorter. | 5221 // Reuse the left register so that code can be made shorter. |
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6863 } | 6978 } |
6864 | 6979 |
6865 // We can fall through if the successor is the next block in the list. | 6980 // We can fall through if the successor is the next block in the list. |
6866 // Otherwise, we need a jump. | 6981 // Otherwise, we need a jump. |
6867 if (!compiler->CanFallThroughTo(successor())) { | 6982 if (!compiler->CanFallThroughTo(successor())) { |
6868 __ b(compiler->GetJumpLabel(successor())); | 6983 __ b(compiler->GetJumpLabel(successor())); |
6869 } | 6984 } |
6870 } | 6985 } |
6871 | 6986 |
6872 | 6987 |
6988 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, | |
6989 bool opt) const { | |
6990 const intptr_t kNumInputs = 1; | |
6991 const intptr_t kNumTemps = 1; | |
6992 | |
6993 LocationSummary* locs = new(isolate) LocationSummary( | |
zerny-google
2014/10/07 12:18:35
Nit: Not sure if locs or summary is the preferred
jgruber1
2014/10/07 15:00:25
Seems to be split 1:2 (locs:summary), I went with
| |
6994 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
6995 | |
6996 locs->set_in(0, Location::RequiresRegister()); | |
6997 locs->set_temp(0, Location::RequiresRegister()); | |
6998 | |
6999 return locs; | |
7000 } | |
7001 | |
7002 | |
7003 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
7004 Register target_address_reg = locs()->temp_slot(0)->reg(); | |
7005 | |
7006 // Load from [current frame pointer] + kPcMarkerSlotFromFp. | |
7007 __ ldr(target_address_reg, Address(FP, kPcMarkerSlotFromFp * kWordSize)); | |
7008 | |
7009 // Add the offset. | |
7010 Register offset_reg = locs()->in(0).reg(); | |
7011 __ add(target_address_reg, | |
7012 target_address_reg, | |
7013 Operand(offset_reg, ASR, kSmiTagSize)); | |
7014 | |
7015 // Jump to the absolute address. | |
7016 __ bx(target_address_reg); | |
7017 } | |
7018 | |
7019 | |
6873 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 7020 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6874 bool opt) const { | 7021 bool opt) const { |
6875 const intptr_t kNumInputs = 2; | 7022 const intptr_t kNumInputs = 2; |
6876 const intptr_t kNumTemps = 0; | 7023 const intptr_t kNumTemps = 0; |
6877 if (needs_number_check()) { | 7024 if (needs_number_check()) { |
6878 LocationSummary* locs = new(isolate) LocationSummary( | 7025 LocationSummary* locs = new(isolate) LocationSummary( |
6879 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 7026 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6880 locs->set_in(0, Location::RegisterLocation(R0)); | 7027 locs->set_in(0, Location::RegisterLocation(R0)); |
6881 locs->set_in(1, Location::RegisterLocation(R1)); | 7028 locs->set_in(1, Location::RegisterLocation(R1)); |
6882 locs->set_out(0, Location::RegisterLocation(R0)); | 7029 locs->set_out(0, Location::RegisterLocation(R0)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7005 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 7152 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
7006 #if defined(DEBUG) | 7153 #if defined(DEBUG) |
7007 __ LoadImmediate(R4, kInvalidObjectPointer); | 7154 __ LoadImmediate(R4, kInvalidObjectPointer); |
7008 __ LoadImmediate(R5, kInvalidObjectPointer); | 7155 __ LoadImmediate(R5, kInvalidObjectPointer); |
7009 #endif | 7156 #endif |
7010 } | 7157 } |
7011 | 7158 |
7012 } // namespace dart | 7159 } // namespace dart |
7013 | 7160 |
7014 #endif // defined TARGET_ARCH_ARM | 7161 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |