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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 // TODO(adamk): Currently the map is only created three times per | 2332 // TODO(adamk): Currently the map is only created three times per |
2333 // isolate. If it's created more often, the map should be moved into the | 2333 // isolate. If it's created more often, the map should be moved into the |
2334 // strong root list. | 2334 // strong root list. |
2335 Handle<Map> map = NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 2335 Handle<Map> map = NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
2336 return Handle<JSWeakMap>::cast(NewJSObjectFromMap(map)); | 2336 return Handle<JSWeakMap>::cast(NewJSObjectFromMap(map)); |
2337 } | 2337 } |
2338 | 2338 |
2339 | 2339 |
2340 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, | 2340 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, |
2341 int number_of_properties, | 2341 int number_of_properties, |
| 2342 bool is_strong, |
2342 bool* is_result_from_cache) { | 2343 bool* is_result_from_cache) { |
2343 const int kMapCacheSize = 128; | 2344 const int kMapCacheSize = 128; |
2344 | 2345 |
2345 // We do not cache maps for too many properties or when running builtin code. | 2346 // We do not cache maps for too many properties or when running builtin code. |
2346 if (number_of_properties > kMapCacheSize || | 2347 // TODO(rossberg): cache strong maps properly |
| 2348 if (number_of_properties > kMapCacheSize || is_strong || |
2347 isolate()->bootstrapper()->IsActive()) { | 2349 isolate()->bootstrapper()->IsActive()) { |
2348 *is_result_from_cache = false; | 2350 *is_result_from_cache = false; |
2349 return Map::Create(isolate(), number_of_properties); | 2351 Handle<Map> map = Map::Create(isolate(), number_of_properties); |
| 2352 if (is_strong) map->set_is_strong(true); |
| 2353 return map; |
2350 } | 2354 } |
2351 *is_result_from_cache = true; | 2355 *is_result_from_cache = true; |
2352 if (number_of_properties == 0) { | 2356 if (number_of_properties == 0) { |
2353 // Reuse the initial map of the Object function if the literal has no | 2357 // Reuse the initial map of the Object function if the literal has no |
2354 // predeclared properties. | 2358 // predeclared properties. |
2355 return handle(context->object_function()->initial_map(), isolate()); | 2359 return handle(context->object_function()->initial_map(), isolate()); |
2356 } | 2360 } |
2357 int cache_index = number_of_properties - 1; | 2361 int cache_index = number_of_properties - 1; |
2358 if (context->map_cache()->IsUndefined()) { | 2362 if (context->map_cache()->IsUndefined()) { |
2359 // Allocate the new map cache for the native context. | 2363 // Allocate the new map cache for the native context. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 return Handle<Object>::null(); | 2426 return Handle<Object>::null(); |
2423 } | 2427 } |
2424 | 2428 |
2425 | 2429 |
2426 Handle<Object> Factory::ToBoolean(bool value) { | 2430 Handle<Object> Factory::ToBoolean(bool value) { |
2427 return value ? true_value() : false_value(); | 2431 return value ? true_value() : false_value(); |
2428 } | 2432 } |
2429 | 2433 |
2430 | 2434 |
2431 } } // namespace v8::internal | 2435 } } // namespace v8::internal |
OLD | NEW |