Commit 220fa8ea authored by ishell@chromium.org's avatar ishell@chromium.org

More set_map() calls replaced with MigrateToMap().

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/338793004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21983 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 776a6568
......@@ -3600,7 +3600,7 @@ void v8::Object::TurnOnAccessCheck() {
i::Handle<i::Map> new_map = i::Map::Copy(i::Handle<i::Map>(obj->map()));
new_map->set_is_access_check_needed(true);
obj->set_map(*new_map);
i::JSObject::MigrateToMap(obj, new_map);
}
......
......@@ -342,10 +342,10 @@ Handle<Context> Bootstrapper::CreateEnvironment(
static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
// object.__proto__ = proto;
Handle<Map> old_to_map = Handle<Map>(object->map());
Handle<Map> new_to_map = Map::Copy(old_to_map);
new_to_map->set_prototype(*proto);
object->set_map(*new_to_map);
Handle<Map> old_map = Handle<Map>(object->map());
Handle<Map> new_map = Map::Copy(old_map);
new_map->set_prototype(*proto);
JSObject::MigrateToMap(object, new_map);
}
......@@ -2540,10 +2540,8 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
TransferIndexedProperties(from, to);
// Transfer the prototype (new map is needed).
Handle<Map> old_to_map = Handle<Map>(to->map());
Handle<Map> new_to_map = Map::Copy(old_to_map);
new_to_map->set_prototype(from->map()->prototype());
to->set_map(*new_to_map);
Handle<Object> proto(from->map()->prototype(), isolate());
SetObjectPrototype(to, proto);
}
......
......@@ -1818,8 +1818,15 @@ void Factory::ReinitializeJSReceiver(Handle<JSReceiver> object,
// before object re-initialization is finished and filler object is installed.
DisallowHeapAllocation no_allocation;
// Put in filler if the new object is smaller than the old.
if (size_difference > 0) {
Address address = object->address() + map->instance_size();
heap->CreateFillerObjectAt(address, size_difference);
heap->AdjustLiveBytes(address, -size_difference, Heap::FROM_MUTATOR);
}
// Reset the map for the object.
object->set_map(*map);
object->synchronized_set_map(*map);
Handle<JSObject> jsobj = Handle<JSObject>::cast(object);
// Reinitialize the object from the constructor map.
......@@ -1832,12 +1839,6 @@ void Factory::ReinitializeJSReceiver(Handle<JSReceiver> object,
Handle<Context> context(isolate()->context()->native_context());
InitializeFunction(js_function, shared.ToHandleChecked(), context);
}
// Put in filler if the new object is smaller than the old.
if (size_difference > 0) {
heap->CreateFillerObjectAt(
object->address() + map->instance_size(), size_difference);
}
}
......@@ -1863,7 +1864,7 @@ void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object,
DisallowHeapAllocation no_allocation;
// Reset the map for the object.
object->set_map(constructor->initial_map());
object->synchronized_set_map(*map);
Heap* heap = isolate()->heap();
// Reinitialize the object from the constructor map.
......
......@@ -761,7 +761,7 @@ Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
// the hole value.
Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map()));
ASSERT(new_map->is_dictionary_map());
object->set_map(*new_map);
JSObject::MigrateToMap(object, new_map);
}
Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
Handle<Object> value = isolate->factory()->the_hole_value();
......@@ -2130,8 +2130,6 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
// converted to doubles.
if (!old_map->InstancesNeedRewriting(
*new_map, number_of_fields, inobject, unused)) {
// Writing the new map here does not require synchronization since it does
// not change the actual object size.
object->synchronized_set_map(*new_map);
return;
}
......@@ -2165,9 +2163,7 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
// Set the new property value and do the map transition.
object->set_properties(*new_storage);
// Writing the new map here does not require synchronization since it does
// not change the actual object size.
object->set_map(*new_map);
object->synchronized_set_map(*new_map);
return;
}
Handle<FixedArray> array = isolate->factory()->NewFixedArray(total_size);
......@@ -2239,24 +2235,21 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
ASSERT(instance_size_delta >= 0);
Address address = object->address() + new_instance_size;
// The trimming is performed on a newly allocated object, which is on a
// freshly allocated page or on an already swept page. Hence, the sweeper
// thread can not get confused with the filler creation. No synchronization
// needed.
isolate->heap()->CreateFillerObjectAt(address, instance_size_delta);
Heap* heap = isolate->heap();
// If there are properties in the new backing store, trim it to the correct
// size and install the backing store into the object.
if (external > 0) {
RightTrimFixedArray<Heap::FROM_MUTATOR>(isolate->heap(), *array, inobject);
RightTrimFixedArray<Heap::FROM_MUTATOR>(heap, *array, inobject);
object->set_properties(*array);
}
// The trimming is performed on a newly allocated object, which is on a
// freshly allocated page or on an already swept page. Hence, the sweeper
// thread can not get confused with the filler creation. No synchronization
// needed.
object->set_map(*new_map);
heap->CreateFillerObjectAt(address, instance_size_delta);
heap->AdjustLiveBytes(address, -instance_size_delta, Heap::FROM_MUTATOR);
// We are storing the new map using release store after creating a filler for
// the left-over space to avoid races with the sweeper thread.
object->synchronized_set_map(*new_map);
}
......@@ -4703,7 +4696,7 @@ void JSObject::TransformToFastProperties(Handle<JSObject> object,
ASSERT_LE(unused_property_fields, inobject_props);
// Transform the object.
new_map->set_unused_property_fields(inobject_props);
object->set_map(*new_map);
object->synchronized_set_map(*new_map);
object->set_properties(isolate->heap()->empty_fixed_array());
// Check that it really works.
ASSERT(object->HasFastProperties());
......@@ -4784,7 +4777,7 @@ void JSObject::TransformToFastProperties(Handle<JSObject> object,
new_map->set_unused_property_fields(unused_property_fields);
// Transform the object.
object->set_map(*new_map);
object->synchronized_set_map(*new_map);
object->set_properties(*fields);
ASSERT(object->IsJSObject());
......@@ -6626,7 +6619,7 @@ void JSObject::SetPropertyCallback(Handle<JSObject> object,
if (object->IsGlobalObject()) {
Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map()));
ASSERT(new_map->is_dictionary_map());
object->set_map(*new_map);
JSObject::MigrateToMap(object, new_map);
// When running crankshaft, changing the map is not enough. We
// need to deoptimize all functions that rely on this global
......
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