Skip to content

Truly independent web browser

LibJS: Don't return the element Object::indexed_take_first() removes

Shannon Booth3a945bb2789f
diff --git a/Libraries/LibJS/Runtime/IndexedProperties.h b/Libraries/LibJS/Runtime/IndexedProperties.h
deleted file mode 100644
index 51f7afd17d7..00000000000
--- a/Libraries/LibJS/Runtime/IndexedProperties.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, Matthew Olsson <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/HashMap.h>
-#include <AK/Optional.h>
-#include <AK/kmalloc.h>
-#include <LibJS/Export.h>
-#include <LibJS/Runtime/PropertyAttributes.h>
-#include <LibJS/Runtime/Shape.h>
-#include <LibJS/Runtime/Value.h>
-
-namespace JS {
-
-// An element of an object's indexed storage, as Object::indexed_take_first() returns it.
-struct ValueAndAttributes {
- Value value;
- PropertyAttributes attributes { default_attributes };
-
- Optional<u32> property_offset {};
-
- void visit_edges(Cell::Visitor& visitor)
- {
- visitor.visit(value);
- }
-};
-
-}
diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp
index d7138127035..746aa253b8e 100644
--- a/Libraries/LibJS/Runtime/Object.cpp
+++ b/Libraries/LibJS/Runtime/Object.cpp
@@ -392,9 +392,9 @@ void Object::indexed_append(Value value, PropertyAttributes attributes)
js_array_indexed_append(object_to_abi(*this), value_to_abi(value));
}
-ValueAndAttributes Object::indexed_take_first()
+void Object::indexed_take_first()
{
- return ValueAndAttributes { .value = value_from_abi(js_array_indexed_take_first(object_to_abi(*this))) };
+ js_array_indexed_take_first(object_to_abi(*this));
}
void Object::convert_to_prototype_if_needed()
diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h
index 6b1575b0b6c..f955c35456a 100644
--- a/Libraries/LibJS/Runtime/Object.h
+++ b/Libraries/LibJS/Runtime/Object.h
@@ -19,8 +19,8 @@
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/EngineCell.h>
#include <LibJS/Runtime/Completion.h>
-#include <LibJS/Runtime/IndexedProperties.h>
#include <LibJS/Runtime/PrimitiveString.h>
+#include <LibJS/Runtime/PropertyAttributes.h>
#include <LibJS/Runtime/PropertyDescriptor.h>
#include <LibJS/Runtime/PropertyKey.h>
#include <LibJS/Runtime/Shape.h>
@@ -176,8 +176,8 @@ public:
u32 indexed_array_like_size() const;
// The runtime appends elements with the default attributes, the only ones LibJS's users append with.
void indexed_append(Value value, PropertyAttributes attributes = default_attributes);
- // The element taken has the default attributes, whatever the ones it was stored with.
- ValueAndAttributes indexed_take_first();
+ // Removes the first element, which must exist, and shifts the others down.
+ void indexed_take_first();
Shape& shape() { return *engine_field<Shape*>(JS_LAYOUT_OBJECT_SHAPE_OFFSET); }
Shape const& shape() const { return *engine_field<Shape*>(JS_LAYOUT_OBJECT_SHAPE_OFFSET); }
diff --git a/Libraries/LibJS/Rust/src/embedding/array.rs b/Libraries/LibJS/Rust/src/embedding/array.rs
index 15be8073704..65e26b6d8dc 100644
--- a/Libraries/LibJS/Rust/src/embedding/array.rs
+++ b/Libraries/LibJS/Rust/src/embedding/array.rs
@@ -98,13 +98,10 @@ pub unsafe extern "C" fn js_array_indexed_append(object: *mut JSObject, value: J
unsafe { cell_from_abi::<JSObject>(object) }.indexed_append(Value::from_bits(value), DEFAULT_ATTRIBUTES);
}
-/// Removes the first element of the object's indexed storage, which must not be empty, shifting the others down, and
-/// returns its value, which is empty for a hole. Main thread only.
+/// Removes the first element of the object's indexed storage, which must not be empty, shifting the others down. Main
+/// thread only.
#[unsafe(no_mangle)]
-pub unsafe extern "C" fn js_array_indexed_take_first(object: *mut JSObject) -> JSValue {
+pub unsafe extern "C" fn js_array_indexed_take_first(object: *mut JSObject) {
// SAFETY: See the module documentation.
- unsafe { cell_from_abi::<JSObject>(object) }
- .indexed_take_first()
- .value
- .0
+ unsafe { cell_from_abi::<JSObject>(object) }.indexed_take_first();
}
diff --git a/Meta/Linters/check_libjs_includes.py b/Meta/Linters/check_libjs_includes.py
index 63201a61c9d..d75758be619 100755
--- a/Meta/Linters/check_libjs_includes.py
+++ b/Meta/Linters/check_libjs_includes.py
@@ -105,7 +105,6 @@ ENGINE_INTERNAL_HEADERS = {
"LibJS/Lexer.h",
"LibJS/Parser.h",
"LibJS/Runtime/EnvironmentShape.h",
- "LibJS/Runtime/IndexedProperties.h",
"LibJS/Runtime/InterpreterStack.h",
"LibJS/Runtime/Shape.h",
"LibJS/RustIntegration.h",