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

Side by Side Diff: runtime/platform/utils_linux.h

Issue 538213003: Speed up freelist by using intrinsics to find last set bit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/platform/utils_android.h ('k') | runtime/platform/utils_macos.h » ('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 (c) 2012, 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 #ifndef PLATFORM_UTILS_LINUX_H_ 5 #ifndef PLATFORM_UTILS_LINUX_H_
6 #define PLATFORM_UTILS_LINUX_H_ 6 #define PLATFORM_UTILS_LINUX_H_
7 7
8 #include <endian.h> // NOLINT 8 #include <endian.h> // NOLINT
9 9
10 namespace dart { 10 namespace dart {
11 11
12 inline int Utils::CountLeadingZeros(uword x) {
13 #if defined(ARCH_IS_32_BIT)
14 return __builtin_clzl(x);
15 #elif defined(ARCH_IS_64_BIT)
16 return __builtin_clzll(x);
17 #else
18 #error Architecture is not 32-bit or 64-bit.
19 #endif
20 }
21
22
12 inline int Utils::CountTrailingZeros(uword x) { 23 inline int Utils::CountTrailingZeros(uword x) {
13 #if defined(ARCH_IS_32_BIT) 24 #if defined(ARCH_IS_32_BIT)
14 return __builtin_ctzl(x); 25 return __builtin_ctzl(x);
15 #elif defined(ARCH_IS_64_BIT) 26 #elif defined(ARCH_IS_64_BIT)
16 return __builtin_ctzll(x); 27 return __builtin_ctzll(x);
17 #else 28 #else
18 #error Architecture is not 32-bit or 64-bit. 29 #error Architecture is not 32-bit or 64-bit.
19 #endif 30 #endif
20 }; 31 }
21 32
22 33
23 inline uint16_t Utils::HostToBigEndian16(uint16_t value) { 34 inline uint16_t Utils::HostToBigEndian16(uint16_t value) {
24 return htobe16(value); 35 return htobe16(value);
25 } 36 }
26 37
27 38
28 inline uint32_t Utils::HostToBigEndian32(uint32_t value) { 39 inline uint32_t Utils::HostToBigEndian32(uint32_t value) {
29 return htobe32(value); 40 return htobe32(value);
30 } 41 }
(...skipping 14 matching lines...) Expand all
45 } 56 }
46 57
47 58
48 inline uint64_t Utils::HostToLittleEndian64(uint64_t value) { 59 inline uint64_t Utils::HostToLittleEndian64(uint64_t value) {
49 return htole64(value); 60 return htole64(value);
50 } 61 }
51 62
52 } // namespace dart 63 } // namespace dart
53 64
54 #endif // PLATFORM_UTILS_LINUX_H_ 65 #endif // PLATFORM_UTILS_LINUX_H_
OLDNEW
« no previous file with comments | « runtime/platform/utils_android.h ('k') | runtime/platform/utils_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698