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