OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 EnsureSpace ensure_space(this); | 1388 EnsureSpace ensure_space(this); |
1389 emit(0x66); | 1389 emit(0x66); |
1390 emit_optional_rex_32(dst); | 1390 emit_optional_rex_32(dst); |
1391 emit(0xC7); | 1391 emit(0xC7); |
1392 emit_operand(0x0, dst); | 1392 emit_operand(0x0, dst); |
1393 emit(static_cast<byte>(imm.value_ & 0xff)); | 1393 emit(static_cast<byte>(imm.value_ & 0xff)); |
1394 emit(static_cast<byte>(imm.value_ >> 8)); | 1394 emit(static_cast<byte>(imm.value_ >> 8)); |
1395 } | 1395 } |
1396 | 1396 |
1397 | 1397 |
1398 void Assembler::movl(Register dst, const Operand& src) { | 1398 void Assembler::emit_mov(Register dst, const Operand& src, int size) { |
1399 EnsureSpace ensure_space(this); | 1399 EnsureSpace ensure_space(this); |
1400 emit_optional_rex_32(dst, src); | 1400 emit_rex(dst, src, size); |
1401 emit(0x8B); | 1401 emit(0x8B); |
1402 emit_operand(dst, src); | 1402 emit_operand(dst, src); |
1403 } | 1403 } |
1404 | 1404 |
1405 | 1405 |
1406 void Assembler::movl(Register dst, Register src) { | 1406 void Assembler::emit_mov(Register dst, Register src, int size) { |
1407 EnsureSpace ensure_space(this); | 1407 EnsureSpace ensure_space(this); |
1408 if (src.low_bits() == 4) { | 1408 if (src.low_bits() == 4) { |
1409 emit_optional_rex_32(src, dst); | 1409 emit_rex(src, dst, size); |
1410 emit(0x89); | 1410 emit(0x89); |
1411 emit_modrm(src, dst); | 1411 emit_modrm(src, dst); |
1412 } else { | 1412 } else { |
1413 emit_optional_rex_32(dst, src); | 1413 emit_rex(dst, src, size); |
1414 emit(0x8B); | 1414 emit(0x8B); |
1415 emit_modrm(dst, src); | 1415 emit_modrm(dst, src); |
1416 } | 1416 } |
1417 } | 1417 } |
1418 | 1418 |
1419 | 1419 |
1420 void Assembler::movl(const Operand& dst, Register src) { | 1420 void Assembler::emit_mov(const Operand& dst, Register src, int size) { |
1421 EnsureSpace ensure_space(this); | 1421 EnsureSpace ensure_space(this); |
1422 emit_optional_rex_32(src, dst); | 1422 emit_rex(src, dst, size); |
1423 emit(0x89); | 1423 emit(0x89); |
1424 emit_operand(src, dst); | 1424 emit_operand(src, dst); |
1425 } | 1425 } |
1426 | 1426 |
1427 | 1427 |
1428 void Assembler::movl(const Operand& dst, Immediate value) { | 1428 void Assembler::emit_mov(Register dst, Immediate value, int size) { |
1429 EnsureSpace ensure_space(this); | 1429 EnsureSpace ensure_space(this); |
1430 emit_optional_rex_32(dst); | 1430 emit_rex(dst, size); |
| 1431 if (size == kInt64Size) { |
| 1432 emit(0xC7); |
| 1433 emit_modrm(0x0, dst); |
| 1434 } else { |
| 1435 ASSERT(size == kInt32Size); |
| 1436 emit(0xB8 + dst.low_bits()); |
| 1437 } |
| 1438 emit(value); |
| 1439 } |
| 1440 |
| 1441 |
| 1442 void Assembler::emit_mov(const Operand& dst, Immediate value, int size) { |
| 1443 EnsureSpace ensure_space(this); |
| 1444 emit_rex(dst, size); |
1431 emit(0xC7); | 1445 emit(0xC7); |
1432 emit_operand(0x0, dst); | 1446 emit_operand(0x0, dst); |
1433 emit(value); | 1447 emit(value); |
1434 } | 1448 } |
1435 | 1449 |
1436 | 1450 |
1437 void Assembler::movl(Register dst, Immediate value) { | |
1438 EnsureSpace ensure_space(this); | |
1439 emit_optional_rex_32(dst); | |
1440 emit(0xB8 + dst.low_bits()); | |
1441 emit(value); | |
1442 } | |
1443 | |
1444 | |
1445 void Assembler::movq(Register dst, const Operand& src) { | |
1446 EnsureSpace ensure_space(this); | |
1447 emit_rex_64(dst, src); | |
1448 emit(0x8B); | |
1449 emit_operand(dst, src); | |
1450 } | |
1451 | |
1452 | |
1453 void Assembler::movq(Register dst, Register src) { | |
1454 EnsureSpace ensure_space(this); | |
1455 if (src.low_bits() == 4) { | |
1456 emit_rex_64(src, dst); | |
1457 emit(0x89); | |
1458 emit_modrm(src, dst); | |
1459 } else { | |
1460 emit_rex_64(dst, src); | |
1461 emit(0x8B); | |
1462 emit_modrm(dst, src); | |
1463 } | |
1464 } | |
1465 | |
1466 | |
1467 void Assembler::movq(Register dst, Immediate value) { | |
1468 EnsureSpace ensure_space(this); | |
1469 emit_rex_64(dst); | |
1470 emit(0xC7); | |
1471 emit_modrm(0x0, dst); | |
1472 emit(value); // Only 32-bit immediates are possible, not 8-bit immediates. | |
1473 } | |
1474 | |
1475 | |
1476 void Assembler::movq(const Operand& dst, Register src) { | |
1477 EnsureSpace ensure_space(this); | |
1478 emit_rex_64(src, dst); | |
1479 emit(0x89); | |
1480 emit_operand(src, dst); | |
1481 } | |
1482 | |
1483 | |
1484 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { | 1451 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { |
1485 // This method must not be used with heap object references. The stored | 1452 // This method must not be used with heap object references. The stored |
1486 // address is not GC safe. Use the handle version instead. | 1453 // address is not GC safe. Use the handle version instead. |
1487 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); | 1454 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); |
1488 if (RelocInfo::IsNone(rmode)) { | 1455 if (RelocInfo::IsNone(rmode)) { |
1489 movq(dst, reinterpret_cast<int64_t>(value)); | 1456 movq(dst, reinterpret_cast<int64_t>(value)); |
1490 } else { | 1457 } else { |
1491 EnsureSpace ensure_space(this); | 1458 EnsureSpace ensure_space(this); |
1492 emit_rex_64(dst); | 1459 emit_rex_64(dst); |
1493 emit(0xB8 | dst.low_bits()); | 1460 emit(0xB8 | dst.low_bits()); |
1494 emitp(value, rmode); | 1461 emitp(value, rmode); |
1495 } | 1462 } |
1496 } | 1463 } |
1497 | 1464 |
1498 | 1465 |
1499 void Assembler::movq(Register dst, int64_t value) { | 1466 void Assembler::movq(Register dst, int64_t value) { |
1500 EnsureSpace ensure_space(this); | 1467 EnsureSpace ensure_space(this); |
1501 emit_rex_64(dst); | 1468 emit_rex_64(dst); |
1502 emit(0xB8 | dst.low_bits()); | 1469 emit(0xB8 | dst.low_bits()); |
1503 emitq(value); | 1470 emitq(value); |
1504 } | 1471 } |
1505 | 1472 |
1506 | 1473 |
1507 void Assembler::movq(const Operand& dst, Immediate value) { | 1474 void Assembler::movq(Register dst, uint64_t value) { |
1508 EnsureSpace ensure_space(this); | 1475 movq(dst, static_cast<int64_t>(value)); |
1509 emit_rex_64(dst); | |
1510 emit(0xC7); | |
1511 emit_operand(0, dst); | |
1512 emit(value); | |
1513 } | 1476 } |
1514 | 1477 |
1515 | 1478 |
1516 // Loads the ip-relative location of the src label into the target location | 1479 // Loads the ip-relative location of the src label into the target location |
1517 // (as a 32-bit offset sign extended to 64-bit). | 1480 // (as a 32-bit offset sign extended to 64-bit). |
1518 void Assembler::movl(const Operand& dst, Label* src) { | 1481 void Assembler::movl(const Operand& dst, Label* src) { |
1519 EnsureSpace ensure_space(this); | 1482 EnsureSpace ensure_space(this); |
1520 emit_optional_rex_32(dst); | 1483 emit_optional_rex_32(dst); |
1521 emit(0xC7); | 1484 emit(0xC7); |
1522 emit_operand(0, dst); | 1485 emit_operand(0, dst); |
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3217 bool RelocInfo::IsCodedSpecially() { | 3180 bool RelocInfo::IsCodedSpecially() { |
3218 // The deserializer needs to know whether a pointer is specially coded. Being | 3181 // The deserializer needs to know whether a pointer is specially coded. Being |
3219 // specially coded on x64 means that it is a relative 32 bit address, as used | 3182 // specially coded on x64 means that it is a relative 32 bit address, as used |
3220 // by branch instructions. | 3183 // by branch instructions. |
3221 return (1 << rmode_) & kApplyMask; | 3184 return (1 << rmode_) & kApplyMask; |
3222 } | 3185 } |
3223 | 3186 |
3224 } } // namespace v8::internal | 3187 } } // namespace v8::internal |
3225 | 3188 |
3226 #endif // V8_TARGET_ARCH_X64 | 3189 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |