| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 21 matching lines...) Expand all Loading... |
| 32 #include "globals.h" | 32 #include "globals.h" |
| 33 | 33 |
| 34 namespace v8 { | 34 namespace v8 { |
| 35 namespace internal { | 35 namespace internal { |
| 36 | 36 |
| 37 // Returns the index of the leading 1 bit, counting the least significant bit at | 37 // Returns the index of the leading 1 bit, counting the least significant bit at |
| 38 // index 0. (1 << IntegerLog2(x)) is a mask for the most significant bit of x. | 38 // index 0. (1 << IntegerLog2(x)) is a mask for the most significant bit of x. |
| 39 // Result is undefined if input is zero. | 39 // Result is undefined if input is zero. |
| 40 int IntegerLog2(uint32_t value); | 40 int IntegerLog2(uint32_t value); |
| 41 | 41 |
| 42 #if defined(__GNUC__) | 42 #if V8_CC_GNU |
| 43 | 43 |
| 44 inline int IntegerLog2(uint32_t value) { | 44 inline int IntegerLog2(uint32_t value) { |
| 45 return 31 - __builtin_clz(value); | 45 return 31 - __builtin_clz(value); |
| 46 } | 46 } |
| 47 | 47 |
| 48 #elif defined(_MSC_VER) | 48 #elif V8_CC_MSVC |
| 49 | 49 |
| 50 #pragma intrinsic(_BitScanReverse) | 50 #pragma intrinsic(_BitScanReverse) |
| 51 | 51 |
| 52 inline int IntegerLog2(uint32_t value) { | 52 inline int IntegerLog2(uint32_t value) { |
| 53 unsigned long result; // NOLINT: MSVC intrinsic demands this type. | 53 unsigned long result; // NOLINT: MSVC intrinsic demands this type. |
| 54 _BitScanReverse(&result, value); | 54 _BitScanReverse(&result, value); |
| 55 return result; | 55 return result; |
| 56 } | 56 } |
| 57 | 57 |
| 58 #else | 58 #else |
| (...skipping 21 matching lines...) Expand all Loading... |
| 80 | 80 |
| 81 result |= (value >> 1); | 81 result |= (value >> 1); |
| 82 | 82 |
| 83 return result; | 83 return result; |
| 84 } | 84 } |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 } } // namespace v8::internal | 87 } } // namespace v8::internal |
| 88 | 88 |
| 89 #endif // V8_MISC_INTRINSICS_H_ | 89 #endif // V8_MISC_INTRINSICS_H_ |
| OLD | NEW |