Chromium Code Reviews| 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 }; | 480 }; |
| 481 | 481 |
| 482 | 482 |
| 483 // ----------------------------------------------------------------------------- | 483 // ----------------------------------------------------------------------------- |
| 484 // Utility functions | 484 // Utility functions |
| 485 | 485 |
| 486 static inline bool is_intn(int x, int n) { | 486 static inline bool is_intn(int x, int n) { |
| 487 return -(1 << (n-1)) <= x && x < (1 << (n-1)); | 487 return -(1 << (n-1)) <= x && x < (1 << (n-1)); |
| 488 } | 488 } |
| 489 | 489 |
| 490 static inline bool is_int8(int x) { return is_intn(x, 8); } | |
| 491 static inline bool is_int16(int x) { return is_intn(x, 16); } | |
| 492 static inline bool is_int18(int x) { return is_intn(x, 18); } | |
| 490 static inline bool is_int24(int x) { return is_intn(x, 24); } | 493 static inline bool is_int24(int x) { return is_intn(x, 24); } |
| 491 static inline bool is_int8(int x) { return is_intn(x, 8); } | |
| 492 | 494 |
| 493 static inline bool is_uintn(int x, int n) { | 495 static inline bool is_uintn(int x, int n) { |
| 494 return (x & -(1 << n)) == 0; | 496 return (x & -(1 << n)) == 0; |
| 495 } | 497 } |
| 496 | 498 |
| 497 static inline bool is_uint2(int x) { return is_uintn(x, 2); } | 499 static inline bool is_uint2(int x) { return is_uintn(x, 2); } |
| 498 static inline bool is_uint3(int x) { return is_uintn(x, 3); } | 500 static inline bool is_uint3(int x) { return is_uintn(x, 3); } |
| 499 static inline bool is_uint4(int x) { return is_uintn(x, 4); } | 501 static inline bool is_uint4(int x) { return is_uintn(x, 4); } |
| 500 static inline bool is_uint5(int x) { return is_uintn(x, 5); } | 502 static inline bool is_uint5(int x) { return is_uintn(x, 5); } |
| 501 static inline bool is_uint6(int x) { return is_uintn(x, 6); } | 503 static inline bool is_uint6(int x) { return is_uintn(x, 6); } |
| 502 static inline bool is_uint8(int x) { return is_uintn(x, 8); } | 504 static inline bool is_uint8(int x) { return is_uintn(x, 8); } |
| 505 static inline bool is_uint10(int x) { return is_uintn(x, 10); } | |
| 503 static inline bool is_uint12(int x) { return is_uintn(x, 12); } | 506 static inline bool is_uint12(int x) { return is_uintn(x, 12); } |
| 504 static inline bool is_uint16(int x) { return is_uintn(x, 16); } | 507 static inline bool is_uint16(int x) { return is_uintn(x, 16); } |
| 505 static inline bool is_uint24(int x) { return is_uintn(x, 24); } | 508 static inline bool is_uint24(int x) { return is_uintn(x, 24); } |
| 509 static inline bool is_uint26(int x) { return is_uintn(x, 26); } | |
| 510 | |
| 511 | |
| 512 static inline uint16_t NumBitsSet(uint32_t x) { | |
|
Søren Thygesen Gjesse
2010/01/19 22:59:12
Rename NumBitsSet to NumberOfBitsSet.
How about j
Alexandre
2010/01/22 23:08:42
Now returning int. The function was renamed to Num
| |
| 513 uint32_t num_bits_set = 0; | |
| 514 for(int i=0; i<32; i++) { | |
|
Søren Thygesen Gjesse
2010/01/19 22:59:12
Please add spaces like this:
for (int i = 0; i <
Alexandre
2010/01/22 23:08:42
Style issue fixed. The body function was changed.
| |
| 515 if(x & 1<<i) num_bits_set++; | |
|
Søren Thygesen Gjesse
2010/01/19 22:59:12
Add spaces here like this
if (x & (1 << i)) num_b
Alexandre
2010/01/22 23:08:42
Style issue fixed.
On 2010/01/19 22:59:12, Søren G
| |
| 516 } | |
| 517 return num_bits_set; | |
| 518 } | |
| 519 | |
| 506 | 520 |
| 507 } } // namespace v8::internal | 521 } } // namespace v8::internal |
| 508 | 522 |
| 509 #endif // V8_ASSEMBLER_H_ | 523 #endif // V8_ASSEMBLER_H_ |
| OLD | NEW |