Reviewers: Jakob,
Message:
PTAL
Description:
Use the initial map of the Object function for empty object literals
BUG=
Please review this at https://codereview.chromium.org/586673002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+8, -4 lines):
M src/factory.cc
M src/hydrogen.cc
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;
}
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
9e025f7964476b753224cc5e468cc0e5e61dd596..f36bddbb03cc13607ade9e33f712fc571ce42fb0
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -11001,7 +11001,8 @@ HInstruction*
HOptimizedGraphBuilder::BuildFastLiteral(
}
// Copy in-object properties.
- if (boilerplate_object->map()->NumberOfFields() != 0) {
+ if (boilerplate_object->map()->NumberOfFields() != 0 ||
+ boilerplate_object->map()->unused_property_fields() > 0) {
BuildEmitInObjectProperties(boilerplate_object, object, site_context,
pretenure_flag);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.