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

Side by Side Diff: runtime/vm/assembler_x64.h

Issue 11956004: Fix vm code base so that it can be built for --arch=simarm (no snapshot yet). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_ASSEMBLER_X64_H_ 5 #ifndef VM_ASSEMBLER_X64_H_
6 #define VM_ASSEMBLER_X64_H_ 6 #define VM_ASSEMBLER_X64_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_x64.h directly; use assembler.h instead. 9 #error Do not include assembler_x64.h directly; use assembler.h instead.
10 #endif 10 #endif
11 11
(...skipping 12 matching lines...) Expand all
24 24
25 int64_t value() const { return value_; } 25 int64_t value() const { return value_; }
26 26
27 bool is_int8() const { return Utils::IsInt(8, value_); } 27 bool is_int8() const { return Utils::IsInt(8, value_); }
28 bool is_uint8() const { return Utils::IsUint(8, value_); } 28 bool is_uint8() const { return Utils::IsUint(8, value_); }
29 bool is_uint16() const { return Utils::IsUint(16, value_); } 29 bool is_uint16() const { return Utils::IsUint(16, value_); }
30 bool is_int32() const { return Utils::IsInt(32, value_); } 30 bool is_int32() const { return Utils::IsInt(32, value_); }
31 31
32 private: 32 private:
33 const int64_t value_; 33 const int64_t value_;
34 34 DISALLOW_COPY_AND_ASSIGN(Immediate);
35 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(Immediate) once the mac
36 // build issue is resolved.
37 }; 35 };
38 36
39 37
40 class Operand : public ValueObject { 38 class Operand {
41 public: 39 public:
42 uint8_t rex() const { 40 uint8_t rex() const {
43 return rex_; 41 return rex_;
44 } 42 }
45 43
46 uint8_t mod() const { 44 uint8_t mod() const {
47 return (encoding_at(0) >> 6) & 3; 45 return (encoding_at(0) >> 6) & 3;
48 } 46 }
49 47
50 Register rm() const { 48 Register rm() const {
(...skipping 18 matching lines...) Expand all
69 int8_t disp8() const { 67 int8_t disp8() const {
70 ASSERT(length_ >= 2); 68 ASSERT(length_ >= 2);
71 return static_cast<int8_t>(encoding_[length_ - 1]); 69 return static_cast<int8_t>(encoding_[length_ - 1]);
72 } 70 }
73 71
74 int32_t disp32() const { 72 int32_t disp32() const {
75 ASSERT(length_ >= 5); 73 ASSERT(length_ >= 5);
76 return bit_copy<int32_t>(encoding_[length_ - 4]); 74 return bit_copy<int32_t>(encoding_[length_ - 4]);
77 } 75 }
78 76
77 Operand(const Operand& other) : length_(other.length_), rex_(other.rex_) {
78 memmove(&encoding_[0], &other.encoding_[0], other.length_);
79 }
80
81 Operand& operator=(const Operand& other) {
82 length_ = other.length_;
83 rex_ = other.rex_;
84 memmove(&encoding_[0], &other.encoding_[0], other.length_);
85 return *this;
86 }
87
79 protected: 88 protected:
80 Operand() : length_(0), rex_(REX_NONE) { } 89 Operand() : length_(0), rex_(REX_NONE) { } // Needed by subclass Address.
81 90
82 void SetModRM(int mod, Register rm) { 91 void SetModRM(int mod, Register rm) {
83 ASSERT((mod & ~3) == 0); 92 ASSERT((mod & ~3) == 0);
84 if ((rm > 7) && !((rm == R12) && (mod != 3))) { 93 if ((rm > 7) && !((rm == R12) && (mod != 3))) {
85 rex_ |= REX_B; 94 rex_ |= REX_B;
86 } 95 }
87 encoding_[0] = (mod << 6) | (rm & 7); 96 encoding_[0] = (mod << 6) | (rm & 7);
88 length_ = 1; 97 length_ = 1;
89 } 98 }
90 99
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 134 }
126 135
127 // Returns whether or not this operand is really the given register in 136 // Returns whether or not this operand is really the given register in
128 // disguise. Used from the assembler to generate better encodings. 137 // disguise. Used from the assembler to generate better encodings.
129 bool IsRegister(Register reg) const { 138 bool IsRegister(Register reg) const {
130 return ((reg > 7 ? 1 : 0) == (rex_ & REX_B)) // REX.B match. 139 return ((reg > 7 ? 1 : 0) == (rex_ & REX_B)) // REX.B match.
131 && ((encoding_at(0) & 0xF8) == 0xC0) // Addressing mode is register. 140 && ((encoding_at(0) & 0xF8) == 0xC0) // Addressing mode is register.
132 && ((encoding_at(0) & 0x07) == reg); // Register codes match. 141 && ((encoding_at(0) & 0x07) == reg); // Register codes match.
133 } 142 }
134 143
135
136 friend class Assembler; 144 friend class Assembler;
137
138 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(Operand) once the mac
139 // build issue is resolved.
140 }; 145 };
141 146
142 147
143 class Address : public Operand { 148 class Address : public Operand {
144 public: 149 public:
145 Address(Register base, int32_t disp) { 150 Address(Register base, int32_t disp) {
146 if ((disp == 0) && ((base & 7) != RBP)) { 151 if ((disp == 0) && ((base & 7) != RBP)) {
147 SetModRM(0, base); 152 SetModRM(0, base);
148 if ((base & 7) == RSP) { 153 if ((base & 7) == RSP) {
149 SetSIB(TIMES_1, RSP, base); 154 SetSIB(TIMES_1, RSP, base);
(...skipping 29 matching lines...) Expand all
179 SetModRM(1, RSP); 184 SetModRM(1, RSP);
180 SetSIB(scale, index, base); 185 SetSIB(scale, index, base);
181 SetDisp8(disp); 186 SetDisp8(disp);
182 } else { 187 } else {
183 SetModRM(2, RSP); 188 SetModRM(2, RSP);
184 SetSIB(scale, index, base); 189 SetSIB(scale, index, base);
185 SetDisp32(disp); 190 SetDisp32(disp);
186 } 191 }
187 } 192 }
188 193
189 private: 194 Address(const Address& other) : Operand(other) { }
190 Address() {}
191 195
192 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(Address) once the mac 196 Address& operator=(const Address& other) {
193 // build issue is resolved. 197 Operand::operator=(other);
198 return *this;
199 }
194 }; 200 };
195 201
196 202
197 class FieldAddress : public Address { 203 class FieldAddress : public Address {
198 public: 204 public:
199 FieldAddress(Register base, int32_t disp) 205 FieldAddress(Register base, int32_t disp)
200 : Address(base, disp - kHeapObjectTag) {} 206 : Address(base, disp - kHeapObjectTag) { }
207
201 FieldAddress(Register base, Register index, ScaleFactor scale, int32_t disp) 208 FieldAddress(Register base, Register index, ScaleFactor scale, int32_t disp)
202 : Address(base, index, scale, disp - kHeapObjectTag) {} 209 : Address(base, index, scale, disp - kHeapObjectTag) { }
210
211 FieldAddress(const FieldAddress& other) : Address(other) { }
212
213 FieldAddress& operator=(const FieldAddress& other) {
214 Address::operator=(other);
215 return *this;
216 }
203 }; 217 };
204 218
205 219
206 class Label : public ValueObject { 220 class Label : public ValueObject {
207 public: 221 public:
208 Label() : position_(0), unresolved_(0) { 222 Label() : position_(0), unresolved_(0) {
209 #ifdef DEBUG 223 #ifdef DEBUG
210 for (int i = 0; i < kMaxUnresolvedBranches; i++) { 224 for (int i = 0; i < kMaxUnresolvedBranches; i++) {
211 unresolved_near_positions_[i] = -1; 225 unresolved_near_positions_[i] = -1;
212 } 226 }
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // Debugging and bringup support. 663 // Debugging and bringup support.
650 void Stop(const char* message); 664 void Stop(const char* message);
651 void Unimplemented(const char* message); 665 void Unimplemented(const char* message);
652 void Untested(const char* message); 666 void Untested(const char* message);
653 void Unreachable(const char* message); 667 void Unreachable(const char* message);
654 668
655 static void InitializeMemoryWithBreakpoints(uword data, int length); 669 static void InitializeMemoryWithBreakpoints(uword data, int length);
656 670
657 static const char* RegisterName(Register reg); 671 static const char* RegisterName(Register reg);
658 672
659 static const char* XmmRegisterName(XmmRegister reg); 673 static const char* FpuRegisterName(FpuRegister reg);
660 674
661 private: 675 private:
662 AssemblerBuffer buffer_; 676 AssemblerBuffer buffer_;
663 int prologue_offset_; 677 int prologue_offset_;
664 678
665 class CodeComment : public ZoneAllocated { 679 class CodeComment : public ZoneAllocated {
666 public: 680 public:
667 CodeComment(intptr_t pc_offset, const String& comment) 681 CodeComment(intptr_t pc_offset, const String& comment)
668 : pc_offset_(pc_offset), comment_(comment) { } 682 : pc_offset_(pc_offset), comment_(comment) { }
669 683
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 803 }
790 804
791 805
792 inline void Assembler::EmitOperandSizeOverride() { 806 inline void Assembler::EmitOperandSizeOverride() {
793 EmitUint8(0x66); 807 EmitUint8(0x66);
794 } 808 }
795 809
796 } // namespace dart 810 } // namespace dart
797 811
798 #endif // VM_ASSEMBLER_X64_H_ 812 #endif // VM_ASSEMBLER_X64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698