OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 while (x >= 128) { | 79 while (x >= 128) { |
80 *--p = static_cast<byte>(x & 127); | 80 *--p = static_cast<byte>(x & 127); |
81 x = x >> 7; | 81 x = x >> 7; |
82 } | 82 } |
83 // x < 128 | 83 // x < 128 |
84 *--p = static_cast<byte>(x + 128); | 84 *--p = static_cast<byte>(x + 128); |
85 return p; | 85 return p; |
86 } | 86 } |
87 | 87 |
88 | 88 |
| 89 // Thomas Wang, Integer Hash Functions. |
| 90 // http://www.concentric.net/~Ttwang/tech/inthash.htm |
| 91 uint32_t ComputeIntegerHash(uint32_t key) { |
| 92 uint32_t hash = key; |
| 93 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; |
| 94 hash = hash ^ (hash >> 12); |
| 95 hash = hash + (hash << 2); |
| 96 hash = hash ^ (hash >> 4); |
| 97 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); |
| 98 hash = hash ^ (hash >> 16); |
| 99 return hash; |
| 100 } |
| 101 |
| 102 |
89 void PrintF(const char* format, ...) { | 103 void PrintF(const char* format, ...) { |
90 va_list arguments; | 104 va_list arguments; |
91 va_start(arguments, format); | 105 va_start(arguments, format); |
92 OS::VPrint(format, arguments); | 106 OS::VPrint(format, arguments); |
93 va_end(arguments); | 107 va_end(arguments); |
94 } | 108 } |
95 | 109 |
96 | 110 |
97 void Flush() { | 111 void Flush() { |
98 fflush(stdout); | 112 fflush(stdout); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 buffer_[position_] = '\0'; | 302 buffer_[position_] = '\0'; |
289 // Make sure nobody managed to add a 0-character to the | 303 // Make sure nobody managed to add a 0-character to the |
290 // buffer while building the string. | 304 // buffer while building the string. |
291 ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_)); | 305 ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_)); |
292 position_ = -1; | 306 position_ = -1; |
293 ASSERT(is_finalized()); | 307 ASSERT(is_finalized()); |
294 return buffer_.start(); | 308 return buffer_.start(); |
295 } | 309 } |
296 | 310 |
297 } } // namespace v8::internal | 311 } } // namespace v8::internal |
OLD | NEW |