Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use enum for frametype not v table #112166

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

davidwrighton
Copy link
Member

@davidwrighton davidwrighton commented Feb 5, 2025

Frames are currently identified by VTable, which is convenient for writing C++ code, but less so for writing asm, or out of process inspection. This change changes that to a FrameIdentifier enum, make the polymorphic dispatch occur using if statements, and removes GS cookies for Frame's as we no longer need to protect the vtable.

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

src/coreclr/vm/frames.h Outdated Show resolved Hide resolved
@davidwrighton davidwrighton changed the title [DRAFT] Use enum for frametype not v table Use enum for frametype not v table Feb 6, 2025
@davidwrighton davidwrighton marked this pull request as ready for review February 6, 2025 23:01
src/coreclr/vm/FrameTypes.h Outdated Show resolved Hide resolved
src/coreclr/vm/FrameTypes.h Outdated Show resolved Hide resolved
src/coreclr/vm/frames.cpp Outdated Show resolved Hide resolved
src/coreclr/vm/frames.h Outdated Show resolved Hide resolved
src/coreclr/vm/arm/ehhelpers.S Show resolved Hide resolved
src/coreclr/vm/comtoclrcall.cpp Show resolved Hide resolved
src/coreclr/vm/frames.h Outdated Show resolved Hide resolved
src/coreclr/vm/frames.h Outdated Show resolved Hide resolved
src/coreclr/vm/frames.cpp Outdated Show resolved Hide resolved
src/coreclr/vm/frames.cpp Outdated Show resolved Hide resolved
src/coreclr/vm/amd64/redirectedhandledjitcase.S Outdated Show resolved Hide resolved
src/coreclr/vm/amd64/ComCallPreStub.asm Outdated Show resolved Hide resolved
src/coreclr/vm/amd64/GenericComCallStubs.asm Outdated Show resolved Hide resolved
src/coreclr/vm/arm64/asmhelpers.S Outdated Show resolved Hide resolved
src/coreclr/vm/riscv64/asmhelpers.S Show resolved Hide resolved
src/coreclr/vm/frames.cpp Outdated Show resolved Hide resolved
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM otherwise. Thank you!

@@ -269,77 +512,30 @@ void Frame::LogFrameChain(

#ifndef DACCESS_COMPILE

// This hashtable contains the vtable value of every Frame type.
static PtrHashMap* s_pFrameVTables = NULL;

// static
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// static

@@ -198,19 +445,19 @@ const size_t FRAME_TYPES_COUNT =
//-----------------------------------------------------------------------
// Implementation of the global table of names. On the DAC side, just the global pointer.
// On the runtime side, the array of names.
#define FRAME_TYPE_NAME(x) {x::GetMethodFrameVPtr(), #x} ,
#define FRAME_TYPE_NAME(x) {FrameIdentifier::x, #x} ,
Copy link
Member

Choose a reason for hiding this comment

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

FrameIdentifier does not need to be in the table anymore. We can just index into the table.

@@ -198,19 +445,19 @@ const size_t FRAME_TYPES_COUNT =
//-----------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

FRAME_TYPES_COUNT above can be deleted

} // void Frame::Init()

#endif // DACCESS_COMPILE

// Returns true if the Frame's VTablePtr is valid

// static
bool Frame::HasValidVTablePtr(Frame * pFrame)
bool Frame::HasFrameIdentifier(Frame * pFrame)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool Frame::HasFrameIdentifier(Frame * pFrame)
bool Frame::HasValidFrameIdentifier(Frame * pFrame)

?

#include "frames.h"

LIMITED_METHOD_CONTRACT;
_frameIdentifier = frameIdentifier;
} // void Frame::Init()

#endif // DACCESS_COMPILE

// Returns true if the Frame's VTablePtr is valid
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Returns true if the Frame's VTablePtr is valid
// Returns true if the Frame has a valid FrameIdentifier


void Frame::GcScanRoots(promote_func *fn, ScanContext* sc)
{
switch (this->GetFrameIdentifier())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
switch (this->GetFrameIdentifier())
switch (GetFrameIdentifier())

Nit: this-> should not be needed

FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE();
return NULL;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
}

Comment on lines 83 to 84

#endif
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#endif
#endif

}
}


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

@max-charlamb
Copy link
Contributor

Resolves #111875

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants