diff options
Diffstat (limited to 'src')
51 files changed, 940 insertions, 449 deletions
diff --git a/src/dlls/mscoree/mscorwks_unixexports.src b/src/dlls/mscoree/mscorwks_unixexports.src index 73ffc0c1c5..e32f7ce1bb 100644 --- a/src/dlls/mscoree/mscorwks_unixexports.src +++ b/src/dlls/mscoree/mscorwks_unixexports.src @@ -104,6 +104,10 @@ GlobalMemoryStatusEx VirtualQuery WideCharToMultiByte WriteFile +GetLogicalProcessorInformationEx +SetThreadGroupAffinity +GetThreadGroupAffinity +GetCurrentProcessorNumberEx ; Function for initializing a standalone GC InitializeGarbageCollector diff --git a/src/jit/CMakeLists.txt b/src/jit/CMakeLists.txt index e2a9ca66ab..b34cf63410 100644 --- a/src/jit/CMakeLists.txt +++ b/src/jit/CMakeLists.txt @@ -238,6 +238,7 @@ if ((CLR_CMAKE_PLATFORM_ARCH_I386 OR CLR_CMAKE_PLATFORM_ARCH_AMD64) AND WIN32) endif () if (CLR_CMAKE_PLATFORM_ARCH_I386 AND WIN32) + add_subdirectory(legacyjit) # On Windows x86, build altjit generating Windows/ARM32 code using LEGACY_BACKEND. # (Note: we could also create linuxlegacynonjit for generating Linux/ARM32 code using LEGACY_BACKEND, if needed.) add_subdirectory(legacynonjit) diff --git a/src/jit/DIRS.proj b/src/jit/DIRS.proj index 12ea52fb20..539743cc6e 100644 --- a/src/jit/DIRS.proj +++ b/src/jit/DIRS.proj @@ -26,7 +26,7 @@ <ItemGroup Condition="'$(BuildExePhase)' == '1' and '$(BuildProjectName)' != 'CoreSys'"> <!-- Build the "FrankenJit" (RyuJIT front-end, legacy back-end) and "FrankenAltjit". These can't conflict with the names of the JIT32 directory outputs. --> - <ProjectFile Condition="'$(BuildArchitecture)' == 'arm'" Include="frankenjit\frankenjit.nativeproj" /> + <ProjectFile Condition="'$(BuildArchitecture)' == 'i386' or '$(BuildArchitecture)' == 'arm'" Include="frankenjit\frankenjit.nativeproj" /> <ProjectFile Condition="'$(BuildArchitecture)' == 'i386'" Include="frankenaltjit\frankenaltjit.nativeproj" /> <!-- This might be useful, to help make sure JIT devs build all configurations of the JIT (including crossgen), but diff --git a/src/jit/block.h b/src/jit/block.h index 461eadc5d7..ad120fc451 100644 --- a/src/jit/block.h +++ b/src/jit/block.h @@ -49,7 +49,7 @@ typedef BitVec_ValRet_T ASSERT_VALRET_TP; // clang-format off -DECLARE_TYPED_ENUM(BBjumpKinds, BYTE) +enum BBjumpKinds : BYTE { BBJ_EHFINALLYRET,// block ends with 'endfinally' (for finally or fault) BBJ_EHFILTERRET, // block ends with 'endfilter' @@ -64,8 +64,7 @@ DECLARE_TYPED_ENUM(BBjumpKinds, BYTE) BBJ_SWITCH, // block ends with a switch statement BBJ_COUNT -} -END_DECLARE_TYPED_ENUM(BBjumpKinds, BYTE) +}; // clang-format on diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp index 55e172314f..7e8d72d1ad 100644 --- a/src/jit/codegenxarch.cpp +++ b/src/jit/codegenxarch.cpp @@ -535,10 +535,6 @@ void CodeGen::genCodeForNegNot(GenTree* tree) // Generate code to get the high N bits of a N*N=2N bit multiplication result void CodeGen::genCodeForMulHi(GenTreeOp* treeNode) { - if (treeNode->OperGet() == GT_MULHI) - { - assert(!(treeNode->gtFlags & GTF_UNSIGNED)); - } assert(!treeNode->gtOverflowEx()); regNumber targetReg = treeNode->gtRegNum; diff --git a/src/jit/compiler.h b/src/jit/compiler.h index d4388628c6..fbdbaf4351 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -1131,14 +1131,13 @@ public: #endif // FEATURE_JIT_METHOD_PERF //------------------- Function/Funclet info ------------------------------- -DECLARE_TYPED_ENUM(FuncKind, BYTE) +enum FuncKind : BYTE { - FUNC_ROOT, // The main/root function (always id==0) - FUNC_HANDLER, // a funclet associated with an EH handler (finally, fault, catch, filter handler) - FUNC_FILTER, // a funclet associated with an EH filter - FUNC_COUNT -} -END_DECLARE_TYPED_ENUM(FuncKind, BYTE) + FUNC_ROOT, // The main/root function (always id==0) + FUNC_HANDLER, // a funclet associated with an EH handler (finally, fault, catch, filter handler) + FUNC_FILTER, // a funclet associated with an EH filter + FUNC_COUNT +}; class emitLocation; diff --git a/src/jit/emit.h b/src/jit/emit.h index a925f1f8a5..cfad5c60d7 100644 --- a/src/jit/emit.h +++ b/src/jit/emit.h @@ -220,15 +220,15 @@ private: /* The following describes an instruction group */ /************************************************************************/ -DECLARE_TYPED_ENUM(insGroupPlaceholderType, unsigned char) +enum insGroupPlaceholderType : unsigned char { IGPT_PROLOG, // currently unused - IGPT_EPILOG, + IGPT_EPILOG, #if FEATURE_EH_FUNCLETS - IGPT_FUNCLET_PROLOG, IGPT_FUNCLET_EPILOG, + IGPT_FUNCLET_PROLOG, + IGPT_FUNCLET_EPILOG, #endif // FEATURE_EH_FUNCLETS -} -END_DECLARE_TYPED_ENUM(insGroupPlaceholderType, unsigned char) +}; #if defined(_MSC_VER) && defined(_TARGET_ARM_) // ARM aligns structures that contain 64-bit ints or doubles on 64-bit boundaries. This causes unwanted @@ -452,16 +452,21 @@ protected: void* emitGetMem(size_t sz); - DECLARE_TYPED_ENUM(opSize, unsigned) + enum opSize : unsigned { - OPSZ1 = 0, OPSZ2 = 1, OPSZ4 = 2, OPSZ8 = 3, OPSZ16 = 4, OPSZ32 = 5, OPSZ_COUNT = 6, + OPSZ1 = 0, + OPSZ2 = 1, + OPSZ4 = 2, + OPSZ8 = 3, + OPSZ16 = 4, + OPSZ32 = 5, + OPSZ_COUNT = 6, #ifdef _TARGET_AMD64_ OPSZP = OPSZ8, #else OPSZP = OPSZ4, #endif - } - END_DECLARE_TYPED_ENUM(opSize, unsigned) + }; #define OPSIZE_INVALID ((opSize)0xffff) @@ -507,14 +512,13 @@ protected: /* The following describes a single instruction */ /************************************************************************/ - DECLARE_TYPED_ENUM(insFormat, unsigned) + enum insFormat : unsigned { #define IF_DEF(en, op1, op2) IF_##en, #include "emitfmts.h" IF_COUNT - } - END_DECLARE_TYPED_ENUM(insFormat, unsigned) + }; #define AM_DISP_BITS ((sizeof(unsigned) * 8) - 2 * (REGNUM_BITS + 1) - 2) #define AM_DISP_BIG_VAL (-(1 << (AM_DISP_BITS - 1))) @@ -553,12 +557,13 @@ protected: #ifdef _TARGET_ARM_ unsigned insEncodeSetFlags(insFlags sf); - DECLARE_TYPED_ENUM(insSize, unsigned) + enum insSize : unsigned { - ISZ_16BIT, ISZ_32BIT, ISZ_48BIT // pseudo-instruction for conditional branch with imm24 range, - // encoded as IT of condition followed by an unconditional branch - } - END_DECLARE_TYPED_ENUM(insSize, unsigned) + ISZ_16BIT, + ISZ_32BIT, + ISZ_48BIT // pseudo-instruction for conditional branch with imm24 range, + // encoded as IT of condition followed by an unconditional branch + }; unsigned insEncodeShiftOpts(insOpts opt); unsigned insEncodePUW_G0(insOpts opt, int imm); @@ -828,6 +833,8 @@ protected: unsigned _idCnsReloc : 1; // LargeCns is an RVA and needs reloc tag unsigned _idDspReloc : 1; // LargeDsp is an RVA and needs reloc tag +#define ID_EXTRA_RELOC_BITS (2) + #define ID_EXTRA_REG_BITS (0) #define ID_EXTRA_BITS (ID_EXTRA_BITFIELD_BITS + ID_EXTRA_RELOC_BITS + ID_EXTRA_REG_BITS) diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp index 5a0abe7da2..b65178282b 100644 --- a/src/jit/emitxarch.cpp +++ b/src/jit/emitxarch.cpp @@ -209,6 +209,7 @@ emitter::code_t emitter::AddVexPrefix(instruction ins, code_t code, emitAttr att // Returns true if this instruction, for the given EA_SIZE(attr), will require a REX.W prefix bool TakesRexWPrefix(instruction ins, emitAttr attr) { +#ifndef LEGACY_BACKEND // Because the current implementation of AVX does not have a way to distinguish between the register // size specification (128 vs. 256 bits) and the operand size specification (32 vs. 64 bits), where both are // required, the instruction must be created with the register size attribute (EA_16BYTE or EA_32BYTE), @@ -217,6 +218,7 @@ bool TakesRexWPrefix(instruction ins, emitAttr attr) { return true; } +#endif // !LEGACY_BACKEND #ifdef _TARGET_AMD64_ // movsx should always sign extend out to 8 bytes just because we don't track // whether the dest should be 4 bytes or 8 bytes (attr indicates the size @@ -359,10 +361,10 @@ emitter::code_t emitter::AddRexWPrefix(instruction ins, code_t code) assert(hasVexPrefix(code)); // W-bit is the only bit that is added in non bit-inverted form. - return code | 0x00008000000000ULL; + return emitter::code_t(code | 0x00008000000000ULL); } #ifdef _TARGET_AMD64_ - return code | 0x4800000000ULL; + return emitter::code_t(code | 0x4800000000ULL); #else assert(!"UNREACHED"); return code; diff --git a/src/jit/gentree.h b/src/jit/gentree.h index 747784b081..32ef9529c0 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -66,7 +66,7 @@ enum SpecialCodeKind /*****************************************************************************/ -DECLARE_TYPED_ENUM(genTreeOps, BYTE) +enum genTreeOps : BYTE { #define GTNODE(en, st, cm, ok) GT_##en, #include "gtlist.h" @@ -74,16 +74,15 @@ DECLARE_TYPED_ENUM(genTreeOps, BYTE) GT_COUNT, #ifdef _TARGET_64BIT_ - // GT_CNS_NATIVELONG is the gtOper symbol for GT_CNS_LNG or GT_CNS_INT, depending on the target. - // For the 64-bit targets we will only use GT_CNS_INT as it used to represent all the possible sizes - GT_CNS_NATIVELONG = GT_CNS_INT, + // GT_CNS_NATIVELONG is the gtOper symbol for GT_CNS_LNG or GT_CNS_INT, depending on the target. + // For the 64-bit targets we will only use GT_CNS_INT as it used to represent all the possible sizes + GT_CNS_NATIVELONG = GT_CNS_INT, #else - // For the 32-bit targets we use a GT_CNS_LNG to hold a 64-bit integer constant and GT_CNS_INT for all others. - // In the future when we retarget the JIT for x86 we should consider eliminating GT_CNS_LNG - GT_CNS_NATIVELONG = GT_CNS_LNG, + // For the 32-bit targets we use a GT_CNS_LNG to hold a 64-bit integer constant and GT_CNS_INT for all others. + // In the future when we retarget the JIT for x86 we should consider eliminating GT_CNS_LNG + GT_CNS_NATIVELONG = GT_CNS_LNG, #endif -} -END_DECLARE_TYPED_ENUM(genTreeOps, BYTE) +}; /***************************************************************************** * @@ -133,15 +132,14 @@ enum genTreeKinds /*****************************************************************************/ -DECLARE_TYPED_ENUM(gtCallTypes, BYTE) +enum gtCallTypes : BYTE { - CT_USER_FUNC, // User function - CT_HELPER, // Jit-helper - CT_INDIRECT, // Indirect call + CT_USER_FUNC, // User function + CT_HELPER, // Jit-helper + CT_INDIRECT, // Indirect call - CT_COUNT // fake entry (must be last) -} -END_DECLARE_TYPED_ENUM(gtCallTypes, BYTE) + CT_COUNT // fake entry (must be last) +}; /*****************************************************************************/ diff --git a/src/jit/instr.h b/src/jit/instr.h index 2d50234fdc..309a2f5dfe 100644 --- a/src/jit/instr.h +++ b/src/jit/instr.h @@ -12,7 +12,7 @@ /*****************************************************************************/ // clang-format off -DECLARE_TYPED_ENUM(instruction,unsigned) +enum instruction : unsigned { #if defined(_TARGET_XARCH_) #define INST0(id, nm, fp, um, rf, wf, mr ) INS_##id, @@ -53,8 +53,7 @@ DECLARE_TYPED_ENUM(instruction,unsigned) INS_none, INS_count = INS_none -} -END_DECLARE_TYPED_ENUM(instruction,unsigned) +}; /*****************************************************************************/ @@ -79,25 +78,23 @@ enum emitJumpKind /*****************************************************************************/ -DECLARE_TYPED_ENUM(GCtype,unsigned) +enum GCtype : unsigned { GCT_NONE, GCT_GCREF, GCT_BYREF -} -END_DECLARE_TYPED_ENUM(GCtype,unsigned) +}; // TODO-Cleanup: Move 'insFlags' under _TARGET_ARM_ -DECLARE_TYPED_ENUM(insFlags,unsigned) +enum insFlags: unsigned { INS_FLAGS_NOT_SET, INS_FLAGS_SET, INS_FLAGS_DONT_CARE }; -END_DECLARE_TYPED_ENUM(insFlags,unsigned) #if defined(_TARGET_ARM_) -DECLARE_TYPED_ENUM(insOpts,unsigned) +enum insOpts: unsigned { INS_OPTS_NONE, INS_OPTS_LDST_PRE_DEC, @@ -108,10 +105,9 @@ DECLARE_TYPED_ENUM(insOpts,unsigned) INS_OPTS_LSR, INS_OPTS_ASR, INS_OPTS_ROR -} -END_DECLARE_TYPED_ENUM(insOpts,unsigned) +}; #elif defined(_TARGET_ARM64_) -DECLARE_TYPED_ENUM(insOpts,unsigned) +enum insOpts : unsigned { INS_OPTS_NONE, @@ -165,10 +161,9 @@ DECLARE_TYPED_ENUM(insOpts,unsigned) INS_OPTS_S_TO_H, // Single to Half INS_OPTS_D_TO_H, // Double to Half -} -END_DECLARE_TYPED_ENUM(insOpts,unsigned) +}; -DECLARE_TYPED_ENUM(insCond,unsigned) +enum insCond : unsigned { INS_COND_EQ, INS_COND_NE, @@ -187,10 +182,9 @@ DECLARE_TYPED_ENUM(insCond,unsigned) INS_COND_GT, INS_COND_LE, -} -END_DECLARE_TYPED_ENUM(insCond,unsigned) +}; -DECLARE_TYPED_ENUM(insCflags,unsigned) +enum insCflags : unsigned { INS_FLAGS_NONE, INS_FLAGS_V, @@ -211,10 +205,9 @@ DECLARE_TYPED_ENUM(insCflags,unsigned) INS_FLAGS_NZV, INS_FLAGS_NZC, INS_FLAGS_NZCV, -} -END_DECLARE_TYPED_ENUM(insCFlags,unsigned) +}; -DECLARE_TYPED_ENUM(insBarrier,unsigned) +enum insBarrier : unsigned { INS_BARRIER_OSHLD = 1, INS_BARRIER_OSHST = 2, @@ -231,12 +224,11 @@ DECLARE_TYPED_ENUM(insBarrier,unsigned) INS_BARRIER_LD = 13, INS_BARRIER_ST = 14, INS_BARRIER_SY = 15, -} -END_DECLARE_TYPED_ENUM(insBarrier,unsigned) +}; #endif #undef EA_UNKNOWN -DECLARE_TYPED_ENUM(emitAttr,unsigned) +enum emitAttr : unsigned { EA_UNKNOWN = 0x000, EA_1BYTE = 0x001, @@ -261,8 +253,7 @@ DECLARE_TYPED_ENUM(emitAttr,unsigned) EA_BYREF = EA_BYREF_FLG | EA_PTRSIZE, /* size == -2 */ EA_DSP_RELOC_FLG = 0x200, EA_CNS_RELOC_FLG = 0x400, -} -END_DECLARE_TYPED_ENUM(emitAttr,unsigned) +}; #define EA_ATTR(x) ((emitAttr)(x)) #define EA_SIZE(x) ((emitAttr)(((unsigned)(x)) & EA_SIZE_MASK)) diff --git a/src/jit/jit.h b/src/jit/jit.h index 5120449411..2810b96e2b 100644 --- a/src/jit/jit.h +++ b/src/jit/jit.h @@ -225,21 +225,6 @@ #endif #endif -// Macros for defining strongly-typed enums. Use as follows: -// -// DECLARE_TYPED_ENUM(FooEnum,BYTE) -// { -// fooTag1, fooTag2 -// } -// END_DECLARE_TYPED_ENUM(FooEnum, BYTE) -// -// VC++ understands the syntax to declare these directly, e.g., "enum FooEnum : BYTE", -// but GCC does not, so we use typedefs. - -#define DECLARE_TYPED_ENUM(tag, baseType) enum tag : baseType - -#define END_DECLARE_TYPED_ENUM(tag, baseType) ; - #include "corhdr.h" #include "corjit.h" #include "jitee.h" diff --git a/src/jit/jitstd/type_traits.h b/src/jit/jitstd/type_traits.h index f0f8518c40..06c8ad170f 100644 --- a/src/jit/jitstd/type_traits.h +++ b/src/jit/jitstd/type_traits.h @@ -194,4 +194,31 @@ struct make_unsigned<__int64> typedef unsigned __int64 type; }; +template<typename Type1> +struct make_signed +{ +}; + +template<> +struct make_signed<unsigned int> +{ + typedef signed int type; +}; + +#ifndef _HOST_UNIX_ + +template<> +struct make_signed<unsigned long> +{ + typedef signed long type; +}; + +#endif // !_HOST_UNIX_ + +template<> +struct make_signed<unsigned __int64> +{ + typedef signed __int64 type; +}; + } // namespace jit_std diff --git a/src/jit/legacyjit/CMakeLists.txt b/src/jit/legacyjit/CMakeLists.txt new file mode 100644 index 0000000000..84fb42ecd1 --- /dev/null +++ b/src/jit/legacyjit/CMakeLists.txt @@ -0,0 +1,63 @@ +project(legacyjit) + +add_definitions(-DLEGACY_BACKEND) +add_definitions(-DALT_JIT) +add_definitions(-DFEATURE_NO_HOST) +add_definitions(-DSELF_NO_HOST) +add_definitions(-DFEATURE_READYTORUN_COMPILER) +remove_definitions(-DFEATURE_MERGE_JIT_AND_ENGINE) + +# No SIMD in legacy back-end. +remove_definitions(-DFEATURE_SIMD) +remove_definitions(-DFEATURE_AVX_SUPPORT) + +if(WIN32) + add_definitions(-DFX_VER_INTERNALNAME_STR=legacyjit.dll) +endif(WIN32) + +add_library_clr(legacyjit + SHARED + ${SHARED_LIB_SOURCES} + ${JIT_ARCH_SOURCES} +) + +add_dependencies(legacyjit jit_exports) + +set_property(TARGET legacyjit APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION}) +set_property(TARGET legacyjit APPEND_STRING PROPERTY LINK_DEPENDS ${JIT_EXPORTS_FILE}) + +set(RYUJIT_LINK_LIBRARIES + utilcodestaticnohost + gcinfo +) + +if(CLR_CMAKE_PLATFORM_UNIX) + list(APPEND RYUJIT_LINK_LIBRARIES + mscorrc_debug + coreclrpal + palrt + ) +else() + list(APPEND RYUJIT_LINK_LIBRARIES + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} + kernel32.lib + advapi32.lib + ole32.lib + oleaut32.lib + uuid.lib + user32.lib + version.lib + shlwapi.lib + bcrypt.lib + crypt32.lib + RuntimeObject.lib + ) +endif(CLR_CMAKE_PLATFORM_UNIX) + +target_link_libraries(legacyjit + ${RYUJIT_LINK_LIBRARIES} +) + +# add the install targets +install_clr(legacyjit)
\ No newline at end of file diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp index 87c96d5841..3bc11b3bc1 100644 --- a/src/jit/lower.cpp +++ b/src/jit/lower.cpp @@ -145,7 +145,7 @@ GenTree* Lowering::LowerNode(GenTree* node) case GT_UDIV: case GT_UMOD: - LowerUnsignedDivOrMod(node); + return LowerUnsignedDivOrMod(node->AsOp()); break; case GT_DIV: @@ -3966,131 +3966,199 @@ GenTree* Lowering::LowerAdd(GenTree* node) } //------------------------------------------------------------------------ -// LowerUnsignedDivOrMod: transform GT_UDIV/GT_UMOD nodes with a const power of 2 -// divisor into GT_RSZ/GT_AND nodes. +// LowerUnsignedDivOrMod: Lowers a GT_UDIV/GT_UMOD node. // // Arguments: -// node - pointer to the GT_UDIV/GT_UMOD node to be lowered +// divMod - pointer to the GT_UDIV/GT_UMOD node to be lowered // -void Lowering::LowerUnsignedDivOrMod(GenTree* node) +// Notes: +// - Transform UDIV/UMOD by power of 2 into RSZ/AND +// - Transform UDIV by constant >= 2^(N-1) into GE +// - Transform UDIV/UMOD by constant >= 3 into "magic division" + +GenTree* Lowering::LowerUnsignedDivOrMod(GenTreeOp* divMod) { - assert((node->OperGet() == GT_UDIV) || (node->OperGet() == GT_UMOD)); + assert(divMod->OperIs(GT_UDIV, GT_UMOD)); - GenTree* divisor = node->gtGetOp2(); - GenTree* dividend = node->gtGetOp1(); + GenTree* next = divMod->gtNext; + GenTree* dividend = divMod->gtGetOp1(); + GenTree* divisor = divMod->gtGetOp2(); - if (divisor->IsCnsIntOrI() -#ifdef _TARGET_X86_ - && (dividend->OperGet() != GT_LONG) +#if !defined(_TARGET_64BIT_) + if (dividend->OperIs(GT_LONG)) + { + return next; + } #endif - ) + + if (!divisor->IsCnsIntOrI()) + { + return next; + } + + if (dividend->IsCnsIntOrI()) { - size_t divisorValue = static_cast<size_t>(divisor->gtIntCon.IconValue()); + // We shouldn't see a divmod with constant operands here but if we do then it's likely + // because optimizations are disabled or it's a case that's supposed to throw an exception. + // Don't optimize this. + return next; + } + + const var_types type = divMod->TypeGet(); + assert((type == TYP_INT) || (type == TYP_I_IMPL)); + + size_t divisorValue = static_cast<size_t>(divisor->AsIntCon()->IconValue()); + + if (type == TYP_INT) + { + // Clear up the upper 32 bits of the value, they may be set to 1 because constants + // are treated as signed and stored in ssize_t which is 64 bit in size on 64 bit targets. + divisorValue &= UINT32_MAX; + } - if (isPow2(divisorValue)) + if (divisorValue == 0) + { + return next; + } + + const bool isDiv = divMod->OperIs(GT_UDIV); + + if (isPow2(divisorValue)) + { + genTreeOps newOper; + + if (isDiv) + { + newOper = GT_RSZ; + divisorValue = genLog2(divisorValue); + } + else { - genTreeOps newOper; + newOper = GT_AND; + divisorValue -= 1; + } - if (node->OperGet() == GT_UDIV) - { - newOper = GT_RSZ; - divisorValue = genLog2(divisorValue); - } - else - { - newOper = GT_AND; - divisorValue -= 1; - } + divMod->SetOper(newOper); + divisor->AsIntCon()->SetIconValue(divisorValue); + + return next; + } - node->SetOper(newOper); - divisor->gtIntCon.SetIconValue(divisorValue); + if (isDiv) + { + // If the divisor is greater or equal than 2^(N - 1) then the result is 1 + // iff the dividend is greater or equal than the divisor. + if (((type == TYP_INT) && (divisorValue > (UINT32_MAX / 2))) || + ((type == TYP_LONG) && (divisorValue > (UINT64_MAX / 2)))) + { + divMod->SetOper(GT_GE); + divMod->gtFlags |= GTF_UNSIGNED; + return next; } } -} -//------------------------------------------------------------------------ -// GetSignedMagicNumberForDivide: Generates a magic number and shift amount for -// the magic number division optimization. -// -// Arguments: -// denom - The denominator -// shift - Pointer to the shift value to be returned -// -// Returns: -// The magic number. -// -// Notes: -// This code is previously from UTC where it notes it was taken from -// _The_PowerPC_Compiler_Writer's_Guide_, pages 57-58. The paper is is based on -// is "Division by invariant integers using multiplication" by Torbjorn Granlund -// and Peter L. Montgomery in PLDI 94 +// TODO-ARM-CQ: Currently there's no GT_MULHI for ARM32/64 +#ifdef _TARGET_XARCH_ + if (!comp->opts.MinOpts() && (divisorValue >= 3)) + { + size_t magic; + bool add; + int shift; -template <typename T> -T GetSignedMagicNumberForDivide(T denom, int* shift /*out*/) -{ - // static SMAG smag; - const int bits = sizeof(T) * 8; - const int bits_minus_1 = bits - 1; - - typedef typename jitstd::make_unsigned<T>::type UT; - - const UT two_nminus1 = UT(1) << bits_minus_1; - - int p; - UT absDenom; - UT absNc; - UT delta; - UT q1; - UT r1; - UT r2; - UT q2; - UT t; - T result_magic; - int result_shift; - int iters = 0; - - absDenom = abs(denom); - t = two_nminus1 + ((unsigned int)denom >> 31); - absNc = t - 1 - (t % absDenom); // absolute value of nc - p = bits_minus_1; // initialize p - q1 = two_nminus1 / absNc; // initialize q1 = 2^p / abs(nc) - r1 = two_nminus1 - (q1 * absNc); // initialize r1 = rem(2^p, abs(nc)) - q2 = two_nminus1 / absDenom; // initialize q1 = 2^p / abs(denom) - r2 = two_nminus1 - (q2 * absDenom); // initialize r1 = rem(2^p, abs(denom)) - - do - { - iters++; - p++; - q1 *= 2; // update q1 = 2^p / abs(nc) - r1 *= 2; // update r1 = rem(2^p / abs(nc)) - - if (r1 >= absNc) - { // must be unsigned comparison - q1++; - r1 -= absNc; + if (type == TYP_INT) + { + magic = MagicDivide::GetUnsigned32Magic(static_cast<uint32_t>(divisorValue), &add, &shift); + } + else + { +#ifdef _TARGET_64BIT_ + magic = MagicDivide::GetUnsigned64Magic(static_cast<uint64_t>(divisorValue), &add, &shift); +#else + unreached(); +#endif } - q2 *= 2; // update q2 = 2^p / abs(denom) - r2 *= 2; // update r2 = rem(2^p / abs(denom)) + // Depending on the "add" flag returned by GetUnsignedMagicNumberForDivide we need to generate: + // add == false (when divisor == 3 for example): + // div = (dividend MULHI magic) RSZ shift + // add == true (when divisor == 7 for example): + // mulhi = dividend MULHI magic + // div = (((dividend SUB mulhi) RSZ 1) ADD mulhi)) RSZ (shift - 1) + const bool requiresAdjustment = add; + const bool requiresDividendMultiuse = requiresAdjustment || !isDiv; + const unsigned curBBWeight = m_block->getBBWeight(comp); + unsigned dividendLclNum = BAD_VAR_NUM; - if (r2 >= absDenom) - { // must be unsigned comparison - q2++; - r2 -= absDenom; + if (requiresDividendMultiuse) + { + LIR::Use dividendUse(BlockRange(), &divMod->gtOp1, divMod); + dividendLclNum = dividendUse.ReplaceWithLclVar(comp, curBBWeight); + dividend = divMod->gtGetOp1(); } - delta = absDenom - r2; - } while (q1 < delta || (q1 == delta && r1 == 0)); + // Insert a new GT_MULHI node before the existing GT_UDIV/GT_UMOD node. + // The existing node will later be transformed into a GT_RSZ/GT_SUB that + // computes the final result. This way don't need to find and change the use + // of the existing node. + GenTree* mulhi = comp->gtNewOperNode(GT_MULHI, type, dividend, divisor); + mulhi->gtFlags |= GTF_UNSIGNED; + divisor->AsIntCon()->SetIconValue(magic); + BlockRange().InsertBefore(divMod, mulhi); - result_magic = q2 + 1; // resulting magic number - if (denom < 0) - { - result_magic = -result_magic; + if (requiresAdjustment) + { + GenTree* dividend = comp->gtNewLclvNode(dividendLclNum, type); + GenTree* sub = comp->gtNewOperNode(GT_SUB, type, dividend, mulhi); + BlockRange().InsertBefore(divMod, dividend, sub); + comp->lvaTable[dividendLclNum].incRefCnts(curBBWeight, comp); + + GenTree* one = comp->gtNewIconNode(1, TYP_INT); + GenTree* rsz = comp->gtNewOperNode(GT_RSZ, type, sub, one); + BlockRange().InsertBefore(divMod, one, rsz); + + LIR::Use mulhiUse(BlockRange(), &sub->gtOp.gtOp2, sub); + unsigned mulhiLclNum = mulhiUse.ReplaceWithLclVar(comp, curBBWeight); + + GenTree* mulhiCopy = comp->gtNewLclvNode(mulhiLclNum, type); + GenTree* add = comp->gtNewOperNode(GT_ADD, type, rsz, mulhiCopy); + BlockRange().InsertBefore(divMod, mulhiCopy, add); + comp->lvaTable[mulhiLclNum].incRefCnts(curBBWeight, comp); + + mulhi = add; + shift -= 1; + } + + GenTree* shiftBy = comp->gtNewIconNode(shift, TYP_INT); + BlockRange().InsertBefore(divMod, shiftBy); + + if (isDiv) + { + divMod->SetOper(GT_RSZ); + divMod->gtOp1 = mulhi; + divMod->gtOp2 = shiftBy; + } + else + { + GenTree* div = comp->gtNewOperNode(GT_RSZ, type, mulhi, shiftBy); + + // divisor UMOD dividend = dividend SUB (div MUL divisor) + GenTree* divisor = comp->gtNewIconNode(divisorValue, type); + GenTree* mul = comp->gtNewOperNode(GT_MUL, type, div, divisor); + GenTree* dividend = comp->gtNewLclvNode(dividendLclNum, type); + + divMod->SetOper(GT_SUB); + divMod->gtOp1 = dividend; + divMod->gtOp2 = mul; + + BlockRange().InsertBefore(divMod, div, divisor, mul, dividend); + comp->lvaTable[dividendLclNum].incRefCnts(curBBWeight, comp); + } + + return mulhi; } - *shift = p - bits; // resulting shift +#endif - return result_magic; + return next; } //------------------------------------------------------------------------ @@ -4163,18 +4231,23 @@ GenTree* Lowering::LowerSignedDivOrMod(GenTreePtr node) if (!isPow2(absDivisorValue)) { + if (comp->opts.MinOpts()) + { + return next; + } + #ifdef _TARGET_XARCH_ ssize_t magic; int shift; if (type == TYP_INT) { - magic = GetSignedMagicNumberForDivide<int32_t>(static_cast<int32_t>(divisorValue), &shift); + magic = MagicDivide::GetSigned32Magic(static_cast<int32_t>(divisorValue), &shift); } else { #ifdef _TARGET_64BIT_ - magic = GetSignedMagicNumberForDivide<int64_t>(static_cast<int64_t>(divisorValue), &shift); + magic = MagicDivide::GetSigned64Magic(static_cast<int64_t>(divisorValue), &shift); #else unreached(); #endif diff --git a/src/jit/lower.h b/src/jit/lower.h index d9bb357089..73d2be68df 100644 --- a/src/jit/lower.h +++ b/src/jit/lower.h @@ -237,7 +237,7 @@ private: // Per tree node member functions void LowerStoreInd(GenTree* node); GenTree* LowerAdd(GenTree* node); - void LowerUnsignedDivOrMod(GenTree* node); + GenTree* LowerUnsignedDivOrMod(GenTreeOp* divMod); GenTree* LowerSignedDivOrMod(GenTree* node); void LowerBlockStore(GenTreeBlk* blkNode); diff --git a/src/jit/lsraarmarch.cpp b/src/jit/lsraarmarch.cpp index e0acb51849..f58da4a671 100644 --- a/src/jit/lsraarmarch.cpp +++ b/src/jit/lsraarmarch.cpp @@ -59,10 +59,17 @@ void Lowering::TreeNodeInfoInitStoreLoc(GenTreeLclVarCommon* storeLoc) // Call node srcCandidates = Bitwise-OR(allregs(GetReturnRegType(i))) for all i=0..RetRegCount-1 regMaskTP srcCandidates = m_lsra->allMultiRegCallNodeRegs(call); op1->gtLsraInfo.setSrcCandidates(m_lsra, srcCandidates); - return; } - - CheckImmedAndMakeContained(storeLoc, op1); +#if defined(_TARGET_ARM_) + else if (op1->OperGet() == GT_LONG) + { + op1->SetContained(); + } +#endif // _TARGET_ARM_ + else + { + CheckImmedAndMakeContained(storeLoc, op1); + } } //------------------------------------------------------------------------ @@ -674,6 +681,7 @@ void Lowering::TreeNodeInfoInitPutArgStk(GenTreePutArgStk* argNode, fgArgTabEntr { // We consume all of the items in the GT_FIELD_LIST argNode->gtLsraInfo.srcCount = info->numSlots; + putArgChild->SetContained(); } else { diff --git a/src/jit/stackfp.cpp b/src/jit/stackfp.cpp index e6d4c9e9c9..594c73e588 100644 --- a/src/jit/stackfp.cpp +++ b/src/jit/stackfp.cpp @@ -411,8 +411,8 @@ void CodeGen::genCodeForPrologStackFP() if (pState && pState->m_uStackSize) { - VARSET_TP VARSET_INIT_NOCOPY(liveEnregIn, VarSetOps::Intersection(compiler, compiler->fgFirstBB->bbLiveIn, - compiler->optAllFPregVars)); + VARSET_TP liveEnregIn( + VarSetOps::Intersection(compiler, compiler->fgFirstBB->bbLiveIn, compiler->optAllFPregVars)); unsigned i; #ifdef DEBUG @@ -1066,8 +1066,7 @@ void CodeGen::genSetupStateStackFP(BasicBlock* block) } // Update liveset and lock enregistered live vars on entry - VARSET_TP VARSET_INIT_NOCOPY(liveSet, - VarSetOps::Intersection(compiler, block->bbLiveIn, compiler->optAllFPregVars)); + VARSET_TP liveSet(VarSetOps::Intersection(compiler, block->bbLiveIn, compiler->optAllFPregVars)); if (!VarSetOps::IsEmpty(compiler, liveSet)) { @@ -2912,7 +2911,7 @@ void CodeGen::genCondJumpLngStackFP(GenTreePtr cond, BasicBlock* jumpTrue, Basic void CodeGen::genQMarkRegVarTransition(GenTreePtr nextNode, VARSET_VALARG_TP liveset) { // Kill any vars that may die in the transition - VARSET_TP VARSET_INIT_NOCOPY(newLiveSet, VarSetOps::Intersection(compiler, liveset, compiler->optAllFPregVars)); + VARSET_TP newLiveSet(VarSetOps::Intersection(compiler, liveset, compiler->optAllFPregVars)); regMaskTP liveRegIn = genRegMaskFromLivenessStackFP(newLiveSet); genCodeForTransitionFromMask(&compCurFPState, liveRegIn); @@ -3088,8 +3087,8 @@ void CodeGen::genTableSwitchStackFP(regNumber reg, unsigned jumpCnt, BasicBlock* // Only come here when we have to do something special for the FPU stack! // assert(!compCurFPState.IsEmpty()); - VARSET_TP VARSET_INIT_NOCOPY(liveInFP, VarSetOps::MakeEmpty(compiler)); - VARSET_TP VARSET_INIT_NOCOPY(liveOutFP, VarSetOps::MakeEmpty(compiler)); + VARSET_TP liveInFP(VarSetOps::MakeEmpty(compiler)); + VARSET_TP liveOutFP(VarSetOps::MakeEmpty(compiler)); for (unsigned i = 0; i < jumpCnt; i++) { VarSetOps::Assign(compiler, liveInFP, jumpTab[i]->bbLiveIn); @@ -3687,7 +3686,7 @@ regNumber Compiler::raRegForVarStackFP(unsigned varTrackedIndex) void Compiler::raAddPayloadStackFP(VARSET_VALARG_TP maskArg, unsigned weight) { - VARSET_TP VARSET_INIT_NOCOPY(mask, VarSetOps::Intersection(this, maskArg, optAllFloatVars)); + VARSET_TP mask(VarSetOps::Intersection(this, maskArg, optAllFloatVars)); if (VarSetOps::IsEmpty(this, mask)) { return; @@ -3854,7 +3853,7 @@ void Compiler::raEnregisterVarsPrePassStackFP() // // // - VARSET_TP VARSET_INIT_NOCOPY(blockLiveOutFloats, VarSetOps::MakeEmpty(this)); + VARSET_TP blockLiveOutFloats(VarSetOps::MakeEmpty(this)); for (block = fgFirstBB; block; block = block->bbNext) { compCurBB = block; @@ -3936,7 +3935,7 @@ void Compiler::raEnregisterVarsPrePassStackFP() } } - VARSET_TP VARSET_INIT(this, liveSet, block->bbLiveIn); + VARSET_TP liveSet(VarSetOps::MakeCopy(this, block->bbLiveIn)); for (GenTreePtr stmt = block->FirstNonPhiDef(); stmt; stmt = stmt->gtNext) { assert(stmt->gtOper == GT_STMT); @@ -4128,7 +4127,7 @@ void Compiler::raEnregisterVarsPostPassStackFP() } */ - VARSET_TP VARSET_INIT(this, lastlife, block->bbLiveIn); + VARSET_TP lastlife(VarSetOps::MakeCopy(this, block->bbLiveIn)); for (GenTreePtr stmt = block->FirstNonPhiDef(); stmt; stmt = stmt->gtNext) { assert(stmt->gtOper == GT_STMT); @@ -4438,7 +4437,7 @@ void Compiler::raEnregisterVarsStackFP() // Create interferences with other variables. assert(VarSetOps::IsEmpty(this, VarSetOps::Diff(this, raLclRegIntfFloat[(int)reg], optAllFloatVars))); - VARSET_TP VARSET_INIT_NOCOPY(intfFloats, VarSetOps::Intersection(this, lvaVarIntf[varIndex], optAllFloatVars)); + VARSET_TP intfFloats(VarSetOps::Intersection(this, lvaVarIntf[varIndex], optAllFloatVars)); VarSetOps::UnionD(this, raLclRegIntfFloat[reg], intfFloats); diff --git a/src/jit/target.h b/src/jit/target.h index ac5456e8f8..2db02cb000 100644 --- a/src/jit/target.h +++ b/src/jit/target.h @@ -56,113 +56,115 @@ // REG_NA - Used to indicate that a register is either not yet assigned or not required. // #if defined(_TARGET_ARM_) -DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) +enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, #define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" - REG_COUNT, REG_NA = REG_COUNT, ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) -} -END_DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) + REG_COUNT, + REG_NA = REG_COUNT, + ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) +}; -DECLARE_TYPED_ENUM(_regMask_enum, unsigned __int64) +enum _regMask_enum : unsigned __int64 { RBM_NONE = 0, #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, #define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" -} -END_DECLARE_TYPED_ENUM(_regMask_enum, unsigned __int64) +}; #elif defined(_TARGET_ARM64_) -DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) +enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, xname, wname) REG_##name = rnum, #define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" - REG_COUNT, REG_NA = REG_COUNT, ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) -} -END_DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) + REG_COUNT, + REG_NA = REG_COUNT, + ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) +}; -DECLARE_TYPED_ENUM(_regMask_enum, unsigned __int64) +enum _regMask_enum : unsigned __int64 { RBM_NONE = 0, #define REGDEF(name, rnum, mask, xname, wname) RBM_##name = mask, #define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" -} -END_DECLARE_TYPED_ENUM(_regMask_enum, unsigned __int64) +}; #elif defined(_TARGET_AMD64_) -DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) +enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, #define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" - REG_COUNT, REG_NA = REG_COUNT, ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) -} -END_DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) + REG_COUNT, + REG_NA = REG_COUNT, + ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) +}; -DECLARE_TYPED_ENUM(_regMask_enum, unsigned) +enum _regMask_enum : unsigned { RBM_NONE = 0, #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, #define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" -} -END_DECLARE_TYPED_ENUM(_regMask_enum, unsigned) +}; #elif defined(_TARGET_X86_) #ifndef LEGACY_BACKEND -DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) +enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, #define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" - REG_COUNT, REG_NA = REG_COUNT, ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) -} -END_DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) + REG_COUNT, + REG_NA = REG_COUNT, + ACTUAL_REG_COUNT = REG_COUNT - 1 // everything but REG_STK (only real regs) +}; -DECLARE_TYPED_ENUM(_regMask_enum, unsigned) +enum _regMask_enum : unsigned { RBM_NONE = 0, #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, #define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" -} -END_DECLARE_TYPED_ENUM(_regMask_enum, unsigned) +}; + #else // LEGACY_BACKEND -DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) +enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, #define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" - REG_COUNT, REG_NA = REG_COUNT, - ACTUAL_REG_COUNT = REG_COUNT - 1, // everything but REG_STK (only real regs) + REG_COUNT, + REG_NA = REG_COUNT, + ACTUAL_REG_COUNT = REG_COUNT - 1, // everything but REG_STK (only real regs) #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, #include "registerfp.h" - REG_FPCOUNT, REG_FPNONE = REG_FPCOUNT, + REG_FPCOUNT, + REG_FPNONE = REG_FPCOUNT, #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, #include "registerxmm.h" - REG_XMMCOUNT -} -END_DECLARE_TYPED_ENUM(_regNumber_enum, unsigned) + REG_XMMCOUNT +}; -DECLARE_TYPED_ENUM(_regMask_enum, unsigned) +enum _regMask_enum : unsigned { RBM_NONE = 0, @@ -175,8 +177,7 @@ DECLARE_TYPED_ENUM(_regMask_enum, unsigned) #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, #include "registerxmm.h" -} -END_DECLARE_TYPED_ENUM(_regMask_enum, unsigned) +}; #endif // LEGACY_BACKEND #else @@ -212,7 +213,7 @@ C_ASSERT(REG_COUNT < REG_PAIR_FIRST); // make sure the register numbers (includi #define REG_PAIR_FIRST 0 #endif -DECLARE_TYPED_ENUM(_regPairNo_enum, unsigned) +enum _regPairNo_enum : unsigned { #define PAIRDEF(rlo, rhi) REG_PAIR_##rlo##rhi = REG_##rlo + (REG_##rhi << REG_PAIR_NBITS) + REG_PAIR_FIRST, #include "regpair.h" @@ -220,8 +221,7 @@ DECLARE_TYPED_ENUM(_regPairNo_enum, unsigned) REG_PAIR_LAST = (REG_COUNT - 1) + ((REG_COUNT - 1) << REG_PAIR_NBITS) + REG_PAIR_FIRST, REG_PAIR_NONE = REG_PAIR_LAST + 1 -} -END_DECLARE_TYPED_ENUM(_regPairNo_enum, unsigned) +}; enum regPairMask { diff --git a/src/jit/utils.cpp b/src/jit/utils.cpp index 9fbe394a21..bdf1554019 100644 --- a/src/jit/utils.cpp +++ b/src/jit/utils.cpp @@ -1808,3 +1808,337 @@ float FloatingPointUtils::round(float x) return _copysignf(flrTempVal, x); } + +namespace MagicDivide +{ +template <int TableBase = 0, int TableSize, typename Magic> +static const Magic* TryGetMagic(const Magic (&table)[TableSize], typename Magic::DivisorType index) +{ + if ((index < TableBase) || (TableBase + TableSize <= index)) + { + return nullptr; + } + + const Magic* p = &table[index - TableBase]; + + if (p->magic == 0) + { + return nullptr; + } + + return p; +}; + +template <typename T> +struct UnsignedMagic +{ + typedef T DivisorType; + + T magic; + bool add; + int shift; +}; + +template <typename T> +const UnsignedMagic<T>* TryGetUnsignedMagic(T divisor) +{ + return nullptr; +} + +template <> +const UnsignedMagic<uint32_t>* TryGetUnsignedMagic(uint32_t divisor) +{ + static const UnsignedMagic<uint32_t> table[]{ + {0xaaaaaaab, false, 1}, // 3 + {}, + {0xcccccccd, false, 2}, // 5 + {0xaaaaaaab, false, 2}, // 6 + {0x24924925, true, 3}, // 7 + {}, + {0x38e38e39, false, 1}, // 9 + {0xcccccccd, false, 3}, // 10 + {0xba2e8ba3, false, 3}, // 11 + {0xaaaaaaab, false, 3}, // 12 + }; + + return TryGetMagic<3>(table, divisor); +} + +template <> +const UnsignedMagic<uint64_t>* TryGetUnsignedMagic(uint64_t divisor) +{ + static const UnsignedMagic<uint64_t> table[]{ + {0xaaaaaaaaaaaaaaab, false, 1}, // 3 + {}, + {0xcccccccccccccccd, false, 2}, // 5 + {0xaaaaaaaaaaaaaaab, false, 2}, // 6 + {0x2492492492492493, true, 3}, // 7 + {}, + {0xe38e38e38e38e38f, false, 3}, // 9 + {0xcccccccccccccccd, false, 3}, // 10 + {0x2e8ba2e8ba2e8ba3, false, 1}, // 11 + {0xaaaaaaaaaaaaaaab, false, 3}, // 12 + }; + + return TryGetMagic<3>(table, divisor); +} + +//------------------------------------------------------------------------ +// GetUnsignedMagic: Generates a magic number and shift amount for the magic +// number unsigned division optimization. +// +// Arguments: +// d - The divisor +// add - Pointer to a flag indicating the kind of code to generate +// shift - Pointer to the shift value to be returned +// +// Returns: +// The magic number. +// +// Notes: +// This code is adapted from _The_PowerPC_Compiler_Writer's_Guide_, pages 57-58. +// The paper is based on "Division by invariant integers using multiplication" +// by Torbjorn Granlund and Peter L. Montgomery in PLDI 94 + +template <typename T> +T GetUnsignedMagic(T d, bool* add /*out*/, int* shift /*out*/) +{ + assert((d >= 3) && !isPow2(d)); + + const UnsignedMagic<T>* magic = TryGetUnsignedMagic(d); + + if (magic != nullptr) + { + *shift = magic->shift; + *add = magic->add; + return magic->magic; + } + + typedef typename jitstd::make_signed<T>::type ST; + + const unsigned bits = sizeof(T) * 8; + const unsigned bitsMinus1 = bits - 1; + const T twoNMinus1 = T(1) << bitsMinus1; + + *add = false; + const T nc = -ST(1) - -ST(d) % ST(d); + unsigned p = bitsMinus1; + T q1 = twoNMinus1 / nc; + T r1 = twoNMinus1 - (q1 * nc); + T q2 = (twoNMinus1 - 1) / d; + T r2 = (twoNMinus1 - 1) - (q2 * d); + T delta; + + do + { + p++; + + if (r1 >= (nc - r1)) + { + q1 = 2 * q1 + 1; + r1 = 2 * r1 - nc; + } + else + { + q1 = 2 * q1; + r1 = 2 * r1; + } + + if ((r2 + 1) >= (d - r2)) + { + if (q2 >= (twoNMinus1 - 1)) + { + *add = true; + } + + q2 = 2 * q2 + 1; + r2 = 2 * r2 + 1 - d; + } + else + { + if (q2 >= twoNMinus1) + { + *add = true; + } + + q2 = 2 * q2; + r2 = 2 * r2 + 1; + } + + delta = d - 1 - r2; + + } while ((p < (bits * 2)) && ((q1 < delta) || ((q1 == delta) && (r1 == 0)))); + + *shift = p - bits; // resulting shift + return q2 + 1; // resulting magic number +} + +uint32_t GetUnsigned32Magic(uint32_t d, bool* add /*out*/, int* shift /*out*/) +{ + return GetUnsignedMagic<uint32_t>(d, add, shift); +} + +#ifdef _TARGET_64BIT_ +uint64_t GetUnsigned64Magic(uint64_t d, bool* add /*out*/, int* shift /*out*/) +{ + return GetUnsignedMagic<uint64_t>(d, add, shift); +} +#endif + +template <typename T> +struct SignedMagic +{ + typedef T DivisorType; + + T magic; + int shift; +}; + +template <typename T> +const SignedMagic<T>* TryGetSignedMagic(T divisor) +{ + return nullptr; +} + +template <> +const SignedMagic<int32_t>* TryGetSignedMagic(int32_t divisor) +{ + static const SignedMagic<int32_t> table[]{ + {0x55555556, 0}, // 3 + {}, + {0x66666667, 1}, // 5 + {0x2aaaaaab, 0}, // 6 + {0x92492493, 2}, // 7 + {}, + {0x38e38e39, 1}, // 9 + {0x66666667, 2}, // 10 + {0x2e8ba2e9, 1}, // 11 + {0x2aaaaaab, 1}, // 12 + }; + + return TryGetMagic<3>(table, divisor); +} + +template <> +const SignedMagic<int64_t>* TryGetSignedMagic(int64_t divisor) +{ + static const SignedMagic<int64_t> table[]{ + {0x5555555555555556, 0}, // 3 + {}, + {0x6666666666666667, 1}, // 5 + {0x2aaaaaaaaaaaaaab, 0}, // 6 + {0x4924924924924925, 1}, // 7 + {}, + {0x1c71c71c71c71c72, 0}, // 9 + {0x6666666666666667, 2}, // 10 + {0x2e8ba2e8ba2e8ba3, 1}, // 11 + {0x2aaaaaaaaaaaaaab, 1}, // 12 + }; + + return TryGetMagic<3>(table, divisor); +} + +//------------------------------------------------------------------------ +// GetSignedMagic: Generates a magic number and shift amount for +// the magic number division optimization. +// +// Arguments: +// denom - The denominator +// shift - Pointer to the shift value to be returned +// +// Returns: +// The magic number. +// +// Notes: +// This code is previously from UTC where it notes it was taken from +// _The_PowerPC_Compiler_Writer's_Guide_, pages 57-58. The paper is is based on +// is "Division by invariant integers using multiplication" by Torbjorn Granlund +// and Peter L. Montgomery in PLDI 94 + +template <typename T> +T GetSignedMagic(T denom, int* shift /*out*/) +{ + const SignedMagic<T>* magic = TryGetSignedMagic(denom); + + if (magic != nullptr) + { + *shift = magic->shift; + return magic->magic; + } + + const int bits = sizeof(T) * 8; + const int bits_minus_1 = bits - 1; + + typedef typename jitstd::make_unsigned<T>::type UT; + + const UT two_nminus1 = UT(1) << bits_minus_1; + + int p; + UT absDenom; + UT absNc; + UT delta; + UT q1; + UT r1; + UT r2; + UT q2; + UT t; + T result_magic; + int result_shift; + int iters = 0; + + absDenom = abs(denom); + t = two_nminus1 + ((unsigned int)denom >> 31); + absNc = t - 1 - (t % absDenom); // absolute value of nc + p = bits_minus_1; // initialize p + q1 = two_nminus1 / absNc; // initialize q1 = 2^p / abs(nc) + r1 = two_nminus1 - (q1 * absNc); // initialize r1 = rem(2^p, abs(nc)) + q2 = two_nminus1 / absDenom; // initialize q1 = 2^p / abs(denom) + r2 = two_nminus1 - (q2 * absDenom); // initialize r1 = rem(2^p, abs(denom)) + + do + { + iters++; + p++; + q1 *= 2; // update q1 = 2^p / abs(nc) + r1 *= 2; // update r1 = rem(2^p / abs(nc)) + + if (r1 >= absNc) + { // must be unsigned comparison + q1++; + r1 -= absNc; + } + + q2 *= 2; // update q2 = 2^p / abs(denom) + r2 *= 2; // update r2 = rem(2^p / abs(denom)) + + if (r2 >= absDenom) + { // must be unsigned comparison + q2++; + r2 -= absDenom; + } + + delta = absDenom - r2; + } while (q1 < delta || (q1 == delta && r1 == 0)); + + result_magic = q2 + 1; // resulting magic number + if (denom < 0) + { + result_magic = -result_magic; + } + *shift = p - bits; // resulting shift + + return result_magic; +} + +int32_t GetSigned32Magic(int32_t d, int* shift /*out*/) +{ + return GetSignedMagic<int32_t>(d, shift); +} + +#ifdef _TARGET_64BIT_ +int64_t GetSigned64Magic(int64_t d, int* shift /*out*/) +{ + return GetSignedMagic<int64_t>(d, shift); +} +#endif +} diff --git a/src/jit/utils.h b/src/jit/utils.h index b41cf84a1e..1a76f5b274 100644 --- a/src/jit/utils.h +++ b/src/jit/utils.h @@ -718,4 +718,16 @@ private: CritSecHolder& operator=(const CritSecHolder&) = delete; }; +namespace MagicDivide +{ +uint32_t GetUnsigned32Magic(uint32_t d, bool* add /*out*/, int* shift /*out*/); +#ifdef _TARGET_64BIT_ +uint64_t GetUnsigned64Magic(uint64_t d, bool* add /*out*/, int* shift /*out*/); +#endif +int32_t GetSigned32Magic(int32_t d, int* shift /*out*/); +#ifdef _TARGET_64BIT_ +int64_t GetSigned64Magic(int64_t d, int* shift /*out*/); +#endif +} + #endif // _UTILS_H_ diff --git a/src/jit/valuenum.h b/src/jit/valuenum.h index fcf6d8699a..ac7e52e76c 100644 --- a/src/jit/valuenum.h +++ b/src/jit/valuenum.h @@ -872,20 +872,19 @@ private: // The base VN of the next chunk to be allocated. Should always be a multiple of ChunkSize. ValueNum m_nextChunkBase; - DECLARE_TYPED_ENUM(ChunkExtraAttribs, BYTE) - { - CEA_None, // No extra attributes. - CEA_Const, // This chunk contains constant values. - CEA_Handle, // This chunk contains handle constants. - CEA_NotAField, // This chunk contains "not a field" values. - CEA_Func0, // Represents functions of arity 0. - CEA_Func1, // ...arity 1. - CEA_Func2, // ...arity 2. - CEA_Func3, // ...arity 3. - CEA_Func4, // ...arity 4. - CEA_Count - } - END_DECLARE_TYPED_ENUM(ChunkExtraAttribs, BYTE); + enum ChunkExtraAttribs : BYTE + { + CEA_None, // No extra attributes. + CEA_Const, // This chunk contains constant values. + CEA_Handle, // This chunk contains handle constants. + CEA_NotAField, // This chunk contains "not a field" values. + CEA_Func0, // Represents functions of arity 0. + CEA_Func1, // ...arity 1. + CEA_Func2, // ...arity 2. + CEA_Func3, // ...arity 3. + CEA_Func4, // ...arity 4. + CEA_Count + }; // A "Chunk" holds "ChunkSize" value numbers, starting at "m_baseVN". All of these share the same // "m_typ" and "m_attribs". These properties determine the interpretation of "m_defs", as discussed below. diff --git a/src/jit/vartype.h b/src/jit/vartype.h index 550aeb9c5b..e75bc2adf1 100644 --- a/src/jit/vartype.h +++ b/src/jit/vartype.h @@ -20,7 +20,7 @@ enum var_types_classification VTF_S = 0x0040, // is a struct type }; -DECLARE_TYPED_ENUM(var_types, BYTE) +enum var_types : BYTE { #define DEF_TP(tn, nm, jitType, verType, sz, sze, asze, st, al, tf, howUsed) TYP_##tn, #include "typelist.h" @@ -28,9 +28,8 @@ DECLARE_TYPED_ENUM(var_types, BYTE) TYP_COUNT, - TYP_lastIntrins = TYP_DOUBLE -} -END_DECLARE_TYPED_ENUM(var_types, BYTE) + TYP_lastIntrins = TYP_DOUBLE +}; /***************************************************************************** * C-style pointers are implemented as TYP_INT or TYP_LONG depending on the diff --git a/src/mscorlib/shared/System/Collections/DictionaryEntry.cs b/src/mscorlib/shared/System/Collections/DictionaryEntry.cs index 0815c93319..3c1c0befa3 100644 --- a/src/mscorlib/shared/System/Collections/DictionaryEntry.cs +++ b/src/mscorlib/shared/System/Collections/DictionaryEntry.cs @@ -12,8 +12,8 @@ namespace System.Collections [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct DictionaryEntry { - private Object _key; - private Object _value; + private Object _key; // Do not rename (binary serialization) + private Object _value; // Do not rename (binary serialization) // Constructs a new DictionaryEnumerator by setting the Key // and Value fields appropriately. diff --git a/src/mscorlib/shared/System/Collections/Generic/KeyValuePair.cs b/src/mscorlib/shared/System/Collections/Generic/KeyValuePair.cs index 6280218063..aeafecd958 100644 --- a/src/mscorlib/shared/System/Collections/Generic/KeyValuePair.cs +++ b/src/mscorlib/shared/System/Collections/Generic/KeyValuePair.cs @@ -49,8 +49,8 @@ namespace System.Collections.Generic [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct KeyValuePair<TKey, TValue> { - private TKey key; // DO NOT change the field name, it's required for compatibility with desktop .NET as it appears in serialization payload. - private TValue value; // DO NOT change the field name, it's required for compatibility with desktop .NET as it appears in serialization payload. + private TKey key; // Do not rename (binary serialization) + private TValue value; // Do not rename (binary serialization) public KeyValuePair(TKey key, TValue value) { diff --git a/src/mscorlib/shared/System/DateTime.cs b/src/mscorlib/shared/System/DateTime.cs index 02f07d2865..4fd9727fcd 100644 --- a/src/mscorlib/shared/System/DateTime.cs +++ b/src/mscorlib/shared/System/DateTime.cs @@ -126,8 +126,8 @@ namespace System private const UInt64 KindLocalAmbiguousDst = 0xC000000000000000; private const Int32 KindShift = 62; - private const String TicksField = "ticks"; - private const String DateDataField = "_dateData"; + private const String TicksField = "ticks"; // Do not rename (binary serialization) + private const String DateDataField = "dateData"; // Do not rename (binary serialization) // The data is stored as an unsigned 64-bit integeter // Bits 01-62: The value of 100-nanosecond ticks where 0 represents 1/1/0001 12:00am, up until the value diff --git a/src/mscorlib/shared/System/DateTimeOffset.cs b/src/mscorlib/shared/System/DateTimeOffset.cs index 6df35fed1e..ab35bdb0fe 100644 --- a/src/mscorlib/shared/System/DateTimeOffset.cs +++ b/src/mscorlib/shared/System/DateTimeOffset.cs @@ -574,8 +574,8 @@ namespace System throw new ArgumentNullException(nameof(info)); } - info.AddValue("DateTime", _dateTime); - info.AddValue("OffsetMinutes", _offsetMinutes); + info.AddValue("DateTime", _dateTime); // Do not rename (binary serialization) + info.AddValue("OffsetMinutes", _offsetMinutes); // Do not rename (binary serialization) } @@ -586,8 +586,8 @@ namespace System throw new ArgumentNullException(nameof(info)); } - _dateTime = (DateTime)info.GetValue("DateTime", typeof(DateTime)); - _offsetMinutes = (Int16)info.GetValue("OffsetMinutes", typeof(Int16)); + _dateTime = (DateTime)info.GetValue("DateTime", typeof(DateTime)); // Do not rename (binary serialization) + _offsetMinutes = (Int16)info.GetValue("OffsetMinutes", typeof(Int16)); // Do not rename (binary serialization) } // Returns the hash code for this DateTimeOffset. diff --git a/src/mscorlib/shared/System/StringComparer.cs b/src/mscorlib/shared/System/StringComparer.cs index 765f43ea1a..4b6193c180 100644 --- a/src/mscorlib/shared/System/StringComparer.cs +++ b/src/mscorlib/shared/System/StringComparer.cs @@ -174,28 +174,30 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class CultureAwareComparer : StringComparer { - private readonly CompareInfo _compareInfo; - private readonly CompareOptions _options; + private readonly CompareInfo _compareInfo; // Do not rename (binary serialization) + private readonly bool _ignoreCase; // Do not rename (binary serialization) internal CultureAwareComparer(CultureInfo culture, bool ignoreCase) { _compareInfo = culture.CompareInfo; - _options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + _ignoreCase = ignoreCase; } + private CompareOptions Options => _ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + public override int Compare(string x, string y) { if (object.ReferenceEquals(x, y)) return 0; if (x == null) return -1; if (y == null) return 1; - return _compareInfo.Compare(x, y, _options); + return _compareInfo.Compare(x, y, Options); } public override bool Equals(string x, string y) { if (object.ReferenceEquals(x, y)) return true; if (x == null || y == null) return false; - return _compareInfo.Compare(x, y, _options) == 0; + return _compareInfo.Compare(x, y, Options) == 0; } public override int GetHashCode(string obj) @@ -204,7 +206,7 @@ namespace System { throw new ArgumentNullException(nameof(obj)); } - return _compareInfo.GetHashCodeOfString(obj, _options); + return _compareInfo.GetHashCodeOfString(obj, Options); } // Equals method for the comparer itself. @@ -213,14 +215,14 @@ namespace System CultureAwareComparer comparer = obj as CultureAwareComparer; return comparer != null && - _options == comparer._options && + _ignoreCase == comparer._ignoreCase && _compareInfo.Equals(comparer._compareInfo); } public override int GetHashCode() { int hashCode = _compareInfo.GetHashCode(); - return _options == CompareOptions.None ? hashCode : ~hashCode; + return _ignoreCase ? ~hashCode : hashCode; } } diff --git a/src/mscorlib/shared/System/Text/StringBuilder.cs b/src/mscorlib/shared/System/Text/StringBuilder.cs index 29f0cdb18b..1167016cc1 100644 --- a/src/mscorlib/shared/System/Text/StringBuilder.cs +++ b/src/mscorlib/shared/System/Text/StringBuilder.cs @@ -59,10 +59,11 @@ namespace System.Text // // internal const int DefaultCapacity = 16; - private const String CapacityField = "Capacity"; - private const String MaxCapacityField = "m_MaxCapacity"; - private const String StringValueField = "m_StringValue"; - private const String ThreadIDField = "m_currentThread"; + private const String CapacityField = "Capacity"; // Do not rename (binary serialization) + private const String MaxCapacityField = "m_MaxCapacity"; // Do not rename (binary serialization) + private const String StringValueField = "m_StringValue"; // Do not rename (binary serialization) + private const String ThreadIDField = "m_currentThread"; // Do not rename (binary serialization) + // We want to keep chunk arrays out of large object heap (< 85K bytes ~ 40K chars) to be sure. // Making the maximum chunk size big means less allocation code called, but also more waste // in unused characters and slower inserts / replaces (since you do need to slide characters over diff --git a/src/mscorlib/shared/System/Version.cs b/src/mscorlib/shared/System/Version.cs index b88db7e6b4..a2140ab137 100644 --- a/src/mscorlib/shared/System/Version.cs +++ b/src/mscorlib/shared/System/Version.cs @@ -21,10 +21,10 @@ namespace System , IComparable<Version>, IEquatable<Version> { // AssemblyName depends on the order staying the same - private readonly int _Major; - private readonly int _Minor; - private readonly int _Build = -1; - private readonly int _Revision = -1; + private readonly int _Major; // Do not rename (binary serialization) + private readonly int _Minor; // Do not rename (binary serialization) + private readonly int _Build = -1; // Do not rename (binary serialization) + private readonly int _Revision = -1; // Do not rename (binary serialization) public Version(int major, int minor, int build, int revision) { diff --git a/src/mscorlib/src/System/AggregateException.cs b/src/mscorlib/src/System/AggregateException.cs index 4f87357c20..0b840972ef 100644 --- a/src/mscorlib/src/System/AggregateException.cs +++ b/src/mscorlib/src/System/AggregateException.cs @@ -33,7 +33,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class AggregateException : Exception { - private ReadOnlyCollection<Exception> m_innerExceptions; // Complete set of exceptions. + private ReadOnlyCollection<Exception> m_innerExceptions; // Complete set of exceptions. Do not rename (binary serialization) /// <summary> /// Initializes a new instance of the <see cref="AggregateException"/> class. diff --git a/src/mscorlib/src/System/ArraySegment.cs b/src/mscorlib/src/System/ArraySegment.cs index d515b468da..7546c5bd56 100644 --- a/src/mscorlib/src/System/ArraySegment.cs +++ b/src/mscorlib/src/System/ArraySegment.cs @@ -33,9 +33,9 @@ namespace System // instantiating another generic type in addition to ArraySegment<T> for new type parameters. public static ArraySegment<T> Empty { get; } = new ArraySegment<T>(new T[0]); - private readonly T[] _array; - private readonly int _offset; - private readonly int _count; + private readonly T[] _array; // Do not rename (binary serialization) + private readonly int _offset; // Do not rename (binary serialization) + private readonly int _count; // Do not rename (binary serialization) public ArraySegment(T[] array) { diff --git a/src/mscorlib/src/System/Collections/Comparer.cs b/src/mscorlib/src/System/Collections/Comparer.cs index 76e19e77f1..00259e6bdb 100644 --- a/src/mscorlib/src/System/Collections/Comparer.cs +++ b/src/mscorlib/src/System/Collections/Comparer.cs @@ -13,21 +13,17 @@ ** ===========================================================*/ -using System; using System.Globalization; -using System.Runtime.Serialization; using System.Diagnostics.Contracts; namespace System.Collections { - internal sealed class Comparer : IComparer, ISerializable + internal sealed class Comparer : IComparer { private CompareInfo m_compareInfo; public static readonly Comparer Default = new Comparer(CultureInfo.CurrentCulture); public static readonly Comparer DefaultInvariant = new Comparer(CultureInfo.InvariantCulture); - private const String CompareInfoName = "CompareInfo"; - private Comparer() { m_compareInfo = null; @@ -73,10 +69,5 @@ namespace System.Collections throw new ArgumentException(SR.Argument_ImplementIComparable); } - - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - throw new PlatformNotSupportedException(); - } } } diff --git a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs index 34ee7a3ee4..50724017dd 100644 --- a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs @@ -75,10 +75,10 @@ namespace System.Collections.Generic private Object _syncRoot; // constants for serialization - private const String VersionName = "Version"; - private const String HashSizeName = "HashSize"; // Must save buckets.Length - private const String KeyValuePairsName = "KeyValuePairs"; - private const String ComparerName = "Comparer"; + private const String VersionName = "Version"; // Do not rename (binary serialization) + private const String HashSizeName = "HashSize"; // Do not rename (binary serialization). Must save buckets.Length + private const String KeyValuePairsName = "KeyValuePairs"; // Do not rename (binary serialization) + private const String ComparerName = "Comparer"; // Do not rename (binary serialization) public Dictionary() : this(0, null) { } diff --git a/src/mscorlib/src/System/Collections/Generic/List.cs b/src/mscorlib/src/System/Collections/Generic/List.cs index f94acb8fdd..2031ddc6ed 100644 --- a/src/mscorlib/src/System/Collections/Generic/List.cs +++ b/src/mscorlib/src/System/Collections/Generic/List.cs @@ -35,10 +35,10 @@ namespace System.Collections.Generic { private const int _defaultCapacity = 4; - private T[] _items; + private T[] _items; // Do not rename (binary serialization) [ContractPublicPropertyName("Count")] - private int _size; - private int _version; + private int _size; // Do not rename (binary serialization) + private int _version; // Do not rename (binary serialization) [NonSerialized] private Object _syncRoot; diff --git a/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs b/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs index 87f180929f..17eb89a2b2 100644 --- a/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs +++ b/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs @@ -23,9 +23,9 @@ namespace System.Collections [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal class ListDictionaryInternal : IDictionary { - private DictionaryNode head; - private int version; - private int count; + private DictionaryNode head; // Do not rename (binary serialization) + private int version; // Do not rename (binary serialization) + private int count; // Do not rename (binary serialization) [NonSerialized] private Object _syncRoot; diff --git a/src/mscorlib/src/System/Collections/ObjectModel/Collection.cs b/src/mscorlib/src/System/Collections/ObjectModel/Collection.cs index b2668edf83..8e5de70e72 100644 --- a/src/mscorlib/src/System/Collections/ObjectModel/Collection.cs +++ b/src/mscorlib/src/System/Collections/ObjectModel/Collection.cs @@ -18,7 +18,7 @@ namespace System.Collections.ObjectModel [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Collection<T> : IList<T>, IList, IReadOnlyList<T> { - private IList<T> items; + private IList<T> items; // Do not rename (binary serialization) [NonSerialized] private Object _syncRoot; diff --git a/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs b/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs index e91ecdc4d3..03c7d45e16 100644 --- a/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs +++ b/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs @@ -18,7 +18,7 @@ namespace System.Collections.ObjectModel [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ReadOnlyCollection<T> : IList<T>, IList, IReadOnlyList<T> { - private IList<T> list; + private IList<T> list; // Do not rename (binary serialization) [NonSerialized] private Object _syncRoot; diff --git a/src/mscorlib/src/System/Decimal.cs b/src/mscorlib/src/System/Decimal.cs index 68cd503d28..b120a368da 100644 --- a/src/mscorlib/src/System/Decimal.cs +++ b/src/mscorlib/src/System/Decimal.cs @@ -133,7 +133,8 @@ namespace System // positive and 1 meaning negative. // // NOTE: Do not change the order in which these fields are declared. The - // native methods in this class rely on this particular order. + // native methods in this class rely on this particular order. + // Do not rename (binary serialization). private int flags; private int hi; private int lo; diff --git a/src/mscorlib/src/System/Exception.cs b/src/mscorlib/src/System/Exception.cs index 63bcbeb36d..725adac4a9 100644 --- a/src/mscorlib/src/System/Exception.cs +++ b/src/mscorlib/src/System/Exception.cs @@ -76,17 +76,17 @@ namespace System throw new ArgumentNullException(nameof(info)); Contract.EndContractBlock(); - _className = info.GetString("ClassName"); - _message = info.GetString("Message"); - _data = (IDictionary)(info.GetValueNoThrow("Data", typeof(IDictionary))); - _innerException = (Exception)(info.GetValue("InnerException", typeof(Exception))); - _helpURL = info.GetString("HelpURL"); - _stackTraceString = info.GetString("StackTraceString"); - _remoteStackTraceString = info.GetString("RemoteStackTraceString"); - _remoteStackIndex = info.GetInt32("RemoteStackIndex"); - - HResult = info.GetInt32("HResult"); - _source = info.GetString("Source"); + _className = info.GetString("ClassName"); // Do not rename (binary serialization) + _message = info.GetString("Message"); // Do not rename (binary serialization) + _data = (IDictionary)(info.GetValueNoThrow("Data", typeof(IDictionary))); // Do not rename (binary serialization) + _innerException = (Exception)(info.GetValue("InnerException", typeof(Exception))); // Do not rename (binary serialization) + _helpURL = info.GetString("HelpURL"); // Do not rename (binary serialization) + _stackTraceString = info.GetString("StackTraceString"); // Do not rename (binary serialization) + _remoteStackTraceString = info.GetString("RemoteStackTraceString"); // Do not rename (binary serialization) + _remoteStackIndex = info.GetInt32("RemoteStackIndex"); // Do not rename (binary serialization) + + HResult = info.GetInt32("HResult"); // Do not rename (binary serialization) + _source = info.GetString("Source"); // Do not rename (binary serialization) // Get the WatsonBuckets that were serialized - this is particularly // done to support exceptions going across AD transitions. @@ -94,7 +94,7 @@ namespace System // We use the no throw version since we could be deserializing a pre-V4 // exception object that may not have this entry. In such a case, we would // get null. - _watsonBuckets = (Object)info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); + _watsonBuckets = (Object)info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); // Do not rename (binary serialization) if (_className == null || HResult == 0) @@ -460,20 +460,20 @@ namespace System _source = Source; // Set the Source information correctly before serialization } - info.AddValue("ClassName", GetClassName(), typeof(String)); - info.AddValue("Message", _message, typeof(String)); - info.AddValue("Data", _data, typeof(IDictionary)); - info.AddValue("InnerException", _innerException, typeof(Exception)); - info.AddValue("HelpURL", _helpURL, typeof(String)); - info.AddValue("StackTraceString", tempStackTraceString, typeof(String)); - info.AddValue("RemoteStackTraceString", _remoteStackTraceString, typeof(String)); - info.AddValue("RemoteStackIndex", _remoteStackIndex, typeof(Int32)); - info.AddValue("ExceptionMethod", null, typeof(String)); - info.AddValue("HResult", HResult); - info.AddValue("Source", _source, typeof(String)); + info.AddValue("ClassName", GetClassName(), typeof(String)); // Do not rename (binary serialization) + info.AddValue("Message", _message, typeof(String)); // Do not rename (binary serialization) + info.AddValue("Data", _data, typeof(IDictionary)); // Do not rename (binary serialization) + info.AddValue("InnerException", _innerException, typeof(Exception)); // Do not rename (binary serialization) + info.AddValue("HelpURL", _helpURL, typeof(String)); // Do not rename (binary serialization) + info.AddValue("StackTraceString", tempStackTraceString, typeof(String)); // Do not rename (binary serialization) + info.AddValue("RemoteStackTraceString", _remoteStackTraceString, typeof(String)); // Do not rename (binary serialization) + info.AddValue("RemoteStackIndex", _remoteStackIndex, typeof(Int32)); // Do not rename (binary serialization) + info.AddValue("ExceptionMethod", null, typeof(String)); // Do not rename (binary serialization) + info.AddValue("HResult", HResult); // Do not rename (binary serialization) + info.AddValue("Source", _source, typeof(String)); // Do not rename (binary serialization) // Serialize the Watson bucket details as well - info.AddValue("WatsonBuckets", _watsonBuckets, typeof(byte[])); + info.AddValue("WatsonBuckets", _watsonBuckets, typeof(byte[])); // Do not rename (binary serialization) } // This method will clear the _stackTrace of the exception object upon deserialization diff --git a/src/mscorlib/src/System/Guid.cs b/src/mscorlib/src/System/Guid.cs index da3473b3d2..e3b3a6f944 100644 --- a/src/mscorlib/src/System/Guid.cs +++ b/src/mscorlib/src/System/Guid.cs @@ -26,17 +26,17 @@ namespace System //////////////////////////////////////////////////////////////////////////////// // Member variables //////////////////////////////////////////////////////////////////////////////// - private int _a; - private short _b; - private short _c; - private byte _d; - private byte _e; - private byte _f; - private byte _g; - private byte _h; - private byte _i; - private byte _j; - private byte _k; + private int _a; // Do not rename (binary serialization) + private short _b; // Do not rename (binary serialization) + private short _c; // Do not rename (binary serialization) + private byte _d; // Do not rename (binary serialization) + private byte _e; // Do not rename (binary serialization) + private byte _f; // Do not rename (binary serialization) + private byte _g; // Do not rename (binary serialization) + private byte _h; // Do not rename (binary serialization) + private byte _i; // Do not rename (binary serialization) + private byte _j; // Do not rename (binary serialization) + private byte _k; // Do not rename (binary serialization) diff --git a/src/mscorlib/src/System/IntPtr.cs b/src/mscorlib/src/System/IntPtr.cs index 4ecf448d52..e3439801ff 100644 --- a/src/mscorlib/src/System/IntPtr.cs +++ b/src/mscorlib/src/System/IntPtr.cs @@ -26,7 +26,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct IntPtr : IEquatable<IntPtr>, ISerializable { - unsafe private void* _value; // The compiler treats void* closest to uint hence explicit casts are required to preserve int behavior + unsafe private void* _value; // The compiler treats void* closest to uint hence explicit casts are required to preserve int behavior. Do not rename (binary serialization) public static readonly IntPtr Zero; diff --git a/src/mscorlib/src/System/Nullable.cs b/src/mscorlib/src/System/Nullable.cs index b9b7c59b31..a2c7c350c9 100644 --- a/src/mscorlib/src/System/Nullable.cs +++ b/src/mscorlib/src/System/Nullable.cs @@ -26,8 +26,8 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct Nullable<T> where T : struct { - private bool hasValue; - internal T value; + private bool hasValue; // Do not rename (binary serialization) + internal T value; // Do not rename (binary serialization) [System.Runtime.Versioning.NonVersionable] public Nullable(T value) diff --git a/src/mscorlib/src/System/TimeSpan.cs b/src/mscorlib/src/System/TimeSpan.cs index 9166656d0f..ca60bcb16f 100644 --- a/src/mscorlib/src/System/TimeSpan.cs +++ b/src/mscorlib/src/System/TimeSpan.cs @@ -68,7 +68,7 @@ namespace System // internal so that DateTime doesn't have to call an extra get // method for some arithmetic operations. - internal long _ticks; + internal long _ticks; // Do not rename (binary serialization) //public TimeSpan() { // _ticks = 0; diff --git a/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs b/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs index c0c27eeab7..79fe8db815 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs @@ -212,13 +212,13 @@ namespace System } Contract.EndContractBlock(); - info.AddValue("DateStart", _dateStart); - info.AddValue("DateEnd", _dateEnd); - info.AddValue("DaylightDelta", _daylightDelta); - info.AddValue("DaylightTransitionStart", _daylightTransitionStart); - info.AddValue("DaylightTransitionEnd", _daylightTransitionEnd); - info.AddValue("BaseUtcOffsetDelta", _baseUtcOffsetDelta); - info.AddValue("NoDaylightTransitions", _noDaylightTransitions); + info.AddValue("DateStart", _dateStart); // Do not rename (binary serialization) + info.AddValue("DateEnd", _dateEnd); // Do not rename (binary serialization) + info.AddValue("DaylightDelta", _daylightDelta); // Do not rename (binary serialization) + info.AddValue("DaylightTransitionStart", _daylightTransitionStart); // Do not rename (binary serialization) + info.AddValue("DaylightTransitionEnd", _daylightTransitionEnd); // Do not rename (binary serialization) + info.AddValue("BaseUtcOffsetDelta", _baseUtcOffsetDelta); // Do not rename (binary serialization) + info.AddValue("NoDaylightTransitions", _noDaylightTransitions); // Do not rename (binary serialization) } private AdjustmentRule(SerializationInfo info, StreamingContext context) @@ -228,19 +228,19 @@ namespace System throw new ArgumentNullException(nameof(info)); } - _dateStart = (DateTime)info.GetValue("DateStart", typeof(DateTime)); - _dateEnd = (DateTime)info.GetValue("DateEnd", typeof(DateTime)); - _daylightDelta = (TimeSpan)info.GetValue("DaylightDelta", typeof(TimeSpan)); - _daylightTransitionStart = (TransitionTime)info.GetValue("DaylightTransitionStart", typeof(TransitionTime)); - _daylightTransitionEnd = (TransitionTime)info.GetValue("DaylightTransitionEnd", typeof(TransitionTime)); + _dateStart = (DateTime)info.GetValue("DateStart", typeof(DateTime)); // Do not rename (binary serialization) + _dateEnd = (DateTime)info.GetValue("DateEnd", typeof(DateTime)); // Do not rename (binary serialization) + _daylightDelta = (TimeSpan)info.GetValue("DaylightDelta", typeof(TimeSpan)); // Do not rename (binary serialization) + _daylightTransitionStart = (TransitionTime)info.GetValue("DaylightTransitionStart", typeof(TransitionTime)); // Do not rename (binary serialization) + _daylightTransitionEnd = (TransitionTime)info.GetValue("DaylightTransitionEnd", typeof(TransitionTime)); // Do not rename (binary serialization) - object o = info.GetValueNoThrow("BaseUtcOffsetDelta", typeof(TimeSpan)); + object o = info.GetValueNoThrow("BaseUtcOffsetDelta", typeof(TimeSpan)); // Do not rename (binary serialization) if (o != null) { _baseUtcOffsetDelta = (TimeSpan)o; } - o = info.GetValueNoThrow("NoDaylightTransitions", typeof(bool)); + o = info.GetValueNoThrow("NoDaylightTransitions", typeof(bool)); // Do not rename (binary serialization) if (o != null) { _noDaylightTransitions = (bool)o; diff --git a/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs b/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs index 1e1d9d328b..0fe3dab0b6 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs @@ -132,12 +132,12 @@ namespace System } Contract.EndContractBlock(); - info.AddValue("TimeOfDay", _timeOfDay); - info.AddValue("Month", _month); - info.AddValue("Week", _week); - info.AddValue("Day", _day); - info.AddValue("DayOfWeek", _dayOfWeek); - info.AddValue("IsFixedDateRule", _isFixedDateRule); + info.AddValue("TimeOfDay", _timeOfDay); // Do not rename (binary serialization) + info.AddValue("Month", _month); // Do not rename (binary serialization) + info.AddValue("Week", _week); // Do not rename (binary serialization) + info.AddValue("Day", _day); // Do not rename (binary serialization) + info.AddValue("DayOfWeek", _dayOfWeek); // Do not rename (binary serialization) + info.AddValue("IsFixedDateRule", _isFixedDateRule); // Do not rename (binary serialization) } private TransitionTime(SerializationInfo info, StreamingContext context) @@ -147,12 +147,12 @@ namespace System throw new ArgumentNullException(nameof(info)); } - _timeOfDay = (DateTime)info.GetValue("TimeOfDay", typeof(DateTime)); - _month = (byte)info.GetValue("Month", typeof(byte)); - _week = (byte)info.GetValue("Week", typeof(byte)); - _day = (byte)info.GetValue("Day", typeof(byte)); - _dayOfWeek = (DayOfWeek)info.GetValue("DayOfWeek", typeof(DayOfWeek)); - _isFixedDateRule = (bool)info.GetValue("IsFixedDateRule", typeof(bool)); + _timeOfDay = (DateTime)info.GetValue("TimeOfDay", typeof(DateTime)); // Do not rename (binary serialization) + _month = (byte)info.GetValue("Month", typeof(byte)); // Do not rename (binary serialization) + _week = (byte)info.GetValue("Week", typeof(byte)); // Do not rename (binary serialization) + _day = (byte)info.GetValue("Day", typeof(byte)); // Do not rename (binary serialization) + _dayOfWeek = (DayOfWeek)info.GetValue("DayOfWeek", typeof(DayOfWeek)); // Do not rename (binary serialization) + _isFixedDateRule = (bool)info.GetValue("IsFixedDateRule", typeof(bool)); // Do not rename (binary serialization) } } } diff --git a/src/mscorlib/src/System/TimeZoneInfo.cs b/src/mscorlib/src/System/TimeZoneInfo.cs index cadc9b2704..a492275a71 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.cs @@ -1041,13 +1041,13 @@ namespace System } Contract.EndContractBlock(); - info.AddValue("Id", _id); - info.AddValue("DisplayName", _displayName); - info.AddValue("StandardName", _standardDisplayName); - info.AddValue("DaylightName", _daylightDisplayName); - info.AddValue("BaseUtcOffset", _baseUtcOffset); - info.AddValue("AdjustmentRules", _adjustmentRules); - info.AddValue("SupportsDaylightSavingTime", _supportsDaylightSavingTime); + info.AddValue("Id", _id); // Do not rename (binary serialization) + info.AddValue("DisplayName", _displayName); // Do not rename (binary serialization) + info.AddValue("StandardName", _standardDisplayName); // Do not rename (binary serialization) + info.AddValue("DaylightName", _daylightDisplayName); // Do not rename (binary serialization) + info.AddValue("BaseUtcOffset", _baseUtcOffset); // Do not rename (binary serialization) + info.AddValue("AdjustmentRules", _adjustmentRules); // Do not rename (binary serialization) + info.AddValue("SupportsDaylightSavingTime", _supportsDaylightSavingTime); // Do not rename (binary serialization) } private TimeZoneInfo(SerializationInfo info, StreamingContext context) @@ -1057,13 +1057,13 @@ namespace System throw new ArgumentNullException(nameof(info)); } - _id = (string)info.GetValue("Id", typeof(string)); - _displayName = (string)info.GetValue("DisplayName", typeof(string)); - _standardDisplayName = (string)info.GetValue("StandardName", typeof(string)); - _daylightDisplayName = (string)info.GetValue("DaylightName", typeof(string)); - _baseUtcOffset = (TimeSpan)info.GetValue("BaseUtcOffset", typeof(TimeSpan)); - _adjustmentRules = (AdjustmentRule[])info.GetValue("AdjustmentRules", typeof(AdjustmentRule[])); - _supportsDaylightSavingTime = (bool)info.GetValue("SupportsDaylightSavingTime", typeof(bool)); + _id = (string)info.GetValue("Id", typeof(string)); // Do not rename (binary serialization) + _displayName = (string)info.GetValue("DisplayName", typeof(string)); // Do not rename (binary serialization) + _standardDisplayName = (string)info.GetValue("StandardName", typeof(string)); // Do not rename (binary serialization) + _daylightDisplayName = (string)info.GetValue("DaylightName", typeof(string)); // Do not rename (binary serialization) + _baseUtcOffset = (TimeSpan)info.GetValue("BaseUtcOffset", typeof(TimeSpan)); // Do not rename (binary serialization) + _adjustmentRules = (AdjustmentRule[])info.GetValue("AdjustmentRules", typeof(AdjustmentRule[])); // Do not rename (binary serialization) + _supportsDaylightSavingTime = (bool)info.GetValue("SupportsDaylightSavingTime", typeof(bool)); // Do not rename (binary serialization) } private AdjustmentRule GetAdjustmentRuleForTime(DateTime dateTime, out int? ruleIndex) diff --git a/src/mscorlib/src/System/Tuple.cs b/src/mscorlib/src/System/Tuple.cs index 87663d186a..6a8758278c 100644 --- a/src/mscorlib/src/System/Tuple.cs +++ b/src/mscorlib/src/System/Tuple.cs @@ -108,7 +108,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; + private readonly T1 m_Item1; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } @@ -208,8 +208,8 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } @@ -323,9 +323,9 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2, T3> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; - private readonly T3 m_Item3; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) + private readonly T3 m_Item3; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } @@ -449,10 +449,10 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2, T3, T4> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; - private readonly T3 m_Item3; - private readonly T4 m_Item4; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) + private readonly T3 m_Item3; // Do not rename (binary serialization) + private readonly T4 m_Item4; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } @@ -586,11 +586,11 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2, T3, T4, T5> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; - private readonly T3 m_Item3; - private readonly T4 m_Item4; - private readonly T5 m_Item5; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) + private readonly T3 m_Item3; // Do not rename (binary serialization) + private readonly T4 m_Item4; // Do not rename (binary serialization) + private readonly T5 m_Item5; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } @@ -734,12 +734,12 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2, T3, T4, T5, T6> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; - private readonly T3 m_Item3; - private readonly T4 m_Item4; - private readonly T5 m_Item5; - private readonly T6 m_Item6; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) + private readonly T3 m_Item3; // Do not rename (binary serialization) + private readonly T4 m_Item4; // Do not rename (binary serialization) + private readonly T5 m_Item5; // Do not rename (binary serialization) + private readonly T6 m_Item6; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } @@ -893,13 +893,13 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2, T3, T4, T5, T6, T7> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; - private readonly T3 m_Item3; - private readonly T4 m_Item4; - private readonly T5 m_Item5; - private readonly T6 m_Item6; - private readonly T7 m_Item7; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) + private readonly T3 m_Item3; // Do not rename (binary serialization) + private readonly T4 m_Item4; // Do not rename (binary serialization) + private readonly T5 m_Item5; // Do not rename (binary serialization) + private readonly T6 m_Item6; // Do not rename (binary serialization) + private readonly T7 m_Item7; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } @@ -1063,14 +1063,14 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple { - private readonly T1 m_Item1; - private readonly T2 m_Item2; - private readonly T3 m_Item3; - private readonly T4 m_Item4; - private readonly T5 m_Item5; - private readonly T6 m_Item6; - private readonly T7 m_Item7; - private readonly TRest m_Rest; + private readonly T1 m_Item1; // Do not rename (binary serialization) + private readonly T2 m_Item2; // Do not rename (binary serialization) + private readonly T3 m_Item3; // Do not rename (binary serialization) + private readonly T4 m_Item4; // Do not rename (binary serialization) + private readonly T5 m_Item5; // Do not rename (binary serialization) + private readonly T6 m_Item6; // Do not rename (binary serialization) + private readonly T7 m_Item7; // Do not rename (binary serialization) + private readonly TRest m_Rest; // Do not rename (binary serialization) public T1 Item1 { get { return m_Item1; } } public T2 Item2 { get { return m_Item2; } } diff --git a/src/mscorlib/src/System/UIntPtr.cs b/src/mscorlib/src/System/UIntPtr.cs index 0ae3b395bd..1bed651e6f 100644 --- a/src/mscorlib/src/System/UIntPtr.cs +++ b/src/mscorlib/src/System/UIntPtr.cs @@ -24,7 +24,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct UIntPtr : IEquatable<UIntPtr>, ISerializable { - unsafe private void* _value; + unsafe private void* _value; // Do not rename (binary serialization) public static readonly UIntPtr Zero; diff --git a/src/mscorlib/src/System/WeakReference.cs b/src/mscorlib/src/System/WeakReference.cs index d0377e1fc3..a6a30c1978 100644 --- a/src/mscorlib/src/System/WeakReference.cs +++ b/src/mscorlib/src/System/WeakReference.cs @@ -58,8 +58,8 @@ namespace System } Contract.EndContractBlock(); - Object target = info.GetValue("TrackedObject", typeof(Object)); - bool trackResurrection = info.GetBoolean("TrackResurrection"); + Object target = info.GetValue("TrackedObject", typeof(Object)); // Do not rename (binary serialization) + bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization) Create(target, trackResurrection); } @@ -109,8 +109,8 @@ namespace System throw new ArgumentNullException(nameof(info)); } Contract.EndContractBlock(); - info.AddValue("TrackedObject", Target, typeof(Object)); - info.AddValue("TrackResurrection", IsTrackResurrection()); + info.AddValue("TrackedObject", Target, typeof(Object)); // Do not rename (binary serialization) + info.AddValue("TrackResurrection", IsTrackResurrection()); // Do not rename (binary serialization) } [MethodImplAttribute(MethodImplOptions.InternalCall)] diff --git a/src/mscorlib/src/System/WeakReferenceOfT.cs b/src/mscorlib/src/System/WeakReferenceOfT.cs index e5b70805c9..7347683e2f 100644 --- a/src/mscorlib/src/System/WeakReferenceOfT.cs +++ b/src/mscorlib/src/System/WeakReferenceOfT.cs @@ -53,8 +53,8 @@ namespace System } Contract.EndContractBlock(); - T target = (T)info.GetValue("TrackedObject", typeof(T)); - bool trackResurrection = info.GetBoolean("TrackResurrection"); + T target = (T)info.GetValue("TrackedObject", typeof(T)); // Do not rename (binary serialization) + bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization) Create(target, trackResurrection); } @@ -106,8 +106,8 @@ namespace System } Contract.EndContractBlock(); - info.AddValue("TrackedObject", this.Target, typeof(T)); - info.AddValue("TrackResurrection", IsTrackResurrection()); + info.AddValue("TrackedObject", this.Target, typeof(T)); // Do not rename (binary serialization) + info.AddValue("TrackResurrection", IsTrackResurrection()); // Do not rename (binary serialization) } [MethodImplAttribute(MethodImplOptions.InternalCall)] diff --git a/src/vm/arm/memcpy.S b/src/vm/arm/memcpy.S index b9788605f7..0c2c26e1d8 100644 --- a/src/vm/arm/memcpy.S +++ b/src/vm/arm/memcpy.S @@ -22,8 +22,8 @@ PROLOG_PUSH "{r7, lr}" PROLOG_STACK_SAVE r7 - ldr r3, [r0] - ldr r3, [r1] + ldrb r3, [r0] + ldrb r3, [r1] blx C_FUNC(memcpy) |