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

Unified Diff: src/heap.cc

Issue 7341: Allocate room for expected number of properties based on the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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/builtins-ia32.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 500)
+++ src/heap.cc (working copy)
@@ -843,6 +843,7 @@
reinterpret_cast<Map*>(result)->set_map(meta_map());
reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
+ reinterpret_cast<Map*>(result)->set_inobject_properties(0);
reinterpret_cast<Map*>(result)->set_unused_property_fields(0);
return result;
}
@@ -858,6 +859,7 @@
map->set_prototype(null_value());
map->set_constructor(null_value());
map->set_instance_size(instance_size);
+ map->set_inobject_properties(0);
map->set_instance_descriptors(empty_descriptor_array());
map->set_code_cache(empty_fixed_array());
map->set_unused_property_fields(0);
@@ -1661,8 +1663,11 @@
Object* Heap::AllocateInitialMap(JSFunction* fun) {
ASSERT(!fun->has_initial_map());
- // First create a new map.
- Object* map_obj = Heap::AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ // First create a new map with the expected number of properties being
+ // allocated in-object.
+ int expected_nof_properties = fun->shared()->expected_nof_properties();
+ Object* map_obj = Heap::AllocateMap(JS_OBJECT_TYPE,
+ JSObject::kHeaderSize + expected_nof_properties * kPointerSize);
if (map_obj->IsFailure()) return map_obj;
// Fetch or allocate prototype.
@@ -1674,7 +1679,8 @@
if (prototype->IsFailure()) return prototype;
}
Map* map = Map::cast(map_obj);
- map->set_unused_property_fields(fun->shared()->expected_nof_properties());
+ map->set_inobject_properties(expected_nof_properties);
+ map->set_unused_property_fields(expected_nof_properties);
map->set_prototype(prototype);
return map;
}
@@ -1702,7 +1708,8 @@
ASSERT(map->instance_type() != JS_FUNCTION_TYPE);
// Allocate the backing storage for the properties.
- Object* properties = AllocateFixedArray(map->unused_property_fields());
+ int prop_size = map->unused_property_fields() - map->inobject_properties();
+ Object* properties = AllocateFixedArray(prop_size);
if (properties->IsFailure()) return properties;
// Allocate the JSObject.
@@ -1751,7 +1758,8 @@
ASSERT(map->instance_size() == object->map()->instance_size());
// Allocate the backing storage for the properties.
- Object* properties = AllocateFixedArray(map->unused_property_fields());
+ int prop_size = map->unused_property_fields() - map->inobject_properties();
+ Object* properties = AllocateFixedArray(prop_size);
if (properties->IsFailure()) return properties;
// Reset the map for the object.
« no previous file with comments | « src/builtins-ia32.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698