OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/x64/assembler-x64.h" | 5 #include "src/x64/assembler-x64.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #if V8_TARGET_ARCH_X64 | 9 #if V8_TARGET_ARCH_X64 |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 printf( | 107 printf( |
108 "SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d BMI1=%d BMI2=%d LZCNT=%d " | 108 "SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d BMI1=%d BMI2=%d LZCNT=%d " |
109 "POPCNT=%d ATOM=%d\n", | 109 "POPCNT=%d ATOM=%d\n", |
110 CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1), | 110 CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1), |
111 CpuFeatures::IsSupported(SAHF), CpuFeatures::IsSupported(AVX), | 111 CpuFeatures::IsSupported(SAHF), CpuFeatures::IsSupported(AVX), |
112 CpuFeatures::IsSupported(FMA3), CpuFeatures::IsSupported(BMI1), | 112 CpuFeatures::IsSupported(FMA3), CpuFeatures::IsSupported(BMI1), |
113 CpuFeatures::IsSupported(BMI2), CpuFeatures::IsSupported(LZCNT), | 113 CpuFeatures::IsSupported(BMI2), CpuFeatures::IsSupported(LZCNT), |
114 CpuFeatures::IsSupported(POPCNT), CpuFeatures::IsSupported(ATOM)); | 114 CpuFeatures::IsSupported(POPCNT), CpuFeatures::IsSupported(ATOM)); |
115 } | 115 } |
116 | 116 |
| 117 // ----------------------------------------------------------------------------- |
| 118 // Implementation of RelocInfo |
| 119 |
| 120 Address RelocInfo::wasm_memory_reference() { |
| 121 DCHECK(IsWasmMemoryReference(rmode_)); |
| 122 return Memory::Address_at(pc_); |
| 123 } |
| 124 |
| 125 uint32_t RelocInfo::wasm_memory_size_reference() { |
| 126 DCHECK(IsWasmMemorySizeReference(rmode_)); |
| 127 return Memory::uint32_at(pc_); |
| 128 } |
| 129 |
| 130 void RelocInfo::update_wasm_memory_reference( |
| 131 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size, |
| 132 ICacheFlushMode icache_flush_mode) { |
| 133 DCHECK(IsWasmMemoryReference(rmode_) || IsWasmMemorySizeReference(rmode_)); |
| 134 if (IsWasmMemoryReference(rmode_)) { |
| 135 Address updated_reference; |
| 136 DCHECK(old_base <= wasm_memory_reference() && |
| 137 wasm_memory_reference() < old_base + old_size); |
| 138 updated_reference = new_base + (wasm_memory_reference() - old_base); |
| 139 DCHECK(new_base <= updated_reference && |
| 140 updated_reference < new_base + new_size); |
| 141 Memory::Address_at(pc_) = updated_reference; |
| 142 } else if (IsWasmMemorySizeReference(rmode_)) { |
| 143 uint32_t updated_size_reference; |
| 144 DCHECK(wasm_memory_size_reference() <= old_size); |
| 145 updated_size_reference = |
| 146 new_size + (wasm_memory_size_reference() - old_size); |
| 147 DCHECK(updated_size_reference <= new_size); |
| 148 Memory::uint32_at(pc_) = updated_size_reference; |
| 149 } else { |
| 150 UNREACHABLE(); |
| 151 } |
| 152 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
| 153 Assembler::FlushICache(isolate_, pc_, sizeof(int64_t)); |
| 154 } |
| 155 } |
117 | 156 |
118 // ----------------------------------------------------------------------------- | 157 // ----------------------------------------------------------------------------- |
119 // Implementation of Operand | 158 // Implementation of Operand |
120 | 159 |
121 Operand::Operand(Register base, int32_t disp) : rex_(0) { | 160 Operand::Operand(Register base, int32_t disp) : rex_(0) { |
122 len_ = 1; | 161 len_ = 1; |
123 if (base.is(rsp) || base.is(r12)) { | 162 if (base.is(rsp) || base.is(r12)) { |
124 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). | 163 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). |
125 set_sib(times_1, rsp, base); | 164 set_sib(times_1, rsp, base); |
126 } | 165 } |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 595 |
557 void Assembler::immediate_arithmetic_op(byte subcode, | 596 void Assembler::immediate_arithmetic_op(byte subcode, |
558 Register dst, | 597 Register dst, |
559 Immediate src, | 598 Immediate src, |
560 int size) { | 599 int size) { |
561 EnsureSpace ensure_space(this); | 600 EnsureSpace ensure_space(this); |
562 emit_rex(dst, size); | 601 emit_rex(dst, size); |
563 if (is_int8(src.value_)) { | 602 if (is_int8(src.value_)) { |
564 emit(0x83); | 603 emit(0x83); |
565 emit_modrm(subcode, dst); | 604 emit_modrm(subcode, dst); |
| 605 if (!RelocInfo::IsNone(src.rmode_)) { |
| 606 RecordRelocInfo(src.rmode_); |
| 607 } |
566 emit(src.value_); | 608 emit(src.value_); |
567 } else if (dst.is(rax)) { | 609 } else if (dst.is(rax)) { |
568 emit(0x05 | (subcode << 3)); | 610 emit(0x05 | (subcode << 3)); |
569 emitl(src.value_); | 611 emit(src); |
570 } else { | 612 } else { |
571 emit(0x81); | 613 emit(0x81); |
572 emit_modrm(subcode, dst); | 614 emit_modrm(subcode, dst); |
573 emitl(src.value_); | 615 emit(src); |
574 } | 616 } |
575 } | 617 } |
576 | 618 |
577 void Assembler::immediate_arithmetic_op(byte subcode, | 619 void Assembler::immediate_arithmetic_op(byte subcode, |
578 const Operand& dst, | 620 const Operand& dst, |
579 Immediate src, | 621 Immediate src, |
580 int size) { | 622 int size) { |
581 EnsureSpace ensure_space(this); | 623 EnsureSpace ensure_space(this); |
582 emit_rex(dst, size); | 624 emit_rex(dst, size); |
583 if (is_int8(src.value_)) { | 625 if (is_int8(src.value_)) { |
584 emit(0x83); | 626 emit(0x83); |
585 emit_operand(subcode, dst); | 627 emit_operand(subcode, dst); |
| 628 if (!RelocInfo::IsNone(src.rmode_)) { |
| 629 RecordRelocInfo(src.rmode_); |
| 630 } |
586 emit(src.value_); | 631 emit(src.value_); |
587 } else { | 632 } else { |
588 emit(0x81); | 633 emit(0x81); |
589 emit_operand(subcode, dst); | 634 emit_operand(subcode, dst); |
590 emitl(src.value_); | 635 emit(src); |
591 } | 636 } |
592 } | 637 } |
593 | 638 |
594 | 639 |
595 void Assembler::immediate_arithmetic_op_16(byte subcode, | 640 void Assembler::immediate_arithmetic_op_16(byte subcode, |
596 Register dst, | 641 Register dst, |
597 Immediate src) { | 642 Immediate src) { |
598 EnsureSpace ensure_space(this); | 643 EnsureSpace ensure_space(this); |
599 emit(0x66); // Operand size override prefix. | 644 emit(0x66); // Operand size override prefix. |
600 emit_optional_rex_32(dst); | 645 emit_optional_rex_32(dst); |
(...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4213 | 4258 |
4214 bool RelocInfo::IsInConstantPool() { | 4259 bool RelocInfo::IsInConstantPool() { |
4215 return false; | 4260 return false; |
4216 } | 4261 } |
4217 | 4262 |
4218 | 4263 |
4219 } // namespace internal | 4264 } // namespace internal |
4220 } // namespace v8 | 4265 } // namespace v8 |
4221 | 4266 |
4222 #endif // V8_TARGET_ARCH_X64 | 4267 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |