Commit ef701cb7 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Refactor copying of maps and descriptor arrays.

Mainly ensure we don't copy descriptor arrays we'll throw away immediately afterwards.

Review URL: https://chromiumcodereview.appspot.com/10700160

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12044 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 432576b7
......@@ -465,14 +465,15 @@ Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
}
Handle<Map> Factory::CopyMapDropDescriptors(Handle<Map> src) {
CALL_HEAP_FUNCTION(isolate(), src->CopyDropDescriptors(), Map);
Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) {
CALL_HEAP_FUNCTION(
isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map);
}
Handle<Map> Factory::CopyMap(Handle<Map> src,
int extra_inobject_properties) {
Handle<Map> copy = CopyMapDropDescriptors(src);
Handle<Map> copy = CopyWithPreallocatedFieldDescriptors(src);
// Check that we do not overflow the instance size when adding the
// extra inobject properties.
int instance_size_delta = extra_inobject_properties * kPointerSize;
......
......@@ -222,7 +222,7 @@ class Factory {
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
Handle<Map> CopyMapDropDescriptors(Handle<Map> map);
Handle<Map> CopyWithPreallocatedFieldDescriptors(Handle<Map> map);
// Copy the map adding more inobject properties if possible without
// overflowing the instance size.
......
......@@ -4180,10 +4180,10 @@ MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
InitializeJSObjectFromMap(global, dictionary, map);
// Create a new map for the global object.
{ MaybeObject* maybe_obj = map->CopyDropDescriptors();
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
Map* new_map;
{ MaybeObject* maybe_map = map->CopyDropDescriptors();
if (!maybe_map->To(&new_map)) return maybe_map;
}
Map* new_map = Map::cast(obj);
// Set up the global object as a normalized object.
global->set_map(new_map);
......
This diff is collapsed.
......@@ -4910,7 +4910,11 @@ class Map: public HeapObject {
String* name,
LookupResult* result);
MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
DescriptorArray* descriptors);
MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
NormalizedMapSharingMode sharing);
......
......@@ -2180,24 +2180,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) {
static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),
details.index());
// Construct a new field descriptors array containing the new descriptor.
Object* descriptors_unchecked;
{ MaybeObject* maybe_descriptors_unchecked =
instance_desc->CopyInsert(&new_desc);
if (!maybe_descriptors_unchecked->ToObject(&descriptors_unchecked)) {
return maybe_descriptors_unchecked;
}
DescriptorArray* new_descriptors;
{ MaybeObject* maybe_descriptors = instance_desc->CopyInsert(&new_desc);
if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
}
DescriptorArray* new_descriptors =
DescriptorArray::cast(descriptors_unchecked);
// Create a new map featuring the new field descriptors array.
Map* new_map;
{ MaybeObject* maybe_map_unchecked =
function->map()->CopyDropDescriptors();
if (!maybe_map_unchecked->To(&new_map)) {
return maybe_map_unchecked;
}
{ MaybeObject* maybe_map =
function->map()->CopyReplaceDescriptors(new_descriptors);
if (!maybe_map->To(&new_map)) return maybe_map;
}
new_map->set_instance_descriptors(new_descriptors);
function->set_map(new_map);
} else { // Dictionary properties.
// Directly manipulate the property details.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment