| 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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 if (!src.is_byte_register()) { | 1350 if (!src.is_byte_register()) { |
| 1351 emit_rex_32(src, dst); | 1351 emit_rex_32(src, dst); |
| 1352 } else { | 1352 } else { |
| 1353 emit_optional_rex_32(src, dst); | 1353 emit_optional_rex_32(src, dst); |
| 1354 } | 1354 } |
| 1355 emit(0x88); | 1355 emit(0x88); |
| 1356 emit_operand(src, dst); | 1356 emit_operand(src, dst); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 | 1359 |
| 1360 void Assembler::movb(const Operand& dst, Immediate imm) { |
| 1361 EnsureSpace ensure_space(this); |
| 1362 emit_optional_rex_32(dst); |
| 1363 emit(0xC6); |
| 1364 emit_operand(0x0, dst); |
| 1365 emit(static_cast<byte>(imm.value_)); |
| 1366 } |
| 1367 |
| 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 |
| 1360 void Assembler::movw(const Operand& dst, Register src) { | 1378 void Assembler::movw(const Operand& dst, Register src) { |
| 1361 EnsureSpace ensure_space(this); | 1379 EnsureSpace ensure_space(this); |
| 1362 emit(0x66); | 1380 emit(0x66); |
| 1363 emit_optional_rex_32(src, dst); | 1381 emit_optional_rex_32(src, dst); |
| 1364 emit(0x89); | 1382 emit(0x89); |
| 1365 emit_operand(src, dst); | 1383 emit_operand(src, dst); |
| 1366 } | 1384 } |
| 1367 | 1385 |
| 1368 | 1386 |
| 1387 void Assembler::movw(const Operand& dst, Immediate imm) { |
| 1388 EnsureSpace ensure_space(this); |
| 1389 emit(0x66); |
| 1390 emit_optional_rex_32(dst); |
| 1391 emit(0xC7); |
| 1392 emit_operand(0x0, dst); |
| 1393 emit(static_cast<byte>(imm.value_ & 0xff)); |
| 1394 emit(static_cast<byte>(imm.value_ >> 8)); |
| 1395 } |
| 1396 |
| 1397 |
| 1369 void Assembler::movl(Register dst, const Operand& src) { | 1398 void Assembler::movl(Register dst, const Operand& src) { |
| 1370 EnsureSpace ensure_space(this); | 1399 EnsureSpace ensure_space(this); |
| 1371 emit_optional_rex_32(dst, src); | 1400 emit_optional_rex_32(dst, src); |
| 1372 emit(0x8B); | 1401 emit(0x8B); |
| 1373 emit_operand(dst, src); | 1402 emit_operand(dst, src); |
| 1374 } | 1403 } |
| 1375 | 1404 |
| 1376 | 1405 |
| 1377 void Assembler::movl(Register dst, Register src) { | 1406 void Assembler::movl(Register dst, Register src) { |
| 1378 EnsureSpace ensure_space(this); | 1407 EnsureSpace ensure_space(this); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 emit_rex_64(src, dst); | 1478 emit_rex_64(src, dst); |
| 1450 emit(0x89); | 1479 emit(0x89); |
| 1451 emit_operand(src, dst); | 1480 emit_operand(src, dst); |
| 1452 } | 1481 } |
| 1453 | 1482 |
| 1454 | 1483 |
| 1455 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { | 1484 void Assembler::movq(Register dst, void* value, RelocInfo::Mode rmode) { |
| 1456 // 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 |
| 1457 // address is not GC safe. Use the handle version instead. | 1486 // address is not GC safe. Use the handle version instead. |
| 1458 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); | 1487 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); |
| 1459 EnsureSpace ensure_space(this); | 1488 if (RelocInfo::IsNone(rmode)) { |
| 1460 emit_rex_64(dst); | 1489 movq(dst, reinterpret_cast<int64_t>(value)); |
| 1461 emit(0xB8 | dst.low_bits()); | |
| 1462 emitp(value, rmode); | |
| 1463 } | |
| 1464 | |
| 1465 | |
| 1466 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) { | |
| 1467 // Non-relocatable values might not need a 64-bit representation. | |
| 1468 ASSERT(RelocInfo::IsNone(rmode)); | |
| 1469 if (is_uint32(value)) { | |
| 1470 movl(dst, Immediate(static_cast<int32_t>(value))); | |
| 1471 } else if (is_int32(value)) { | |
| 1472 movq(dst, Immediate(static_cast<int32_t>(value))); | |
| 1473 } else { | 1490 } else { |
| 1474 // Value cannot be represented by 32 bits, so do a full 64 bit immediate | |
| 1475 // value. | |
| 1476 EnsureSpace ensure_space(this); | 1491 EnsureSpace ensure_space(this); |
| 1477 emit_rex_64(dst); | 1492 emit_rex_64(dst); |
| 1478 emit(0xB8 | dst.low_bits()); | 1493 emit(0xB8 | dst.low_bits()); |
| 1479 emitq(value); | 1494 emitp(value, rmode); |
| 1480 } | 1495 } |
| 1481 } | 1496 } |
| 1482 | 1497 |
| 1483 | 1498 |
| 1484 void Assembler::movq(Register dst, ExternalReference ref) { | 1499 void Assembler::movq(Register dst, int64_t value) { |
| 1485 Address value = reinterpret_cast<Address>(ref.address()); | 1500 EnsureSpace ensure_space(this); |
| 1486 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE); | 1501 emit_rex_64(dst); |
| 1502 emit(0xB8 | dst.low_bits()); |
| 1503 emitq(value); |
| 1487 } | 1504 } |
| 1488 | 1505 |
| 1489 | 1506 |
| 1490 void Assembler::movq(const Operand& dst, Immediate value) { | 1507 void Assembler::movq(const Operand& dst, Immediate value) { |
| 1491 EnsureSpace ensure_space(this); | 1508 EnsureSpace ensure_space(this); |
| 1492 emit_rex_64(dst); | 1509 emit_rex_64(dst); |
| 1493 emit(0xC7); | 1510 emit(0xC7); |
| 1494 emit_operand(0, dst); | 1511 emit_operand(0, dst); |
| 1495 emit(value); | 1512 emit(value); |
| 1496 } | 1513 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1514 ASSERT(src->is_unused()); | 1531 ASSERT(src->is_unused()); |
| 1515 int32_t current = pc_offset(); | 1532 int32_t current = pc_offset(); |
| 1516 emitl(current); | 1533 emitl(current); |
| 1517 src->link_to(current); | 1534 src->link_to(current); |
| 1518 } | 1535 } |
| 1519 } | 1536 } |
| 1520 | 1537 |
| 1521 | 1538 |
| 1522 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { | 1539 void Assembler::movq(Register dst, Handle<Object> value, RelocInfo::Mode mode) { |
| 1523 AllowDeferredHandleDereference using_raw_address; | 1540 AllowDeferredHandleDereference using_raw_address; |
| 1524 // If there is no relocation info, emit the value of the handle efficiently | 1541 ASSERT(!RelocInfo::IsNone(mode)); |
| 1525 // (possibly using less that 8 bytes for the value). | 1542 EnsureSpace ensure_space(this); |
| 1526 if (RelocInfo::IsNone(mode)) { | 1543 ASSERT(value->IsHeapObject()); |
| 1527 // There is no possible reason to store a heap pointer without relocation | 1544 ASSERT(!isolate()->heap()->InNewSpace(*value)); |
| 1528 // info, so it must be a smi. | 1545 emit_rex_64(dst); |
| 1529 ASSERT(value->IsSmi()); | 1546 emit(0xB8 | dst.low_bits()); |
| 1530 movq(dst, reinterpret_cast<int64_t>(*value), RelocInfo::NONE64); | 1547 emitp(value.location(), mode); |
| 1531 } else { | |
| 1532 EnsureSpace ensure_space(this); | |
| 1533 ASSERT(value->IsHeapObject()); | |
| 1534 ASSERT(!isolate()->heap()->InNewSpace(*value)); | |
| 1535 emit_rex_64(dst); | |
| 1536 emit(0xB8 | dst.low_bits()); | |
| 1537 emitp(value.location(), mode); | |
| 1538 } | |
| 1539 } | 1548 } |
| 1540 | 1549 |
| 1541 | 1550 |
| 1542 void Assembler::movsxbq(Register dst, const Operand& src) { | 1551 void Assembler::movsxbq(Register dst, const Operand& src) { |
| 1543 EnsureSpace ensure_space(this); | 1552 EnsureSpace ensure_space(this); |
| 1544 emit_rex_64(dst, src); | 1553 emit_rex_64(dst, src); |
| 1545 emit(0x0F); | 1554 emit(0x0F); |
| 1546 emit(0xBE); | 1555 emit(0xBE); |
| 1547 emit_operand(dst, src); | 1556 emit_operand(dst, src); |
| 1548 } | 1557 } |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2469 | 2478 |
| 2470 | 2479 |
| 2471 void Assembler::emit_farith(int b1, int b2, int i) { | 2480 void Assembler::emit_farith(int b1, int b2, int i) { |
| 2472 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode | 2481 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode |
| 2473 ASSERT(is_uint3(i)); // illegal stack offset | 2482 ASSERT(is_uint3(i)); // illegal stack offset |
| 2474 emit(b1); | 2483 emit(b1); |
| 2475 emit(b2 + i); | 2484 emit(b2 + i); |
| 2476 } | 2485 } |
| 2477 | 2486 |
| 2478 | 2487 |
| 2488 // SSE operations. |
| 2489 |
| 2490 void Assembler::andps(XMMRegister dst, XMMRegister src) { |
| 2491 EnsureSpace ensure_space(this); |
| 2492 emit_optional_rex_32(dst, src); |
| 2493 emit(0x0F); |
| 2494 emit(0x54); |
| 2495 emit_sse_operand(dst, src); |
| 2496 } |
| 2497 |
| 2498 |
| 2499 void Assembler::orps(XMMRegister dst, XMMRegister src) { |
| 2500 EnsureSpace ensure_space(this); |
| 2501 emit_optional_rex_32(dst, src); |
| 2502 emit(0x0F); |
| 2503 emit(0x56); |
| 2504 emit_sse_operand(dst, src); |
| 2505 } |
| 2506 |
| 2507 |
| 2508 void Assembler::xorps(XMMRegister dst, XMMRegister src) { |
| 2509 EnsureSpace ensure_space(this); |
| 2510 emit_optional_rex_32(dst, src); |
| 2511 emit(0x0F); |
| 2512 emit(0x57); |
| 2513 emit_sse_operand(dst, src); |
| 2514 } |
| 2515 |
| 2516 |
| 2479 // SSE 2 operations. | 2517 // SSE 2 operations. |
| 2480 | 2518 |
| 2481 void Assembler::movd(XMMRegister dst, Register src) { | 2519 void Assembler::movd(XMMRegister dst, Register src) { |
| 2482 EnsureSpace ensure_space(this); | 2520 EnsureSpace ensure_space(this); |
| 2483 emit(0x66); | 2521 emit(0x66); |
| 2484 emit_optional_rex_32(dst, src); | 2522 emit_optional_rex_32(dst, src); |
| 2485 emit(0x0F); | 2523 emit(0x0F); |
| 2486 emit(0x6E); | 2524 emit(0x6E); |
| 2487 emit_sse_operand(dst, src); | 2525 emit_sse_operand(dst, src); |
| 2488 } | 2526 } |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { | 2938 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { |
| 2901 EnsureSpace ensure_space(this); | 2939 EnsureSpace ensure_space(this); |
| 2902 emit(0x66); | 2940 emit(0x66); |
| 2903 emit_optional_rex_32(dst, src); | 2941 emit_optional_rex_32(dst, src); |
| 2904 emit(0x0F); | 2942 emit(0x0F); |
| 2905 emit(0x57); | 2943 emit(0x57); |
| 2906 emit_sse_operand(dst, src); | 2944 emit_sse_operand(dst, src); |
| 2907 } | 2945 } |
| 2908 | 2946 |
| 2909 | 2947 |
| 2910 void Assembler::xorps(XMMRegister dst, XMMRegister src) { | |
| 2911 EnsureSpace ensure_space(this); | |
| 2912 emit_optional_rex_32(dst, src); | |
| 2913 emit(0x0F); | |
| 2914 emit(0x57); | |
| 2915 emit_sse_operand(dst, src); | |
| 2916 } | |
| 2917 | |
| 2918 | |
| 2919 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { | 2948 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { |
| 2920 EnsureSpace ensure_space(this); | 2949 EnsureSpace ensure_space(this); |
| 2921 emit(0xF2); | 2950 emit(0xF2); |
| 2922 emit_optional_rex_32(dst, src); | 2951 emit_optional_rex_32(dst, src); |
| 2923 emit(0x0F); | 2952 emit(0x0F); |
| 2924 emit(0x51); | 2953 emit(0x51); |
| 2925 emit_sse_operand(dst, src); | 2954 emit_sse_operand(dst, src); |
| 2926 } | 2955 } |
| 2927 | 2956 |
| 2928 | 2957 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3078 bool RelocInfo::IsCodedSpecially() { | 3107 bool RelocInfo::IsCodedSpecially() { |
| 3079 // 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 |
| 3080 // 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 |
| 3081 // by branch instructions. | 3110 // by branch instructions. |
| 3082 return (1 << rmode_) & kApplyMask; | 3111 return (1 << rmode_) & kApplyMask; |
| 3083 } | 3112 } |
| 3084 | 3113 |
| 3085 } } // namespace v8::internal | 3114 } } // namespace v8::internal |
| 3086 | 3115 |
| 3087 #endif // V8_TARGET_ARCH_X64 | 3116 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |