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,
false);
JSObject::AddProperty(isolate, element, factory->value_string(), value, NONE);
RETURN_ON_EXCEPTION_VALUE(
isolate, JSObject::AddDataElement(array, index, element, NONE), false);
JSObject::AddDataElement(array, index, element, NONE);
return true;
}
......
......@@ -1165,8 +1165,7 @@ Handle<JSObject> ConvertToJSObject(Isolate* isolate,
type_profile, position,
isolate->factory()->NewJSArrayWithElements(
ArrayList::Elements(position_specific_types)),
PropertyAttributes::NONE)
.ToHandleChecked();
PropertyAttributes::NONE);
}
}
return type_profile;
......
......@@ -5300,10 +5300,9 @@ Maybe<bool> Object::AddDataProperty(LookupIterator* it, Handle<Object> value,
}
Handle<JSObject> receiver_obj = Handle<JSObject>::cast(receiver);
Maybe<bool> result = JSObject::AddDataElement(
receiver_obj, it->index(), value, attributes, should_throw);
JSObject::AddDataElement(receiver_obj, it->index(), value, attributes);
JSObject::ValidateElements(*receiver_obj);
return result;
return Just(true);
} else {
it->UpdateProtector();
// Migrate to the most up-to-date map that will be able to store |value|
......@@ -15586,23 +15585,10 @@ static bool ShouldConvertToFastElements(JSObject* object,
return 2 * dictionary_size >= *new_capacity;
}
// static
MaybeHandle<Object> JSObject::AddDataElement(Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
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) {
void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
Handle<Object> value,
PropertyAttributes attributes) {
DCHECK(object->map()->is_extensible());
Isolate* isolate = object->GetIsolate();
......@@ -15652,8 +15638,6 @@ Maybe<bool> JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
isolate->factory()->NewNumberFromUint(index + 1);
JSArray::cast(*object)->set_length(*new_length);
}
return Just(true);
}
......
......@@ -2207,12 +2207,9 @@ class JSObject: public JSReceiver {
Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes);
V8_WARN_UNUSED_RESULT static Maybe<bool> AddDataElement(
Handle<JSObject> receiver, uint32_t index, 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);
static void AddDataElement(Handle<JSObject> receiver, uint32_t index,
Handle<Object> value,
PropertyAttributes attributes);
// Extend the receiver with a single fast property appeared first in the
// passed map. This also extends the property backing store if necessary.
......
......@@ -1385,7 +1385,7 @@ namespace {
void AddElement(Handle<JSObject> object, uint32_t index, Handle<Object> value,
PropertyAttributes attributes = NONE) {
JSObject::AddDataElement(object, index, value, attributes).ToHandleChecked();
JSObject::AddDataElement(object, index, value, attributes);
}
} // 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