Commit 2bb56165 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[JSObject] Refactor AddDataElement

This can't fail.

Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I2b8972fe02d3446726ce12f615fd1f92d00632ff
Reviewed-on: https://chromium-review.googlesource.com/1131015Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54351}
parent adbb4d1d
...@@ -231,8 +231,7 @@ bool AddElement(Handle<JSArray> array, int index, ...@@ -231,8 +231,7 @@ bool AddElement(Handle<JSArray> array, int index,
false); false);
JSObject::AddProperty(isolate, element, factory->value_string(), value, NONE); JSObject::AddProperty(isolate, element, factory->value_string(), value, NONE);
RETURN_ON_EXCEPTION_VALUE( JSObject::AddDataElement(array, index, element, NONE);
isolate, JSObject::AddDataElement(array, index, element, NONE), false);
return true; return true;
} }
......
...@@ -1165,8 +1165,7 @@ Handle<JSObject> ConvertToJSObject(Isolate* isolate, ...@@ -1165,8 +1165,7 @@ Handle<JSObject> ConvertToJSObject(Isolate* isolate,
type_profile, position, type_profile, position,
isolate->factory()->NewJSArrayWithElements( isolate->factory()->NewJSArrayWithElements(
ArrayList::Elements(position_specific_types)), ArrayList::Elements(position_specific_types)),
PropertyAttributes::NONE) PropertyAttributes::NONE);
.ToHandleChecked();
} }
} }
return type_profile; return type_profile;
......
...@@ -5300,10 +5300,9 @@ Maybe<bool> Object::AddDataProperty(LookupIterator* it, Handle<Object> value, ...@@ -5300,10 +5300,9 @@ Maybe<bool> Object::AddDataProperty(LookupIterator* it, Handle<Object> value,
} }
Handle<JSObject> receiver_obj = Handle<JSObject>::cast(receiver); Handle<JSObject> receiver_obj = Handle<JSObject>::cast(receiver);
Maybe<bool> result = JSObject::AddDataElement( JSObject::AddDataElement(receiver_obj, it->index(), value, attributes);
receiver_obj, it->index(), value, attributes, should_throw);
JSObject::ValidateElements(*receiver_obj); JSObject::ValidateElements(*receiver_obj);
return result; return Just(true);
} else { } else {
it->UpdateProtector(); it->UpdateProtector();
// Migrate to the most up-to-date map that will be able to store |value| // Migrate to the most up-to-date map that will be able to store |value|
...@@ -15586,23 +15585,10 @@ static bool ShouldConvertToFastElements(JSObject* object, ...@@ -15586,23 +15585,10 @@ static bool ShouldConvertToFastElements(JSObject* object,
return 2 * dictionary_size >= *new_capacity; return 2 * dictionary_size >= *new_capacity;
} }
// static // static
MaybeHandle<Object> JSObject::AddDataElement(Handle<JSObject> object, void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
uint32_t index,
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes) { PropertyAttributes attributes) {
MAYBE_RETURN_NULL(
AddDataElement(object, index, value, attributes, kThrowOnError));
return value;
}
// static
Maybe<bool> JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
Handle<Object> value,
PropertyAttributes attributes,
ShouldThrow should_throw) {
DCHECK(object->map()->is_extensible()); DCHECK(object->map()->is_extensible());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
...@@ -15652,8 +15638,6 @@ Maybe<bool> JSObject::AddDataElement(Handle<JSObject> object, uint32_t index, ...@@ -15652,8 +15638,6 @@ Maybe<bool> JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
isolate->factory()->NewNumberFromUint(index + 1); isolate->factory()->NewNumberFromUint(index + 1);
JSArray::cast(*object)->set_length(*new_length); JSArray::cast(*object)->set_length(*new_length);
} }
return Just(true);
} }
......
...@@ -2207,11 +2207,8 @@ class JSObject: public JSReceiver { ...@@ -2207,11 +2207,8 @@ class JSObject: public JSReceiver {
Handle<Name> name, Handle<Object> value, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes); PropertyAttributes attributes);
V8_WARN_UNUSED_RESULT static Maybe<bool> AddDataElement( static void AddDataElement(Handle<JSObject> receiver, uint32_t index,
Handle<JSObject> receiver, uint32_t index, Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes, ShouldThrow should_throw);
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> AddDataElement(
Handle<JSObject> receiver, uint32_t index, Handle<Object> value,
PropertyAttributes attributes); PropertyAttributes attributes);
// Extend the receiver with a single fast property appeared first in the // Extend the receiver with a single fast property appeared first in the
......
...@@ -1385,7 +1385,7 @@ namespace { ...@@ -1385,7 +1385,7 @@ namespace {
void AddElement(Handle<JSObject> object, uint32_t index, Handle<Object> value, void AddElement(Handle<JSObject> object, uint32_t index, Handle<Object> value,
PropertyAttributes attributes = NONE) { PropertyAttributes attributes = NONE) {
JSObject::AddDataElement(object, index, value, attributes).ToHandleChecked(); JSObject::AddDataElement(object, index, value, attributes);
} }
} // namespace } // namespace
......
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