Skip to content
Merged
8 changes: 4 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4553,10 +4553,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
};
DoPhase(this, PHASE_POST_MORPH, postMorphPhase);

// GS security checks for unsafe buffers
//
DoPhase(this, PHASE_GS_COOKIE, &Compiler::gsPhase);

if (opts.OptimizationEnabled())
{
// Compute the block weights
Expand Down Expand Up @@ -4948,6 +4944,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
DoPhase(this, PHASE_ASYNC, &Compiler::TransformAsync);
}

// GS security checks for unsafe buffers
//
DoPhase(this, PHASE_GS_COOKIE, &Compiler::gsPhase);

#ifdef TARGET_WASM
// Transform any strongly connected components into reducible flow.
//
Expand Down
21 changes: 13 additions & 8 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11247,18 +11247,23 @@ class Compiler
#endif
};

GSCookie* gsGlobalSecurityCookieAddr; // Address of global cookie for unsafe buffer checks
GSCookie gsGlobalSecurityCookieVal; // Value of global cookie if addr is NULL
ShadowParamVarInfo* gsShadowVarInfo = nullptr; // Table used by shadow param analysis code
GSCookie* gsGlobalSecurityCookieAddr; // Address of global cookie for unsafe buffer checks
GSCookie gsGlobalSecurityCookieVal; // Value of global cookie if addr is NULL
ShadowParamVarInfo* gsShadowVarInfo = nullptr; // Table used by shadow param analysis code
unsigned gsShadowVarInfoCount = 0;

PhaseStatus gsPhase();
void gsGSChecksInitCookie(); // Grabs cookie variable
void gsCopyShadowParams(); // Identify vulnerable params and create dhadow copies
void gsCopyShadowParams(); // Identify vulnerable params and create shadow copies
bool gsFindVulnerableParams(); // Shadow param analysis code
void gsParamsToShadows(); // Insert copy code and replave param uses by shadow

static fgWalkPreFn gsMarkPtrsAndAssignGroups; // Shadow param analysis tree-walk
static fgWalkPreFn gsReplaceShadowParams; // Shadow param replacement tree-walk
template <typename TVisit>
void gsVisitDependentLocals(GenTree* tree, TVisit visit);
void gsMarkPointers(GenTree* tree);
void gsUnionAssignGroups(unsigned lclNum1, unsigned lclNum2, GenTree* reason);
void gsParamsToShadows(); // Insert copy code and replace param uses by shadow
void gsCopyIntoShadow(unsigned lclNum, unsigned shadowLclNum);
bool gsCreateShadowingLocals();
void gsRewriteTreeForShadowParam(GenTree* tree);

#define DEFAULT_MAX_INLINE_SIZE \
100 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined.
Expand Down
Loading
Loading