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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 244 } |
245 | 245 |
246 | 246 |
247 // Returns the minimum of the two parameters. | 247 // Returns the minimum of the two parameters. |
248 template <typename T> | 248 template <typename T> |
249 T Min(T a, T b) { | 249 T Min(T a, T b) { |
250 return a < b ? a : b; | 250 return a < b ? a : b; |
251 } | 251 } |
252 | 252 |
253 | 253 |
| 254 // Returns the absolute value of its argument. |
| 255 template <typename T> |
| 256 T Abs(T a) { |
| 257 return a < 0 ? -a : a; |
| 258 } |
| 259 |
| 260 |
254 // Returns the negative absolute value of its argument. | 261 // Returns the negative absolute value of its argument. |
255 template <typename T> | 262 template <typename T> |
256 T NegAbs(T a) { | 263 T NegAbs(T a) { |
257 return a < 0 ? a : -a; | 264 return a < 0 ? a : -a; |
258 } | 265 } |
259 | 266 |
260 | 267 |
261 inline int StrLength(const char* string) { | 268 inline int StrLength(const char* string) { |
262 size_t length = strlen(string); | 269 size_t length = strlen(string); |
263 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); | 270 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 | 1135 |
1129 // Every compiled stub starts with this id. | 1136 // Every compiled stub starts with this id. |
1130 static const int kStubEntryId = 5; | 1137 static const int kStubEntryId = 5; |
1131 | 1138 |
1132 int id_; | 1139 int id_; |
1133 }; | 1140 }; |
1134 | 1141 |
1135 } } // namespace v8::internal | 1142 } } // namespace v8::internal |
1136 | 1143 |
1137 #endif // V8_UTILS_H_ | 1144 #endif // V8_UTILS_H_ |
OLD | NEW |