Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: src/factory.cc

Issue 586673002: Use the initial map of the Object function for empty object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make unused properties of Object be inobject Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 if (context->map_cache()->IsUndefined()) { 2321 if (context->map_cache()->IsUndefined()) {
2322 // Allocate the new map cache for the native context. 2322 // Allocate the new map cache for the native context.
2323 Handle<MapCache> new_cache = MapCache::New(isolate(), 24); 2323 Handle<MapCache> new_cache = MapCache::New(isolate(), 24);
2324 context->set_map_cache(*new_cache); 2324 context->set_map_cache(*new_cache);
2325 } 2325 }
2326 // Check to see whether there is a matching element in the cache. 2326 // Check to see whether there is a matching element in the cache.
2327 Handle<MapCache> cache = 2327 Handle<MapCache> cache =
2328 Handle<MapCache>(MapCache::cast(context->map_cache())); 2328 Handle<MapCache>(MapCache::cast(context->map_cache()));
2329 Handle<Object> result = Handle<Object>(cache->Lookup(*keys), isolate()); 2329 Handle<Object> result = Handle<Object>(cache->Lookup(*keys), isolate());
2330 if (result->IsMap()) return Handle<Map>::cast(result); 2330 if (result->IsMap()) return Handle<Map>::cast(result);
2331 // Create a new map and add it to the cache. 2331 int length = keys->length();
2332 Handle<Map> map = Map::Create( 2332 // Create a new map and add it to the cache. Reuse the initial map of the
2333 handle(context->object_function()), keys->length()); 2333 // Object function if the literal has no predeclared properties.
2334 Handle<Map> map =
2335 length == 0 ? handle(context->object_function()->initial_map())
2336 : Map::Create(handle(context->object_function()), length);
2334 AddToMapCache(context, keys, map); 2337 AddToMapCache(context, keys, map);
2335 return map; 2338 return map;
2336 } 2339 }
2337 2340
2338 2341
2339 void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp, 2342 void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp,
2340 JSRegExp::Type type, 2343 JSRegExp::Type type,
2341 Handle<String> source, 2344 Handle<String> source,
2342 JSRegExp::Flags flags, 2345 JSRegExp::Flags flags,
2343 Handle<Object> data) { 2346 Handle<Object> data) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 return Handle<Object>::null(); 2397 return Handle<Object>::null();
2395 } 2398 }
2396 2399
2397 2400
2398 Handle<Object> Factory::ToBoolean(bool value) { 2401 Handle<Object> Factory::ToBoolean(bool value) {
2399 return value ? true_value() : false_value(); 2402 return value ? true_value() : false_value();
2400 } 2403 }
2401 2404
2402 2405
2403 } } // namespace v8::internal 2406 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698