| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Indicate that code has changed. | 133 // Indicate that code has changed. |
| 134 CPU::FlushICache(pc_, instruction_count); | 134 CPU::FlushICache(pc_, instruction_count); |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 // ----------------------------------------------------------------------------- | 138 // ----------------------------------------------------------------------------- |
| 139 // Register constants. | 139 // Register constants. |
| 140 | 140 |
| 141 const int | 141 const int |
| 142 Register::kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters] = { | 142 Register::kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters] = { |
| 143 // rax, rbx, rdx, rcx, rdi, r8, r9, r11, r14, r15 | 143 // rax, rbx, rdx, rcx, rsi, rdi, r8, r9, r11, r14, r15 |
| 144 0, 3, 2, 1, 7, 8, 9, 11, 14, 15 | 144 0, 3, 2, 1, 6, 7, 8, 9, 11, 14, 15 |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 const int Register::kAllocationIndexByRegisterCode[kNumRegisters] = { | 147 const int Register::kAllocationIndexByRegisterCode[kNumRegisters] = { |
| 148 0, 3, 2, 1, -1, -1, -1, 4, 5, 6, -1, 7, -1, -1, 8, 9 | 148 0, 3, 2, 1, -1, -1, 4, 5, 6, 7, -1, 8, -1, -1, 9, 10 |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 | 151 |
| 152 // ----------------------------------------------------------------------------- | 152 // ----------------------------------------------------------------------------- |
| 153 // Implementation of Operand | 153 // Implementation of Operand |
| 154 | 154 |
| 155 Operand::Operand(Register base, int32_t disp) : rex_(0) { | 155 Operand::Operand(Register base, int32_t disp) : rex_(0) { |
| 156 len_ = 1; | 156 len_ = 1; |
| 157 if (base.is(rsp) || base.is(r12)) { | 157 if (base.is(rsp) || base.is(r12)) { |
| 158 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). | 158 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 | 1359 |
| 1360 void Assembler::movb(const Operand& dst, Immediate imm) { | 1360 void Assembler::movb(const Operand& dst, Immediate imm) { |
| 1361 EnsureSpace ensure_space(this); | 1361 EnsureSpace ensure_space(this); |
| 1362 emit_optional_rex_32(dst); | 1362 emit_optional_rex_32(dst); |
| 1363 emit(0xC6); | 1363 emit(0xC6); |
| 1364 emit_operand(0x0, dst); | 1364 emit_operand(0x0, dst); |
| 1365 emit(static_cast<byte>(imm.value_)); | 1365 emit(static_cast<byte>(imm.value_)); |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 | 1368 |
| 1369 void Assembler::movw(Register dst, const Operand& src) { |
| 1370 EnsureSpace ensure_space(this); |
| 1371 emit(0x66); |
| 1372 emit_optional_rex_32(dst, src); |
| 1373 emit(0x8B); |
| 1374 emit_operand(dst, src); |
| 1375 } |
| 1376 |
| 1377 |
| 1369 void Assembler::movw(const Operand& dst, Register src) { | 1378 void Assembler::movw(const Operand& dst, Register src) { |
| 1370 EnsureSpace ensure_space(this); | 1379 EnsureSpace ensure_space(this); |
| 1371 emit(0x66); | 1380 emit(0x66); |
| 1372 emit_optional_rex_32(src, dst); | 1381 emit_optional_rex_32(src, dst); |
| 1373 emit(0x89); | 1382 emit(0x89); |
| 1374 emit_operand(src, dst); | 1383 emit_operand(src, dst); |
| 1375 } | 1384 } |
| 1376 | 1385 |
| 1377 | 1386 |
| 1378 void Assembler::movw(const Operand& dst, Immediate imm) { | 1387 void Assembler::movw(const Operand& dst, Immediate imm) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 emit_rex_64(src, dst); | 1478 emit_rex_64(src, dst); |
| 1470 emit(0x89); | 1479 emit(0x89); |
| 1471 emit_operand(src, dst); | 1480 emit_operand(src, dst); |
| 1472 } | 1481 } |
| 1473 | 1482 |
| 1474 | 1483 |
| 1475 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { | 1484 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { |
| 1476 // This method must not be used with heap object references. The stored | 1485 // This method must not be used with heap object references. The stored |
| 1477 // address is not GC safe. Use the handle version instead. | 1486 // address is not GC safe. Use the handle version instead. |
| 1478 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); | 1487 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); |
| 1479 EnsureSpace ensure_space(this); | 1488 if (RelocInfo::IsNone(rmode)) { |
| 1480 emit_rex_64(dst); | 1489 movq(dst, reinterpret_cast<int64_t>(value)); |
| 1481 emit(0xB8 | dst.low_bits()); | |
| 1482 emitp(value, rmode); | |
| 1483 } | |
| 1484 | |
| 1485 | |
| 1486 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) { | |
| 1487 // Non-relocatable values might not need a 64-bit representation. | |
| 1488 ASSERT(RelocInfo::IsNone(rmode)); | |
| 1489 if (is_uint32(value)) { | |
| 1490 movl(dst, Immediate(static_cast<int32_t>(value))); | |
| 1491 } else if (is_int32(value)) { | |
| 1492 movq(dst, Immediate(static_cast<int32_t>(value))); | |
| 1493 } else { | 1490 } else { |
| 1494 // Value cannot be represented by 32 bits, so do a full 64 bit immediate | |
| 1495 // value. | |
| 1496 EnsureSpace ensure_space(this); | 1491 EnsureSpace ensure_space(this); |
| 1497 emit_rex_64(dst); | 1492 emit_rex_64(dst); |
| 1498 emit(0xB8 | dst.low_bits()); | 1493 emit(0xB8 | dst.low_bits()); |
| 1499 emitq(value); | 1494 emitp(value, rmode); |
| 1500 } | 1495 } |
| 1501 } | 1496 } |
| 1502 | 1497 |
| 1503 | 1498 |
| 1504 void Assembler::movq(Register dst, ExternalReference ref) { | 1499 void Assembler::movq(Register dst, int64_t value) { |
| 1505 Address value = reinterpret_cast<Address>(ref.address()); | 1500 EnsureSpace ensure_space(this); |
| 1506 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE); | 1501 emit_rex_64(dst); |
| 1502 emit(0xB8 | dst.low_bits()); |
| 1503 emitq(value); |
| 1507 } | 1504 } |
| 1508 | 1505 |
| 1509 | 1506 |
| 1510 void Assembler::movq(const Operand& dst, Immediate value) { | 1507 void Assembler::movq(const Operand& dst, Immediate value) { |
| 1511 EnsureSpace ensure_space(this); | 1508 EnsureSpace ensure_space(this); |
| 1512 emit_rex_64(dst); | 1509 emit_rex_64(dst); |
| 1513 emit(0xC7); | 1510 emit(0xC7); |
| 1514 emit_operand(0, dst); | 1511 emit_operand(0, dst); |
| 1515 emit(value); | 1512 emit(value); |
| 1516 } | 1513 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1534 ASSERT(src->is_unused()); | 1531 ASSERT(src->is_unused()); |
| 1535 int32_t current = pc_offset(); | 1532 int32_t current = pc_offset(); |
| 1536 emitl(current); | 1533 emitl(current); |
| 1537 src->link_to(current); | 1534 src->link_to(current); |
| 1538 } | 1535 } |
| 1539 } | 1536 } |
| 1540 | 1537 |
| 1541 | 1538 |
| 1542 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { | 1539 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { |
| 1543 AllowDeferredHandleDereference using_raw_address; | 1540 AllowDeferredHandleDereference using_raw_address; |
| 1544 // If there is no relocation info, emit the value of the handle efficiently | 1541 ASSERT(!RelocInfo::IsNone(mode)); |
| 1545 // (possibly using less that 8 bytes for the value). | 1542 EnsureSpace ensure_space(this); |
| 1546 if (RelocInfo::IsNone(mode)) { | 1543 ASSERT(value->IsHeapObject()); |
| 1547 // There is no possible reason to store a heap pointer without relocation | 1544 ASSERT(!isolate()->heap()->InNewSpace(*value)); |
| 1548 // info, so it must be a smi. | 1545 emit_rex_64(dst); |
| 1549 ASSERT(value->IsSmi()); | 1546 emit(0xB8 | dst.low_bits()); |
| 1550 movq(dst, reinterpret_cast<int64_t>(*value), RelocInfo::NONE64); | 1547 emitp(value.location(), mode); |
| 1551 } else { | |
| 1552 EnsureSpace ensure_space(this); | |
| 1553 ASSERT(value->IsHeapObject()); | |
| 1554 ASSERT(!isolate()->heap()->InNewSpace(*value)); | |
| 1555 emit_rex_64(dst); | |
| 1556 emit(0xB8 | dst.low_bits()); | |
| 1557 emitp(value.location(), mode); | |
| 1558 } | |
| 1559 } | 1548 } |
| 1560 | 1549 |
| 1561 | 1550 |
| 1562 void Assembler::movsxbq(Register dst, const Operand& src) { | 1551 void Assembler::movsxbq(Register dst, const Operand& src) { |
| 1563 EnsureSpace ensure_space(this); | 1552 EnsureSpace ensure_space(this); |
| 1564 emit_rex_64(dst, src); | 1553 emit_rex_64(dst, src); |
| 1565 emit(0x0F); | 1554 emit(0x0F); |
| 1566 emit(0xBE); | 1555 emit(0xBE); |
| 1567 emit_operand(dst, src); | 1556 emit_operand(dst, src); |
| 1568 } | 1557 } |
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 bool RelocInfo::IsCodedSpecially() { | 3107 bool RelocInfo::IsCodedSpecially() { |
| 3119 // The deserializer needs to know whether a pointer is specially coded. Being | 3108 // The deserializer needs to know whether a pointer is specially coded. Being |
| 3120 // specially coded on x64 means that it is a relative 32 bit address, as used | 3109 // specially coded on x64 means that it is a relative 32 bit address, as used |
| 3121 // by branch instructions. | 3110 // by branch instructions. |
| 3122 return (1 << rmode_) & kApplyMask; | 3111 return (1 << rmode_) & kApplyMask; |
| 3123 } | 3112 } |
| 3124 | 3113 |
| 3125 } } // namespace v8::internal | 3114 } } // namespace v8::internal |
| 3126 | 3115 |
| 3127 #endif // V8_TARGET_ARCH_X64 | 3116 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |