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

Add support for delegate GDV and method-based vtable GDV #68703

Merged
merged 73 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
26ad0a8
Add support for storing method handle histograms in profiles
jakobbotsch Apr 12, 2022
6959656
Fix R2R reader for PGO schema entries without data
jakobbotsch Apr 12, 2022
3245442
Support instrumenting method handles for delegates and vtable calls
jakobbotsch Apr 13, 2022
2cbe83f
Handle static methods and also move fcall handling
jakobbotsch Apr 14, 2022
5b31bee
Fix writing out methods
jakobbotsch Apr 14, 2022
7596146
Remove an unnecessary check
jakobbotsch Apr 15, 2022
a1c3a7e
Merge remote-tracking branch 'upstream/main' into method-handle-histo…
jakobbotsch Apr 15, 2022
5114f2c
Fix build and some logic inversions
jakobbotsch Apr 15, 2022
decb84d
Bump R2R minor version and JIT-EE GUID
jakobbotsch Apr 18, 2022
baf3662
Merge remote-tracking branch 'upstream/main' into method-handle-histo…
jakobbotsch Apr 18, 2022
8703a49
Merge remote-tracking branch 'upstream/main' into method-handle-instr…
jakobbotsch Apr 25, 2022
7b1714a
Merge branch 'method-handle-histograms' into method-handle-instrument…
jakobbotsch Apr 25, 2022
7910dba
Merge remote-tracking branch 'origin/method-handle-histograms' into m…
jakobbotsch Apr 25, 2022
01353ed
Fix after merge
jakobbotsch Apr 25, 2022
a3b04a3
Change to static_assert and remove a comment
jakobbotsch Apr 28, 2022
8dc5c6a
Foo
jakobbotsch Apr 29, 2022
da05869
Few cleanups
jakobbotsch Apr 29, 2022
af7232b
Better comment
jakobbotsch Apr 29, 2022
12d1d86
Run jit-format
jakobbotsch Apr 29, 2022
5a09741
More cleanup
jakobbotsch Apr 29, 2022
cd07709
Do not null check delegate GDV calls
jakobbotsch Apr 29, 2022
8456a11
Avoid devirt for probed calls
jakobbotsch Apr 29, 2022
e401711
Cleanup and format
jakobbotsch Apr 30, 2022
7bc4374
Fix 32-bit build
jakobbotsch Apr 30, 2022
5ee82e2
Reuse target from temp in cold call
jakobbotsch May 2, 2022
7250abe
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch May 4, 2022
98671fc
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch May 17, 2022
b175511
Fix build
jakobbotsch May 18, 2022
95af330
Add MethodProfiling PGO scenarios
jakobbotsch May 18, 2022
fa01664
Support randomized GDVs for method handle histograms
jakobbotsch May 18, 2022
7a5386e
Run jit-format
jakobbotsch May 18, 2022
f1bb0da
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch May 23, 2022
edd2db7
Fix an asertion failure
jakobbotsch May 23, 2022
e4093c9
Make sure we only log in DEBUG
jakobbotsch May 23, 2022
2c1ebe3
Avoid GDV for static calls
jakobbotsch May 23, 2022
fbbac89
Fix interaction with chained GDV
jakobbotsch May 23, 2022
d622b64
Fix cast helper probes
jakobbotsch May 23, 2022
8ce47f8
Run jit-format
jakobbotsch May 23, 2022
39ac90a
Pick random GDV after logging histogram
jakobbotsch May 24, 2022
0ab00ae
Fix GDV for vtable calls on System.Delegate
jakobbotsch May 24, 2022
93efde4
Mark early expanded vtable calls as such
jakobbotsch May 24, 2022
8a7ec55
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch May 24, 2022
4b44c8d
Pull reservoir index calculation up in profile helpers
jakobbotsch May 24, 2022
c30a951
Record only delegate cases that we can actually GDV for
jakobbotsch May 25, 2022
531ac9d
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch May 27, 2022
f6e0827
Fix pesky x86 GTF_CALL_POP_ARGS bug
jakobbotsch May 27, 2022
27aff20
Exclude dynamic methods as well as methods in collectible ALCs
jakobbotsch May 27, 2022
8444cee
Remove excessive JIT-EE calls for debug logging in non-verbose
jakobbotsch May 27, 2022
cbc494b
Increase some timeouts to get a full test run
jakobbotsch Jun 2, 2022
6beca6a
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch Jun 2, 2022
0937004
Add missing helper in CorInfoHelpFunc.cs
jakobbotsch Jun 2, 2022
56019b7
Fix conflict resolution and add profiling helpers on crossgen2 side
jakobbotsch Jun 2, 2022
1bd5203
Lower likelihood threshold to 30%, like vtable calls
jakobbotsch Jun 4, 2022
924d0b1
Revert "Increase some timeouts to get a full test run"
jakobbotsch Jun 7, 2022
dfbcc86
Add signature compatibility check
jakobbotsch Jun 7, 2022
1f7a1be
Increase some timeouts to get a full test run"
jakobbotsch Jun 7, 2022
b0a5c24
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch Jun 7, 2022
0363bf2
Fix after merge
jakobbotsch Jun 7, 2022
4201bf0
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch Jun 8, 2022
ed1a073
Separate delegate and vtable profiling
jakobbotsch Jun 8, 2022
f0010e6
Set gtTargetHandle for GDV function addrs
jakobbotsch Jun 8, 2022
2b2781d
Fix build
jakobbotsch Jun 9, 2022
993c4c2
Disable method GDV for R2R
jakobbotsch Jun 9, 2022
54b5a0b
Make extra SPMI queries for GDV debugging output purposes
jakobbotsch Jun 10, 2022
901d4d1
Reorder static and signature check
jakobbotsch Jun 10, 2022
12f3654
Misc changes
jakobbotsch Jun 10, 2022
6a9fbfe
Enable delegate profiling by default
jakobbotsch Jun 10, 2022
c46ebaa
Fix newlines when printing test profile
jakobbotsch Jun 14, 2022
2fad8de
Merge branch 'main' of github.com:dotnet/runtime into method-handle-i…
jakobbotsch Jun 15, 2022
60f140e
Add GetLikelyMethod and hook it up through R2R
jakobbotsch Jun 15, 2022
1bfc4d8
Update JIT-EE GUID
jakobbotsch Jun 15, 2022
55cdf81
Address some feedback, remove some unneeded stuff
jakobbotsch Jun 16, 2022
55c9d54
Address some more feedback
jakobbotsch Jun 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions eng/pipelines/common/templates/runtimes/run-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ jobs:
timeoutInMinutes: 300
${{ else }}:
timeoutInMinutes: 200
${{ if in(parameters.testGroup, 'outerloop', 'jit-experimental', 'pgo', 'jit-cfg') }}:
${{ if in(parameters.testGroup, 'outerloop', 'jit-experimental', 'jit-cfg') }}:
timeoutInMinutes: 270
${{ if in(parameters.testGroup, 'gc-longrunning', 'gc-simulator') }}:
timeoutInMinutes: 480
${{ if in(parameters.testGroup, 'jitstress', 'jitstress-isas-arm', 'jitstressregs-x86', 'jitstressregs', 'jitstress2-jitstressregs', 'gcstress0x3-gcstress0xc', 'ilasm') }}:
timeoutInMinutes: 390
${{ if in(parameters.testGroup, 'gcstress-extra', 'r2r-extra', 'clrinterpreter') }}:
${{ if in(parameters.testGroup, 'gcstress-extra', 'r2r-extra', 'clrinterpreter', 'pgo') }}:
timeoutInMinutes: 510
Comment on lines -236 to 237
Copy link
Member Author

Choose a reason for hiding this comment

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

I am thinking to keep these timeout changes until we get around to splitting up the jobs, it fixes the problem we are seeing with timeouts and I have not seen any issues with making the timeout this high.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good.

${{ if eq(parameters.testGroup, 'jitstress-isas-x86') }}:
timeoutInMinutes: 960
Expand Down Expand Up @@ -397,7 +397,7 @@ jobs:
${{ if eq(parameters.runtimeFlavor, 'mono') }}:
# tiered compilation isn't done on mono yet
scenarios:
- normal
- normal
${{ elseif eq(variables['Build.Reason'], 'PullRequest') }}:
scenarios:
- no_tiered_compilation
Expand Down Expand Up @@ -545,7 +545,9 @@ jobs:
- defaultpgo
- dynamicpgo
- fullpgo
- fullpgo_methodprofiling
- fullpgo_random_gdv
- fullpgo_random_gdv_methodprofiling_only
- fullpgo_random_edge
- fullpgo_random_gdv_edge
${{ if in(parameters.testGroup, 'gc-longrunning') }}:
Expand All @@ -568,7 +570,6 @@ jobs:
- jitelthookenabled_tiered
${{ if in(parameters.testGroup, 'jit-experimental') }}:
scenarios:
- jitosr
- jitosr_stress
- jitosr_pgo
- jitosr_stress_random
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/coreclr/libraries-pgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
helixQueueGroup: libraries
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
jobParameters:
timeoutInMinutes: 150
timeoutInMinutes: 600
testScope: innerloop
liveRuntimeBuildConfig: checked
dependsOnTestBuildConfiguration: Release
Expand Down
3 changes: 2 additions & 1 deletion eng/pipelines/libraries/run-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ jobs:
- defaultpgo
- dynamicpgo
- fullpgo
- fullpgo_methodprofiling
- fullpgo_random_gdv
- fullpgo_random_gdv_methodprofiling_only
- fullpgo_random_edge
- fullpgo_random_gdv_edge
- jitosr
- jitosr_stress
- jitosr_stress_random
- jitosr_pgo
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,14 @@ enum CorInfoHelpFunc
CORINFO_HELP_STACK_PROBE, // Probes each page of the allocated stack frame

CORINFO_HELP_PATCHPOINT, // Notify runtime that code has reached a patchpoint
CORINFO_HELP_PARTIAL_COMPILATION_PATCHPOINT, // Notify runtime that code has reached a part of the method that wasn't originally jitted.

CORINFO_HELP_CLASSPROFILE32, // Update 32-bit class profile for a call site
CORINFO_HELP_CLASSPROFILE64, // Update 64-bit class profile for a call site
CORINFO_HELP_PARTIAL_COMPILATION_PATCHPOINT, // Notify runtime that code has reached a part of the method that wasn't originally jitted.
CORINFO_HELP_DELEGATEPROFILE32, // Update 32-bit method profile for a delegate call site
CORINFO_HELP_DELEGATEPROFILE64, // Update 64-bit method profile for a delegate call site
CORINFO_HELP_VTABLEPROFILE32, // Update 32-bit method profile for a vtable call site
CORINFO_HELP_VTABLEPROFILE64, // Update 64-bit method profile for a vtable call site

CORINFO_HELP_VALIDATE_INDIRECT_CALL, // CFG: Validate function pointer
CORINFO_HELP_DISPATCH_INDIRECT_CALL, // CFG: Validate and dispatch to pointer
Expand Down
21 changes: 12 additions & 9 deletions src/coreclr/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,34 +330,36 @@ class ICorJitInfo : public ICorDynamicInfo

// Data structure for a single class probe using 32-bit count.
//
// CLASS_FLAG and INTERFACE_FLAG are placed into the Other field in the schema
// CLASS_FLAG, INTERFACE_FLAG and DELEGATE_FLAG are placed into the Other field in the schema.
// If CLASS_FLAG is set the handle table consists of type handles, and otherwise method handles.
//
// Count is the number of times a call was made at that call site.
//
// SIZE is the number of entries in the table.
//
// SAMPLE_INTERVAL must be >= SIZE. SAMPLE_INTERVAL / SIZE
// gives the average number of calls between table updates.
//
struct ClassProfile32
//
struct HandleHistogram32
{
enum
{
SIZE = 8,
SAMPLE_INTERVAL = 32,
CLASS_FLAG = 0x80000000,
INTERFACE_FLAG = 0x40000000,
OFFSET_MASK = 0x3FFFFFFF
DELEGATE_FLAG = 0x20000000,
OFFSET_MASK = 0x0FFFFFFF
};

uint32_t Count;
CORINFO_CLASS_HANDLE ClassTable[SIZE];
void* HandleTable[SIZE];
};

struct ClassProfile64
struct HandleHistogram64
{
uint64_t Count;
CORINFO_CLASS_HANDLE ClassTable[ClassProfile32::SIZE];
void* HandleTable[HandleHistogram32::SIZE];
};

enum class PgoInstrumentationKind
Expand Down Expand Up @@ -387,7 +389,7 @@ class ICorJitInfo : public ICorDynamicInfo
Done = None, // All instrumentation schemas must end with a record which is "Done"
BasicBlockIntCount = (DescriptorMin * 1) | FourByte, // basic block counter using unsigned 4 byte int
BasicBlockLongCount = (DescriptorMin * 1) | EightByte, // basic block counter using unsigned 8 byte int
HandleHistogramIntCount = (DescriptorMin * 2) | FourByte | AlignPointer, // 4 byte counter that is part of a type histogram. Aligned to match ClassProfile32's alignment.
HandleHistogramIntCount = (DescriptorMin * 2) | FourByte | AlignPointer, // 4 byte counter that is part of a type histogram. Aligned to match HandleHistogram32's alignment.
HandleHistogramLongCount = (DescriptorMin * 2) | EightByte, // 8 byte counter that is part of a type histogram
HandleHistogramTypes = (DescriptorMin * 3) | TypeHandle, // Histogram of type handles
HandleHistogramMethods = (DescriptorMin * 3) | MethodHandle, // Histogram of method handles
Expand All @@ -396,6 +398,7 @@ class ICorJitInfo : public ICorDynamicInfo
EdgeIntCount = (DescriptorMin * 6) | FourByte, // edge counter using unsigned 4 byte int
EdgeLongCount = (DescriptorMin * 6) | EightByte, // edge counter using unsigned 8 byte int
GetLikelyClass = (DescriptorMin * 7) | TypeHandle, // Compressed get likely class data
GetLikelyMethod = (DescriptorMin * 7) | MethodHandle, // Compressed get likely method data
};

struct PgoInstrumentationSchema
Expand All @@ -418,7 +421,7 @@ class ICorJitInfo : public ICorDynamicInfo
Sampling= 6, // PGO data derived from sampling
};

#define DEFAULT_UNKNOWN_TYPEHANDLE 1
#define DEFAULT_UNKNOWN_HANDLE 1
#define UNKNOWN_HANDLE_MIN 1
#define UNKNOWN_HANDLE_MAX 33

Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* af5b6632-6fbe-4a2e-82d6-24487a138e4a */
0xaf5b6632,
0x6fbe,
0x4a2e,
{0x82, 0xd6, 0x24, 0x48, 0x7a, 0x13, 0x8e, 0x4a}
constexpr GUID JITEEVersionIdentifier = { /* f2faa5fc-a1ec-4244-aebb-5597bfd7153a */
0xf2faa5fc,
0xa1ec,
0x4244,
{0xae, 0xbb, 0x55, 0x97, 0xbf, 0xd7, 0x15, 0x3a}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,14 @@
#endif

JITHELPER(CORINFO_HELP_PATCHPOINT, JIT_Patchpoint, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_PARTIAL_COMPILATION_PATCHPOINT, JIT_PartialCompilationPatchpoint, CORINFO_HELP_SIG_REG_ONLY)

JITHELPER(CORINFO_HELP_CLASSPROFILE32, JIT_ClassProfile32, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_CLASSPROFILE64, JIT_ClassProfile64, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_PARTIAL_COMPILATION_PATCHPOINT, JIT_PartialCompilationPatchpoint, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_DELEGATEPROFILE32, JIT_DelegateProfile32, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_DELEGATEPROFILE64, JIT_DelegateProfile64, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_VTABLEPROFILE32, JIT_VTableProfile32, CORINFO_HELP_SIG_4_STACK)
JITHELPER(CORINFO_HELP_VTABLEPROFILE64, JIT_VTableProfile64, CORINFO_HELP_SIG_4_STACK)

#if defined(TARGET_AMD64) || defined(TARGET_ARM64)
JITHELPER(CORINFO_HELP_VALIDATE_INDIRECT_CALL, JIT_ValidateIndirectCall, CORINFO_HELP_SIG_REG_ONLY)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// Keep these in sync with src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs
#define READYTORUN_MAJOR_VERSION 0x0006
#define READYTORUN_MINOR_VERSION 0x0001
#define READYTORUN_MINOR_VERSION 0x0002

#define MINIMUM_READYTORUN_MAJOR_VERSION 0x006

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/ClrJit.PAL.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
getJit
jitStartup
getLikelyClasses
getLikelyMethods
jitBuildString
1 change: 1 addition & 0 deletions src/coreclr/jit/ClrJit.exports
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ EXPORTS
getJit
jitStartup
getLikelyClasses
getLikelyMethods
jitBuildString
52 changes: 26 additions & 26 deletions src/coreclr/jit/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,32 +526,32 @@ enum BasicBlockFlags : unsigned __int64

#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)

BBF_BACKWARD_JUMP = MAKE_BBFLAG(24), // BB is surrounded by a backward jump/switch arc
BBF_RETLESS_CALL = MAKE_BBFLAG(25), // BBJ_CALLFINALLY that will never return (and therefore, won't need a paired
// BBJ_ALWAYS); see isBBCallAlwaysPair().
BBF_LOOP_PREHEADER = MAKE_BBFLAG(26), // BB is a loop preheader block
BBF_COLD = MAKE_BBFLAG(27), // BB is cold

BBF_PROF_WEIGHT = MAKE_BBFLAG(28), // BB weight is computed from profile data
BBF_IS_LIR = MAKE_BBFLAG(29), // Set if the basic block contains LIR (as opposed to HIR)
BBF_KEEP_BBJ_ALWAYS = MAKE_BBFLAG(30), // A special BBJ_ALWAYS block, used by EH code generation. Keep the jump kind
// as BBJ_ALWAYS. Used for the paired BBJ_ALWAYS block following the
// BBJ_CALLFINALLY block, as well as, on x86, the final step block out of a
// finally.
BBF_CLONED_FINALLY_BEGIN = MAKE_BBFLAG(31), // First block of a cloned finally region

BBF_CLONED_FINALLY_END = MAKE_BBFLAG(32), // Last block of a cloned finally region
BBF_HAS_CALL = MAKE_BBFLAG(33), // BB contains a call
BBF_BACKWARD_JUMP = MAKE_BBFLAG(24), // BB is surrounded by a backward jump/switch arc
BBF_RETLESS_CALL = MAKE_BBFLAG(25), // BBJ_CALLFINALLY that will never return (and therefore, won't need a paired
// BBJ_ALWAYS); see isBBCallAlwaysPair().
BBF_LOOP_PREHEADER = MAKE_BBFLAG(26), // BB is a loop preheader block
BBF_COLD = MAKE_BBFLAG(27), // BB is cold

BBF_PROF_WEIGHT = MAKE_BBFLAG(28), // BB weight is computed from profile data
BBF_IS_LIR = MAKE_BBFLAG(29), // Set if the basic block contains LIR (as opposed to HIR)
BBF_KEEP_BBJ_ALWAYS = MAKE_BBFLAG(30), // A special BBJ_ALWAYS block, used by EH code generation. Keep the jump kind
// as BBJ_ALWAYS. Used for the paired BBJ_ALWAYS block following the
// BBJ_CALLFINALLY block, as well as, on x86, the final step block out of a
// finally.
BBF_CLONED_FINALLY_BEGIN = MAKE_BBFLAG(31), // First block of a cloned finally region

BBF_CLONED_FINALLY_END = MAKE_BBFLAG(32), // Last block of a cloned finally region
BBF_HAS_CALL = MAKE_BBFLAG(33), // BB contains a call
BBF_DOMINATED_BY_EXCEPTIONAL_ENTRY = MAKE_BBFLAG(34), // Block is dominated by exceptional entry.
BBF_BACKWARD_JUMP_TARGET = MAKE_BBFLAG(35), // Block is a target of a backward jump
BBF_BACKWARD_JUMP_TARGET = MAKE_BBFLAG(35), // Block is a target of a backward jump

BBF_PATCHPOINT = MAKE_BBFLAG(36), // Block is a patchpoint
BBF_HAS_CLASS_PROFILE = MAKE_BBFLAG(37), // BB contains a call needing a class profile
BBF_PARTIAL_COMPILATION_PATCHPOINT = MAKE_BBFLAG(38), // Block is a partial compilation patchpoint
BBF_HAS_ALIGN = MAKE_BBFLAG(39), // BB ends with 'align' instruction
BBF_TAILCALL_SUCCESSOR = MAKE_BBFLAG(40), // BB has pred that has potential tail call
BBF_PATCHPOINT = MAKE_BBFLAG(36), // Block is a patchpoint
BBF_HAS_HISTOGRAM_PROFILE = MAKE_BBFLAG(37), // BB contains a call needing a histogram profile
BBF_PARTIAL_COMPILATION_PATCHPOINT = MAKE_BBFLAG(38), // Block is a partial compilation patchpoint
BBF_HAS_ALIGN = MAKE_BBFLAG(39), // BB ends with 'align' instruction
BBF_TAILCALL_SUCCESSOR = MAKE_BBFLAG(40), // BB has pred that has potential tail call

BBF_BACKWARD_JUMP_SOURCE = MAKE_BBFLAG(41), // Block is a source of a backward jump
BBF_BACKWARD_JUMP_SOURCE = MAKE_BBFLAG(41), // Block is a source of a backward jump

// The following are sets of flags.

Expand Down Expand Up @@ -582,7 +582,7 @@ enum BasicBlockFlags : unsigned __int64
// TODO: Should BBF_RUN_RARELY be added to BBF_SPLIT_GAINED ?

BBF_SPLIT_GAINED = BBF_DONT_REMOVE | BBF_HAS_JMP | BBF_BACKWARD_JUMP | BBF_HAS_IDX_LEN | BBF_HAS_NEWARRAY | BBF_PROF_WEIGHT | \
BBF_HAS_NEWOBJ | BBF_KEEP_BBJ_ALWAYS | BBF_CLONED_FINALLY_END | BBF_HAS_NULLCHECK | BBF_HAS_CLASS_PROFILE,
BBF_HAS_NEWOBJ | BBF_KEEP_BBJ_ALWAYS | BBF_CLONED_FINALLY_END | BBF_HAS_NULLCHECK | BBF_HAS_HISTOGRAM_PROFILE,
};

