OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 static const int kNumRegisters = 8; | 72 static const int kNumRegisters = 8; |
73 | 73 |
74 static inline const char* AllocationIndexToString(int index); | 74 static inline const char* AllocationIndexToString(int index); |
75 | 75 |
76 static inline int ToAllocationIndex(Register reg); | 76 static inline int ToAllocationIndex(Register reg); |
77 | 77 |
78 static inline Register FromAllocationIndex(int index); | 78 static inline Register FromAllocationIndex(int index); |
79 | 79 |
80 static Register from_code(int code) { | 80 static Register from_code(int code) { |
81 ASSERT(code >= 0); | 81 DCHECK(code >= 0); |
82 ASSERT(code < kNumRegisters); | 82 DCHECK(code < kNumRegisters); |
83 Register r = { code }; | 83 Register r = { code }; |
84 return r; | 84 return r; |
85 } | 85 } |
86 bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } | 86 bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } |
87 bool is(Register reg) const { return code_ == reg.code_; } | 87 bool is(Register reg) const { return code_ == reg.code_; } |
88 // eax, ebx, ecx and edx are byte registers, the rest are not. | 88 // eax, ebx, ecx and edx are byte registers, the rest are not. |
89 bool is_byte_register() const { return code_ <= 3; } | 89 bool is_byte_register() const { return code_ <= 3; } |
90 int code() const { | 90 int code() const { |
91 ASSERT(is_valid()); | 91 DCHECK(is_valid()); |
92 return code_; | 92 return code_; |
93 } | 93 } |
94 int bit() const { | 94 int bit() const { |
95 ASSERT(is_valid()); | 95 DCHECK(is_valid()); |
96 return 1 << code_; | 96 return 1 << code_; |
97 } | 97 } |
98 | 98 |
99 // Unfortunately we can't make this private in a struct. | 99 // Unfortunately we can't make this private in a struct. |
100 int code_; | 100 int code_; |
101 }; | 101 }; |
102 | 102 |
103 const int kRegister_eax_Code = 0; | 103 const int kRegister_eax_Code = 0; |
104 const int kRegister_ecx_Code = 1; | 104 const int kRegister_ecx_Code = 1; |
105 const int kRegister_edx_Code = 2; | 105 const int kRegister_edx_Code = 2; |
106 const int kRegister_ebx_Code = 3; | 106 const int kRegister_ebx_Code = 3; |
107 const int kRegister_esp_Code = 4; | 107 const int kRegister_esp_Code = 4; |
108 const int kRegister_ebp_Code = 5; | 108 const int kRegister_ebp_Code = 5; |
109 const int kRegister_esi_Code = 6; | 109 const int kRegister_esi_Code = 6; |
110 const int kRegister_edi_Code = 7; | 110 const int kRegister_edi_Code = 7; |
111 const int kRegister_no_reg_Code = -1; | 111 const int kRegister_no_reg_Code = -1; |
112 | 112 |
113 const Register eax = { kRegister_eax_Code }; | 113 const Register eax = { kRegister_eax_Code }; |
114 const Register ecx = { kRegister_ecx_Code }; | 114 const Register ecx = { kRegister_ecx_Code }; |
115 const Register edx = { kRegister_edx_Code }; | 115 const Register edx = { kRegister_edx_Code }; |
116 const Register ebx = { kRegister_ebx_Code }; | 116 const Register ebx = { kRegister_ebx_Code }; |
117 const Register esp = { kRegister_esp_Code }; | 117 const Register esp = { kRegister_esp_Code }; |
118 const Register ebp = { kRegister_ebp_Code }; | 118 const Register ebp = { kRegister_ebp_Code }; |
119 const Register esi = { kRegister_esi_Code }; | 119 const Register esi = { kRegister_esi_Code }; |
120 const Register edi = { kRegister_edi_Code }; | 120 const Register edi = { kRegister_edi_Code }; |
121 const Register no_reg = { kRegister_no_reg_Code }; | 121 const Register no_reg = { kRegister_no_reg_Code }; |
122 | 122 |
123 | 123 |
124 inline const char* Register::AllocationIndexToString(int index) { | 124 inline const char* Register::AllocationIndexToString(int index) { |
125 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 125 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); |
126 // This is the mapping of allocation indices to registers. | 126 // This is the mapping of allocation indices to registers. |
127 const char* const kNames[] = { "eax", "ecx", "edx", "ebx", "esi", "edi" }; | 127 const char* const kNames[] = { "eax", "ecx", "edx", "ebx", "esi", "edi" }; |
128 return kNames[index]; | 128 return kNames[index]; |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 inline int Register::ToAllocationIndex(Register reg) { | 132 inline int Register::ToAllocationIndex(Register reg) { |
133 ASSERT(reg.is_valid() && !reg.is(esp) && !reg.is(ebp)); | 133 DCHECK(reg.is_valid() && !reg.is(esp) && !reg.is(ebp)); |
134 return (reg.code() >= 6) ? reg.code() - 2 : reg.code(); | 134 return (reg.code() >= 6) ? reg.code() - 2 : reg.code(); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 inline Register Register::FromAllocationIndex(int index) { | 138 inline Register Register::FromAllocationIndex(int index) { |
139 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 139 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); |
140 return (index >= 4) ? from_code(index + 2) : from_code(index); | 140 return (index >= 4) ? from_code(index + 2) : from_code(index); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 struct X87Register { | 144 struct X87Register { |
145 static const int kMaxNumAllocatableRegisters = 8; | 145 static const int kMaxNumAllocatableRegisters = 8; |
146 static const int kMaxNumRegisters = 8; | 146 static const int kMaxNumRegisters = 8; |
147 static int NumAllocatableRegisters() { | 147 static int NumAllocatableRegisters() { |
148 return kMaxNumAllocatableRegisters; | 148 return kMaxNumAllocatableRegisters; |
149 } | 149 } |
150 | 150 |
151 static int ToAllocationIndex(X87Register reg) { | 151 static int ToAllocationIndex(X87Register reg) { |
152 return reg.code_; | 152 return reg.code_; |
153 } | 153 } |
154 | 154 |
155 static const char* AllocationIndexToString(int index) { | 155 static const char* AllocationIndexToString(int index) { |
156 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 156 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); |
157 const char* const names[] = { | 157 const char* const names[] = { |
158 "stX_0", "stX_1", "stX_2", "stX_3", "stX_4", | 158 "stX_0", "stX_1", "stX_2", "stX_3", "stX_4", |
159 "stX_5", "stX_6", "stX_7" | 159 "stX_5", "stX_6", "stX_7" |
160 }; | 160 }; |
161 return names[index]; | 161 return names[index]; |
162 } | 162 } |
163 | 163 |
164 static X87Register FromAllocationIndex(int index) { | 164 static X87Register FromAllocationIndex(int index) { |
165 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 165 DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); |
166 X87Register result; | 166 X87Register result; |
167 result.code_ = index; | 167 result.code_ = index; |
168 return result; | 168 return result; |
169 } | 169 } |
170 | 170 |
171 bool is_valid() const { | 171 bool is_valid() const { |
172 return 0 <= code_ && code_ < kMaxNumRegisters; | 172 return 0 <= code_ && code_ < kMaxNumRegisters; |
173 } | 173 } |
174 | 174 |
175 int code() const { | 175 int code() const { |
176 ASSERT(is_valid()); | 176 DCHECK(is_valid()); |
177 return code_; | 177 return code_; |
178 } | 178 } |
179 | 179 |
180 bool is(X87Register reg) const { | 180 bool is(X87Register reg) const { |
181 return code_ == reg.code_; | 181 return code_ == reg.code_; |
182 } | 182 } |
183 | 183 |
184 int code_; | 184 int code_; |
185 }; | 185 }; |
186 | 186 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 explicit EnsureSpace(Assembler* assembler) : assembler_(assembler) { | 1027 explicit EnsureSpace(Assembler* assembler) : assembler_(assembler) { |
1028 if (assembler_->buffer_overflow()) assembler_->GrowBuffer(); | 1028 if (assembler_->buffer_overflow()) assembler_->GrowBuffer(); |
1029 #ifdef DEBUG | 1029 #ifdef DEBUG |
1030 space_before_ = assembler_->available_space(); | 1030 space_before_ = assembler_->available_space(); |
1031 #endif | 1031 #endif |
1032 } | 1032 } |
1033 | 1033 |
1034 #ifdef DEBUG | 1034 #ifdef DEBUG |
1035 ~EnsureSpace() { | 1035 ~EnsureSpace() { |
1036 int bytes_generated = space_before_ - assembler_->available_space(); | 1036 int bytes_generated = space_before_ - assembler_->available_space(); |
1037 ASSERT(bytes_generated < assembler_->kGap); | 1037 DCHECK(bytes_generated < assembler_->kGap); |
1038 } | 1038 } |
1039 #endif | 1039 #endif |
1040 | 1040 |
1041 private: | 1041 private: |
1042 Assembler* assembler_; | 1042 Assembler* assembler_; |
1043 #ifdef DEBUG | 1043 #ifdef DEBUG |
1044 int space_before_; | 1044 int space_before_; |
1045 #endif | 1045 #endif |
1046 }; | 1046 }; |
1047 | 1047 |
1048 } } // namespace v8::internal | 1048 } } // namespace v8::internal |
1049 | 1049 |
1050 #endif // V8_X87_ASSEMBLER_X87_H_ | 1050 #endif // V8_X87_ASSEMBLER_X87_H_ |
OLD | NEW |