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 2368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 // TODO(adamk): Currently the map is only created three times per | 2379 // TODO(adamk): Currently the map is only created three times per |
2380 // isolate. If it's created more often, the map should be moved into the | 2380 // isolate. If it's created more often, the map should be moved into the |
2381 // strong root list. | 2381 // strong root list. |
2382 Handle<Map> map = NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 2382 Handle<Map> map = NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
2383 return Handle<JSWeakMap>::cast(NewJSObjectFromMap(map)); | 2383 return Handle<JSWeakMap>::cast(NewJSObjectFromMap(map)); |
2384 } | 2384 } |
2385 | 2385 |
2386 | 2386 |
2387 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, | 2387 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, |
2388 int number_of_properties, | 2388 int number_of_properties, |
2389 bool is_strong, | |
2390 bool* is_result_from_cache) { | 2389 bool* is_result_from_cache) { |
2391 const int kMapCacheSize = 128; | 2390 const int kMapCacheSize = 128; |
2392 | 2391 |
2393 // We do not cache maps for too many properties or when running builtin code. | 2392 // We do not cache maps for too many properties or when running builtin code. |
2394 // TODO(rossberg): cache strong maps properly | 2393 if (number_of_properties > kMapCacheSize || |
2395 if (number_of_properties > kMapCacheSize || is_strong || | |
2396 isolate()->bootstrapper()->IsActive()) { | 2394 isolate()->bootstrapper()->IsActive()) { |
2397 *is_result_from_cache = false; | 2395 *is_result_from_cache = false; |
2398 Handle<Map> map = Map::Create(isolate(), number_of_properties); | 2396 return Map::Create(isolate(), number_of_properties); |
2399 if (is_strong) map->set_is_strong(true); | |
2400 return map; | |
2401 } | 2397 } |
2402 *is_result_from_cache = true; | 2398 *is_result_from_cache = true; |
2403 if (number_of_properties == 0) { | 2399 if (number_of_properties == 0) { |
2404 // Reuse the initial map of the Object function if the literal has no | 2400 // Reuse the initial map of the Object function if the literal has no |
2405 // predeclared properties. | 2401 // predeclared properties. |
2406 return handle(context->object_function()->initial_map(), isolate()); | 2402 return handle(context->object_function()->initial_map(), isolate()); |
2407 } | 2403 } |
2408 int cache_index = number_of_properties - 1; | 2404 int cache_index = number_of_properties - 1; |
2409 if (context->map_cache()->IsUndefined()) { | 2405 if (context->map_cache()->IsUndefined()) { |
2410 // Allocate the new map cache for the native context. | 2406 // Allocate the new map cache for the native context. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2473 return Handle<Object>::null(); | 2469 return Handle<Object>::null(); |
2474 } | 2470 } |
2475 | 2471 |
2476 | 2472 |
2477 Handle<Object> Factory::ToBoolean(bool value) { | 2473 Handle<Object> Factory::ToBoolean(bool value) { |
2478 return value ? true_value() : false_value(); | 2474 return value ? true_value() : false_value(); |
2479 } | 2475 } |
2480 | 2476 |
2481 | 2477 |
2482 } } // namespace v8::internal | 2478 } } // namespace v8::internal |
OLD | NEW |