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

Unified Diff: src/factory.cc

Issue 17308: Allocate as many object-literal properties as possible inobject.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 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/factory.h ('k') | src/handles.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
===================================================================
--- src/factory.cc (revision 1049)
+++ src/factory.cc (working copy)
@@ -195,6 +195,29 @@
}
+Handle<Map> Factory::CopyMap(Handle<Map> src,
+ int extra_inobject_properties) {
+ Handle<Map> copy = CopyMap(src);
+ // Check that we do not overflow the instance size when adding the
+ // extra inobject properties.
+ int instance_size_delta = extra_inobject_properties * kPointerSize;
+ int max_instance_size_delta =
+ JSObject::kMaxInstanceSize - copy->instance_size();
+ if (instance_size_delta > max_instance_size_delta) {
+ // If the instance size overflows, we allocate as many properties
+ // as we can as inobject properties.
+ instance_size_delta = max_instance_size_delta;
+ extra_inobject_properties = max_instance_size_delta >> kPointerSizeLog2;
+ }
+ // Adjust the map with the extra inobject properties.
+ int inobject_properties =
+ copy->inobject_properties() + extra_inobject_properties;
+ copy->set_inobject_properties(inobject_properties);
+ copy->set_unused_property_fields(inobject_properties);
+ copy->set_instance_size(copy->instance_size() + instance_size_delta);
+ return copy;
+}
+
Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) {
CALL_HEAP_FUNCTION(src->CopyDropTransitions(), Map);
}
@@ -577,16 +600,6 @@
}
-Handle<JSObject> Factory::NewObjectLiteral(int expected_number_of_properties) {
- Handle<Map> map = Handle<Map>(Top::object_function()->initial_map());
- map = Factory::CopyMap(map);
- map->set_instance_descriptors(Heap::empty_descriptor_array());
- map->set_unused_property_fields(expected_number_of_properties);
- CALL_HEAP_FUNCTION(Heap::AllocateJSObjectFromMap(*map, TENURED),
- JSObject);
-}
-
-
Handle<JSArray> Factory::NewArrayLiteral(int length) {
return NewJSArrayWithElements(NewFixedArray(length), TENURED);
}
@@ -816,7 +829,8 @@
if (result->IsMap()) return Handle<Map>::cast(result);
// Create a new map and add it to the cache.
Handle<Map> map =
- CopyMap(Handle<Map>(context->object_function()->initial_map()));
+ CopyMap(Handle<Map>(context->object_function()->initial_map()),
+ keys->length());
AddToMapCache(context, keys, map);
return Handle<Map>(map);
}
« no previous file with comments | « src/factory.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698