Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: src/x64/assembler-x64.cc

Issue 133443009: A64: Synchronize with r17441. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 37
38 // ----------------------------------------------------------------------------- 38 // -----------------------------------------------------------------------------
39 // Implementation of CpuFeatures 39 // Implementation of CpuFeatures
40 40
41 41
42 #ifdef DEBUG 42 #ifdef DEBUG
43 bool CpuFeatures::initialized_ = false; 43 bool CpuFeatures::initialized_ = false;
44 #endif 44 #endif
45 uint64_t CpuFeatures::supported_ = CpuFeatures::kDefaultCpuFeatures; 45 uint64_t CpuFeatures::supported_ = CpuFeatures::kDefaultCpuFeatures;
46 uint64_t CpuFeatures::found_by_runtime_probing_only_ = 0; 46 uint64_t CpuFeatures::found_by_runtime_probing_only_ = 0;
47 47 uint64_t CpuFeatures::cross_compile_ = 0;
48 48
49 ExternalReference ExternalReference::cpu_features() { 49 ExternalReference ExternalReference::cpu_features() {
50 ASSERT(CpuFeatures::initialized_); 50 ASSERT(CpuFeatures::initialized_);
51 return ExternalReference(&CpuFeatures::supported_); 51 return ExternalReference(&CpuFeatures::supported_);
52 } 52 }
53 53
54 54
55 void CpuFeatures::Probe() { 55 void CpuFeatures::Probe() {
56 ASSERT(supported_ == CpuFeatures::kDefaultCpuFeatures); 56 ASSERT(supported_ == CpuFeatures::kDefaultCpuFeatures);
57 #ifdef DEBUG 57 #ifdef DEBUG
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Create a code patcher. 103 // Create a code patcher.
104 CodePatcher patcher(pc_, code_size); 104 CodePatcher patcher(pc_, code_size);
105 105
106 // Add a label for checking the size of the code used for returning. 106 // Add a label for checking the size of the code used for returning.
107 #ifdef DEBUG 107 #ifdef DEBUG
108 Label check_codesize; 108 Label check_codesize;
109 patcher.masm()->bind(&check_codesize); 109 patcher.masm()->bind(&check_codesize);
110 #endif 110 #endif
111 111
112 // Patch the code. 112 // Patch the code.
113 patcher.masm()->movq(r10, target, RelocInfo::NONE64); 113 patcher.masm()->movq(kScratchRegister, target, RelocInfo::NONE64);
114 patcher.masm()->call(r10); 114 patcher.masm()->call(kScratchRegister);
115 115
116 // Check that the size of the code generated is as expected. 116 // Check that the size of the code generated is as expected.
117 ASSERT_EQ(Assembler::kCallSequenceLength, 117 ASSERT_EQ(Assembler::kCallSequenceLength,
118 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); 118 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
119 119
120 // Add the requested number of int3 instructions after the call. 120 // Add the requested number of int3 instructions after the call.
121 for (int i = 0; i < guard_bytes; i++) { 121 for (int i = 0; i < guard_bytes; i++) {
122 patcher.masm()->int3(); 122 patcher.masm()->int3();
123 } 123 }
124 } 124 }
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM); 1458 ASSERT(rmode > RelocInfo::LAST_GCED_ENUM);
1459 EnsureSpace ensure_space(this); 1459 EnsureSpace ensure_space(this);
1460 emit_rex_64(dst); 1460 emit_rex_64(dst);
1461 emit(0xB8 | dst.low_bits()); 1461 emit(0xB8 | dst.low_bits());
1462 emitp(value, rmode); 1462 emitp(value, rmode);
1463 } 1463 }
1464 1464
1465 1465
1466 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) { 1466 void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) {
1467 // Non-relocatable values might not need a 64-bit representation. 1467 // Non-relocatable values might not need a 64-bit representation.
1468 if (RelocInfo::IsNone(rmode)) { 1468 ASSERT(RelocInfo::IsNone(rmode));
1469 if (is_uint32(value)) { 1469 if (is_uint32(value)) {
1470 movl(dst, Immediate(static_cast<int32_t>(value))); 1470 movl(dst, Immediate(static_cast<int32_t>(value)));
1471 return; 1471 } else if (is_int32(value)) {
1472 } else if (is_int32(value)) { 1472 movq(dst, Immediate(static_cast<int32_t>(value)));
1473 movq(dst, Immediate(static_cast<int32_t>(value))); 1473 } else {
1474 return;
1475 }
1476 // Value cannot be represented by 32 bits, so do a full 64 bit immediate 1474 // Value cannot be represented by 32 bits, so do a full 64 bit immediate
1477 // value. 1475 // value.
1476 EnsureSpace ensure_space(this);
1477 emit_rex_64(dst);
1478 emit(0xB8 | dst.low_bits());
1479 emitq(value);
1478 } 1480 }
1479 EnsureSpace ensure_space(this);
1480 emit_rex_64(dst);
1481 emit(0xB8 | dst.low_bits());
1482 emitq(value, rmode);
1483 } 1481 }
1484 1482
1485 1483
1486 void Assembler::movq(Register dst, ExternalReference ref) { 1484 void Assembler::movq(Register dst, ExternalReference ref) {
1487 int64_t value = reinterpret_cast<int64_t>(ref.address()); 1485 Address value = reinterpret_cast<Address>(ref.address());
1488 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE); 1486 movq(dst, value, RelocInfo::EXTERNAL_REFERENCE);
1489 } 1487 }
1490 1488
1491 1489
1492 void Assembler::movq(const Operand& dst, Immediate value) { 1490 void Assembler::movq(const Operand& dst, Immediate value) {
1493 EnsureSpace ensure_space(this); 1491 EnsureSpace ensure_space(this);
1494 emit_rex_64(dst); 1492 emit_rex_64(dst);
1495 emit(0xC7); 1493 emit(0xC7);
1496 emit_operand(0, dst); 1494 emit_operand(0, dst);
1497 emit(value); 1495 emit(value);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 1890
1893 void Assembler::shrd(Register dst, Register src) { 1891 void Assembler::shrd(Register dst, Register src) {
1894 EnsureSpace ensure_space(this); 1892 EnsureSpace ensure_space(this);
1895 emit_rex_64(src, dst); 1893 emit_rex_64(src, dst);
1896 emit(0x0F); 1894 emit(0x0F);
1897 emit(0xAD); 1895 emit(0xAD);
1898 emit_modrm(src, dst); 1896 emit_modrm(src, dst);
1899 } 1897 }
1900 1898
1901 1899
1902 void Assembler::xchg(Register dst, Register src) { 1900 void Assembler::xchgq(Register dst, Register src) {
1903 EnsureSpace ensure_space(this); 1901 EnsureSpace ensure_space(this);
1904 if (src.is(rax) || dst.is(rax)) { // Single-byte encoding 1902 if (src.is(rax) || dst.is(rax)) { // Single-byte encoding
1905 Register other = src.is(rax) ? dst : src; 1903 Register other = src.is(rax) ? dst : src;
1906 emit_rex_64(other); 1904 emit_rex_64(other);
1907 emit(0x90 | other.low_bits()); 1905 emit(0x90 | other.low_bits());
1908 } else if (dst.low_bits() == 4) { 1906 } else if (dst.low_bits() == 4) {
1909 emit_rex_64(dst, src); 1907 emit_rex_64(dst, src);
1910 emit(0x87); 1908 emit(0x87);
1911 emit_modrm(dst, src); 1909 emit_modrm(dst, src);
1912 } else { 1910 } else {
1913 emit_rex_64(src, dst); 1911 emit_rex_64(src, dst);
1914 emit(0x87); 1912 emit(0x87);
1915 emit_modrm(src, dst); 1913 emit_modrm(src, dst);
1916 } 1914 }
1917 } 1915 }
1918 1916
1919 1917
1918 void Assembler::xchgl(Register dst, Register src) {
1919 EnsureSpace ensure_space(this);
1920 if (src.is(rax) || dst.is(rax)) { // Single-byte encoding
1921 Register other = src.is(rax) ? dst : src;
1922 emit_optional_rex_32(other);
1923 emit(0x90 | other.low_bits());
1924 } else if (dst.low_bits() == 4) {
1925 emit_optional_rex_32(dst, src);
1926 emit(0x87);
1927 emit_modrm(dst, src);
1928 } else {
1929 emit_optional_rex_32(src, dst);
1930 emit(0x87);
1931 emit_modrm(src, dst);
1932 }
1933 }
1934
1935
1920 void Assembler::store_rax(void* dst, RelocInfo::Mode mode) { 1936 void Assembler::store_rax(void* dst, RelocInfo::Mode mode) {
1921 EnsureSpace ensure_space(this); 1937 EnsureSpace ensure_space(this);
1922 emit(0x48); // REX.W 1938 emit(0x48); // REX.W
1923 emit(0xA3); 1939 emit(0xA3);
1924 emitp(dst, mode); 1940 emitp(dst, mode);
1925 } 1941 }
1926 1942
1927 1943
1928 void Assembler::store_rax(ExternalReference ref) { 1944 void Assembler::store_rax(ExternalReference ref) {
1929 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE); 1945 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 return; 2044 return;
2029 } 2045 }
2030 EnsureSpace ensure_space(this); 2046 EnsureSpace ensure_space(this);
2031 emit_optional_rex_32(rax, op); 2047 emit_optional_rex_32(rax, op);
2032 emit(0xF7); 2048 emit(0xF7);
2033 emit_operand(rax, op); // Operation code 0 2049 emit_operand(rax, op); // Operation code 0
2034 emit(mask); 2050 emit(mask);
2035 } 2051 }
2036 2052
2037 2053
2054 void Assembler::testl(const Operand& op, Register reg) {
2055 EnsureSpace ensure_space(this);
2056 emit_optional_rex_32(reg, op);
2057 emit(0x85);
2058 emit_operand(reg, op);
2059 }
2060
2061
2038 void Assembler::testq(const Operand& op, Register reg) { 2062 void Assembler::testq(const Operand& op, Register reg) {
2039 EnsureSpace ensure_space(this); 2063 EnsureSpace ensure_space(this);
2040 emit_rex_64(reg, op); 2064 emit_rex_64(reg, op);
2041 emit(0x85); 2065 emit(0x85);
2042 emit_operand(reg, op); 2066 emit_operand(reg, op);
2043 } 2067 }
2044 2068
2045 2069
2046 void Assembler::testq(Register dst, Register src) { 2070 void Assembler::testq(Register dst, Register src) {
2047 EnsureSpace ensure_space(this); 2071 EnsureSpace ensure_space(this);
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 2469
2446 2470
2447 void Assembler::emit_farith(int b1, int b2, int i) { 2471 void Assembler::emit_farith(int b1, int b2, int i) {
2448 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode 2472 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode
2449 ASSERT(is_uint3(i)); // illegal stack offset 2473 ASSERT(is_uint3(i)); // illegal stack offset
2450 emit(b1); 2474 emit(b1);
2451 emit(b2 + i); 2475 emit(b2 + i);
2452 } 2476 }
2453 2477
2454 2478
2479 // SSE operations.
2480
2481 void Assembler::andps(XMMRegister dst, XMMRegister src) {
2482 EnsureSpace ensure_space(this);
2483 emit_optional_rex_32(dst, src);
2484 emit(0x0F);
2485 emit(0x54);
2486 emit_sse_operand(dst, src);
2487 }
2488
2489
2455 // SSE 2 operations. 2490 // SSE 2 operations.
2456 2491
2457 void Assembler::movd(XMMRegister dst, Register src) { 2492 void Assembler::movd(XMMRegister dst, Register src) {
2458 EnsureSpace ensure_space(this); 2493 EnsureSpace ensure_space(this);
2459 emit(0x66); 2494 emit(0x66);
2460 emit_optional_rex_32(dst, src); 2495 emit_optional_rex_32(dst, src);
2461 emit(0x0F); 2496 emit(0x0F);
2462 emit(0x6E); 2497 emit(0x6E);
2463 emit_sse_operand(dst, src); 2498 emit_sse_operand(dst, src);
2464 } 2499 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 EnsureSpace ensure_space(this); 2582 EnsureSpace ensure_space(this);
2548 emit(0xF3); 2583 emit(0xF3);
2549 emit_rex_64(dst, src); 2584 emit_rex_64(dst, src);
2550 emit(0x0F); 2585 emit(0x0F);
2551 emit(0x6F); 2586 emit(0x6F);
2552 emit_sse_operand(dst, src); 2587 emit_sse_operand(dst, src);
2553 } 2588 }
2554 2589
2555 2590
2556 void Assembler::extractps(Register dst, XMMRegister src, byte imm8) { 2591 void Assembler::extractps(Register dst, XMMRegister src, byte imm8) {
2557 ASSERT(CpuFeatures::IsSupported(SSE4_1)); 2592 ASSERT(IsEnabled(SSE4_1));
2558 ASSERT(is_uint8(imm8)); 2593 ASSERT(is_uint8(imm8));
2559 EnsureSpace ensure_space(this); 2594 EnsureSpace ensure_space(this);
2560 emit(0x66); 2595 emit(0x66);
2561 emit_optional_rex_32(dst, src); 2596 emit_optional_rex_32(src, dst);
2562 emit(0x0F); 2597 emit(0x0F);
2563 emit(0x3A); 2598 emit(0x3A);
2564 emit(0x17); 2599 emit(0x17);
2565 emit_sse_operand(dst, src); 2600 emit_sse_operand(src, dst);
2566 emit(imm8); 2601 emit(imm8);
2567 } 2602 }
2568 2603
2569 2604
2570 void Assembler::movsd(const Operand& dst, XMMRegister src) { 2605 void Assembler::movsd(const Operand& dst, XMMRegister src) {
2571 EnsureSpace ensure_space(this); 2606 EnsureSpace ensure_space(this);
2572 emit(0xF2); // double 2607 emit(0xF2); // double
2573 emit_optional_rex_32(src, dst); 2608 emit_optional_rex_32(src, dst);
2574 emit(0x0F); 2609 emit(0x0F);
2575 emit(0x11); // store 2610 emit(0x11); // store
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2997 void Assembler::dd(uint32_t data) { 3032 void Assembler::dd(uint32_t data) {
2998 EnsureSpace ensure_space(this); 3033 EnsureSpace ensure_space(this);
2999 emitl(data); 3034 emitl(data);
3000 } 3035 }
3001 3036
3002 3037
3003 // Relocation information implementations. 3038 // Relocation information implementations.
3004 3039
3005 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { 3040 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
3006 ASSERT(!RelocInfo::IsNone(rmode)); 3041 ASSERT(!RelocInfo::IsNone(rmode));
3007 // Don't record external references unless the heap will be serialized.
3008 if (rmode == RelocInfo::EXTERNAL_REFERENCE) { 3042 if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
3043 // Don't record external references unless the heap will be serialized.
3009 #ifdef DEBUG 3044 #ifdef DEBUG
3010 if (!Serializer::enabled()) { 3045 if (!Serializer::enabled()) {
3011 Serializer::TooLateToEnableNow(); 3046 Serializer::TooLateToEnableNow();
3012 } 3047 }
3013 #endif 3048 #endif
3014 if (!Serializer::enabled() && !emit_debug_code()) { 3049 if (!Serializer::enabled() && !emit_debug_code()) {
3015 return; 3050 return;
3016 } 3051 }
3052 } else if (rmode == RelocInfo::CODE_AGE_SEQUENCE) {
3053 // Don't record psuedo relocation info for code age sequence mode.
3054 return;
3017 } 3055 }
3018 RelocInfo rinfo(pc_, rmode, data, NULL); 3056 RelocInfo rinfo(pc_, rmode, data, NULL);
3019 reloc_info_writer.Write(&rinfo); 3057 reloc_info_writer.Write(&rinfo);
3020 } 3058 }
3021 3059
3022 3060
3023 void Assembler::RecordJSReturn() { 3061 void Assembler::RecordJSReturn() {
3024 positions_recorder()->WriteRecordedPositions(); 3062 positions_recorder()->WriteRecordedPositions();
3025 EnsureSpace ensure_space(this); 3063 EnsureSpace ensure_space(this);
3026 RecordRelocInfo(RelocInfo::JS_RETURN); 3064 RecordRelocInfo(RelocInfo::JS_RETURN);
(...skipping 24 matching lines...) Expand all
3051 bool RelocInfo::IsCodedSpecially() { 3089 bool RelocInfo::IsCodedSpecially() {
3052 // The deserializer needs to know whether a pointer is specially coded. Being 3090 // The deserializer needs to know whether a pointer is specially coded. Being
3053 // specially coded on x64 means that it is a relative 32 bit address, as used 3091 // specially coded on x64 means that it is a relative 32 bit address, as used
3054 // by branch instructions. 3092 // by branch instructions.
3055 return (1 << rmode_) & kApplyMask; 3093 return (1 << rmode_) & kApplyMask;
3056 } 3094 }
3057 3095
3058 } } // namespace v8::internal 3096 } } // namespace v8::internal
3059 3097
3060 #endif // V8_TARGET_ARCH_X64 3098 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698