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

Side by Side Diff: src/x64/macro-assembler-x64.h

Issue 196139: X64: Convert smis to holding 32 bits of payload. (Closed)
Patch Set: Addressed review comments. Forwarded to head. Created 11 years, 2 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
« no previous file with comments | « src/x64/ic-x64.cc ('k') | src/x64/macro-assembler-x64.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Set the remembered set bit for [object+offset]. 65 // Set the remembered set bit for [object+offset].
66 // object is the object being stored into, value is the object being stored. 66 // object is the object being stored into, value is the object being stored.
67 // If offset is zero, then the scratch register contains the array index into 67 // If offset is zero, then the scratch register contains the array index into
68 // the elements array represented as a Smi. 68 // the elements array represented as a Smi.
69 // All registers are clobbered by the operation. 69 // All registers are clobbered by the operation.
70 void RecordWrite(Register object, 70 void RecordWrite(Register object,
71 int offset, 71 int offset,
72 Register value, 72 Register value,
73 Register scratch); 73 Register scratch);
74 74
75 // Set the remembered set bit for [object+offset].
76 // The value is known to not be a smi.
77 // object is the object being stored into, value is the object being stored.
78 // If offset is zero, then the scratch register contains the array index into
79 // the elements array represented as a Smi.
80 // All registers are clobbered by the operation.
81 void RecordWriteNonSmi(Register object,
82 int offset,
83 Register value,
84 Register scratch);
85
86
75 #ifdef ENABLE_DEBUGGER_SUPPORT 87 #ifdef ENABLE_DEBUGGER_SUPPORT
76 // --------------------------------------------------------------------------- 88 // ---------------------------------------------------------------------------
77 // Debugger Support 89 // Debugger Support
78 90
79 void SaveRegistersToMemory(RegList regs); 91 void SaveRegistersToMemory(RegList regs);
80 void RestoreRegistersFromMemory(RegList regs); 92 void RestoreRegistersFromMemory(RegList regs);
81 void PushRegistersFromMemory(RegList regs); 93 void PushRegistersFromMemory(RegList regs);
82 void PopRegistersToMemory(RegList regs); 94 void PopRegistersToMemory(RegList regs);
83 void CopyRegistersFromStackToMemory(Register base, 95 void CopyRegistersFromStackToMemory(Register base,
84 Register scratch, 96 Register scratch,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // Smi tagging, untagging and operations on tagged smis. 151 // Smi tagging, untagging and operations on tagged smis.
140 152
141 // Conversions between tagged smi values and non-tagged integer values. 153 // Conversions between tagged smi values and non-tagged integer values.
142 154
143 // Tag an integer value. The result must be known to be a valid smi value. 155 // Tag an integer value. The result must be known to be a valid smi value.
144 // Only uses the low 32 bits of the src register. 156 // Only uses the low 32 bits of the src register.
145 void Integer32ToSmi(Register dst, Register src); 157 void Integer32ToSmi(Register dst, Register src);
146 158
147 // Tag an integer value if possible, or jump the integer value cannot be 159 // Tag an integer value if possible, or jump the integer value cannot be
148 // represented as a smi. Only uses the low 32 bit of the src registers. 160 // represented as a smi. Only uses the low 32 bit of the src registers.
161 // NOTICE: Destroys the dst register even if unsuccessful!
149 void Integer32ToSmi(Register dst, Register src, Label* on_overflow); 162 void Integer32ToSmi(Register dst, Register src, Label* on_overflow);
150 163
151 // Adds constant to src and tags the result as a smi. 164 // Adds constant to src and tags the result as a smi.
152 // Result must be a valid smi. 165 // Result must be a valid smi.
153 void Integer64AddToSmi(Register dst, Register src, int constant); 166 void Integer64PlusConstantToSmi(Register dst, Register src, int constant);
154 167
155 // Convert smi to 32-bit integer. I.e., not sign extended into 168 // Convert smi to 32-bit integer. I.e., not sign extended into
156 // high 32 bits of destination. 169 // high 32 bits of destination.
157 void SmiToInteger32(Register dst, Register src); 170 void SmiToInteger32(Register dst, Register src);
158 171
159 // Convert smi to 64-bit integer (sign extended if necessary). 172 // Convert smi to 64-bit integer (sign extended if necessary).
160 void SmiToInteger64(Register dst, Register src); 173 void SmiToInteger64(Register dst, Register src);
161 174
162 // Multiply a positive smi's integer value by a power of two. 175 // Multiply a positive smi's integer value by a power of two.
163 // Provides result as 64-bit integer value. 176 // Provides result as 64-bit integer value.
164 void PositiveSmiTimesPowerOfTwoToInteger64(Register dst, 177 void PositiveSmiTimesPowerOfTwoToInteger64(Register dst,
165 Register src, 178 Register src,
166 int power); 179 int power);
167 180
181 // Simple comparison of smis.
182 void SmiCompare(Register dst, Register src);
183 void SmiCompare(Register dst, Smi* src);
184 void SmiCompare(const Operand& dst, Register src);
185 void SmiCompare(const Operand& dst, Smi* src);
186 // Sets sign and zero flags depending on value of smi in register.
187 void SmiTest(Register src);
188
168 // Functions performing a check on a known or potential smi. Returns 189 // Functions performing a check on a known or potential smi. Returns
169 // a condition that is satisfied if the check is successful. 190 // a condition that is satisfied if the check is successful.
170 191
171 // Is the value a tagged smi. 192 // Is the value a tagged smi.
172 Condition CheckSmi(Register src); 193 Condition CheckSmi(Register src);
173 194
174 // Is the value not a tagged smi.
175 Condition CheckNotSmi(Register src);
176
177 // Is the value a positive tagged smi. 195 // Is the value a positive tagged smi.
178 Condition CheckPositiveSmi(Register src); 196 Condition CheckPositiveSmi(Register src);
179 197
180 // Is the value not a positive tagged smi.
181 Condition CheckNotPositiveSmi(Register src);
182
183 // Are both values are tagged smis. 198 // Are both values are tagged smis.
184 Condition CheckBothSmi(Register first, Register second); 199 Condition CheckBothSmi(Register first, Register second);
185 200
186 // Is one of the values not a tagged smi.
187 Condition CheckNotBothSmi(Register first, Register second);
188
189 // Is the value the minimum smi value (since we are using 201 // Is the value the minimum smi value (since we are using
190 // two's complement numbers, negating the value is known to yield 202 // two's complement numbers, negating the value is known to yield
191 // a non-smi value). 203 // a non-smi value).
192 Condition CheckIsMinSmi(Register src); 204 Condition CheckIsMinSmi(Register src);
193 205
194 // Check whether a tagged smi is equal to a constant.
195 Condition CheckSmiEqualsConstant(Register src, int constant);
196
197 // Check whether a tagged smi is greater than or equal to a constant.
198 Condition CheckSmiGreaterEqualsConstant(Register src, int constant);
199
200 // Checks whether an 32-bit integer value is a valid for conversion 206 // Checks whether an 32-bit integer value is a valid for conversion
201 // to a smi. 207 // to a smi.
202 Condition CheckInteger32ValidSmiValue(Register src); 208 Condition CheckInteger32ValidSmiValue(Register src);
203 209
204 // Test-and-jump functions. Typically combines a check function 210 // Test-and-jump functions. Typically combines a check function
205 // above with a conditional jump. 211 // above with a conditional jump.
206 212
207 // Jump if the value cannot be represented by a smi. 213 // Jump if the value cannot be represented by a smi.
208 void JumpIfNotValidSmiValue(Register src, Label* on_invalid); 214 void JumpIfNotValidSmiValue(Register src, Label* on_invalid);
209 215
210 // Jump to label if the value is a tagged smi. 216 // Jump to label if the value is a tagged smi.
211 void JumpIfSmi(Register src, Label* on_smi); 217 void JumpIfSmi(Register src, Label* on_smi);
212 218
213 // Jump to label if the value is not a tagged smi. 219 // Jump to label if the value is not a tagged smi.
214 void JumpIfNotSmi(Register src, Label* on_not_smi); 220 void JumpIfNotSmi(Register src, Label* on_not_smi);
215 221
216 // Jump to label if the value is not a positive tagged smi. 222 // Jump to label if the value is not a positive tagged smi.
217 void JumpIfNotPositiveSmi(Register src, Label* on_not_smi); 223 void JumpIfNotPositiveSmi(Register src, Label* on_not_smi);
218 224
219 // Jump to label if the value is a tagged smi with value equal 225 // Jump to label if the value, which must be a tagged smi, has value equal
220 // to the constant. 226 // to the constant.
221 void JumpIfSmiEqualsConstant(Register src, int constant, Label* on_equals); 227 void JumpIfSmiEqualsConstant(Register src, Smi* constant, Label* on_equals);
222
223 // Jump to label if the value is a tagged smi with value greater than or equal
224 // to the constant.
225 void JumpIfSmiGreaterEqualsConstant(Register src,
226 int constant,
227 Label* on_equals);
228 228
229 // Jump if either or both register are not smi values. 229 // Jump if either or both register are not smi values.
230 void JumpIfNotBothSmi(Register src1, Register src2, Label* on_not_both_smi); 230 void JumpIfNotBothSmi(Register src1, Register src2, Label* on_not_both_smi);
231 231
232 // Operations on tagged smi values. 232 // Operations on tagged smi values.
233 233
234 // Smis represent a subset of integers. The subset is always equivalent to 234 // Smis represent a subset of integers. The subset is always equivalent to
235 // a two's complement interpretation of a fixed number of bits. 235 // a two's complement interpretation of a fixed number of bits.
236 236
237 // Optimistically adds an integer constant to a supposed smi. 237 // Optimistically adds an integer constant to a supposed smi.
238 // If the src is not a smi, or the result is not a smi, jump to 238 // If the src is not a smi, or the result is not a smi, jump to
239 // the label. 239 // the label.
240 void SmiTryAddConstant(Register dst, 240 void SmiTryAddConstant(Register dst,
241 Register src, 241 Register src,
242 int32_t constant, 242 Smi* constant,
243 Label* on_not_smi_result); 243 Label* on_not_smi_result);
244 244
245 // Add an integer constant to a tagged smi, giving a tagged smi as result.
246 // No overflow testing on the result is done.
247 void SmiAddConstant(Register dst, Register src, Smi* constant);
248
245 // Add an integer constant to a tagged smi, giving a tagged smi as result, 249 // Add an integer constant to a tagged smi, giving a tagged smi as result,
246 // or jumping to a label if the result cannot be represented by a smi. 250 // or jumping to a label if the result cannot be represented by a smi.
247 // If the label is NULL, no testing on the result is done.
248 void SmiAddConstant(Register dst, 251 void SmiAddConstant(Register dst,
249 Register src, 252 Register src,
250 int32_t constant, 253 Smi* constant,
251 Label* on_not_smi_result); 254 Label* on_not_smi_result);
252 255
253 // Subtract an integer constant from a tagged smi, giving a tagged smi as 256 // Subtract an integer constant from a tagged smi, giving a tagged smi as
257 // result. No testing on the result is done.
258 void SmiSubConstant(Register dst, Register src, Smi* constant);
259
260 // Subtract an integer constant from a tagged smi, giving a tagged smi as
254 // result, or jumping to a label if the result cannot be represented by a smi. 261 // result, or jumping to a label if the result cannot be represented by a smi.
255 // If the label is NULL, no testing on the result is done.
256 void SmiSubConstant(Register dst, 262 void SmiSubConstant(Register dst,
257 Register src, 263 Register src,
258 int32_t constant, 264 Smi* constant,
259 Label* on_not_smi_result); 265 Label* on_not_smi_result);
260 266
261 // Negating a smi can give a negative zero or too large positive value. 267 // Negating a smi can give a negative zero or too large positive value.
268 // NOTICE: This operation jumps on success, not failure!
262 void SmiNeg(Register dst, 269 void SmiNeg(Register dst,
263 Register src, 270 Register src,
264 Label* on_not_smi_result); 271 Label* on_smi_result);
265 272
266 // Adds smi values and return the result as a smi. 273 // Adds smi values and return the result as a smi.
267 // If dst is src1, then src1 will be destroyed, even if 274 // If dst is src1, then src1 will be destroyed, even if
268 // the operation is unsuccessful. 275 // the operation is unsuccessful.
269 void SmiAdd(Register dst, 276 void SmiAdd(Register dst,
270 Register src1, 277 Register src1,
271 Register src2, 278 Register src2,
272 Label* on_not_smi_result); 279 Label* on_not_smi_result);
273 280
274 // Subtracts smi values and return the result as a smi. 281 // Subtracts smi values and return the result as a smi.
(...skipping 25 matching lines...) Expand all
300 void SmiMod(Register dst, 307 void SmiMod(Register dst,
301 Register src1, 308 Register src1,
302 Register src2, 309 Register src2,
303 Label* on_not_smi_result); 310 Label* on_not_smi_result);
304 311
305 // Bitwise operations. 312 // Bitwise operations.
306 void SmiNot(Register dst, Register src); 313 void SmiNot(Register dst, Register src);
307 void SmiAnd(Register dst, Register src1, Register src2); 314 void SmiAnd(Register dst, Register src1, Register src2);
308 void SmiOr(Register dst, Register src1, Register src2); 315 void SmiOr(Register dst, Register src1, Register src2);
309 void SmiXor(Register dst, Register src1, Register src2); 316 void SmiXor(Register dst, Register src1, Register src2);
310 void SmiAndConstant(Register dst, Register src1, int constant); 317 void SmiAndConstant(Register dst, Register src1, Smi* constant);
311 void SmiOrConstant(Register dst, Register src1, int constant); 318 void SmiOrConstant(Register dst, Register src1, Smi* constant);
312 void SmiXorConstant(Register dst, Register src1, int constant); 319 void SmiXorConstant(Register dst, Register src1, Smi* constant);
313 320
314 void SmiShiftLeftConstant(Register dst, 321 void SmiShiftLeftConstant(Register dst,
315 Register src, 322 Register src,
316 int shift_value, 323 int shift_value,
317 Label* on_not_smi_result); 324 Label* on_not_smi_result);
318 void SmiShiftLogicalRightConstant(Register dst, 325 void SmiShiftLogicalRightConstant(Register dst,
319 Register src, 326 Register src,
320 int shift_value, 327 int shift_value,
321 Label* on_not_smi_result); 328 Label* on_not_smi_result);
322 void SmiShiftArithmeticRightConstant(Register dst, 329 void SmiShiftArithmeticRightConstant(Register dst,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // power of two to multiply the index value by (e.g. 367 // power of two to multiply the index value by (e.g.
361 // to index by smi-value * kPointerSize, pass the smi and kPointerSizeLog2). 368 // to index by smi-value * kPointerSize, pass the smi and kPointerSizeLog2).
362 // The returned index register may be either src or dst, depending 369 // The returned index register may be either src or dst, depending
363 // on what is most efficient. If src and dst are different registers, 370 // on what is most efficient. If src and dst are different registers,
364 // src is always unchanged. 371 // src is always unchanged.
365 SmiIndex SmiToIndex(Register dst, Register src, int shift); 372 SmiIndex SmiToIndex(Register dst, Register src, int shift);
366 373
367 // Converts a positive smi to a negative index. 374 // Converts a positive smi to a negative index.
368 SmiIndex SmiToNegativeIndex(Register dst, Register src, int shift); 375 SmiIndex SmiToNegativeIndex(Register dst, Register src, int shift);
369 376
377 bool IsUnsafeSmi(Smi* value);
378 void LoadUnsafeSmi(Register dst, Smi* source);
379
380 // Basic Smi operations.
381 void Move(Register dst, Smi* source);
382 void Move(const Operand& dst, Smi* source);
383 void Push(Smi* smi);
384 void Test(const Operand& dst, Smi* source);
385
370 // --------------------------------------------------------------------------- 386 // ---------------------------------------------------------------------------
371 // Macro instructions 387 // Macro instructions
372 388
373 // Expression support 389 // Load a register with a long value as efficiently as possible.
374 void Set(Register dst, int64_t x); 390 void Set(Register dst, int64_t x);
375 void Set(const Operand& dst, int64_t x); 391 void Set(const Operand& dst, int64_t x);
376 392
377 // Handle support 393 // Handle support
378 bool IsUnsafeSmi(Smi* value);
379 bool IsUnsafeSmi(Handle<Object> value) { 394 bool IsUnsafeSmi(Handle<Object> value) {
380 return IsUnsafeSmi(Smi::cast(*value)); 395 return IsUnsafeSmi(Smi::cast(*value));
381 } 396 }
382 397
383 void LoadUnsafeSmi(Register dst, Smi* source);
384 void LoadUnsafeSmi(Register dst, Handle<Object> source) { 398 void LoadUnsafeSmi(Register dst, Handle<Object> source) {
385 LoadUnsafeSmi(dst, Smi::cast(*source)); 399 LoadUnsafeSmi(dst, Smi::cast(*source));
386 } 400 }
387 401
388 void Move(Register dst, Handle<Object> source); 402 void Move(Register dst, Handle<Object> source);
389 void Move(const Operand& dst, Handle<Object> source); 403 void Move(const Operand& dst, Handle<Object> source);
390 void Cmp(Register dst, Handle<Object> source); 404 void Cmp(Register dst, Handle<Object> source);
391 void Cmp(const Operand& dst, Handle<Object> source); 405 void Cmp(const Operand& dst, Handle<Object> source);
392 void Push(Handle<Object> source); 406 void Push(Handle<Object> source);
393 void Push(Smi* smi);
394 407
395 // Control Flow 408 // Control Flow
396 void Jump(Address destination, RelocInfo::Mode rmode); 409 void Jump(Address destination, RelocInfo::Mode rmode);
397 void Jump(ExternalReference ext); 410 void Jump(ExternalReference ext);
398 void Jump(Handle<Code> code_object, RelocInfo::Mode rmode); 411 void Jump(Handle<Code> code_object, RelocInfo::Mode rmode);
399 412
400 void Call(Address destination, RelocInfo::Mode rmode); 413 void Call(Address destination, RelocInfo::Mode rmode);
401 void Call(ExternalReference ext); 414 void Call(ExternalReference ext);
402 void Call(Handle<Code> code_object, RelocInfo::Mode rmode); 415 void Call(Handle<Code> code_object, RelocInfo::Mode rmode);
403 416
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } \ 698 } \
686 masm-> 699 masm->
687 #else 700 #else
688 #define ACCESS_MASM(masm) masm-> 701 #define ACCESS_MASM(masm) masm->
689 #endif 702 #endif
690 703
691 704
692 } } // namespace v8::internal 705 } } // namespace v8::internal
693 706
694 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ 707 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « src/x64/ic-x64.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698