Skip to content

Commit 137e840

Browse files
committed
Add SparseElement indexed storage variant
Introduce a new `SparseElement` variant to `IndexedProperties` that stores simple values (data descriptors with all flags true) in a hash map without full property descriptors. This optimizes memory usage for sparse arrays.
1 parent 5cbbb72 commit 137e840

File tree

4 files changed

+210
-117
lines changed

4 files changed

+210
-117
lines changed

cli/src/debug/object.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn id(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult<JsValue> {
2222
}
2323

2424
/// Returns objects pointer in memory.
25-
fn indexed_elements_type(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult<JsValue> {
25+
fn indexed_storage_type(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult<JsValue> {
2626
let Some(value) = args.first() else {
2727
return Err(JsNativeError::typ()
2828
.with_message("expected object argument")
@@ -39,7 +39,8 @@ fn indexed_elements_type(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsRe
3939
IndexProperties::DenseI32(_) => "DenseI32",
4040
IndexProperties::DenseF64(_) => "DenseF64",
4141
IndexProperties::DenseElement(_) => "DenseElement",
42-
IndexProperties::Sparse(_) => "SparseElement",
42+
IndexProperties::SparseElement(_) => "SparseElement",
43+
IndexProperties::SparseProperty(_) => "SparseProperty",
4344
};
4445
Ok(js_string!(typ).into())
4546
}
@@ -48,8 +49,8 @@ pub(super) fn create_object(context: &mut Context) -> JsObject {
4849
ObjectInitializer::new(context)
4950
.function(NativeFunction::from_fn_ptr(id), js_string!("id"), 1)
5051
.function(
51-
NativeFunction::from_fn_ptr(indexed_elements_type),
52-
js_string!("indexedElementsType"),
52+
NativeFunction::from_fn_ptr(indexed_storage_type),
53+
js_string!("indexedStorageType"),
5354
1,
5455
)
5556
.build()

0 commit comments

Comments
 (0)