| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 }; | 499 }; |
| 500 | 500 |
| 501 | 501 |
| 502 // ----------------------------------------------------------------------------- | 502 // ----------------------------------------------------------------------------- |
| 503 // Utility functions | 503 // Utility functions |
| 504 | 504 |
| 505 static inline bool is_intn(int x, int n) { | 505 static inline bool is_intn(int x, int n) { |
| 506 return -(1 << (n-1)) <= x && x < (1 << (n-1)); | 506 return -(1 << (n-1)) <= x && x < (1 << (n-1)); |
| 507 } | 507 } |
| 508 | 508 |
| 509 static inline bool is_int8(int x) { return is_intn(x, 8); } |
| 510 static inline bool is_int16(int x) { return is_intn(x, 16); } |
| 511 static inline bool is_int18(int x) { return is_intn(x, 18); } |
| 509 static inline bool is_int24(int x) { return is_intn(x, 24); } | 512 static inline bool is_int24(int x) { return is_intn(x, 24); } |
| 510 static inline bool is_int8(int x) { return is_intn(x, 8); } | |
| 511 | 513 |
| 512 static inline bool is_uintn(int x, int n) { | 514 static inline bool is_uintn(int x, int n) { |
| 513 return (x & -(1 << n)) == 0; | 515 return (x & -(1 << n)) == 0; |
| 514 } | 516 } |
| 515 | 517 |
| 516 static inline bool is_uint2(int x) { return is_uintn(x, 2); } | 518 static inline bool is_uint2(int x) { return is_uintn(x, 2); } |
| 517 static inline bool is_uint3(int x) { return is_uintn(x, 3); } | 519 static inline bool is_uint3(int x) { return is_uintn(x, 3); } |
| 518 static inline bool is_uint4(int x) { return is_uintn(x, 4); } | 520 static inline bool is_uint4(int x) { return is_uintn(x, 4); } |
| 519 static inline bool is_uint5(int x) { return is_uintn(x, 5); } | 521 static inline bool is_uint5(int x) { return is_uintn(x, 5); } |
| 520 static inline bool is_uint6(int x) { return is_uintn(x, 6); } | 522 static inline bool is_uint6(int x) { return is_uintn(x, 6); } |
| 521 static inline bool is_uint8(int x) { return is_uintn(x, 8); } | 523 static inline bool is_uint8(int x) { return is_uintn(x, 8); } |
| 524 static inline bool is_uint10(int x) { return is_uintn(x, 10); } |
| 522 static inline bool is_uint12(int x) { return is_uintn(x, 12); } | 525 static inline bool is_uint12(int x) { return is_uintn(x, 12); } |
| 523 static inline bool is_uint16(int x) { return is_uintn(x, 16); } | 526 static inline bool is_uint16(int x) { return is_uintn(x, 16); } |
| 524 static inline bool is_uint24(int x) { return is_uintn(x, 24); } | 527 static inline bool is_uint24(int x) { return is_uintn(x, 24); } |
| 528 static inline bool is_uint26(int x) { return is_uintn(x, 26); } |
| 529 static inline bool is_uint28(int x) { return is_uintn(x, 28); } |
| 530 |
| 531 static inline int NumberOfBitsSet(uint32_t x) { |
| 532 unsigned int num_bits_set; |
| 533 for (num_bits_set = 0; x; x >>= 1) { |
| 534 num_bits_set += x & 1; |
| 535 } |
| 536 return num_bits_set; |
| 537 } |
| 525 | 538 |
| 526 } } // namespace v8::internal | 539 } } // namespace v8::internal |
| 527 | 540 |
| 528 #endif // V8_ASSEMBLER_H_ | 541 #endif // V8_ASSEMBLER_H_ |
| OLD | NEW |