| 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/conversions.h" | 9 #include "src/conversions.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 return undefined_value(); | 2142 return undefined_value(); |
| 2143 } | 2143 } |
| 2144 | 2144 |
| 2145 | 2145 |
| 2146 void Factory::SetNumberStringCache(Handle<Object> number, | 2146 void Factory::SetNumberStringCache(Handle<Object> number, |
| 2147 Handle<String> string) { | 2147 Handle<String> string) { |
| 2148 int hash = NumberCacheHash(number_string_cache(), number); | 2148 int hash = NumberCacheHash(number_string_cache(), number); |
| 2149 if (number_string_cache()->get(hash * 2) != *undefined_value()) { | 2149 if (number_string_cache()->get(hash * 2) != *undefined_value()) { |
| 2150 int full_size = isolate()->heap()->FullSizeNumberStringCacheLength(); | 2150 int full_size = isolate()->heap()->FullSizeNumberStringCacheLength(); |
| 2151 if (number_string_cache()->length() != full_size) { | 2151 if (number_string_cache()->length() != full_size) { |
| 2152 // The first time we have a hash collision, we move to the full sized | |
| 2153 // number string cache. The idea is to have a small number string | |
| 2154 // cache in the snapshot to keep boot-time memory usage down. | |
| 2155 // If we expand the number string cache already while creating | |
| 2156 // the snapshot then that didn't work out. | |
| 2157 DCHECK(!isolate()->serializer_enabled()); | |
| 2158 Handle<FixedArray> new_cache = NewFixedArray(full_size, TENURED); | 2152 Handle<FixedArray> new_cache = NewFixedArray(full_size, TENURED); |
| 2159 isolate()->heap()->set_number_string_cache(*new_cache); | 2153 isolate()->heap()->set_number_string_cache(*new_cache); |
| 2160 return; | 2154 return; |
| 2161 } | 2155 } |
| 2162 } | 2156 } |
| 2163 number_string_cache()->set(hash * 2, *number); | 2157 number_string_cache()->set(hash * 2, *number); |
| 2164 number_string_cache()->set(hash * 2 + 1, *string); | 2158 number_string_cache()->set(hash * 2 + 1, *string); |
| 2165 } | 2159 } |
| 2166 | 2160 |
| 2167 | 2161 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2519 return Handle<Object>::null(); | 2513 return Handle<Object>::null(); |
| 2520 } | 2514 } |
| 2521 | 2515 |
| 2522 | 2516 |
| 2523 Handle<Object> Factory::ToBoolean(bool value) { | 2517 Handle<Object> Factory::ToBoolean(bool value) { |
| 2524 return value ? true_value() : false_value(); | 2518 return value ? true_value() : false_value(); |
| 2525 } | 2519 } |
| 2526 | 2520 |
| 2527 | 2521 |
| 2528 } } // namespace v8::internal | 2522 } } // namespace v8::internal |
| OLD | NEW |