inline constexpr BasicBlockFlags operator ~(BasicBlockFlags a)
Expand Down Expand Up @@ -918,8 +918,8 @@ struct BasicBlock : private LIR::Range
};

union {
unsigned bbStkTempsOut; // base# for output stack temps
int bbClassSchemaIndex; // schema index for class instrumentation
unsigned bbStkTempsOut; // base# for output stack temps
int bbHistogramSchemaIndex; // schema index for histogram instrumentation
};

#define MAX_XCPTN_INDEX (USHRT_MAX - 1)
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6384,10 +6384,10 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE classPtr,
compHndBBtabCount = 0;
compHndBBtabAllocCount = 0;

info.compNativeCodeSize = 0;
info.compTotalHotCodeSize = 0;
info.compTotalColdCodeSize = 0;
info.compClassProbeCount = 0;
info.compNativeCodeSize = 0;
info.compTotalHotCodeSize = 0;
info.compTotalColdCodeSize = 0;
info.compHandleHistogramProbeCount = 0;

compHasBackwardJump = false;
compHasBackwardJumpInHandler = false;
Expand Down
42 changes: 33 additions & 9 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ class Compiler
friend class MorphInitBlockHelper;
friend class MorphCopyBlockHelper;
friend class CallArgs;
friend class IndirectCallTransformer;

