Skip to content

Commit

Permalink
avm2: Annotate all object *Data structs with #[repr(C)]
Browse files Browse the repository at this point in the history
This ensures that the ScriptObjectData common to every *Data is always at the same offset, which results in better codegen for TObject methods
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Aug 1, 2024
1 parent c54de07 commit 6c233ed
Show file tree
Hide file tree
Showing 38 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/avm2/object/array_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl fmt::Debug for ArrayObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct ArrayObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/bitmapdata_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl fmt::Debug for BitmapDataObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct BitmapDataObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/bytearray_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl fmt::Debug for ByteArrayObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct ByteArrayObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/class_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct ClassObjectWeak<'gc>(pub GcWeak<'gc, ClassObjectData<'gc>>);

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct ClassObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/context3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ impl<'gc> Context3DObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct Context3DData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/date_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl<'gc> DateObject<'gc> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct DateObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/dictionary_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl fmt::Debug for DictionaryObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct DictionaryObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/dispatch_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl fmt::Debug for DispatchObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct DispatchObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/domain_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl fmt::Debug for DomainObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct DomainObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/error_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl fmt::Debug for ErrorObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct ErrorObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/event_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct EventObjectWeak<'gc>(pub GcWeak<'gc, EventObjectData<'gc>>);

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct EventObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/file_reference_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub enum FileReference {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct FileReferenceObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/font_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl<'gc> TObject<'gc> for FontObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct FontObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/function_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl fmt::Debug for FunctionObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct FunctionObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/index_buffer_3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl<'gc> IndexBuffer3DObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct IndexBuffer3DObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/loaderinfo_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl fmt::Debug for LoaderInfoObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct LoaderInfoObjectData<'gc> {
/// All normal script data.
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/local_connection_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl fmt::Debug for LocalConnectionObject<'_> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct LocalConnectionObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/namespace_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl fmt::Debug for NamespaceObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct NamespaceObjectData<'gc> {
/// All normal script data.
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/net_connection_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct NetConnectionObjectWeak<'gc>(pub GcWeak<'gc, NetConnectionObjectData<

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct NetConnectionObjectData<'gc> {
base: RefLock<ScriptObjectData<'gc>>,
#[collect(require_static)]
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/netstream_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct NetStreamObjectWeak<'gc>(pub GcWeak<'gc, NetStreamObjectData<'gc>>);

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct NetStreamObjectData<'gc> {
base: RefLock<ScriptObjectData<'gc>>,
ns: NetStream<'gc>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/primitive_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl fmt::Debug for PrimitiveObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct PrimitiveObjectData<'gc> {
/// All normal script data.
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/program_3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl<'gc> Program3DObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct Program3DObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/proxy_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl fmt::Debug for ProxyObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct ProxyObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/qname_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl fmt::Debug for QNameObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct QNameObjectData<'gc> {
/// All normal script data.
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/regexp_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl fmt::Debug for RegExpObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct RegExpObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/responder_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl<'gc> ResponderObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct ResponderObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/shader_data_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl<'gc> ShaderDataObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct ShaderDataObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/socket_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl_read!(read_float 4; f32, read_double 8; f64, read_int 4; i32, read_unsigned

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct SocketObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/sound_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl fmt::Debug for SoundObject<'_> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct SoundObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/soundchannel_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl fmt::Debug for SoundChannelObject<'_> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct SoundChannelObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/stage3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl<'gc> Stage3DObject<'gc> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct Stage3DObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/stage_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct StageObjectWeak<'gc>(pub GcWeak<'gc, StageObjectData<'gc>>);

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct StageObjectData<'gc> {
/// The base data common to all AVM2 objects.
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/textformat_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl fmt::Debug for TextFormatObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct TextFormatObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/texture_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl<'gc> TextureObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct TextureObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/vector_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl fmt::Debug for VectorObject<'_> {

#[derive(Collect, Clone)]
#[collect(no_drop)]
#[repr(C)]
pub struct VectorObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/vertex_buffer_3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl<'gc> VertexBuffer3DObject<'gc> {

#[derive(Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct VertexBuffer3DObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/xml_list_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ impl<'gc> XmlListObject<'gc> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct XmlListObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down
1 change: 1 addition & 0 deletions core/src/avm2/object/xml_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl fmt::Debug for XmlObject<'_> {

#[derive(Clone, Collect)]
#[collect(no_drop)]
#[repr(C)]
pub struct XmlObjectData<'gc> {
/// Base script object
base: RefLock<ScriptObjectData<'gc>>,
Expand Down

1 comment on commit 6c233ed

@evilpie
Copy link
Collaborator

@evilpie evilpie commented on 6c233ed Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way we could assert that this optimization is happening?

Please sign in to comment.