Commit dba715ec authored by verwaest's avatar verwaest Committed by Commit bot

Cleanup Delete backend implementation.

BUG=v8:4137
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#29477}
parent b0a852e8
This diff is collapsed.
...@@ -62,8 +62,7 @@ class ElementsAccessor { ...@@ -62,8 +62,7 @@ class ElementsAccessor {
virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0; virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0;
// Deletes an element in an object. // Deletes an element in an object.
virtual void Delete(Handle<JSObject> holder, uint32_t key, virtual void Delete(Handle<JSObject> holder, uint32_t index) = 0;
LanguageMode language_mode) = 0;
// If kCopyToEnd is specified as the copy_size to CopyElements, it copies all // If kCopyToEnd is specified as the copy_size to CopyElements, it copies all
// of elements from source after source_start to the destination array. // of elements from source after source_start to the destination array.
......
...@@ -223,6 +223,28 @@ void LookupIterator::ApplyTransitionToDataProperty() { ...@@ -223,6 +223,28 @@ void LookupIterator::ApplyTransitionToDataProperty() {
} }
void LookupIterator::Delete() {
Handle<JSObject> holder = Handle<JSObject>::cast(holder_);
if (IsElement()) {
ElementsAccessor* accessor = holder->GetElementsAccessor();
accessor->Delete(holder, number_);
} else {
PropertyNormalizationMode mode = holder->map()->is_prototype_map()
? KEEP_INOBJECT_PROPERTIES
: CLEAR_INOBJECT_PROPERTIES;
if (holder->HasFastProperties()) {
JSObject::NormalizeProperties(holder, mode, 0, "DeletingProperty");
holder_map_ = handle(holder->map(), isolate_);
ReloadPropertyInformation();
}
// TODO(verwaest): Get rid of the name_ argument.
JSObject::DeleteNormalizedProperty(holder, name_, number_);
JSObject::ReoptimizeIfPrototype(holder);
}
}
void LookupIterator::TransitionToAccessorProperty( void LookupIterator::TransitionToAccessorProperty(
AccessorComponent component, Handle<Object> accessor, AccessorComponent component, Handle<Object> accessor,
PropertyAttributes attributes) { PropertyAttributes attributes) {
......
...@@ -216,6 +216,7 @@ class LookupIterator final BASE_EMBEDDED { ...@@ -216,6 +216,7 @@ class LookupIterator final BASE_EMBEDDED {
void ApplyTransitionToDataProperty(); void ApplyTransitionToDataProperty();
void ReconfigureDataProperty(Handle<Object> value, void ReconfigureDataProperty(Handle<Object> value,
PropertyAttributes attributes); PropertyAttributes attributes);
void Delete();
void TransitionToAccessorProperty(AccessorComponent component, void TransitionToAccessorProperty(AccessorComponent component,
Handle<Object> accessor, Handle<Object> accessor,
PropertyAttributes attributes); PropertyAttributes attributes);
......
...@@ -229,7 +229,7 @@ class CallSite { ...@@ -229,7 +229,7 @@ class CallSite {
T(StrongArity, \ T(StrongArity, \
"In strong mode, calling a function with too few arguments is deprecated") \ "In strong mode, calling a function with too few arguments is deprecated") \
T(StrongDeleteProperty, \ T(StrongDeleteProperty, \
"On strong object %, deletion of property % is deprecated") \ "Deleting property '%' of strong object '%' is deprecated") \
T(StrongImplicitConversion, \ T(StrongImplicitConversion, \
"In strong mode, implicit conversions are deprecated") \ "In strong mode, implicit conversions are deprecated") \
T(StrongRedefineDisallowed, \ T(StrongRedefineDisallowed, \
......
...@@ -5145,14 +5145,13 @@ MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor( ...@@ -5145,14 +5145,13 @@ MaybeHandle<Object> JSObject::DeletePropertyWithInterceptor(
void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, void JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
Handle<Name> name) { Handle<Name> name, int entry) {
DCHECK(!object->HasFastProperties()); DCHECK(!object->HasFastProperties());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
if (object->IsGlobalObject()) { if (object->IsGlobalObject()) {
// If we have a global object, invalidate the cell and swap in a new one. // If we have a global object, invalidate the cell and swap in a new one.
Handle<GlobalDictionary> dictionary(object->global_dictionary()); Handle<GlobalDictionary> dictionary(object->global_dictionary());
int entry = dictionary->FindEntry(name);
DCHECK_NE(GlobalDictionary::kNotFound, entry); DCHECK_NE(GlobalDictionary::kNotFound, entry);
auto cell = PropertyCell::InvalidateEntry(dictionary, entry); auto cell = PropertyCell::InvalidateEntry(dictionary, entry);
...@@ -5162,7 +5161,6 @@ void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, ...@@ -5162,7 +5161,6 @@ void JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
cell->property_details().set_cell_type(PropertyCellType::kInvalidated)); cell->property_details().set_cell_type(PropertyCellType::kInvalidated));
} else { } else {
Handle<NameDictionary> dictionary(object->property_dictionary()); Handle<NameDictionary> dictionary(object->property_dictionary());
int entry = dictionary->FindEntry(name);
DCHECK_NE(NameDictionary::kNotFound, entry); DCHECK_NE(NameDictionary::kNotFound, entry);
NameDictionary::DeleteProperty(dictionary, entry); NameDictionary::DeleteProperty(dictionary, entry);
...@@ -5221,16 +5219,12 @@ MaybeHandle<Object> JSReceiver::DeleteProperty(LookupIterator* it, ...@@ -5221,16 +5219,12 @@ MaybeHandle<Object> JSReceiver::DeleteProperty(LookupIterator* it,
if (!it->IsConfigurable() || receiver->map()->is_strong()) { if (!it->IsConfigurable() || receiver->map()->is_strong()) {
// Fail if the property is not configurable, or on a strong object. // Fail if the property is not configurable, or on a strong object.
if (is_strict(language_mode)) { if (is_strict(language_mode)) {
if (receiver->map()->is_strong()) { MessageTemplate::Template templ =
THROW_NEW_ERROR( receiver->map()->is_strong()
isolate, NewTypeError(MessageTemplate::kStrongDeleteProperty, ? MessageTemplate::kStrongDeleteProperty
receiver, it->GetName()), : MessageTemplate::kStrictDeleteProperty;
Object); THROW_NEW_ERROR(
} isolate, NewTypeError(templ, it->GetName(), receiver), Object);
THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kStrictDeleteProperty,
it->GetName(), receiver),
Object);
} }
return it->factory()->false_value(); return it->factory()->false_value();
} }
...@@ -5243,18 +5237,7 @@ MaybeHandle<Object> JSReceiver::DeleteProperty(LookupIterator* it, ...@@ -5243,18 +5237,7 @@ MaybeHandle<Object> JSReceiver::DeleteProperty(LookupIterator* it,
return it->factory()->true_value(); return it->factory()->true_value();
} }
if (it->IsElement()) { it->Delete();
ElementsAccessor* accessor = holder->GetElementsAccessor();
accessor->Delete(holder, it->index(), language_mode);
} else {
PropertyNormalizationMode mode = holder->map()->is_prototype_map()
? KEEP_INOBJECT_PROPERTIES
: CLEAR_INOBJECT_PROPERTIES;
JSObject::NormalizeProperties(holder, mode, 0, "DeletingProperty");
JSObject::DeleteNormalizedProperty(holder, it->name());
JSObject::ReoptimizeIfPrototype(holder);
}
if (is_observed) { if (is_observed) {
RETURN_ON_EXCEPTION(isolate, RETURN_ON_EXCEPTION(isolate,
......
...@@ -2292,6 +2292,10 @@ class JSObject: public JSReceiver { ...@@ -2292,6 +2292,10 @@ class JSObject: public JSReceiver {
// Gets the current elements capacity and the number of used elements. // Gets the current elements capacity and the number of used elements.
void GetElementsCapacityAndUsage(int* capacity, int* used); void GetElementsCapacityAndUsage(int* capacity, int* used);
// Deletes an existing named property in a normalized object.
static void DeleteNormalizedProperty(Handle<JSObject> object,
Handle<Name> name, int entry);
private: private:
friend class DictionaryElementsAccessor; friend class DictionaryElementsAccessor;
friend class JSReceiver; friend class JSReceiver;
...@@ -2318,10 +2322,6 @@ class JSObject: public JSReceiver { ...@@ -2318,10 +2322,6 @@ class JSObject: public JSReceiver {
MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor( MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor(
LookupIterator* it); LookupIterator* it);
// Deletes an existing named property in a normalized object.
static void DeleteNormalizedProperty(Handle<JSObject> object,
Handle<Name> name);
bool ReferencesObjectFromElements(FixedArray* elements, bool ReferencesObjectFromElements(FixedArray* elements,
ElementsKind kind, ElementsKind kind,
Object* object); Object* object);
......
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