Skip to content

Commit

Permalink
More JIT formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcovington committed Sep 22, 2021
1 parent 3191bd4 commit 237ce31
Show file tree
Hide file tree
Showing 125 changed files with 2,529 additions and 2,974 deletions.
156 changes: 79 additions & 77 deletions src/coreclr/jit/_typeinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,70 +142,70 @@ inline ti_types JITtype2tiType(CorInfoType type)
return g_ti_types_map[type];
};

/*****************************************************************************
* Declares the typeInfo class, which represents the type of an entity on the
* stack, in a local variable or an argument.
*
* Flags: LLLLLLLLLLLLLLLLffffffffffTTTTTT
*
* L = local var # or instance field #
* x = unused
* f = flags
* T = type
*
* The lower bits are used to store the type component, and may be one of:
*
* TI_* (primitive) - see tyelist.h for enumeration (BYTE, SHORT, INT..)
* TI_REF - OBJREF / ARRAY use m_cls for the type
* (including arrays and null objref)
* TI_STRUCT - VALUE type, use m_cls for the actual type
*
* NOTE carefully that BYREF info is not stored here. You will never see a
* TI_BYREF in this component. For example, the type component
* of a "byref TI_INT" is TI_FLAG_BYREF | TI_INT.
*
* NOTE carefully that Generic Type Variable info is
* only stored here in part. Values of type "T" (e.g "!0" in ILASM syntax),
* i.e. some generic variable type, appear only when verifying generic
* code. They come in two flavours: unboxed and boxed. Unboxed
* is the norm, e.g. a local, field or argument of type T. Boxed
* values arise from an IL instruction such as "box !0".
* The EE provides type handles for each different type
* variable and the EE's "canCast" operation decides casting
* for boxed type variable. Thus:
*
* (TI_REF, <type-variable-type-handle>) == boxed type variable
*
* (TI_REF, <type-variable-type-handle>)
* + TI_FLAG_GENERIC_TYPE_VAR == unboxed type variable
*
* Using TI_REF for these may seem odd but using TI_STRUCT means the
* code-generation parts of the importer get confused when they
* can't work out the size, GC-ness etc. of the "struct". So using TI_REF
* just tricks these backend parts into generating pseudo-trees for
* the generic code we're verifying. These trees then get thrown away
* anyway as we do verification of generic code in import-only mode.
*
*/
/*****************************************************************************
* Declares the typeInfo class, which represents the type of an entity on the
* stack, in a local variable or an argument.
*
* Flags: LLLLLLLLLLLLLLLLffffffffffTTTTTT
*
* L = local var # or instance field #
* x = unused
* f = flags
* T = type
*
* The lower bits are used to store the type component, and may be one of:
*
* TI_* (primitive) - see tyelist.h for enumeration (BYTE, SHORT, INT..)
* TI_REF - OBJREF / ARRAY use m_cls for the type
* (including arrays and null objref)
* TI_STRUCT - VALUE type, use m_cls for the actual type
*
* NOTE carefully that BYREF info is not stored here. You will never see a
* TI_BYREF in this component. For example, the type component
* of a "byref TI_INT" is TI_FLAG_BYREF | TI_INT.
*
* NOTE carefully that Generic Type Variable info is
* only stored here in part. Values of type "T" (e.g "!0" in ILASM syntax),
* i.e. some generic variable type, appear only when verifying generic
* code. They come in two flavours: unboxed and boxed. Unboxed
* is the norm, e.g. a local, field or argument of type T. Boxed
* values arise from an IL instruction such as "box !0".
* The EE provides type handles for each different type
* variable and the EE's "canCast" operation decides casting
* for boxed type variable. Thus:
*
* (TI_REF, <type-variable-type-handle>) == boxed type variable
*
* (TI_REF, <type-variable-type-handle>)
* + TI_FLAG_GENERIC_TYPE_VAR == unboxed type variable
*
* Using TI_REF for these may seem odd but using TI_STRUCT means the
* code-generation parts of the importer get confused when they
* can't work out the size, GC-ness etc. of the "struct". So using TI_REF
* just tricks these backend parts into generating pseudo-trees for
* the generic code we're verifying. These trees then get thrown away
* anyway as we do verification of generic code in import-only mode.
*
*/

#define TI_FLAG_DATA_BITS 6
#define TI_FLAG_DATA_MASK ((1 << TI_FLAG_DATA_BITS) - 1)

// Flag indicating this item is uninitialized
// Note that if UNINIT and BYREF are both set,
// it means byref (uninit x) - i.e. we are pointing to an uninit <something>
// Flag indicating this item is uninitialized
// Note that if UNINIT and BYREF are both set,
// it means byref (uninit x) - i.e. we are pointing to an uninit <something>

#define TI_FLAG_UNINIT_OBJREF 0x00000040

// Flag indicating this item is a byref <something>
// Flag indicating this item is a byref <something>

#define TI_FLAG_BYREF 0x00000080

// This item is a byref generated using the readonly. prefix
// to a ldelema or Address function on an array type. The
// runtime type check is ignored in these cases, but the
// resulting byref can only be used in order to perform a
// constraint call.
// This item is a byref generated using the readonly. prefix
// to a ldelema or Address function on an array type. The
// runtime type check is ignored in these cases, but the
// resulting byref can only be used in order to perform a
// constraint call.

#define TI_FLAG_BYREF_READONLY 0x00000100

Expand All @@ -224,23 +224,23 @@ inline ti_types JITtype2tiType(CorInfoType type)
// This item contains resolved token. It is used for ctor delegate optimization.
#define TI_FLAG_TOKEN 0x00000400

// This item contains the 'this' pointer (used for tracking)
// This item contains the 'this' pointer (used for tracking)

#define TI_FLAG_THIS_PTR 0x00001000

// This item is a byref to something which has a permanent home
// (e.g. a static field, or instance field of an object in GC heap, as
// opposed to the stack or a local variable). TI_FLAG_BYREF must also be
// set. This information is useful for tail calls and return byrefs.
//
// Instructions that generate a permanent home byref:
//
// ldelema
// ldflda of a ref object or another permanent home byref
// array element address Get() helper
// call or calli to a method that returns a byref and is verifiable or SkipVerify
// dup
// unbox
// This item is a byref to something which has a permanent home
// (e.g. a static field, or instance field of an object in GC heap, as
// opposed to the stack or a local variable). TI_FLAG_BYREF must also be
// set. This information is useful for tail calls and return byrefs.
//
// Instructions that generate a permanent home byref:
//
// ldelema
// ldflda of a ref object or another permanent home byref
// array element address Get() helper
// call or calli to a method that returns a byref and is verifiable or SkipVerify
// dup
// unbox

#define TI_FLAG_BYREF_PERMANENT_HOME 0x00002000

Expand All @@ -252,12 +252,12 @@ inline ti_types JITtype2tiType(CorInfoType type)
// e.g. the result of a "box T" instruction.
#define TI_FLAG_GENERIC_TYPE_VAR 0x00004000

// Number of bits local var # is shifted
// Number of bits local var # is shifted

#define TI_FLAG_LOCAL_VAR_SHIFT 16
#define TI_FLAG_LOCAL_VAR_MASK 0xFFFF0000

// Field info uses the same space as the local info
// Field info uses the same space as the local info

