Skip to content

Truly independent web browser

LibJS: Keep state the collector never reads out of GcRefCell

Shannon Booth805ca89d3ad2
diff --git a/Libraries/LibJS/Rust/src/console.rs b/Libraries/LibJS/Rust/src/console.rs
index 00197eb3435..c1b829a443f 100644
--- a/Libraries/LibJS/Rust/src/console.rs
+++ b/Libraries/LibJS/Rust/src/console.rs
@@ -6,7 +6,7 @@
//! The console namespace of https://console.spec.whatwg.org, and the client a host gives it to print with.
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::time::{Duration, Instant};
@@ -15,7 +15,6 @@ use libjs_runtime_macros::Trace;
use crate::console_log_level::ConsoleLogLevel;
use crate::gc::class::{GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::gc::root::MarkedVec;
use crate::interpreter::vm::Vm;
use crate::layout::cell::{CellHeader, Gc};
@@ -68,11 +67,11 @@ pub struct Console {
client: Cell<Option<Gc<ConsoleClient>>>,
#[gc(untraced)]
- counters: GcRefCell<HashMap<Utf16FlyString, u32>>,
+ counters: RefCell<HashMap<Utf16FlyString, u32>>,
#[gc(untraced)]
- timer_table: GcRefCell<HashMap<Utf16FlyString, Instant>>,
+ timer_table: RefCell<HashMap<Utf16FlyString, Instant>>,
#[gc(untraced)]
- group_stack: GcRefCell<Vec<Group>>,
+ group_stack: RefCell<Vec<Group>>,
}
define_cell!(Console, Other);
@@ -99,9 +98,9 @@ impl Console {
header: CellHeader::for_class(Self::CLASS),
realm,
client: Cell::new(None),
- counters: GcRefCell::default(),
- timer_table: GcRefCell::default(),
- group_stack: GcRefCell::default(),
+ counters: RefCell::default(),
+ timer_table: RefCell::default(),
+ group_stack: RefCell::default(),
})
}
@@ -113,7 +112,7 @@ impl Console {
self.realm
}
- pub fn counters(&self) -> &GcRefCell<HashMap<Utf16FlyString, u32>> {
+ pub fn counters(&self) -> &RefCell<HashMap<Utf16FlyString, u32>> {
&self.counters
}
diff --git a/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs b/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs
index 86ac2661071..060d572d01d 100644
--- a/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/declarative_environment.rs
@@ -9,7 +9,7 @@
//! shared by every environment that one piece of code creates, or in the rare data for bindings the shape does not
//! cover.
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use std::collections::HashMap;
@@ -127,11 +127,12 @@ impl Bitmap {
/// The part of DeclarativeEnvironment::RareData that the interpreter does not read.
#[derive(Default, Trace)]
pub struct DeclarativeEnvironmentRareDataStorage {
- binding_names: GcRefCell<Vec<Utf16FlyString>>,
#[gc(untraced)]
- deleted_bindings: GcRefCell<Bitmap>,
+ binding_names: RefCell<Vec<Utf16FlyString>>,
#[gc(untraced)]
- bindings_assoc: GcRefCell<HashMap<Utf16FlyString, usize, foldhash::fast::RandomState>>,
+ deleted_bindings: RefCell<Bitmap>,
+ #[gc(untraced)]
+ bindings_assoc: RefCell<HashMap<Utf16FlyString, usize, foldhash::fast::RandomState>>,
dispose_capability: GcRefCell<DisposeCapability>,
environment_shape_cache: Cell<Option<EnvironmentShapeCache>>,
expected_binding_count: Cell<usize>,
@@ -140,7 +141,7 @@ pub struct DeclarativeEnvironmentRareDataStorage {
tracks_assignments: Cell<bool>,
/// The bindings that were assigned since their initialization, if the environment tracks assignments.
#[gc(untraced)]
- assigned_bindings: GcRefCell<Bitmap>,
+ assigned_bindings: RefCell<Bitmap>,
/// Whether JIT code depends on the environment getting no bindings and on its bindings staying unassigned.
has_dependent_code: Cell<bool>,
}
diff --git a/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs b/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs
index d8095d9774f..68a4153ab95 100644
--- a/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs
+++ b/Libraries/LibJS/Rust/src/runtime/descriptor_array.rs
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+use core::cell::RefCell;
use core::hash::BuildHasher;
use core::ops::ControlFlow;
@@ -45,7 +46,7 @@ impl Entry {
pub struct DescriptorArray {
header: CellHeader,
entries: GcRefCell<Vec<Entry>>,
- entry_indices_by_enum_index: GcRefCell<Vec<u32>>,
+ entry_indices_by_enum_index: RefCell<Vec<u32>>,
}
define_cell!(DescriptorArray, Other);
@@ -127,7 +128,7 @@ impl DescriptorArray {
Self {
header: CellHeader::for_class(Self::CLASS),
entries: GcRefCell::new(entries),
- entry_indices_by_enum_index: GcRefCell::new(entry_indices_by_enum_index),
+ entry_indices_by_enum_index: RefCell::new(entry_indices_by_enum_index),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/collator.rs b/Libraries/LibJS/Rust/src/runtime/intl/collator.rs
index acc57349448..00a5d29460f 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/collator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/collator.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -28,7 +27,7 @@ use crate::utf16::Utf16View;
pub struct Collator {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
usage: Cell<Usage>, // [[Usage]]
#[gc(untraced)]
@@ -36,7 +35,7 @@ pub struct Collator {
#[gc(untraced)]
case_first: Cell<CaseFirst>, // [[CaseFirst]]
#[gc(untraced)]
- collation: GcRefCell<Utf16String>, // [[Collation]]
+ collation: RefCell<Utf16String>, // [[Collation]]
#[gc(untraced)]
ignore_punctuation: Cell<bool>, // [[IgnorePunctuation]]
#[gc(untraced)]
@@ -45,7 +44,7 @@ pub struct Collator {
// Non-standard. Stores the ICU collator for the Intl object's collation options.
#[gc(untraced)]
- collator: GcRefCell<Option<unicode::Collator>>,
+ collator: RefCell<Option<unicode::Collator>>,
}
define_cell!(Collator, Object, extends: [Object], finalize: finalize);
@@ -68,15 +67,15 @@ impl Collator {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> Collator {
Collator {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
+ locale: RefCell::default(),
usage: Cell::new(Usage::Sort),
sensitivity: Cell::new(Sensitivity::Variant),
case_first: Cell::new(CaseFirst::False),
- collation: GcRefCell::default(),
+ collation: RefCell::default(),
ignore_punctuation: Cell::new(false),
numeric: Cell::new(false),
bound_compare: Cell::new(None),
- collator: GcRefCell::new(None),
+ collator: RefCell::new(None),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format.rs b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format.rs
index 14ff9a46503..e00d92390d4 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/date_time_format.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/date_time_format.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -61,52 +60,52 @@ pub enum ValueFormatter {
pub struct DateTimeFormat {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
- calendar: GcRefCell<Utf16String>, // [[Calendar]]
+ calendar: RefCell<Utf16String>, // [[Calendar]]
#[gc(untraced)]
- numbering_system: GcRefCell<Utf16String>, // [[NumberingSystem]]
+ numbering_system: RefCell<Utf16String>, // [[NumberingSystem]]
#[gc(untraced)]
- time_zone: GcRefCell<Utf16String>, // [[TimeZone]]
+ time_zone: RefCell<Utf16String>, // [[TimeZone]]
#[gc(untraced)]
date_style: Cell<Option<DateTimeStyle>>, // [[DateStyle]]
#[gc(untraced)]
time_style: Cell<Option<DateTimeStyle>>, // [[TimeStyle]]
#[gc(untraced)]
- date_time_format: GcRefCell<CalendarPattern>, // [[DateTimeFormat]]
+ date_time_format: RefCell<CalendarPattern>, // [[DateTimeFormat]]
#[gc(untraced)]
- temporal_plain_date_format: GcRefCell<Option<CalendarPattern>>, // [[TemporalPlainDateFormat]]
+ temporal_plain_date_format: RefCell<Option<CalendarPattern>>, // [[TemporalPlainDateFormat]]
#[gc(untraced)]
- temporal_plain_year_month_format: GcRefCell<Option<CalendarPattern>>, // [[TemporalPlainYearMonthFormat]]
+ temporal_plain_year_month_format: RefCell<Option<CalendarPattern>>, // [[TemporalPlainYearMonthFormat]]
#[gc(untraced)]
- temporal_plain_month_day_format: GcRefCell<Option<CalendarPattern>>, // [[TemporalPlainMonthDayFormat]]
+ temporal_plain_month_day_format: RefCell<Option<CalendarPattern>>, // [[TemporalPlainMonthDayFormat]]
#[gc(untraced)]
- temporal_plain_time_format: GcRefCell<Option<CalendarPattern>>, // [[TemporalPlainTimeFormat]]
+ temporal_plain_time_format: RefCell<Option<CalendarPattern>>, // [[TemporalPlainTimeFormat]]
#[gc(untraced)]
- temporal_plain_date_time_format: GcRefCell<Option<CalendarPattern>>, // [[TemporalPlainDateTimeFormat]]
+ temporal_plain_date_time_format: RefCell<Option<CalendarPattern>>, // [[TemporalPlainDateTimeFormat]]
#[gc(untraced)]
- temporal_instant_format: GcRefCell<Option<CalendarPattern>>, // [[TemporalInstantFormat]]
+ temporal_instant_format: RefCell<Option<CalendarPattern>>, // [[TemporalInstantFormat]]
bound_format: Cell<Option<Gc<DateTimeFormatFunction>>>, // [[BoundFormat]]
// Non-standard. Stores the ICU date-time formatters for the Intl object's formatting options.
#[gc(untraced)]
- icu_locale: GcRefCell<Utf16String>,
+ icu_locale: RefCell<Utf16String>,
#[gc(untraced)]
- formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_plain_date_formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ temporal_plain_date_formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_plain_year_month_formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ temporal_plain_year_month_formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_plain_month_day_formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ temporal_plain_month_day_formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_plain_time_formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ temporal_plain_time_formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_plain_date_time_formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ temporal_plain_date_time_formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_instant_formatter: GcRefCell<Option<unicode::DateTimeFormat>>,
+ temporal_instant_formatter: RefCell<Option<unicode::DateTimeFormat>>,
#[gc(untraced)]
- temporal_time_zone: GcRefCell<Utf16String>,
+ temporal_time_zone: RefCell<Utf16String>,
}
define_cell!(DateTimeFormat, Object, extends: [Object], finalize: finalize);
@@ -139,29 +138,29 @@ impl DateTimeFormat {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> DateTimeFormat {
DateTimeFormat {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
- calendar: GcRefCell::default(),
- numbering_system: GcRefCell::default(),
- time_zone: GcRefCell::default(),
+ locale: RefCell::default(),
+ calendar: RefCell::default(),
+ numbering_system: RefCell::default(),
+ time_zone: RefCell::default(),
date_style: Cell::new(None),
time_style: Cell::new(None),
- date_time_format: GcRefCell::default(),
- temporal_plain_date_format: GcRefCell::new(None),
- temporal_plain_year_month_format: GcRefCell::new(None),
- temporal_plain_month_day_format: GcRefCell::new(None),
- temporal_plain_time_format: GcRefCell::new(None),
- temporal_plain_date_time_format: GcRefCell::new(None),
- temporal_instant_format: GcRefCell::new(None),
+ date_time_format: RefCell::default(),
+ temporal_plain_date_format: RefCell::new(None),
+ temporal_plain_year_month_format: RefCell::new(None),
+ temporal_plain_month_day_format: RefCell::new(None),
+ temporal_plain_time_format: RefCell::new(None),
+ temporal_plain_date_time_format: RefCell::new(None),
+ temporal_instant_format: RefCell::new(None),
bound_format: Cell::new(None),
- icu_locale: GcRefCell::default(),
- formatter: GcRefCell::new(None),
- temporal_plain_date_formatter: GcRefCell::new(None),
- temporal_plain_year_month_formatter: GcRefCell::new(None),
- temporal_plain_month_day_formatter: GcRefCell::new(None),
- temporal_plain_time_formatter: GcRefCell::new(None),
- temporal_plain_date_time_formatter: GcRefCell::new(None),
- temporal_instant_formatter: GcRefCell::new(None),
- temporal_time_zone: GcRefCell::default(),
+ icu_locale: RefCell::default(),
+ formatter: RefCell::new(None),
+ temporal_plain_date_formatter: RefCell::new(None),
+ temporal_plain_year_month_formatter: RefCell::new(None),
+ temporal_plain_month_day_formatter: RefCell::new(None),
+ temporal_plain_time_formatter: RefCell::new(None),
+ temporal_plain_date_time_formatter: RefCell::new(None),
+ temporal_instant_formatter: RefCell::new(None),
+ temporal_time_zone: RefCell::default(),
}
}
@@ -289,8 +288,8 @@ impl DateTimeFormat {
&self,
value_formatter: ValueFormatter,
) -> (
- &GcRefCell<Option<CalendarPattern>>,
- &GcRefCell<Option<unicode::DateTimeFormat>>,
+ &RefCell<Option<CalendarPattern>>,
+ &RefCell<Option<unicode::DateTimeFormat>>,
) {
match value_formatter {
ValueFormatter::DateTimeFormat => unreachable!("[[DateTimeFormat]] is not the format of a Temporal type"),
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/display_names.rs b/Libraries/LibJS/Rust/src/runtime/intl/display_names.rs
index 29797b0b9d6..2f32d940b17 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/display_names.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/display_names.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -55,7 +54,7 @@ pub enum Fallback {
pub struct DisplayNames {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
style: Cell<Style>, // [[Style]]
#[gc(untraced)]
@@ -67,7 +66,7 @@ pub struct DisplayNames {
// Non-standard. Stores the ICU locale for display-name lookups.
#[gc(untraced)]
- icu_locale: GcRefCell<Utf16String>,
+ icu_locale: RefCell<Utf16String>,
}
define_cell!(DisplayNames, Object, extends: [Object]);
@@ -84,12 +83,12 @@ impl DisplayNames {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> DisplayNames {
DisplayNames {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
+ locale: RefCell::default(),
style: Cell::new(Style::Long),
type_: Cell::new(Type::Invalid),
fallback: Cell::new(Fallback::Invalid),
language_display: Cell::new(None),
- icu_locale: GcRefCell::default(),
+ icu_locale: RefCell::default(),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/duration_format.rs b/Libraries/LibJS/Rust/src/runtime/intl/duration_format.rs
index 773712d500f..234af7abb19 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/duration_format.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/duration_format.rs
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
@@ -12,7 +12,6 @@ use libjs_runtime_macros::Trace;
use num_traits::FromPrimitive;
use crate::gc::class::{GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -98,13 +97,13 @@ impl Default for DurationUnitOptions {
pub struct DurationFormat {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
- numbering_system: GcRefCell<Utf16String>, // [[NumberingSystem]]
+ numbering_system: RefCell<Utf16String>, // [[NumberingSystem]]
#[gc(untraced)]
- hour_minute_separator: GcRefCell<Utf16String>, // [[HourMinutesSeparator]]
+ hour_minute_separator: RefCell<Utf16String>, // [[HourMinutesSeparator]]
#[gc(untraced)]
- minute_second_separator: GcRefCell<Utf16String>, // [[MinutesSecondsSeparator]]
+ minute_second_separator: RefCell<Utf16String>, // [[MinutesSecondsSeparator]]
#[gc(untraced)]
style: Cell<Style>, // [[Style]]
@@ -161,10 +160,10 @@ impl DurationFormat {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> DurationFormat {
DurationFormat {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
- numbering_system: GcRefCell::default(),
- hour_minute_separator: GcRefCell::default(),
- minute_second_separator: GcRefCell::default(),
+ locale: RefCell::default(),
+ numbering_system: RefCell::default(),
+ hour_minute_separator: RefCell::default(),
+ minute_second_separator: RefCell::default(),
style: Cell::new(Style::Long),
years_options: Cell::new(DurationUnitOptions::default()),
months_options: Cell::new(DurationUnitOptions::default()),
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/list_format.rs b/Libraries/LibJS/Rust/src/runtime/intl/list_format.rs
index 16180acfb03..d9c855b7652 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/list_format.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/list_format.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -34,7 +33,7 @@ use crate::utf16::Utf16View;
pub struct ListFormat {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
type_: Cell<ListFormatType>, // [[Type]]
#[gc(untraced)]
@@ -42,7 +41,7 @@ pub struct ListFormat {
// Non-standard. Stores the ICU list formatter for the Intl object's formatting options.
#[gc(untraced)]
- formatter: GcRefCell<Option<unicode::ListFormat>>,
+ formatter: RefCell<Option<unicode::ListFormat>>,
}
define_cell!(ListFormat, Object, extends: [Object], finalize: finalize);
@@ -65,10 +64,10 @@ impl ListFormat {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> ListFormat {
ListFormat {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
+ locale: RefCell::default(),
type_: Cell::new(ListFormatType::Conjunction),
style: Cell::new(Style::Long),
- formatter: GcRefCell::new(None),
+ formatter: RefCell::new(None),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/locale.rs b/Libraries/LibJS/Rust/src/runtime/intl/locale.rs
index 0b39abbd5af..afb491efbce 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/locale.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/locale.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -30,23 +29,23 @@ use crate::utf16::Utf16View;
pub struct Locale {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
- calendar: GcRefCell<Option<Utf16String>>, // [[Calendar]]
+ calendar: RefCell<Option<Utf16String>>, // [[Calendar]]
#[gc(untraced)]
- case_first: GcRefCell<Option<Utf16String>>, // [[CaseFirst]]
+ case_first: RefCell<Option<Utf16String>>, // [[CaseFirst]]
#[gc(untraced)]
- collation: GcRefCell<Option<Utf16String>>, // [[Collation]]
+ collation: RefCell<Option<Utf16String>>, // [[Collation]]
#[gc(untraced)]
- first_day_of_week: GcRefCell<Option<Utf16String>>, // [[FirstDayOfWeek]]
+ first_day_of_week: RefCell<Option<Utf16String>>, // [[FirstDayOfWeek]]
#[gc(untraced)]
- hour_cycle: GcRefCell<Option<Utf16String>>, // [[HourCycle]]
+ hour_cycle: RefCell<Option<Utf16String>>, // [[HourCycle]]
#[gc(untraced)]
- numbering_system: GcRefCell<Option<Utf16String>>, // [[NumberingSystem]]
+ numbering_system: RefCell<Option<Utf16String>>, // [[NumberingSystem]]
#[gc(untraced)]
numeric: Cell<bool>, // [[Numeric]]
#[gc(untraced)]
- cached_locale_id: GcRefCell<Option<LocaleID>>,
+ cached_locale_id: RefCell<Option<LocaleID>>,
}
define_cell!(Locale, Object, extends: [Object]);
@@ -63,15 +62,15 @@ impl Locale {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> Locale {
Locale {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
- calendar: GcRefCell::default(),
- case_first: GcRefCell::default(),
- collation: GcRefCell::default(),
- first_day_of_week: GcRefCell::default(),
- hour_cycle: GcRefCell::default(),
- numbering_system: GcRefCell::default(),
+ locale: RefCell::default(),
+ calendar: RefCell::default(),
+ case_first: RefCell::default(),
+ collation: RefCell::default(),
+ first_day_of_week: RefCell::default(),
+ hour_cycle: RefCell::default(),
+ numbering_system: RefCell::default(),
numeric: Cell::new(false),
- cached_locale_id: GcRefCell::default(),
+ cached_locale_id: RefCell::default(),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/number_format.rs b/Libraries/LibJS/Rust/src/runtime/intl/number_format.rs
index 5de78c5e40d..aa20d01529c 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/number_format.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/number_format.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Class, Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -53,7 +52,7 @@ pub enum ComputedRoundingPriority {
pub struct NumberFormatBase {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
min_integer_digits: Cell<i32>, // [[MinimumIntegerDigits]]
#[gc(untraced)]
@@ -81,7 +80,7 @@ pub struct NumberFormatBase {
// Non-standard. Stores the ICU number formatter for the Intl object's formatting options.
#[gc(untraced)]
- formatter: GcRefCell<Option<unicode::NumberFormat>>,
+ formatter: RefCell<Option<unicode::NumberFormat>>,
}
define_cell!(NumberFormatBase, Object, extends: [Object], finalize: finalize);
@@ -104,7 +103,7 @@ impl NumberFormatBase {
pub fn new(vm: &Vm, class: &'static Class, prototype: Gc<Object>) -> NumberFormatBase {
NumberFormatBase {
base: Object::new_with_prototype(vm, class, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
+ locale: RefCell::default(),
min_integer_digits: Cell::new(0),
min_fraction_digits: Cell::new(None),
max_fraction_digits: Cell::new(None),
@@ -117,7 +116,7 @@ impl NumberFormatBase {
rounding_mode: Cell::new(RoundingMode::HalfExpand),
rounding_increment: Cell::new(1),
trailing_zero_display: Cell::new(TrailingZeroDisplay::Auto),
- formatter: GcRefCell::new(None),
+ formatter: RefCell::new(None),
}
}
@@ -328,17 +327,17 @@ impl NumberFormatBase {
pub struct NumberFormat {
base: NumberFormatBase,
#[gc(untraced)]
- numbering_system: GcRefCell<Utf16String>, // [[NumberingSystem]]
+ numbering_system: RefCell<Utf16String>, // [[NumberingSystem]]
#[gc(untraced)]
style: Cell<NumberFormatStyle>, // [[Style]]
#[gc(untraced)]
- currency: GcRefCell<Option<Utf16String>>, // [[Currency]]
+ currency: RefCell<Option<Utf16String>>, // [[Currency]]
#[gc(untraced)]
currency_display: Cell<Option<CurrencyDisplay>>, // [[CurrencyDisplay]]
#[gc(untraced)]
currency_sign: Cell<Option<CurrencySign>>, // [[CurrencySign]]
#[gc(untraced)]
- unit: GcRefCell<Option<Utf16String>>, // [[Unit]]
+ unit: RefCell<Option<Utf16String>>, // [[Unit]]
#[gc(untraced)]
unit_display: Cell<Option<Style>>, // [[UnitDisplay]]
#[gc(untraced)]
@@ -362,12 +361,12 @@ impl NumberFormat {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> NumberFormat {
NumberFormat {
base: NumberFormatBase::new(vm, Self::CLASS, prototype),
- numbering_system: GcRefCell::default(),
+ numbering_system: RefCell::default(),
style: Cell::new(NumberFormatStyle::Decimal),
- currency: GcRefCell::new(None),
+ currency: RefCell::new(None),
currency_display: Cell::new(None),
currency_sign: Cell::new(None),
- unit: GcRefCell::new(None),
+ unit: RefCell::new(None),
unit_display: Cell::new(None),
use_grouping: Cell::new(Grouping::False),
sign_display: Cell::new(SignDisplay::Auto),
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format.rs b/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format.rs
index 39fe4017c4b..00dab67bfc1 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/relative_time_format.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -36,9 +35,9 @@ use crate::utf16::Utf16View;
pub struct RelativeTimeFormat {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
- numbering_system: GcRefCell<Utf16String>, // [[NumberingSystem]]
+ numbering_system: RefCell<Utf16String>, // [[NumberingSystem]]
#[gc(untraced)]
style: Cell<Style>, // [[Style]]
#[gc(untraced)]
@@ -46,7 +45,7 @@ pub struct RelativeTimeFormat {
// Non-standard. Stores the ICU relative-time formatter for the Intl object's formatting options.
#[gc(untraced)]
- formatter: GcRefCell<Option<unicode_relative_time_format::RelativeTimeFormat>>,
+ formatter: RefCell<Option<unicode_relative_time_format::RelativeTimeFormat>>,
}
define_cell!(RelativeTimeFormat, Object, extends: [Object], finalize: finalize);
@@ -69,11 +68,11 @@ impl RelativeTimeFormat {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> RelativeTimeFormat {
RelativeTimeFormat {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
- numbering_system: GcRefCell::default(),
+ locale: RefCell::default(),
+ numbering_system: RefCell::default(),
style: Cell::new(Style::Long),
numeric: Cell::new(NumericDisplay::Always),
- formatter: GcRefCell::new(None),
+ formatter: RefCell::new(None),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs b/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs
index de1e1a3024e..a8a955d3903 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segment_iterator.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -27,7 +26,7 @@ use crate::utf16::Utf16View;
pub struct SegmentIterator {
base: Object,
#[gc(untraced)]
- iterating_segmenter: GcRefCell<Option<unicode::Segmenter>>, // [[IteratingSegmenter]]
+ iterating_segmenter: RefCell<Option<unicode::Segmenter>>, // [[IteratingSegmenter]]
#[gc(untraced)]
iterated_string: Utf16String, // [[IteratedString]]
@@ -76,14 +75,14 @@ impl SegmentIterator {
realm.intrinsics().intl_segment_iterator_prototype(),
MayInterfereWithIndexedPropertyAccess::No,
),
- iterating_segmenter: GcRefCell::new(Some(segmenter)),
+ iterating_segmenter: RefCell::new(Some(segmenter)),
iterated_string: string,
segments: Cell::new(segments),
},
)
}
- pub fn iterating_segmenter(&self) -> &GcRefCell<Option<unicode::Segmenter>> {
+ pub fn iterating_segmenter(&self) -> &RefCell<Option<unicode::Segmenter>> {
&self.iterating_segmenter
}
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segmenter.rs b/Libraries/LibJS/Rust/src/runtime/intl/segmenter.rs
index b76538123c7..a8f0f948950 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segmenter.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segmenter.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -29,13 +28,13 @@ use crate::utf16::Utf16View;
pub struct Segmenter {
base: Object,
#[gc(untraced)]
- locale: GcRefCell<Utf16String>, // [[Locale]]
+ locale: RefCell<Utf16String>, // [[Locale]]
#[gc(untraced)]
segmenter_granularity: Cell<SegmenterGranularity>, // [[SegmenterGranularity]]
// Non-standard. Stores the ICU segmenter for the Intl object's segmentation options.
#[gc(untraced)]
- segmenter: GcRefCell<Option<unicode::Segmenter>>,
+ segmenter: RefCell<Option<unicode::Segmenter>>,
}
define_cell!(Segmenter, Object, extends: [Object], finalize: finalize);
@@ -58,9 +57,9 @@ impl Segmenter {
pub fn new(vm: &Vm, prototype: Gc<Object>) -> Segmenter {
Segmenter {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- locale: GcRefCell::default(),
+ locale: RefCell::default(),
segmenter_granularity: Cell::new(SegmenterGranularity::Grapheme),
- segmenter: GcRefCell::new(None),
+ segmenter: RefCell::new(None),
}
}
@@ -118,7 +117,7 @@ impl IntlObject for Segmenter {
/// allocations this makes.
pub fn create_segment_data_object(
vm: &Vm,
- segmenter: &GcRefCell<Option<unicode::Segmenter>>,
+ segmenter: &RefCell<Option<unicode::Segmenter>>,
string_value: Gc<PrimitiveString>,
string: Utf16View<'_>,
start_index: usize,
diff --git a/Libraries/LibJS/Rust/src/runtime/intl/segments.rs b/Libraries/LibJS/Rust/src/runtime/intl/segments.rs
index fa55365f0c7..8c92e0fac89 100644
--- a/Libraries/LibJS/Rust/src/runtime/intl/segments.rs
+++ b/Libraries/LibJS/Rust/src/runtime/intl/segments.rs
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -27,7 +26,7 @@ use crate::utf16::Utf16View;
pub struct Segments {
base: Object,
#[gc(untraced)]
- segments_segmenter: GcRefCell<Option<unicode::Segmenter>>, // [[SegmentsSegmenter]]
+ segments_segmenter: RefCell<Option<unicode::Segmenter>>, // [[SegmentsSegmenter]]
segments_string_value: Cell<Gc<PrimitiveString>>, // [[SegmentsStringValue]]
#[gc(untraced)]
segments_string: Utf16String, // [[SegmentsString]]
@@ -74,14 +73,14 @@ impl Segments {
realm.intrinsics().intl_segments_prototype(),
MayInterfereWithIndexedPropertyAccess::No,
),
- segments_segmenter: GcRefCell::new(Some(segmenter)),
+ segments_segmenter: RefCell::new(Some(segmenter)),
segments_string_value: Cell::new(string),
segments_string,
},
)
}
- pub fn segments_segmenter(&self) -> &GcRefCell<Option<unicode::Segmenter>> {
+ pub fn segments_segmenter(&self) -> &RefCell<Option<unicode::Segmenter>> {
&self.segments_segmenter
}
diff --git a/Libraries/LibJS/Rust/src/runtime/private_environment.rs b/Libraries/LibJS/Rust/src/runtime/private_environment.rs
index 90b9caa72ed..9d937d88dbb 100644
--- a/Libraries/LibJS/Rust/src/runtime/private_environment.rs
+++ b/Libraries/LibJS/Rust/src/runtime/private_environment.rs
@@ -4,12 +4,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use ak::Utf16FlyString;
use crate::gc::class::{GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::gc::visitor::{Trace, Visitor};
use crate::interpreter::vm::Vm;
use crate::layout::cell::{CellHeader, Gc};
@@ -55,7 +54,7 @@ impl PrivateName {
/// The parts of a private environment the interpreter does not read.
pub struct PrivateEnvironmentStorage {
/// [[Names]]
- private_names: GcRefCell<Vec<PrivateName>>,
+ private_names: RefCell<Vec<PrivateName>>,
unique_id: u64,
}
@@ -79,7 +78,7 @@ impl PrivateEnvironment {
header: CellHeader::for_class(Self::CLASS),
outer: Cell::new(parent),
storage: PrivateEnvironmentStorage {
- private_names: GcRefCell::new(Vec::new()),
+ private_names: RefCell::new(Vec::new()),
unique_id,
},
})
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_object.rs b/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
index abd0ad40bba..2c3e62c023c 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use core::cell::Cell;
+use core::cell::{Cell, RefCell};
use core::ops::Deref;
use std::rc::Rc;
@@ -12,7 +12,6 @@ use ak::Utf16String;
use libjs_runtime_macros::Trace;
use crate::gc::class::{Finalize, GcCell, define_cell};
-use crate::gc::gc_ref_cell::GcRefCell;
use crate::interpreter::vm::Vm;
use crate::layout::cell::Gc;
use crate::layout::object::Object;
@@ -134,16 +133,16 @@ const PARAGRAPH_SEPARATOR: u16 = 0x2029;
pub struct RegExpObject {
base: Object,
#[gc(untraced)]
- pattern: GcRefCell<Utf16String>,
+ pattern: RefCell<Utf16String>,
#[gc(untraced)]
- flags: GcRefCell<Utf16String>,
+ flags: RefCell<Utf16String>,
#[gc(untraced)]
flag_bits: Cell<RegExpFlags>,
#[gc(untraced)]
legacy_features_enabled: Cell<bool>, // [[LegacyFeaturesEnabled]]
/// The compiled pattern, which RegExp objects with the same pattern and flags share through the regex cache.
#[gc(untraced)]
- cached_regex: GcRefCell<Option<Rc<EcmaScriptRegex>>>,
+ cached_regex: RefCell<Option<Rc<EcmaScriptRegex>>>,
// Note: This is initialized in RegExpAlloc, but will be non-null afterwards
realm: Cell<Option<Gc<Realm>>>, // [[Realm]]
}
@@ -199,11 +198,11 @@ impl RegExpObject {
vm,
RegExpObject {
base: Object::new_with_shape(Self::CLASS, shape, MayInterfereWithIndexedPropertyAccess::No),
- pattern: GcRefCell::new(pattern),
- flags: GcRefCell::new(flags),
+ pattern: RefCell::new(pattern),
+ flags: RefCell::new(flags),
flag_bits: Cell::new(flag_bits),
legacy_features_enabled: Cell::new(false),
- cached_regex: GcRefCell::new(None),
+ cached_regex: RefCell::new(None),
realm: Cell::new(None),
},
);
@@ -215,11 +214,11 @@ impl RegExpObject {
let flag_bits = to_flag_bits(Utf16View::of_string(&flags));
RegExpObject {
base: Object::new_with_prototype(vm, Self::CLASS, prototype, MayInterfereWithIndexedPropertyAccess::No),
- pattern: GcRefCell::new(pattern),
- flags: GcRefCell::new(flags),
+ pattern: RefCell::new(pattern),
+ flags: RefCell::new(flags),
flag_bits: Cell::new(flag_bits),
legacy_features_enabled: Cell::new(false),
- cached_regex: GcRefCell::new(None),
+ cached_regex: RefCell::new(None),
realm: Cell::new(None),
}
}
diff --git a/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs b/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs
index ddc90b8729e..7f6cd45ba16 100644
--- a/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs
+++ b/Libraries/LibJS/Rust/src/runtime/shared_function_instance_data.rs
@@ -76,7 +76,8 @@ pub struct SharedFunctionInstanceDataStorage {
// dynamically created functions via Function constructor).
#[gc(untraced)]
source_code: RefCell<Option<Rc<SourceCode>>>,
- source_text_owner: GcRefCell<Utf16String>,
+ #[gc(untraced)]
+ source_text_owner: RefCell<Utf16String>,
source_text_offset: Cell<usize>,
source_text_length: Cell<usize>, // [[SourceText]]
@@ -229,7 +230,7 @@ impl SharedFunctionInstanceData {
storage: SharedFunctionInstanceDataStorage {
name,
source_code: RefCell::new(None),
- source_text_owner: GcRefCell::new(Utf16String::default()),
+ source_text_owner: RefCell::new(Utf16String::default()),
source_text_offset: Cell::new(0),
source_text_length: Cell::new(0),
function_length,