| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/utils.h" | 5 #include "platform/utils.h" |
| 6 | 6 |
| 7 namespace dart { | 7 namespace dart { |
| 8 | 8 |
| 9 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., | 9 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., |
| 10 // figure 3-3, page 48, where the function is called clp2. | 10 // figure 3-3, page 48, where the function is called clp2. |
| 11 uint32_t Utils::RoundUpToPowerOfTwo(uint32_t x) { | 11 uint32_t Utils::RoundUpToPowerOfTwo(uint32_t x) { |
| 12 x = x - 1; | 12 x = x - 1; |
| 13 x = x | (x >> 1); | 13 x = x | (x >> 1); |
| 14 x = x | (x >> 2); | 14 x = x | (x >> 2); |
| 15 x = x | (x >> 4); | 15 x = x | (x >> 4); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 a = (a + 0x7ed55d16) + (a << 12); | 82 a = (a + 0x7ed55d16) + (a << 12); |
| 83 a = (a ^ 0xc761c23c) ^ (a >> 19); | 83 a = (a ^ 0xc761c23c) ^ (a >> 19); |
| 84 a = (a + 0x165667b1) + (a << 5); | 84 a = (a + 0x165667b1) + (a << 5); |
| 85 a = (a + 0xd3a2646c) ^ (a << 9); | 85 a = (a + 0xd3a2646c) ^ (a << 9); |
| 86 a = (a + 0xfd7046c5) + (a << 3); | 86 a = (a + 0xfd7046c5) + (a << 3); |
| 87 a = (a ^ 0xb55a4f09) ^ (a >> 16); | 87 a = (a ^ 0xb55a4f09) ^ (a >> 16); |
| 88 return static_cast<uint32_t>(a); | 88 return static_cast<uint32_t>(a); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace dart | 91 } // namespace dart |
| OLD | NEW |