-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Annotate handle indirections with GTF_IND_INVARIANT and add validation to fgDebugCheckFlags #42021
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
Changes from all commits
91b9a3f
0ecbc7e
b7dfea7
fbf97a4
d574273
626c662
682f94a
f4d0be2
74d2c4b
6bf0511
1a4d4d5
8e2dca9
bb18e85
90b4635
2e3fb69
dacee29
65bcaea
0a22f24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5987,18 +5987,25 @@ GenTree* Compiler::gtNewIndOfIconHandleNode(var_types indType, size_t addr, unsi | |
// | ||
indNode->gtFlags |= GTF_IND_NONFAULTING; | ||
|
||
// String Literal handles are indirections that return a TYP_REF. | ||
// They are pointers into the GC heap and they are not invariant | ||
// as the address is a reportable GC-root and as such it can be | ||
// modified during a GC collection | ||
// String Literal handles are indirections that return a TYP_REF, and | ||
// these are pointers into the GC heap. We don't currently have any | ||
// TYP_BYREF pointers, but if we did they also must be pointers into the GC heap. | ||
// | ||
if (indType == TYP_REF) | ||
// Also every GTF_ICON_STATIC_HDL also must be a pointer into the GC heap | ||
// we will set GTF_GLOB_REF for these kinds of references. | ||
// | ||
if ((varTypeIsGC(indType)) || (iconFlags == GTF_ICON_STATIC_HDL)) | ||
{ | ||
// This indirection points into the gloabal heap | ||
// This indirection also points into the gloabal heap | ||
indNode->gtFlags |= GTF_GLOB_REF; | ||
} | ||
|
||
if (isInvariant) | ||
{ | ||
assert(iconFlags != GTF_ICON_STATIC_HDL); // Pointer to a mutable class Static variable | ||
assert(iconFlags != GTF_ICON_BBC_PTR); // Pointer to a mutable basic block count value | ||
assert(iconFlags != GTF_ICON_GLOBAL_PTR); // Pointer to mutable data from the VM state | ||
|
||
// This indirection also is invariant. | ||
indNode->gtFlags |= GTF_IND_INVARIANT; | ||
} | ||
|
@@ -6044,12 +6051,9 @@ GenTree* Compiler::gtNewIconEmbHndNode(void* value, void* pValue, unsigned iconF | |
|
||
// This indirection won't cause an exception. | ||
handleNode->gtFlags |= GTF_IND_NONFAULTING; | ||
#if 0 | ||
// It should also be invariant, but marking it as such leads to bad diffs. | ||
|
||
// This indirection also is invariant. | ||
handleNode->gtFlags |= GTF_IND_INVARIANT; | ||
#endif | ||
} | ||
|
||
iconNode->AsIntCon()->gtCompileTimeHandle = (size_t)compileTimeHandle; | ||
|
@@ -6064,7 +6068,14 @@ GenTree* Compiler::gtNewStringLiteralNode(InfoAccessType iat, void* pValue) | |
|
||
switch (iat) | ||
{ | ||
case IAT_VALUE: // constructStringLiteral in CoreRT case can return IAT_VALUE | ||
case IAT_VALUE: | ||
// For CoreRT only - Constant object can be a frozen string. | ||
if (!IsTargetAbi(CORINFO_CORERT_ABI)) | ||
{ | ||
// Non CoreRT - This case is illegal, creating a TYP_REF from an INT_CNS | ||
noway_assert(!"unreachable IAT_VALUE case in gtNewStringLiteralNode"); | ||
} | ||
|
||
tree = gtNewIconEmbHndNode(pValue, nullptr, GTF_ICON_STR_HDL, nullptr); | ||
tree->gtType = TYP_REF; | ||
#ifdef DEBUG | ||
|
@@ -6083,7 +6094,7 @@ GenTree* Compiler::gtNewStringLiteralNode(InfoAccessType iat, void* pValue) | |
|
||
case IAT_PPVALUE: // The value needs to be accessed via a double indirection | ||
// Create the first indirection | ||
tree = gtNewIndOfIconHandleNode(TYP_I_IMPL, (size_t)pValue, GTF_ICON_PSTR_HDL, true); | ||
tree = gtNewIndOfIconHandleNode(TYP_I_IMPL, (size_t)pValue, GTF_ICON_CONST_PTR, true); | ||
#ifdef DEBUG | ||
tree->gtGetOp1()->AsIntCon()->gtTargetHandle = (size_t)pValue; | ||
#endif | ||
|
@@ -10304,6 +10315,31 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, __in __in_z _ | |
printf((tree->gtFlags & GTF_JCMP_EQ) ? "EQ" : "NE"); | ||
goto DASH; | ||
|
||
case GT_CNS_INT: | ||
if (tree->IsIconHandle()) | ||
{ | ||
if ((tree->gtFlags & GTF_ICON_INITCLASS) != 0) | ||
{ | ||
printf("I"); // Static Field handle with INITCLASS requirement | ||
--msgLength; | ||
break; | ||
} | ||
else if ((tree->gtFlags & GTF_ICON_FIELD_OFF) != 0) | ||
{ | ||
printf("O"); | ||
--msgLength; | ||
break; | ||
} | ||
else | ||
{ | ||
// Some other handle | ||
printf("H"); | ||
--msgLength; | ||
break; | ||
} | ||
} | ||
goto DASH; | ||
|
||
default: | ||
DASH: | ||
printf("-"); | ||
|
@@ -10869,13 +10905,14 @@ void Compiler::gtDispConst(GenTree* tree) | |
if (tree->IsIconHandle(GTF_ICON_STR_HDL)) | ||
{ | ||
const WCHAR* str = eeGetCPString(tree->AsIntCon()->gtIconVal); | ||
if (str != nullptr) | ||
// If *str points to a '\0' then don't print the string's values | ||
if ((str != nullptr) && (*str != '\0')) | ||
{ | ||
printf(" 0x%X \"%S\"", dspPtr(tree->AsIntCon()->gtIconVal), str); | ||
} | ||
else | ||
else // We can't print the value of the string | ||
{ | ||
// Note that eGetCPString isn't currently implemented on Linux/ARM | ||
// Note that eeGetCPString isn't currently implemented on Linux/ARM | ||
|
||
// and instead always returns nullptr | ||
printf(" 0x%X [ICON_STR_HDL]", dspPtr(tree->AsIntCon()->gtIconVal)); | ||
} | ||
|
@@ -10941,11 +10978,11 @@ void Compiler::gtDispConst(GenTree* tree) | |
case GTF_ICON_STR_HDL: | ||
unreached(); // This case is handled above | ||
break; | ||
case GTF_ICON_PSTR_HDL: | ||
printf(" pstr"); | ||
case GTF_ICON_CONST_PTR: | ||
printf(" const ptr"); | ||
break; | ||
case GTF_ICON_PTR_HDL: | ||
printf(" ptr"); | ||
case GTF_ICON_GLOBAL_PTR: | ||
printf(" global ptr"); | ||
break; | ||
case GTF_ICON_VARG_HDL: | ||
printf(" vararg"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the header was not finished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update this