| 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 "factory.h" | 5 #include "factory.h" |
| 6 | 6 |
| 7 #include "macro-assembler.h" | 7 #include "macro-assembler.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "v8conversions.h" | 9 #include "v8conversions.h" |
| 10 | 10 |
| (...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 | 2225 |
| 2226 | 2226 |
| 2227 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { | 2227 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { |
| 2228 CALL_HEAP_FUNCTION(isolate(), | 2228 CALL_HEAP_FUNCTION(isolate(), |
| 2229 MapCache::Allocate(isolate()->heap(), | 2229 MapCache::Allocate(isolate()->heap(), |
| 2230 at_least_space_for), | 2230 at_least_space_for), |
| 2231 MapCache); | 2231 MapCache); |
| 2232 } | 2232 } |
| 2233 | 2233 |
| 2234 | 2234 |
| 2235 MUST_USE_RESULT static MaybeObject* UpdateMapCacheWith(Context* context, | |
| 2236 FixedArray* keys, | |
| 2237 Map* map) { | |
| 2238 Object* result; | |
| 2239 { MaybeObject* maybe_result = | |
| 2240 MapCache::cast(context->map_cache())->Put(keys, map); | |
| 2241 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 2242 } | |
| 2243 context->set_map_cache(MapCache::cast(result)); | |
| 2244 return result; | |
| 2245 } | |
| 2246 | |
| 2247 | |
| 2248 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context, | 2235 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context, |
| 2249 Handle<FixedArray> keys, | 2236 Handle<FixedArray> keys, |
| 2250 Handle<Map> map) { | 2237 Handle<Map> map) { |
| 2251 CALL_HEAP_FUNCTION(isolate(), | 2238 Handle<MapCache> map_cache = handle(MapCache::cast(context->map_cache())); |
| 2252 UpdateMapCacheWith(*context, *keys, *map), MapCache); | 2239 Handle<MapCache> result = MapCache::Put(map_cache, keys, map); |
| 2240 context->set_map_cache(*result); |
| 2241 return result; |
| 2253 } | 2242 } |
| 2254 | 2243 |
| 2255 | 2244 |
| 2256 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, | 2245 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, |
| 2257 Handle<FixedArray> keys) { | 2246 Handle<FixedArray> keys) { |
| 2258 if (context->map_cache()->IsUndefined()) { | 2247 if (context->map_cache()->IsUndefined()) { |
| 2259 // Allocate the new map cache for the native context. | 2248 // Allocate the new map cache for the native context. |
| 2260 Handle<MapCache> new_cache = NewMapCache(24); | 2249 Handle<MapCache> new_cache = NewMapCache(24); |
| 2261 context->set_map_cache(*new_cache); | 2250 context->set_map_cache(*new_cache); |
| 2262 } | 2251 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2330 if (String::Equals(name, infinity_string())) return infinity_value(); | 2319 if (String::Equals(name, infinity_string())) return infinity_value(); |
| 2331 return Handle<Object>::null(); | 2320 return Handle<Object>::null(); |
| 2332 } | 2321 } |
| 2333 | 2322 |
| 2334 | 2323 |
| 2335 Handle<Object> Factory::ToBoolean(bool value) { | 2324 Handle<Object> Factory::ToBoolean(bool value) { |
| 2336 return value ? true_value() : false_value(); | 2325 return value ? true_value() : false_value(); |
| 2337 } | 2326 } |
| 2338 | 2327 |
| 2339 } } // namespace v8::internal | 2328 } } // namespace v8::internal |
| OLD | NEW |