OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 | 226 |
227 | 227 |
228 // Returns the minimum of the two parameters. | 228 // Returns the minimum of the two parameters. |
229 template <typename T> | 229 template <typename T> |
230 T Min(T a, T b) { | 230 T Min(T a, T b) { |
231 return a < b ? a : b; | 231 return a < b ? a : b; |
232 } | 232 } |
233 | 233 |
234 | 234 |
| 235 // Returns the negative absolute value of its argument. |
| 236 template <typename T> |
| 237 T NegAbs(T a) { |
| 238 return a < 0 ? a : -a; |
| 239 } |
| 240 |
| 241 |
235 inline int StrLength(const char* string) { | 242 inline int StrLength(const char* string) { |
236 size_t length = strlen(string); | 243 size_t length = strlen(string); |
237 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); | 244 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); |
238 return static_cast<int>(length); | 245 return static_cast<int>(length); |
239 } | 246 } |
240 | 247 |
241 | 248 |
242 // ---------------------------------------------------------------------------- | 249 // ---------------------------------------------------------------------------- |
243 // BitField is a help template for encoding and decode bitfield with | 250 // BitField is a help template for encoding and decode bitfield with |
244 // unsigned content. | 251 // unsigned content. |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 | 1109 |
1103 // Every compiled stub starts with this id. | 1110 // Every compiled stub starts with this id. |
1104 static const int kStubEntryId = 5; | 1111 static const int kStubEntryId = 5; |
1105 | 1112 |
1106 int id_; | 1113 int id_; |
1107 }; | 1114 }; |
1108 | 1115 |
1109 } } // namespace v8::internal | 1116 } } // namespace v8::internal |
1110 | 1117 |
1111 #endif // V8_UTILS_H_ | 1118 #endif // V8_UTILS_H_ |
OLD | NEW |