Commit 6aaa49fb authored by verwaest's avatar verwaest Committed by Commit bot

[LookupIterator] Optimize the path that writes to fields.

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

Cr-Commit-Position: refs/heads/master@{#34149}
parent d6ba5200
......@@ -517,18 +517,21 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
Handle<JSObject> object = Handle<JSObject>::cast(holder);
ElementsAccessor* accessor = object->GetElementsAccessor();
accessor->Set(object, number_, *value);
} else if (holder->HasFastProperties()) {
if (property_details_.type() == v8::internal::DATA) {
JSObject::cast(*holder)->WriteToField(descriptor_number(),
property_details_, *value);
} else {
DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type());
}
} else if (holder->IsJSGlobalObject()) {
Handle<GlobalDictionary> property_dictionary =
handle(JSObject::cast(*holder)->global_dictionary());
PropertyCell::UpdateCell(property_dictionary, dictionary_entry(), value,
property_details_);
} else if (!holder->HasFastProperties()) {
} else {
NameDictionary* property_dictionary = holder->property_dictionary();
property_dictionary->ValueAtPut(dictionary_entry(), *value);
} else if (property_details_.type() == v8::internal::DATA) {
JSObject::cast(*holder)->WriteToField(descriptor_number(), *value);
} else {
DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type());
}
}
......
......@@ -991,14 +991,14 @@ ElementsKind Object::OptimalElementsKind() {
bool Object::FitsRepresentation(Representation representation) {
if (FLAG_track_fields && representation.IsNone()) {
return false;
} else if (FLAG_track_fields && representation.IsSmi()) {
if (FLAG_track_fields && representation.IsSmi()) {
return IsSmi();
} else if (FLAG_track_double_fields && representation.IsDouble()) {
return IsMutableHeapNumber() || IsNumber();
} else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) {
return IsHeapObject();
} else if (FLAG_track_fields && representation.IsNone()) {
return false;
}
return true;
}
......@@ -2088,15 +2088,10 @@ void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) {
}
}
void JSObject::WriteToField(int descriptor, Object* value) {
DisallowHeapAllocation no_gc;
DescriptorArray* desc = map()->instance_descriptors();
PropertyDetails details = desc->GetDetails(descriptor);
void JSObject::WriteToField(int descriptor, PropertyDetails details,
Object* value) {
DCHECK(details.type() == DATA);
DisallowHeapAllocation no_gc;
FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor);
if (details.representation().IsDouble()) {
// Nothing more to be done.
......@@ -2113,6 +2108,11 @@ void JSObject::WriteToField(int descriptor, Object* value) {
}
}
void JSObject::WriteToField(int descriptor, Object* value) {
DescriptorArray* desc = map()->instance_descriptors();
PropertyDetails details = desc->GetDetails(descriptor);
WriteToField(descriptor, details, value);
}
int JSObject::GetInObjectPropertyOffset(int index) {
return map()->GetInObjectPropertyOffset(index);
......
......@@ -2335,6 +2335,8 @@ class JSObject: public JSReceiver {
inline void FastPropertyAtPut(FieldIndex index, Object* value);
inline void RawFastPropertyAtPut(FieldIndex index, Object* value);
inline void RawFastDoublePropertyAtPut(FieldIndex index, double value);
inline void WriteToField(int descriptor, PropertyDetails details,
Object* value);
inline void WriteToField(int descriptor, Object* value);
// Access to in object properties.
......
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