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

Side by Side Diff: src/utils.h

Issue 6993057: Version 3.4.2 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 6 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 | « src/runtime.cc ('k') | src/v8natives.js » ('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 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Returns true iff x is a power of 2 (or zero). Cannot be used with the 46 // Returns true iff x is a power of 2 (or zero). Cannot be used with the
47 // maximally negative value of the type T (the -1 overflows). 47 // maximally negative value of the type T (the -1 overflows).
48 template <typename T> 48 template <typename T>
49 static inline bool IsPowerOf2(T x) { 49 static inline bool IsPowerOf2(T x) {
50 return IS_POWER_OF_TWO(x); 50 return IS_POWER_OF_TWO(x);
51 } 51 }
52 52
53 53
54 // X must be a power of 2. Returns the number of trailing zeros. 54 // X must be a power of 2. Returns the number of trailing zeros.
55 template <typename T> 55 static inline int WhichPowerOf2(uint32_t x) {
56 static inline int WhichPowerOf2(T x) {
57 ASSERT(IsPowerOf2(x)); 56 ASSERT(IsPowerOf2(x));
58 ASSERT(x != 0); 57 ASSERT(x != 0);
59 if (x < 0) return 31;
60 int bits = 0; 58 int bits = 0;
61 #ifdef DEBUG 59 #ifdef DEBUG
62 int original_x = x; 60 int original_x = x;
63 #endif 61 #endif
64 if (x >= 0x10000) { 62 if (x >= 0x10000) {
65 bits += 16; 63 bits += 16;
66 x >>= 16; 64 x >>= 16;
67 } 65 }
68 if (x >= 0x100) { 66 if (x >= 0x100) {
69 bits += 8; 67 bits += 8;
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 INLINE(Dest BitCast(const Source& source)); 789 INLINE(Dest BitCast(const Source& source));
792 790
793 template <class Dest, class Source> 791 template <class Dest, class Source>
794 inline Dest BitCast(const Source& source) { 792 inline Dest BitCast(const Source& source) {
795 return BitCastHelper<Dest, Source>::cast(source); 793 return BitCastHelper<Dest, Source>::cast(source);
796 } 794 }
797 795
798 } } // namespace v8::internal 796 } } // namespace v8::internal
799 797
800 #endif // V8_UTILS_H_ 798 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698