#ifdef FEATURE_HW_INTRINSICS
friend struct HWIntrinsicInfo;
Expand Down Expand Up @@ -3537,6 +3538,18 @@ class Compiler
bool isExplicitTailCall,
IL_OFFSET ilOffset = BAD_IL_OFFSET);

bool impConsiderCallProbe(GenTreeCall* call, IL_OFFSET ilOffset);

enum class GDVProbeType
{
None,
ClassProfile,
MethodProfile,
MethodAndClassProfile,
};

GDVProbeType compClassifyGDVProbeType(GenTreeCall* call);

//=========================================================================
// PROTECTED
//=========================================================================
Expand Down Expand Up @@ -5425,19 +5438,21 @@ class Compiler
bool fgGetProfileWeightForBasicBlock(IL_OFFSET offset, weight_t* weight);

Instrumentor* fgCountInstrumentor;
Instrumentor* fgClassInstrumentor;
Instrumentor* fgHistogramInstrumentor;

PhaseStatus fgPrepareToInstrumentMethod();
PhaseStatus fgInstrumentMethod();
PhaseStatus fgIncorporateProfileData();
void fgIncorporateBlockCounts();
void fgIncorporateEdgeCounts();

CORINFO_CLASS_HANDLE getRandomClass(ICorJitInfo::PgoInstrumentationSchema* schema,
UINT32 countSchemaItems,
BYTE* pInstrumentationData,
int32_t ilOffset,
CLRRandom* random);
void getRandomGDV(ICorJitInfo::PgoInstrumentationSchema* schema,
UINT32 countSchemaItems,
BYTE* pInstrumentationData,
int32_t ilOffset,
CLRRandom* random,
CORINFO_CLASS_HANDLE* classGuess,
CORINFO_METHOD_HANDLE* methodGuess);

public:
const char* fgPgoFailReason;
Expand Down Expand Up @@ -5677,6 +5692,7 @@ class Compiler
Statement* paramAssignmentInsertionPoint);
GenTree* fgMorphCall(GenTreeCall* call);
GenTree* fgExpandVirtualVtableCallTarget(GenTreeCall* call);

void fgMorphCallInline(GenTreeCall* call, InlineResult* result);
void fgMorphCallInlineHelper(GenTreeCall* call, InlineResult* result, InlineContext** createdContext);
#if DEBUG
Expand Down Expand Up @@ -6795,13 +6811,21 @@ class Compiler
optMethodFlags |= OMF_HAS_GUARDEDDEVIRT;
}

void pickGDV(GenTreeCall* call,
IL_OFFSET ilOffset,
bool isInterface,
CORINFO_CLASS_HANDLE* classGuess,
CORINFO_METHOD_HANDLE* methodGuess,
unsigned* likelihood);

void considerGuardedDevirtualization(GenTreeCall* call,
IL_OFFSET ilOffset,
bool isInterface,
CORINFO_METHOD_HANDLE baseMethod,
CORINFO_CLASS_HANDLE baseClass,
CORINFO_CONTEXT_HANDLE* pContextHandle DEBUGARG(CORINFO_CLASS_HANDLE objClass)
DEBUGARG(const char* objClassName));
CORINFO_CONTEXT_HANDLE* pContextHandle);

bool isCompatibleMethodGDV(GenTreeCall* call, CORINFO_METHOD_HANDLE gdvTarget);

void addGuardedDevirtualizationCandidate(GenTreeCall* call,
CORINFO_METHOD_HANDLE methodHandle,
Expand Down Expand Up @@ -9537,7 +9561,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
unsigned genCPU; // What CPU are we running on

// Number of class profile probes in this method
unsigned compClassProbeCount;
unsigned compHandleHistogramProbeCount;

} info;

Expand Down
Loading