OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 ASSERT(offset == (xmm_regs_count * kDoubleSize)); | 1329 ASSERT(offset == (xmm_regs_count * kDoubleSize)); |
1330 __ addl(ESP, Immediate(offset)); | 1330 __ addl(ESP, Immediate(offset)); |
1331 } | 1331 } |
1332 } | 1332 } |
1333 | 1333 |
1334 | 1334 |
1335 #undef __ | 1335 #undef __ |
1336 #define __ compiler_->assembler()-> | 1336 #define __ compiler_->assembler()-> |
1337 | 1337 |
1338 | 1338 |
1339 static Address ToStackSlotAddress(Location loc) { | |
1340 const intptr_t index = loc.stack_index(); | |
1341 if (index < 0) { | |
1342 const intptr_t offset = (1 - index) * kWordSize; | |
1343 return Address(EBP, offset); | |
1344 } else { | |
1345 const intptr_t offset = | |
1346 (ParsedFunction::kFirstLocalSlotIndex - index) * kWordSize; | |
1347 return Address(EBP, offset); | |
1348 } | |
1349 } | |
1350 | |
1351 | |
1352 void ParallelMoveResolver::EmitMove(int index) { | 1339 void ParallelMoveResolver::EmitMove(int index) { |
1353 MoveOperands* move = moves_[index]; | 1340 MoveOperands* move = moves_[index]; |
1354 const Location source = move->src(); | 1341 const Location source = move->src(); |
1355 const Location destination = move->dest(); | 1342 const Location destination = move->dest(); |
1356 | 1343 |
1357 if (source.IsRegister()) { | 1344 if (source.IsRegister()) { |
1358 if (destination.IsRegister()) { | 1345 if (destination.IsRegister()) { |
1359 __ movl(destination.reg(), source.reg()); | 1346 __ movl(destination.reg(), source.reg()); |
1360 } else { | 1347 } else { |
1361 ASSERT(destination.IsStackSlot()); | 1348 ASSERT(destination.IsStackSlot()); |
1362 __ movl(ToStackSlotAddress(destination), source.reg()); | 1349 __ movl(destination.ToStackSlotAddress(), source.reg()); |
1363 } | 1350 } |
1364 } else if (source.IsStackSlot()) { | 1351 } else if (source.IsStackSlot()) { |
1365 if (destination.IsRegister()) { | 1352 if (destination.IsRegister()) { |
1366 __ movl(destination.reg(), ToStackSlotAddress(source)); | 1353 __ movl(destination.reg(), source.ToStackSlotAddress()); |
1367 } else { | 1354 } else { |
1368 ASSERT(destination.IsStackSlot()); | 1355 ASSERT(destination.IsStackSlot()); |
1369 MoveMemoryToMemory(ToStackSlotAddress(destination), | 1356 MoveMemoryToMemory(destination.ToStackSlotAddress(), |
1370 ToStackSlotAddress(source)); | 1357 source.ToStackSlotAddress()); |
1371 } | 1358 } |
1372 } else if (source.IsXmmRegister()) { | 1359 } else if (source.IsXmmRegister()) { |
1373 if (destination.IsXmmRegister()) { | 1360 if (destination.IsXmmRegister()) { |
1374 // Optimization manual recommends using MOVAPS for register | 1361 // Optimization manual recommends using MOVAPS for register |
1375 // to register moves. | 1362 // to register moves. |
1376 __ movaps(destination.xmm_reg(), source.xmm_reg()); | 1363 __ movaps(destination.xmm_reg(), source.xmm_reg()); |
1377 } else { | 1364 } else { |
1378 ASSERT(destination.IsDoubleStackSlot()); | 1365 ASSERT(destination.IsDoubleStackSlot()); |
1379 __ movsd(ToStackSlotAddress(destination), source.xmm_reg()); | 1366 __ movsd(destination.ToStackSlotAddress(), source.xmm_reg()); |
1380 } | 1367 } |
1381 } else if (source.IsDoubleStackSlot()) { | 1368 } else if (source.IsDoubleStackSlot()) { |
1382 if (destination.IsXmmRegister()) { | 1369 if (destination.IsXmmRegister()) { |
1383 __ movsd(destination.xmm_reg(), ToStackSlotAddress(source)); | 1370 __ movsd(destination.xmm_reg(), source.ToStackSlotAddress()); |
1384 } else { | 1371 } else { |
1385 ASSERT(destination.IsDoubleStackSlot()); | 1372 ASSERT(destination.IsDoubleStackSlot()); |
1386 __ movsd(XMM0, ToStackSlotAddress(source)); | 1373 __ movsd(XMM0, source.ToStackSlotAddress()); |
1387 __ movsd(ToStackSlotAddress(destination), XMM0); | 1374 __ movsd(destination.ToStackSlotAddress(), XMM0); |
1388 } | 1375 } |
1389 } else { | 1376 } else { |
1390 ASSERT(source.IsConstant()); | 1377 ASSERT(source.IsConstant()); |
1391 if (destination.IsRegister()) { | 1378 if (destination.IsRegister()) { |
1392 const Object& constant = source.constant(); | 1379 const Object& constant = source.constant(); |
1393 if (constant.IsSmi() && (Smi::Cast(constant).Value() == 0)) { | 1380 if (constant.IsSmi() && (Smi::Cast(constant).Value() == 0)) { |
1394 __ xorl(destination.reg(), destination.reg()); | 1381 __ xorl(destination.reg(), destination.reg()); |
1395 } else { | 1382 } else { |
1396 __ LoadObject(destination.reg(), constant); | 1383 __ LoadObject(destination.reg(), constant); |
1397 } | 1384 } |
1398 } else { | 1385 } else { |
1399 ASSERT(destination.IsStackSlot()); | 1386 ASSERT(destination.IsStackSlot()); |
1400 StoreObject(ToStackSlotAddress(destination), source.constant()); | 1387 StoreObject(destination.ToStackSlotAddress(), source.constant()); |
1401 } | 1388 } |
1402 } | 1389 } |
1403 | 1390 |
1404 move->Eliminate(); | 1391 move->Eliminate(); |
1405 } | 1392 } |
1406 | 1393 |
1407 | 1394 |
1408 void ParallelMoveResolver::EmitSwap(int index) { | 1395 void ParallelMoveResolver::EmitSwap(int index) { |
1409 MoveOperands* move = moves_[index]; | 1396 MoveOperands* move = moves_[index]; |
1410 const Location source = move->src(); | 1397 const Location source = move->src(); |
1411 const Location destination = move->dest(); | 1398 const Location destination = move->dest(); |
1412 | 1399 |
1413 if (source.IsRegister() && destination.IsRegister()) { | 1400 if (source.IsRegister() && destination.IsRegister()) { |
1414 __ xchgl(destination.reg(), source.reg()); | 1401 __ xchgl(destination.reg(), source.reg()); |
1415 } else if (source.IsRegister() && destination.IsStackSlot()) { | 1402 } else if (source.IsRegister() && destination.IsStackSlot()) { |
1416 Exchange(source.reg(), ToStackSlotAddress(destination)); | 1403 Exchange(source.reg(), destination.ToStackSlotAddress()); |
1417 } else if (source.IsStackSlot() && destination.IsRegister()) { | 1404 } else if (source.IsStackSlot() && destination.IsRegister()) { |
1418 Exchange(destination.reg(), ToStackSlotAddress(source)); | 1405 Exchange(destination.reg(), source.ToStackSlotAddress()); |
1419 } else if (source.IsStackSlot() && destination.IsStackSlot()) { | 1406 } else if (source.IsStackSlot() && destination.IsStackSlot()) { |
1420 Exchange(ToStackSlotAddress(destination), ToStackSlotAddress(source)); | 1407 Exchange(destination.ToStackSlotAddress(), source.ToStackSlotAddress()); |
1421 } else if (source.IsXmmRegister() && destination.IsXmmRegister()) { | 1408 } else if (source.IsXmmRegister() && destination.IsXmmRegister()) { |
1422 __ movaps(XMM0, source.xmm_reg()); | 1409 __ movaps(XMM0, source.xmm_reg()); |
1423 __ movaps(source.xmm_reg(), destination.xmm_reg()); | 1410 __ movaps(source.xmm_reg(), destination.xmm_reg()); |
1424 __ movaps(destination.xmm_reg(), XMM0); | 1411 __ movaps(destination.xmm_reg(), XMM0); |
1425 } else if (source.IsXmmRegister() || destination.IsXmmRegister()) { | 1412 } else if (source.IsXmmRegister() || destination.IsXmmRegister()) { |
1426 ASSERT(destination.IsDoubleStackSlot() || source.IsDoubleStackSlot()); | 1413 ASSERT(destination.IsDoubleStackSlot() || source.IsDoubleStackSlot()); |
1427 XmmRegister reg = source.IsXmmRegister() ? source.xmm_reg() | 1414 XmmRegister reg = source.IsXmmRegister() ? source.xmm_reg() |
1428 : destination.xmm_reg(); | 1415 : destination.xmm_reg(); |
1429 Address slot_address = | 1416 Address slot_address = source.IsXmmRegister() |
1430 ToStackSlotAddress(source.IsXmmRegister() ? destination : source); | 1417 ? destination.ToStackSlotAddress() |
| 1418 : source.ToStackSlotAddress(); |
1431 | 1419 |
1432 __ movsd(XMM0, slot_address); | 1420 __ movsd(XMM0, slot_address); |
1433 __ movsd(slot_address, reg); | 1421 __ movsd(slot_address, reg); |
1434 __ movaps(reg, XMM0); | 1422 __ movaps(reg, XMM0); |
1435 } else { | 1423 } else { |
1436 UNREACHABLE(); | 1424 UNREACHABLE(); |
1437 } | 1425 } |
1438 | 1426 |
1439 // The swap of source and destination has executed a move from source to | 1427 // The swap of source and destination has executed a move from source to |
1440 // destination. | 1428 // destination. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 __ popl(ECX); | 1487 __ popl(ECX); |
1500 __ popl(EAX); | 1488 __ popl(EAX); |
1501 } | 1489 } |
1502 | 1490 |
1503 | 1491 |
1504 #undef __ | 1492 #undef __ |
1505 | 1493 |
1506 } // namespace dart | 1494 } // namespace dart |
1507 | 1495 |
1508 #endif // defined TARGET_ARCH_IA32 | 1496 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |