Commit 02265704 authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[rab/gsab] Clean up the remaining uses of HasTypedArrayElements

Bug: v8:11111
Change-Id: I94f992f78a12a86c89924261bd64c73f935051b5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3576118Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79869}
parent e921842f
......@@ -369,7 +369,7 @@ void VerifyJSObjectElements(Isolate* isolate, JSObject object) {
if (object.IsJSTypedArray()) {
// TODO(bmeurer,v8:4153): Fix CreateTypedArray to either not instantiate
// the object or propertly initialize it on errors during construction.
/* CHECK(object->HasTypedArrayElements()); */
/* CHECK(object->HasTypedArrayOrRabGsabTypedArrayElements()); */
return;
}
CHECK(!object.elements().IsByteArray());
......
......@@ -2559,7 +2559,8 @@ Handle<JSObject> Factory::NewJSObjectFromMap(
InitializeJSObjectFromMap(js_obj, *empty_fixed_array(), *map);
DCHECK(js_obj.HasFastElements() || js_obj.HasTypedArrayElements() ||
DCHECK(js_obj.HasFastElements() ||
js_obj.HasTypedArrayOrRabGsabTypedArrayElements() ||
js_obj.HasFastStringWrapperElements() ||
js_obj.HasFastArgumentsElements() || js_obj.HasDictionaryElements());
return handle(js_obj, isolate());
......
......@@ -725,11 +725,6 @@ DEF_GETTER(JSObject, HasSlowStringWrapperElements, bool) {
return GetElementsKind(cage_base) == SLOW_STRING_WRAPPER_ELEMENTS;
}
DEF_GETTER(JSObject, HasTypedArrayElements, bool) {
DCHECK(!elements(cage_base).is_null());
return map(cage_base).has_typed_array_elements();
}
DEF_GETTER(JSObject, HasTypedArrayOrRabGsabTypedArrayElements, bool) {
DCHECK(!elements(cage_base).is_null());
return map(cage_base).has_typed_array_or_rab_gsab_typed_array_elements();
......
......@@ -3461,7 +3461,6 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes(
Maybe<ShouldThrow> should_throw, AccessorInfoHandling handling,
EnforceDefineSemantics semantics, StoreOrigin store_origin) {
it->UpdateProtector();
Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
for (; it->IsFound(); it->Next()) {
switch (it->state()) {
......@@ -3559,13 +3558,11 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes(
return Object::SetDataProperty(it, value);
}
// Special case: properties of typed arrays cannot be reconfigured to
// non-writable nor to non-enumerable.
if (it->IsElement() && object->HasTypedArrayElements()) {
return Object::RedefineIncompatibleProperty(
it->isolate(), it->GetName(), value, should_throw);
}
// The non-matching attribute case for JSTypedArrays has already been
// handled by JSTypedArray::DefineOwnProperty.
DCHECK(!it->IsElement() ||
!Handle<JSObject>::cast(it->GetReceiver())
->HasTypedArrayOrRabGsabTypedArrayElements());
// Reconfigure the data property if the attributes mismatch.
it->ReconfigureDataProperty(value, attributes);
......@@ -3842,7 +3839,7 @@ void JSObject::RequireSlowElements(NumberDictionary dictionary) {
}
Handle<NumberDictionary> JSObject::NormalizeElements(Handle<JSObject> object) {
DCHECK(!object->HasTypedArrayElements());
DCHECK(!object->HasTypedArrayOrRabGsabTypedArrayElements());
Isolate* isolate = object->GetIsolate();
bool is_sloppy_arguments = object->HasSloppyArgumentsElements();
{
......@@ -4089,16 +4086,15 @@ Maybe<bool> JSObject::PreventExtensions(Handle<JSObject> object,
NewTypeError(MessageTemplate::kCannotPreventExt));
}
if (!object->HasTypedArrayElements()) {
// If there are fast elements we normalize.
Handle<NumberDictionary> dictionary = NormalizeElements(object);
DCHECK(object->HasDictionaryElements() ||
object->HasSlowArgumentsElements());
DCHECK(!object->HasTypedArrayOrRabGsabTypedArrayElements());
// Make sure that we never go back to fast case.
if (*dictionary != ReadOnlyRoots(isolate).empty_slow_element_dictionary()) {
object->RequireSlowElements(*dictionary);
}
// Normalize fast elements.
Handle<NumberDictionary> dictionary = NormalizeElements(object);
DCHECK(object->HasDictionaryElements() || object->HasSlowArgumentsElements());
// Make sure that we never go back to fast case.
if (*dictionary != ReadOnlyRoots(isolate).empty_slow_element_dictionary()) {
object->RequireSlowElements(*dictionary);
}
// Do a map transition, other objects with this map may still
......@@ -4167,7 +4163,8 @@ template void JSObject::ApplyAttributesToDictionary(
Handle<NumberDictionary> CreateElementDictionary(Isolate* isolate,
Handle<JSObject> object) {
Handle<NumberDictionary> new_element_dictionary;
if (!object->HasTypedArrayElements() && !object->HasDictionaryElements() &&
if (!object->HasTypedArrayOrRabGsabTypedArrayElements() &&
!object->HasDictionaryElements() &&
!object->HasSlowStringWrapperElements()) {
int length = object->IsJSArray()
? Smi::ToInt(Handle<JSArray>::cast(object)->length())
......@@ -4345,6 +4342,7 @@ Maybe<bool> JSObject::PreventExtensionsWithTransition(
// Both seal and preventExtensions always go through without modifications to
// typed array elements. Freeze works only if there are no actual elements.
if (object->HasTypedArrayOrRabGsabTypedArrayElements()) {
DCHECK(new_element_dictionary.is_null());
if (attrs == FROZEN && JSTypedArray::cast(*object).GetLength() > 0) {
isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kCannotFreezeArrayBufferView));
......@@ -4535,7 +4533,7 @@ MaybeHandle<Object> JSObject::DefineAccessor(LookupIterator* it,
Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
// Ignore accessors on typed arrays.
if (it->IsElement() && object->HasTypedArrayElements()) {
if (it->IsElement() && object->HasTypedArrayOrRabGsabTypedArrayElements()) {
return it->factory()->undefined_value();
}
......@@ -4572,7 +4570,7 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
}
// Ignore accessors on typed arrays.
if (it.IsElement() && object->HasTypedArrayElements()) {
if (it.IsElement() && object->HasTypedArrayOrRabGsabTypedArrayElements()) {
return it.factory()->undefined_value();
}
......
......@@ -379,7 +379,6 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
DECL_GETTER(HasSealedElements, bool)
DECL_GETTER(HasNonextensibleElements, bool)
DECL_GETTER(HasTypedArrayElements, bool)
DECL_GETTER(HasTypedArrayOrRabGsabTypedArrayElements, bool)
DECL_GETTER(HasFixedUint8ClampedElements, bool)
......
......@@ -475,7 +475,7 @@ void LookupIterator::ReconfigureDataProperty(Handle<Object> value,
Handle<JSObject> holder_obj = Handle<JSObject>::cast(holder);
if (IsElement(*holder)) {
DCHECK(!holder_obj->HasTypedArrayElements(isolate_));
DCHECK(!holder_obj->HasTypedArrayOrRabGsabTypedArrayElements(isolate_));
DCHECK(attributes != NONE || !holder_obj->HasFastElements(isolate_));
Handle<FixedArrayBase> elements(holder_obj->elements(isolate_), isolate());
holder_obj->GetElementsAccessor(isolate_)->Reconfigure(
......@@ -1238,7 +1238,7 @@ bool HasInterceptor(Map map, size_t index) {
if (index > JSObject::kMaxElementIndex) {
// There is currently no way to install interceptors on an object with
// typed array elements.
DCHECK(!map.has_typed_array_elements());
DCHECK(!map.has_typed_array_or_rab_gsab_typed_array_elements());
return map.has_named_interceptor();
}
return map.has_indexed_interceptor();
......@@ -1388,7 +1388,7 @@ Handle<InterceptorInfo> LookupIterator::GetInterceptorForFailedAccessCheck()
if (!access_check_info.is_null()) {
// There is currently no way to create objects with typed array elements
// and access checks.
DCHECK(!holder_->map().has_typed_array_elements());
DCHECK(!holder_->map().has_typed_array_or_rab_gsab_typed_array_elements());
Object interceptor = is_js_array_element(IsElement())
? access_check_info.indexed_interceptor()
: access_check_info.named_interceptor();
......
......@@ -590,14 +590,6 @@ bool Map::has_fast_string_wrapper_elements() const {
return elements_kind() == FAST_STRING_WRAPPER_ELEMENTS;
}
bool Map::has_typed_array_elements() const {
return IsTypedArrayElementsKind(elements_kind());
}
bool Map::has_rab_gsab_typed_array_elements() const {
return IsRabGsabTypedArrayElementsKind(elements_kind());
}
bool Map::has_typed_array_or_rab_gsab_typed_array_elements() const {
return IsTypedArrayOrRabGsabTypedArrayElementsKind(elements_kind());
}
......
......@@ -419,8 +419,6 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
inline bool has_sloppy_arguments_elements() const;
inline bool has_fast_sloppy_arguments_elements() const;
inline bool has_fast_string_wrapper_elements() const;
inline bool has_typed_array_elements() const;
inline bool has_rab_gsab_typed_array_elements() const;
inline bool has_typed_array_or_rab_gsab_typed_array_elements() const;
inline bool has_any_typed_array_or_wasm_array_elements() const;
inline bool has_dictionary_elements() const;
......
......@@ -157,7 +157,7 @@ RUNTIME_FUNCTION(Runtime_NormalizeElements) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
Handle<JSObject> array = args.at<JSObject>(0);
CHECK(!array->HasTypedArrayElements());
CHECK(!array->HasTypedArrayOrRabGsabTypedArrayElements());
CHECK(!array->IsJSGlobalProxy());
JSObject::NormalizeElements(array);
return *array;
......
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