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

Side by Side Diff: src/IceUtils.h

Issue 874353006: Write out global initializers and data rel directly to ELF file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: tweak comment Created 5 years, 10 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
OLDNEW
1 //===- subzero/src/IceUtils.h - Utility functions ---------------*- C++ -*-===// 1 //===- subzero/src/IceUtils.h - Utility functions ---------------*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares some utility functions. 10 // This file declares some utility functions.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 assert((0 < N) && 46 assert((0 < N) &&
47 (static_cast<unsigned int>(N) < (CHAR_BIT * sizeof(value)))); 47 (static_cast<unsigned int>(N) < (CHAR_BIT * sizeof(value))));
48 T limit = static_cast<T>(1) << N; 48 T limit = static_cast<T>(1) << N;
49 return (0 <= value) && (value < limit); 49 return (0 <= value) && (value < limit);
50 } 50 }
51 51
52 template <typename T> static inline bool WouldOverflowAdd(T X, T Y) { 52 template <typename T> static inline bool WouldOverflowAdd(T X, T Y) {
53 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) || 53 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) ||
54 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y))); 54 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y)));
55 } 55 }
56
57 static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) {
58 assert(llvm::isPowerOf2_64(Align));
59 uint64_t Mod = Pos & (Align - 1);
60 if (Mod == 0)
61 return 0;
62 return Align - Mod;
63 }
56 }; 64 };
57 65
58 // BoundedProducerConsumerQueue is a work queue that allows multiple 66 // BoundedProducerConsumerQueue is a work queue that allows multiple
59 // producers and multiple consumers. A producer adds entries using 67 // producers and multiple consumers. A producer adds entries using
60 // blockingPush(), and may block if the queue is "full". A producer 68 // blockingPush(), and may block if the queue is "full". A producer
61 // uses notifyEnd() to indicate that no more entries will be added. A 69 // uses notifyEnd() to indicate that no more entries will be added. A
62 // consumer removes an item using blockingPop(), which will return 70 // consumer removes an item using blockingPop(), which will return
63 // nullptr if notifyEnd() has been called and the queue is empty (it 71 // nullptr if notifyEnd() has been called and the queue is empty (it
64 // never returns nullptr if the queue contained any items). 72 // never returns nullptr if the queue contained any items).
65 // 73 //
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 186 }
179 T *pop() { 187 T *pop() {
180 assert(!empty()); 188 assert(!empty());
181 return WorkItems[Front++ & MaxStaticSizeMask]; 189 return WorkItems[Front++ & MaxStaticSizeMask];
182 } 190 }
183 }; 191 };
184 192
185 } // end of namespace Ice 193 } // end of namespace Ice
186 194
187 #endif // SUBZERO_SRC_ICEUTILS_H 195 #endif // SUBZERO_SRC_ICEUTILS_H
OLDNEW
« src/IceELFObjectWriter.cpp ('K') | « src/IceTranslator.cpp ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698