Upgrade to new `gc-arena` API (#11182)

* core: add temporary, ruffle-internal copy of `gc-arena` crate

This will allow bumping the upstream `gc-arena` version while
reexporting our own version of the old `GcCell` API, so that
Ruffle's code can be gradually migrated.

Once the migration is done, this crate should be removed.

* core: bump `gc-arena` to kyren/gc-arena#56

Add back the removed `GcCell` to our internal facade crate

* core: bump `gc-arena` to current master

This bump renames `Gc::allocate` to `Gc::new`

* core: rename `GcCell::allocate` to `GcCell::new`, to match `Gc`

* core: bump gc-arena to (slighly after) v0.3.1

Add typedefs for old `*Context` names in the gc-arena facade crate

* core: replace uses of `CollectionContext<'_>` by `&Collection`

* core: Add `gc()` convenience method for `*Context` and `Activation` types

This allows shortening most instances of `[activation.]context.gc_context`
to `activation.gc()` or `context.gc()` (but not all instances, because of
borrowck) Note that this doesn't actually do these shortenings to avoid
major code churn.
This commit is contained in:
moulins 2023-07-09 23:04:25 +02:00 committed by GitHub
parent 9d3e96e3a4
commit f5b4fbce77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
111 changed files with 487 additions and 298 deletions

25
Cargo.lock generated
View File

@ -1810,8 +1810,8 @@ dependencies = [
[[package]] [[package]]
name = "gc-arena" name = "gc-arena"
version = "0.2.2" version = "0.3.1"
source = "git+https://github.com/kyren/gc-arena?rev=63dab12871321e0e5ada10ff1f1de8f4cf1764f9#63dab12871321e0e5ada10ff1f1de8f4cf1764f9" source = "git+https://github.com/kyren/gc-arena?rev=ad3e24f89c78d8bb94db18383987290f88e4edcb#ad3e24f89c78d8bb94db18383987290f88e4edcb"
dependencies = [ dependencies = [
"gc-arena-derive", "gc-arena-derive",
"sptr", "sptr",
@ -1819,8 +1819,8 @@ dependencies = [
[[package]] [[package]]
name = "gc-arena-derive" name = "gc-arena-derive"
version = "0.2.2" version = "0.3.1"
source = "git+https://github.com/kyren/gc-arena?rev=63dab12871321e0e5ada10ff1f1de8f4cf1764f9#63dab12871321e0e5ada10ff1f1de8f4cf1764f9" source = "git+https://github.com/kyren/gc-arena?rev=ad3e24f89c78d8bb94db18383987290f88e4edcb#ad3e24f89c78d8bb94db18383987290f88e4edcb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3816,7 +3816,6 @@ dependencies = [
"flv-rs", "flv-rs",
"fnv", "fnv",
"futures", "futures",
"gc-arena",
"generational-arena", "generational-arena",
"hashbrown 0.14.0", "hashbrown 0.14.0",
"indexmap 2.0.0", "indexmap 2.0.0",
@ -3832,6 +3831,7 @@ dependencies = [
"rand", "rand",
"realfft", "realfft",
"regress", "regress",
"ruffle_gc_arena",
"ruffle_macros", "ruffle_macros",
"ruffle_render", "ruffle_render",
"ruffle_video", "ruffle_video",
@ -3888,6 +3888,13 @@ dependencies = [
"winit", "winit",
] ]
[[package]]
name = "ruffle_gc_arena"
version = "0.0.0"
dependencies = [
"gc-arena",
]
[[package]] [[package]]
name = "ruffle_input_format" name = "ruffle_input_format"
version = "0.1.0" version = "0.1.0"
@ -3915,7 +3922,6 @@ dependencies = [
"downcast-rs", "downcast-rs",
"enum-map", "enum-map",
"flate2", "flate2",
"gc-arena",
"gif", "gif",
"h263-rs-yuv", "h263-rs-yuv",
"jpeg-decoder", "jpeg-decoder",
@ -3925,6 +3931,7 @@ dependencies = [
"num-traits", "num-traits",
"png", "png",
"renderdoc", "renderdoc",
"ruffle_gc_arena",
"ruffle_wstr", "ruffle_wstr",
"serde", "serde",
"smallvec", "smallvec",
@ -3941,9 +3948,9 @@ version = "0.1.0"
dependencies = [ dependencies = [
"downcast-rs", "downcast-rs",
"fnv", "fnv",
"gc-arena",
"js-sys", "js-sys",
"log", "log",
"ruffle_gc_arena",
"ruffle_render", "ruffle_render",
"ruffle_web_common", "ruffle_web_common",
"swf", "swf",
@ -3958,9 +3965,9 @@ dependencies = [
"bytemuck", "bytemuck",
"downcast-rs", "downcast-rs",
"fnv", "fnv",
"gc-arena",
"js-sys", "js-sys",
"log", "log",
"ruffle_gc_arena",
"ruffle_render", "ruffle_render",
"ruffle_web_common", "ruffle_web_common",
"swf", "swf",
@ -3979,7 +3986,6 @@ dependencies = [
"enum-map", "enum-map",
"fnv", "fnv",
"futures", "futures",
"gc-arena",
"image", "image",
"indexmap 2.0.0", "indexmap 2.0.0",
"lru", "lru",
@ -3990,6 +3996,7 @@ dependencies = [
"ouroboros", "ouroboros",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle",
"ruffle_gc_arena",
"ruffle_render", "ruffle_render",
"swf", "swf",
"tracing", "tracing",

View File

@ -18,6 +18,8 @@ members = [
"render/wgpu", "render/wgpu",
"render/webgl", "render/webgl",
"ruffle_gc_arena",
"video", "video",
"video/software", "video/software",
@ -36,7 +38,7 @@ repository = "https://github.com/ruffle-rs/ruffle"
version = "0.1.0" version = "0.1.0"
[workspace.dependencies] [workspace.dependencies]
gc-arena = { git = "https://github.com/kyren/gc-arena", rev = "63dab12871321e0e5ada10ff1f1de8f4cf1764f9" } # gc-arena = { git = "https://github.com/kyren/gc-arena", rev = "ad3e24f89c78d8bb94db18383987290f88e4edcb" }
tracing = "0.1.37" tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
naga = { version = "0.12.2", features = ["validate", "wgsl-out"] } naga = { version = "0.12.2", features = ["validate", "wgsl-out"] }

View File

@ -13,7 +13,7 @@ byteorder = "1.4"
bitstream-io = "1.6.0" bitstream-io = "1.6.0"
flate2 = "1.0.26" flate2 = "1.0.26"
fnv = "1.0.7" fnv = "1.0.7"
gc-arena = { workspace = true } gc-arena = { package = "ruffle_gc_arena", path = "../ruffle_gc_arena" }
generational-arena = "0.2.9" generational-arena = "0.2.9"
indexmap = "2.0.0" indexmap = "2.0.0"
tracing = { workspace = true } tracing = { workspace = true }

View File

@ -45,7 +45,7 @@ pub struct RegisterSet<'gc>(SmallVec<[Value<'gc>; 8]>);
unsafe impl<'gc> gc_arena::Collect for RegisterSet<'gc> { unsafe impl<'gc> gc_arena::Collect for RegisterSet<'gc> {
#[inline] #[inline]
fn trace(&self, cc: gc_arena::CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for register in &self.0 { for register in &self.0 {
register.trace(cc); register.trace(cc);
} }
@ -172,6 +172,7 @@ impl<'a> ActivationIdentifier<'a> {
} }
} }
/// Represents a single activation of a given AVM1 function or keyframe.
pub struct Activation<'a, 'gc: 'a> { pub struct Activation<'a, 'gc: 'a> {
/// Represents the SWF version of a given function. /// Represents the SWF version of a given function.
/// ///
@ -233,6 +234,13 @@ impl Drop for Activation<'_, '_> {
} }
impl<'a, 'gc> Activation<'a, 'gc> { impl<'a, 'gc> Activation<'a, 'gc> {
/// Convenience method to retrieve the current GC context. Note that explicitely writing
/// `self.context.gc_context` can be sometimes necessary to satisfy the borrow checker.
#[inline(always)]
pub fn gc(&self) -> &'gc gc_arena::Mutation<'gc> {
self.context.gc_context
}
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub fn from_action( pub fn from_action(
context: UpdateContext<'a, 'gc>, context: UpdateContext<'a, 'gc>,
@ -357,7 +365,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
let clip_obj = active_clip let clip_obj = active_clip
.object() .object()
.coerce_to_object(&mut parent_activation); .coerce_to_object(&mut parent_activation);
let child_scope = Gc::allocate( let child_scope = Gc::new(
parent_activation.context.gc_context, parent_activation.context.gc_context,
Scope::new( Scope::new(
parent_activation.scope(), parent_activation.scope(),
@ -395,7 +403,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
Value::Object(o) => o, Value::Object(o) => o,
_ => panic!("No script object for display object"), _ => panic!("No script object for display object"),
}; };
let child_scope = Gc::allocate( let child_scope = Gc::new(
self.context.gc_context, self.context.gc_context,
Scope::new( Scope::new(
self.context.avm1.global_scope(), self.context.avm1.global_scope(),
@ -869,7 +877,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
self.context self.context
.avm1 .avm1
.set_constant_pool(Gc::allocate(self.context.gc_context, constants)); .set_constant_pool(Gc::new(self.context.gc_context, constants));
self.set_constant_pool(self.context.avm1.constant_pool()); self.set_constant_pool(self.context.avm1.constant_pool());
Ok(FrameControl::Continue) Ok(FrameControl::Continue)
@ -907,7 +915,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
.into(); .into();
let func_obj = FunctionObject::function( let func_obj = FunctionObject::function(
self.context.gc_context, self.context.gc_context,
Gc::allocate(self.context.gc_context, func), Gc::new(self.context.gc_context, func),
self.context.avm1.prototypes().function, self.context.avm1.prototypes().function,
prototype, prototype,
); );
@ -2388,7 +2396,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
value => { value => {
// Note that primitives get boxed at this point. // Note that primitives get boxed at this point.
let object = value.coerce_to_object(self); let object = value.coerce_to_object(self);
let with_scope = Gc::allocate( let with_scope = Gc::new(
self.context.gc_context, self.context.gc_context,
Scope::new_with_scope(self.scope(), object), Scope::new_with_scope(self.scope(), object),
); );
@ -3017,7 +3025,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
pub fn allocate_local_registers(&mut self, num: u8, mc: MutationContext<'gc, '_>) { pub fn allocate_local_registers(&mut self, num: u8, mc: MutationContext<'gc, '_>) {
self.local_registers = match num { self.local_registers = match num {
0 => None, 0 => None,
num => Some(GcCell::allocate(mc, RegisterSet::new(num))), num => Some(GcCell::new(mc, RegisterSet::new(num))),
}; };
} }

View File

@ -381,7 +381,7 @@ impl<'gc> Executable<'gc> {
_ => unreachable!(), _ => unreachable!(),
}; };
// TODO: It would be nice to avoid these extra Scope allocs. // TODO: It would be nice to avoid these extra Scope allocs.
let scope = Gc::allocate( let scope = Gc::new(
activation.context.gc_context, activation.context.gc_context,
Scope::new( Scope::new(
activation.context.avm1.global_scope(), activation.context.avm1.global_scope(),
@ -392,7 +392,7 @@ impl<'gc> Executable<'gc> {
(swf_version, scope) (swf_version, scope)
}; };
let child_scope = Gc::allocate( let child_scope = Gc::new(
activation.context.gc_context, activation.context.gc_context,
Scope::new_local_scope(parent_scope, activation.context.gc_context), Scope::new_local_scope(parent_scope, activation.context.gc_context),
); );
@ -508,7 +508,7 @@ impl<'gc> FunctionObject<'gc> {
) -> Self { ) -> Self {
Self { Self {
base: ScriptObject::new(gc_context, Some(fn_proto)), base: ScriptObject::new(gc_context, Some(fn_proto)),
data: GcCell::allocate( data: GcCell::new(
gc_context, gc_context,
FunctionObjectData { FunctionObjectData {
function, function,
@ -711,7 +711,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
Ok(FunctionObject { Ok(FunctionObject {
base: ScriptObject::new(activation.context.gc_context, Some(prototype)), base: ScriptObject::new(activation.context.gc_context, Some(prototype)),
data: GcCell::allocate( data: GcCell::new(
activation.context.gc_context, activation.context.gc_context,
FunctionObjectData { FunctionObjectData {
function: None, function: None,

View File

@ -170,7 +170,7 @@ pub struct BevelFilter<'gc>(GcCell<'gc, BevelFilterData>);
impl<'gc> BevelFilter<'gc> { impl<'gc> BevelFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let bevel_filter = Self(GcCell::allocate( let bevel_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -190,11 +190,11 @@ impl<'gc> BevelFilter<'gc> {
} }
pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::BevelFilter) -> Self { pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::BevelFilter) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn distance(&self) -> f64 { fn distance(&self) -> f64 {

View File

@ -71,10 +71,7 @@ fn new_bitmap_data<'gc>(
} }
object.set_native( object.set_native(
gc_context, gc_context,
NativeObject::BitmapData(BitmapDataWrapper::new(GcCell::allocate( NativeObject::BitmapData(BitmapDataWrapper::new(GcCell::new(gc_context, bitmap_data))),
gc_context,
bitmap_data,
))),
); );
object object
} }
@ -108,7 +105,7 @@ fn constructor<'gc>(
let bitmap_data = BitmapData::new(width, height, transparency, fill_color); let bitmap_data = BitmapData::new(width, height, transparency, fill_color);
this.set_native( this.set_native(
activation.context.gc_context, activation.context.gc_context,
NativeObject::BitmapData(BitmapDataWrapper::new(GcCell::allocate( NativeObject::BitmapData(BitmapDataWrapper::new(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
bitmap_data, bitmap_data,
))), ))),

View File

@ -54,7 +54,7 @@ pub struct BlurFilter<'gc>(GcCell<'gc, BlurFilterData>);
impl<'gc> BlurFilter<'gc> { impl<'gc> BlurFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let blur_filter = Self(GcCell::allocate( let blur_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -65,11 +65,11 @@ impl<'gc> BlurFilter<'gc> {
} }
pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::BlurFilter) -> Self { pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::BlurFilter) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn blur_x(&self) -> f64 { fn blur_x(&self) -> f64 {

View File

@ -51,7 +51,7 @@ pub struct ColorMatrixFilter<'gc>(GcCell<'gc, ColorMatrixFilterData>);
impl<'gc> ColorMatrixFilter<'gc> { impl<'gc> ColorMatrixFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let color_matrix_filter = Self(GcCell::allocate( let color_matrix_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -63,11 +63,11 @@ impl<'gc> ColorMatrixFilter<'gc> {
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
filter: swf::ColorMatrixFilter, filter: swf::ColorMatrixFilter,
) -> Self { ) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn matrix(&self, activation: &mut Activation<'_, 'gc>) -> Value<'gc> { fn matrix(&self, activation: &mut Activation<'_, 'gc>) -> Value<'gc> {

View File

@ -129,10 +129,7 @@ pub fn constructor<'gc>(
}; };
this.set_native( this.set_native(
activation.context.gc_context, activation.context.gc_context,
NativeObject::ColorTransform(GcCell::allocate( NativeObject::ColorTransform(GcCell::new(activation.context.gc_context, color_transform)),
activation.context.gc_context,
color_transform,
)),
); );
Ok(this.into()) Ok(this.into())
} }

View File

@ -111,7 +111,7 @@ pub struct ConvolutionFilter<'gc>(GcCell<'gc, ConvolutionFilterData>);
impl<'gc> ConvolutionFilter<'gc> { impl<'gc> ConvolutionFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let convolution_filter = Self(GcCell::allocate( let convolution_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -141,11 +141,11 @@ impl<'gc> ConvolutionFilter<'gc> {
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
filter: swf::ConvolutionFilter, filter: swf::ConvolutionFilter,
) -> Self { ) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn matrix_x(&self) -> u8 { fn matrix_x(&self) -> u8 {

View File

@ -372,7 +372,7 @@ fn constructor<'gc>(
}; };
this.set_native( this.set_native(
activation.context.gc_context, activation.context.gc_context,
NativeObject::Date(GcCell::allocate(activation.context.gc_context, date)), NativeObject::Date(GcCell::new(activation.context.gc_context, date)),
); );
Ok(this.into()) Ok(this.into())
} }

View File

@ -113,7 +113,7 @@ pub struct DisplacementMapFilter<'gc>(GcCell<'gc, DisplacementMapFilterData<'gc>
impl<'gc> DisplacementMapFilter<'gc> { impl<'gc> DisplacementMapFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let displacement_map_filter = Self(GcCell::allocate( let displacement_map_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -133,11 +133,11 @@ impl<'gc> DisplacementMapFilter<'gc> {
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
filter: ruffle_render::filters::DisplacementMapFilter, filter: ruffle_render::filters::DisplacementMapFilter,
) -> Self { ) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn map_bitmap(&self, context: &mut UpdateContext<'_, 'gc>) -> Option<Object<'gc>> { fn map_bitmap(&self, context: &mut UpdateContext<'_, 'gc>) -> Option<Object<'gc>> {

View File

@ -97,7 +97,7 @@ pub struct DropShadowFilter<'gc>(GcCell<'gc, DropShadowFilterData>);
impl<'gc> DropShadowFilter<'gc> { impl<'gc> DropShadowFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let drop_shadow_filter = Self(GcCell::allocate( let drop_shadow_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -119,11 +119,11 @@ impl<'gc> DropShadowFilter<'gc> {
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
filter: swf::DropShadowFilter, filter: swf::DropShadowFilter,
) -> Self { ) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn distance(&self) -> f64 { fn distance(&self) -> f64 {

View File

@ -85,7 +85,7 @@ pub struct GlowFilter<'gc>(GcCell<'gc, GlowFilterData>);
impl<'gc> GlowFilter<'gc> { impl<'gc> GlowFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let glow_filter = Self(GcCell::allocate( let glow_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -101,11 +101,11 @@ impl<'gc> GlowFilter<'gc> {
} }
pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::GlowFilter) -> Self { pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::GlowFilter) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn color(&self) -> i32 { fn color(&self) -> i32 {

View File

@ -122,7 +122,7 @@ pub struct GradientFilter<'gc>(GcCell<'gc, GradientFilterData>);
impl<'gc> GradientFilter<'gc> { impl<'gc> GradientFilter<'gc> {
fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> { fn new(activation: &mut Activation<'_, 'gc>, args: &[Value<'gc>]) -> Result<Self, Error<'gc>> {
let gradient_bevel_filter = Self(GcCell::allocate( let gradient_bevel_filter = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Default::default(), Default::default(),
)); ));
@ -141,11 +141,11 @@ impl<'gc> GradientFilter<'gc> {
} }
pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::GradientFilter) -> Self { pub fn from_filter(gc_context: MutationContext<'gc, '_>, filter: swf::GradientFilter) -> Self {
Self(GcCell::allocate(gc_context, filter.into())) Self(GcCell::new(gc_context, filter.into()))
} }
pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self { pub(crate) fn duplicate(&self, gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, self.0.read().clone())) Self(GcCell::new(gc_context, self.0.read().clone()))
} }
fn distance(&self) -> f64 { fn distance(&self) -> f64 {

View File

@ -135,7 +135,7 @@ fn new_text_format<'gc>(
let object = ScriptObject::new(activation.context.gc_context, Some(proto)); let object = ScriptObject::new(activation.context.gc_context, Some(proto));
object.set_native( object.set_native(
activation.context.gc_context, activation.context.gc_context,
NativeObject::TextFormat(GcCell::allocate(activation.context.gc_context, text_format)), NativeObject::TextFormat(GcCell::new(activation.context.gc_context, text_format)),
); );
object object
} }

View File

@ -609,7 +609,7 @@ pub fn constructor<'gc>(
)?; )?;
this.set_native( this.set_native(
activation.context.gc_context, activation.context.gc_context,
NativeObject::TextFormat(GcCell::allocate(activation.context.gc_context, text_format)), NativeObject::TextFormat(GcCell::new(activation.context.gc_context, text_format)),
); );
Ok(this.into()) Ok(this.into())
} }

View File

@ -69,7 +69,7 @@ impl fmt::Debug for ScriptObject<'_> {
impl<'gc> ScriptObject<'gc> { impl<'gc> ScriptObject<'gc> {
pub fn new(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self { pub fn new(gc_context: MutationContext<'gc, '_>, proto: Option<Object<'gc>>) -> Self {
let object = Self(GcCell::allocate( let object = Self(GcCell::new(
gc_context, gc_context,
ScriptObjectData { ScriptObjectData {
native: NativeObject::None, native: NativeObject::None,

View File

@ -31,7 +31,7 @@ impl fmt::Debug for SharedObject<'_> {
impl<'gc> SharedObject<'gc> { impl<'gc> SharedObject<'gc> {
pub fn empty_shared_obj(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self { pub fn empty_shared_obj(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
SharedObject(GcCell::allocate( SharedObject(GcCell::new(
gc_context, gc_context,
SharedObjectData { SharedObjectData {
base: ScriptObject::new(gc_context, Some(proto)), base: ScriptObject::new(gc_context, Some(proto)),

View File

@ -61,7 +61,7 @@ impl<'gc> SoundObject<'gc> {
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
proto: Object<'gc>, proto: Object<'gc>,
) -> SoundObject<'gc> { ) -> SoundObject<'gc> {
SoundObject(GcCell::allocate( SoundObject(GcCell::new(
gc_context, gc_context,
SoundObjectData { SoundObjectData {
base: ScriptObject::new(gc_context, Some(proto)), base: ScriptObject::new(gc_context, Some(proto)),

View File

@ -48,7 +48,7 @@ impl<'gc> StageObject<'gc> {
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
proto: Object<'gc>, proto: Object<'gc>,
) -> Self { ) -> Self {
Self(GcCell::allocate( Self(GcCell::new(
gc_context, gc_context,
StageObjectData { StageObjectData {
base: ScriptObject::new(gc_context, Some(proto)), base: ScriptObject::new(gc_context, Some(proto)),

View File

@ -42,7 +42,7 @@ pub struct SuperObjectData<'gc> {
impl<'gc> SuperObject<'gc> { impl<'gc> SuperObject<'gc> {
/// Construct a `super` for an incoming stack frame. /// Construct a `super` for an incoming stack frame.
pub fn new(activation: &mut Activation<'_, 'gc>, this: Object<'gc>, depth: u8) -> Self { pub fn new(activation: &mut Activation<'_, 'gc>, this: Object<'gc>, depth: u8) -> Self {
Self(Gc::allocate( Self(Gc::new(
activation.context.gc_context, activation.context.gc_context,
SuperObjectData { this, depth }, SuperObjectData { this, depth },
)) ))

View File

@ -48,7 +48,7 @@ impl<'gc> ValueObject<'gc> {
_ => None, _ => None,
}; };
let obj = ValueObject(GcCell::allocate( let obj = ValueObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ValueObjectData { ValueObjectData {
base: ScriptObject::new(activation.context.gc_context, proto), base: ScriptObject::new(activation.context.gc_context, proto),
@ -80,7 +80,7 @@ impl<'gc> ValueObject<'gc> {
/// Construct an empty box to be filled by a constructor. /// Construct an empty box to be filled by a constructor.
pub fn empty_box(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Object<'gc> { pub fn empty_box(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Object<'gc> {
ValueObject(GcCell::allocate( ValueObject(GcCell::new(
gc_context, gc_context,
ValueObjectData { ValueObjectData {
base: ScriptObject::new(gc_context, Some(proto)), base: ScriptObject::new(gc_context, Some(proto)),

View File

@ -28,7 +28,7 @@ impl<'gc> XmlNodeObject<'gc> {
mut node: XmlNode<'gc>, mut node: XmlNode<'gc>,
proto: Object<'gc>, proto: Object<'gc>,
) -> Self { ) -> Self {
let object = Self(GcCell::allocate( let object = Self(GcCell::new(
gc_context, gc_context,
XmlNodeObjectData { XmlNodeObjectData {
base: ScriptObject::new(gc_context, Some(proto)), base: ScriptObject::new(gc_context, Some(proto)),

View File

@ -83,7 +83,7 @@ impl<'gc> XmlObject<'gc> {
/// Construct a new XML document and object pair. /// Construct a new XML document and object pair.
pub fn empty(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self { pub fn empty(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Self {
let mut root = XmlNode::new(gc_context, ELEMENT_NODE, None); let mut root = XmlNode::new(gc_context, ELEMENT_NODE, None);
let object = Self(GcCell::allocate( let object = Self(GcCell::new(
gc_context, gc_context,
XmlObjectData { XmlObjectData {
base: ScriptObject::new(gc_context, Some(proto)), base: ScriptObject::new(gc_context, Some(proto)),

View File

@ -90,11 +90,11 @@ impl<'gc> MovieClipReference<'gc> {
return None; return None;
}; };
Some(Self(Gc::allocate( Some(Self(Gc::new(
activation.context.gc_context, activation.context.gc_context,
MovieClipReferenceData { MovieClipReferenceData {
path: MovieClipPath::new_from_path(activation, path), path: MovieClipPath::new_from_path(activation, path),
cached_stage_object: GcCell::allocate( cached_stage_object: GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Some(cached.as_weak()), Some(cached.as_weak()),
), ),

View File

@ -109,7 +109,7 @@ impl<'gc, V> PropertyMap<'gc, V> {
} }
unsafe impl<'gc, V: Collect> Collect for PropertyMap<'gc, V> { unsafe impl<'gc, V: Collect> Collect for PropertyMap<'gc, V> {
fn trace(&self, cc: gc_arena::CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for (key, value) in &self.0 { for (key, value) in &self.0 {
key.0.trace(cc); key.0.trace(cc);
value.trace(cc); value.trace(cc);

View File

@ -79,8 +79,8 @@ impl<'gc> Avm1<'gc> {
Self { Self {
player_version, player_version,
constant_pool: Gc::allocate(gc_context, vec![]), constant_pool: Gc::new(gc_context, vec![]),
global_scope: Gc::allocate(gc_context, Scope::from_global_object(globals)), global_scope: Gc::new(gc_context, Scope::from_global_object(globals)),
prototypes, prototypes,
broadcaster_functions, broadcaster_functions,
display_properties: stage_object::DisplayPropertyMap::new(), display_properties: stage_object::DisplayPropertyMap::new(),
@ -126,7 +126,7 @@ impl<'gc> Avm1<'gc> {
let clip_obj = active_clip let clip_obj = active_clip
.object() .object()
.coerce_to_object(&mut parent_activation); .coerce_to_object(&mut parent_activation);
let child_scope = Gc::allocate( let child_scope = Gc::new(
parent_activation.context.gc_context, parent_activation.context.gc_context,
Scope::new( Scope::new(
parent_activation.scope(), parent_activation.scope(),
@ -166,7 +166,7 @@ impl<'gc> Avm1<'gc> {
Value::Object(o) => o, Value::Object(o) => o,
_ => panic!("No script object for display object"), _ => panic!("No script object for display object"),
}; };
let child_scope = Gc::allocate( let child_scope = Gc::new(
action_context.gc_context, action_context.gc_context,
Scope::new( Scope::new(
action_context.avm1.global_scope, action_context.avm1.global_scope,
@ -210,7 +210,7 @@ impl<'gc> Avm1<'gc> {
let clip_obj = active_clip let clip_obj = active_clip
.object() .object()
.coerce_to_object(&mut parent_activation); .coerce_to_object(&mut parent_activation);
let child_scope = Gc::allocate( let child_scope = Gc::new(
parent_activation.context.gc_context, parent_activation.context.gc_context,
Scope::new( Scope::new(
parent_activation.scope(), parent_activation.scope(),

View File

@ -72,7 +72,7 @@ impl<'gc> Scope<'gc> {
scope.parent = scope.parent.map(|p| Self::new_target_scope(p, clip, mc)); scope.parent = scope.parent.map(|p| Self::new_target_scope(p, clip, mc));
} }
Gc::allocate(mc, scope) Gc::new(mc, scope)
} }
/// Construct a with scope to be used as the scope during a with block. /// Construct a with scope to be used as the scope during a with block.

View File

@ -164,7 +164,7 @@ impl<'gc> Avm2<'gc> {
player_version, player_version,
stack: Vec::new(), stack: Vec::new(),
scope_stack: Vec::new(), scope_stack: Vec::new(),
call_stack: GcCell::allocate(context.gc_context, CallStack::new()), call_stack: GcCell::new(context.gc_context, CallStack::new()),
playerglobals_domain, playerglobals_domain,
stage_domain, stage_domain,
system_classes: None, system_classes: None,

View File

@ -43,7 +43,7 @@ pub struct RegisterSet<'gc>(SmallVec<[Value<'gc>; 8]>);
unsafe impl<'gc> gc_arena::Collect for RegisterSet<'gc> { unsafe impl<'gc> gc_arena::Collect for RegisterSet<'gc> {
#[inline] #[inline]
fn trace(&self, cc: gc_arena::CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for register in &self.0 { for register in &self.0 {
register.trace(cc); register.trace(cc);
} }
@ -139,6 +139,13 @@ pub struct Activation<'a, 'gc: 'a> {
} }
impl<'a, 'gc> Activation<'a, 'gc> { impl<'a, 'gc> Activation<'a, 'gc> {
/// Convenience method to retrieve the current GC context. Note that explicitely writing
/// `self.context.gc_context` can be sometimes necessary to satisfy the borrow checker.
#[inline(always)]
pub fn gc(&self) -> &'gc gc_arena::Mutation<'gc> {
self.context.gc_context
}
/// Construct an activation that does not represent any particular scope. /// Construct an activation that does not represent any particular scope.
/// ///
/// This exists primarily for non-AVM2 related manipulations of the /// This exists primarily for non-AVM2 related manipulations of the
@ -764,7 +771,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
.pool_maybe_uninitialized_multiname(index, &mut self.borrow_gc())?; .pool_maybe_uninitialized_multiname(index, &mut self.borrow_gc())?;
if name.has_lazy_component() { if name.has_lazy_component() {
let name = name.fill_with_runtime_params(self)?; let name = name.fill_with_runtime_params(self)?;
Ok(Gc::allocate(self.context.gc_context, name)) Ok(Gc::new(self.context.gc_context, name))
} else { } else {
Ok(name) Ok(name)
} }

View File

@ -203,7 +203,7 @@ impl<'gc> Class<'gc> {
) -> GcCell<'gc, Self> { ) -> GcCell<'gc, Self> {
let native_instance_init = instance_init.clone(); let native_instance_init = instance_init.clone();
GcCell::allocate( GcCell::new(
mc, mc,
Self { Self {
name, name,
@ -268,7 +268,7 @@ impl<'gc> Class<'gc> {
AvmString::new_utf8(mc, name_with_params), AvmString::new_utf8(mc, name_with_params),
); );
let new_class = GcCell::allocate(mc, new_class); let new_class = GcCell::new(mc, new_class);
drop(read); drop(read);
this.write(mc).applications.insert(key, new_class); this.write(mc).applications.insert(key, new_class);
@ -378,7 +378,7 @@ impl<'gc> Class<'gc> {
} }
} }
Ok(GcCell::allocate( Ok(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Self { Self {
name, name,
@ -538,7 +538,7 @@ impl<'gc> Class<'gc> {
)?); )?);
} }
Ok(GcCell::allocate( Ok(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Self { Self {
name: QName::new(activation.avm2().public_namespace, name), name: QName::new(activation.avm2().public_namespace, name),

View File

@ -55,7 +55,7 @@ impl<'gc> Domain<'gc> {
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
parent: Option<Domain<'gc>>, parent: Option<Domain<'gc>>,
) -> Domain<'gc> { ) -> Domain<'gc> {
Self(GcCell::allocate( Self(GcCell::new(
mc, mc,
DomainData { DomainData {
defs: PropertyMap::new(), defs: PropertyMap::new(),
@ -75,7 +75,7 @@ impl<'gc> Domain<'gc> {
/// This function must not be called before the player globals have been /// This function must not be called before the player globals have been
/// fully allocated. /// fully allocated.
pub fn movie_domain(activation: &mut Activation<'_, 'gc>, parent: Domain<'gc>) -> Domain<'gc> { pub fn movie_domain(activation: &mut Activation<'_, 'gc>, parent: Domain<'gc>) -> Domain<'gc> {
let this = Self(GcCell::allocate( let this = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
DomainData { DomainData {
defs: PropertyMap::new(), defs: PropertyMap::new(),

View File

@ -68,7 +68,7 @@ pub enum E4XNodeKind<'gc> {
impl<'gc> E4XNode<'gc> { impl<'gc> E4XNode<'gc> {
pub fn dummy(mc: MutationContext<'gc, '_>) -> Self { pub fn dummy(mc: MutationContext<'gc, '_>) -> Self {
E4XNode(GcCell::allocate( E4XNode(GcCell::new(
mc, mc,
E4XNodeData { E4XNodeData {
parent: None, parent: None,
@ -82,7 +82,7 @@ impl<'gc> E4XNode<'gc> {
} }
pub fn text(mc: MutationContext<'gc, '_>, text: AvmString<'gc>, parent: Option<Self>) -> Self { pub fn text(mc: MutationContext<'gc, '_>, text: AvmString<'gc>, parent: Option<Self>) -> Self {
E4XNode(GcCell::allocate( E4XNode(GcCell::new(
mc, mc,
E4XNodeData { E4XNodeData {
parent, parent,
@ -93,7 +93,7 @@ impl<'gc> E4XNode<'gc> {
} }
pub fn element(mc: MutationContext<'gc, '_>, name: AvmString<'gc>, parent: Self) -> Self { pub fn element(mc: MutationContext<'gc, '_>, name: AvmString<'gc>, parent: Self) -> Self {
E4XNode(GcCell::allocate( E4XNode(GcCell::new(
mc, mc,
E4XNodeData { E4XNodeData {
parent: Some(parent), parent: Some(parent),
@ -112,7 +112,7 @@ impl<'gc> E4XNode<'gc> {
value: AvmString<'gc>, value: AvmString<'gc>,
parent: E4XNode<'gc>, parent: E4XNode<'gc>,
) -> Self { ) -> Self {
E4XNode(GcCell::allocate( E4XNode(GcCell::new(
mc, mc,
E4XNodeData { E4XNodeData {
parent: Some(parent), parent: Some(parent),
@ -191,7 +191,7 @@ impl<'gc> E4XNode<'gc> {
}, },
}; };
let node = E4XNode(GcCell::allocate( let node = E4XNode(GcCell::new(
mc, mc,
E4XNodeData { E4XNodeData {
parent: None, parent: None,
@ -360,7 +360,7 @@ impl<'gc> E4XNode<'gc> {
text text
}, },
); );
let node = E4XNode(GcCell::allocate( let node = E4XNode(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
E4XNodeData { E4XNodeData {
parent: None, parent: None,
@ -445,7 +445,7 @@ impl<'gc> E4XNode<'gc> {
Event::PI(_) => E4XNodeKind::ProcessingInstruction(text), Event::PI(_) => E4XNodeKind::ProcessingInstruction(text),
_ => unreachable!(), _ => unreachable!(),
}; };
let node = E4XNode(GcCell::allocate( let node = E4XNode(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
E4XNodeData { E4XNodeData {
parent: None, parent: None,
@ -494,10 +494,7 @@ impl<'gc> E4XNode<'gc> {
local_name: Some(key), local_name: Some(key),
kind: E4XNodeKind::Attribute(value), kind: E4XNodeKind::Attribute(value),
}; };
let attribute = E4XNode(GcCell::allocate( let attribute = E4XNode(GcCell::new(activation.context.gc_context, attribute_data));
activation.context.gc_context,
attribute_data,
));
attribute_nodes.push(attribute); attribute_nodes.push(attribute);
} }
@ -510,10 +507,7 @@ impl<'gc> E4XNode<'gc> {
}, },
}; };
Ok(E4XNode(GcCell::allocate( Ok(E4XNode(GcCell::new(activation.context.gc_context, data)))
activation.context.gc_context,
data,
)))
} }
pub fn local_name(&self) -> Option<AvmString<'gc>> { pub fn local_name(&self) -> Option<AvmString<'gc>> {

View File

@ -29,7 +29,7 @@ pub trait FilterAvm2Ext {
#[derive(Clone, Collect)] #[derive(Clone, Collect)]
#[collect(require_static)] #[collect(require_static)]
pub struct ObjectWrapper { pub struct ObjectWrapper {
root: DynamicRoot<Rootable![Object<'gc>]>, root: DynamicRoot<Rootable![Object<'_>]>,
} }
impl ShaderObject for ObjectWrapper { impl ShaderObject for ObjectWrapper {

View File

@ -68,7 +68,7 @@ pub fn fill_bitmap_data_from_symbol<'gc>(
activation: &mut Activation<'_, 'gc>, activation: &mut Activation<'_, 'gc>,
bd: &Bitmap<'gc>, bd: &Bitmap<'gc>,
) -> BitmapDataWrapper<'gc> { ) -> BitmapDataWrapper<'gc> {
let new_bitmap_data = GcCell::allocate( let new_bitmap_data = GcCell::new(
activation.context.gc_context, activation.context.gc_context,
BitmapData::new_with_pixels( BitmapData::new_with_pixels(
Bitmap::width(*bd).into(), Bitmap::width(*bd).into(),
@ -134,10 +134,7 @@ pub fn init<'gc>(
} }
let new_bitmap_data = BitmapData::new(width, height, transparency, fill_color); let new_bitmap_data = BitmapData::new(width, height, transparency, fill_color);
BitmapDataWrapper::new(GcCell::allocate( BitmapDataWrapper::new(GcCell::new(activation.context.gc_context, new_bitmap_data))
activation.context.gc_context,
new_bitmap_data,
))
}; };
new_bitmap_data.init_object2(activation.context.gc_context, this); new_bitmap_data.init_object2(activation.context.gc_context, this);
@ -1133,10 +1130,7 @@ pub fn clone<'gc>(
let class = activation.avm2().classes().bitmapdata; let class = activation.avm2().classes().bitmapdata;
let new_bitmap_data_object = BitmapDataObject::from_bitmap_data_internal( let new_bitmap_data_object = BitmapDataObject::from_bitmap_data_internal(
activation, activation,
BitmapDataWrapper::new(GcCell::allocate( BitmapDataWrapper::new(GcCell::new(activation.context.gc_context, new_bitmap_data)),
activation.context.gc_context,
new_bitmap_data,
)),
class, class,
)?; )?;
@ -1398,10 +1392,7 @@ pub fn compare<'gc>(
let class = activation.avm2().classes().bitmapdata; let class = activation.avm2().classes().bitmapdata;
Ok(BitmapDataObject::from_bitmap_data_internal( Ok(BitmapDataObject::from_bitmap_data_internal(
activation, activation,
BitmapDataWrapper::new(GcCell::allocate( BitmapDataWrapper::new(GcCell::new(activation.context.gc_context, bitmap_data)),
activation.context.gc_context,
bitmap_data,
)),
class, class,
)? )?
.into()) .into())

View File

@ -153,7 +153,7 @@ impl<'gc> BytecodeMethod<'gc> {
.clone(); .clone();
let activation_class = if method.flags.contains(AbcMethodFlags::NEED_ACTIVATION) { let activation_class = if method.flags.contains(AbcMethodFlags::NEED_ACTIVATION) {
Some(GcCell::allocate(activation.context.gc_context, None)) Some(GcCell::new(activation.context.gc_context, None))
} else { } else {
None None
}; };
@ -323,7 +323,7 @@ impl<'gc> Method<'gc> {
is_variadic: bool, is_variadic: bool,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Self { ) -> Self {
Self::Native(Gc::allocate( Self::Native(Gc::new(
mc, mc,
NativeMethod { NativeMethod {
method, method,
@ -342,7 +342,7 @@ impl<'gc> Method<'gc> {
name: &'static str, name: &'static str,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Self { ) -> Self {
Self::Native(Gc::allocate( Self::Native(Gc::new(
mc, mc,
NativeMethod { NativeMethod {
method, method,

View File

@ -24,7 +24,7 @@ enum NamespaceSet<'gc> {
impl<'gc> NamespaceSet<'gc> { impl<'gc> NamespaceSet<'gc> {
pub fn multiple(set: Vec<Namespace<'gc>>, mc: MutationContext<'gc, '_>) -> Self { pub fn multiple(set: Vec<Namespace<'gc>>, mc: MutationContext<'gc, '_>) -> Self {
Self::Multiple(Gc::allocate(mc, set)) Self::Multiple(Gc::new(mc, set))
} }
pub fn single(ns: Namespace<'gc>) -> Self { pub fn single(ns: Namespace<'gc>) -> Self {
Self::Single(ns) Self::Single(ns)

View File

@ -85,11 +85,11 @@ impl<'gc> Namespace<'gc> {
NamespaceData::Private(translation_unit.pool_string(idx.0, context)?) NamespaceData::Private(translation_unit.pool_string(idx.0, context)?)
} }
}; };
Ok(Self(Gc::allocate(context.gc_context, ns))) Ok(Self(Gc::new(context.gc_context, ns)))
} }
pub fn any(mc: MutationContext<'gc, '_>) -> Self { pub fn any(mc: MutationContext<'gc, '_>) -> Self {
Self(Gc::allocate(mc, NamespaceData::Any)) Self(Gc::new(mc, NamespaceData::Any))
} }
// TODO(moulins): allow passing an AvmAtom or a non-static `&WStr` directly // TODO(moulins): allow passing an AvmAtom or a non-static `&WStr` directly
@ -100,10 +100,7 @@ impl<'gc> Namespace<'gc> {
let atom = context let atom = context
.interner .interner
.intern(context.gc_context, package_name.into()); .intern(context.gc_context, package_name.into());
Self(Gc::allocate( Self(Gc::new(context.gc_context, NamespaceData::Namespace(atom)))
context.gc_context,
NamespaceData::Namespace(atom),
))
} }
// TODO(moulins): allow passing an AvmAtom or a non-static `&WStr` directly // TODO(moulins): allow passing an AvmAtom or a non-static `&WStr` directly
@ -114,7 +111,7 @@ impl<'gc> Namespace<'gc> {
let atom = context let atom = context
.interner .interner
.intern(context.gc_context, package_name.into()); .intern(context.gc_context, package_name.into());
Self(Gc::allocate( Self(Gc::new(
context.gc_context, context.gc_context,
NamespaceData::PackageInternal(atom), NamespaceData::PackageInternal(atom),
)) ))

View File

@ -19,7 +19,7 @@ pub fn array_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ArrayObject(GcCell::allocate( Ok(ArrayObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ArrayObjectData { ArrayObjectData {
base, base,
@ -72,7 +72,7 @@ impl<'gc> ArrayObject<'gc> {
let class = activation.avm2().classes().array; let class = activation.avm2().classes().array;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut instance: Object<'gc> = ArrayObject(GcCell::allocate( let mut instance: Object<'gc> = ArrayObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ArrayObjectData { base, array }, ArrayObjectData { base, array },
)) ))

View File

@ -17,7 +17,7 @@ pub fn bitmap_data_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(BitmapDataObject(GcCell::allocate( Ok(BitmapDataObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
BitmapDataObjectData { BitmapDataObjectData {
base, base,
@ -70,7 +70,7 @@ impl<'gc> BitmapDataObject<'gc> {
bitmap_data: BitmapDataWrapper<'gc>, bitmap_data: BitmapDataWrapper<'gc>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let mut instance: Object<'gc> = Self(GcCell::allocate( let mut instance: Object<'gc> = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
BitmapDataObjectData { BitmapDataObjectData {
base: ScriptObjectData::new(class), base: ScriptObjectData::new(class),

View File

@ -40,7 +40,7 @@ pub fn byte_array_allocator<'gc>(
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ByteArrayObject(GcCell::allocate( Ok(ByteArrayObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ByteArrayObjectData { base, storage }, ByteArrayObjectData { base, storage },
)) ))
@ -80,7 +80,7 @@ impl<'gc> ByteArrayObject<'gc> {
let class = activation.avm2().classes().bytearray; let class = activation.avm2().classes().bytearray;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut instance: Object<'gc> = ByteArrayObject(GcCell::allocate( let mut instance: Object<'gc> = ByteArrayObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ByteArrayObjectData { ByteArrayObjectData {
base, base,

View File

@ -194,7 +194,7 @@ impl<'gc> ClassObject<'gc> {
.or_else(|| superclass_object.and_then(|c| c.instance_allocator())) .or_else(|| superclass_object.and_then(|c| c.instance_allocator()))
.unwrap_or(scriptobject_allocator); .unwrap_or(scriptobject_allocator);
let class_object = ClassObject(GcCell::allocate( let class_object = ClassObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ClassObjectData { ClassObjectData {
base: ScriptObjectData::custom_new(None, None), base: ScriptObjectData::custom_new(None, None),
@ -953,7 +953,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
let native_constructor = self.0.read().native_constructor.clone(); let native_constructor = self.0.read().native_constructor.clone();
let call_handler = self.0.read().call_handler.clone(); let call_handler = self.0.read().call_handler.clone();
let mut class_object = ClassObject(GcCell::allocate( let mut class_object = ClassObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ClassObjectData { ClassObjectData {
base: ScriptObjectData::new(class_class), base: ScriptObjectData::new(class_class),

View File

@ -40,7 +40,7 @@ impl<'gc> Context3DObject<'gc> {
let class = activation.avm2().classes().context3d; let class = activation.avm2().classes().context3d;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = Context3DObject(GcCell::allocate( let mut this: Object<'gc> = Context3DObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Context3DData { Context3DData {
base, base,
@ -264,7 +264,7 @@ impl<'gc> Context3DObject<'gc> {
) { ) {
let module = match program { let module = match program {
Some(program) => program.shader_module_handle(), Some(program) => program.shader_module_handle(),
None => GcCell::allocate(activation.context.gc_context, None), None => GcCell::new(activation.context.gc_context, None),
}; };
self.0 self.0

View File

@ -15,7 +15,7 @@ pub fn date_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(DateObject(GcCell::allocate( Ok(DateObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
DateObjectData { DateObjectData {
base, base,

View File

@ -18,7 +18,7 @@ pub fn dictionary_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(DictionaryObject(GcCell::allocate( Ok(DictionaryObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
DictionaryObjectData { DictionaryObjectData {
base, base,

View File

@ -67,7 +67,7 @@ impl<'gc> DispatchObject<'gc> {
// TODO: we might want this to be a proper Object instance, just in case // TODO: we might want this to be a proper Object instance, just in case
let base = ScriptObjectData::custom_new(None, None); let base = ScriptObjectData::custom_new(None, None);
DispatchObject(GcCell::allocate( DispatchObject(GcCell::new(
mc, mc,
DispatchObjectData { DispatchObjectData {
base, base,

View File

@ -18,7 +18,7 @@ pub fn application_domain_allocator<'gc>(
let domain = activation.domain(); let domain = activation.domain();
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(DomainObject(GcCell::allocate( Ok(DomainObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
DomainObjectData { base, domain }, DomainObjectData { base, domain },
)) ))
@ -62,7 +62,7 @@ impl<'gc> DomainObject<'gc> {
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().application_domain; let class = activation.avm2().classes().application_domain;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = DomainObject(GcCell::allocate( let mut this: Object<'gc> = DomainObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
DomainObjectData { base, domain }, DomainObjectData { base, domain },
)) ))

View File

@ -21,7 +21,7 @@ pub fn error_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ErrorObject(GcCell::allocate( Ok(ErrorObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ErrorObjectData { ErrorObjectData {
base, base,

View File

@ -22,7 +22,7 @@ pub fn event_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(EventObject(GcCell::allocate( Ok(EventObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
EventObjectData { EventObjectData {
base, base,
@ -81,7 +81,7 @@ impl<'gc> EventObject<'gc> {
event.set_bubbles(bubbles); event.set_bubbles(bubbles);
event.set_cancelable(cancelable); event.set_cancelable(cancelable);
let event_object = EventObject(GcCell::allocate( let event_object = EventObject(GcCell::new(
context.gc_context, context.gc_context,
EventObjectData { base, event }, EventObjectData { base, event },
)); ));

View File

@ -25,7 +25,7 @@ pub fn function_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let dummy = Gc::allocate( let dummy = Gc::new(
activation.context.gc_context, activation.context.gc_context,
NativeMethod { NativeMethod {
method: |_, _, _| Ok(Value::Undefined), method: |_, _, _| Ok(Value::Undefined),
@ -36,7 +36,7 @@ pub fn function_allocator<'gc>(
}, },
); );
Ok(FunctionObject(GcCell::allocate( Ok(FunctionObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
FunctionObjectData { FunctionObjectData {
base, base,
@ -120,7 +120,7 @@ impl<'gc> FunctionObject<'gc> {
let fn_class = activation.avm2().classes().function; let fn_class = activation.avm2().classes().function;
let exec = Executable::from_method(method, scope, receiver, subclass_object); let exec = Executable::from_method(method, scope, receiver, subclass_object);
FunctionObject(GcCell::allocate( FunctionObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
FunctionObjectData { FunctionObjectData {
base: ScriptObjectData::new(fn_class), base: ScriptObjectData::new(fn_class),

View File

@ -28,7 +28,7 @@ impl<'gc> IndexBuffer3DObject<'gc> {
let class = activation.avm2().classes().indexbuffer3d; let class = activation.avm2().classes().indexbuffer3d;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = IndexBuffer3DObject(GcCell::allocate( let mut this: Object<'gc> = IndexBuffer3DObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
IndexBuffer3DObjectData { IndexBuffer3DObjectData {
base, base,

View File

@ -22,7 +22,7 @@ pub fn loader_info_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(LoaderInfoObject(GcCell::allocate( Ok(LoaderInfoObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
LoaderInfoObjectData { LoaderInfoObjectData {
base, base,
@ -128,7 +128,7 @@ impl<'gc> LoaderInfoObject<'gc> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let loaded_stream = Some(LoaderStream::Swf(movie, root)); let loaded_stream = Some(LoaderStream::Swf(movie, root));
let mut this: Object<'gc> = LoaderInfoObject(GcCell::allocate( let mut this: Object<'gc> = LoaderInfoObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
LoaderInfoObjectData { LoaderInfoObjectData {
base, base,
@ -172,7 +172,7 @@ impl<'gc> LoaderInfoObject<'gc> {
let class = activation.avm2().classes().loaderinfo; let class = activation.avm2().classes().loaderinfo;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = LoaderInfoObject(GcCell::allocate( let mut this: Object<'gc> = LoaderInfoObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
LoaderInfoObjectData { LoaderInfoObjectData {
base, base,

View File

@ -17,7 +17,7 @@ pub fn namespace_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(NamespaceObject(GcCell::allocate( Ok(NamespaceObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
NamespaceObjectData { NamespaceObjectData {
base, base,
@ -63,7 +63,7 @@ impl<'gc> NamespaceObject<'gc> {
let class = activation.avm2().classes().namespace; let class = activation.avm2().classes().namespace;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = NamespaceObject(GcCell::allocate( let mut this: Object<'gc> = NamespaceObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
NamespaceObjectData { base, namespace }, NamespaceObjectData { base, namespace },
)) ))

View File

@ -16,7 +16,7 @@ pub fn netstream_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let ns = NetStream::new(activation.context.gc_context, None); let ns = NetStream::new(activation.context.gc_context, None);
let this: Object<'gc> = NetStreamObject(GcCell::allocate( let this: Object<'gc> = NetStreamObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
NetStreamObjectData { base, ns }, NetStreamObjectData { base, ns },
)) ))

View File

@ -18,7 +18,7 @@ pub fn primitive_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(PrimitiveObject(GcCell::allocate( Ok(PrimitiveObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
PrimitiveObjectData { PrimitiveObjectData {
base, base,
@ -86,7 +86,7 @@ impl<'gc> PrimitiveObject<'gc> {
}; };
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = PrimitiveObject(GcCell::allocate( let mut this: Object<'gc> = PrimitiveObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
PrimitiveObjectData { base, primitive }, PrimitiveObjectData { base, primitive },
)) ))

View File

@ -28,12 +28,12 @@ impl<'gc> Program3DObject<'gc> {
let class = activation.avm2().classes().program3d; let class = activation.avm2().classes().program3d;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = Program3DObject(GcCell::allocate( let mut this: Object<'gc> = Program3DObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Program3DObjectData { Program3DObjectData {
base, base,
context3d, context3d,
shader_module_handle: GcCell::allocate(activation.context.gc_context, None), shader_module_handle: GcCell::new(activation.context.gc_context, None),
}, },
)) ))
.into(); .into();

View File

@ -17,7 +17,7 @@ pub fn proxy_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ProxyObject(GcCell::allocate( Ok(ProxyObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ProxyObjectData { base }, ProxyObjectData { base },
)) ))

View File

@ -19,7 +19,7 @@ pub fn q_name_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(QNameObject(GcCell::allocate( Ok(QNameObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
QNameObjectData { QNameObjectData {
base, base,
@ -65,7 +65,7 @@ impl<'gc> QNameObject<'gc> {
let class = activation.avm2().classes().qname; let class = activation.avm2().classes().qname;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = QNameObject(GcCell::allocate( let mut this: Object<'gc> = QNameObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
QNameObjectData { base, name }, QNameObjectData { base, name },
)) ))

View File

@ -18,7 +18,7 @@ pub fn reg_exp_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(RegExpObject(GcCell::allocate( Ok(RegExpObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
RegExpObjectData { RegExpObjectData {
base, base,
@ -61,7 +61,7 @@ impl<'gc> RegExpObject<'gc> {
let class = activation.avm2().classes().regexp; let class = activation.avm2().classes().regexp;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = RegExpObject(GcCell::allocate( let mut this: Object<'gc> = RegExpObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
RegExpObjectData { base, regexp }, RegExpObjectData { base, regexp },
)) ))

View File

@ -21,7 +21,7 @@ pub fn scriptobject_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ScriptObject(GcCell::allocate(activation.context.gc_context, base)).into()) Ok(ScriptObject(GcCell::new(activation.context.gc_context, base)).into())
} }
/// Default implementation of `avm2::Object`. /// Default implementation of `avm2::Object`.
@ -101,11 +101,7 @@ impl<'gc> ScriptObject<'gc> {
class: Option<ClassObject<'gc>>, class: Option<ClassObject<'gc>>,
proto: Option<Object<'gc>>, proto: Option<Object<'gc>>,
) -> Object<'gc> { ) -> Object<'gc> {
ScriptObject(GcCell::allocate( ScriptObject(GcCell::new(mc, ScriptObjectData::custom_new(proto, class))).into()
mc,
ScriptObjectData::custom_new(proto, class),
))
.into()
} }
/// A special case for `newcatch` implementation. Basically a variable (q)name /// A special case for `newcatch` implementation. Basically a variable (q)name
@ -118,7 +114,7 @@ impl<'gc> ScriptObject<'gc> {
base.set_vtable(vt); base.set_vtable(vt);
base.install_instance_slots(); base.install_instance_slots();
ScriptObject(GcCell::allocate(mc, base)).into() ScriptObject(GcCell::new(mc, base)).into()
} }
} }

View File

@ -17,7 +17,7 @@ pub fn shader_data_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ShaderDataObject(GcCell::allocate( Ok(ShaderDataObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ShaderDataObjectData { base, shader: None }, ShaderDataObjectData { base, shader: None },
)) ))

View File

@ -22,7 +22,7 @@ pub fn sound_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(SoundObject(GcCell::allocate( Ok(SoundObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
SoundObjectData { SoundObjectData {
base, base,

View File

@ -19,7 +19,7 @@ pub fn sound_channel_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(SoundChannelObject(GcCell::allocate( Ok(SoundChannelObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
SoundChannelObjectData { SoundChannelObjectData {
base, base,
@ -81,7 +81,7 @@ impl<'gc> SoundChannelObject<'gc> {
let class = activation.avm2().classes().soundchannel; let class = activation.avm2().classes().soundchannel;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut sound_object = SoundChannelObject(GcCell::allocate( let mut sound_object = SoundChannelObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
SoundChannelObjectData { SoundChannelObjectData {
base, base,

View File

@ -16,7 +16,7 @@ pub fn stage_3d_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(Stage3DObject(GcCell::allocate( Ok(Stage3DObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
Stage3DObjectData { Stage3DObjectData {
base, base,

View File

@ -46,7 +46,7 @@ impl<'gc> StageObject<'gc> {
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
) -> Result<Self, Error<'gc>> { ) -> Result<Self, Error<'gc>> {
let mut instance = Self(GcCell::allocate( let mut instance = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
StageObjectData { StageObjectData {
base: ScriptObjectData::new(class), base: ScriptObjectData::new(class),
@ -96,7 +96,7 @@ impl<'gc> StageObject<'gc> {
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
) -> Result<Self, Error<'gc>> { ) -> Result<Self, Error<'gc>> {
let class = activation.avm2().classes().graphics; let class = activation.avm2().classes().graphics;
let mut this = Self(GcCell::allocate( let mut this = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
StageObjectData { StageObjectData {
base: ScriptObjectData::new(class), base: ScriptObjectData::new(class),

View File

@ -17,7 +17,7 @@ pub fn textformat_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(TextFormatObject(GcCell::allocate( Ok(TextFormatObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
TextFormatObjectData { TextFormatObjectData {
base, base,
@ -60,7 +60,7 @@ impl<'gc> TextFormatObject<'gc> {
let class = activation.avm2().classes().textformat; let class = activation.avm2().classes().textformat;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = Self(GcCell::allocate( let mut this: Object<'gc> = Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
TextFormatObjectData { base, text_format }, TextFormatObjectData { base, text_format },
)) ))

View File

@ -29,7 +29,7 @@ impl<'gc> TextureObject<'gc> {
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = TextureObject(GcCell::allocate( let mut this: Object<'gc> = TextureObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
TextureObjectData { TextureObjectData {
base, base,

View File

@ -27,7 +27,7 @@ pub fn vector_allocator<'gc>(
.flatten() .flatten()
.unwrap_or_else(|| activation.avm2().classes().object); .unwrap_or_else(|| activation.avm2().classes().object);
Ok(VectorObject(GcCell::allocate( Ok(VectorObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
VectorObjectData { VectorObjectData {
base, base,
@ -75,7 +75,7 @@ impl<'gc> VectorObject<'gc> {
let applied_class = vector_class.apply(activation, value_type.into())?; let applied_class = vector_class.apply(activation, value_type.into())?;
let mut object: Object<'gc> = VectorObject(GcCell::allocate( let mut object: Object<'gc> = VectorObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
VectorObjectData { VectorObjectData {
base: ScriptObjectData::new(applied_class), base: ScriptObjectData::new(applied_class),

View File

@ -30,7 +30,7 @@ impl<'gc> VertexBuffer3DObject<'gc> {
let class = activation.avm2().classes().vertexbuffer3d; let class = activation.avm2().classes().vertexbuffer3d;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = VertexBuffer3DObject(GcCell::allocate( let mut this: Object<'gc> = VertexBuffer3DObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
VertexBuffer3DObjectData { VertexBuffer3DObjectData {
base, base,

View File

@ -18,7 +18,7 @@ pub fn xml_list_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(XmlListObject(GcCell::allocate( Ok(XmlListObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
XmlListObjectData { XmlListObjectData {
base, base,
@ -54,7 +54,7 @@ impl<'gc> XmlListObject<'gc> {
target: Option<Object<'gc>>, target: Option<Object<'gc>>,
) -> Self { ) -> Self {
let base = ScriptObjectData::new(activation.context.avm2.classes().xml_list); let base = ScriptObjectData::new(activation.context.avm2.classes().xml_list);
XmlListObject(GcCell::allocate( XmlListObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
XmlListObjectData { XmlListObjectData {
base, base,

View File

@ -21,7 +21,7 @@ pub fn xml_allocator<'gc>(
) -> Result<Object<'gc>, Error<'gc>> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(XmlObject(GcCell::allocate( Ok(XmlObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
XmlObjectData { XmlObjectData {
base, base,
@ -58,7 +58,7 @@ pub struct XmlObjectData<'gc> {
impl<'gc> XmlObject<'gc> { impl<'gc> XmlObject<'gc> {
pub fn new(node: E4XNode<'gc>, activation: &mut Activation<'_, 'gc>) -> Self { pub fn new(node: E4XNode<'gc>, activation: &mut Activation<'_, 'gc>) -> Self {
XmlObject(GcCell::allocate( XmlObject(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
XmlObjectData { XmlObjectData {
base: ScriptObjectData::new(activation.context.avm2.classes().xml), base: ScriptObjectData::new(activation.context.avm2.classes().xml),

View File

@ -50,7 +50,7 @@ impl<'gc> PropertyClass<'gc> {
name: Multiname<'gc>, name: Multiname<'gc>,
unit: Option<TranslationUnit<'gc>>, unit: Option<TranslationUnit<'gc>>,
) -> Self { ) -> Self {
PropertyClass::Name(Gc::allocate(mc, (name, unit))) PropertyClass::Name(Gc::new(mc, (name, unit)))
} }
/// Returns `value` coerced to the type of this `PropertyClass`. /// Returns `value` coerced to the type of this `PropertyClass`.

View File

@ -5,7 +5,7 @@ use crate::avm2::Multiname;
use crate::avm2::Namespace; use crate::avm2::Namespace;
use crate::avm2::QName; use crate::avm2::QName;
use fnv::FnvBuildHasher; use fnv::FnvBuildHasher;
use gc_arena::{Collect, CollectionContext}; use gc_arena::Collect;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::HashMap; use std::collections::HashMap;
use std::mem::swap; use std::mem::swap;
@ -34,7 +34,7 @@ where
V: Collect, V: Collect,
{ {
#[inline] #[inline]
fn trace(&self, cc: CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for (key, value) in self.0.iter() { for (key, value) in self.0.iter() {
key.trace(cc); key.trace(cc);
for (ns, v) in value.iter() { for (ns, v) in value.iter() {

View File

@ -126,7 +126,7 @@ impl<'gc> ScopeChain<'gc> {
let mut cloned = container.read().scopes.clone(); let mut cloned = container.read().scopes.clone();
cloned.extend_from_slice(new_scopes); cloned.extend_from_slice(new_scopes);
Self { Self {
container: Some(GcCell::allocate(mc, ScopeContainer::new(cloned))), container: Some(GcCell::new(mc, ScopeContainer::new(cloned))),
domain: self.domain, domain: self.domain,
} }
} }
@ -134,10 +134,7 @@ impl<'gc> ScopeChain<'gc> {
// We are chaining on top of an empty ScopeChain, so we don't actually // We are chaining on top of an empty ScopeChain, so we don't actually
// need to chain anything. // need to chain anything.
Self { Self {
container: Some(GcCell::allocate( container: Some(GcCell::new(mc, ScopeContainer::new(new_scopes.to_vec()))),
mc,
ScopeContainer::new(new_scopes.to_vec()),
)),
domain: self.domain, domain: self.domain,
} }
} }

View File

@ -90,7 +90,7 @@ impl<'gc> TranslationUnit<'gc> {
let namespaces = vec![None; abc.constant_pool.namespaces.len() + 1]; let namespaces = vec![None; abc.constant_pool.namespaces.len() + 1];
let multinames = vec![None; abc.constant_pool.multinames.len() + 1]; let multinames = vec![None; abc.constant_pool.multinames.len() + 1];
Self(GcCell::allocate( Self(GcCell::new(
mc, mc,
TranslationUnitData { TranslationUnitData {
domain, domain,
@ -160,7 +160,7 @@ impl<'gc> TranslationUnit<'gc> {
); );
} }
} }
Gc::allocate(activation.context.gc_context, bc_method).into() Gc::new(activation.context.gc_context, bc_method).into()
})(); })();
self.0.write(activation.context.gc_context).methods[method_index.0 as usize] = self.0.write(activation.context.gc_context).methods[method_index.0 as usize] =
@ -317,7 +317,7 @@ impl<'gc> TranslationUnit<'gc> {
drop(read); drop(read);
let multiname = Multiname::from_abc_index(self, multiname_index, context)?; let multiname = Multiname::from_abc_index(self, multiname_index, context)?;
let multiname = Gc::allocate(mc, multiname); let multiname = Gc::new(mc, multiname);
self.0.write(mc).multinames[multiname_index.0 as usize] = Some(multiname); self.0.write(mc).multinames[multiname_index.0 as usize] = Some(multiname);
Ok(multiname) Ok(multiname)
@ -351,7 +351,7 @@ impl<'gc> TranslationUnit<'gc> {
) -> Result<Gc<'gc, Multiname<'gc>>, Error<'gc>> { ) -> Result<Gc<'gc, Multiname<'gc>>, Error<'gc>> {
if multiname_index.0 == 0 { if multiname_index.0 == 0 {
let mc = context.gc_context; let mc = context.gc_context;
Ok(Gc::allocate(mc, Multiname::any(mc))) Ok(Gc::new(mc, Multiname::any(mc)))
} else { } else {
self.pool_multiname_static(multiname_index, context) self.pool_multiname_static(multiname_index, context)
} }
@ -404,7 +404,7 @@ impl<'gc> Script<'gc> {
globals: Object<'gc>, globals: Object<'gc>,
domain: Domain<'gc>, domain: Domain<'gc>,
) -> Self { ) -> Self {
Self(GcCell::allocate( Self(GcCell::new(
mc, mc,
ScriptData { ScriptData {
globals, globals,
@ -447,7 +447,7 @@ impl<'gc> Script<'gc> {
let init = unit.load_method(script.init_method, false, activation)?; let init = unit.load_method(script.init_method, false, activation)?;
Ok(Self(GcCell::allocate( Ok(Self(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
ScriptData { ScriptData {
globals, globals,

View File

@ -54,7 +54,7 @@ pub struct ClassBoundMethod<'gc> {
impl<'gc> VTable<'gc> { impl<'gc> VTable<'gc> {
pub fn empty(mc: MutationContext<'gc, '_>) -> Self { pub fn empty(mc: MutationContext<'gc, '_>) -> Self {
VTable(GcCell::allocate( VTable(GcCell::new(
mc, mc,
VTableData { VTableData {
defining_class: None, defining_class: None,
@ -74,7 +74,7 @@ impl<'gc> VTable<'gc> {
rt.insert(*vname, Property::Slot { slot_id: 1 }); rt.insert(*vname, Property::Slot { slot_id: 1 });
let vt = VTable(GcCell::allocate( let vt = VTable(GcCell::new(
mc, mc,
VTableData { VTableData {
defining_class: None, defining_class: None,
@ -95,7 +95,7 @@ impl<'gc> VTable<'gc> {
} }
pub fn duplicate(self, mc: MutationContext<'gc, '_>) -> Self { pub fn duplicate(self, mc: MutationContext<'gc, '_>) -> Self {
VTable(GcCell::allocate(mc, self.0.read().clone())) VTable(GcCell::new(mc, self.0.read().clone()))
} }
pub fn resolved_traits(&self) -> Ref<'_, PropertyMap<'gc, Property>> { pub fn resolved_traits(&self) -> Ref<'_, PropertyMap<'gc, Property>> {

View File

@ -289,7 +289,7 @@ mod wrapper {
// Marking it as disposed skips rendering, and the unset `avm2_object` will cause this to // Marking it as disposed skips rendering, and the unset `avm2_object` will cause this to
// be inaccessible to AS3 code. // be inaccessible to AS3 code.
pub fn dummy(mc: MutationContext<'gc, '_>) -> Self { pub fn dummy(mc: MutationContext<'gc, '_>) -> Self {
BitmapDataWrapper(GcCell::allocate( BitmapDataWrapper(GcCell::new(
mc, mc,
BitmapData { BitmapData {
pixels: Vec::new(), pixels: Vec::new(),

View File

@ -26,7 +26,7 @@ use crate::stub::StubCollection;
use crate::tag_utils::{SwfMovie, SwfSlice}; use crate::tag_utils::{SwfMovie, SwfSlice};
use crate::timer::Timers; use crate::timer::Timers;
use core::fmt; use core::fmt;
use gc_arena::{Collect, MutationContext}; use gc_arena::{Collect, Mutation};
use instant::Instant; use instant::Instant;
use rand::rngs::SmallRng; use rand::rngs::SmallRng;
use ruffle_render::backend::{BitmapCacheEntry, RenderBackend}; use ruffle_render::backend::{BitmapCacheEntry, RenderBackend};
@ -39,8 +39,8 @@ use std::time::Duration;
/// Minimal context, useful for manipulating the GC heap. /// Minimal context, useful for manipulating the GC heap.
pub struct GcContext<'a, 'gc> { pub struct GcContext<'a, 'gc> {
/// The mutation context to allocate and mutate `GcCell` types. /// The mutation context to allocate and mutate `Gc` pointers.
pub gc_context: MutationContext<'gc, 'a>, pub gc_context: &'gc Mutation<'gc>,
/// The global string interner. /// The global string interner.
pub interner: &'a mut AvmStringInterner<'gc>, pub interner: &'a mut AvmStringInterner<'gc>,
@ -57,6 +57,13 @@ impl<'a, 'gc> GcContext<'a, 'gc> {
interner: self.interner, interner: self.interner,
} }
} }
/// Convenience method to retrieve the current GC context. Note that explicitely writing
/// `self.gc_context` can be sometimes necessary to satisfy the borrow checker.
#[inline(always)]
pub fn gc(&self) -> &'gc Mutation<'gc> {
self.gc_context
}
} }
/// `UpdateContext` holds shared data that is used by the various subsystems of Ruffle. /// `UpdateContext` holds shared data that is used by the various subsystems of Ruffle.
@ -67,8 +74,8 @@ pub struct UpdateContext<'a, 'gc> {
/// Display objects and actions can push actions onto the queue. /// Display objects and actions can push actions onto the queue.
pub action_queue: &'a mut ActionQueue<'gc>, pub action_queue: &'a mut ActionQueue<'gc>,
/// The mutation context to allocate and mutate `GcCell` types. /// The mutation context to allocate and mutate `Gc` pointers.
pub gc_context: MutationContext<'gc, 'a>, pub gc_context: &'gc Mutation<'gc>,
/// The global string interner. /// The global string interner.
pub interner: &'a mut AvmStringInterner<'gc>, pub interner: &'a mut AvmStringInterner<'gc>,
@ -317,6 +324,13 @@ impl<'a, 'gc> UpdateContext<'a, 'gc> {
} }
impl<'a, 'gc> UpdateContext<'a, 'gc> { impl<'a, 'gc> UpdateContext<'a, 'gc> {
/// Convenience method to retrieve the current GC context. Note that explicitely writing
/// `self.gc_context` can be sometimes necessary to satisfy the borrow checker.
#[inline(always)]
pub fn gc(&self) -> &'gc Mutation<'gc> {
self.gc_context
}
/// Transform a borrowed update context into an owned update context with /// Transform a borrowed update context into an owned update context with
/// a shorter internal lifetime. /// a shorter internal lifetime.
/// ///
@ -469,6 +483,9 @@ impl<'gc> Default for ActionQueue<'gc> {
/// Shared data used during rendering. /// Shared data used during rendering.
/// `Player` creates this when it renders a frame and passes it down to display objects. /// `Player` creates this when it renders a frame and passes it down to display objects.
///
/// As a convenience, this type can be deref-coerced to `Mutation<'gc>`, but note that explicitely
/// writing `context.gc_context` can be sometimes necessary to satisfy the borrow checker.
pub struct RenderContext<'a, 'gc> { pub struct RenderContext<'a, 'gc> {
/// The renderer, used by the display objects to register themselves. /// The renderer, used by the display objects to register themselves.
pub renderer: &'a mut dyn RenderBackend, pub renderer: &'a mut dyn RenderBackend,
@ -479,9 +496,8 @@ pub struct RenderContext<'a, 'gc> {
/// Any offscreen draws that should be used to redraw a cacheAsBitmap /// Any offscreen draws that should be used to redraw a cacheAsBitmap
pub cache_draws: &'a mut Vec<BitmapCacheEntry>, pub cache_draws: &'a mut Vec<BitmapCacheEntry>,
/// The GC MutationContext, used to perform any GcCell writes /// The GC context, used to perform any `Gc` writes that must occur during rendering.
/// that must occur during rendering. pub gc_context: &'gc Mutation<'gc>,
pub gc_context: MutationContext<'gc, 'a>,
/// The library, which provides access to fonts and other definitions when rendering. /// The library, which provides access to fonts and other definitions when rendering.
pub library: &'a Library<'gc>, pub library: &'a Library<'gc>,
@ -499,6 +515,15 @@ pub struct RenderContext<'a, 'gc> {
pub stage: Stage<'gc>, pub stage: Stage<'gc>,
} }
impl<'a, 'gc> RenderContext<'a, 'gc> {
/// Convenience method to retrieve the current GC context. Note that explicitely writing
/// `self.gc_context` can be sometimes necessary to satisfy the borrow checker.
#[inline(always)]
pub fn gc(&self) -> &'gc Mutation<'gc> {
self.gc_context
}
}
/// The type of action being run. /// The type of action being run.
#[derive(Clone, Collect)] #[derive(Clone, Collect)]
#[collect(no_drop)] #[collect(no_drop)]

View File

@ -9,7 +9,7 @@ use std::hash::{Hash, Hasher};
// TODO: Make this generic somehow // TODO: Make this generic somehow
#[derive(Clone)] #[derive(Clone)]
pub struct DisplayObjectHandle { pub struct DisplayObjectHandle {
root: DynamicRoot<Rootable![DisplayObject<'gc>]>, root: DynamicRoot<Rootable![DisplayObject<'_>]>,
ptr: *const DisplayObjectPtr, ptr: *const DisplayObjectPtr,
} }
@ -59,7 +59,7 @@ impl Eq for DisplayObjectHandle {}
#[derive(Clone)] #[derive(Clone)]
pub struct AVM1ObjectHandle { pub struct AVM1ObjectHandle {
root: DynamicRoot<Rootable![crate::avm1::Object<'gc>]>, root: DynamicRoot<Rootable![crate::avm1::Object<'_>]>,
ptr: *const crate::avm1::ObjectPtr, ptr: *const crate::avm1::ObjectPtr,
} }
@ -102,7 +102,7 @@ impl Eq for AVM1ObjectHandle {}
#[derive(Clone)] #[derive(Clone)]
pub struct AVM2ObjectHandle { pub struct AVM2ObjectHandle {
root: DynamicRoot<Rootable![crate::avm2::Object<'gc>]>, root: DynamicRoot<Rootable![crate::avm2::Object<'_>]>,
ptr: *const crate::avm2::object::ObjectPtr, ptr: *const crate::avm2::object::ObjectPtr,
} }

View File

@ -73,11 +73,11 @@ impl<'gc> Avm1Button<'gc> {
over_to_up_sound: None, over_to_up_sound: None,
}; };
Avm1Button(GcCell::allocate( Avm1Button(GcCell::new(
gc_context, gc_context,
Avm1ButtonData { Avm1ButtonData {
base: Default::default(), base: Default::default(),
static_data: GcCell::allocate(gc_context, static_data), static_data: GcCell::new(gc_context, static_data),
container: ChildContainer::new(), container: ChildContainer::new(),
hit_area: BTreeMap::new(), hit_area: BTreeMap::new(),
state: self::ButtonState::Up, state: self::ButtonState::Up,
@ -246,7 +246,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -110,11 +110,11 @@ impl<'gc> Avm2Button<'gc> {
over_to_up_sound: None, over_to_up_sound: None,
}; };
Avm2Button(GcCell::allocate( Avm2Button(GcCell::new(
context.gc_context, context.gc_context,
Avm2ButtonData { Avm2ButtonData {
base: Default::default(), base: Default::default(),
static_data: GcCell::allocate(context.gc_context, static_data), static_data: GcCell::new(context.gc_context, static_data),
state: self::ButtonState::Up, state: self::ButtonState::Up,
hit_area: None, hit_area: None,
up_state: None, up_state: None,
@ -411,7 +411,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -112,7 +112,7 @@ impl<'gc> Bitmap<'gc> {
let width = bitmap_data.width(); let width = bitmap_data.width();
let height = bitmap_data.height(); let height = bitmap_data.height();
Bitmap(GcCell::allocate( Bitmap(GcCell::new(
context.gc_context, context.gc_context,
BitmapGraphicData { BitmapGraphicData {
base: Default::default(), base: Default::default(),
@ -153,7 +153,7 @@ impl<'gc> Bitmap<'gc> {
Ok(Self::new_with_bitmap_data( Ok(Self::new_with_bitmap_data(
context, context,
id, id,
BitmapDataWrapper::new(GcCell::allocate(context.gc_context, bitmap_data)), BitmapDataWrapper::new(GcCell::new(context.gc_context, bitmap_data)),
smoothing, smoothing,
)) ))
} }
@ -253,7 +253,7 @@ impl<'gc> TDisplayObject<'gc> for Bitmap<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -250,12 +250,12 @@ impl<'gc> EditText<'gc> {
flags.contains(EditTextFlag::BORDER), flags.contains(EditTextFlag::BORDER),
); );
let et = EditText(GcCell::allocate( let et = EditText(GcCell::new(
context.gc_context, context.gc_context,
EditTextData { EditTextData {
base, base,
text_spans, text_spans,
static_data: gc_arena::Gc::allocate( static_data: gc_arena::Gc::new(
context.gc_context, context.gc_context,
EditTextStatic { EditTextStatic {
swf: swf_movie, swf: swf_movie,
@ -1586,7 +1586,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -59,11 +59,11 @@ impl<'gc> Graphic<'gc> {
movie, movie,
}; };
Graphic(GcCell::allocate( Graphic(GcCell::new(
context.gc_context, context.gc_context,
GraphicData { GraphicData {
base: Default::default(), base: Default::default(),
static_data: gc_arena::Gc::allocate(context.gc_context, static_data), static_data: gc_arena::Gc::new(context.gc_context, static_data),
avm2_object: None, avm2_object: None,
drawing: None, drawing: None,
}, },
@ -92,11 +92,11 @@ impl<'gc> Graphic<'gc> {
}; };
let drawing = Drawing::new(); let drawing = Drawing::new();
Graphic(GcCell::allocate( Graphic(GcCell::new(
context.gc_context, context.gc_context,
GraphicData { GraphicData {
base: Default::default(), base: Default::default(),
static_data: gc_arena::Gc::allocate(context.gc_context, static_data), static_data: gc_arena::Gc::new(context.gc_context, static_data),
avm2_object: None, avm2_object: None,
drawing: Some(drawing), drawing: Some(drawing),
}, },
@ -120,7 +120,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -42,7 +42,7 @@ pub struct LoaderDisplayData<'gc> {
impl<'gc> LoaderDisplay<'gc> { impl<'gc> LoaderDisplay<'gc> {
pub fn empty(activation: &mut Activation<'_, 'gc>, movie: Arc<SwfMovie>) -> Self { pub fn empty(activation: &mut Activation<'_, 'gc>, movie: Arc<SwfMovie>) -> Self {
let obj = LoaderDisplay(GcCell::allocate( let obj = LoaderDisplay(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
LoaderDisplayData { LoaderDisplayData {
base: Default::default(), base: Default::default(),
@ -72,7 +72,7 @@ impl<'gc> TDisplayObject<'gc> for LoaderDisplay<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -43,11 +43,11 @@ impl<'gc> MorphShape<'gc> {
movie: Arc<SwfMovie>, movie: Arc<SwfMovie>,
) -> Self { ) -> Self {
let static_data = MorphShapeStatic::from_swf_tag(&tag, movie); let static_data = MorphShapeStatic::from_swf_tag(&tag, movie);
MorphShape(GcCell::allocate( MorphShape(GcCell::new(
gc_context, gc_context,
MorphShapeData { MorphShapeData {
base: Default::default(), base: Default::default(),
static_data: Gc::allocate(gc_context, static_data), static_data: Gc::new(gc_context, static_data),
ratio: 0, ratio: 0,
object: None, object: None,
}, },
@ -74,7 +74,7 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -137,11 +137,11 @@ pub struct MovieClipData<'gc> {
impl<'gc> MovieClip<'gc> { impl<'gc> MovieClip<'gc> {
pub fn new(movie: Arc<SwfMovie>, gc_context: MutationContext<'gc, '_>) -> Self { pub fn new(movie: Arc<SwfMovie>, gc_context: MutationContext<'gc, '_>) -> Self {
MovieClip(GcCell::allocate( MovieClip(GcCell::new(
gc_context, gc_context,
MovieClipData { MovieClipData {
base: Default::default(), base: Default::default(),
static_data: Gc::allocate(gc_context, MovieClipStatic::empty(movie, gc_context)), static_data: Gc::new(gc_context, MovieClipStatic::empty(movie, gc_context)),
tag_stream_pos: 0, tag_stream_pos: 0,
current_frame: 0, current_frame: 0,
audio_stream: None, audio_stream: None,
@ -176,11 +176,11 @@ impl<'gc> MovieClip<'gc> {
class: Avm2ClassObject<'gc>, class: Avm2ClassObject<'gc>,
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
) -> Self { ) -> Self {
MovieClip(GcCell::allocate( MovieClip(GcCell::new(
gc_context, gc_context,
MovieClipData { MovieClipData {
base: Default::default(), base: Default::default(),
static_data: Gc::allocate(gc_context, MovieClipStatic::empty(movie, gc_context)), static_data: Gc::new(gc_context, MovieClipStatic::empty(movie, gc_context)),
tag_stream_pos: 0, tag_stream_pos: 0,
current_frame: 0, current_frame: 0,
audio_stream: None, audio_stream: None,
@ -216,11 +216,11 @@ impl<'gc> MovieClip<'gc> {
swf: SwfSlice, swf: SwfSlice,
num_frames: u16, num_frames: u16,
) -> Self { ) -> Self {
MovieClip(GcCell::allocate( MovieClip(GcCell::new(
gc_context, gc_context,
MovieClipData { MovieClipData {
base: Default::default(), base: Default::default(),
static_data: Gc::allocate( static_data: Gc::new(
gc_context, gc_context,
MovieClipStatic::with_data(id, swf, num_frames, None, gc_context), MovieClipStatic::with_data(id, swf, num_frames, None, gc_context),
), ),
@ -275,11 +275,11 @@ impl<'gc> MovieClip<'gc> {
None None
}; };
let mc = MovieClip(GcCell::allocate( let mc = MovieClip(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
MovieClipData { MovieClipData {
base: Default::default(), base: Default::default(),
static_data: Gc::allocate( static_data: Gc::new(
activation.context.gc_context, activation.context.gc_context,
MovieClipStatic::with_data( MovieClipStatic::with_data(
0, 0,
@ -357,7 +357,7 @@ impl<'gc> MovieClip<'gc> {
); );
mc.base.base.reset_for_movie_load(); mc.base.base.reset_for_movie_load();
mc.static_data = Gc::allocate( mc.static_data = Gc::new(
context.gc_context, context.gc_context,
MovieClipStatic::with_data( MovieClipStatic::with_data(
0, 0,
@ -682,8 +682,7 @@ impl<'gc> MovieClip<'gc> {
.unwrap(); .unwrap();
} }
self.0.write(context.gc_context).static_data = self.0.write(context.gc_context).static_data = Gc::new(context.gc_context, static_data);
Gc::allocate(context.gc_context, static_data);
is_finished is_finished
} }
@ -2361,7 +2360,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {
@ -4277,9 +4276,9 @@ impl<'gc> MovieClipStatic<'gc> {
scene_labels_map: HashMap::new(), scene_labels_map: HashMap::new(),
audio_stream_info: None, audio_stream_info: None,
audio_stream_handle: None, audio_stream_handle: None,
exported_name: GcCell::allocate(gc_context, None), exported_name: GcCell::new(gc_context, None),
loader_info, loader_info,
preload_progress: GcCell::allocate(gc_context, Default::default()), preload_progress: GcCell::new(gc_context, Default::default()),
} }
} }
} }

View File

@ -150,7 +150,7 @@ impl<'gc> Stage<'gc> {
fullscreen: bool, fullscreen: bool,
movie: Arc<SwfMovie>, movie: Arc<SwfMovie>,
) -> Stage<'gc> { ) -> Stage<'gc> {
let stage = Self(GcCell::allocate( let stage = Self(GcCell::new(
gc_context, gc_context,
StageData { StageData {
base: Default::default(), base: Default::default(),
@ -732,7 +732,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -41,11 +41,11 @@ impl<'gc> Text<'gc> {
swf: Arc<SwfMovie>, swf: Arc<SwfMovie>,
tag: &swf::Text, tag: &swf::Text,
) -> Self { ) -> Self {
Text(GcCell::allocate( Text(GcCell::new(
context.gc_context, context.gc_context,
TextData { TextData {
base: Default::default(), base: Default::default(),
static_data: gc_arena::Gc::allocate( static_data: gc_arena::Gc::new(
context.gc_context, context.gc_context,
TextStatic { TextStatic {
swf, swf,
@ -81,7 +81,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -130,7 +130,7 @@ impl<'gc> Video<'gc> {
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Self { ) -> Self {
let size = (streamdef.width.into(), streamdef.height.into()); let size = (streamdef.width.into(), streamdef.height.into());
let source = GcCell::allocate( let source = GcCell::new(
mc, mc,
VideoSource::Swf { VideoSource::Swf {
streamdef, streamdef,
@ -138,7 +138,7 @@ impl<'gc> Video<'gc> {
}, },
); );
Video(GcCell::allocate( Video(GcCell::new(
mc, mc,
VideoData { VideoData {
base: Default::default(), base: Default::default(),
@ -160,9 +160,9 @@ impl<'gc> Video<'gc> {
height: i32, height: i32,
object: Option<AvmObject<'gc>>, object: Option<AvmObject<'gc>>,
) -> Self { ) -> Self {
let source = GcCell::allocate(mc, VideoSource::Unconnected); let source = GcCell::new(mc, VideoSource::Unconnected);
Video(GcCell::allocate( Video(GcCell::new(
mc, mc,
VideoData { VideoData {
base: Default::default(), base: Default::default(),
@ -187,7 +187,7 @@ impl<'gc> Video<'gc> {
pub fn attach_netstream(self, context: &mut UpdateContext<'_, 'gc>, stream: NetStream<'gc>) { pub fn attach_netstream(self, context: &mut UpdateContext<'_, 'gc>, stream: NetStream<'gc>) {
let mut video = self.0.write(context.gc_context); let mut video = self.0.write(context.gc_context);
video.source = GcCell::allocate(context.gc_context, VideoSource::NetStream { stream }); video.source = GcCell::new(context.gc_context, VideoSource::NetStream { stream });
video.stream = VideoStream::Uninstantiated(0); video.stream = VideoStream::Uninstantiated(0);
video.keyframes = BTreeSet::new(); video.keyframes = BTreeSet::new();
} }
@ -358,7 +358,7 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
} }
fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> { fn instantiate(&self, gc_context: MutationContext<'gc, '_>) -> DisplayObject<'gc> {
Self(GcCell::allocate(gc_context, self.0.read().clone())).into() Self(GcCell::new(gc_context, self.0.read().clone())).into()
} }
fn as_ptr(&self) -> *const DisplayObjectPtr { fn as_ptr(&self) -> *const DisplayObjectPtr {

View File

@ -12,7 +12,7 @@ pub struct FocusTracker<'gc>(GcCell<'gc, Option<DisplayObject<'gc>>>);
impl<'gc> FocusTracker<'gc> { impl<'gc> FocusTracker<'gc> {
pub fn new(gc_context: MutationContext<'gc, '_>) -> Self { pub fn new(gc_context: MutationContext<'gc, '_>) -> Self {
Self(GcCell::allocate(gc_context, None)) Self(GcCell::new(gc_context, None))
} }
pub fn get(&self) -> Option<DisplayObject<'gc>> { pub fn get(&self) -> Option<DisplayObject<'gc>> {

View File

@ -149,7 +149,7 @@ impl<'gc> Font<'gc> {
fnv::FnvHashMap::default() fnv::FnvHashMap::default()
}; };
Font(Gc::allocate( Font(Gc::new(
gc_context, gc_context,
FontData { FontData {
glyphs, glyphs,

View File

@ -49,7 +49,7 @@ pub struct Avm2ClassRegistry<'gc> {
} }
unsafe impl Collect for Avm2ClassRegistry<'_> { unsafe impl Collect for Avm2ClassRegistry<'_> {
fn trace(&self, cc: gc_arena::CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for (k, _) in self.class_map.iter() { for (k, _) in self.class_map.iter() {
k.trace(cc); k.trace(cc);
} }
@ -394,7 +394,7 @@ pub struct Library<'gc> {
unsafe impl<'gc> gc_arena::Collect for Library<'gc> { unsafe impl<'gc> gc_arena::Collect for Library<'gc> {
#[inline] #[inline]
fn trace(&self, cc: gc_arena::CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for (_, val) in self.movie_libraries.iter() { for (_, val) in self.movie_libraries.iter() {
val.trace(cc); val.trace(cc);
} }

View File

@ -28,7 +28,7 @@ use crate::string::AvmString;
use crate::tag_utils::SwfMovie; use crate::tag_utils::SwfMovie;
use crate::vminterface::Instantiator; use crate::vminterface::Instantiator;
use encoding_rs::UTF_8; use encoding_rs::UTF_8;
use gc_arena::{Collect, CollectionContext, GcCell}; use gc_arena::{Collect, GcCell};
use generational_arena::{Arena, Index}; use generational_arena::{Arena, Index};
use ruffle_render::utils::{determine_jpeg_tag_format, JpegTagFormat}; use ruffle_render::utils::{determine_jpeg_tag_format, JpegTagFormat};
use std::fmt; use std::fmt;
@ -192,7 +192,7 @@ impl From<crate::avm1::Error<'_>> for Error {
pub struct LoadManager<'gc>(Arena<Loader<'gc>>); pub struct LoadManager<'gc>(Arena<Loader<'gc>>);
unsafe impl<'gc> Collect for LoadManager<'gc> { unsafe impl<'gc> Collect for LoadManager<'gc> {
fn trace(&self, cc: CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
for (_, loader) in self.0.iter() { for (_, loader) in self.0.iter() {
loader.trace(cc) loader.trace(cc)
} }
@ -1573,7 +1573,7 @@ impl<'gc> Loader<'gc> {
transparency, transparency,
bitmap.as_colors().map(Color::from).collect(), bitmap.as_colors().map(Color::from).collect(),
); );
let bitmapdata_wrapper = BitmapDataWrapper::new(GcCell::allocate( let bitmapdata_wrapper = BitmapDataWrapper::new(GcCell::new(
activation.context.gc_context, activation.context.gc_context,
bitmap_data, bitmap_data,
)); ));

View File

@ -46,8 +46,7 @@ use crate::stub::StubCollection;
use crate::tag_utils::SwfMovie; use crate::tag_utils::SwfMovie;
use crate::timer::Timers; use crate::timer::Timers;
use crate::vminterface::Instantiator; use crate::vminterface::Instantiator;
use gc_arena::{ArenaParameters, Collect, DynamicRootSet, GcCell}; use gc_arena::{ArenaParameters, Collect, DynamicRootSet, GcCell, Rootable};
use gc_arena::{MutationContext, Rootable};
use instant::Instant; use instant::Instant;
use rand::{rngs::SmallRng, SeedableRng}; use rand::{rngs::SmallRng, SeedableRng};
use ruffle_render::backend::{null::NullRenderer, RenderBackend, ViewportDimensions}; use ruffle_render::backend::{null::NullRenderer, RenderBackend, ViewportDimensions};
@ -212,7 +211,7 @@ impl<'gc> GcRootData<'gc> {
} }
} }
type GcArena = gc_arena::Arena<Rootable![GcRoot<'gc>]>; type GcArena = gc_arena::Arena<Rootable![GcRoot<'_>]>;
type Audio = Box<dyn AudioBackend>; type Audio = Box<dyn AudioBackend>;
type Navigator = Box<dyn NavigatorBackend>; type Navigator = Box<dyn NavigatorBackend>;
@ -1849,7 +1848,7 @@ impl Player {
} }
pub fn load_device_font<'gc>( pub fn load_device_font<'gc>(
gc_context: gc_arena::MutationContext<'gc, '_>, gc_context: &'gc gc_arena::Mutation<'gc>,
renderer: &mut dyn RenderBackend, renderer: &mut dyn RenderBackend,
) -> Font<'gc> { ) -> Font<'gc> {
const DEVICE_FONT_TAG: &[u8] = include_bytes!("../assets/noto-sans-definefont3.bin"); const DEVICE_FONT_TAG: &[u8] = include_bytes!("../assets/noto-sans-definefont3.bin");
@ -2249,7 +2248,7 @@ impl PlayerBuilder {
} }
fn create_gc_root<'gc>( fn create_gc_root<'gc>(
gc_context: MutationContext<'gc, '_>, gc_context: &'gc gc_arena::Mutation<'gc>,
player_version: u8, player_version: u8,
fullscreen: bool, fullscreen: bool,
fake_movie: Arc<SwfMovie>, fake_movie: Arc<SwfMovie>,
@ -2263,8 +2262,8 @@ impl PlayerBuilder {
let dynamic_root = DynamicRootSet::new(gc_context); let dynamic_root = DynamicRootSet::new(gc_context);
GcRoot { GcRoot {
callstack: GcCell::allocate(gc_context, GcCallstack::default()), callstack: GcCell::new(gc_context, GcCallstack::default()),
data: GcCell::allocate( data: GcCell::new(
gc_context, gc_context,
GcRootData { GcRootData {
audio_manager: AudioManager::new(), audio_manager: AudioManager::new(),

View File

@ -186,7 +186,7 @@ pub struct NetStreamData<'gc> {
impl<'gc> NetStream<'gc> { impl<'gc> NetStream<'gc> {
pub fn new(gc_context: MutationContext<'gc, '_>, avm_object: Option<AvmObject<'gc>>) -> Self { pub fn new(gc_context: MutationContext<'gc, '_>, avm_object: Option<AvmObject<'gc>>) -> Self {
Self(GcCell::allocate( Self(GcCell::new(
gc_context, gc_context,
NetStreamData { NetStreamData {
buffer: Arc::new(Mutex::new(Vec::new())), buffer: Arc::new(Mutex::new(Vec::new())),

View File

@ -25,7 +25,7 @@ impl<'gc> AvmString<'gc> {
Source::Owned(s) => s, Source::Owned(s) => s,
Source::Static(s) => { Source::Static(s) => {
let repr = AvmStringRepr::from_raw(s.into(), false); let repr = AvmStringRepr::from_raw(s.into(), false);
Gc::allocate(gc_context, repr) Gc::new(gc_context, repr)
} }
} }
} }
@ -40,7 +40,7 @@ impl<'gc> AvmString<'gc> {
}; };
let repr = AvmStringRepr::from_raw(buf, false); let repr = AvmStringRepr::from_raw(buf, false);
Self { Self {
source: Source::Owned(Gc::allocate(gc_context, repr)), source: Source::Owned(Gc::new(gc_context, repr)),
} }
} }
@ -52,7 +52,7 @@ impl<'gc> AvmString<'gc> {
pub fn new<S: Into<WString>>(gc_context: MutationContext<'gc, '_>, string: S) -> Self { pub fn new<S: Into<WString>>(gc_context: MutationContext<'gc, '_>, string: S) -> Self {
let repr = AvmStringRepr::from_raw(string.into(), false); let repr = AvmStringRepr::from_raw(string.into(), false);
Self { Self {
source: Source::Owned(Gc::allocate(gc_context, repr)), source: Source::Owned(Gc::new(gc_context, repr)),
} }
} }

View File

@ -5,7 +5,7 @@ use std::hash::{BuildHasher, Hash, Hasher};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::DerefMut; use std::ops::DerefMut;
use gc_arena::{Collect, CollectionContext, Gc, GcWeak, MutationContext}; use gc_arena::{Collect, Gc, GcWeak, MutationContext};
use hashbrown::HashSet; use hashbrown::HashSet;
use crate::string::{AvmString, AvmStringRepr, WStr}; use crate::string::{AvmString, AvmStringRepr, WStr};
@ -60,7 +60,7 @@ impl<'gc> AvmStringInterner<'gc> {
fn alloc(mc: MutationContext<'gc, '_>, s: Cow<'_, WStr>) -> Gc<'gc, AvmStringRepr> { fn alloc(mc: MutationContext<'gc, '_>, s: Cow<'_, WStr>) -> Gc<'gc, AvmStringRepr> {
let repr = AvmStringRepr::from_raw(s.into_owned(), true); let repr = AvmStringRepr::from_raw(s.into_owned(), true);
Gc::allocate(mc, repr) Gc::new(mc, repr)
} }
#[must_use] #[must_use]
@ -220,7 +220,7 @@ impl<'gc, T: Hash + 'gc> WeakSet<'gc, T> {
} }
unsafe impl<'gc, T> Collect for WeakSet<'gc, T> { unsafe impl<'gc, T> Collect for WeakSet<'gc, T> {
fn trace(&self, cc: CollectionContext) { fn trace(&self, cc: &gc_arena::Collection) {
// Prune entries known to be dead. // Prune entries known to be dead.
// Safe, as we never pick up new GC pointers from outside this allocation. // Safe, as we never pick up new GC pointers from outside this allocation.
let mut guard = unsafe { self.table.steal_for_trace() }; let mut guard = unsafe { self.table.steal_for_trace() };
@ -256,12 +256,12 @@ impl<'gc, T> CollectCell<'gc, T> {
/// SAFETY: must be called inside a `Collect::trace` function. /// SAFETY: must be called inside a `Collect::trace` function.
/// ///
/// An alternative would be to require a `CollectionContext` argument, but this is /// An alternative would be to require a `&gc_arena::Collection` argument, but this is
/// still unsound in presence of nested arenas (preventing this would require a `'gc` /// still unsound in presence of nested arenas (preventing this would require a `'gc`
/// lifetime on `CollectionContext` and `Collect`): /// lifetime on `&gc_arena::Collection` and `Collect`):
/// ///
/// ```rs,ignore /// ```rs,ignore
/// fn trace(&self, cc: CollectionContext) { /// fn trace(&self, cc: &gc_arena::Collection) {
/// rootless_arena(|mc| { /// rootless_arena(|mc| {
/// let cell = CollectCell::<i32>::default(); /// let cell = CollectCell::<i32>::default();
/// let borrow: &i32 = dbg!(cell.as_ref(mc)); // 0 /// let borrow: &i32 = dbg!(cell.as_ref(mc)); // 0

Some files were not shown because too many files have changed in this diff Show More