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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/bootstrapper.cc ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 5eefda29f641cf61adcb525b1cd329c7bdd7a5fb..4e5b5592dd2b8307af94869e577462c629be849d 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -2328,9 +2328,12 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context,
Handle<MapCache>(MapCache::cast(context->map_cache()));
Handle<Object> result = Handle<Object>(cache->Lookup(*keys), isolate());
if (result->IsMap()) return Handle<Map>::cast(result);
- // Create a new map and add it to the cache.
- Handle<Map> map = Map::Create(
- handle(context->object_function()), keys->length());
+ int length = keys->length();
+ // Create a new map and add it to the cache. Reuse the initial map of the
+ // Object function if the literal has no predeclared properties.
+ Handle<Map> map =
+ length == 0 ? handle(context->object_function()->initial_map())
+ : Map::Create(handle(context->object_function()), length);
AddToMapCache(context, keys, map);
return map;
}
« 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