#define TI_FLAG_FIELD_SHIFT TI_FLAG_LOCAL_VAR_SHIFT
#define TI_FLAG_FIELD_MASK TI_FLAG_LOCAL_VAR_MASK
Expand All @@ -283,7 +283,8 @@ class typeInfo
{

private:
union {
union
{
struct
{
ti_types type : TI_FLAG_DATA_BITS;
Expand All @@ -301,7 +302,8 @@ class typeInfo
DWORD m_flags;
};

union {
union
{
CORINFO_CLASS_HANDLE m_cls;
// Valid only for type TI_METHOD without IsToken
CORINFO_METHOD_HANDLE m_method;
Expand Down Expand Up @@ -405,8 +407,8 @@ class typeInfo
}

unsigned type = li.m_flags & TI_FLAG_DATA_MASK;
assert(TI_ERROR <
TI_ONLY_ENUM); // TI_ERROR looks like it needs more than enum. This optimises the success case a bit
assert(TI_ERROR < TI_ONLY_ENUM); // TI_ERROR looks like it needs more than enum. This optimises the success
// case a bit
if (type > TI_ONLY_ENUM)
{
return true;
Expand Down Expand Up @@ -664,9 +666,9 @@ class typeInfo
// as primitives
bool IsValueClassWithClsHnd() const
{
if ((GetType() == TI_STRUCT) ||
(m_cls && GetType() != TI_REF && GetType() != TI_METHOD &&
GetType() != TI_ERROR)) // necessary because if byref bit is set, we return TI_ERROR)
if ((GetType() == TI_STRUCT) || (m_cls && GetType() != TI_REF && GetType() != TI_METHOD &&
GetType() != TI_ERROR)) // necessary because if byref bit is set, we return
// TI_ERROR)
{
return true;
}
Expand Down
14 changes: 5 additions & 9 deletions src/coreclr/jit/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ArenaAllocator
void* allocateNewPage(size_t size);

static void* allocateHostMemory(size_t size, size_t* pActualSize);
static void freeHostMemory(void* block, size_t size);
static void freeHostMemory(void* block, size_t size);

#if MEASURE_MEM_ALLOC
struct MemStats
Expand Down Expand Up @@ -125,8 +125,8 @@ class ArenaAllocator

public:
MemStatsAllocator* getMemStatsAllocator(CompMemKind kind);
void finishMemStats();
void dumpMemStats(FILE* file);
void finishMemStats();
void dumpMemStats(FILE* file);

static void dumpMaxMemStats(FILE* file);
static void dumpAggregateMemStats(FILE* file);
Expand Down Expand Up @@ -243,9 +243,7 @@ class CompAllocator

// Deallocate a block of memory previously allocated by `allocate`.
// The arena allocator does not release memory so this doesn't do anything.
void deallocate(void* p)
{
}
void deallocate(void* p) {}
};

// Global operator new overloads that work with CompAllocator
Expand All @@ -270,9 +268,7 @@ class CompIAllocator : public IAllocator
char m_zeroLenAllocTarg;

public:
CompIAllocator(CompAllocator alloc) : m_alloc(alloc)
{
}
CompIAllocator(CompAllocator alloc) : m_alloc(alloc) {}

// Allocates a block of memory at least `sz` in size.
virtual void* Alloc(size_t sz) override
Expand Down
30 changes: 15 additions & 15 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,8 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,
assertion.op1.lcl.ssaNum = op1->AsLclVarCommon()->GetSsaNum();

assert((assertion.op1.lcl.ssaNum == SsaConfig::RESERVED_SSA_NUM) ||
(assertion.op1.vn ==
vnStore->VNConservativeNormalValue(
lvaTable[lclNum].GetPerSsaData(assertion.op1.lcl.ssaNum)->m_vnPair)));
(assertion.op1.vn == vnStore->VNConservativeNormalValue(
lvaTable[lclNum].GetPerSsaData(assertion.op1.lcl.ssaNum)->m_vnPair)));

ssize_t cnsValue = 0;
GenTreeFlags iconFlags = GTF_EMPTY;
Expand Down Expand Up @@ -2416,8 +2415,8 @@ AssertionInfo Compiler::optAssertionGenJtrue(GenTree* tree)
ValueNum op1VN = vnStore->VNConservativeNormalValue(op1->gtVNPair);
ValueNum op2VN = vnStore->VNConservativeNormalValue(op2->gtVNPair);
// If op1 is lcl and op2 is const or lcl, create assertion.
if ((op1->gtOper == GT_LCL_VAR) &&
((op2->OperKind() & GTK_CONST) || (op2->gtOper == GT_LCL_VAR))) // Fix for Dev10 851483
if ((op1->gtOper == GT_LCL_VAR) && ((op2->OperKind() & GTK_CONST) || (op2->gtOper == GT_LCL_VAR))) // Fix for Dev10
// 851483
{
return optCreateJtrueAssertions(op1, op2, assertionKind);
}
Expand Down Expand Up @@ -2741,10 +2740,10 @@ AssertionIndex Compiler::optAssertionIsSubrange(GenTree* tree, IntegralRange ran
for (AssertionIndex index = 1; index <= optAssertionCount; index++)
{
AssertionDsc* curAssertion = optGetAssertion(index);
if ((optLocalAssertionProp ||
BitVecOps::IsMember(apTraits, assertions, index - 1)) && // either local prop or use propagated assertions
(curAssertion->assertionKind == OAK_SUBRANGE) &&
(curAssertion->op1.kind == O1K_LCLVAR))
if ((optLocalAssertionProp || BitVecOps::IsMember(apTraits, assertions, index - 1)) && // either local prop or
// use propagated
// assertions
(curAssertion->assertionKind == OAK_SUBRANGE) && (curAssertion->op1.kind == O1K_LCLVAR))
{
// For local assertion prop use comparison on locals, and use comparison on vns for global prop.
bool isEqual = optLocalAssertionProp
Expand Down Expand Up @@ -3087,7 +3086,7 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
//
GenTree* Compiler::optConstantAssertionProp(AssertionDsc* curAssertion,
GenTreeLclVarCommon* tree,
Statement* stmt DEBUGARG(AssertionIndex index))
Statement* stmt DEBUGARG(AssertionIndex index))
{
const unsigned lclNum = tree->GetLclNum();

Expand Down Expand Up @@ -3304,7 +3303,7 @@ bool Compiler::optAssertionProp_LclVarTypeCheck(GenTree* tree, LclVarDsc* lclVar
//
GenTree* Compiler::optCopyAssertionProp(AssertionDsc* curAssertion,
GenTreeLclVarCommon* tree,
Statement* stmt DEBUGARG(AssertionIndex index))
Statement* stmt DEBUGARG(AssertionIndex index))
{
const AssertionDsc::AssertionDscOp1& op1 = curAssertion->op1;
const AssertionDsc::AssertionDscOp2& op2 = curAssertion->op2;
Expand Down Expand Up @@ -3841,8 +3840,9 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen
{
printf("\nVN relop based copy assertion prop in " FMT_BB ":\n", compCurBB->bbNum);
printf("Assertion index=#%02u: V%02d.%02d %s V%02d.%02d\n", index, op1->AsLclVar()->GetLclNum(),
op1->AsLclVar()->GetSsaNum(), (curAssertion->assertionKind == OAK_EQUAL) ? "==" : "!=",
op2->AsLclVar()->GetLclNum(), op2->AsLclVar()->GetSsaNum());
op1->AsLclVar()->GetSsaNum(),
(curAssertion->assertionKind == OAK_EQUAL) ? "==" : "!=", op2->AsLclVar()->GetLclNum(),
op2->AsLclVar()->GetSsaNum());
gtDispTree(tree, nullptr, nullptr, true);
}
#endif
Expand Down Expand Up @@ -4168,7 +4168,7 @@ GenTree* Compiler::optAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* tr
// If both VN and assertion table yield a matching assertion, "pVnBased"
// is only set and the return value is "NO_ASSERTION_INDEX."
//
bool Compiler::optAssertionIsNonNull(GenTree* op,
bool Compiler::optAssertionIsNonNull(GenTree* op,
ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased)
DEBUGARG(AssertionIndex* pIndex))
{
Expand Down Expand Up @@ -4204,7 +4204,7 @@ bool Compiler::optAssertionIsNonNull(GenTree* op,
// Returns:
// index of assertion, or NO_ASSERTION_INDEX
//
AssertionIndex Compiler::optAssertionIsNonNullInternal(GenTree* op,
AssertionIndex Compiler::optAssertionIsNonNullInternal(GenTree* op,
ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased))
{

Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/jit/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,7 @@ class BitSetOpsWithCounter
Env m_env;

public:
Iter(Env env, BitSetValueArgType bs) : m_iter(env, bs), m_env(env)
{
}
Iter(Env env, BitSetValueArgType bs) : m_iter(env, bs), m_env(env) {}

bool NextElem(unsigned* pElem)
{
Expand Down
Loading

0 comments on commit 237ce31

Please sign in to comment.