OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 return share; | 2154 return share; |
2155 } | 2155 } |
2156 | 2156 |
2157 | 2157 |
2158 static inline int NumberCacheHash(Handle<FixedArray> cache, | 2158 static inline int NumberCacheHash(Handle<FixedArray> cache, |
2159 Handle<Object> number) { | 2159 Handle<Object> number) { |
2160 int mask = (cache->length() >> 1) - 1; | 2160 int mask = (cache->length() >> 1) - 1; |
2161 if (number->IsSmi()) { | 2161 if (number->IsSmi()) { |
2162 return Handle<Smi>::cast(number)->value() & mask; | 2162 return Handle<Smi>::cast(number)->value() & mask; |
2163 } else { | 2163 } else { |
2164 DoubleRepresentation rep(number->Number()); | 2164 int64_t bits = bit_cast<int64_t>(number->Number()); |
2165 return | 2165 return (static_cast<int>(bits) ^ static_cast<int>(bits >> 32)) & mask; |
2166 (static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) & mask; | |
2167 } | 2166 } |
2168 } | 2167 } |
2169 | 2168 |
2170 | 2169 |
2171 Handle<Object> Factory::GetNumberStringCache(Handle<Object> number) { | 2170 Handle<Object> Factory::GetNumberStringCache(Handle<Object> number) { |
2172 DisallowHeapAllocation no_gc; | 2171 DisallowHeapAllocation no_gc; |
2173 int hash = NumberCacheHash(number_string_cache(), number); | 2172 int hash = NumberCacheHash(number_string_cache(), number); |
2174 Object* key = number_string_cache()->get(hash * 2); | 2173 Object* key = number_string_cache()->get(hash * 2); |
2175 if (key == *number || (key->IsHeapNumber() && number->IsHeapNumber() && | 2174 if (key == *number || (key->IsHeapNumber() && number->IsHeapNumber() && |
2176 key->Number() == number->Number())) { | 2175 key->Number() == number->Number())) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 } | 2376 } |
2378 | 2377 |
2379 | 2378 |
2380 Handle<Object> Factory::ToBoolean(bool value) { | 2379 Handle<Object> Factory::ToBoolean(bool value) { |
2381 return value ? true_value() : false_value(); | 2380 return value ? true_value() : false_value(); |
2382 } | 2381 } |
2383 | 2382 |
2384 | 2383 |
2385 } // namespace internal | 2384 } // namespace internal |
2386 } // namespace v8 | 2385 } // namespace v8 |
OLD | NEW |