repo_name
stringclasses
6 values
pr_number
int64
512
78.9k
pr_title
stringlengths
3
144
pr_description
stringlengths
0
30.3k
author
stringlengths
2
21
date_created
timestamp[ns, tz=UTC]
date_merged
timestamp[ns, tz=UTC]
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
17
30.4k
filepath
stringlengths
9
210
before_content
stringlengths
0
112M
after_content
stringlengths
0
112M
label
int64
-1
1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/Methodical/Arrays/huge/huge_i4_il_r.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="huge_i4.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <RestorePackages>true</RestorePackages> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="huge_i4.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/mono/mono/arch/amd64/amd64-codegen.h
/* * amd64-codegen.h: Macros for generating amd64 code * * Authors: * Paolo Molaro ([email protected]) * Intel Corporation (ORP Project) * Sergey Chaban ([email protected]) * Dietmar Maurer ([email protected]) * Patrik Torstensson * Zalman Stern * * Copyright (C) 2000 Intel Corporation. All rights reserved. * Copyright (C) 2001, 2002 Ximian, Inc. * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #ifndef AMD64_H #define AMD64_H // Conventions in this file: // body: implementation. other macros call this one // disp: displacement // inst: instruction // is_half: short if true, byte if false (then why is it named is_half...?) // imm: immediate // mem: read from (immediate-supplied address?) // membase: read from address in a base register plus a displacement // memindex: SIP addressing: (address in base register) + (displacement in index register)<<(shift) // reg: register, encode modR/M bits 00 // regp: register, encode modR/M bits 11 // size: Expected 1,2,4 or 8 // widen: extends from 1 or 2 bytes #include <glib.h> typedef enum { AMD64_RAX = 0, AMD64_RCX = 1, AMD64_RDX = 2, AMD64_RBX = 3, AMD64_RSP = 4, AMD64_RBP = 5, AMD64_RSI = 6, AMD64_RDI = 7, AMD64_R8 = 8, AMD64_R9 = 9, AMD64_R10 = 10, AMD64_R11 = 11, AMD64_R12 = 12, AMD64_R13 = 13, AMD64_R14 = 14, AMD64_R15 = 15, AMD64_RIP = 16, AMD64_NREG } AMD64_Reg_No; typedef enum { AMD64_XMM0 = 0, AMD64_XMM1 = 1, AMD64_XMM2 = 2, AMD64_XMM3 = 3, AMD64_XMM4 = 4, AMD64_XMM5 = 5, AMD64_XMM6 = 6, AMD64_XMM7 = 7, AMD64_XMM8 = 8, AMD64_XMM9 = 9, AMD64_XMM10 = 10, AMD64_XMM11 = 11, AMD64_XMM12 = 12, AMD64_XMM13 = 13, AMD64_XMM14 = 14, AMD64_XMM15 = 15, AMD64_XMM_NREG = 16, } AMD64_XMM_Reg_No; typedef enum { AMD64_REX_B = 1, /* The register in r/m field, base register in SIB byte, or reg in opcode is 8-15 rather than 0-7 */ AMD64_REX_X = 2, /* The index register in SIB byte is 8-15 rather than 0-7 */ AMD64_REX_R = 4, /* The reg field of ModRM byte is 8-15 rather than 0-7 */ AMD64_REX_W = 8 /* Opeartion is 64-bits instead of 32 (default) or 16 (with 0x66 prefix) */ } AMD64_REX_Bits; #define amd64_codegen_pre(inst) #define amd64_codegen_post(inst) #ifdef TARGET_WIN32 #define AMD64_ARG_REG1 AMD64_RCX #define AMD64_ARG_REG2 AMD64_RDX #define AMD64_ARG_REG3 AMD64_R8 #define AMD64_ARG_REG4 AMD64_R9 #else #define AMD64_ARG_REG1 AMD64_RDI #define AMD64_ARG_REG2 AMD64_RSI #define AMD64_ARG_REG3 AMD64_RDX #define AMD64_ARG_REG4 AMD64_RCX #endif #ifdef TARGET_WIN32 #define AMD64_CALLEE_REGS ((1<<AMD64_RAX) | (1<<AMD64_RCX) | (1<<AMD64_RDX) | (1<<AMD64_R8) | (1<<AMD64_R9) | (1<<AMD64_R10)) #define AMD64_IS_CALLEE_REG(reg) (AMD64_CALLEE_REGS & (1 << (reg))) #define AMD64_ARGUMENT_REGS ((1<<AMD64_RDX) | (1<<AMD64_RCX) | (1<<AMD64_R8) | (1<<AMD64_R9)) #define AMD64_IS_ARGUMENT_REG(reg) (AMD64_ARGUMENT_REGS & (1 << (reg))) /* xmm0-xmm3 for standard calling convention, additionally xmm4-xmm5 for __vectorcall (not currently used) */ #define AMD64_ARGUMENT_XREGS ((1<<AMD64_XMM0) | (1<<AMD64_XMM1) | (1<<AMD64_XMM2) | (1<<AMD64_XMM3) | (1<<AMD64_XMM4) | (1<<AMD64_XMM5)) #define AMD64_IS_ARGUMENT_XREG(reg) (AMD64_ARGUMENT_XREGS & (1 << (reg))) #define AMD64_CALLEE_SAVED_REGS ((1<<AMD64_RDI) | (1<<AMD64_RSI) | (1<<AMD64_RBX) | (1<<AMD64_R12) | (1<<AMD64_R13) | (1<<AMD64_R14) | (1<<AMD64_R15) | (1<<AMD64_RBP)) #define AMD64_IS_CALLEE_SAVED_REG(reg) (AMD64_CALLEE_SAVED_REGS & (1 << (reg))) #else #define AMD64_CALLEE_REGS ((1<<AMD64_RAX) | (1<<AMD64_RCX) | (1<<AMD64_RDX) | (1<<AMD64_RSI) | (1<<AMD64_RDI) | (1<<AMD64_R8) | (1<<AMD64_R9) | (1<<AMD64_R10)) #define AMD64_IS_CALLEE_REG(reg) (AMD64_CALLEE_REGS & (1 << (reg))) #define AMD64_ARGUMENT_REGS ((1<<AMD64_RDI) | (1<<AMD64_RSI) | (1<<AMD64_RDX) | (1<<AMD64_RCX) | (1<<AMD64_R8) | (1<<AMD64_R9)) #define AMD64_IS_ARGUMENT_REG(reg) (AMD64_ARGUMENT_REGS & (1 << (reg))) #define AMD64_ARGUMENT_XREGS ((1<<AMD64_XMM0) | (1<<AMD64_XMM1) | (1<<AMD64_XMM2) | (1<<AMD64_XMM3) | (1<<AMD64_XMM4) | (1<<AMD64_XMM5) | (1<<AMD64_XMM6) | (1<<AMD64_XMM7)) #define AMD64_IS_ARGUMENT_XREG(reg) (AMD64_ARGUMENT_XREGS & (1 << (reg))) #define AMD64_CALLEE_SAVED_REGS ((1<<AMD64_RBX) | (1<<AMD64_R12) | (1<<AMD64_R13) | (1<<AMD64_R14) | (1<<AMD64_R15) | (1<<AMD64_RBP)) #define AMD64_IS_CALLEE_SAVED_REG(reg) (AMD64_CALLEE_SAVED_REGS & (1 << (reg))) #endif #define AMD64_REX(bits) ((unsigned char)(0x40 | (bits))) #define amd64_emit_rex(inst, width, reg_modrm, reg_index, reg_rm_base_opcode) do \ { \ unsigned char _amd64_rex_bits = \ (((width) > 4) ? AMD64_REX_W : 0) | \ (((reg_modrm) > 7) ? AMD64_REX_R : 0) | \ (((reg_index) > 7) ? AMD64_REX_X : 0) | \ (((reg_rm_base_opcode) > 7) ? AMD64_REX_B : 0); \ if ((_amd64_rex_bits != 0) || (((width) == 1))) *(inst)++ = AMD64_REX(_amd64_rex_bits); \ } while (0) typedef union { guint64 val; unsigned char b [8]; } amd64_imm_buf; #include "../x86/x86-codegen.h" /* In 64 bit mode, all registers have a low byte subregister */ #undef X86_IS_BYTE_REG #define X86_IS_BYTE_REG(reg) 1 #define amd64_modrm_mod(modrm) ((modrm) >> 6) #define amd64_modrm_reg(modrm) (((modrm) >> 3) & 0x7) #define amd64_modrm_rm(modrm) ((modrm) & 0x7) #define amd64_rex_r(rex) ((((rex) >> 2) & 0x1) << 3) #define amd64_rex_x(rex) ((((rex) >> 1) & 0x1) << 3) #define amd64_rex_b(rex) ((((rex) >> 0) & 0x1) << 3) #define amd64_sib_scale(sib) ((sib) >> 6) #define amd64_sib_index(sib) (((sib) >> 3) & 0x7) #define amd64_sib_base(sib) ((sib) & 0x7) #define amd64_is_imm32(val) ((gint64)val >= -((gint64)1<<31) && (gint64)val <= (((gint64)1<<31)-1)) #define x86_imm_emit64(inst,imm) \ do { \ amd64_imm_buf imb; \ imb.val = (guint64) (imm); \ *(inst)++ = imb.b [0]; \ *(inst)++ = imb.b [1]; \ *(inst)++ = imb.b [2]; \ *(inst)++ = imb.b [3]; \ *(inst)++ = imb.b [4]; \ *(inst)++ = imb.b [5]; \ *(inst)++ = imb.b [6]; \ *(inst)++ = imb.b [7]; \ } while (0) #define amd64_membase_emit(inst,reg,basereg,disp) do { \ if ((basereg) == AMD64_RIP) { \ x86_address_byte ((inst), 0, (reg)&0x7, 5); \ x86_imm_emit32 ((inst), (disp)); \ } \ else \ x86_membase_emit ((inst),(reg)&0x7, (basereg)&0x7, (disp)); \ } while (0) #define amd64_alu_reg_imm_size_body(inst,opc,reg,imm,size) \ do { \ if (x86_is_imm8((imm))) { \ amd64_emit_rex(inst, size, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x83; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((reg) == AMD64_RAX) { \ amd64_emit_rex(inst, size, 0, 0, 0); \ *(inst)++ = (((unsigned char)(opc)) << 3) + 5; \ x86_imm_emit32 ((inst), (imm)); \ } else { \ amd64_emit_rex(inst, size, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x81; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define amd64_alu_reg_reg_size_body(inst,opc,dreg,reg,size) \ do { \ amd64_emit_rex(inst, size, (dreg), 0, (reg)); \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define amd64_test_reg_imm_size_body(inst,reg,imm,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),0,0,(reg)); \ if ((reg) == AMD64_RAX) { \ *(inst)++ = (unsigned char)0xa9; \ } \ else { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit((inst), 0, (reg)); \ } \ x86_imm_emit32((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) \ amd64_alu_reg_imm_size_body((inst), (opc), (reg), (imm), (size)) #define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) \ amd64_alu_reg_reg_size_body((inst), (opc), (dreg), (reg), (size)) #define amd64_test_reg_imm_size(inst, reg, imm, size) \ amd64_test_reg_imm_size_body(inst, reg, imm, size) #define amd64_alu_reg_imm(inst,opc,reg,imm) amd64_alu_reg_imm_size((inst),(opc),(reg),(imm),8) #define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size ((inst),(opc),(dreg),(reg),8) #define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8) #define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),(reg),0,(basereg)); \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ amd64_membase_emit (inst, reg, basereg, disp); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_regp_reg(inst,regp,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, (regp)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_regp_emit ((inst), (reg), (regp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_membase_reg(inst,basereg,disp,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_mem_reg(inst,mem,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, 0); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_address_byte ((inst), 0, (reg), 4); \ x86_address_byte ((inst), 0, 4, 5); \ x86_imm_emit32 ((inst), (mem)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_reg(inst,dreg,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (dreg), 0, (reg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_mem_body(inst,reg,mem,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, 0); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_address_byte ((inst), 0, (reg), 4); \ x86_address_byte ((inst), 0, 4, 5); \ x86_imm_emit32 ((inst), (mem)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_mem(inst,reg,mem,size) \ do { \ amd64_mov_reg_mem_body((inst),(reg),(mem),(size)); \ } while (0) #define amd64_mov_reg_membase_body(inst,reg,basereg,disp,size) \ do { \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define amd64_mov_reg_memindex_size_body(inst,reg,basereg,disp,indexreg,shift,size) \ do { \ amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); \ x86_mov_reg_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(size) == 8 ? 4 : (size)); \ } while (0) #define amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) \ amd64_mov_reg_memindex_size_body((inst),(reg),(basereg),(disp),(indexreg),(shift),(size)) #define amd64_mov_reg_membase(inst,reg,basereg,disp,size) \ do { \ amd64_mov_reg_membase_body((inst), (reg), (basereg), (disp), (size)); \ } while (0) #define amd64_movzx_reg_membase(inst,reg,basereg,disp,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xb6; break; \ case 2: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xb7; break; \ case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsxd_reg_mem(inst,reg,mem) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst,8,(reg),0,0); \ *(inst)++ = (unsigned char)0x63; \ x86_mem_emit ((inst), ((reg)&0x7), (mem)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsxd_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst,8,(reg),0,(basereg)); \ *(inst)++ = (unsigned char)0x63; \ x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsxd_reg_reg(inst,dreg,reg) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst,8,(dreg),0,(reg)); \ *(inst)++ = (unsigned char)0x63; \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) /* Pretty much the only instruction that supports a 64-bit immediate. Optimize for common case of * 32-bit immediate. Pepper with casts to avoid warnings. */ #define amd64_mov_reg_imm_size(inst,reg,imm,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, (size), 0, 0, (reg)); \ *(inst)++ = (unsigned char)0xb8 + ((reg) & 0x7); \ if ((size) == 8) \ x86_imm_emit64 ((inst), (guint64)(imm)); \ else \ x86_imm_emit32 ((inst), (int)(guint64)(imm)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_imm(inst,reg,imm) \ do { \ amd64_codegen_pre(inst); \ amd64_mov_reg_imm_size ((inst), (reg), (imm), (amd64_is_imm32 (((gint64)imm)) ? 4 : 8)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_set_reg_template(inst,reg) amd64_mov_reg_imm_size ((inst),(reg), 0, 8) #define amd64_set_template(inst,reg) amd64_set_reg_template((inst),(reg)) #define amd64_mov_membase_imm(inst,basereg,disp,imm,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size) == 1 ? 0 : (size), 0, 0, (basereg)); \ if ((size) == 1) { \ *(inst)++ = (unsigned char)0xc6; \ x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((size) == 2) { \ *(inst)++ = (unsigned char)0xc7; \ x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \ x86_imm_emit16 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0xc7; \ x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \ x86_imm_emit32 ((inst), (imm)); \ } \ amd64_codegen_post(inst); \ } while (0) #define amd64_lea_membase_body(inst,reg,basereg,disp,width) \ do { \ amd64_emit_rex(inst, width, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x8d; \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define amd64_lea4_membase(inst,reg,basereg,disp) \ amd64_lea_membase_body((inst), (reg), (basereg), (disp), 4) #define amd64_lea_membase(inst,reg,basereg,disp) \ amd64_lea_membase_body((inst), (reg), (basereg), (disp), 8) /* Instruction are implicitly 64-bits so don't generate REX for just the size. */ #define amd64_push_reg(inst,reg) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, 0, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x50 + ((reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) /* Instruction is implicitly 64-bits so don't generate REX for just the size. */ #define amd64_push_membase(inst,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, 0, 0, 0, (basereg)); \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 6, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_pop_reg_body(inst,reg) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, 0, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x58 + ((reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_call_reg(inst,reg) \ do { \ amd64_emit_rex(inst, 0, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst), 2, ((reg) & 0x7)); \ } while (0) #define amd64_ret(inst) do { *(inst)++ = (unsigned char)0xc3; } while (0) #define amd64_leave(inst) do { *(inst)++ = (unsigned char)0xc9; } while (0) #define amd64_pop_reg(inst,reg) amd64_pop_reg_body((inst), (reg)) #define amd64_movsd_reg_regp(inst,reg,regp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsd_regp_reg(inst,regp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_reg_regp(inst,reg,regp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_regp_reg(inst,regp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movdqu_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x6f; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsd_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movdqu_membase_reg(inst,basereg,disp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x7f; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsd_membase_reg(inst,basereg,disp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_membase_reg(inst,basereg,disp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) /* The original inc_reg opcode is used as the REX prefix */ #define amd64_inc_reg_size(inst,reg,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),0,0,(reg)); \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst),0,(reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_dec_reg_size(inst,reg,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),0,0,(reg)); \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst),1,(reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_fld_membase_size(inst,basereg,disp,is_double,size) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),0,0,0,(basereg)); \ *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \ amd64_membase_emit ((inst), 0, (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) /* From the AMD64 Software Optimization Manual */ #define amd64_padding_size(inst,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = 0x90; break; \ case 2: *(inst)++ = 0x66; *(inst)++ = 0x90; break; \ case 3: *(inst)++ = 0x66; *(inst)++ = 0x66; *(inst)++ = 0x90; break; \ default: amd64_emit_rex ((inst),8,0,0,0); x86_padding ((inst), (size) - 1); \ }; \ } while (0) #define amd64_call_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); *(inst)++ = (unsigned char)0xff; amd64_membase_emit ((inst),2, (basereg),(disp)); } while (0) #define amd64_jump_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); *(inst)++ = (unsigned char)0xff; amd64_membase_emit ((inst), 4, (basereg), (disp)); } while (0) #define amd64_jump_code_size(inst,target,size) do { \ if (amd64_is_imm32 ((gint64)(target) - (gint64)(inst))) { \ x86_jump_code((inst),(target)); \ } else { \ amd64_jump_membase ((inst), AMD64_RIP, 0); \ *(guint64*)(inst) = (guint64)(target); \ (inst) += 8; \ } \ } while (0) /* * SSE */ //TODO Reorganize SSE opcode defines. /* Two opcode SSE defines */ #define emit_sse_reg_reg_op2_size(inst,dreg,reg,op1,op2,size) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_reg_op2(inst,dreg,reg,op1,op2) emit_sse_reg_reg_op2_size ((inst), (dreg), (reg), (op1), (op2), 0) #define emit_sse_reg_reg_op2_imm(inst,dreg,reg,op1,op2,imm) do { \ amd64_codegen_pre(inst); \ emit_sse_reg_reg_op2 ((inst), (dreg), (reg), (op1), (op2)); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_membase_reg_op2(inst,basereg,disp,reg,op1,op2) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst), 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_membase_op2(inst,dreg,basereg,disp,op1,op2) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst), 0, (dreg), 0, (basereg) == AMD64_RIP ? 0 : (basereg)); \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ amd64_membase_emit ((inst), (dreg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) /* Three opcode SSE defines */ #define emit_opcode3(inst,op1,op2,op3) do { \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ } while (0) #define emit_sse_reg_reg_size(inst,dreg,reg,op1,op2,op3,size) do { \ amd64_codegen_pre(inst); \ *(inst)++ = (unsigned char)(op1); \ amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_reg(inst,dreg,reg,op1,op2,op3) emit_sse_reg_reg_size ((inst), (dreg), (reg), (op1), (op2), (op3), 0) #define emit_sse_reg_reg_imm(inst,dreg,reg,op1,op2,op3,imm) do { \ amd64_codegen_pre(inst); \ emit_sse_reg_reg ((inst), (dreg), (reg), (op1), (op2), (op3)); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_membase_reg(inst,basereg,disp,reg,op1,op2,op3) do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), (unsigned char)(op1)); \ amd64_emit_rex ((inst), 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_membase(inst,dreg,basereg,disp,op1,op2,op3) do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), (unsigned char)(op1)); \ amd64_emit_rex ((inst), 0, (dreg), 0, (basereg) == AMD64_RIP ? 0 : (basereg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ amd64_membase_emit ((inst), (dreg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) /* Four opcode SSE defines */ #define emit_sse_reg_reg_op4_size(inst,dreg,reg,op1,op2,op3,op4,size) do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), (unsigned char)(op1)); \ amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ *(inst)++ = (unsigned char)(op4); \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_reg_op4(inst,dreg,reg,op1,op2,op3,op4) emit_sse_reg_reg_op4_size ((inst), (dreg), (reg), (op1), (op2), (op3), (op4), 0) #define emit_sse_reg_reg_op4_imm(inst,dreg,reg,op1,op2,op3,op4,imm) do { \ amd64_codegen_pre(inst); \ emit_sse_reg_reg_op4 ((inst), (dreg), (reg), (op1), (op2), (op3), (op4)); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) /* specific SSE opcode defines */ #define amd64_sse_xorpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg), 0x66, 0x0f, 0x57) #define amd64_sse_xorpd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst),(dreg),(basereg), (disp), 0x66, 0x0f, 0x57) #define amd64_sse_andpd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst),(dreg),(basereg), (disp), 0x66, 0x0f, 0x54) #define amd64_sse_movsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x10) #define amd64_sse_movss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x10) #define amd64_sse_movsd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf2, 0x0f, 0x10) #define amd64_sse_movsd_membase_reg(inst,basereg,disp,reg) emit_sse_membase_reg ((inst), (basereg), (disp), (reg), 0xf2, 0x0f, 0x11) #define amd64_sse_movss_membase_reg(inst,basereg,disp,reg) emit_sse_membase_reg ((inst), (basereg), (disp), (reg), 0xf3, 0x0f, 0x11) #define amd64_sse_movss_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf3, 0x0f, 0x10) #define amd64_sse_comisd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x66,0x0f,0x2f) #define amd64_sse_comiss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x67,0x0f,0x2f) #define amd64_sse_comisd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x2f) #define amd64_sse_ucomisd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x66,0x0f,0x2e) #define amd64_sse_cvtsd2si_reg_reg(inst,dreg,reg) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2d, 8) #define amd64_sse_cvtss2si_reg_reg(inst,dreg,reg) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf3, 0x0f, 0x2d, 8) #define amd64_sse_cvttsd2si_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2c, (size)) #define amd64_sse_cvtss2si_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf3, 0x0f, 0x2c, (size)) #define amd64_sse_cvttsd2si_reg_reg(inst,dreg,reg) amd64_sse_cvttsd2si_reg_reg_size ((inst), (dreg), (reg), 8) #define amd64_sse_cvtsi2sd_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2a, (size)) #define amd64_sse_cvtsi2sd_reg_reg(inst,dreg,reg) amd64_sse_cvtsi2sd_reg_reg_size ((inst), (dreg), (reg), 8) #define amd64_sse_cvtsi2ss_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf3, 0x0f, 0x2a, (size)) #define amd64_sse_cvtsi2ss_reg_reg(inst,dreg,reg) amd64_sse_cvtsi2ss_reg_reg_size ((inst), (dreg), (reg), 8) #define amd64_sse_cvtsd2ss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5a) #define amd64_sse_cvtss2sd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5a) #define amd64_sse_addsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x58) #define amd64_sse_addss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x58) #define amd64_sse_subsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5c) #define amd64_sse_subss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5c) #define amd64_sse_mulsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x59) #define amd64_sse_mulss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x59) #define amd64_sse_divsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5e) #define amd64_sse_divss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5e) #define amd64_sse_sqrtsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x51) #define amd64_sse_pinsrw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm ((inst), (dreg), (reg), 0x66, 0x0f, 0xc4, (imm)) #define amd64_sse_pextrw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm ((inst), (dreg), (reg), 0x66, 0x0f, 0xc5, (imm)) #define amd64_sse_cvttsd2si_reg_xreg_size(inst,reg,xreg,size) emit_sse_reg_reg_size ((inst), (reg), (xreg), 0xf2, 0x0f, 0x2c, (size)) #define amd64_sse_addps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x58) #define amd64_sse_divps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5e) #define amd64_sse_mulps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x59) #define amd64_sse_subps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5c) #define amd64_sse_maxps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5f) #define amd64_sse_minps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5d) #define amd64_sse_cmpps_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_op2_imm((inst), (dreg), (reg), 0x0f, 0xc2, (imm)) #define amd64_sse_andps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x54) #define amd64_sse_andnps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x55) #define amd64_sse_orps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x56) #define amd64_sse_xorps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x57) #define amd64_sse_sqrtps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x51) #define amd64_sse_rsqrtps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x52) #define amd64_sse_rcpps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x53) #define amd64_sse_addsubps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0xd0) #define amd64_sse_haddps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x7c) #define amd64_sse_hsubps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x7d) #define amd64_sse_movshdup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf3, 0x0f, 0x16) #define amd64_sse_movsldup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf3, 0x0f, 0x12) #define amd64_sse_pshufhw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0xf3, 0x0f, 0x70, (imm)) #define amd64_sse_pshuflw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0xf2, 0x0f, 0x70, (imm)) #define amd64_sse_pshufd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0x70, (imm)) #define amd64_sse_shufps_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_op2_imm((inst), (dreg), (reg), 0x0f, 0xC6, (imm)) #define amd64_sse_shufpd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0xC6, (imm)) #define amd64_sse_roundpd_reg_reg_imm(inst, dreg, reg, imm) emit_sse_reg_reg_op4_imm((inst), (dreg), (reg), 0x66, 0x0f, 0x3a, 0x09, (imm)) #define amd64_sse_addpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x58) #define amd64_sse_divpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5e) #define amd64_sse_mulpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x59) #define amd64_sse_subpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5c) #define amd64_sse_maxpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5f) #define amd64_sse_minpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5d) #define amd64_sse_cmppd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0xc2, (imm)) #define amd64_sse_andpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x54) #define amd64_sse_andnpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x55) #define amd64_sse_orpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x56) #define amd64_sse_sqrtpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x51) #define amd64_sse_rsqrtpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x52) #define amd64_sse_rcppd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x53) #define amd64_sse_addsubpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd0) #define amd64_sse_haddpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x7c) #define amd64_sse_hsubpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x7d) #define amd64_sse_movddup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x12) #define amd64_sse_pmovmskb_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd7) #define amd64_sse_pand_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdb) #define amd64_sse_pandn_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdf) #define amd64_sse_por_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xeb) #define amd64_sse_pxor_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xef) #define amd64_sse_paddb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfc) #define amd64_sse_paddw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfd) #define amd64_sse_paddd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfe) #define amd64_sse_paddq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd4) #define amd64_sse_psubb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf8) #define amd64_sse_psubw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf9) #define amd64_sse_psubd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfa) #define amd64_sse_psubq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfb) #define amd64_sse_pmaxub_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xde) #define amd64_sse_pmaxuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3e) #define amd64_sse_pmaxud_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3f) #define amd64_sse_pmaxsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3c) #define amd64_sse_pmaxsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xee) #define amd64_sse_pmaxsd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3d) #define amd64_sse_pavgb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe0) #define amd64_sse_pavgw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe3) #define amd64_sse_pminub_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xda) #define amd64_sse_pminuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3a) #define amd64_sse_pminud_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3b) #define amd64_sse_pminsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x38) #define amd64_sse_pminsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xea) #define amd64_sse_pminsd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x39) #define amd64_sse_pcmpeqb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x74) #define amd64_sse_pcmpeqw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x75) #define amd64_sse_pcmpeqd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x76) #define amd64_sse_pcmpeqq_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x29) #define amd64_sse_pcmpgtb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x64) #define amd64_sse_pcmpgtw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x65) #define amd64_sse_pcmpgtd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x66) #define amd64_sse_pcmpgtq_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x37) #define amd64_sse_psadbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf6) #define amd64_sse_punpcklbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x60) #define amd64_sse_punpcklwd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x61) #define amd64_sse_punpckldq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x62) #define amd64_sse_punpcklqdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6c) #define amd64_sse_unpcklpd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x14) #define amd64_sse_unpcklps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x14) #define amd64_sse_punpckhbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x68) #define amd64_sse_punpckhwd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x69) #define amd64_sse_punpckhdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6a) #define amd64_sse_punpckhqdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6d) #define amd64_sse_unpckhpd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x15) #define amd64_sse_unpckhps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x15) #define amd64_sse_packsswb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x63) #define amd64_sse_packssdw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6b) #define amd64_sse_packuswb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x67) #define amd64_sse_packusdw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x2b) #define amd64_sse_paddusb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdc) #define amd64_sse_psubusb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd8) #define amd64_sse_paddusw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdd) #define amd64_sse_psubusw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd8) #define amd64_sse_paddsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xec) #define amd64_sse_psubsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe8) #define amd64_sse_paddsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xed) #define amd64_sse_psubsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe9) #define amd64_sse_pmullw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd5) #define amd64_sse_pmulld_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x40) #define amd64_sse_pmuludq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf4) #define amd64_sse_pmulhuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe4) #define amd64_sse_pmulhw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe5) #define amd64_sse_psrlw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x71, (imm)) #define amd64_sse_psrlw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd1) #define amd64_sse_psraw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x71, (imm)) #define amd64_sse_psraw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe1) #define amd64_sse_psllw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x71, (imm)) #define amd64_sse_psllw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf1) #define amd64_sse_psrld_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x72, (imm)) #define amd64_sse_psrld_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd2) #define amd64_sse_psrad_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x72, (imm)) #define amd64_sse_psrad_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe2) #define amd64_sse_pslld_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x72, (imm)) #define amd64_sse_pslld_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf2) #define amd64_sse_psrlq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x73, (imm)) #define amd64_sse_psrlq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd3) #define amd64_sse_psraq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x73, (imm)) #define amd64_sse_psraq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe3) #define amd64_sse_psllq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x73, (imm)) #define amd64_sse_psllq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf3) #define amd64_sse_cvtdq2pd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xF3, 0x0F, 0xE6) #define amd64_sse_cvtdq2ps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0F, 0x5B) #define amd64_sse_cvtpd2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xF2, 0x0F, 0xE6) #define amd64_sse_cvtpd2ps_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0F, 0x5A) #define amd64_sse_cvtps2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0F, 0x5B) #define amd64_sse_cvtps2pd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0F, 0x5A) #define amd64_sse_cvttpd2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0F, 0xE6) #define amd64_sse_cvttps2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xF3, 0x0F, 0x5B) #define amd64_movd_xreg_reg_size(inst,dreg,sreg,size) emit_sse_reg_reg_size((inst), (dreg), (sreg), 0x66, 0x0f, 0x6e, (size)) #define amd64_movd_reg_xreg_size(inst,dreg,sreg,size) emit_sse_reg_reg_size((inst), (sreg), (dreg), 0x66, 0x0f, 0x7e, (size)) #define amd64_movd_xreg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x6e) #define amd64_movlhps_reg_reg(inst,dreg,sreg) emit_sse_reg_reg_op2((inst), (dreg), (sreg), 0x0f, 0x16) #define amd64_movhlps_reg_reg(inst,dreg,sreg) emit_sse_reg_reg_op2((inst), (dreg), (sreg), 0x0f, 0x12) #define amd64_sse_movups_membase_reg(inst, basereg, disp, reg) emit_sse_membase_reg_op2((inst), (basereg), (disp), (reg), 0x0f, 0x11) #define amd64_sse_movups_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x10) #define amd64_sse_movaps_membase_reg(inst, basereg, disp, reg) emit_sse_membase_reg_op2((inst), (basereg), (disp), (reg), 0x0f, 0x29) #define amd64_sse_movaps_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x28) #define amd64_sse_movaps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x28) #define amd64_sse_movntps_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x2b) #define amd64_sse_prefetch_reg_membase(inst, arg, basereg, disp) emit_sse_reg_membase_op2((inst), (arg), (basereg), (disp), 0x0f, 0x18) #define amd64_sse_lzcnt_reg_reg_size(inst, dreg, reg, size) emit_sse_reg_reg_size((inst), (dreg), (reg), 0xf3, 0x0f, 0xbd, (size)) #define amd64_sse_popcnt_reg_reg_size(inst, dreg, reg, size) emit_sse_reg_reg_size((inst), (dreg), (reg), 0xf3, 0x0f, 0xb8, (size)) /* Generated from x86-codegen.h */ #define amd64_breakpoint_size(inst,size) do { x86_breakpoint(inst); } while (0) #define amd64_cld_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_cld(inst); amd64_codegen_post(inst); } while (0) #define amd64_stosb_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_stosb(inst); amd64_codegen_post(inst); } while (0) #define amd64_stosl_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_stosl(inst); amd64_codegen_post(inst); } while (0) #define amd64_stosd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_stosd(inst); amd64_codegen_post(inst); } while (0) #define amd64_movsb_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_movsb(inst); amd64_codegen_post(inst); } while (0) #define amd64_movsl_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_movsl(inst); amd64_codegen_post(inst); } while (0) #define amd64_movsd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_movsd(inst); amd64_codegen_post(inst); } while (0) #define amd64_prefix_size(inst,p,size) do { x86_prefix((inst), p); } while (0) #define amd64_rdtsc_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_rdtsc(inst); amd64_codegen_post(inst); } while (0) #define amd64_cmpxchg_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_cmpxchg_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_cmpxchg_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_cmpxchg_mem_reg((inst),(mem),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_cmpxchg_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_cmpxchg_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_xchg_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_xchg_reg_reg((inst),((dreg)&0x7),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_xchg_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_xchg_mem_reg((inst),(mem),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_xchg_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_xchg_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_inc_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_inc_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_inc_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_inc_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) //#define amd64_inc_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_inc_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_dec_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_dec_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_dec_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_dec_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) //#define amd64_dec_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_dec_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_not_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_not_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_not_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_not_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_not_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_not_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_neg_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_neg_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_neg_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_neg_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_neg_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_neg_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_nop_size(inst,size) do { amd64_codegen_pre(inst); x86_nop(inst); amd64_codegen_post(inst); } while (0) //#define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_imm((inst),(opc),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_mem_imm_size(inst,opc,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_alu_mem_imm((inst),(opc),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_membase_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_alu_membase_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_membase8_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_alu_membase8_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_mem_reg_size(inst,opc,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_mem_reg((inst),(opc),(mem),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_alu_membase_reg_size(inst,opc,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_membase_reg((inst),(opc),((basereg)&0x7),(disp),((reg)&0x7)); amd64_codegen_post(inst); } while (0) //#define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg_reg((inst),(opc),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg8_reg8((inst),(opc),((dreg)&0x7),((reg)&0x7),(is_dreg_h),(is_reg_h)); amd64_codegen_post(inst); } while (0) #define amd64_alu_reg_mem_size(inst,opc,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_mem((inst),(opc),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) //#define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_reg_membase((inst),(opc),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) //#define amd64_test_reg_imm_size(inst,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_reg_imm((inst),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_test_mem_imm_size(inst,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_test_mem_imm((inst),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_test_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_test_membase_imm((inst),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_test_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_test_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_test_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_mem_reg((inst),(mem),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_test_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_test_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shift_reg_imm_size(inst,opc,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_reg_imm((inst),(opc),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_shift_mem_imm_size(inst,opc,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_mem_imm((inst),(opc),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_shift_membase_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_shift_membase_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_shift_reg_size(inst,opc,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_reg((inst),(opc),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shift_mem_size(inst,opc,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_mem((inst),(opc),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_shift_membase_size(inst,opc,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_shift_membase((inst),(opc),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_shrd_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shrd_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shrd_reg_imm_size(inst,dreg,reg,shamt,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shrd_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(shamt)); amd64_codegen_post(inst); } while (0) #define amd64_shld_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shld_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shld_reg_imm_size(inst,dreg,reg,shamt,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shld_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(shamt)); amd64_codegen_post(inst); } while (0) #define amd64_mul_reg_size(inst,reg,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mul_reg((inst),((reg)&0x7),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_mul_mem_size(inst,mem,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_mul_mem((inst),(mem),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_mul_membase_size(inst,basereg,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_mul_membase((inst),((basereg)&0x7),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_imul_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_mem_size(inst,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_imul_reg_mem((inst),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_membase_size(inst,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_imul_reg_membase((inst),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_reg_imm_size(inst,dreg,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_imul_reg_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_mem_imm_size(inst,reg,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_imul_reg_mem_imm((inst),((reg)&0x7),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_membase_imm_size(inst,reg,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_imul_reg_membase_imm((inst),((reg)&0x7),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_div_reg_size(inst,reg,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_div_reg((inst),((reg)&0x7),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_div_mem_size(inst,mem,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_div_mem((inst),(mem),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_div_membase_size(inst,basereg,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_div_membase((inst),((basereg)&0x7),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_mov_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_mem_reg((inst),(mem),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_regp_reg_size(inst,regp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(regp),0,(reg)); x86_mov_regp_reg((inst),(regp),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_mov_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_mov_memindex_reg_size(inst,basereg,disp,indexreg,shift,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_mov_memindex_reg((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_mem_size(inst,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_reg_mem((inst),((reg)&0x7),(mem),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_membase_size(inst,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_mov_reg_membase((inst),((reg)&0x7),((basereg)&0x7),(disp),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_mov_reg_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_clear_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_clear_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_imm_size(inst,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_reg_imm((inst),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_mov_mem_imm_size(inst,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_mov_mem_imm((inst),(mem),(imm),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_mov_membase_imm((inst),((basereg)&0x7),(disp),(imm),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_mov_memindex_imm_size(inst,basereg,disp,indexreg,shift,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,(indexreg),(basereg)); x86_mov_memindex_imm((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(imm),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_lea_mem_size(inst,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_lea_mem((inst),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) //#define amd64_lea_membase_size(inst,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_lea_membase((inst),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_lea_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift)); amd64_codegen_post(inst); } while (0) #define amd64_widen_reg_size(inst,dreg,reg,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_widen_reg((inst),((dreg)&0x7),((reg)&0x7),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_widen_mem_size(inst,dreg,mem,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,0); x86_widen_mem((inst),((dreg)&0x7),(mem),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_widen_membase_size(inst,dreg,basereg,disp,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(basereg)); x86_widen_membase((inst),((dreg)&0x7),((basereg)&0x7),(disp),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_widen_memindex_size(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),(indexreg),(basereg)); x86_widen_memindex((inst),((dreg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_cdq_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_cdq(inst); amd64_codegen_post(inst); } while (0) #define amd64_wait_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_wait(inst); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_mem_size(inst,opc,mem,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fp_op_mem((inst),(opc),(mem),(is_double)); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_membase_size(inst,opc,basereg,disp,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fp_op_membase((inst),(opc),((basereg)&0x7),(disp),(is_double)); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_size(inst,opc,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fp_op((inst),(opc),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_reg_size(inst,opc,index,pop_stack,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fp_op_reg((inst),(opc),(index),(pop_stack)); amd64_codegen_post(inst); } while (0) #define amd64_fp_int_op_membase_size(inst,opc,basereg,disp,is_int,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fp_int_op_membase((inst),(opc),((basereg)&0x7),(disp),(is_int)); amd64_codegen_post(inst); } while (0) #define amd64_fstp_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fstp((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fcompp_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fcompp(inst); amd64_codegen_post(inst); } while (0) #define amd64_fucompp_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fucompp(inst); amd64_codegen_post(inst); } while (0) #define amd64_fnstsw_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fnstsw(inst); amd64_codegen_post(inst); } while (0) #define amd64_fnstcw_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fnstcw((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fnstcw_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_fnstcw_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fldcw_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fldcw((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fldcw_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fldcw_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fchs_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fchs(inst); amd64_codegen_post(inst); } while (0) #define amd64_frem_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_frem(inst); amd64_codegen_post(inst); } while (0) #define amd64_fxch_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fxch((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fcomi_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fcomi((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fcomip_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fcomip((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fucomi_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fucomi((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fucomip_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fucomip((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fld_size(inst,mem,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld((inst),(mem),(is_double)); amd64_codegen_post(inst); } while (0) //#define amd64_fld_membase_size(inst,basereg,disp,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fld_membase((inst),((basereg)&0x7),(disp),(is_double)); amd64_codegen_post(inst); } while (0) #define amd64_fld80_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld80_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fld80_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_fld80_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fild_size(inst,mem,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fild((inst),(mem),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fild_membase_size(inst,basereg,disp,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fild_membase((inst),((basereg)&0x7),(disp),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fld_reg_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld_reg((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fldz_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fldz(inst); amd64_codegen_post(inst); } while (0) #define amd64_fld1_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld1(inst); amd64_codegen_post(inst); } while (0) #define amd64_fldpi_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fldpi(inst); amd64_codegen_post(inst); } while (0) #define amd64_fst_size(inst,mem,is_double,pop_stack,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fst((inst),(mem),(is_double),(pop_stack)); amd64_codegen_post(inst); } while (0) #define amd64_fst_membase_size(inst,basereg,disp,is_double,pop_stack,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fst_membase((inst),((basereg)&0x7),(disp),(is_double),(pop_stack)); amd64_codegen_post(inst); } while (0) #define amd64_fst80_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fst80_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fst80_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fst80_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fist_pop_size(inst,mem,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fist_pop((inst),(mem),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fist_pop_membase_size(inst,basereg,disp,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fist_pop_membase((inst),((basereg)&0x7),(disp),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fstsw_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_fstsw(inst); amd64_codegen_post(inst); } while (0) #define amd64_fist_membase_size(inst,basereg,disp,is_int,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fist_membase((inst),((basereg)&0x7),(disp),(is_int)); amd64_codegen_post(inst); } while (0) //#define amd64_push_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_push_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_push_regp_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_push_regp((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_push_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_push_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) //#define amd64_push_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_push_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_push_memindex_size(inst,basereg,disp,indexreg,shift,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,(indexreg),(basereg)); x86_push_memindex((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift)); amd64_codegen_post(inst); } while (0) #define amd64_push_imm_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_push_imm((inst),(imm)); amd64_codegen_post(inst); } while (0) //#define amd64_pop_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_pop_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_pop_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_pop_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_pop_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_pop_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_pushad_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_pushad(inst); amd64_codegen_post(inst); } while (0) #define amd64_pushfd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_pushfd(inst); amd64_codegen_post(inst); } while (0) #define amd64_popad_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_popad(inst); amd64_codegen_post(inst); } while (0) #define amd64_popfd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_popfd(inst); amd64_codegen_post(inst); } while (0) #define amd64_loop_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_loop((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_loope_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_loope((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_loopne_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_loopne((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_jump32_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_jump32((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_jump8_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_jump8((inst),(imm)); amd64_codegen_post(inst); } while (0) /* Defined above for Native Client, so they can be used in other macros */ #define amd64_jump_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),0,0,0,(reg)); x86_jump_reg((inst),((reg)&0x7)); } while (0) #define amd64_jump_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_jump_mem((inst),(mem)); } while (0) #define amd64_jump_disp_size(inst,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_jump_disp((inst),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_branch8_size(inst,cond,imm,is_signed,size) do { x86_branch8((inst),(cond),(imm),(is_signed)); } while (0) #define amd64_branch32_size(inst,cond,imm,is_signed,size) do { x86_branch32((inst),(cond),(imm),(is_signed)); } while (0) #define amd64_branch_size_body(inst,cond,target,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_branch((inst),(cond),(target),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_branch_size(inst,cond,target,is_signed,size) do { amd64_branch_size_body((inst),(cond),(target),(is_signed),(size)); } while (0) #define amd64_branch_disp_size(inst,cond,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_branch_disp((inst),(cond),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_set_reg_size(inst,cond,reg,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex((inst),1,0,0,(reg)); x86_set_reg((inst),(cond),((reg)&0x7),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_set_mem_size(inst,cond,mem,is_signed,size) do { amd64_codegen_pre(inst); x86_set_mem((inst),(cond),(mem),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_set_membase_size(inst,cond,basereg,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_set_membase((inst),(cond),((basereg)&0x7),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) //#define amd64_call_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_call_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_call_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_call_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_call_imm_size(inst,disp,size) do { x86_call_imm((inst),(disp)); } while (0) #define amd64_call_code_size(inst,target,size) do { x86_call_code((inst),(target)); } while (0) //#define amd64_ret_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_ret(inst); amd64_codegen_post(inst); } while (0) #define amd64_ret_imm_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_ret_imm((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_cmov_reg_size(inst,cond,is_signed,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_cmov_reg((inst),(cond),(is_signed),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_cmov_mem_size(inst,cond,is_signed,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_cmov_mem((inst),(cond),(is_signed),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_cmov_membase_size(inst,cond,is_signed,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_cmov_membase((inst),(cond),(is_signed),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_enter_size(inst,framesize) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_enter((inst),(framesize)); amd64_codegen_post(inst); } while (0) //#define amd64_leave_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_leave(inst); amd64_codegen_post(inst); } while (0) #define amd64_sahf_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_sahf(inst); amd64_codegen_post(inst); } while (0) #define amd64_fsin_size(inst,size) do { amd64_codegen_pre(inst); x86_fsin(inst); amd64_codegen_post(inst); } while (0) #define amd64_fcos_size(inst,size) do { amd64_codegen_pre(inst); x86_fcos(inst); amd64_codegen_post(inst); } while (0) #define amd64_fabs_size(inst,size) do { amd64_codegen_pre(inst); x86_fabs(inst); amd64_codegen_post(inst); } while (0) #define amd64_ftst_size(inst,size) do { amd64_codegen_pre(inst); x86_ftst(inst); amd64_codegen_post(inst); } while (0) #define amd64_fxam_size(inst,size) do { amd64_codegen_pre(inst); x86_fxam(inst); amd64_codegen_post(inst); } while (0) #define amd64_fpatan_size(inst,size) do { amd64_codegen_pre(inst); x86_fpatan(inst); amd64_codegen_post(inst); } while (0) #define amd64_fprem_size(inst,size) do { amd64_codegen_pre(inst); x86_fprem(inst); amd64_codegen_post(inst); } while (0) #define amd64_fprem1_size(inst,size) do { amd64_codegen_pre(inst); x86_fprem1(inst); amd64_codegen_post(inst); } while (0) #define amd64_frndint_size(inst,size) do { amd64_codegen_pre(inst); x86_frndint(inst); amd64_codegen_post(inst); } while (0) #define amd64_fsqrt_size(inst,size) do { amd64_codegen_pre(inst); x86_fsqrt(inst); amd64_codegen_post(inst); } while (0) #define amd64_fptan_size(inst,size) do { amd64_codegen_pre(inst); x86_fptan(inst); amd64_codegen_post(inst); } while (0) //#define amd64_padding_size(inst,size) do { amd64_codegen_pre(inst); x86_padding((inst),(size)); amd64_codegen_post(inst); } while (0) #define amd64_prolog_size(inst,frame_size,reg_mask,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_prolog((inst),(frame_size),(reg_mask)); amd64_codegen_post(inst); } while (0) #define amd64_epilog_size(inst,reg_mask,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_epilog((inst),(reg_mask)); amd64_codegen_post(inst); } while (0) #define amd64_xadd_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_xadd_reg_reg ((inst), (dreg), (reg), (size)); amd64_codegen_post(inst); } while (0) #define amd64_xadd_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_xadd_mem_reg((inst),(mem),((reg)&0x7), (size)); amd64_codegen_post(inst); } while (0) #define amd64_xadd_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_xadd_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size)); amd64_codegen_post(inst); } while (0) #define amd64_breakpoint(inst) amd64_breakpoint_size(inst,8) #define amd64_cld(inst) amd64_cld_size(inst,8) #define amd64_stosb(inst) amd64_stosb_size(inst,8) #define amd64_stosl(inst) amd64_stosl_size(inst,8) #define amd64_stosd(inst) amd64_stosd_size(inst,8) #define amd64_movsb(inst) amd64_movsb_size(inst,8) #define amd64_movsl(inst) amd64_movsl_size(inst,8) #define amd64_movsd(inst) amd64_movsd_size(inst,8) #define amd64_prefix(inst,p) amd64_prefix_size(inst,p,8) #define amd64_rdtsc(inst) amd64_rdtsc_size(inst,8) #define amd64_cmpxchg_reg_reg(inst,dreg,reg) amd64_cmpxchg_reg_reg_size(inst,dreg,reg,8) #define amd64_cmpxchg_mem_reg(inst,mem,reg) amd64_cmpxchg_mem_reg_size(inst,mem,reg,8) #define amd64_cmpxchg_membase_reg(inst,basereg,disp,reg) amd64_cmpxchg_membase_reg_size(inst,basereg,disp,reg,8) #define amd64_xchg_reg_reg(inst,dreg,reg,size) amd64_xchg_reg_reg_size(inst,dreg,reg,size) #define amd64_xchg_mem_reg(inst,mem,reg,size) amd64_xchg_mem_reg_size(inst,mem,reg,size) #define amd64_xchg_membase_reg(inst,basereg,disp,reg,size) amd64_xchg_membase_reg_size(inst,basereg,disp,reg,size) #define amd64_xadd_reg_reg(inst,dreg,reg,size) amd64_xadd_reg_reg_size(inst,dreg,reg,size) #define amd64_xadd_mem_reg(inst,mem,reg,size) amd64_xadd_mem_reg_size(inst,mem,reg,size) #define amd64_xadd_membase_reg(inst,basereg,disp,reg,size) amd64_xadd_membase_reg_size(inst,basereg,disp,reg,size) #define amd64_inc_mem(inst,mem) amd64_inc_mem_size(inst,mem,8) #define amd64_inc_membase(inst,basereg,disp) amd64_inc_membase_size(inst,basereg,disp,8) #define amd64_inc_reg(inst,reg) amd64_inc_reg_size(inst,reg,8) #define amd64_dec_mem(inst,mem) amd64_dec_mem_size(inst,mem,8) #define amd64_dec_membase(inst,basereg,disp) amd64_dec_membase_size(inst,basereg,disp,8) #define amd64_dec_reg(inst,reg) amd64_dec_reg_size(inst,reg,8) #define amd64_not_mem(inst,mem) amd64_not_mem_size(inst,mem,8) #define amd64_not_membase(inst,basereg,disp) amd64_not_membase_size(inst,basereg,disp,8) #define amd64_not_reg(inst,reg) amd64_not_reg_size(inst,reg,8) #define amd64_neg_mem(inst,mem) amd64_neg_mem_size(inst,mem,8) #define amd64_neg_membase(inst,basereg,disp) amd64_neg_membase_size(inst,basereg,disp,8) #define amd64_neg_reg(inst,reg) amd64_neg_reg_size(inst,reg,8) #define amd64_nop(inst) amd64_nop_size(inst,8) //#define amd64_alu_reg_imm(inst,opc,reg,imm) amd64_alu_reg_imm_size(inst,opc,reg,imm,8) #define amd64_alu_mem_imm(inst,opc,mem,imm) amd64_alu_mem_imm_size(inst,opc,mem,imm,8) #define amd64_alu_membase_imm(inst,opc,basereg,disp,imm) amd64_alu_membase_imm_size(inst,opc,basereg,disp,imm,8) #define amd64_alu_mem_reg(inst,opc,mem,reg) amd64_alu_mem_reg_size(inst,opc,mem,reg,8) #define amd64_alu_membase_reg(inst,opc,basereg,disp,reg) amd64_alu_membase_reg_size(inst,opc,basereg,disp,reg,8) //#define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size(inst,opc,dreg,reg,8) #define amd64_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,8) #define amd64_alu_reg_mem(inst,opc,reg,mem) amd64_alu_reg_mem_size(inst,opc,reg,mem,8) #define amd64_alu_reg_membase(inst,opc,reg,basereg,disp) amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,8) //#define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8) #define amd64_test_mem_imm(inst,mem,imm) amd64_test_mem_imm_size(inst,mem,imm,8) #define amd64_test_membase_imm(inst,basereg,disp,imm) amd64_test_membase_imm_size(inst,basereg,disp,imm,8) #define amd64_test_reg_reg(inst,dreg,reg) amd64_test_reg_reg_size(inst,dreg,reg,8) #define amd64_test_mem_reg(inst,mem,reg) amd64_test_mem_reg_size(inst,mem,reg,8) #define amd64_test_membase_reg(inst,basereg,disp,reg) amd64_test_membase_reg_size(inst,basereg,disp,reg,8) #define amd64_shift_reg_imm(inst,opc,reg,imm) amd64_shift_reg_imm_size(inst,opc,reg,imm,8) #define amd64_shift_mem_imm(inst,opc,mem,imm) amd64_shift_mem_imm_size(inst,opc,mem,imm,8) #define amd64_shift_membase_imm(inst,opc,basereg,disp,imm) amd64_shift_membase_imm_size(inst,opc,basereg,disp,imm,8) #define amd64_shift_reg(inst,opc,reg) amd64_shift_reg_size(inst,opc,reg,8) #define amd64_shift_mem(inst,opc,mem) amd64_shift_mem_size(inst,opc,mem,8) #define amd64_shift_membase(inst,opc,basereg,disp) amd64_shift_membase_size(inst,opc,basereg,disp,8) #define amd64_shrd_reg(inst,dreg,reg) amd64_shrd_reg_size(inst,dreg,reg,8) #define amd64_shrd_reg_imm(inst,dreg,reg,shamt) amd64_shrd_reg_imm_size(inst,dreg,reg,shamt,8) #define amd64_shld_reg(inst,dreg,reg) amd64_shld_reg_size(inst,dreg,reg,8) #define amd64_shld_reg_imm(inst,dreg,reg,shamt) amd64_shld_reg_imm_size(inst,dreg,reg,shamt,8) #define amd64_mul_reg(inst,reg,is_signed) amd64_mul_reg_size(inst,reg,is_signed,8) #define amd64_mul_mem(inst,mem,is_signed) amd64_mul_mem_size(inst,mem,is_signed,8) #define amd64_mul_membase(inst,basereg,disp,is_signed) amd64_mul_membase_size(inst,basereg,disp,is_signed,8) #define amd64_imul_reg_reg(inst,dreg,reg) amd64_imul_reg_reg_size(inst,dreg,reg,8) #define amd64_imul_reg_mem(inst,reg,mem) amd64_imul_reg_mem_size(inst,reg,mem,8) #define amd64_imul_reg_membase(inst,reg,basereg,disp) amd64_imul_reg_membase_size(inst,reg,basereg,disp,8) #define amd64_imul_reg_reg_imm(inst,dreg,reg,imm) amd64_imul_reg_reg_imm_size(inst,dreg,reg,imm,8) #define amd64_imul_reg_mem_imm(inst,reg,mem,imm) amd64_imul_reg_mem_imm_size(inst,reg,mem,imm,8) #define amd64_imul_reg_membase_imm(inst,reg,basereg,disp,imm) amd64_imul_reg_membase_imm_size(inst,reg,basereg,disp,imm,8) #define amd64_div_reg(inst,reg,is_signed) amd64_div_reg_size(inst,reg,is_signed,8) #define amd64_div_mem(inst,mem,is_signed) amd64_div_mem_size(inst,mem,is_signed,8) #define amd64_div_membase(inst,basereg,disp,is_signed) amd64_div_membase_size(inst,basereg,disp,is_signed,8) //#define amd64_mov_mem_reg(inst,mem,reg,size) amd64_mov_mem_reg_size(inst,mem,reg,size) //#define amd64_mov_regp_reg(inst,regp,reg,size) amd64_mov_regp_reg_size(inst,regp,reg,size) //#define amd64_mov_membase_reg(inst,basereg,disp,reg,size) amd64_mov_membase_reg_size(inst,basereg,disp,reg,size) #define amd64_mov_memindex_reg(inst,basereg,disp,indexreg,shift,reg,size) amd64_mov_memindex_reg_size(inst,basereg,disp,indexreg,shift,reg,size) //#define amd64_mov_reg_reg(inst,dreg,reg,size) amd64_mov_reg_reg_size(inst,dreg,reg,size) //#define amd64_mov_reg_mem(inst,reg,mem,size) amd64_mov_reg_mem_size(inst,reg,mem,size) //#define amd64_mov_reg_membase(inst,reg,basereg,disp,size) amd64_mov_reg_membase_size(inst,reg,basereg,disp,size) #define amd64_mov_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) #define amd64_clear_reg(inst,reg) amd64_clear_reg_size(inst,reg,8) //#define amd64_mov_reg_imm(inst,reg,imm) amd64_mov_reg_imm_size(inst,reg,imm,8) #define amd64_mov_mem_imm(inst,mem,imm,size) amd64_mov_mem_imm_size(inst,mem,imm,size) //#define amd64_mov_membase_imm(inst,basereg,disp,imm,size) amd64_mov_membase_imm_size(inst,basereg,disp,imm,size) #define amd64_mov_memindex_imm(inst,basereg,disp,indexreg,shift,imm,size) amd64_mov_memindex_imm_size(inst,basereg,disp,indexreg,shift,imm,size) #define amd64_lea_mem(inst,reg,mem) amd64_lea_mem_size(inst,reg,mem,8) //#define amd64_lea_membase(inst,reg,basereg,disp) amd64_lea_membase_size(inst,reg,basereg,disp,8) #define amd64_lea_memindex(inst,reg,basereg,disp,indexreg,shift) amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,8) #define amd64_widen_reg(inst,dreg,reg,is_signed,is_half) amd64_widen_reg_size(inst,dreg,reg,is_signed,is_half,8) #define amd64_widen_mem(inst,dreg,mem,is_signed,is_half) amd64_widen_mem_size(inst,dreg,mem,is_signed,is_half,8) #define amd64_widen_membase(inst,dreg,basereg,disp,is_signed,is_half) amd64_widen_membase_size(inst,dreg,basereg,disp,is_signed,is_half,8) #define amd64_widen_memindex(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half) amd64_widen_memindex_size(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half,8) #define amd64_cdq(inst) amd64_cdq_size(inst,8) #define amd64_wait(inst) amd64_wait_size(inst,8) #define amd64_fp_op_mem(inst,opc,mem,is_double) amd64_fp_op_mem_size(inst,opc,mem,is_double,8) #define amd64_fp_op_membase(inst,opc,basereg,disp,is_double) amd64_fp_op_membase_size(inst,opc,basereg,disp,is_double,8) #define amd64_fp_op(inst,opc,index) amd64_fp_op_size(inst,opc,index,8) #define amd64_fp_op_reg(inst,opc,index,pop_stack) amd64_fp_op_reg_size(inst,opc,index,pop_stack,8) #define amd64_fp_int_op_membase(inst,opc,basereg,disp,is_int) amd64_fp_int_op_membase_size(inst,opc,basereg,disp,is_int,8) #define amd64_fstp(inst,index) amd64_fstp_size(inst,index,8) #define amd64_fcompp(inst) amd64_fcompp_size(inst,8) #define amd64_fucompp(inst) amd64_fucompp_size(inst,8) #define amd64_fnstsw(inst) amd64_fnstsw_size(inst,8) #define amd64_fnstcw(inst,mem) amd64_fnstcw_size(inst,mem,8) #define amd64_fnstcw_membase(inst,basereg,disp) amd64_fnstcw_membase_size(inst,basereg,disp,8) #define amd64_fldcw(inst,mem) amd64_fldcw_size(inst,mem,8) #define amd64_fldcw_membase(inst,basereg,disp) amd64_fldcw_membase_size(inst,basereg,disp,8) #define amd64_fchs(inst) amd64_fchs_size(inst,8) #define amd64_frem(inst) amd64_frem_size(inst,8) #define amd64_fxch(inst,index) amd64_fxch_size(inst,index,8) #define amd64_fcomi(inst,index) amd64_fcomi_size(inst,index,8) #define amd64_fcomip(inst,index) amd64_fcomip_size(inst,index,8) #define amd64_fucomi(inst,index) amd64_fucomi_size(inst,index,8) #define amd64_fucomip(inst,index) amd64_fucomip_size(inst,index,8) #define amd64_fld(inst,mem,is_double) amd64_fld_size(inst,mem,is_double,8) #define amd64_fld_membase(inst,basereg,disp,is_double) amd64_fld_membase_size(inst,basereg,disp,is_double,8) #define amd64_fld80_mem(inst,mem) amd64_fld80_mem_size(inst,mem,8) #define amd64_fld80_membase(inst,basereg,disp) amd64_fld80_membase_size(inst,basereg,disp,8) #define amd64_fild(inst,mem,is_long) amd64_fild_size(inst,mem,is_long,8) #define amd64_fild_membase(inst,basereg,disp,is_long) amd64_fild_membase_size(inst,basereg,disp,is_long,8) #define amd64_fld_reg(inst,index) amd64_fld_reg_size(inst,index,8) #define amd64_fldz(inst) amd64_fldz_size(inst,8) #define amd64_fld1(inst) amd64_fld1_size(inst,8) #define amd64_fldpi(inst) amd64_fldpi_size(inst,8) #define amd64_fst(inst,mem,is_double,pop_stack) amd64_fst_size(inst,mem,is_double,pop_stack,8) #define amd64_fst_membase(inst,basereg,disp,is_double,pop_stack) amd64_fst_membase_size(inst,basereg,disp,is_double,pop_stack,8) #define amd64_fst80_mem(inst,mem) amd64_fst80_mem_size(inst,mem,8) #define amd64_fst80_membase(inst,basereg,disp) amd64_fst80_membase_size(inst,basereg,disp,8) #define amd64_fist_pop(inst,mem,is_long) amd64_fist_pop_size(inst,mem,is_long,8) #define amd64_fist_pop_membase(inst,basereg,disp,is_long) amd64_fist_pop_membase_size(inst,basereg,disp,is_long,8) #define amd64_fstsw(inst) amd64_fstsw_size(inst,8) #define amd64_fist_membase(inst,basereg,disp,is_int) amd64_fist_membase_size(inst,basereg,disp,is_int,8) //#define amd64_push_reg(inst,reg) amd64_push_reg_size(inst,reg,8) #define amd64_push_regp(inst,reg) amd64_push_regp_size(inst,reg,8) #define amd64_push_mem(inst,mem) amd64_push_mem_size(inst,mem,8) //#define amd64_push_membase(inst,basereg,disp) amd64_push_membase_size(inst,basereg,disp,8) #define amd64_push_memindex(inst,basereg,disp,indexreg,shift) amd64_push_memindex_size(inst,basereg,disp,indexreg,shift,8) #define amd64_push_imm(inst,imm) amd64_push_imm_size(inst,imm,8) //#define amd64_pop_reg(inst,reg) amd64_pop_reg_size(inst,reg,8) #define amd64_pop_mem(inst,mem) amd64_pop_mem_size(inst,mem,8) #define amd64_pop_membase(inst,basereg,disp) amd64_pop_membase_size(inst,basereg,disp,8) #define amd64_pushad(inst) amd64_pushad_size(inst,8) #define amd64_pushfd(inst) amd64_pushfd_size(inst,8) #define amd64_popad(inst) amd64_popad_size(inst,8) #define amd64_popfd(inst) amd64_popfd_size(inst,8) #define amd64_loop(inst,imm) amd64_loop_size(inst,imm,8) #define amd64_loope(inst,imm) amd64_loope_size(inst,imm,8) #define amd64_loopne(inst,imm) amd64_loopne_size(inst,imm,8) #define amd64_jump32(inst,imm) amd64_jump32_size(inst,imm,8) #define amd64_jump8(inst,imm) amd64_jump8_size(inst,imm,8) #define amd64_jump_reg(inst,reg) amd64_jump_reg_size(inst,reg,8) #define amd64_jump_mem(inst,mem) amd64_jump_mem_size(inst,mem,8) #define amd64_jump_membase(inst,basereg,disp) amd64_jump_membase_size(inst,basereg,disp,8) #define amd64_jump_code(inst,target) amd64_jump_code_size(inst,target,8) #define amd64_jump_disp(inst,disp) amd64_jump_disp_size(inst,disp,8) #define amd64_branch8(inst,cond,imm,is_signed) amd64_branch8_size(inst,cond,imm,is_signed,8) #define amd64_branch32(inst,cond,imm,is_signed) amd64_branch32_size(inst,cond,imm,is_signed,8) #define amd64_branch(inst,cond,target,is_signed) amd64_branch_size(inst,cond,target,is_signed,8) #define amd64_branch_disp(inst,cond,disp,is_signed) amd64_branch_disp_size(inst,cond,disp,is_signed,8) #define amd64_set_reg(inst,cond,reg,is_signed) amd64_set_reg_size(inst,cond,reg,is_signed,8) #define amd64_set_mem(inst,cond,mem,is_signed) amd64_set_mem_size(inst,cond,mem,is_signed,8) #define amd64_set_membase(inst,cond,basereg,disp,is_signed) amd64_set_membase_size(inst,cond,basereg,disp,is_signed,8) #define amd64_call_imm(inst,disp) amd64_call_imm_size(inst,disp,8) //#define amd64_call_reg(inst,reg) amd64_call_reg_size(inst,reg,8) #define amd64_call_mem(inst,mem) amd64_call_mem_size(inst,mem,8) #define amd64_call_membase(inst,basereg,disp) amd64_call_membase_size(inst,basereg,disp,8) #define amd64_call_code(inst,target) amd64_call_code_size(inst,target,8) //#define amd64_ret(inst) amd64_ret_size(inst,8) #define amd64_ret_imm(inst,imm) amd64_ret_imm_size(inst,imm,8) #define amd64_cmov_reg(inst,cond,is_signed,dreg,reg) amd64_cmov_reg_size(inst,cond,is_signed,dreg,reg,8) #define amd64_cmov_mem(inst,cond,is_signed,reg,mem) amd64_cmov_mem_size(inst,cond,is_signed,reg,mem,8) #define amd64_cmov_membase(inst,cond,is_signed,reg,basereg,disp) amd64_cmov_membase_size(inst,cond,is_signed,reg,basereg,disp,8) #define amd64_enter(inst,framesize) amd64_enter_size(inst,framesize) //#define amd64_leave(inst) amd64_leave_size(inst,8) #define amd64_sahf(inst) amd64_sahf_size(inst,8) #define amd64_fsin(inst) amd64_fsin_size(inst,8) #define amd64_fcos(inst) amd64_fcos_size(inst,8) #define amd64_fabs(inst) amd64_fabs_size(inst,8) #define amd64_ftst(inst) amd64_ftst_size(inst,8) #define amd64_fxam(inst) amd64_fxam_size(inst,8) #define amd64_fpatan(inst) amd64_fpatan_size(inst,8) #define amd64_fprem(inst) amd64_fprem_size(inst,8) #define amd64_fprem1(inst) amd64_fprem1_size(inst,8) #define amd64_frndint(inst) amd64_frndint_size(inst,8) #define amd64_fsqrt(inst) amd64_fsqrt_size(inst,8) #define amd64_fptan(inst) amd64_fptan_size(inst,8) #define amd64_padding(inst,size) amd64_padding_size(inst,size) #define amd64_prolog(inst,frame,reg_mask) amd64_prolog_size(inst,frame,reg_mask,8) #define amd64_epilog(inst,reg_mask) amd64_epilog_size(inst,reg_mask,8) #endif // AMD64_H
/* * amd64-codegen.h: Macros for generating amd64 code * * Authors: * Paolo Molaro ([email protected]) * Intel Corporation (ORP Project) * Sergey Chaban ([email protected]) * Dietmar Maurer ([email protected]) * Patrik Torstensson * Zalman Stern * * Copyright (C) 2000 Intel Corporation. All rights reserved. * Copyright (C) 2001, 2002 Ximian, Inc. * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #ifndef AMD64_H #define AMD64_H // Conventions in this file: // body: implementation. other macros call this one // disp: displacement // inst: instruction // is_half: short if true, byte if false (then why is it named is_half...?) // imm: immediate // mem: read from (immediate-supplied address?) // membase: read from address in a base register plus a displacement // memindex: SIP addressing: (address in base register) + (displacement in index register)<<(shift) // reg: register, encode modR/M bits 00 // regp: register, encode modR/M bits 11 // size: Expected 1,2,4 or 8 // widen: extends from 1 or 2 bytes #include <glib.h> typedef enum { AMD64_RAX = 0, AMD64_RCX = 1, AMD64_RDX = 2, AMD64_RBX = 3, AMD64_RSP = 4, AMD64_RBP = 5, AMD64_RSI = 6, AMD64_RDI = 7, AMD64_R8 = 8, AMD64_R9 = 9, AMD64_R10 = 10, AMD64_R11 = 11, AMD64_R12 = 12, AMD64_R13 = 13, AMD64_R14 = 14, AMD64_R15 = 15, AMD64_RIP = 16, AMD64_NREG } AMD64_Reg_No; typedef enum { AMD64_XMM0 = 0, AMD64_XMM1 = 1, AMD64_XMM2 = 2, AMD64_XMM3 = 3, AMD64_XMM4 = 4, AMD64_XMM5 = 5, AMD64_XMM6 = 6, AMD64_XMM7 = 7, AMD64_XMM8 = 8, AMD64_XMM9 = 9, AMD64_XMM10 = 10, AMD64_XMM11 = 11, AMD64_XMM12 = 12, AMD64_XMM13 = 13, AMD64_XMM14 = 14, AMD64_XMM15 = 15, AMD64_XMM_NREG = 16, } AMD64_XMM_Reg_No; typedef enum { AMD64_REX_B = 1, /* The register in r/m field, base register in SIB byte, or reg in opcode is 8-15 rather than 0-7 */ AMD64_REX_X = 2, /* The index register in SIB byte is 8-15 rather than 0-7 */ AMD64_REX_R = 4, /* The reg field of ModRM byte is 8-15 rather than 0-7 */ AMD64_REX_W = 8 /* Opeartion is 64-bits instead of 32 (default) or 16 (with 0x66 prefix) */ } AMD64_REX_Bits; #define amd64_codegen_pre(inst) #define amd64_codegen_post(inst) #ifdef TARGET_WIN32 #define AMD64_ARG_REG1 AMD64_RCX #define AMD64_ARG_REG2 AMD64_RDX #define AMD64_ARG_REG3 AMD64_R8 #define AMD64_ARG_REG4 AMD64_R9 #else #define AMD64_ARG_REG1 AMD64_RDI #define AMD64_ARG_REG2 AMD64_RSI #define AMD64_ARG_REG3 AMD64_RDX #define AMD64_ARG_REG4 AMD64_RCX #endif #ifdef TARGET_WIN32 #define AMD64_CALLEE_REGS ((1<<AMD64_RAX) | (1<<AMD64_RCX) | (1<<AMD64_RDX) | (1<<AMD64_R8) | (1<<AMD64_R9) | (1<<AMD64_R10)) #define AMD64_IS_CALLEE_REG(reg) (AMD64_CALLEE_REGS & (1 << (reg))) #define AMD64_ARGUMENT_REGS ((1<<AMD64_RDX) | (1<<AMD64_RCX) | (1<<AMD64_R8) | (1<<AMD64_R9)) #define AMD64_IS_ARGUMENT_REG(reg) (AMD64_ARGUMENT_REGS & (1 << (reg))) /* xmm0-xmm3 for standard calling convention, additionally xmm4-xmm5 for __vectorcall (not currently used) */ #define AMD64_ARGUMENT_XREGS ((1<<AMD64_XMM0) | (1<<AMD64_XMM1) | (1<<AMD64_XMM2) | (1<<AMD64_XMM3) | (1<<AMD64_XMM4) | (1<<AMD64_XMM5)) #define AMD64_IS_ARGUMENT_XREG(reg) (AMD64_ARGUMENT_XREGS & (1 << (reg))) #define AMD64_CALLEE_SAVED_REGS ((1<<AMD64_RDI) | (1<<AMD64_RSI) | (1<<AMD64_RBX) | (1<<AMD64_R12) | (1<<AMD64_R13) | (1<<AMD64_R14) | (1<<AMD64_R15) | (1<<AMD64_RBP)) #define AMD64_IS_CALLEE_SAVED_REG(reg) (AMD64_CALLEE_SAVED_REGS & (1 << (reg))) #else #define AMD64_CALLEE_REGS ((1<<AMD64_RAX) | (1<<AMD64_RCX) | (1<<AMD64_RDX) | (1<<AMD64_RSI) | (1<<AMD64_RDI) | (1<<AMD64_R8) | (1<<AMD64_R9) | (1<<AMD64_R10)) #define AMD64_IS_CALLEE_REG(reg) (AMD64_CALLEE_REGS & (1 << (reg))) #define AMD64_ARGUMENT_REGS ((1<<AMD64_RDI) | (1<<AMD64_RSI) | (1<<AMD64_RDX) | (1<<AMD64_RCX) | (1<<AMD64_R8) | (1<<AMD64_R9)) #define AMD64_IS_ARGUMENT_REG(reg) (AMD64_ARGUMENT_REGS & (1 << (reg))) #define AMD64_ARGUMENT_XREGS ((1<<AMD64_XMM0) | (1<<AMD64_XMM1) | (1<<AMD64_XMM2) | (1<<AMD64_XMM3) | (1<<AMD64_XMM4) | (1<<AMD64_XMM5) | (1<<AMD64_XMM6) | (1<<AMD64_XMM7)) #define AMD64_IS_ARGUMENT_XREG(reg) (AMD64_ARGUMENT_XREGS & (1 << (reg))) #define AMD64_CALLEE_SAVED_REGS ((1<<AMD64_RBX) | (1<<AMD64_R12) | (1<<AMD64_R13) | (1<<AMD64_R14) | (1<<AMD64_R15) | (1<<AMD64_RBP)) #define AMD64_IS_CALLEE_SAVED_REG(reg) (AMD64_CALLEE_SAVED_REGS & (1 << (reg))) #endif #define AMD64_REX(bits) ((unsigned char)(0x40 | (bits))) #define amd64_emit_rex(inst, width, reg_modrm, reg_index, reg_rm_base_opcode) do \ { \ unsigned char _amd64_rex_bits = \ (((width) > 4) ? AMD64_REX_W : 0) | \ (((reg_modrm) > 7) ? AMD64_REX_R : 0) | \ (((reg_index) > 7) ? AMD64_REX_X : 0) | \ (((reg_rm_base_opcode) > 7) ? AMD64_REX_B : 0); \ if ((_amd64_rex_bits != 0) || (((width) == 1))) *(inst)++ = AMD64_REX(_amd64_rex_bits); \ } while (0) typedef union { guint64 val; unsigned char b [8]; } amd64_imm_buf; #include "../x86/x86-codegen.h" /* In 64 bit mode, all registers have a low byte subregister */ #undef X86_IS_BYTE_REG #define X86_IS_BYTE_REG(reg) 1 #define amd64_modrm_mod(modrm) ((modrm) >> 6) #define amd64_modrm_reg(modrm) (((modrm) >> 3) & 0x7) #define amd64_modrm_rm(modrm) ((modrm) & 0x7) #define amd64_rex_r(rex) ((((rex) >> 2) & 0x1) << 3) #define amd64_rex_x(rex) ((((rex) >> 1) & 0x1) << 3) #define amd64_rex_b(rex) ((((rex) >> 0) & 0x1) << 3) #define amd64_sib_scale(sib) ((sib) >> 6) #define amd64_sib_index(sib) (((sib) >> 3) & 0x7) #define amd64_sib_base(sib) ((sib) & 0x7) #define amd64_is_imm32(val) ((gint64)val >= -((gint64)1<<31) && (gint64)val <= (((gint64)1<<31)-1)) #define x86_imm_emit64(inst,imm) \ do { \ amd64_imm_buf imb; \ imb.val = (guint64) (imm); \ *(inst)++ = imb.b [0]; \ *(inst)++ = imb.b [1]; \ *(inst)++ = imb.b [2]; \ *(inst)++ = imb.b [3]; \ *(inst)++ = imb.b [4]; \ *(inst)++ = imb.b [5]; \ *(inst)++ = imb.b [6]; \ *(inst)++ = imb.b [7]; \ } while (0) #define amd64_membase_emit(inst,reg,basereg,disp) do { \ if ((basereg) == AMD64_RIP) { \ x86_address_byte ((inst), 0, (reg)&0x7, 5); \ x86_imm_emit32 ((inst), (disp)); \ } \ else \ x86_membase_emit ((inst),(reg)&0x7, (basereg)&0x7, (disp)); \ } while (0) #define amd64_alu_reg_imm_size_body(inst,opc,reg,imm,size) \ do { \ if (x86_is_imm8((imm))) { \ amd64_emit_rex(inst, size, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x83; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((reg) == AMD64_RAX) { \ amd64_emit_rex(inst, size, 0, 0, 0); \ *(inst)++ = (((unsigned char)(opc)) << 3) + 5; \ x86_imm_emit32 ((inst), (imm)); \ } else { \ amd64_emit_rex(inst, size, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x81; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define amd64_alu_reg_reg_size_body(inst,opc,dreg,reg,size) \ do { \ amd64_emit_rex(inst, size, (dreg), 0, (reg)); \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define amd64_test_reg_imm_size_body(inst,reg,imm,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),0,0,(reg)); \ if ((reg) == AMD64_RAX) { \ *(inst)++ = (unsigned char)0xa9; \ } \ else { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit((inst), 0, (reg)); \ } \ x86_imm_emit32((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) \ amd64_alu_reg_imm_size_body((inst), (opc), (reg), (imm), (size)) #define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) \ amd64_alu_reg_reg_size_body((inst), (opc), (dreg), (reg), (size)) #define amd64_test_reg_imm_size(inst, reg, imm, size) \ amd64_test_reg_imm_size_body(inst, reg, imm, size) #define amd64_alu_reg_imm(inst,opc,reg,imm) amd64_alu_reg_imm_size((inst),(opc),(reg),(imm),8) #define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size ((inst),(opc),(dreg),(reg),8) #define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8) #define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),(reg),0,(basereg)); \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ amd64_membase_emit (inst, reg, basereg, disp); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_regp_reg(inst,regp,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, (regp)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_regp_emit ((inst), (reg), (regp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_membase_reg(inst,basereg,disp,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_mem_reg(inst,mem,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, 0); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_address_byte ((inst), 0, (reg), 4); \ x86_address_byte ((inst), 0, 4, 5); \ x86_imm_emit32 ((inst), (mem)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_reg(inst,dreg,reg,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (dreg), 0, (reg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_mem_body(inst,reg,mem,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, 0); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_address_byte ((inst), 0, (reg), 4); \ x86_address_byte ((inst), 0, 4, 5); \ x86_imm_emit32 ((inst), (mem)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_mem(inst,reg,mem,size) \ do { \ amd64_mov_reg_mem_body((inst),(reg),(mem),(size)); \ } while (0) #define amd64_mov_reg_membase_body(inst,reg,basereg,disp,size) \ do { \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define amd64_mov_reg_memindex_size_body(inst,reg,basereg,disp,indexreg,shift,size) \ do { \ amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); \ x86_mov_reg_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(size) == 8 ? 4 : (size)); \ } while (0) #define amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) \ amd64_mov_reg_memindex_size_body((inst),(reg),(basereg),(disp),(indexreg),(shift),(size)) #define amd64_mov_reg_membase(inst,reg,basereg,disp,size) \ do { \ amd64_mov_reg_membase_body((inst), (reg), (basereg), (disp), (size)); \ } while (0) #define amd64_movzx_reg_membase(inst,reg,basereg,disp,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xb6; break; \ case 2: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xb7; break; \ case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsxd_reg_mem(inst,reg,mem) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst,8,(reg),0,0); \ *(inst)++ = (unsigned char)0x63; \ x86_mem_emit ((inst), ((reg)&0x7), (mem)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsxd_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst,8,(reg),0,(basereg)); \ *(inst)++ = (unsigned char)0x63; \ x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsxd_reg_reg(inst,dreg,reg) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst,8,(dreg),0,(reg)); \ *(inst)++ = (unsigned char)0x63; \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) /* Pretty much the only instruction that supports a 64-bit immediate. Optimize for common case of * 32-bit immediate. Pepper with casts to avoid warnings. */ #define amd64_mov_reg_imm_size(inst,reg,imm,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, (size), 0, 0, (reg)); \ *(inst)++ = (unsigned char)0xb8 + ((reg) & 0x7); \ if ((size) == 8) \ x86_imm_emit64 ((inst), (guint64)(imm)); \ else \ x86_imm_emit32 ((inst), (int)(guint64)(imm)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_mov_reg_imm(inst,reg,imm) \ do { \ amd64_codegen_pre(inst); \ amd64_mov_reg_imm_size ((inst), (reg), (imm), (amd64_is_imm32 (((gint64)imm)) ? 4 : 8)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_set_reg_template(inst,reg) amd64_mov_reg_imm_size ((inst),(reg), 0, 8) #define amd64_set_template(inst,reg) amd64_set_reg_template((inst),(reg)) #define amd64_mov_membase_imm(inst,basereg,disp,imm,size) \ do { \ amd64_codegen_pre(inst); \ if ((size) == 2) \ x86_prefix((inst), X86_OPERAND_PREFIX); \ amd64_emit_rex(inst, (size) == 1 ? 0 : (size), 0, 0, (basereg)); \ if ((size) == 1) { \ *(inst)++ = (unsigned char)0xc6; \ x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((size) == 2) { \ *(inst)++ = (unsigned char)0xc7; \ x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \ x86_imm_emit16 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0xc7; \ x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \ x86_imm_emit32 ((inst), (imm)); \ } \ amd64_codegen_post(inst); \ } while (0) #define amd64_lea_membase_body(inst,reg,basereg,disp,width) \ do { \ amd64_emit_rex(inst, width, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x8d; \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define amd64_lea4_membase(inst,reg,basereg,disp) \ amd64_lea_membase_body((inst), (reg), (basereg), (disp), 4) #define amd64_lea_membase(inst,reg,basereg,disp) \ amd64_lea_membase_body((inst), (reg), (basereg), (disp), 8) /* Instruction are implicitly 64-bits so don't generate REX for just the size. */ #define amd64_push_reg(inst,reg) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, 0, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x50 + ((reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) /* Instruction is implicitly 64-bits so don't generate REX for just the size. */ #define amd64_push_membase(inst,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, 0, 0, 0, (basereg)); \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 6, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_pop_reg_body(inst,reg) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex(inst, 0, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0x58 + ((reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_call_reg(inst,reg) \ do { \ amd64_emit_rex(inst, 0, 0, 0, (reg)); \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst), 2, ((reg) & 0x7)); \ } while (0) #define amd64_ret(inst) do { *(inst)++ = (unsigned char)0xc3; } while (0) #define amd64_leave(inst) do { *(inst)++ = (unsigned char)0xc9; } while (0) #define amd64_pop_reg(inst,reg) amd64_pop_reg_body((inst), (reg)) #define amd64_movsd_reg_regp(inst,reg,regp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsd_regp_reg(inst,regp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_reg_regp(inst,reg,regp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_regp_reg(inst,regp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (regp)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movdqu_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x6f; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsd_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_reg_membase(inst,reg,basereg,disp) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x10; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movdqu_membase_reg(inst,basereg,disp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x7f; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movsd_membase_reg(inst,basereg,disp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf2); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) #define amd64_movss_membase_reg(inst,basereg,disp,reg) \ do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), 0xf3); \ amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0x11; \ x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \ amd64_codegen_post(inst); \ } while (0) /* The original inc_reg opcode is used as the REX prefix */ #define amd64_inc_reg_size(inst,reg,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),0,0,(reg)); \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst),0,(reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_dec_reg_size(inst,reg,size) \ do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),(size),0,0,(reg)); \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst),1,(reg) & 0x7); \ amd64_codegen_post(inst); \ } while (0) #define amd64_fld_membase_size(inst,basereg,disp,is_double,size) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst),0,0,0,(basereg)); \ *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \ amd64_membase_emit ((inst), 0, (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) /* From the AMD64 Software Optimization Manual */ #define amd64_padding_size(inst,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = 0x90; break; \ case 2: *(inst)++ = 0x66; *(inst)++ = 0x90; break; \ case 3: *(inst)++ = 0x66; *(inst)++ = 0x66; *(inst)++ = 0x90; break; \ default: amd64_emit_rex ((inst),8,0,0,0); x86_padding ((inst), (size) - 1); \ }; \ } while (0) #define amd64_call_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); *(inst)++ = (unsigned char)0xff; amd64_membase_emit ((inst),2, (basereg),(disp)); } while (0) #define amd64_jump_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); *(inst)++ = (unsigned char)0xff; amd64_membase_emit ((inst), 4, (basereg), (disp)); } while (0) #define amd64_jump_code_size(inst,target,size) do { \ if (amd64_is_imm32 ((gint64)(target) - (gint64)(inst))) { \ x86_jump_code((inst),(target)); \ } else { \ amd64_jump_membase ((inst), AMD64_RIP, 0); \ *(guint64*)(inst) = (guint64)(target); \ (inst) += 8; \ } \ } while (0) /* * SSE */ //TODO Reorganize SSE opcode defines. /* Two opcode SSE defines */ #define emit_sse_reg_reg_op2_size(inst,dreg,reg,op1,op2,size) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_reg_op2(inst,dreg,reg,op1,op2) emit_sse_reg_reg_op2_size ((inst), (dreg), (reg), (op1), (op2), 0) #define emit_sse_reg_reg_op2_imm(inst,dreg,reg,op1,op2,imm) do { \ amd64_codegen_pre(inst); \ emit_sse_reg_reg_op2 ((inst), (dreg), (reg), (op1), (op2)); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_membase_reg_op2(inst,basereg,disp,reg,op1,op2) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst), 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_membase_op2(inst,dreg,basereg,disp,op1,op2) do { \ amd64_codegen_pre(inst); \ amd64_emit_rex ((inst), 0, (dreg), 0, (basereg) == AMD64_RIP ? 0 : (basereg)); \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ amd64_membase_emit ((inst), (dreg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) /* Three opcode SSE defines */ #define emit_opcode3(inst,op1,op2,op3) do { \ *(inst)++ = (unsigned char)(op1); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ } while (0) #define emit_sse_reg_reg_size(inst,dreg,reg,op1,op2,op3,size) do { \ amd64_codegen_pre(inst); \ *(inst)++ = (unsigned char)(op1); \ amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_reg(inst,dreg,reg,op1,op2,op3) emit_sse_reg_reg_size ((inst), (dreg), (reg), (op1), (op2), (op3), 0) #define emit_sse_reg_reg_imm(inst,dreg,reg,op1,op2,op3,imm) do { \ amd64_codegen_pre(inst); \ emit_sse_reg_reg ((inst), (dreg), (reg), (op1), (op2), (op3)); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_membase_reg(inst,basereg,disp,reg,op1,op2,op3) do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), (unsigned char)(op1)); \ amd64_emit_rex ((inst), 0, (reg), 0, (basereg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ amd64_membase_emit ((inst), (reg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_membase(inst,dreg,basereg,disp,op1,op2,op3) do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), (unsigned char)(op1)); \ amd64_emit_rex ((inst), 0, (dreg), 0, (basereg) == AMD64_RIP ? 0 : (basereg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ amd64_membase_emit ((inst), (dreg), (basereg), (disp)); \ amd64_codegen_post(inst); \ } while (0) /* Four opcode SSE defines */ #define emit_sse_reg_reg_op4_size(inst,dreg,reg,op1,op2,op3,op4,size) do { \ amd64_codegen_pre(inst); \ x86_prefix((inst), (unsigned char)(op1)); \ amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \ *(inst)++ = (unsigned char)(op2); \ *(inst)++ = (unsigned char)(op3); \ *(inst)++ = (unsigned char)(op4); \ x86_reg_emit ((inst), (dreg), (reg)); \ amd64_codegen_post(inst); \ } while (0) #define emit_sse_reg_reg_op4(inst,dreg,reg,op1,op2,op3,op4) emit_sse_reg_reg_op4_size ((inst), (dreg), (reg), (op1), (op2), (op3), (op4), 0) #define emit_sse_reg_reg_op4_imm(inst,dreg,reg,op1,op2,op3,op4,imm) do { \ amd64_codegen_pre(inst); \ emit_sse_reg_reg_op4 ((inst), (dreg), (reg), (op1), (op2), (op3), (op4)); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) /* specific SSE opcode defines */ #define amd64_sse_xorpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg), 0x66, 0x0f, 0x57) #define amd64_sse_xorpd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst),(dreg),(basereg), (disp), 0x66, 0x0f, 0x57) #define amd64_sse_andpd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst),(dreg),(basereg), (disp), 0x66, 0x0f, 0x54) #define amd64_sse_movsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x10) #define amd64_sse_movss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x10) #define amd64_sse_movsd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf2, 0x0f, 0x10) #define amd64_sse_movsd_membase_reg(inst,basereg,disp,reg) emit_sse_membase_reg ((inst), (basereg), (disp), (reg), 0xf2, 0x0f, 0x11) #define amd64_sse_movss_membase_reg(inst,basereg,disp,reg) emit_sse_membase_reg ((inst), (basereg), (disp), (reg), 0xf3, 0x0f, 0x11) #define amd64_sse_movss_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf3, 0x0f, 0x10) #define amd64_sse_comisd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x66,0x0f,0x2f) #define amd64_sse_comiss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x67,0x0f,0x2f) #define amd64_sse_comisd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x2f) #define amd64_sse_ucomisd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x66,0x0f,0x2e) #define amd64_sse_cvtsd2si_reg_reg(inst,dreg,reg) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2d, 8) #define amd64_sse_cvtss2si_reg_reg(inst,dreg,reg) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf3, 0x0f, 0x2d, 8) #define amd64_sse_cvttsd2si_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2c, (size)) #define amd64_sse_cvtss2si_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf3, 0x0f, 0x2c, (size)) #define amd64_sse_cvttsd2si_reg_reg(inst,dreg,reg) amd64_sse_cvttsd2si_reg_reg_size ((inst), (dreg), (reg), 8) #define amd64_sse_cvtsi2sd_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2a, (size)) #define amd64_sse_cvtsi2sd_reg_reg(inst,dreg,reg) amd64_sse_cvtsi2sd_reg_reg_size ((inst), (dreg), (reg), 8) #define amd64_sse_cvtsi2ss_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf3, 0x0f, 0x2a, (size)) #define amd64_sse_cvtsi2ss_reg_reg(inst,dreg,reg) amd64_sse_cvtsi2ss_reg_reg_size ((inst), (dreg), (reg), 8) #define amd64_sse_cvtsd2ss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5a) #define amd64_sse_cvtss2sd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5a) #define amd64_sse_addsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x58) #define amd64_sse_addss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x58) #define amd64_sse_subsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5c) #define amd64_sse_subss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5c) #define amd64_sse_mulsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x59) #define amd64_sse_mulss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x59) #define amd64_sse_divsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5e) #define amd64_sse_divss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5e) #define amd64_sse_sqrtsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x51) #define amd64_sse_pinsrw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm ((inst), (dreg), (reg), 0x66, 0x0f, 0xc4, (imm)) #define amd64_sse_pextrw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm ((inst), (dreg), (reg), 0x66, 0x0f, 0xc5, (imm)) #define amd64_sse_cvttsd2si_reg_xreg_size(inst,reg,xreg,size) emit_sse_reg_reg_size ((inst), (reg), (xreg), 0xf2, 0x0f, 0x2c, (size)) #define amd64_sse_addps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x58) #define amd64_sse_divps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5e) #define amd64_sse_mulps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x59) #define amd64_sse_subps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5c) #define amd64_sse_maxps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5f) #define amd64_sse_minps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5d) #define amd64_sse_cmpps_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_op2_imm((inst), (dreg), (reg), 0x0f, 0xc2, (imm)) #define amd64_sse_andps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x54) #define amd64_sse_andnps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x55) #define amd64_sse_orps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x56) #define amd64_sse_xorps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x57) #define amd64_sse_sqrtps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x51) #define amd64_sse_rsqrtps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x52) #define amd64_sse_rcpps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x53) #define amd64_sse_addsubps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0xd0) #define amd64_sse_haddps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x7c) #define amd64_sse_hsubps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x7d) #define amd64_sse_movshdup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf3, 0x0f, 0x16) #define amd64_sse_movsldup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf3, 0x0f, 0x12) #define amd64_sse_pshufhw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0xf3, 0x0f, 0x70, (imm)) #define amd64_sse_pshuflw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0xf2, 0x0f, 0x70, (imm)) #define amd64_sse_pshufd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0x70, (imm)) #define amd64_sse_shufps_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_op2_imm((inst), (dreg), (reg), 0x0f, 0xC6, (imm)) #define amd64_sse_shufpd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0xC6, (imm)) #define amd64_sse_roundpd_reg_reg_imm(inst, dreg, reg, imm) emit_sse_reg_reg_op4_imm((inst), (dreg), (reg), 0x66, 0x0f, 0x3a, 0x09, (imm)) #define amd64_sse_addpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x58) #define amd64_sse_divpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5e) #define amd64_sse_mulpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x59) #define amd64_sse_subpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5c) #define amd64_sse_maxpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5f) #define amd64_sse_minpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5d) #define amd64_sse_cmppd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0xc2, (imm)) #define amd64_sse_andpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x54) #define amd64_sse_andnpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x55) #define amd64_sse_orpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x56) #define amd64_sse_sqrtpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x51) #define amd64_sse_rsqrtpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x52) #define amd64_sse_rcppd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x53) #define amd64_sse_addsubpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd0) #define amd64_sse_haddpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x7c) #define amd64_sse_hsubpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x7d) #define amd64_sse_movddup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x12) #define amd64_sse_pmovmskb_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd7) #define amd64_sse_pand_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdb) #define amd64_sse_pandn_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdf) #define amd64_sse_por_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xeb) #define amd64_sse_pxor_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xef) #define amd64_sse_paddb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfc) #define amd64_sse_paddw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfd) #define amd64_sse_paddd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfe) #define amd64_sse_paddq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd4) #define amd64_sse_psubb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf8) #define amd64_sse_psubw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf9) #define amd64_sse_psubd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfa) #define amd64_sse_psubq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfb) #define amd64_sse_pmaxub_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xde) #define amd64_sse_pmaxuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3e) #define amd64_sse_pmaxud_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3f) #define amd64_sse_pmaxsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3c) #define amd64_sse_pmaxsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xee) #define amd64_sse_pmaxsd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3d) #define amd64_sse_pavgb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe0) #define amd64_sse_pavgw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe3) #define amd64_sse_pminub_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xda) #define amd64_sse_pminuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3a) #define amd64_sse_pminud_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3b) #define amd64_sse_pminsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x38) #define amd64_sse_pminsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xea) #define amd64_sse_pminsd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x39) #define amd64_sse_pcmpeqb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x74) #define amd64_sse_pcmpeqw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x75) #define amd64_sse_pcmpeqd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x76) #define amd64_sse_pcmpeqq_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x29) #define amd64_sse_pcmpgtb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x64) #define amd64_sse_pcmpgtw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x65) #define amd64_sse_pcmpgtd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x66) #define amd64_sse_pcmpgtq_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x37) #define amd64_sse_psadbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf6) #define amd64_sse_punpcklbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x60) #define amd64_sse_punpcklwd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x61) #define amd64_sse_punpckldq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x62) #define amd64_sse_punpcklqdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6c) #define amd64_sse_unpcklpd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x14) #define amd64_sse_unpcklps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x14) #define amd64_sse_punpckhbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x68) #define amd64_sse_punpckhwd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x69) #define amd64_sse_punpckhdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6a) #define amd64_sse_punpckhqdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6d) #define amd64_sse_unpckhpd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x15) #define amd64_sse_unpckhps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x15) #define amd64_sse_packsswb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x63) #define amd64_sse_packssdw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6b) #define amd64_sse_packuswb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x67) #define amd64_sse_packusdw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x2b) #define amd64_sse_paddusb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdc) #define amd64_sse_psubusb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd8) #define amd64_sse_paddusw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdd) #define amd64_sse_psubusw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd8) #define amd64_sse_paddsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xec) #define amd64_sse_psubsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe8) #define amd64_sse_paddsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xed) #define amd64_sse_psubsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe9) #define amd64_sse_pmullw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd5) #define amd64_sse_pmulld_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x40) #define amd64_sse_pmuludq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf4) #define amd64_sse_pmulhuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe4) #define amd64_sse_pmulhw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe5) #define amd64_sse_psrlw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x71, (imm)) #define amd64_sse_psrlw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd1) #define amd64_sse_psraw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x71, (imm)) #define amd64_sse_psraw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe1) #define amd64_sse_psllw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x71, (imm)) #define amd64_sse_psllw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf1) #define amd64_sse_psrld_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x72, (imm)) #define amd64_sse_psrld_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd2) #define amd64_sse_psrad_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x72, (imm)) #define amd64_sse_psrad_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe2) #define amd64_sse_pslld_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x72, (imm)) #define amd64_sse_pslld_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf2) #define amd64_sse_psrlq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x73, (imm)) #define amd64_sse_psrlq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd3) #define amd64_sse_psraq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x73, (imm)) #define amd64_sse_psraq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe3) #define amd64_sse_psllq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x73, (imm)) #define amd64_sse_psllq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf3) #define amd64_sse_cvtdq2pd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xF3, 0x0F, 0xE6) #define amd64_sse_cvtdq2ps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0F, 0x5B) #define amd64_sse_cvtpd2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xF2, 0x0F, 0xE6) #define amd64_sse_cvtpd2ps_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0F, 0x5A) #define amd64_sse_cvtps2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0F, 0x5B) #define amd64_sse_cvtps2pd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0F, 0x5A) #define amd64_sse_cvttpd2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0F, 0xE6) #define amd64_sse_cvttps2dq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xF3, 0x0F, 0x5B) #define amd64_movd_xreg_reg_size(inst,dreg,sreg,size) emit_sse_reg_reg_size((inst), (dreg), (sreg), 0x66, 0x0f, 0x6e, (size)) #define amd64_movd_reg_xreg_size(inst,dreg,sreg,size) emit_sse_reg_reg_size((inst), (sreg), (dreg), 0x66, 0x0f, 0x7e, (size)) #define amd64_movd_xreg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x6e) #define amd64_movlhps_reg_reg(inst,dreg,sreg) emit_sse_reg_reg_op2((inst), (dreg), (sreg), 0x0f, 0x16) #define amd64_movhlps_reg_reg(inst,dreg,sreg) emit_sse_reg_reg_op2((inst), (dreg), (sreg), 0x0f, 0x12) #define amd64_sse_movups_membase_reg(inst, basereg, disp, reg) emit_sse_membase_reg_op2((inst), (basereg), (disp), (reg), 0x0f, 0x11) #define amd64_sse_movups_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x10) #define amd64_sse_movaps_membase_reg(inst, basereg, disp, reg) emit_sse_membase_reg_op2((inst), (basereg), (disp), (reg), 0x0f, 0x29) #define amd64_sse_movaps_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x28) #define amd64_sse_movaps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x28) #define amd64_sse_movntps_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x2b) #define amd64_sse_prefetch_reg_membase(inst, arg, basereg, disp) emit_sse_reg_membase_op2((inst), (arg), (basereg), (disp), 0x0f, 0x18) #define amd64_sse_lzcnt_reg_reg_size(inst, dreg, reg, size) emit_sse_reg_reg_size((inst), (dreg), (reg), 0xf3, 0x0f, 0xbd, (size)) #define amd64_sse_popcnt_reg_reg_size(inst, dreg, reg, size) emit_sse_reg_reg_size((inst), (dreg), (reg), 0xf3, 0x0f, 0xb8, (size)) /* Generated from x86-codegen.h */ #define amd64_breakpoint_size(inst,size) do { x86_breakpoint(inst); } while (0) #define amd64_cld_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_cld(inst); amd64_codegen_post(inst); } while (0) #define amd64_stosb_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_stosb(inst); amd64_codegen_post(inst); } while (0) #define amd64_stosl_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_stosl(inst); amd64_codegen_post(inst); } while (0) #define amd64_stosd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_stosd(inst); amd64_codegen_post(inst); } while (0) #define amd64_movsb_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_movsb(inst); amd64_codegen_post(inst); } while (0) #define amd64_movsl_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_movsl(inst); amd64_codegen_post(inst); } while (0) #define amd64_movsd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_movsd(inst); amd64_codegen_post(inst); } while (0) #define amd64_prefix_size(inst,p,size) do { x86_prefix((inst), p); } while (0) #define amd64_rdtsc_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_rdtsc(inst); amd64_codegen_post(inst); } while (0) #define amd64_cmpxchg_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_cmpxchg_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_cmpxchg_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_cmpxchg_mem_reg((inst),(mem),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_cmpxchg_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_cmpxchg_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_xchg_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_xchg_reg_reg((inst),((dreg)&0x7),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_xchg_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_xchg_mem_reg((inst),(mem),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_xchg_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_xchg_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_inc_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_inc_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_inc_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_inc_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) //#define amd64_inc_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_inc_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_dec_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_dec_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_dec_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_dec_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) //#define amd64_dec_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_dec_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_not_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_not_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_not_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_not_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_not_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_not_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_neg_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_neg_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_neg_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_neg_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_neg_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_neg_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_nop_size(inst,size) do { amd64_codegen_pre(inst); x86_nop(inst); amd64_codegen_post(inst); } while (0) //#define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_imm((inst),(opc),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_mem_imm_size(inst,opc,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_alu_mem_imm((inst),(opc),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_membase_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_alu_membase_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_membase8_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_alu_membase8_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_alu_mem_reg_size(inst,opc,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_mem_reg((inst),(opc),(mem),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_alu_membase_reg_size(inst,opc,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_membase_reg((inst),(opc),((basereg)&0x7),(disp),((reg)&0x7)); amd64_codegen_post(inst); } while (0) //#define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg_reg((inst),(opc),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg8_reg8((inst),(opc),((dreg)&0x7),((reg)&0x7),(is_dreg_h),(is_reg_h)); amd64_codegen_post(inst); } while (0) #define amd64_alu_reg_mem_size(inst,opc,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_mem((inst),(opc),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) //#define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_reg_membase((inst),(opc),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) //#define amd64_test_reg_imm_size(inst,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_reg_imm((inst),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_test_mem_imm_size(inst,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_test_mem_imm((inst),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_test_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_test_membase_imm((inst),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_test_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_test_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_test_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_mem_reg((inst),(mem),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_test_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_test_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shift_reg_imm_size(inst,opc,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_reg_imm((inst),(opc),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_shift_mem_imm_size(inst,opc,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_mem_imm((inst),(opc),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_shift_membase_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_shift_membase_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_shift_reg_size(inst,opc,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_reg((inst),(opc),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shift_mem_size(inst,opc,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_mem((inst),(opc),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_shift_membase_size(inst,opc,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_shift_membase((inst),(opc),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_shrd_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shrd_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shrd_reg_imm_size(inst,dreg,reg,shamt,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shrd_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(shamt)); amd64_codegen_post(inst); } while (0) #define amd64_shld_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shld_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_shld_reg_imm_size(inst,dreg,reg,shamt,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shld_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(shamt)); amd64_codegen_post(inst); } while (0) #define amd64_mul_reg_size(inst,reg,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mul_reg((inst),((reg)&0x7),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_mul_mem_size(inst,mem,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_mul_mem((inst),(mem),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_mul_membase_size(inst,basereg,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_mul_membase((inst),((basereg)&0x7),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_imul_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_mem_size(inst,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_imul_reg_mem((inst),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_membase_size(inst,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_imul_reg_membase((inst),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_reg_imm_size(inst,dreg,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_imul_reg_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_mem_imm_size(inst,reg,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_imul_reg_mem_imm((inst),((reg)&0x7),(mem),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_imul_reg_membase_imm_size(inst,reg,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_imul_reg_membase_imm((inst),((reg)&0x7),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_div_reg_size(inst,reg,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_div_reg((inst),((reg)&0x7),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_div_mem_size(inst,mem,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_div_mem((inst),(mem),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_div_membase_size(inst,basereg,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_div_membase((inst),((basereg)&0x7),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_mov_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_mem_reg((inst),(mem),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_regp_reg_size(inst,regp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(regp),0,(reg)); x86_mov_regp_reg((inst),(regp),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_mov_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_mov_memindex_reg_size(inst,basereg,disp,indexreg,shift,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_mov_memindex_reg((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),((reg)&0x7),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_mem_size(inst,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_reg_mem((inst),((reg)&0x7),(mem),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_membase_size(inst,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_mov_reg_membase((inst),((reg)&0x7),((basereg)&0x7),(disp),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_mov_reg_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_clear_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_clear_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_reg_imm_size(inst,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_reg_imm((inst),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_mov_mem_imm_size(inst,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_mov_mem_imm((inst),(mem),(imm),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) //#define amd64_mov_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_mov_membase_imm((inst),((basereg)&0x7),(disp),(imm),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_mov_memindex_imm_size(inst,basereg,disp,indexreg,shift,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,(indexreg),(basereg)); x86_mov_memindex_imm((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(imm),(size) == 8 ? 4 : (size)); amd64_codegen_post(inst); } while (0) #define amd64_lea_mem_size(inst,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_lea_mem((inst),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) //#define amd64_lea_membase_size(inst,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_lea_membase((inst),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_lea_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift)); amd64_codegen_post(inst); } while (0) #define amd64_widen_reg_size(inst,dreg,reg,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_widen_reg((inst),((dreg)&0x7),((reg)&0x7),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_widen_mem_size(inst,dreg,mem,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,0); x86_widen_mem((inst),((dreg)&0x7),(mem),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_widen_membase_size(inst,dreg,basereg,disp,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(basereg)); x86_widen_membase((inst),((dreg)&0x7),((basereg)&0x7),(disp),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_widen_memindex_size(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),(indexreg),(basereg)); x86_widen_memindex((inst),((dreg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(is_signed),(is_half)); amd64_codegen_post(inst); } while (0) #define amd64_cdq_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_cdq(inst); amd64_codegen_post(inst); } while (0) #define amd64_wait_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_wait(inst); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_mem_size(inst,opc,mem,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fp_op_mem((inst),(opc),(mem),(is_double)); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_membase_size(inst,opc,basereg,disp,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fp_op_membase((inst),(opc),((basereg)&0x7),(disp),(is_double)); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_size(inst,opc,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fp_op((inst),(opc),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fp_op_reg_size(inst,opc,index,pop_stack,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fp_op_reg((inst),(opc),(index),(pop_stack)); amd64_codegen_post(inst); } while (0) #define amd64_fp_int_op_membase_size(inst,opc,basereg,disp,is_int,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fp_int_op_membase((inst),(opc),((basereg)&0x7),(disp),(is_int)); amd64_codegen_post(inst); } while (0) #define amd64_fstp_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fstp((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fcompp_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fcompp(inst); amd64_codegen_post(inst); } while (0) #define amd64_fucompp_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fucompp(inst); amd64_codegen_post(inst); } while (0) #define amd64_fnstsw_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fnstsw(inst); amd64_codegen_post(inst); } while (0) #define amd64_fnstcw_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fnstcw((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fnstcw_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_fnstcw_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fldcw_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fldcw((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fldcw_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fldcw_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fchs_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fchs(inst); amd64_codegen_post(inst); } while (0) #define amd64_frem_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_frem(inst); amd64_codegen_post(inst); } while (0) #define amd64_fxch_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fxch((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fcomi_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fcomi((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fcomip_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fcomip((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fucomi_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fucomi((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fucomip_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fucomip((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fld_size(inst,mem,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld((inst),(mem),(is_double)); amd64_codegen_post(inst); } while (0) //#define amd64_fld_membase_size(inst,basereg,disp,is_double,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fld_membase((inst),((basereg)&0x7),(disp),(is_double)); amd64_codegen_post(inst); } while (0) #define amd64_fld80_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld80_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fld80_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_fld80_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fild_size(inst,mem,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fild((inst),(mem),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fild_membase_size(inst,basereg,disp,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fild_membase((inst),((basereg)&0x7),(disp),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fld_reg_size(inst,index,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld_reg((inst),(index)); amd64_codegen_post(inst); } while (0) #define amd64_fldz_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fldz(inst); amd64_codegen_post(inst); } while (0) #define amd64_fld1_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fld1(inst); amd64_codegen_post(inst); } while (0) #define amd64_fldpi_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fldpi(inst); amd64_codegen_post(inst); } while (0) #define amd64_fst_size(inst,mem,is_double,pop_stack,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fst((inst),(mem),(is_double),(pop_stack)); amd64_codegen_post(inst); } while (0) #define amd64_fst_membase_size(inst,basereg,disp,is_double,pop_stack,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fst_membase((inst),((basereg)&0x7),(disp),(is_double),(pop_stack)); amd64_codegen_post(inst); } while (0) #define amd64_fst80_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fst80_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_fst80_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fst80_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_fist_pop_size(inst,mem,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_fist_pop((inst),(mem),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fist_pop_membase_size(inst,basereg,disp,is_long,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fist_pop_membase((inst),((basereg)&0x7),(disp),(is_long)); amd64_codegen_post(inst); } while (0) #define amd64_fstsw_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_fstsw(inst); amd64_codegen_post(inst); } while (0) #define amd64_fist_membase_size(inst,basereg,disp,is_int,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fist_membase((inst),((basereg)&0x7),(disp),(is_int)); amd64_codegen_post(inst); } while (0) //#define amd64_push_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_push_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_push_regp_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_push_regp((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_push_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_push_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) //#define amd64_push_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_push_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_push_memindex_size(inst,basereg,disp,indexreg,shift,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,(indexreg),(basereg)); x86_push_memindex((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift)); amd64_codegen_post(inst); } while (0) #define amd64_push_imm_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_push_imm((inst),(imm)); amd64_codegen_post(inst); } while (0) //#define amd64_pop_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_pop_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_pop_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_pop_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_pop_membase_size(inst,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_pop_membase((inst),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_pushad_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_pushad(inst); amd64_codegen_post(inst); } while (0) #define amd64_pushfd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_pushfd(inst); amd64_codegen_post(inst); } while (0) #define amd64_popad_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_popad(inst); amd64_codegen_post(inst); } while (0) #define amd64_popfd_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_popfd(inst); amd64_codegen_post(inst); } while (0) #define amd64_loop_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_loop((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_loope_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_loope((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_loopne_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_loopne((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_jump32_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_jump32((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_jump8_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_jump8((inst),(imm)); amd64_codegen_post(inst); } while (0) /* Defined above for Native Client, so they can be used in other macros */ #define amd64_jump_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),0,0,0,(reg)); x86_jump_reg((inst),((reg)&0x7)); } while (0) #define amd64_jump_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_jump_mem((inst),(mem)); } while (0) #define amd64_jump_disp_size(inst,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,0); x86_jump_disp((inst),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_branch8_size(inst,cond,imm,is_signed,size) do { x86_branch8((inst),(cond),(imm),(is_signed)); } while (0) #define amd64_branch32_size(inst,cond,imm,is_signed,size) do { x86_branch32((inst),(cond),(imm),(is_signed)); } while (0) #define amd64_branch_size_body(inst,cond,target,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_branch((inst),(cond),(target),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_branch_size(inst,cond,target,is_signed,size) do { amd64_branch_size_body((inst),(cond),(target),(is_signed),(size)); } while (0) #define amd64_branch_disp_size(inst,cond,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_branch_disp((inst),(cond),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_set_reg_size(inst,cond,reg,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex((inst),1,0,0,(reg)); x86_set_reg((inst),(cond),((reg)&0x7),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_set_mem_size(inst,cond,mem,is_signed,size) do { amd64_codegen_pre(inst); x86_set_mem((inst),(cond),(mem),(is_signed)); amd64_codegen_post(inst); } while (0) #define amd64_set_membase_size(inst,cond,basereg,disp,is_signed,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),0,0,0,(basereg)); x86_set_membase((inst),(cond),((basereg)&0x7),(disp),(is_signed)); amd64_codegen_post(inst); } while (0) //#define amd64_call_reg_size(inst,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_call_reg((inst),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_call_mem_size(inst,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_call_mem((inst),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_call_imm_size(inst,disp,size) do { x86_call_imm((inst),(disp)); } while (0) #define amd64_call_code_size(inst,target,size) do { x86_call_code((inst),(target)); } while (0) //#define amd64_ret_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_ret(inst); amd64_codegen_post(inst); } while (0) #define amd64_ret_imm_size(inst,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_ret_imm((inst),(imm)); amd64_codegen_post(inst); } while (0) #define amd64_cmov_reg_size(inst,cond,is_signed,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_cmov_reg((inst),(cond),(is_signed),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0) #define amd64_cmov_mem_size(inst,cond,is_signed,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_cmov_mem((inst),(cond),(is_signed),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0) #define amd64_cmov_membase_size(inst,cond,is_signed,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_cmov_membase((inst),(cond),(is_signed),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0) #define amd64_enter_size(inst,framesize) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_enter((inst),(framesize)); amd64_codegen_post(inst); } while (0) //#define amd64_leave_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_leave(inst); amd64_codegen_post(inst); } while (0) #define amd64_sahf_size(inst,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_sahf(inst); amd64_codegen_post(inst); } while (0) #define amd64_fsin_size(inst,size) do { amd64_codegen_pre(inst); x86_fsin(inst); amd64_codegen_post(inst); } while (0) #define amd64_fcos_size(inst,size) do { amd64_codegen_pre(inst); x86_fcos(inst); amd64_codegen_post(inst); } while (0) #define amd64_fabs_size(inst,size) do { amd64_codegen_pre(inst); x86_fabs(inst); amd64_codegen_post(inst); } while (0) #define amd64_ftst_size(inst,size) do { amd64_codegen_pre(inst); x86_ftst(inst); amd64_codegen_post(inst); } while (0) #define amd64_fxam_size(inst,size) do { amd64_codegen_pre(inst); x86_fxam(inst); amd64_codegen_post(inst); } while (0) #define amd64_fpatan_size(inst,size) do { amd64_codegen_pre(inst); x86_fpatan(inst); amd64_codegen_post(inst); } while (0) #define amd64_fprem_size(inst,size) do { amd64_codegen_pre(inst); x86_fprem(inst); amd64_codegen_post(inst); } while (0) #define amd64_fprem1_size(inst,size) do { amd64_codegen_pre(inst); x86_fprem1(inst); amd64_codegen_post(inst); } while (0) #define amd64_frndint_size(inst,size) do { amd64_codegen_pre(inst); x86_frndint(inst); amd64_codegen_post(inst); } while (0) #define amd64_fsqrt_size(inst,size) do { amd64_codegen_pre(inst); x86_fsqrt(inst); amd64_codegen_post(inst); } while (0) #define amd64_fptan_size(inst,size) do { amd64_codegen_pre(inst); x86_fptan(inst); amd64_codegen_post(inst); } while (0) //#define amd64_padding_size(inst,size) do { amd64_codegen_pre(inst); x86_padding((inst),(size)); amd64_codegen_post(inst); } while (0) #define amd64_prolog_size(inst,frame_size,reg_mask,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_prolog((inst),(frame_size),(reg_mask)); amd64_codegen_post(inst); } while (0) #define amd64_epilog_size(inst,reg_mask,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_epilog((inst),(reg_mask)); amd64_codegen_post(inst); } while (0) #define amd64_xadd_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_xadd_reg_reg ((inst), (dreg), (reg), (size)); amd64_codegen_post(inst); } while (0) #define amd64_xadd_mem_reg_size(inst,mem,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_xadd_mem_reg((inst),(mem),((reg)&0x7), (size)); amd64_codegen_post(inst); } while (0) #define amd64_xadd_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_xadd_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size)); amd64_codegen_post(inst); } while (0) #define amd64_breakpoint(inst) amd64_breakpoint_size(inst,8) #define amd64_cld(inst) amd64_cld_size(inst,8) #define amd64_stosb(inst) amd64_stosb_size(inst,8) #define amd64_stosl(inst) amd64_stosl_size(inst,8) #define amd64_stosd(inst) amd64_stosd_size(inst,8) #define amd64_movsb(inst) amd64_movsb_size(inst,8) #define amd64_movsl(inst) amd64_movsl_size(inst,8) #define amd64_movsd(inst) amd64_movsd_size(inst,8) #define amd64_prefix(inst,p) amd64_prefix_size(inst,p,8) #define amd64_rdtsc(inst) amd64_rdtsc_size(inst,8) #define amd64_cmpxchg_reg_reg(inst,dreg,reg) amd64_cmpxchg_reg_reg_size(inst,dreg,reg,8) #define amd64_cmpxchg_mem_reg(inst,mem,reg) amd64_cmpxchg_mem_reg_size(inst,mem,reg,8) #define amd64_cmpxchg_membase_reg(inst,basereg,disp,reg) amd64_cmpxchg_membase_reg_size(inst,basereg,disp,reg,8) #define amd64_xchg_reg_reg(inst,dreg,reg,size) amd64_xchg_reg_reg_size(inst,dreg,reg,size) #define amd64_xchg_mem_reg(inst,mem,reg,size) amd64_xchg_mem_reg_size(inst,mem,reg,size) #define amd64_xchg_membase_reg(inst,basereg,disp,reg,size) amd64_xchg_membase_reg_size(inst,basereg,disp,reg,size) #define amd64_xadd_reg_reg(inst,dreg,reg,size) amd64_xadd_reg_reg_size(inst,dreg,reg,size) #define amd64_xadd_mem_reg(inst,mem,reg,size) amd64_xadd_mem_reg_size(inst,mem,reg,size) #define amd64_xadd_membase_reg(inst,basereg,disp,reg,size) amd64_xadd_membase_reg_size(inst,basereg,disp,reg,size) #define amd64_inc_mem(inst,mem) amd64_inc_mem_size(inst,mem,8) #define amd64_inc_membase(inst,basereg,disp) amd64_inc_membase_size(inst,basereg,disp,8) #define amd64_inc_reg(inst,reg) amd64_inc_reg_size(inst,reg,8) #define amd64_dec_mem(inst,mem) amd64_dec_mem_size(inst,mem,8) #define amd64_dec_membase(inst,basereg,disp) amd64_dec_membase_size(inst,basereg,disp,8) #define amd64_dec_reg(inst,reg) amd64_dec_reg_size(inst,reg,8) #define amd64_not_mem(inst,mem) amd64_not_mem_size(inst,mem,8) #define amd64_not_membase(inst,basereg,disp) amd64_not_membase_size(inst,basereg,disp,8) #define amd64_not_reg(inst,reg) amd64_not_reg_size(inst,reg,8) #define amd64_neg_mem(inst,mem) amd64_neg_mem_size(inst,mem,8) #define amd64_neg_membase(inst,basereg,disp) amd64_neg_membase_size(inst,basereg,disp,8) #define amd64_neg_reg(inst,reg) amd64_neg_reg_size(inst,reg,8) #define amd64_nop(inst) amd64_nop_size(inst,8) //#define amd64_alu_reg_imm(inst,opc,reg,imm) amd64_alu_reg_imm_size(inst,opc,reg,imm,8) #define amd64_alu_mem_imm(inst,opc,mem,imm) amd64_alu_mem_imm_size(inst,opc,mem,imm,8) #define amd64_alu_membase_imm(inst,opc,basereg,disp,imm) amd64_alu_membase_imm_size(inst,opc,basereg,disp,imm,8) #define amd64_alu_mem_reg(inst,opc,mem,reg) amd64_alu_mem_reg_size(inst,opc,mem,reg,8) #define amd64_alu_membase_reg(inst,opc,basereg,disp,reg) amd64_alu_membase_reg_size(inst,opc,basereg,disp,reg,8) //#define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size(inst,opc,dreg,reg,8) #define amd64_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,8) #define amd64_alu_reg_mem(inst,opc,reg,mem) amd64_alu_reg_mem_size(inst,opc,reg,mem,8) #define amd64_alu_reg_membase(inst,opc,reg,basereg,disp) amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,8) //#define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8) #define amd64_test_mem_imm(inst,mem,imm) amd64_test_mem_imm_size(inst,mem,imm,8) #define amd64_test_membase_imm(inst,basereg,disp,imm) amd64_test_membase_imm_size(inst,basereg,disp,imm,8) #define amd64_test_reg_reg(inst,dreg,reg) amd64_test_reg_reg_size(inst,dreg,reg,8) #define amd64_test_mem_reg(inst,mem,reg) amd64_test_mem_reg_size(inst,mem,reg,8) #define amd64_test_membase_reg(inst,basereg,disp,reg) amd64_test_membase_reg_size(inst,basereg,disp,reg,8) #define amd64_shift_reg_imm(inst,opc,reg,imm) amd64_shift_reg_imm_size(inst,opc,reg,imm,8) #define amd64_shift_mem_imm(inst,opc,mem,imm) amd64_shift_mem_imm_size(inst,opc,mem,imm,8) #define amd64_shift_membase_imm(inst,opc,basereg,disp,imm) amd64_shift_membase_imm_size(inst,opc,basereg,disp,imm,8) #define amd64_shift_reg(inst,opc,reg) amd64_shift_reg_size(inst,opc,reg,8) #define amd64_shift_mem(inst,opc,mem) amd64_shift_mem_size(inst,opc,mem,8) #define amd64_shift_membase(inst,opc,basereg,disp) amd64_shift_membase_size(inst,opc,basereg,disp,8) #define amd64_shrd_reg(inst,dreg,reg) amd64_shrd_reg_size(inst,dreg,reg,8) #define amd64_shrd_reg_imm(inst,dreg,reg,shamt) amd64_shrd_reg_imm_size(inst,dreg,reg,shamt,8) #define amd64_shld_reg(inst,dreg,reg) amd64_shld_reg_size(inst,dreg,reg,8) #define amd64_shld_reg_imm(inst,dreg,reg,shamt) amd64_shld_reg_imm_size(inst,dreg,reg,shamt,8) #define amd64_mul_reg(inst,reg,is_signed) amd64_mul_reg_size(inst,reg,is_signed,8) #define amd64_mul_mem(inst,mem,is_signed) amd64_mul_mem_size(inst,mem,is_signed,8) #define amd64_mul_membase(inst,basereg,disp,is_signed) amd64_mul_membase_size(inst,basereg,disp,is_signed,8) #define amd64_imul_reg_reg(inst,dreg,reg) amd64_imul_reg_reg_size(inst,dreg,reg,8) #define amd64_imul_reg_mem(inst,reg,mem) amd64_imul_reg_mem_size(inst,reg,mem,8) #define amd64_imul_reg_membase(inst,reg,basereg,disp) amd64_imul_reg_membase_size(inst,reg,basereg,disp,8) #define amd64_imul_reg_reg_imm(inst,dreg,reg,imm) amd64_imul_reg_reg_imm_size(inst,dreg,reg,imm,8) #define amd64_imul_reg_mem_imm(inst,reg,mem,imm) amd64_imul_reg_mem_imm_size(inst,reg,mem,imm,8) #define amd64_imul_reg_membase_imm(inst,reg,basereg,disp,imm) amd64_imul_reg_membase_imm_size(inst,reg,basereg,disp,imm,8) #define amd64_div_reg(inst,reg,is_signed) amd64_div_reg_size(inst,reg,is_signed,8) #define amd64_div_mem(inst,mem,is_signed) amd64_div_mem_size(inst,mem,is_signed,8) #define amd64_div_membase(inst,basereg,disp,is_signed) amd64_div_membase_size(inst,basereg,disp,is_signed,8) //#define amd64_mov_mem_reg(inst,mem,reg,size) amd64_mov_mem_reg_size(inst,mem,reg,size) //#define amd64_mov_regp_reg(inst,regp,reg,size) amd64_mov_regp_reg_size(inst,regp,reg,size) //#define amd64_mov_membase_reg(inst,basereg,disp,reg,size) amd64_mov_membase_reg_size(inst,basereg,disp,reg,size) #define amd64_mov_memindex_reg(inst,basereg,disp,indexreg,shift,reg,size) amd64_mov_memindex_reg_size(inst,basereg,disp,indexreg,shift,reg,size) //#define amd64_mov_reg_reg(inst,dreg,reg,size) amd64_mov_reg_reg_size(inst,dreg,reg,size) //#define amd64_mov_reg_mem(inst,reg,mem,size) amd64_mov_reg_mem_size(inst,reg,mem,size) //#define amd64_mov_reg_membase(inst,reg,basereg,disp,size) amd64_mov_reg_membase_size(inst,reg,basereg,disp,size) #define amd64_mov_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) #define amd64_clear_reg(inst,reg) amd64_clear_reg_size(inst,reg,8) //#define amd64_mov_reg_imm(inst,reg,imm) amd64_mov_reg_imm_size(inst,reg,imm,8) #define amd64_mov_mem_imm(inst,mem,imm,size) amd64_mov_mem_imm_size(inst,mem,imm,size) //#define amd64_mov_membase_imm(inst,basereg,disp,imm,size) amd64_mov_membase_imm_size(inst,basereg,disp,imm,size) #define amd64_mov_memindex_imm(inst,basereg,disp,indexreg,shift,imm,size) amd64_mov_memindex_imm_size(inst,basereg,disp,indexreg,shift,imm,size) #define amd64_lea_mem(inst,reg,mem) amd64_lea_mem_size(inst,reg,mem,8) //#define amd64_lea_membase(inst,reg,basereg,disp) amd64_lea_membase_size(inst,reg,basereg,disp,8) #define amd64_lea_memindex(inst,reg,basereg,disp,indexreg,shift) amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,8) #define amd64_widen_reg(inst,dreg,reg,is_signed,is_half) amd64_widen_reg_size(inst,dreg,reg,is_signed,is_half,8) #define amd64_widen_mem(inst,dreg,mem,is_signed,is_half) amd64_widen_mem_size(inst,dreg,mem,is_signed,is_half,8) #define amd64_widen_membase(inst,dreg,basereg,disp,is_signed,is_half) amd64_widen_membase_size(inst,dreg,basereg,disp,is_signed,is_half,8) #define amd64_widen_memindex(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half) amd64_widen_memindex_size(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half,8) #define amd64_cdq(inst) amd64_cdq_size(inst,8) #define amd64_wait(inst) amd64_wait_size(inst,8) #define amd64_fp_op_mem(inst,opc,mem,is_double) amd64_fp_op_mem_size(inst,opc,mem,is_double,8) #define amd64_fp_op_membase(inst,opc,basereg,disp,is_double) amd64_fp_op_membase_size(inst,opc,basereg,disp,is_double,8) #define amd64_fp_op(inst,opc,index) amd64_fp_op_size(inst,opc,index,8) #define amd64_fp_op_reg(inst,opc,index,pop_stack) amd64_fp_op_reg_size(inst,opc,index,pop_stack,8) #define amd64_fp_int_op_membase(inst,opc,basereg,disp,is_int) amd64_fp_int_op_membase_size(inst,opc,basereg,disp,is_int,8) #define amd64_fstp(inst,index) amd64_fstp_size(inst,index,8) #define amd64_fcompp(inst) amd64_fcompp_size(inst,8) #define amd64_fucompp(inst) amd64_fucompp_size(inst,8) #define amd64_fnstsw(inst) amd64_fnstsw_size(inst,8) #define amd64_fnstcw(inst,mem) amd64_fnstcw_size(inst,mem,8) #define amd64_fnstcw_membase(inst,basereg,disp) amd64_fnstcw_membase_size(inst,basereg,disp,8) #define amd64_fldcw(inst,mem) amd64_fldcw_size(inst,mem,8) #define amd64_fldcw_membase(inst,basereg,disp) amd64_fldcw_membase_size(inst,basereg,disp,8) #define amd64_fchs(inst) amd64_fchs_size(inst,8) #define amd64_frem(inst) amd64_frem_size(inst,8) #define amd64_fxch(inst,index) amd64_fxch_size(inst,index,8) #define amd64_fcomi(inst,index) amd64_fcomi_size(inst,index,8) #define amd64_fcomip(inst,index) amd64_fcomip_size(inst,index,8) #define amd64_fucomi(inst,index) amd64_fucomi_size(inst,index,8) #define amd64_fucomip(inst,index) amd64_fucomip_size(inst,index,8) #define amd64_fld(inst,mem,is_double) amd64_fld_size(inst,mem,is_double,8) #define amd64_fld_membase(inst,basereg,disp,is_double) amd64_fld_membase_size(inst,basereg,disp,is_double,8) #define amd64_fld80_mem(inst,mem) amd64_fld80_mem_size(inst,mem,8) #define amd64_fld80_membase(inst,basereg,disp) amd64_fld80_membase_size(inst,basereg,disp,8) #define amd64_fild(inst,mem,is_long) amd64_fild_size(inst,mem,is_long,8) #define amd64_fild_membase(inst,basereg,disp,is_long) amd64_fild_membase_size(inst,basereg,disp,is_long,8) #define amd64_fld_reg(inst,index) amd64_fld_reg_size(inst,index,8) #define amd64_fldz(inst) amd64_fldz_size(inst,8) #define amd64_fld1(inst) amd64_fld1_size(inst,8) #define amd64_fldpi(inst) amd64_fldpi_size(inst,8) #define amd64_fst(inst,mem,is_double,pop_stack) amd64_fst_size(inst,mem,is_double,pop_stack,8) #define amd64_fst_membase(inst,basereg,disp,is_double,pop_stack) amd64_fst_membase_size(inst,basereg,disp,is_double,pop_stack,8) #define amd64_fst80_mem(inst,mem) amd64_fst80_mem_size(inst,mem,8) #define amd64_fst80_membase(inst,basereg,disp) amd64_fst80_membase_size(inst,basereg,disp,8) #define amd64_fist_pop(inst,mem,is_long) amd64_fist_pop_size(inst,mem,is_long,8) #define amd64_fist_pop_membase(inst,basereg,disp,is_long) amd64_fist_pop_membase_size(inst,basereg,disp,is_long,8) #define amd64_fstsw(inst) amd64_fstsw_size(inst,8) #define amd64_fist_membase(inst,basereg,disp,is_int) amd64_fist_membase_size(inst,basereg,disp,is_int,8) //#define amd64_push_reg(inst,reg) amd64_push_reg_size(inst,reg,8) #define amd64_push_regp(inst,reg) amd64_push_regp_size(inst,reg,8) #define amd64_push_mem(inst,mem) amd64_push_mem_size(inst,mem,8) //#define amd64_push_membase(inst,basereg,disp) amd64_push_membase_size(inst,basereg,disp,8) #define amd64_push_memindex(inst,basereg,disp,indexreg,shift) amd64_push_memindex_size(inst,basereg,disp,indexreg,shift,8) #define amd64_push_imm(inst,imm) amd64_push_imm_size(inst,imm,8) //#define amd64_pop_reg(inst,reg) amd64_pop_reg_size(inst,reg,8) #define amd64_pop_mem(inst,mem) amd64_pop_mem_size(inst,mem,8) #define amd64_pop_membase(inst,basereg,disp) amd64_pop_membase_size(inst,basereg,disp,8) #define amd64_pushad(inst) amd64_pushad_size(inst,8) #define amd64_pushfd(inst) amd64_pushfd_size(inst,8) #define amd64_popad(inst) amd64_popad_size(inst,8) #define amd64_popfd(inst) amd64_popfd_size(inst,8) #define amd64_loop(inst,imm) amd64_loop_size(inst,imm,8) #define amd64_loope(inst,imm) amd64_loope_size(inst,imm,8) #define amd64_loopne(inst,imm) amd64_loopne_size(inst,imm,8) #define amd64_jump32(inst,imm) amd64_jump32_size(inst,imm,8) #define amd64_jump8(inst,imm) amd64_jump8_size(inst,imm,8) #define amd64_jump_reg(inst,reg) amd64_jump_reg_size(inst,reg,8) #define amd64_jump_mem(inst,mem) amd64_jump_mem_size(inst,mem,8) #define amd64_jump_membase(inst,basereg,disp) amd64_jump_membase_size(inst,basereg,disp,8) #define amd64_jump_code(inst,target) amd64_jump_code_size(inst,target,8) #define amd64_jump_disp(inst,disp) amd64_jump_disp_size(inst,disp,8) #define amd64_branch8(inst,cond,imm,is_signed) amd64_branch8_size(inst,cond,imm,is_signed,8) #define amd64_branch32(inst,cond,imm,is_signed) amd64_branch32_size(inst,cond,imm,is_signed,8) #define amd64_branch(inst,cond,target,is_signed) amd64_branch_size(inst,cond,target,is_signed,8) #define amd64_branch_disp(inst,cond,disp,is_signed) amd64_branch_disp_size(inst,cond,disp,is_signed,8) #define amd64_set_reg(inst,cond,reg,is_signed) amd64_set_reg_size(inst,cond,reg,is_signed,8) #define amd64_set_mem(inst,cond,mem,is_signed) amd64_set_mem_size(inst,cond,mem,is_signed,8) #define amd64_set_membase(inst,cond,basereg,disp,is_signed) amd64_set_membase_size(inst,cond,basereg,disp,is_signed,8) #define amd64_call_imm(inst,disp) amd64_call_imm_size(inst,disp,8) //#define amd64_call_reg(inst,reg) amd64_call_reg_size(inst,reg,8) #define amd64_call_mem(inst,mem) amd64_call_mem_size(inst,mem,8) #define amd64_call_membase(inst,basereg,disp) amd64_call_membase_size(inst,basereg,disp,8) #define amd64_call_code(inst,target) amd64_call_code_size(inst,target,8) //#define amd64_ret(inst) amd64_ret_size(inst,8) #define amd64_ret_imm(inst,imm) amd64_ret_imm_size(inst,imm,8) #define amd64_cmov_reg(inst,cond,is_signed,dreg,reg) amd64_cmov_reg_size(inst,cond,is_signed,dreg,reg,8) #define amd64_cmov_mem(inst,cond,is_signed,reg,mem) amd64_cmov_mem_size(inst,cond,is_signed,reg,mem,8) #define amd64_cmov_membase(inst,cond,is_signed,reg,basereg,disp) amd64_cmov_membase_size(inst,cond,is_signed,reg,basereg,disp,8) #define amd64_enter(inst,framesize) amd64_enter_size(inst,framesize) //#define amd64_leave(inst) amd64_leave_size(inst,8) #define amd64_sahf(inst) amd64_sahf_size(inst,8) #define amd64_fsin(inst) amd64_fsin_size(inst,8) #define amd64_fcos(inst) amd64_fcos_size(inst,8) #define amd64_fabs(inst) amd64_fabs_size(inst,8) #define amd64_ftst(inst) amd64_ftst_size(inst,8) #define amd64_fxam(inst) amd64_fxam_size(inst,8) #define amd64_fpatan(inst) amd64_fpatan_size(inst,8) #define amd64_fprem(inst) amd64_fprem_size(inst,8) #define amd64_fprem1(inst) amd64_fprem1_size(inst,8) #define amd64_frndint(inst) amd64_frndint_size(inst,8) #define amd64_fsqrt(inst) amd64_fsqrt_size(inst,8) #define amd64_fptan(inst) amd64_fptan_size(inst,8) #define amd64_padding(inst,size) amd64_padding_size(inst,size) #define amd64_prolog(inst,frame,reg_mask) amd64_prolog_size(inst,frame,reg_mask,8) #define amd64_epilog(inst,reg_mask) amd64_epilog_size(inst,reg_mask,8) #endif // AMD64_H
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/HardwareIntrinsics/X86/Avx2_Vector128/MaskStore.UInt32.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void MaskStoreUInt32() { var test = new StoreBinaryOpTest__MaskStoreUInt32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class StoreBinaryOpTest__MaskStoreUInt32 { private struct TestStruct { public Vector128<UInt32> _fld1; public Vector128<UInt32> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); return testStruct; } public void RunStructFldScenario(StoreBinaryOpTest__MaskStoreUInt32 testClass) { Avx2.MaskStore((UInt32*)testClass._dataTable.outArrayPtr, _fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static UInt32[] _data1 = new UInt32[Op1ElementCount]; private static UInt32[] _data2 = new UInt32[Op2ElementCount]; private static Vector128<UInt32> _clsVar1; private static Vector128<UInt32> _clsVar2; private Vector128<UInt32> _fld1; private Vector128<UInt32> _fld2; private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable; static StoreBinaryOpTest__MaskStoreUInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); } public StoreBinaryOpTest__MaskStoreUInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); typeof(Avx2).GetMethod(nameof(Avx2.MaskStore), new Type[] { typeof(UInt32*), typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); typeof(Avx2).GetMethod(nameof(Avx2.MaskStore), new Type[] { typeof(UInt32*), typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); typeof(Avx2).GetMethod(nameof(Avx2.MaskStore), new Type[] { typeof(UInt32*), typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var left = Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr); var right = Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, left, right); ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var left = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); var right = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, left, right); ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var left = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); var right = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, left, right); ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new StoreBinaryOpTest__MaskStoreUInt32(); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, _fld1, _fld2); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), left); Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (((left[0] & (1U << 31)) != 0) ? right[0] : result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (((left[i] & (1U << 31)) != 0) ? right[i] : result[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.MaskStore)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void MaskStoreUInt32() { var test = new StoreBinaryOpTest__MaskStoreUInt32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class StoreBinaryOpTest__MaskStoreUInt32 { private struct TestStruct { public Vector128<UInt32> _fld1; public Vector128<UInt32> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); return testStruct; } public void RunStructFldScenario(StoreBinaryOpTest__MaskStoreUInt32 testClass) { Avx2.MaskStore((UInt32*)testClass._dataTable.outArrayPtr, _fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static UInt32[] _data1 = new UInt32[Op1ElementCount]; private static UInt32[] _data2 = new UInt32[Op2ElementCount]; private static Vector128<UInt32> _clsVar1; private static Vector128<UInt32> _clsVar2; private Vector128<UInt32> _fld1; private Vector128<UInt32> _fld2; private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable; static StoreBinaryOpTest__MaskStoreUInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); } public StoreBinaryOpTest__MaskStoreUInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } _dataTable = new SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); typeof(Avx2).GetMethod(nameof(Avx2.MaskStore), new Type[] { typeof(UInt32*), typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); typeof(Avx2).GetMethod(nameof(Avx2.MaskStore), new Type[] { typeof(UInt32*), typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); typeof(Avx2).GetMethod(nameof(Avx2.MaskStore), new Type[] { typeof(UInt32*), typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); Avx2.MaskStore( (UInt32*)_dataTable.outArrayPtr, _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var left = Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr); var right = Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, left, right); ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var left = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); var right = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, left, right); ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var left = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); var right = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, left, right); ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new StoreBinaryOpTest__MaskStoreUInt32(); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, _fld1, _fld2); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); Avx2.MaskStore((UInt32*)_dataTable.outArrayPtr, test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), left); Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (((left[0] & (1U << 31)) != 0) ? right[0] : result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (((left[i] & (1U << 31)) != 0) ? right[i] : result[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.MaskStore)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/coreclr/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test10.c ** ** Purpose: Tests sscanf_s with wide characters ** ** **==========================================================================*/ #include <palsuite.h> #include "../sscanf_s.h" PALTEST(c_runtime_sscanf_s_test10_paltest_sscanf_test10, "c_runtime/sscanf_s/test10/paltest_sscanf_test10") { if (PAL_Initialize(argc, argv)) { return FAIL; } DoWCharTest("1234d", "%C", convert("1"), 1); DoWCharTest("1234d", "%C", convert("1"), 1); DoWCharTest("abc", "%2C", convert("ab"), 2); DoWCharTest(" ab", "%C", convert(" "), 1); DoCharTest("ab", "%hC", "a", 1); DoWCharTest("ab", "%lC", convert("a"), 1); DoWCharTest("ab", "%LC", convert("a"), 1); DoWCharTest("ab", "%I64C", convert("a"), 1); PAL_Terminate(); return PASS; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test10.c ** ** Purpose: Tests sscanf_s with wide characters ** ** **==========================================================================*/ #include <palsuite.h> #include "../sscanf_s.h" PALTEST(c_runtime_sscanf_s_test10_paltest_sscanf_test10, "c_runtime/sscanf_s/test10/paltest_sscanf_test10") { if (PAL_Initialize(argc, argv)) { return FAIL; } DoWCharTest("1234d", "%C", convert("1"), 1); DoWCharTest("1234d", "%C", convert("1"), 1); DoWCharTest("abc", "%2C", convert("ab"), 2); DoWCharTest(" ab", "%C", convert(" "), 1); DoCharTest("ab", "%hC", "a", 1); DoWCharTest("ab", "%lC", convert("a"), 1); DoWCharTest("ab", "%LC", convert("a"), 1); DoWCharTest("ab", "%I64C", convert("a"), 1); PAL_Terminate(); return PASS; }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/mono/wasm/runtime/types/emscripten.ts
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. export declare interface ManagedPointer { __brandManagedPointer: "ManagedPointer" } export declare interface NativePointer { __brandNativePointer: "NativePointer" } export declare interface VoidPtr extends NativePointer { __brand: "VoidPtr" } export declare interface CharPtr extends NativePointer { __brand: "CharPtr" } export declare interface Int32Ptr extends NativePointer { __brand: "Int32Ptr" } export declare interface CharPtrPtr extends NativePointer { __brand: "CharPtrPtr" } export declare interface EmscriptenModule { HEAP8: Int8Array, HEAP16: Int16Array; HEAP32: Int32Array; HEAPU8: Uint8Array; HEAPU16: Uint16Array; HEAPU32: Uint32Array; HEAPF32: Float32Array; HEAPF64: Float64Array; // this should match emcc -s EXPORTED_FUNCTIONS _malloc(size: number): VoidPtr; _free(ptr: VoidPtr): void; // this should match emcc -s EXPORTED_RUNTIME_METHODS print(message: string): void; printErr(message: string): void; ccall<T>(ident: string, returnType?: string | null, argTypes?: string[], args?: any[], opts?: any): T; cwrap<T extends Function>(ident: string, returnType: string, argTypes?: string[], opts?: any): T; cwrap<T extends Function>(ident: string, ...args: any[]): T; setValue(ptr: VoidPtr, value: number, type: string, noSafe?: number | boolean): void; setValue(ptr: Int32Ptr, value: number, type: string, noSafe?: number | boolean): void; getValue(ptr: number, type: string, noSafe?: number | boolean): number; UTF8ToString(ptr: CharPtr, maxBytesToRead?: number): string; UTF8ArrayToString(u8Array: Uint8Array, idx?: number, maxBytesToRead?: number): string; FS_createPath(parent: string, path: string, canRead?: boolean, canWrite?: boolean): string; FS_createDataFile(parent: string, name: string, data: TypedArray, canRead: boolean, canWrite: boolean, canOwn?: boolean): string; removeRunDependency(id: string): void; addRunDependency(id: string): void; ready: Promise<unknown>; preInit?: (() => any)[]; preRun?: (() => any)[]; postRun?: (() => any)[]; onAbort?: { (error: any): void }; onRuntimeInitialized?: () => any; instantiateWasm: (imports: any, successCallback: Function) => any; } export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. export declare interface ManagedPointer { __brandManagedPointer: "ManagedPointer" } export declare interface NativePointer { __brandNativePointer: "NativePointer" } export declare interface VoidPtr extends NativePointer { __brand: "VoidPtr" } export declare interface CharPtr extends NativePointer { __brand: "CharPtr" } export declare interface Int32Ptr extends NativePointer { __brand: "Int32Ptr" } export declare interface CharPtrPtr extends NativePointer { __brand: "CharPtrPtr" } export declare interface EmscriptenModule { HEAP8: Int8Array, HEAP16: Int16Array; HEAP32: Int32Array; HEAPU8: Uint8Array; HEAPU16: Uint16Array; HEAPU32: Uint32Array; HEAPF32: Float32Array; HEAPF64: Float64Array; // this should match emcc -s EXPORTED_FUNCTIONS _malloc(size: number): VoidPtr; _free(ptr: VoidPtr): void; // this should match emcc -s EXPORTED_RUNTIME_METHODS print(message: string): void; printErr(message: string): void; ccall<T>(ident: string, returnType?: string | null, argTypes?: string[], args?: any[], opts?: any): T; cwrap<T extends Function>(ident: string, returnType: string, argTypes?: string[], opts?: any): T; cwrap<T extends Function>(ident: string, ...args: any[]): T; setValue(ptr: VoidPtr, value: number, type: string, noSafe?: number | boolean): void; setValue(ptr: Int32Ptr, value: number, type: string, noSafe?: number | boolean): void; getValue(ptr: number, type: string, noSafe?: number | boolean): number; UTF8ToString(ptr: CharPtr, maxBytesToRead?: number): string; UTF8ArrayToString(u8Array: Uint8Array, idx?: number, maxBytesToRead?: number): string; FS_createPath(parent: string, path: string, canRead?: boolean, canWrite?: boolean): string; FS_createDataFile(parent: string, name: string, data: TypedArray, canRead: boolean, canWrite: boolean, canOwn?: boolean): string; removeRunDependency(id: string): void; addRunDependency(id: string): void; ready: Promise<unknown>; preInit?: (() => any)[]; preRun?: (() => any)[]; postRun?: (() => any)[]; onAbort?: { (error: any): void }; onRuntimeInitialized?: () => any; instantiateWasm: (imports: any, successCallback: Function) => any; } export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.Serialization; namespace System.Text { public sealed class DecoderExceptionFallback : DecoderFallback { internal static readonly DecoderExceptionFallback s_default = new DecoderExceptionFallback(); public override DecoderFallbackBuffer CreateFallbackBuffer() => new DecoderExceptionFallbackBuffer(); // Maximum number of characters that this instance of this fallback could return public override int MaxCharCount => 0; public override bool Equals([NotNullWhen(true)] object? value) => value is DecoderExceptionFallback; public override int GetHashCode() => 879; } public sealed class DecoderExceptionFallbackBuffer : DecoderFallbackBuffer { public override bool Fallback(byte[] bytesUnknown, int index) { Throw(bytesUnknown, index); return true; } public override char GetNextChar() => (char)0; // Exception fallback doesn't have anywhere to back up to. public override bool MovePrevious() => false; // Exceptions are always empty public override int Remaining => 0; [DoesNotReturn] private static void Throw(byte[] bytesUnknown, int index) { bytesUnknown ??= Array.Empty<byte>(); // Create a string representation of our bytes. StringBuilder strBytes = new StringBuilder(bytesUnknown.Length * 4); const int MaxLength = 20; for (int i = 0; i < bytesUnknown.Length && i < MaxLength; i++) { strBytes.Append($"[{bytesUnknown[i]:X2}]"); } // In case the string's really long if (bytesUnknown.Length > MaxLength) { strBytes.Append(" ..."); } // Known index throw new DecoderFallbackException( SR.Format(SR.Argument_InvalidCodePageBytesIndex, strBytes, index), bytesUnknown, index); } } // Exception for decoding unknown byte sequences. [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed class DecoderFallbackException : ArgumentException { private readonly byte[]? _bytesUnknown; private readonly int _index; public DecoderFallbackException() : base(SR.Arg_ArgumentException) { HResult = HResults.COR_E_ARGUMENT; } public DecoderFallbackException(string? message) : base(message) { HResult = HResults.COR_E_ARGUMENT; } public DecoderFallbackException(string? message, Exception? innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENT; } public DecoderFallbackException(string? message, byte[]? bytesUnknown, int index) : base(message) { _bytesUnknown = bytesUnknown; _index = index; } private DecoderFallbackException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } public byte[]? BytesUnknown => _bytesUnknown; public int Index => _index; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.Serialization; namespace System.Text { public sealed class DecoderExceptionFallback : DecoderFallback { internal static readonly DecoderExceptionFallback s_default = new DecoderExceptionFallback(); public override DecoderFallbackBuffer CreateFallbackBuffer() => new DecoderExceptionFallbackBuffer(); // Maximum number of characters that this instance of this fallback could return public override int MaxCharCount => 0; public override bool Equals([NotNullWhen(true)] object? value) => value is DecoderExceptionFallback; public override int GetHashCode() => 879; } public sealed class DecoderExceptionFallbackBuffer : DecoderFallbackBuffer { public override bool Fallback(byte[] bytesUnknown, int index) { Throw(bytesUnknown, index); return true; } public override char GetNextChar() => (char)0; // Exception fallback doesn't have anywhere to back up to. public override bool MovePrevious() => false; // Exceptions are always empty public override int Remaining => 0; [DoesNotReturn] private static void Throw(byte[] bytesUnknown, int index) { bytesUnknown ??= Array.Empty<byte>(); // Create a string representation of our bytes. StringBuilder strBytes = new StringBuilder(bytesUnknown.Length * 4); const int MaxLength = 20; for (int i = 0; i < bytesUnknown.Length && i < MaxLength; i++) { strBytes.Append($"[{bytesUnknown[i]:X2}]"); } // In case the string's really long if (bytesUnknown.Length > MaxLength) { strBytes.Append(" ..."); } // Known index throw new DecoderFallbackException( SR.Format(SR.Argument_InvalidCodePageBytesIndex, strBytes, index), bytesUnknown, index); } } // Exception for decoding unknown byte sequences. [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed class DecoderFallbackException : ArgumentException { private readonly byte[]? _bytesUnknown; private readonly int _index; public DecoderFallbackException() : base(SR.Arg_ArgumentException) { HResult = HResults.COR_E_ARGUMENT; } public DecoderFallbackException(string? message) : base(message) { HResult = HResults.COR_E_ARGUMENT; } public DecoderFallbackException(string? message, Exception? innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENT; } public DecoderFallbackException(string? message, byte[]? bytesUnknown, int index) : base(message) { _bytesUnknown = bytesUnknown; _index = index; } private DecoderFallbackException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { } public byte[]? BytesUnknown => _bytesUnknown; public int Index => _index; } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/mono/mono/utils/mono-error.c
/** * \file * Error handling code * * Authors: * Rodrigo Kumpera ([email protected]) * Copyright 2009 Novell, Inc (http://www.novell.com) * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include <glib.h> #include <config.h> #include <mono/utils/mono-error.h> #include "mono-error-internals.h" #include <mono/metadata/exception.h> #include <mono/metadata/exception-internals.h> #include <mono/metadata/debug-helpers.h> #include <mono/metadata/object-internals.h> #define set_error_messagev() do { \ if (msg_format && !(error->full_message = g_strdup_vprintf (msg_format, args))) \ error->flags |= MONO_ERROR_INCOMPLETE; \ } while (0) #define set_error_message() do { \ va_list args; \ va_start (args, msg_format); \ set_error_messagev(); \ va_end (args); \ } while (0) static void mono_error_set_generic_errorv (MonoError *oerror, const char *name_space, const char *name, const char *msg_format, va_list args); static gboolean is_managed_error_code (guint16 error_code) { return error_code == MONO_ERROR_EXCEPTION_INSTANCE; } static gboolean is_managed_exception (MonoErrorInternal *error) { return is_managed_error_code (error->error_code); } static gboolean is_boxed_error_flags (guint16 error_flags) { return (error_flags & MONO_ERROR_MEMPOOL_BOXED) != 0; } static gboolean is_boxed (MonoErrorInternal *error) { return is_boxed_error_flags (error->flags); } static void mono_error_free_string (const char **error_string) { g_free ((char*)*error_string); *error_string = NULL; } static void mono_error_init_deferred (MonoErrorInternal *error) // mono_error_init and mono_error_init_flags are optimized and only initialize a minimum. // Initialize the rest, prior to originating an error. { memset (&error->type_name, 0, sizeof (*error) - offsetof (MonoErrorInternal, type_name)); } static void mono_error_prepare (MonoErrorInternal *error) { /* mono_error_set_* after a mono_error_cleanup without an intervening init */ g_assert (error->error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); if (error->error_code != MONO_ERROR_NONE) return; mono_error_init_deferred (error); } static MonoClass* get_class (MonoErrorInternal *error) { MonoClass *klass = NULL; if (is_managed_exception (error)) klass = mono_object_class (mono_gchandle_get_target_internal (error->exn.instance_handle)); else klass = error->exn.klass; return klass; } static const char* get_type_name (MonoErrorInternal *error) { if (error->type_name) return error->type_name; MonoClass *klass = get_class (error); if (klass) return m_class_get_name (klass); return "<unknown type>"; } static const char* get_assembly_name (MonoErrorInternal *error) { if (error->assembly_name) return error->assembly_name; MonoClass *klass = get_class (error); if (klass && m_class_get_image (klass)) return m_class_get_image (klass)->name; return "<unknown assembly>"; } void mono_error_init_flags (MonoError *oerror, guint16 flags) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; g_static_assert (sizeof (MonoErrorExternal) >= sizeof (MonoErrorInternal)); error->error_code = MONO_ERROR_NONE; error->flags = flags; } /** * mono_error_init: * \param error Pointer to \c MonoError struct to initialize * Any function which takes a \c MonoError for purposes of reporting an error * is required to call either this or \c mono_error_init_flags on entry. */ void mono_error_init (MonoError *error) { mono_error_init_flags (error, 0); } void mono_error_cleanup (MonoError *oerror) { // This function is called a lot so it is optimized. MonoErrorInternal *error = (MonoErrorInternal*)oerror; #if G_BYTE_ORDER == G_LITTLE_ENDIAN const guint32 init = oerror->init; const guint16 error_code = (guint16)(init & 0xFFFF); const guint16 error_flags = (guint16)(init >> 16); #else const guint16 error_code = error->error_code; const guint16 error_flags = error->flags; #endif /* Two cleanups in a row without an intervening init. */ g_assert (error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); /* Mempool stored error shouldn't be cleaned up */ g_assert (!is_boxed_error_flags (error_flags)); /* Mark it as cleaned up. */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN oerror->init = MONO_ERROR_CLEANUP_CALLED_SENTINEL; #else error->error_code = MONO_ERROR_CLEANUP_CALLED_SENTINEL; error->flags = 0; #endif if (error_code == MONO_ERROR_NONE) return; if (is_managed_error_code (error_code)) mono_gchandle_free_internal (error->exn.instance_handle); mono_error_free_string (&error->full_message); mono_error_free_string (&error->full_message_with_fields); if (!(error_flags & MONO_ERROR_FREE_STRINGS)) //no memory was allocated return; mono_error_free_string (&error->type_name); mono_error_free_string (&error->assembly_name); mono_error_free_string (&error->member_name); mono_error_free_string (&error->exception_name_space); mono_error_free_string (&error->exception_name); mono_error_free_string (&error->first_argument); error->exn.klass = NULL; } gboolean mono_error_ok (MonoError *error) { return is_ok (error); } guint16 mono_error_get_error_code (MonoError *error) { return error->error_code; } const char* mono_error_get_exception_name (MonoError *oerror) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; if (error->error_code == MONO_ERROR_NONE) return NULL; return error->exception_name; } /*Return a pointer to the internal error message, might be NULL. Caller should not release it.*/ const char* mono_error_get_message (MonoError *oerror) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; const guint16 error_code = error->error_code; if (error_code == MONO_ERROR_NONE) return NULL; g_assert (error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); //Those are the simplified errors switch (error_code) { case MONO_ERROR_MISSING_METHOD: case MONO_ERROR_BAD_IMAGE: case MONO_ERROR_FILE_NOT_FOUND: case MONO_ERROR_MISSING_FIELD: return error->full_message; } if (error->full_message_with_fields) return error->full_message_with_fields; error->full_message_with_fields = g_strdup_printf ("%s assembly:%s type:%s member:%s", error->full_message, get_assembly_name (error), get_type_name (error), error->member_name); return error->full_message_with_fields ? error->full_message_with_fields : error->full_message; } /* * Inform that this error has heap allocated strings. * The strings will be duplicated if @dup_strings is TRUE * otherwise they will just be free'd in mono_error_cleanup. */ void mono_error_dup_strings (MonoError *oerror, gboolean dup_strings) { #define DUP_STR(field) do { if (error->field) {\ if (!(error->field = g_strdup (error->field))) \ error->flags |= MONO_ERROR_INCOMPLETE; \ }} while (0); MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->flags |= MONO_ERROR_FREE_STRINGS; if (dup_strings) { DUP_STR (type_name); DUP_STR (assembly_name); DUP_STR (member_name); DUP_STR (exception_name_space); DUP_STR (exception_name); DUP_STR (first_argument); } #undef DUP_STR } void mono_error_set_error (MonoError *oerror, int error_code, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = error_code; set_error_message (); } static void mono_error_set_assembly_name (MonoError *oerror, const char *assembly_name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; g_assert (error->error_code != MONO_ERROR_NONE); error->assembly_name = assembly_name; } static void mono_error_set_member_name (MonoError *oerror, const char *member_name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->member_name = member_name; } static void mono_error_set_type_name (MonoError *oerror, const char *type_name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->type_name = type_name; } static void mono_error_set_class (MonoError *oerror, MonoClass *klass) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; if (is_managed_exception (error)) return; error->exn.klass = klass; } static void mono_error_set_corlib_exception (MonoError *oerror, const char *name_space, const char *name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->exception_name_space = name_space; error->exception_name = name; } void mono_error_set_type_load_class (MonoError *oerror, MonoClass *klass, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_vset_type_load_class (oerror, klass, msg_format, args); va_end (args); } void mono_error_vset_type_load_class (MonoError *oerror, MonoClass *klass, const char *msg_format, va_list args) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_TYPE_LOAD; mono_error_set_class (oerror, klass); set_error_messagev (); } /* * Different than other functions, this one here assumes that type_name and assembly_name to have been allocated just for us. * Which means mono_error_cleanup will free them. */ void mono_error_set_type_load_name (MonoError *oerror, const char *type_name, const char *assembly_name, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_TYPE_LOAD; mono_error_set_type_name (oerror, type_name); mono_error_set_assembly_name (oerror, assembly_name); mono_error_dup_strings (oerror, FALSE); set_error_message (); } /* * Sets @error to be of type @error_code with message @message * XXX only works for MONO_ERROR_MISSING_METHOD, MONO_ERROR_BAD_IMAGE, MONO_ERROR_FILE_NOT_FOUND and MONO_ERROR_MISSING_FIELD for now */ void mono_error_set_specific (MonoError *oerror, int error_code, const char *message) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = error_code; error->full_message = message; error->flags |= MONO_ERROR_FREE_STRINGS; } void mono_error_set_generic_errorv (MonoError *oerror, const char *name_space, const char *name, const char *msg_format, va_list args) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_GENERIC; mono_error_set_corlib_exception (oerror, name_space, name); set_error_messagev (); } void mono_error_set_generic_error (MonoError *oerror, const char * name_space, const char *name, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, name_space, name, msg_format, args); va_end (args); } /** * mono_error_set_not_implemented: * * System.NotImplementedException */ void mono_error_set_not_implemented (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "NotImplementedException", msg_format, args); va_end (args); } /** * mono_error_set_execution_engine: * * System.ExecutionEngineException */ void mono_error_set_execution_engine (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "ExecutionEngineException", msg_format, args); va_end (args); } /** * mono_error_set_not_supported: * * System.NotSupportedException */ void mono_error_set_not_supported (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "NotSupportedException", msg_format, args); va_end (args); } /** * mono_error_set_ambiguous_implementation: * * System.Runtime.AmbiguousImplementationException */ void mono_error_set_ambiguous_implementation (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System.Runtime", "AmbiguousImplementationException", msg_format, args); va_end (args); } /** * mono_error_set_invalid_operation: * * System.InvalidOperationException */ void mono_error_set_invalid_operation (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "InvalidOperationException", msg_format, args); va_end (args); } void mono_error_set_invalid_program (MonoError *oerror, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_INVALID_PROGRAM; set_error_message (); } void mono_error_set_member_access (MonoError *oerror, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_MEMBER_ACCESS; set_error_message (); } /** * mono_error_set_invalid_cast: * * System.InvalidCastException */ void mono_error_set_invalid_cast (MonoError *oerror) { mono_error_set_generic_error (oerror, "System", "InvalidCastException", ""); } void mono_error_set_exception_instance (MonoError *oerror, MonoException *exc) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_EXCEPTION_INSTANCE; error->exn.instance_handle = mono_gchandle_new_internal (exc ? &exc->object : NULL, FALSE); } void mono_error_set_exception_handle (MonoError *oerror, MonoExceptionHandle exc) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_EXCEPTION_INSTANCE; error->exn.instance_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST(MonoObject, exc), FALSE); } void mono_error_set_out_of_memory (MonoError *oerror, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_OUT_OF_MEMORY; set_error_message (); } void mono_error_set_argument_format (MonoError *oerror, const char *argument, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_ARGUMENT; error->first_argument = argument; set_error_message (); } void mono_error_set_argument (MonoError *oerror, const char *argument, const char *msg) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_ARGUMENT; error->first_argument = argument; if (msg && msg [0] && !(error->full_message = g_strdup (msg))) error->flags |= MONO_ERROR_INCOMPLETE; } void mono_error_set_argument_null (MonoError *oerror, const char *argument, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_ARGUMENT_NULL; error->first_argument = argument; set_error_message (); } void mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_NOT_VERIFIABLE; if (method) { mono_error_set_class (oerror, method->klass); mono_error_set_member_name (oerror, mono_method_full_name (method, 1)); } set_error_message (); } /* Used by mono_error_prepare_exception - it sets its own error on mono_string_new_checked failure. */ static MonoStringHandle string_new_cleanup (const char *text) { ERROR_DECL (ignored_err); MonoStringHandle result = mono_string_new_handle (text, ignored_err); mono_error_cleanup (ignored_err); return result; } static MonoStringHandle get_type_name_as_mono_string (MonoErrorInternal *error, MonoError *error_out) { HANDLE_FUNCTION_ENTER (); MonoStringHandle res = NULL_HANDLE_STRING; if (error->type_name) { res = string_new_cleanup (error->type_name); } else { MonoClass *klass = get_class (error); if (klass) { char *name = mono_type_full_name (m_class_get_byval_arg (klass)); if (name) { res = string_new_cleanup (name); g_free (name); } } } if (MONO_HANDLE_IS_NULL (res)) mono_error_set_out_of_memory (error_out, "Could not allocate type name"); HANDLE_FUNCTION_RETURN_REF (MonoString, res); } #if 0 static MonoExceptionHandle mono_error_prepare_exception_handle (MonoError *oerror, MonoError *error_out) // Can fail with out-of-memory { HANDLE_FUNCTION_ENTER (); MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, mono_error_prepare_exception (oerror, error_out)); HANDLE_FUNCTION_RETURN_REF (MonoException, ex); } #endif /*Can fail with out-of-memory*/ MonoException* mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) { HANDLE_FUNCTION_ENTER (); MonoErrorInternal *error = (MonoErrorInternal*)oerror; MonoExceptionHandle exception = MONO_HANDLE_CAST (MonoException, mono_new_null ()); char *type_name = NULL; char *message = NULL; error_init (error_out); const guint16 error_code = error->error_code; g_assert (error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); switch (error_code) { case MONO_ERROR_NONE: goto exit; case MONO_ERROR_MISSING_METHOD: exception = mono_corlib_exception_new_with_args ("System", "MissingMethodException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_BAD_IMAGE: exception = mono_corlib_exception_new_with_args ("System", "BadImageFormatException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_FILE_NOT_FOUND: exception = mono_corlib_exception_new_with_args ("System.IO", "FileNotFoundException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_MISSING_FIELD: exception = mono_corlib_exception_new_with_args ("System", "MissingFieldException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_MEMBER_ACCESS: exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System", "MemberAccessException", error->full_message, error_out); break; case MONO_ERROR_TYPE_LOAD: { MonoStringHandle assembly_name; MonoStringHandle type_name; if ((error->type_name && error->assembly_name) || error->exn.klass) { type_name = get_type_name_as_mono_string (error, error_out); if (!is_ok (error_out)) break; if (error->assembly_name) { assembly_name = string_new_cleanup (error->assembly_name); if (MONO_HANDLE_IS_NULL (assembly_name)) { mono_error_set_out_of_memory (error_out, "Could not allocate assembly name"); break; } } else { assembly_name = mono_string_empty_handle (); } exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", "TypeLoadException", type_name, assembly_name, error_out); if (!MONO_HANDLE_IS_NULL (exception)) { const char *full_message = error->full_message; if (full_message && full_message [0]) { MonoStringHandle msg = string_new_cleanup (full_message); if (!MONO_HANDLE_IS_NULL (msg)) MONO_HANDLE_SET (exception, message, msg); else mono_error_set_out_of_memory (error_out, "Could not allocate exception object"); } } } else { exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System", "TypeLoadException", error->full_message, error_out); } } break; case MONO_ERROR_OUT_OF_MEMORY: { MonoDomain *domain = mono_domain_get (); if (domain) exception = MONO_HANDLE_NEW (MonoException, domain->out_of_memory_ex); if (MONO_HANDLE_IS_NULL (exception)) exception = mono_get_exception_out_of_memory_handle (); break; } case MONO_ERROR_ARGUMENT: exception = mono_exception_new_argument (error->first_argument, error->full_message, error_out); break; case MONO_ERROR_ARGUMENT_NULL: exception = mono_exception_new_argument_null (error->first_argument, error_out); break; case MONO_ERROR_ARGUMENT_OUT_OF_RANGE: exception = mono_exception_new_argument_out_of_range(error->first_argument, error->full_message, error_out); break; case MONO_ERROR_NOT_VERIFIABLE: if (error->exn.klass) { type_name = mono_type_get_full_name (error->exn.klass); if (!type_name) goto out_of_memory; } message = g_strdup_printf ("Error in %s:%s %s", type_name, error->member_name, error->full_message); if (!message) goto out_of_memory; exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System.Security", "VerificationException", message, error_out); break; case MONO_ERROR_GENERIC: if (!error->exception_name_space || !error->exception_name) mono_error_set_execution_engine (error_out, "MonoError with generic error but no exception name was supplied"); else exception = mono_exception_new_by_name_msg (mono_defaults.corlib, error->exception_name_space, error->exception_name, error->full_message, error_out); break; case MONO_ERROR_EXCEPTION_INSTANCE: exception = MONO_HANDLE_CAST (MonoException, mono_gchandle_get_target_handle (error->exn.instance_handle)); break; case MONO_ERROR_CLEANUP_CALLED_SENTINEL: mono_error_set_execution_engine (error_out, "MonoError reused after mono_error_cleanup"); break; case MONO_ERROR_INVALID_PROGRAM: exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System", "InvalidProgramException", (error->flags & MONO_ERROR_INCOMPLETE) ? "" : error->full_message, error_out); break; default: mono_error_set_execution_engine (error_out, "Invalid error-code %d", error->error_code); } if (!is_ok (error_out)) goto return_null; if (MONO_HANDLE_IS_NULL (exception)) mono_error_set_out_of_memory (error_out, "Could not allocate exception object"); goto exit; out_of_memory: mono_error_set_out_of_memory (error_out, "Could not allocate message"); goto exit; return_null: exception = MONO_HANDLE_CAST (MonoException, mono_new_null ()); exit: g_free (message); g_free (type_name); HANDLE_FUNCTION_RETURN_OBJ (exception); } /* Convert this MonoError to an exception if it's faulty or return NULL. The error object is cleant after. */ MonoException* mono_error_convert_to_exception (MonoError *target_error) { ERROR_DECL (error); MonoException *ex; /* Mempool stored error shouldn't be cleaned up */ g_assert (!is_boxed ((MonoErrorInternal*)target_error)); if (is_ok (target_error)) return NULL; ex = mono_error_prepare_exception (target_error, error); if (!is_ok (error)) { ERROR_DECL (second_chance); /*Try to produce the exception for the second error. FIXME maybe we should log about the original one*/ ex = mono_error_prepare_exception (error, second_chance); // We cannot reasonably handle double faults, maybe later. g_assert (is_ok (second_chance)); mono_error_cleanup (error); } mono_error_cleanup (target_error); return ex; } void mono_error_move (MonoError *dest, MonoError *src) { memcpy (dest, src, sizeof (MonoErrorInternal)); error_init (src); } /** * mono_error_box: * \param ierror The input error that will be boxed. * \param image The mempool of this image will hold the boxed error. * Creates a new boxed error in the given mempool from \c MonoError. * It does not alter \p ierror, so you still have to clean it up with * \c mono_error_cleanup or \c mono_error_convert_to_exception or another such function. * \returns the boxed error, or NULL if the mempool could not allocate. */ MonoErrorBoxed* mono_error_box (const MonoError *ierror, MonoImage *image) { MonoErrorInternal *from = (MonoErrorInternal*)ierror; /* Don't know how to box a gchandle */ g_assert (!is_managed_exception (from)); MonoErrorBoxed* box = (MonoErrorBoxed*)mono_image_alloc (image, sizeof (MonoErrorBoxed)); box->image = image; mono_error_init_flags (&box->error, MONO_ERROR_MEMPOOL_BOXED); MonoErrorInternal *to = (MonoErrorInternal*)&box->error; #define DUP_STR(field) do { \ if (from->field) { \ if (!(to->field = mono_image_strdup (image, from->field))) \ to->flags |= MONO_ERROR_INCOMPLETE; \ } else { \ to->field = NULL; \ } \ } while (0) to->error_code = from->error_code; DUP_STR (type_name); DUP_STR (assembly_name); DUP_STR (member_name); DUP_STR (exception_name_space); DUP_STR (exception_name); DUP_STR (full_message); DUP_STR (full_message_with_fields); DUP_STR (first_argument); to->exn.klass = from->exn.klass; #undef DUP_STR return box; } /** * mono_error_set_from_boxed: * \param oerror The error that will be set to the contents of the box. * \param box A mempool-allocated error. * Sets the error condition in the oerror from the contents of the * given boxed error. Does not alter the boxed error, so it can be * used in a future call to \c mono_error_set_from_boxed as needed. The * \p oerror should've been previously initialized with \c mono_error_init, * as usual. * \returns TRUE on success or FALSE on failure. */ gboolean mono_error_set_from_boxed (MonoError *oerror, const MonoErrorBoxed *box) { MonoErrorInternal* to = (MonoErrorInternal*)oerror; MonoErrorInternal* from = (MonoErrorInternal*)&box->error; g_assert (!is_managed_exception (from)); mono_error_prepare (to); to->flags |= MONO_ERROR_FREE_STRINGS; #define DUP_STR(field) do { \ if (from->field) { \ if (!(to->field = g_strdup (from->field))) \ to->flags |= MONO_ERROR_INCOMPLETE; \ } else { \ to->field = NULL; \ } \ } while (0) to->error_code = from->error_code; DUP_STR (type_name); DUP_STR (assembly_name); DUP_STR (member_name); DUP_STR (exception_name_space); DUP_STR (exception_name); DUP_STR (full_message); DUP_STR (full_message_with_fields); DUP_STR (first_argument); to->exn.klass = from->exn.klass; #undef DUP_STR return (to->flags & MONO_ERROR_INCOMPLETE) == 0 ; } void mono_error_set_first_argument (MonoError *oerror, const char *first_argument) { MonoErrorInternal* to = (MonoErrorInternal*)oerror; to->first_argument = g_strdup (first_argument); to->flags |= MONO_ERROR_FREE_STRINGS; }
/** * \file * Error handling code * * Authors: * Rodrigo Kumpera ([email protected]) * Copyright 2009 Novell, Inc (http://www.novell.com) * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include <glib.h> #include <config.h> #include <mono/utils/mono-error.h> #include "mono-error-internals.h" #include <mono/metadata/exception.h> #include <mono/metadata/exception-internals.h> #include <mono/metadata/debug-helpers.h> #include <mono/metadata/object-internals.h> #define set_error_messagev() do { \ if (msg_format && !(error->full_message = g_strdup_vprintf (msg_format, args))) \ error->flags |= MONO_ERROR_INCOMPLETE; \ } while (0) #define set_error_message() do { \ va_list args; \ va_start (args, msg_format); \ set_error_messagev(); \ va_end (args); \ } while (0) static void mono_error_set_generic_errorv (MonoError *oerror, const char *name_space, const char *name, const char *msg_format, va_list args); static gboolean is_managed_error_code (guint16 error_code) { return error_code == MONO_ERROR_EXCEPTION_INSTANCE; } static gboolean is_managed_exception (MonoErrorInternal *error) { return is_managed_error_code (error->error_code); } static gboolean is_boxed_error_flags (guint16 error_flags) { return (error_flags & MONO_ERROR_MEMPOOL_BOXED) != 0; } static gboolean is_boxed (MonoErrorInternal *error) { return is_boxed_error_flags (error->flags); } static void mono_error_free_string (const char **error_string) { g_free ((char*)*error_string); *error_string = NULL; } static void mono_error_init_deferred (MonoErrorInternal *error) // mono_error_init and mono_error_init_flags are optimized and only initialize a minimum. // Initialize the rest, prior to originating an error. { memset (&error->type_name, 0, sizeof (*error) - offsetof (MonoErrorInternal, type_name)); } static void mono_error_prepare (MonoErrorInternal *error) { /* mono_error_set_* after a mono_error_cleanup without an intervening init */ g_assert (error->error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); if (error->error_code != MONO_ERROR_NONE) return; mono_error_init_deferred (error); } static MonoClass* get_class (MonoErrorInternal *error) { MonoClass *klass = NULL; if (is_managed_exception (error)) klass = mono_object_class (mono_gchandle_get_target_internal (error->exn.instance_handle)); else klass = error->exn.klass; return klass; } static const char* get_type_name (MonoErrorInternal *error) { if (error->type_name) return error->type_name; MonoClass *klass = get_class (error); if (klass) return m_class_get_name (klass); return "<unknown type>"; } static const char* get_assembly_name (MonoErrorInternal *error) { if (error->assembly_name) return error->assembly_name; MonoClass *klass = get_class (error); if (klass && m_class_get_image (klass)) return m_class_get_image (klass)->name; return "<unknown assembly>"; } void mono_error_init_flags (MonoError *oerror, guint16 flags) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; g_static_assert (sizeof (MonoErrorExternal) >= sizeof (MonoErrorInternal)); error->error_code = MONO_ERROR_NONE; error->flags = flags; } /** * mono_error_init: * \param error Pointer to \c MonoError struct to initialize * Any function which takes a \c MonoError for purposes of reporting an error * is required to call either this or \c mono_error_init_flags on entry. */ void mono_error_init (MonoError *error) { mono_error_init_flags (error, 0); } void mono_error_cleanup (MonoError *oerror) { // This function is called a lot so it is optimized. MonoErrorInternal *error = (MonoErrorInternal*)oerror; #if G_BYTE_ORDER == G_LITTLE_ENDIAN const guint32 init = oerror->init; const guint16 error_code = (guint16)(init & 0xFFFF); const guint16 error_flags = (guint16)(init >> 16); #else const guint16 error_code = error->error_code; const guint16 error_flags = error->flags; #endif /* Two cleanups in a row without an intervening init. */ g_assert (error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); /* Mempool stored error shouldn't be cleaned up */ g_assert (!is_boxed_error_flags (error_flags)); /* Mark it as cleaned up. */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN oerror->init = MONO_ERROR_CLEANUP_CALLED_SENTINEL; #else error->error_code = MONO_ERROR_CLEANUP_CALLED_SENTINEL; error->flags = 0; #endif if (error_code == MONO_ERROR_NONE) return; if (is_managed_error_code (error_code)) mono_gchandle_free_internal (error->exn.instance_handle); mono_error_free_string (&error->full_message); mono_error_free_string (&error->full_message_with_fields); if (!(error_flags & MONO_ERROR_FREE_STRINGS)) //no memory was allocated return; mono_error_free_string (&error->type_name); mono_error_free_string (&error->assembly_name); mono_error_free_string (&error->member_name); mono_error_free_string (&error->exception_name_space); mono_error_free_string (&error->exception_name); mono_error_free_string (&error->first_argument); error->exn.klass = NULL; } gboolean mono_error_ok (MonoError *error) { return is_ok (error); } guint16 mono_error_get_error_code (MonoError *error) { return error->error_code; } const char* mono_error_get_exception_name (MonoError *oerror) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; if (error->error_code == MONO_ERROR_NONE) return NULL; return error->exception_name; } /*Return a pointer to the internal error message, might be NULL. Caller should not release it.*/ const char* mono_error_get_message (MonoError *oerror) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; const guint16 error_code = error->error_code; if (error_code == MONO_ERROR_NONE) return NULL; g_assert (error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); //Those are the simplified errors switch (error_code) { case MONO_ERROR_MISSING_METHOD: case MONO_ERROR_BAD_IMAGE: case MONO_ERROR_FILE_NOT_FOUND: case MONO_ERROR_MISSING_FIELD: return error->full_message; } if (error->full_message_with_fields) return error->full_message_with_fields; error->full_message_with_fields = g_strdup_printf ("%s assembly:%s type:%s member:%s", error->full_message, get_assembly_name (error), get_type_name (error), error->member_name); return error->full_message_with_fields ? error->full_message_with_fields : error->full_message; } /* * Inform that this error has heap allocated strings. * The strings will be duplicated if @dup_strings is TRUE * otherwise they will just be free'd in mono_error_cleanup. */ void mono_error_dup_strings (MonoError *oerror, gboolean dup_strings) { #define DUP_STR(field) do { if (error->field) {\ if (!(error->field = g_strdup (error->field))) \ error->flags |= MONO_ERROR_INCOMPLETE; \ }} while (0); MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->flags |= MONO_ERROR_FREE_STRINGS; if (dup_strings) { DUP_STR (type_name); DUP_STR (assembly_name); DUP_STR (member_name); DUP_STR (exception_name_space); DUP_STR (exception_name); DUP_STR (first_argument); } #undef DUP_STR } void mono_error_set_error (MonoError *oerror, int error_code, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = error_code; set_error_message (); } static void mono_error_set_assembly_name (MonoError *oerror, const char *assembly_name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; g_assert (error->error_code != MONO_ERROR_NONE); error->assembly_name = assembly_name; } static void mono_error_set_member_name (MonoError *oerror, const char *member_name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->member_name = member_name; } static void mono_error_set_type_name (MonoError *oerror, const char *type_name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->type_name = type_name; } static void mono_error_set_class (MonoError *oerror, MonoClass *klass) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; if (is_managed_exception (error)) return; error->exn.klass = klass; } static void mono_error_set_corlib_exception (MonoError *oerror, const char *name_space, const char *name) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; error->exception_name_space = name_space; error->exception_name = name; } void mono_error_set_type_load_class (MonoError *oerror, MonoClass *klass, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_vset_type_load_class (oerror, klass, msg_format, args); va_end (args); } void mono_error_vset_type_load_class (MonoError *oerror, MonoClass *klass, const char *msg_format, va_list args) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_TYPE_LOAD; mono_error_set_class (oerror, klass); set_error_messagev (); } /* * Different than other functions, this one here assumes that type_name and assembly_name to have been allocated just for us. * Which means mono_error_cleanup will free them. */ void mono_error_set_type_load_name (MonoError *oerror, const char *type_name, const char *assembly_name, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_TYPE_LOAD; mono_error_set_type_name (oerror, type_name); mono_error_set_assembly_name (oerror, assembly_name); mono_error_dup_strings (oerror, FALSE); set_error_message (); } /* * Sets @error to be of type @error_code with message @message * XXX only works for MONO_ERROR_MISSING_METHOD, MONO_ERROR_BAD_IMAGE, MONO_ERROR_FILE_NOT_FOUND and MONO_ERROR_MISSING_FIELD for now */ void mono_error_set_specific (MonoError *oerror, int error_code, const char *message) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = error_code; error->full_message = message; error->flags |= MONO_ERROR_FREE_STRINGS; } void mono_error_set_generic_errorv (MonoError *oerror, const char *name_space, const char *name, const char *msg_format, va_list args) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_GENERIC; mono_error_set_corlib_exception (oerror, name_space, name); set_error_messagev (); } void mono_error_set_generic_error (MonoError *oerror, const char * name_space, const char *name, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, name_space, name, msg_format, args); va_end (args); } /** * mono_error_set_not_implemented: * * System.NotImplementedException */ void mono_error_set_not_implemented (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "NotImplementedException", msg_format, args); va_end (args); } /** * mono_error_set_execution_engine: * * System.ExecutionEngineException */ void mono_error_set_execution_engine (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "ExecutionEngineException", msg_format, args); va_end (args); } /** * mono_error_set_not_supported: * * System.NotSupportedException */ void mono_error_set_not_supported (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "NotSupportedException", msg_format, args); va_end (args); } /** * mono_error_set_ambiguous_implementation: * * System.Runtime.AmbiguousImplementationException */ void mono_error_set_ambiguous_implementation (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System.Runtime", "AmbiguousImplementationException", msg_format, args); va_end (args); } /** * mono_error_set_invalid_operation: * * System.InvalidOperationException */ void mono_error_set_invalid_operation (MonoError *oerror, const char *msg_format, ...) { va_list args; va_start (args, msg_format); mono_error_set_generic_errorv (oerror, "System", "InvalidOperationException", msg_format, args); va_end (args); } void mono_error_set_invalid_program (MonoError *oerror, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_INVALID_PROGRAM; set_error_message (); } void mono_error_set_member_access (MonoError *oerror, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_MEMBER_ACCESS; set_error_message (); } /** * mono_error_set_invalid_cast: * * System.InvalidCastException */ void mono_error_set_invalid_cast (MonoError *oerror) { mono_error_set_generic_error (oerror, "System", "InvalidCastException", ""); } void mono_error_set_exception_instance (MonoError *oerror, MonoException *exc) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_EXCEPTION_INSTANCE; error->exn.instance_handle = mono_gchandle_new_internal (exc ? &exc->object : NULL, FALSE); } void mono_error_set_exception_handle (MonoError *oerror, MonoExceptionHandle exc) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_EXCEPTION_INSTANCE; error->exn.instance_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST(MonoObject, exc), FALSE); } void mono_error_set_out_of_memory (MonoError *oerror, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_OUT_OF_MEMORY; set_error_message (); } void mono_error_set_argument_format (MonoError *oerror, const char *argument, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_ARGUMENT; error->first_argument = argument; set_error_message (); } void mono_error_set_argument (MonoError *oerror, const char *argument, const char *msg) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_ARGUMENT; error->first_argument = argument; if (msg && msg [0] && !(error->full_message = g_strdup (msg))) error->flags |= MONO_ERROR_INCOMPLETE; } void mono_error_set_argument_null (MonoError *oerror, const char *argument, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_ARGUMENT_NULL; error->first_argument = argument; set_error_message (); } void mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_NOT_VERIFIABLE; if (method) { mono_error_set_class (oerror, method->klass); mono_error_set_member_name (oerror, mono_method_full_name (method, 1)); } set_error_message (); } /* Used by mono_error_prepare_exception - it sets its own error on mono_string_new_checked failure. */ static MonoStringHandle string_new_cleanup (const char *text) { ERROR_DECL (ignored_err); MonoStringHandle result = mono_string_new_handle (text, ignored_err); mono_error_cleanup (ignored_err); return result; } static MonoStringHandle get_type_name_as_mono_string (MonoErrorInternal *error, MonoError *error_out) { HANDLE_FUNCTION_ENTER (); MonoStringHandle res = NULL_HANDLE_STRING; if (error->type_name) { res = string_new_cleanup (error->type_name); } else { MonoClass *klass = get_class (error); if (klass) { char *name = mono_type_full_name (m_class_get_byval_arg (klass)); if (name) { res = string_new_cleanup (name); g_free (name); } } } if (MONO_HANDLE_IS_NULL (res)) mono_error_set_out_of_memory (error_out, "Could not allocate type name"); HANDLE_FUNCTION_RETURN_REF (MonoString, res); } #if 0 static MonoExceptionHandle mono_error_prepare_exception_handle (MonoError *oerror, MonoError *error_out) // Can fail with out-of-memory { HANDLE_FUNCTION_ENTER (); MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, mono_error_prepare_exception (oerror, error_out)); HANDLE_FUNCTION_RETURN_REF (MonoException, ex); } #endif /*Can fail with out-of-memory*/ MonoException* mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) { HANDLE_FUNCTION_ENTER (); MonoErrorInternal *error = (MonoErrorInternal*)oerror; MonoExceptionHandle exception = MONO_HANDLE_CAST (MonoException, mono_new_null ()); char *type_name = NULL; char *message = NULL; error_init (error_out); const guint16 error_code = error->error_code; g_assert (error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL); switch (error_code) { case MONO_ERROR_NONE: goto exit; case MONO_ERROR_MISSING_METHOD: exception = mono_corlib_exception_new_with_args ("System", "MissingMethodException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_BAD_IMAGE: exception = mono_corlib_exception_new_with_args ("System", "BadImageFormatException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_FILE_NOT_FOUND: exception = mono_corlib_exception_new_with_args ("System.IO", "FileNotFoundException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_MISSING_FIELD: exception = mono_corlib_exception_new_with_args ("System", "MissingFieldException", error->full_message, error->first_argument, error_out); break; case MONO_ERROR_MEMBER_ACCESS: exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System", "MemberAccessException", error->full_message, error_out); break; case MONO_ERROR_TYPE_LOAD: { MonoStringHandle assembly_name; MonoStringHandle type_name; if ((error->type_name && error->assembly_name) || error->exn.klass) { type_name = get_type_name_as_mono_string (error, error_out); if (!is_ok (error_out)) break; if (error->assembly_name) { assembly_name = string_new_cleanup (error->assembly_name); if (MONO_HANDLE_IS_NULL (assembly_name)) { mono_error_set_out_of_memory (error_out, "Could not allocate assembly name"); break; } } else { assembly_name = mono_string_empty_handle (); } exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", "TypeLoadException", type_name, assembly_name, error_out); if (!MONO_HANDLE_IS_NULL (exception)) { const char *full_message = error->full_message; if (full_message && full_message [0]) { MonoStringHandle msg = string_new_cleanup (full_message); if (!MONO_HANDLE_IS_NULL (msg)) MONO_HANDLE_SET (exception, message, msg); else mono_error_set_out_of_memory (error_out, "Could not allocate exception object"); } } } else { exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System", "TypeLoadException", error->full_message, error_out); } } break; case MONO_ERROR_OUT_OF_MEMORY: { MonoDomain *domain = mono_domain_get (); if (domain) exception = MONO_HANDLE_NEW (MonoException, domain->out_of_memory_ex); if (MONO_HANDLE_IS_NULL (exception)) exception = mono_get_exception_out_of_memory_handle (); break; } case MONO_ERROR_ARGUMENT: exception = mono_exception_new_argument (error->first_argument, error->full_message, error_out); break; case MONO_ERROR_ARGUMENT_NULL: exception = mono_exception_new_argument_null (error->first_argument, error_out); break; case MONO_ERROR_ARGUMENT_OUT_OF_RANGE: exception = mono_exception_new_argument_out_of_range(error->first_argument, error->full_message, error_out); break; case MONO_ERROR_NOT_VERIFIABLE: if (error->exn.klass) { type_name = mono_type_get_full_name (error->exn.klass); if (!type_name) goto out_of_memory; } message = g_strdup_printf ("Error in %s:%s %s", type_name, error->member_name, error->full_message); if (!message) goto out_of_memory; exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System.Security", "VerificationException", message, error_out); break; case MONO_ERROR_GENERIC: if (!error->exception_name_space || !error->exception_name) mono_error_set_execution_engine (error_out, "MonoError with generic error but no exception name was supplied"); else exception = mono_exception_new_by_name_msg (mono_defaults.corlib, error->exception_name_space, error->exception_name, error->full_message, error_out); break; case MONO_ERROR_EXCEPTION_INSTANCE: exception = MONO_HANDLE_CAST (MonoException, mono_gchandle_get_target_handle (error->exn.instance_handle)); break; case MONO_ERROR_CLEANUP_CALLED_SENTINEL: mono_error_set_execution_engine (error_out, "MonoError reused after mono_error_cleanup"); break; case MONO_ERROR_INVALID_PROGRAM: exception = mono_exception_new_by_name_msg (mono_defaults.corlib, "System", "InvalidProgramException", (error->flags & MONO_ERROR_INCOMPLETE) ? "" : error->full_message, error_out); break; default: mono_error_set_execution_engine (error_out, "Invalid error-code %d", error->error_code); } if (!is_ok (error_out)) goto return_null; if (MONO_HANDLE_IS_NULL (exception)) mono_error_set_out_of_memory (error_out, "Could not allocate exception object"); goto exit; out_of_memory: mono_error_set_out_of_memory (error_out, "Could not allocate message"); goto exit; return_null: exception = MONO_HANDLE_CAST (MonoException, mono_new_null ()); exit: g_free (message); g_free (type_name); HANDLE_FUNCTION_RETURN_OBJ (exception); } /* Convert this MonoError to an exception if it's faulty or return NULL. The error object is cleant after. */ MonoException* mono_error_convert_to_exception (MonoError *target_error) { ERROR_DECL (error); MonoException *ex; /* Mempool stored error shouldn't be cleaned up */ g_assert (!is_boxed ((MonoErrorInternal*)target_error)); if (is_ok (target_error)) return NULL; ex = mono_error_prepare_exception (target_error, error); if (!is_ok (error)) { ERROR_DECL (second_chance); /*Try to produce the exception for the second error. FIXME maybe we should log about the original one*/ ex = mono_error_prepare_exception (error, second_chance); // We cannot reasonably handle double faults, maybe later. g_assert (is_ok (second_chance)); mono_error_cleanup (error); } mono_error_cleanup (target_error); return ex; } void mono_error_move (MonoError *dest, MonoError *src) { memcpy (dest, src, sizeof (MonoErrorInternal)); error_init (src); } /** * mono_error_box: * \param ierror The input error that will be boxed. * \param image The mempool of this image will hold the boxed error. * Creates a new boxed error in the given mempool from \c MonoError. * It does not alter \p ierror, so you still have to clean it up with * \c mono_error_cleanup or \c mono_error_convert_to_exception or another such function. * \returns the boxed error, or NULL if the mempool could not allocate. */ MonoErrorBoxed* mono_error_box (const MonoError *ierror, MonoImage *image) { MonoErrorInternal *from = (MonoErrorInternal*)ierror; /* Don't know how to box a gchandle */ g_assert (!is_managed_exception (from)); MonoErrorBoxed* box = (MonoErrorBoxed*)mono_image_alloc (image, sizeof (MonoErrorBoxed)); box->image = image; mono_error_init_flags (&box->error, MONO_ERROR_MEMPOOL_BOXED); MonoErrorInternal *to = (MonoErrorInternal*)&box->error; #define DUP_STR(field) do { \ if (from->field) { \ if (!(to->field = mono_image_strdup (image, from->field))) \ to->flags |= MONO_ERROR_INCOMPLETE; \ } else { \ to->field = NULL; \ } \ } while (0) to->error_code = from->error_code; DUP_STR (type_name); DUP_STR (assembly_name); DUP_STR (member_name); DUP_STR (exception_name_space); DUP_STR (exception_name); DUP_STR (full_message); DUP_STR (full_message_with_fields); DUP_STR (first_argument); to->exn.klass = from->exn.klass; #undef DUP_STR return box; } /** * mono_error_set_from_boxed: * \param oerror The error that will be set to the contents of the box. * \param box A mempool-allocated error. * Sets the error condition in the oerror from the contents of the * given boxed error. Does not alter the boxed error, so it can be * used in a future call to \c mono_error_set_from_boxed as needed. The * \p oerror should've been previously initialized with \c mono_error_init, * as usual. * \returns TRUE on success or FALSE on failure. */ gboolean mono_error_set_from_boxed (MonoError *oerror, const MonoErrorBoxed *box) { MonoErrorInternal* to = (MonoErrorInternal*)oerror; MonoErrorInternal* from = (MonoErrorInternal*)&box->error; g_assert (!is_managed_exception (from)); mono_error_prepare (to); to->flags |= MONO_ERROR_FREE_STRINGS; #define DUP_STR(field) do { \ if (from->field) { \ if (!(to->field = g_strdup (from->field))) \ to->flags |= MONO_ERROR_INCOMPLETE; \ } else { \ to->field = NULL; \ } \ } while (0) to->error_code = from->error_code; DUP_STR (type_name); DUP_STR (assembly_name); DUP_STR (member_name); DUP_STR (exception_name_space); DUP_STR (exception_name); DUP_STR (full_message); DUP_STR (full_message_with_fields); DUP_STR (first_argument); to->exn.klass = from->exn.klass; #undef DUP_STR return (to->flags & MONO_ERROR_INCOMPLETE) == 0 ; } void mono_error_set_first_argument (MonoError *oerror, const char *first_argument) { MonoErrorInternal* to = (MonoErrorInternal*)oerror; to->first_argument = g_strdup (first_argument); to->flags |= MONO_ERROR_FREE_STRINGS; }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/Regression/CLR-x86-JIT/V1-M10/b13466/b13466.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Security.Cryptography/tests/Sha384Tests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.IO; using System.Threading; using System.Threading.Tasks; using Xunit; namespace System.Security.Cryptography.Tests { public class Sha384Tests : HashAlgorithmTestDriver { protected override HashAlgorithm Create() { return SHA384.Create(); } protected override bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten) { return SHA384.TryHashData(source, destination, out bytesWritten); } protected override byte[] HashData(byte[] source) => SHA384.HashData(source); protected override byte[] HashData(ReadOnlySpan<byte> source) => SHA384.HashData(source); protected override int HashData(ReadOnlySpan<byte> source, Span<byte> destination) => SHA384.HashData(source, destination); protected override int HashData(Stream source, Span<byte> destination) => SHA384.HashData(source, destination); protected override byte[] HashData(Stream source) => SHA384.HashData(source); protected override ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken) => SHA384.HashDataAsync(source, destination, cancellationToken); protected override ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken) => SHA384.HashDataAsync(source, cancellationToken); [Fact] public void Sha384_Empty() { Verify( Array.Empty<byte>(), "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public void Sha384_Empty_Stream() { VerifyRepeating( "", 0, "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public async Task Sha384_Empty_Stream_Async() { await VerifyRepeatingAsync( "", 0, "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public void Sha384_VerifyLargeStream_MultipleOf4096() { // Verfied with: // for _ in {1..1024}; do echo -n "0102030405060708"; done | openssl dgst -sha384 VerifyRepeating( "0102030405060708", 1024, "d9deec18b8ec0d31270eaeaaf3bcb1de55f1d81482a55d2c023bad873175f1694d8c28e8138d9147dc180e679cd79c58"); } [Fact] public void Sha384_VerifyLargeStream_NotMultipleOf4096() { // Verfied with: // for _ in {1..1025}; do echo -n "0102030405060708"; done | openssl dgst -sha384 VerifyRepeating( "0102030405060708", 1025, "35cf18493364379093c7def8477330f817f9045d2e311d721730b24d98c9d9e9761c7f27821742e0c236509627aea7fa"); } [Fact] public async Task Sha384_VerifyLargeStream_NotMultipleOf4096_Async() { // Verfied with: // for _ in {1..1025}; do echo -n "0102030405060708"; done | openssl dgst -sha384 await VerifyRepeatingAsync( "0102030405060708", 1025, "35cf18493364379093c7def8477330f817f9045d2e311d721730b24d98c9d9e9761c7f27821742e0c236509627aea7fa"); } [Fact] public async Task Sha384_VerifyLargeStream_MultipleOf4096_Async() { // Verfied with: // for _ in {1..1024}; do echo -n "0102030405060708"; done | openssl dgst -sha384 await VerifyRepeatingAsync( "0102030405060708", 1024, "d9deec18b8ec0d31270eaeaaf3bcb1de55f1d81482a55d2c023bad873175f1694d8c28e8138d9147dc180e679cd79c58"); } // These test cases are from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf [Fact] public void Sha384_NistShaAll_1() { Verify( "abc", "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7"); } [Fact] public void Sha384_Fips180_MultiBlock() { VerifyMultiBlock( "a", "bc", "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7", "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public void Sha384_NistShaAll_2() { Verify( "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", "09330C33F71147E83D192FC782CD1B4753111B173B3B05D22FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.IO; using System.Threading; using System.Threading.Tasks; using Xunit; namespace System.Security.Cryptography.Tests { public class Sha384Tests : HashAlgorithmTestDriver { protected override HashAlgorithm Create() { return SHA384.Create(); } protected override bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten) { return SHA384.TryHashData(source, destination, out bytesWritten); } protected override byte[] HashData(byte[] source) => SHA384.HashData(source); protected override byte[] HashData(ReadOnlySpan<byte> source) => SHA384.HashData(source); protected override int HashData(ReadOnlySpan<byte> source, Span<byte> destination) => SHA384.HashData(source, destination); protected override int HashData(Stream source, Span<byte> destination) => SHA384.HashData(source, destination); protected override byte[] HashData(Stream source) => SHA384.HashData(source); protected override ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken) => SHA384.HashDataAsync(source, destination, cancellationToken); protected override ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken) => SHA384.HashDataAsync(source, cancellationToken); [Fact] public void Sha384_Empty() { Verify( Array.Empty<byte>(), "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public void Sha384_Empty_Stream() { VerifyRepeating( "", 0, "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public async Task Sha384_Empty_Stream_Async() { await VerifyRepeatingAsync( "", 0, "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public void Sha384_VerifyLargeStream_MultipleOf4096() { // Verfied with: // for _ in {1..1024}; do echo -n "0102030405060708"; done | openssl dgst -sha384 VerifyRepeating( "0102030405060708", 1024, "d9deec18b8ec0d31270eaeaaf3bcb1de55f1d81482a55d2c023bad873175f1694d8c28e8138d9147dc180e679cd79c58"); } [Fact] public void Sha384_VerifyLargeStream_NotMultipleOf4096() { // Verfied with: // for _ in {1..1025}; do echo -n "0102030405060708"; done | openssl dgst -sha384 VerifyRepeating( "0102030405060708", 1025, "35cf18493364379093c7def8477330f817f9045d2e311d721730b24d98c9d9e9761c7f27821742e0c236509627aea7fa"); } [Fact] public async Task Sha384_VerifyLargeStream_NotMultipleOf4096_Async() { // Verfied with: // for _ in {1..1025}; do echo -n "0102030405060708"; done | openssl dgst -sha384 await VerifyRepeatingAsync( "0102030405060708", 1025, "35cf18493364379093c7def8477330f817f9045d2e311d721730b24d98c9d9e9761c7f27821742e0c236509627aea7fa"); } [Fact] public async Task Sha384_VerifyLargeStream_MultipleOf4096_Async() { // Verfied with: // for _ in {1..1024}; do echo -n "0102030405060708"; done | openssl dgst -sha384 await VerifyRepeatingAsync( "0102030405060708", 1024, "d9deec18b8ec0d31270eaeaaf3bcb1de55f1d81482a55d2c023bad873175f1694d8c28e8138d9147dc180e679cd79c58"); } // These test cases are from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf [Fact] public void Sha384_NistShaAll_1() { Verify( "abc", "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7"); } [Fact] public void Sha384_Fips180_MultiBlock() { VerifyMultiBlock( "a", "bc", "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7", "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"); } [Fact] public void Sha384_NistShaAll_2() { Verify( "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", "09330C33F71147E83D192FC782CD1B4753111B173B3B05D22FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039"); } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltScenarios/EXslt/out/math-abs.xml
<out> <test1>22.9</test1> <test2>22.9</test2> <test3>NaN</test3> <test4>Infinity</test4> <test5>Infinity</test5> </out>
<out> <test1>22.9</test1> <test2>22.9</test2> <test3>NaN</test3> <test4>Infinity</test4> <test5>Infinity</test5> </out>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/Loader/classloader/generics/Variance/IL/Unbox005.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; public class Base {} public class Sub : Base {} public class GBase<T> {} public class GSubT<T> : GBase<T> {} public struct GTU<T,U> : IPlusT<T>, IMinusT<U>, IMinusTPlusU<T,U> {} public struct GTArrUArr<T,U> : IMinusT<T[]>, IPlusT<U[]>, IMinusTPlusU<T[],U[]> {} public struct GRefTRefU<T,U> : IMinusT<IPlusT<T>>, IMinusT<IMinusT<U>>, IMinusTPlusU<IPlusT<T>, IPlusT<U>> {} public struct GRefTArrRefUArr<T,U> : IMinusT<IPlusT<T[]>>, IMinusT<IMinusT<U[]>>, IMinusTPlusU<IPlusT<T[]>,IPlusT<U[]>> {} public struct GArrRefTArrRefU<T,U> : IMinusT<IPlusT<T>[]>, IMinusT<IMinusT<U>[]>, IMinusTPlusU<IPlusT<T>[],IPlusT<U>[]> {} public class TestClass { static int iTestCount= 0; static int iErrorCount= 0; static int iExitCode = 101; public static void Eval(string location, bool exp) { ++iTestCount; if ( !(exp)) { iErrorCount++; Console.WriteLine("Test Failed at location: {0} @ count {1} ", location, iTestCount); } } private static void UnboxUToTInternal<T,U>() { T t = (T) Activator.CreateInstance(typeof(U)); } private static void CaseClassUToTWrapper<T,U>() { UnboxUToTInternal<T,U>(); } public static bool UnboxUToT<T,U>(bool expected) { try { CaseClassUToTWrapper<T,U>(); if (expected) { return true; } else { return false; } } catch (InvalidCastException) { if (expected) { Console.WriteLine("Unexpected Exception InvalidCastException"); return false; } else { return true; } } catch(Exception E) { Console.WriteLine("Unexpected Exception {0}, with T = {1} and U = {2}", E, typeof(T), typeof(U)); return false; } } private static bool RunTests() { Eval("Test001", UnboxUToT<IPlusT<IMinusT<Base>>, GTU<IMinusT<Sub>,Base>>(false)); Eval("Test002", UnboxUToT<IMinusT<IMinusT<Sub>>, GTU<Sub,IMinusT<Base>>>(false)); Eval("Test003", UnboxUToT<IPlusTMinusU<Base,Sub>, GTU<Sub,Base>>(false)); Eval("Test004", UnboxUToT<IPlusT<IMinusT<Base[]>>, GTU<IMinusT<Sub[]>,Base>>(false)); Eval("Test005", UnboxUToT<IMinusT<IMinusT<Sub[]>>, GTU<Sub,IMinusT<Base[]>>>(false)); Eval("Test006", UnboxUToT<IPlusTMinusU<Base[],Sub[]>, GTU<Sub[],Base[]>>(false)); Eval("Test007", UnboxUToT<IPlusT<IMinusT<GBase<int>>>, GTU<IMinusT<GSubT<int>>,GBase<int>>>(false)); Eval("Test008", UnboxUToT<IMinusT<IMinusT<GSubT<int>>>, GTU<GSubT<int>,IMinusT<GBase<int>>>>(false)); Eval("Test009", UnboxUToT<IPlusTMinusU<GBase<int>,GSubT<int>>, GTU<GSubT<int>,GBase<int>>>(false)); Eval("Test010", UnboxUToT<IPlusT<IMinusT<GBase<int>[]>>, GTU<IMinusT<GSubT<int>[]>,GBase<int>[]>>(false)); Eval("Test011", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GTU<GSubT<int>[],IMinusT<GBase<int>[]>>>(false)); Eval("Test012", UnboxUToT<IPlusTMinusU<GBase<int>[],GSubT<int>[]>, GTU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test101", UnboxUToT<IPlusT<IMinusT<Base>[]>, GTArrUArr<IMinusT<Sub>,Base>>(false)); Eval("Test102", UnboxUToT<IMinusT<IMinusT<Sub>[]>, GTArrUArr<Sub,IMinusT<Base>>>(false)); Eval("Test103", UnboxUToT<IPlusTMinusU<Base[],Sub[]>, GTArrUArr<Sub,Base>>(false)); Eval("Test104", UnboxUToT<IPlusT<IMinusT<Base[]>[]>, GTArrUArr<IMinusT<Sub[]>,Base>>(false)); Eval("Test105", UnboxUToT<IMinusT<IMinusT<Sub[]>[]>, GTArrUArr<Sub,IMinusT<Base[]>>>(false)); Eval("Test106", UnboxUToT<IPlusTMinusU<Base[][],Sub[][]>, GTArrUArr<Sub[],Base[]>>(false)); Eval("Test107", UnboxUToT<IPlusT<IMinusT<GBase<int>>[]>, GTArrUArr<IMinusT<GSubT<int>>,GBase<int>>>(false)); Eval("Test108", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GTArrUArr<GSubT<int>,IMinusT<GBase<int>>>>(false)); Eval("Test109", UnboxUToT<IPlusTMinusU<GBase<int>,GSubT<int>>, GTArrUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test110", UnboxUToT<IPlusT<IMinusT<GBase<int>[]>>[], GTArrUArr<IMinusT<GSubT<int>[]>,GBase<int>[]>>(false)); Eval("Test111", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>[]>, GTArrUArr<GSubT<int>[],IMinusT<GBase<int>[]>>>(false)); Eval("Test112", UnboxUToT<IPlusTMinusU<GBase<int>[][],GSubT<int>[][]>, GTArrUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test201", UnboxUToT<IPlusT<IPlusT<Base>>, GRefTRefU<Sub,Base>>(false)); Eval("Test202", UnboxUToT<IMinusT<IMinusT<Sub>>, GRefTRefU<Sub,Base>>(false)); Eval("Test203", UnboxUToT<IPlusTMinusU<IPlusT<Base>,IPlusT<Sub>>, GRefTRefU<Sub,Base>>(false)); Eval("Test204", UnboxUToT<IPlusT<IPlusT<Base[]>>, GRefTRefU<Sub[],Base[]>>(false)); Eval("Test205", UnboxUToT<IMinusT<IMinusT<Sub[]>>, GRefTRefU<Sub[],Base[]>>(false)); Eval("Test206", UnboxUToT<IPlusTMinusU<IPlusT<Base[]>,IPlusT<Sub[]>>, GRefTRefU<Sub[],Base[]>>(false)); Eval("Test207", UnboxUToT<IPlusT<IPlusT<GBase<int>>>, GRefTRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test208", UnboxUToT<IMinusT<IMinusT<GSubT<int>>>, GRefTRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test209", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>>,IPlusT<GSubT<int>>>, GRefTRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test210", UnboxUToT<IPlusT<IPlusT<GBase<int>[]>>, GRefTRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test211", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GRefTRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test212", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[]>,IPlusT<GSubT<int>[]>>, GRefTRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test301", UnboxUToT<IPlusT<IPlusT<Base[]>>, GRefTArrRefUArr<Sub,Base>>(false)); Eval("Test302", UnboxUToT<IMinusT<IMinusT<Sub[]>>, GRefTArrRefUArr<Sub,Base>>(false)); Eval("Test303", UnboxUToT<IPlusTMinusU<IPlusT<Base[]>,IPlusT<Sub[]>>, GRefTArrRefUArr<Sub,Base>>(false)); Eval("Test304", UnboxUToT<IPlusT<IPlusT<Base[][]>>, GRefTArrRefUArr<Sub[],Base[]>>(false)); Eval("Test305", UnboxUToT<IMinusT<IMinusT<Sub[][]>>, GRefTArrRefUArr<Sub[],Base[]>>(false)); Eval("Test306", UnboxUToT<IPlusTMinusU<IPlusT<Base[][]>,IPlusT<Sub[][]>>, GRefTArrRefUArr<Sub[],Base[]>>(false)); Eval("Test307", UnboxUToT<IPlusT<IPlusT<GBase<int>[]>>, GRefTArrRefUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test308", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GRefTArrRefUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test309", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[]>,IPlusT<GSubT<int>[]>>, GRefTArrRefUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test310", UnboxUToT<IPlusT<IPlusT<GBase<int>[][]>>, GRefTArrRefUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test311", UnboxUToT<IMinusT<IMinusT<GSubT<int>[][]>>, GRefTArrRefUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test312", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[][]>,IPlusT<GSubT<int>[][]>>, GRefTArrRefUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test401", UnboxUToT<IPlusT<IPlusT<Base>[]>, GArrRefTArrRefU<Sub,Base>>(false)); Eval("Test402", UnboxUToT<IMinusT<IMinusT<Sub>[]>, GArrRefTArrRefU<Sub,Base>>(false)); Eval("Test403", UnboxUToT<IPlusTMinusU<IPlusT<Base>[],IPlusT<Sub>[]>, GArrRefTArrRefU<Sub,Base>>(false)); Eval("Test404", UnboxUToT<IPlusT<IPlusT<Base[,]>[]>, GArrRefTArrRefU<Sub[,],Base[,]>>(false)); Eval("Test405", UnboxUToT<IMinusT<IMinusT<Sub[,]>[]>, GArrRefTArrRefU<Sub[,],Base[,]>>(false)); Eval("Test406", UnboxUToT<IPlusTMinusU<IPlusT<Base[,]>[],IPlusT<Sub[,]>[]>, GArrRefTArrRefU<Sub[,],Base[,]>>(false)); Eval("Test407", UnboxUToT<IPlusT<IPlusT<GBase<int>>[]>, GArrRefTArrRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test408", UnboxUToT<IMinusT<IMinusT<GSubT<int>>[]>, GArrRefTArrRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test409", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>>[],IPlusT<GSubT<int>>[]>, GArrRefTArrRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test410", UnboxUToT<IPlusT<IPlusT<GBase<int>[]>[]>, GArrRefTArrRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test411", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>[]>, GArrRefTArrRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test412", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[]>[],IPlusT<GSubT<int>[]>[]>, GArrRefTArrRefU<GSubT<int>[],GBase<int>[]>>(false)); if( iErrorCount > 0 ) { Console.WriteLine( "Total test cases: " + iTestCount + " Failed test cases: " + iErrorCount ); return false; } else { Console.WriteLine( "Total test cases: " + iTestCount ); return true; } } public static int Main(String [] args) { if( RunTests() ) { iExitCode = 100; Console.WriteLine( "All test cases passed" ); } else { iExitCode = 101; Console.WriteLine( "Test failed" ); } return iExitCode; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; public class Base {} public class Sub : Base {} public class GBase<T> {} public class GSubT<T> : GBase<T> {} public struct GTU<T,U> : IPlusT<T>, IMinusT<U>, IMinusTPlusU<T,U> {} public struct GTArrUArr<T,U> : IMinusT<T[]>, IPlusT<U[]>, IMinusTPlusU<T[],U[]> {} public struct GRefTRefU<T,U> : IMinusT<IPlusT<T>>, IMinusT<IMinusT<U>>, IMinusTPlusU<IPlusT<T>, IPlusT<U>> {} public struct GRefTArrRefUArr<T,U> : IMinusT<IPlusT<T[]>>, IMinusT<IMinusT<U[]>>, IMinusTPlusU<IPlusT<T[]>,IPlusT<U[]>> {} public struct GArrRefTArrRefU<T,U> : IMinusT<IPlusT<T>[]>, IMinusT<IMinusT<U>[]>, IMinusTPlusU<IPlusT<T>[],IPlusT<U>[]> {} public class TestClass { static int iTestCount= 0; static int iErrorCount= 0; static int iExitCode = 101; public static void Eval(string location, bool exp) { ++iTestCount; if ( !(exp)) { iErrorCount++; Console.WriteLine("Test Failed at location: {0} @ count {1} ", location, iTestCount); } } private static void UnboxUToTInternal<T,U>() { T t = (T) Activator.CreateInstance(typeof(U)); } private static void CaseClassUToTWrapper<T,U>() { UnboxUToTInternal<T,U>(); } public static bool UnboxUToT<T,U>(bool expected) { try { CaseClassUToTWrapper<T,U>(); if (expected) { return true; } else { return false; } } catch (InvalidCastException) { if (expected) { Console.WriteLine("Unexpected Exception InvalidCastException"); return false; } else { return true; } } catch(Exception E) { Console.WriteLine("Unexpected Exception {0}, with T = {1} and U = {2}", E, typeof(T), typeof(U)); return false; } } private static bool RunTests() { Eval("Test001", UnboxUToT<IPlusT<IMinusT<Base>>, GTU<IMinusT<Sub>,Base>>(false)); Eval("Test002", UnboxUToT<IMinusT<IMinusT<Sub>>, GTU<Sub,IMinusT<Base>>>(false)); Eval("Test003", UnboxUToT<IPlusTMinusU<Base,Sub>, GTU<Sub,Base>>(false)); Eval("Test004", UnboxUToT<IPlusT<IMinusT<Base[]>>, GTU<IMinusT<Sub[]>,Base>>(false)); Eval("Test005", UnboxUToT<IMinusT<IMinusT<Sub[]>>, GTU<Sub,IMinusT<Base[]>>>(false)); Eval("Test006", UnboxUToT<IPlusTMinusU<Base[],Sub[]>, GTU<Sub[],Base[]>>(false)); Eval("Test007", UnboxUToT<IPlusT<IMinusT<GBase<int>>>, GTU<IMinusT<GSubT<int>>,GBase<int>>>(false)); Eval("Test008", UnboxUToT<IMinusT<IMinusT<GSubT<int>>>, GTU<GSubT<int>,IMinusT<GBase<int>>>>(false)); Eval("Test009", UnboxUToT<IPlusTMinusU<GBase<int>,GSubT<int>>, GTU<GSubT<int>,GBase<int>>>(false)); Eval("Test010", UnboxUToT<IPlusT<IMinusT<GBase<int>[]>>, GTU<IMinusT<GSubT<int>[]>,GBase<int>[]>>(false)); Eval("Test011", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GTU<GSubT<int>[],IMinusT<GBase<int>[]>>>(false)); Eval("Test012", UnboxUToT<IPlusTMinusU<GBase<int>[],GSubT<int>[]>, GTU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test101", UnboxUToT<IPlusT<IMinusT<Base>[]>, GTArrUArr<IMinusT<Sub>,Base>>(false)); Eval("Test102", UnboxUToT<IMinusT<IMinusT<Sub>[]>, GTArrUArr<Sub,IMinusT<Base>>>(false)); Eval("Test103", UnboxUToT<IPlusTMinusU<Base[],Sub[]>, GTArrUArr<Sub,Base>>(false)); Eval("Test104", UnboxUToT<IPlusT<IMinusT<Base[]>[]>, GTArrUArr<IMinusT<Sub[]>,Base>>(false)); Eval("Test105", UnboxUToT<IMinusT<IMinusT<Sub[]>[]>, GTArrUArr<Sub,IMinusT<Base[]>>>(false)); Eval("Test106", UnboxUToT<IPlusTMinusU<Base[][],Sub[][]>, GTArrUArr<Sub[],Base[]>>(false)); Eval("Test107", UnboxUToT<IPlusT<IMinusT<GBase<int>>[]>, GTArrUArr<IMinusT<GSubT<int>>,GBase<int>>>(false)); Eval("Test108", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GTArrUArr<GSubT<int>,IMinusT<GBase<int>>>>(false)); Eval("Test109", UnboxUToT<IPlusTMinusU<GBase<int>,GSubT<int>>, GTArrUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test110", UnboxUToT<IPlusT<IMinusT<GBase<int>[]>>[], GTArrUArr<IMinusT<GSubT<int>[]>,GBase<int>[]>>(false)); Eval("Test111", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>[]>, GTArrUArr<GSubT<int>[],IMinusT<GBase<int>[]>>>(false)); Eval("Test112", UnboxUToT<IPlusTMinusU<GBase<int>[][],GSubT<int>[][]>, GTArrUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test201", UnboxUToT<IPlusT<IPlusT<Base>>, GRefTRefU<Sub,Base>>(false)); Eval("Test202", UnboxUToT<IMinusT<IMinusT<Sub>>, GRefTRefU<Sub,Base>>(false)); Eval("Test203", UnboxUToT<IPlusTMinusU<IPlusT<Base>,IPlusT<Sub>>, GRefTRefU<Sub,Base>>(false)); Eval("Test204", UnboxUToT<IPlusT<IPlusT<Base[]>>, GRefTRefU<Sub[],Base[]>>(false)); Eval("Test205", UnboxUToT<IMinusT<IMinusT<Sub[]>>, GRefTRefU<Sub[],Base[]>>(false)); Eval("Test206", UnboxUToT<IPlusTMinusU<IPlusT<Base[]>,IPlusT<Sub[]>>, GRefTRefU<Sub[],Base[]>>(false)); Eval("Test207", UnboxUToT<IPlusT<IPlusT<GBase<int>>>, GRefTRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test208", UnboxUToT<IMinusT<IMinusT<GSubT<int>>>, GRefTRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test209", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>>,IPlusT<GSubT<int>>>, GRefTRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test210", UnboxUToT<IPlusT<IPlusT<GBase<int>[]>>, GRefTRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test211", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GRefTRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test212", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[]>,IPlusT<GSubT<int>[]>>, GRefTRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test301", UnboxUToT<IPlusT<IPlusT<Base[]>>, GRefTArrRefUArr<Sub,Base>>(false)); Eval("Test302", UnboxUToT<IMinusT<IMinusT<Sub[]>>, GRefTArrRefUArr<Sub,Base>>(false)); Eval("Test303", UnboxUToT<IPlusTMinusU<IPlusT<Base[]>,IPlusT<Sub[]>>, GRefTArrRefUArr<Sub,Base>>(false)); Eval("Test304", UnboxUToT<IPlusT<IPlusT<Base[][]>>, GRefTArrRefUArr<Sub[],Base[]>>(false)); Eval("Test305", UnboxUToT<IMinusT<IMinusT<Sub[][]>>, GRefTArrRefUArr<Sub[],Base[]>>(false)); Eval("Test306", UnboxUToT<IPlusTMinusU<IPlusT<Base[][]>,IPlusT<Sub[][]>>, GRefTArrRefUArr<Sub[],Base[]>>(false)); Eval("Test307", UnboxUToT<IPlusT<IPlusT<GBase<int>[]>>, GRefTArrRefUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test308", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>>, GRefTArrRefUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test309", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[]>,IPlusT<GSubT<int>[]>>, GRefTArrRefUArr<GSubT<int>,GBase<int>>>(false)); Eval("Test310", UnboxUToT<IPlusT<IPlusT<GBase<int>[][]>>, GRefTArrRefUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test311", UnboxUToT<IMinusT<IMinusT<GSubT<int>[][]>>, GRefTArrRefUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test312", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[][]>,IPlusT<GSubT<int>[][]>>, GRefTArrRefUArr<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test401", UnboxUToT<IPlusT<IPlusT<Base>[]>, GArrRefTArrRefU<Sub,Base>>(false)); Eval("Test402", UnboxUToT<IMinusT<IMinusT<Sub>[]>, GArrRefTArrRefU<Sub,Base>>(false)); Eval("Test403", UnboxUToT<IPlusTMinusU<IPlusT<Base>[],IPlusT<Sub>[]>, GArrRefTArrRefU<Sub,Base>>(false)); Eval("Test404", UnboxUToT<IPlusT<IPlusT<Base[,]>[]>, GArrRefTArrRefU<Sub[,],Base[,]>>(false)); Eval("Test405", UnboxUToT<IMinusT<IMinusT<Sub[,]>[]>, GArrRefTArrRefU<Sub[,],Base[,]>>(false)); Eval("Test406", UnboxUToT<IPlusTMinusU<IPlusT<Base[,]>[],IPlusT<Sub[,]>[]>, GArrRefTArrRefU<Sub[,],Base[,]>>(false)); Eval("Test407", UnboxUToT<IPlusT<IPlusT<GBase<int>>[]>, GArrRefTArrRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test408", UnboxUToT<IMinusT<IMinusT<GSubT<int>>[]>, GArrRefTArrRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test409", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>>[],IPlusT<GSubT<int>>[]>, GArrRefTArrRefU<GSubT<int>,GBase<int>>>(false)); Eval("Test410", UnboxUToT<IPlusT<IPlusT<GBase<int>[]>[]>, GArrRefTArrRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test411", UnboxUToT<IMinusT<IMinusT<GSubT<int>[]>[]>, GArrRefTArrRefU<GSubT<int>[],GBase<int>[]>>(false)); Eval("Test412", UnboxUToT<IPlusTMinusU<IPlusT<GBase<int>[]>[],IPlusT<GSubT<int>[]>[]>, GArrRefTArrRefU<GSubT<int>[],GBase<int>[]>>(false)); if( iErrorCount > 0 ) { Console.WriteLine( "Total test cases: " + iTestCount + " Failed test cases: " + iErrorCount ); return false; } else { Console.WriteLine( "Total test cases: " + iTestCount ); return true; } } public static int Main(String [] args) { if( RunTests() ) { iExitCode = 100; Console.WriteLine( "All test cases passed" ); } else { iExitCode = 101; Console.WriteLine( "Test failed" ); } return iExitCode; } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/Loader/classloader/generics/Variance/IL/IsInst001.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="IsInst001.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="Lib.ilproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="IsInst001.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="Lib.ilproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Reflection.Metadata/tests/Metadata/Ecma335/Encoding/LabelHandleTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Reflection.Metadata.Ecma335.Tests { public class LabelHandleTests { [Fact] public void Equality() { var a1 = new LabelHandle(1); var a2 = new LabelHandle(2); var b1 = new LabelHandle(1); Assert.False(((object)a1).Equals(a2)); Assert.False(a1.Equals(new object())); Assert.False(a1.Equals(a2)); Assert.False(a1 == a2); Assert.True(((object)a1).Equals(b1)); Assert.True(a1.Equals(b1)); Assert.True(a1 == b1); Assert.Equal(a1.GetHashCode(), b1.GetHashCode()); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Reflection.Metadata.Ecma335.Tests { public class LabelHandleTests { [Fact] public void Equality() { var a1 = new LabelHandle(1); var a2 = new LabelHandle(2); var b1 = new LabelHandle(1); Assert.False(((object)a1).Equals(a2)); Assert.False(a1.Equals(new object())); Assert.False(a1.Equals(a2)); Assert.False(a1 == a2); Assert.True(((object)a1).Equals(b1)); Assert.True(a1.Equals(b1)); Assert.True(a1 == b1); Assert.Equal(a1.GetHashCode(), b1.GetHashCode()); } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pt-BR.xlf
<?xml version="1.0" encoding="utf-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd"> <file datatype="xml" source-language="en" target-language="pt-BR" original="../Strings.resx"> <body> <trans-unit id="ContextClassesMustBePartialMessageFormat"> <source>Derived 'JsonSerializerContext' type '{0}' specifies JSON-serializable types. The type and all containing types must be made partial to kick off source generation.</source> <target state="translated">O tipo 'JsonSerializerContext' derivado '{0}' especifica tipos serializáveis por JSON. O tipo e todos os tipos de contenção devem ser feitos parcialmente para iniciar a geração de origem.</target> <note /> </trans-unit> <trans-unit id="ContextClassesMustBePartialTitle"> <source>Derived 'JsonSerializerContext' types and all containing types must be partial.</source> <target state="translated">Os tipos derivados de 'JsonSerializerContext' e todos os tipos contidos devem ser parciais.</target> <note /> </trans-unit> <trans-unit id="DataExtensionPropertyInvalidFormat"> <source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source> <target state="translated">A propriedade da extensão de dados '{0}.{1}' é inválida. Deve implementar 'IDictionary&lt;string, JsonElement&gt;' ou 'IDictionary&lt;string, object&gt;', ou ter 'JsonObject'.</target> <note /> </trans-unit> <trans-unit id="DataExtensionPropertyInvalidTitle"> <source>Data extension property type invalid.</source> <target state="translated">Tipo de propriedade de extensão de dados inválido.</target> <note /> </trans-unit> <trans-unit id="DuplicateTypeNameMessageFormat"> <source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source> <target state="translated">Existem vários tipos chamados {0}. A fonte foi gerada para o primeiro detectado. Use 'JsonSerializableAttribute.TypeInfoPropertyName' para resolver esta colisão.</target> <note /> </trans-unit> <trans-unit id="DuplicateTypeNameTitle"> <source>Duplicate type name.</source> <target state="translated">Nome de tipo duplicado.</target> <note /> </trans-unit> <trans-unit id="InaccessibleJsonIncludePropertiesNotSupportedFormat"> <source>The member '{0}.{1}' has been annotated with the JsonIncludeAttribute but is not visible to the source generator.</source> <target state="translated">O membro '{0}.{1}' foi anotado com o JsonIncludeAttribute, mas não é visível para o gerador de origem.</target> <note /> </trans-unit> <trans-unit id="InaccessibleJsonIncludePropertiesNotSupportedTitle"> <source>Inaccessible properties annotated with the JsonIncludeAttribute are not supported in source generation mode.</source> <target state="translated">Propriedades inacessíveis anotadas com JsonIncludeAttribute não são suportadas no modo de geração de origem.</target> <note /> </trans-unit> <trans-unit id="InitOnlyPropertyDeserializationNotSupportedFormat"> <source>The type '{0}' defines init-only properties, deserialization of which is currently not supported in source generation mode.</source> <target state="translated">O tipo '{0}' define propriedades apenas de inicialização, a desserialização das quais atualmente não é suportada no modo de geração de origem.</target> <note /> </trans-unit> <trans-unit id="InitOnlyPropertyDeserializationNotSupportedTitle"> <source>Deserialization of init-only properties is currently not supported in source generation mode.</source> <target state="translated">A desserialização de propriedades apenas de inicialização não é atualmente suportada no modo de geração de origem.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonConstructorAttributeFormat"> <source>Type '{0}' has multiple constructors annotated with 'JsonConstructorAttribute'.</source> <target state="translated">O tipo '{0}' tem vários construtores anotados com 'JsonConstructorAttribute'.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonConstructorAttributeTitle"> <source>Type has multiple constructors annotated with JsonConstructorAttribute.</source> <target state="translated">O tipo tem vários construtores anotados com JsonConstructorAttribute.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonExtensionDataAttributeFormat"> <source>Type '{0}' has multiple members annotated with 'JsonExtensionDataAttribute'.</source> <target state="translated">Tipo '{0}' tem vários membros anotados com 'JsonExtensionDataAttribute'.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonExtensionDataAttributeTitle"> <source>Type has multiple members annotated with JsonExtensionDataAttribute.</source> <target state="translated">Tipo tem vários membros anotados com JsonExtensionDataAttribute.</target> <note /> </trans-unit> <trans-unit id="TypeNotSupportedMessageFormat"> <source>Did not generate serialization metadata for type '{0}'.</source> <target state="translated">Não gerou metadados de serialização para o tipo '{0}'.</target> <note /> </trans-unit> <trans-unit id="TypeNotSupportedTitle"> <source>Did not generate serialization metadata for type.</source> <target state="translated">Não gerou metadados de serialização para o tipo.</target> <note /> </trans-unit> </body> </file> </xliff>
<?xml version="1.0" encoding="utf-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd"> <file datatype="xml" source-language="en" target-language="pt-BR" original="../Strings.resx"> <body> <trans-unit id="ContextClassesMustBePartialMessageFormat"> <source>Derived 'JsonSerializerContext' type '{0}' specifies JSON-serializable types. The type and all containing types must be made partial to kick off source generation.</source> <target state="translated">O tipo 'JsonSerializerContext' derivado '{0}' especifica tipos serializáveis por JSON. O tipo e todos os tipos de contenção devem ser feitos parcialmente para iniciar a geração de origem.</target> <note /> </trans-unit> <trans-unit id="ContextClassesMustBePartialTitle"> <source>Derived 'JsonSerializerContext' types and all containing types must be partial.</source> <target state="translated">Os tipos derivados de 'JsonSerializerContext' e todos os tipos contidos devem ser parciais.</target> <note /> </trans-unit> <trans-unit id="DataExtensionPropertyInvalidFormat"> <source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary&lt;string, JsonElement&gt;' or 'IDictionary&lt;string, object&gt;', or be 'JsonObject'.</source> <target state="translated">A propriedade da extensão de dados '{0}.{1}' é inválida. Deve implementar 'IDictionary&lt;string, JsonElement&gt;' ou 'IDictionary&lt;string, object&gt;', ou ter 'JsonObject'.</target> <note /> </trans-unit> <trans-unit id="DataExtensionPropertyInvalidTitle"> <source>Data extension property type invalid.</source> <target state="translated">Tipo de propriedade de extensão de dados inválido.</target> <note /> </trans-unit> <trans-unit id="DuplicateTypeNameMessageFormat"> <source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source> <target state="translated">Existem vários tipos chamados {0}. A fonte foi gerada para o primeiro detectado. Use 'JsonSerializableAttribute.TypeInfoPropertyName' para resolver esta colisão.</target> <note /> </trans-unit> <trans-unit id="DuplicateTypeNameTitle"> <source>Duplicate type name.</source> <target state="translated">Nome de tipo duplicado.</target> <note /> </trans-unit> <trans-unit id="InaccessibleJsonIncludePropertiesNotSupportedFormat"> <source>The member '{0}.{1}' has been annotated with the JsonIncludeAttribute but is not visible to the source generator.</source> <target state="translated">O membro '{0}.{1}' foi anotado com o JsonIncludeAttribute, mas não é visível para o gerador de origem.</target> <note /> </trans-unit> <trans-unit id="InaccessibleJsonIncludePropertiesNotSupportedTitle"> <source>Inaccessible properties annotated with the JsonIncludeAttribute are not supported in source generation mode.</source> <target state="translated">Propriedades inacessíveis anotadas com JsonIncludeAttribute não são suportadas no modo de geração de origem.</target> <note /> </trans-unit> <trans-unit id="InitOnlyPropertyDeserializationNotSupportedFormat"> <source>The type '{0}' defines init-only properties, deserialization of which is currently not supported in source generation mode.</source> <target state="translated">O tipo '{0}' define propriedades apenas de inicialização, a desserialização das quais atualmente não é suportada no modo de geração de origem.</target> <note /> </trans-unit> <trans-unit id="InitOnlyPropertyDeserializationNotSupportedTitle"> <source>Deserialization of init-only properties is currently not supported in source generation mode.</source> <target state="translated">A desserialização de propriedades apenas de inicialização não é atualmente suportada no modo de geração de origem.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonConstructorAttributeFormat"> <source>Type '{0}' has multiple constructors annotated with 'JsonConstructorAttribute'.</source> <target state="translated">O tipo '{0}' tem vários construtores anotados com 'JsonConstructorAttribute'.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonConstructorAttributeTitle"> <source>Type has multiple constructors annotated with JsonConstructorAttribute.</source> <target state="translated">O tipo tem vários construtores anotados com JsonConstructorAttribute.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonExtensionDataAttributeFormat"> <source>Type '{0}' has multiple members annotated with 'JsonExtensionDataAttribute'.</source> <target state="translated">Tipo '{0}' tem vários membros anotados com 'JsonExtensionDataAttribute'.</target> <note /> </trans-unit> <trans-unit id="MultipleJsonExtensionDataAttributeTitle"> <source>Type has multiple members annotated with JsonExtensionDataAttribute.</source> <target state="translated">Tipo tem vários membros anotados com JsonExtensionDataAttribute.</target> <note /> </trans-unit> <trans-unit id="TypeNotSupportedMessageFormat"> <source>Did not generate serialization metadata for type '{0}'.</source> <target state="translated">Não gerou metadados de serialização para o tipo '{0}'.</target> <note /> </trans-unit> <trans-unit id="TypeNotSupportedTitle"> <source>Did not generate serialization metadata for type.</source> <target state="translated">Não gerou metadados de serialização para o tipo.</target> <note /> </trans-unit> </body> </file> </xliff>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Test.Assembly/System.Runtime.Loader.Test.Assembly.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0</TargetFrameworks> </PropertyGroup> <ItemGroup> <Compile Include="TestClass.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0</TargetFrameworks> </PropertyGroup> <ItemGroup> <Compile Include="TestClass.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/ilverify/ILVerificationTests.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputPath>$(BaseOutputPathWithConfig)ilverify\</OutputPath> <CLRTestPriority>1</CLRTestPriority> <!-- The test uses xunit directly and it fails to find the test assembly for some reason --> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Compile Include="ILMethodTester.cs" /> <Compile Include="ILTypeVerificationTester.cs" /> <Compile Include="TestDataLoader.cs" /> </ItemGroup> <Import Project="..\..\coreclr\tools\ILVerification\ILVerification.projitems" /> <ItemGroup> <PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="ILTests\*.ilproj"> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <OutputItemType>Content</OutputItemType> </ProjectReference> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputPath>$(BaseOutputPathWithConfig)ilverify\</OutputPath> <CLRTestPriority>1</CLRTestPriority> <!-- The test uses xunit directly and it fails to find the test assembly for some reason --> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Compile Include="ILMethodTester.cs" /> <Compile Include="ILTypeVerificationTester.cs" /> <Compile Include="TestDataLoader.cs" /> </ItemGroup> <Import Project="..\..\coreclr\tools\ILVerification\ILVerification.projitems" /> <ItemGroup> <PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="ILTests\*.ilproj"> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <OutputItemType>Content</OutputItemType> </ProjectReference> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Private.Xml/tests/Xslt/TestFiles/TestData/xsltc/baseline/dft12.xsl
<xsl:stylesheet version= '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > <xsl:template match="/"> <xsl:for-each select="//foo"> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
<xsl:stylesheet version= '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > <xsl:template match="/"> <xsl:for-each select="//foo"> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApiV2/xsltarg_multithreading1.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myObj="urn:my-obj1"> <xsl:template match="/"> <result>Function1:<xsl:value-of select="myObj:Fn1()"/></result> </xsl:template> </xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myObj="urn:my-obj1"> <xsl:template match="/"> <result>Function1:<xsl:value-of select="myObj:Fn1()"/></result> </xsl:template> </xsl:stylesheet>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedCallersOnlyAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Runtime.InteropServices { /// <summary> /// Any method marked with <see cref="System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute" /> can be directly called from /// native code. The function token can be loaded to a local variable using the <see href="https://docs.microsoft.com/dotnet/csharp/language-reference/operators/pointer-related-operators#address-of-operator-">address-of</see> operator /// in C# and passed as a callback to a native method. /// </summary> /// <remarks> /// Methods marked with this attribute have the following restrictions: /// * Method must be marked "static". /// * Must not be called from managed code. /// * Must only have <see href="https://docs.microsoft.com/dotnet/framework/interop/blittable-and-non-blittable-types">blittable</see> arguments. /// </remarks> [AttributeUsage(AttributeTargets.Method, Inherited = false)] public sealed class UnmanagedCallersOnlyAttribute : Attribute { public UnmanagedCallersOnlyAttribute() { } /// <summary> /// Optional. If omitted, the runtime will use the default platform calling convention. /// </summary> /// <remarks> /// Supplied types must be from the official "System.Runtime.CompilerServices" namespace and /// be of the form "CallConvXXX". /// </remarks> public Type[]? CallConvs; /// <summary> /// Optional. If omitted, no named export is emitted during compilation. /// </summary> public string? EntryPoint; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Runtime.InteropServices { /// <summary> /// Any method marked with <see cref="System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute" /> can be directly called from /// native code. The function token can be loaded to a local variable using the <see href="https://docs.microsoft.com/dotnet/csharp/language-reference/operators/pointer-related-operators#address-of-operator-">address-of</see> operator /// in C# and passed as a callback to a native method. /// </summary> /// <remarks> /// Methods marked with this attribute have the following restrictions: /// * Method must be marked "static". /// * Must not be called from managed code. /// * Must only have <see href="https://docs.microsoft.com/dotnet/framework/interop/blittable-and-non-blittable-types">blittable</see> arguments. /// </remarks> [AttributeUsage(AttributeTargets.Method, Inherited = false)] public sealed class UnmanagedCallersOnlyAttribute : Attribute { public UnmanagedCallersOnlyAttribute() { } /// <summary> /// Optional. If omitted, the runtime will use the default platform calling convention. /// </summary> /// <remarks> /// Supplied types must be from the official "System.Runtime.CompilerServices" namespace and /// be of the form "CallConvXXX". /// </remarks> public Type[]? CallConvs; /// <summary> /// Optional. If omitted, no named export is emitted during compilation. /// </summary> public string? EntryPoint; } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/ControlFlowInstructions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic.Utils; using System.Reflection; using System.Runtime.CompilerServices; namespace System.Linq.Expressions.Interpreter { internal abstract class OffsetInstruction : Instruction { internal const int Unknown = int.MinValue; internal const int CacheSize = 32; // the offset to jump to (relative to this instruction): protected int _offset = Unknown; public abstract Instruction[] Cache { get; } public Instruction Fixup(int offset) { Debug.Assert(_offset == Unknown && offset != Unknown); _offset = offset; Instruction[] cache = Cache; if (cache != null && offset >= 0 && offset < cache.Length) { return cache[offset] ?? (cache[offset] = this); } return this; } public override string ToDebugString(int instructionIndex, object? cookie, Func<int, int> labelIndexer, IReadOnlyList<object>? objects) { return ToString() + (_offset != Unknown ? " -> " + (instructionIndex + _offset) : ""); } public override string ToString() { return InstructionName + (_offset == Unknown ? "(?)" : "(" + _offset + ")"); } } internal sealed class BranchFalseInstruction : OffsetInstruction { private static Instruction[]? s_cache; public override Instruction[] Cache { get { if (s_cache == null) { s_cache = new Instruction[CacheSize]; } return s_cache; } } public override string InstructionName => "BranchFalse"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); if (!(bool)frame.Pop()!) { return _offset; } return 1; } } internal sealed class BranchTrueInstruction : OffsetInstruction { private static Instruction[]? s_cache; public override Instruction[] Cache { get { if (s_cache == null) { s_cache = new Instruction[CacheSize]; } return s_cache; } } public override string InstructionName => "BranchTrue"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); if ((bool)frame.Pop()!) { return _offset; } return 1; } } internal sealed class CoalescingBranchInstruction : OffsetInstruction { private static Instruction[]? s_cache; public override Instruction[] Cache { get { if (s_cache == null) { s_cache = new Instruction[CacheSize]; } return s_cache; } } public override string InstructionName => "CoalescingBranch"; public override int ConsumedStack => 1; public override int ProducedStack => 1; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); if (frame.Peek() != null) { return _offset; } return 1; } } internal sealed class BranchInstruction : OffsetInstruction { private static Instruction[][][]? s_caches; public override Instruction[] Cache { get { if (s_caches == null) { s_caches = new Instruction[2][][] { new Instruction[2][], new Instruction[2][] }; } return s_caches[ConsumedStack][ProducedStack] ?? (s_caches[ConsumedStack][ProducedStack] = new Instruction[CacheSize]); } } internal readonly bool _hasResult; internal readonly bool _hasValue; internal BranchInstruction() : this(false, false) { } public BranchInstruction(bool hasResult, bool hasValue) { _hasResult = hasResult; _hasValue = hasValue; } public override string InstructionName => "Branch"; public override int ConsumedStack => _hasValue ? 1 : 0; public override int ProducedStack => _hasResult ? 1 : 0; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); return _offset; } } internal abstract class IndexedBranchInstruction : Instruction { protected const int CacheSize = 32; internal readonly int _labelIndex; public IndexedBranchInstruction(int labelIndex) { _labelIndex = labelIndex; } public RuntimeLabel GetLabel(InterpretedFrame frame) { Debug.Assert(_labelIndex != UnknownInstrIndex); return frame.Interpreter._labels[_labelIndex]; } public override string ToDebugString(int instructionIndex, object? cookie, Func<int, int> labelIndexer, IReadOnlyList<object>? objects) { Debug.Assert(_labelIndex != UnknownInstrIndex); int targetIndex = labelIndexer(_labelIndex); return ToString() + (targetIndex != BranchLabel.UnknownIndex ? " -> " + targetIndex : ""); } public override string ToString() { Debug.Assert(_labelIndex != UnknownInstrIndex); return InstructionName + "[" + _labelIndex + "]"; } } /// <summary> /// This instruction implements a goto expression that can jump out of any expression. /// It pops values (arguments) from the evaluation stack that the expression tree nodes in between /// the goto expression and the target label node pushed and not consumed yet. /// A goto expression can jump into a node that evaluates arguments only if it carries /// a value and jumps right after the first argument (the carried value will be used as the first argument). /// Goto can jump into an arbitrary child of a BlockExpression since the block doesn't accumulate values /// on evaluation stack as its child expressions are being evaluated. /// /// Goto needs to execute any finally blocks on the way to the target label. /// <example> /// { /// f(1, 2, try { g(3, 4, try { goto L } finally { ... }, 6) } finally { ... }, 7, 8) /// L: ... /// } /// </example> /// The goto expression here jumps to label L while having 4 items on evaluation stack (1, 2, 3 and 4). /// The jump needs to execute both finally blocks, the first one on stack level 4 the /// second one on stack level 2. So, it needs to jump the first finally block, pop 2 items from the stack, /// run second finally block and pop another 2 items from the stack and set instruction pointer to label L. /// /// Goto also needs to rethrow ThreadAbortException iff it jumps out of a catch handler and /// the current thread is in "abort requested" state. /// </summary> internal sealed class GotoInstruction : IndexedBranchInstruction { private const int Variants = 8; private static readonly GotoInstruction[] s_cache = new GotoInstruction[Variants * CacheSize]; public override string InstructionName => "Goto"; private readonly bool _hasResult; private readonly bool _hasValue; private readonly bool _labelTargetGetsValue; // Should technically return 1 for ConsumedContinuations and ProducedContinuations for gotos that target a label whose continuation depth // is different from the current continuation depth. This is because we will consume one continuation from the _continuations // and at meantime produce a new _pendingContinuation. However, in case of forward gotos, we don't not know that is the // case until the label is emitted. By then the consumed and produced stack information is useless. // The important thing here is that the stack balance is 0. public override int ConsumedStack => _hasValue ? 1 : 0; public override int ProducedStack => _hasResult ? 1 : 0; private GotoInstruction(int targetIndex, bool hasResult, bool hasValue, bool labelTargetGetsValue) : base(targetIndex) { _hasResult = hasResult; _hasValue = hasValue; _labelTargetGetsValue = labelTargetGetsValue; } internal static GotoInstruction Create(int labelIndex, bool hasResult, bool hasValue, bool labelTargetGetsValue) { if (labelIndex < CacheSize) { int index = Variants * labelIndex | (labelTargetGetsValue ? 4 : 0) | (hasResult ? 2 : 0) | (hasValue ? 1 : 0); return s_cache[index] ?? (s_cache[index] = new GotoInstruction(labelIndex, hasResult, hasValue, labelTargetGetsValue)); } return new GotoInstruction(labelIndex, hasResult, hasValue, labelTargetGetsValue); } public override int Run(InterpretedFrame frame) { // Are we jumping out of catch/finally while aborting the current thread? #if FEATURE_THREAD_ABORT Interpreter.AbortThreadIfRequested(frame, _labelIndex); #endif // goto the target label or the current finally continuation: object? value = _hasValue ? frame.Pop() : Interpreter.NoValue; return frame.Goto(_labelIndex, _labelTargetGetsValue ? value : Interpreter.NoValue, gotoExceptionHandler: false); } } internal sealed class EnterTryCatchFinallyInstruction : IndexedBranchInstruction { private readonly bool _hasFinally; private TryCatchFinallyHandler? _tryHandler; internal void SetTryHandler(TryCatchFinallyHandler tryHandler) { Debug.Assert(_tryHandler == null && tryHandler != null, "the tryHandler can be set only once"); _tryHandler = tryHandler; } internal TryCatchFinallyHandler? Handler => _tryHandler; public override int ProducedContinuations => _hasFinally ? 1 : 0; private EnterTryCatchFinallyInstruction(int targetIndex, bool hasFinally) : base(targetIndex) { _hasFinally = hasFinally; } internal static EnterTryCatchFinallyInstruction CreateTryFinally(int labelIndex) { return new EnterTryCatchFinallyInstruction(labelIndex, true); } internal static EnterTryCatchFinallyInstruction CreateTryCatch() { return new EnterTryCatchFinallyInstruction(UnknownInstrIndex, false); } public override int Run(InterpretedFrame frame) { Debug.Assert(_tryHandler != null, "the tryHandler must be set already"); if (_hasFinally) { // Push finally. frame.PushContinuation(_labelIndex); } int prevInstrIndex = frame.InstructionIndex; frame.InstructionIndex++; // Start to run the try/catch/finally blocks Instruction[] instructions = frame.Interpreter.Instructions.Instructions; try { // run the try block int index = frame.InstructionIndex; while (index >= _tryHandler.TryStartIndex && index < _tryHandler.TryEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } // we finish the try block and is about to jump out of the try/catch blocks if (index == _tryHandler.GotoEndTargetIndex) { // run the 'Goto' that jumps out of the try/catch/finally blocks Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/catch/finally"); frame.InstructionIndex += instructions[index].Run(frame); } } catch (Exception exception) when (_tryHandler.HasHandler(frame, exception, out ExceptionHandler? exHandler, out object? unwrappedException)) { Debug.Assert(!(unwrappedException is RethrowException)); frame.InstructionIndex += frame.Goto(exHandler.LabelIndex, unwrappedException, gotoExceptionHandler: true); #if FEATURE_THREAD_ABORT // stay in the current catch so that ThreadAbortException is not rethrown by CLR: var abort = exception as ThreadAbortException; if (abort != null) { Interpreter.AnyAbortException = abort; frame.CurrentAbortHandler = exHandler; } #endif bool rethrow = false; try { // run the catch block int index = frame.InstructionIndex; while (index >= exHandler.HandlerStartIndex && index < exHandler.HandlerEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } // we finish the catch block and is about to jump out of the try/catch blocks if (index == _tryHandler.GotoEndTargetIndex) { // run the 'Goto' that jumps out of the try/catch/finally blocks Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/catch/finally"); frame.InstructionIndex += instructions[index].Run(frame); } } catch (RethrowException) { // a rethrow instruction in a catch block gets to run rethrow = true; } if (rethrow) { throw; } } finally { if (_tryHandler.IsFinallyBlockExist) { // We get to the finally block in two paths: // 1. Jump from the try/catch blocks. This includes two sub-routes: // a. 'Goto' instruction in the middle of try/catch block // b. try/catch block runs to its end. Then the 'Goto(end)' will be trigger to jump out of the try/catch block // 2. Exception thrown from the try/catch blocks // In the first path, the continuation mechanism works and frame.InstructionIndex will be updated to point to the first instruction of the finally block // In the second path, the continuation mechanism is not involved and frame.InstructionIndex is not updated #if DEBUG bool isFromJump = frame.IsJumpHappened(); Debug.Assert(!isFromJump || (isFromJump && _tryHandler.FinallyStartIndex == frame.InstructionIndex), "we should already jump to the first instruction of the finally"); #endif // run the finally block // we cannot jump out of the finally block, and we cannot have an immediate rethrow in it int index = frame.InstructionIndex = _tryHandler.FinallyStartIndex; while (index >= _tryHandler.FinallyStartIndex && index < _tryHandler.FinallyEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } } } return frame.InstructionIndex - prevInstrIndex; } public override string InstructionName => _hasFinally ? "EnterTryFinally" : "EnterTryCatch"; public override string ToString() => _hasFinally ? "EnterTryFinally[" + _labelIndex + "]" : "EnterTryCatch"; } internal sealed class EnterTryFaultInstruction : IndexedBranchInstruction { private TryFaultHandler? _tryHandler; internal EnterTryFaultInstruction(int targetIndex) : base(targetIndex) { } public override string InstructionName => "EnterTryFault"; public override int ProducedContinuations => 1; internal TryFaultHandler? Handler => _tryHandler; internal void SetTryHandler(TryFaultHandler tryHandler) { Debug.Assert(tryHandler != null); Debug.Assert(_tryHandler == null, "the tryHandler can be set only once"); _tryHandler = tryHandler; } public override int Run(InterpretedFrame frame) { Debug.Assert(_tryHandler != null, "the tryHandler must be set already"); // Push fault. frame.PushContinuation(_labelIndex); int prevInstrIndex = frame.InstructionIndex; frame.InstructionIndex++; // Start to run the try/fault blocks Instruction[] instructions = frame.Interpreter.Instructions.Instructions; // C# 6 has no direct support for fault blocks, but they can be faked or coerced out of the compiler // in several ways. Catch-and-rethrow can work in specific cases, but not generally as the double-pass // will not work correctly with filters higher up the call stack. Iterators can be used to produce real // fault blocks, but it depends on an implementation detail rather than a guarantee, and is rather // indirect. This leaves using a finally block and not doing anything in it if the body ran to // completion, which is the approach used here. bool ranWithoutFault = false; try { // run the try block int index = frame.InstructionIndex; while (index >= _tryHandler.TryStartIndex && index < _tryHandler.TryEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } // run the 'Goto' that jumps out of the try/fault blocks Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/fault"); // if we've arrived here there was no exception thrown. As the fault block won't run, we need to // pop the continuation for it here, before Gotoing the end of the try/fault. ranWithoutFault = true; frame.RemoveContinuation(); frame.InstructionIndex += instructions[index].Run(frame); } finally { if (!ranWithoutFault) { // run the fault block // we cannot jump out of the finally block, and we cannot have an immediate rethrow in it int index = frame.InstructionIndex = _tryHandler.FinallyStartIndex; while (index >= _tryHandler.FinallyStartIndex && index < _tryHandler.FinallyEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } } } return frame.InstructionIndex - prevInstrIndex; } } /// <summary> /// The first instruction of finally block. /// </summary> internal sealed class EnterFinallyInstruction : IndexedBranchInstruction { private static readonly EnterFinallyInstruction[] s_cache = new EnterFinallyInstruction[CacheSize]; private EnterFinallyInstruction(int labelIndex) : base(labelIndex) { } public override string InstructionName => "EnterFinally"; public override int ProducedStack => 2; public override int ConsumedContinuations => 1; internal static EnterFinallyInstruction Create(int labelIndex) { if (labelIndex < CacheSize) { return s_cache[labelIndex] ?? (s_cache[labelIndex] = new EnterFinallyInstruction(labelIndex)); } return new EnterFinallyInstruction(labelIndex); } public override int Run(InterpretedFrame frame) { // If _pendingContinuation == -1 then we were getting into the finally block because an exception was thrown // in this case we need to set the stack depth // Else we were getting into this finally block from a 'Goto' jump, and the stack depth is already set properly if (!frame.IsJumpHappened()) { frame.SetStackDepth(GetLabel(frame).StackDepth); } frame.PushPendingContinuation(); frame.RemoveContinuation(); return 1; } } /// <summary> /// The last instruction of finally block. /// </summary> internal sealed class LeaveFinallyInstruction : Instruction { internal static readonly Instruction Instance = new LeaveFinallyInstruction(); private LeaveFinallyInstruction() { } public override int ConsumedStack => 2; public override string InstructionName => "LeaveFinally"; public override int Run(InterpretedFrame frame) { frame.PopPendingContinuation(); // If _pendingContinuation == -1 then we were getting into the finally block because an exception was thrown // In this case we just return 1, and the real instruction index will be calculated by GotoHandler later if (!frame.IsJumpHappened()) { return 1; } // jump to goto target or to the next finally: return frame.YieldToPendingContinuation(); } } internal sealed class EnterFaultInstruction : IndexedBranchInstruction { private static readonly EnterFaultInstruction[] s_cache = new EnterFaultInstruction[CacheSize]; private EnterFaultInstruction(int labelIndex) : base(labelIndex) { } public override string InstructionName => "EnterFault"; public override int ProducedStack => 2; internal static EnterFaultInstruction Create(int labelIndex) { if (labelIndex < CacheSize) { return s_cache[labelIndex] ?? (s_cache[labelIndex] = new EnterFaultInstruction(labelIndex)); } return new EnterFaultInstruction(labelIndex); } public override int Run(InterpretedFrame frame) { Debug.Assert(!frame.IsJumpHappened()); frame.SetStackDepth(GetLabel(frame).StackDepth); frame.PushPendingContinuation(); frame.RemoveContinuation(); return 1; } } internal sealed class LeaveFaultInstruction : Instruction { internal static readonly Instruction Instance = new LeaveFaultInstruction(); private LeaveFaultInstruction() { } public override int ConsumedStack => 2; public override int ConsumedContinuations => 1; public override string InstructionName => "LeaveFault"; public override int Run(InterpretedFrame frame) { frame.PopPendingContinuation(); Debug.Assert(!frame.IsJumpHappened()); // Just return 1, and the real instruction index will be calculated by GotoHandler later return 1; } } // no-op: we need this just to balance the stack depth and aid debugging of the instruction list. internal sealed class EnterExceptionFilterInstruction : Instruction { internal static readonly EnterExceptionFilterInstruction Instance = new EnterExceptionFilterInstruction(); private EnterExceptionFilterInstruction() { } public override string InstructionName => "EnterExceptionFilter"; // The exception is pushed onto the stack in the filter runner. public override int ProducedStack => 1; [ExcludeFromCodeCoverage(Justification = "Known to be a no-op, this instruction is skipped on execution")] public override int Run(InterpretedFrame frame) => 1; } // no-op: we need this just to balance the stack depth and aid debugging of the instruction list. internal sealed class LeaveExceptionFilterInstruction : Instruction { internal static readonly LeaveExceptionFilterInstruction Instance = new LeaveExceptionFilterInstruction(); private LeaveExceptionFilterInstruction() { } public override string InstructionName => "LeaveExceptionFilter"; // The exception and the boolean result are popped from the stack in the filter runner. public override int ConsumedStack => 2; [ExcludeFromCodeCoverage(Justification = "Known to be a no-op, this instruction is skipped on execution")] public override int Run(InterpretedFrame frame) => 1; } // no-op: we need this just to balance the stack depth. internal sealed class EnterExceptionHandlerInstruction : Instruction { internal static readonly EnterExceptionHandlerInstruction Void = new EnterExceptionHandlerInstruction(false); internal static readonly EnterExceptionHandlerInstruction NonVoid = new EnterExceptionHandlerInstruction(true); // True if try-expression is non-void. private readonly bool _hasValue; private EnterExceptionHandlerInstruction(bool hasValue) { _hasValue = hasValue; } public override string InstructionName => "EnterExceptionHandler"; // If an exception is throws in try-body the expression result of try-body is not evaluated and loaded to the stack. // So the stack doesn't contain the try-body's value when we start executing the handler. // However, while emitting instructions try block falls thru the catch block with a value on stack. // We need to declare it consumed so that the stack state upon entry to the handler corresponds to the real // stack depth after throw jumped to this catch block. public override int ConsumedStack => _hasValue ? 1 : 0; // A variable storing the current exception is pushed to the stack by exception handling. // Catch handlers: The value is immediately popped and stored into a local. public override int ProducedStack => 1; [ExcludeFromCodeCoverage(Justification = "Known to be a no-op, this instruction is skipped on execution")] public override int Run(InterpretedFrame frame) { // nop (the exception value is pushed by the interpreter in HandleCatch) return 1; } } /// <summary> /// The last instruction of a catch exception handler. /// </summary> internal sealed class LeaveExceptionHandlerInstruction : IndexedBranchInstruction { private static readonly LeaveExceptionHandlerInstruction[] s_cache = new LeaveExceptionHandlerInstruction[2 * CacheSize]; private readonly bool _hasValue; private LeaveExceptionHandlerInstruction(int labelIndex, bool hasValue) : base(labelIndex) { _hasValue = hasValue; } public override string InstructionName => "LeaveExceptionHandler"; // The catch block yields a value if the body is non-void. This value is left on the stack. public override int ConsumedStack => _hasValue ? 1 : 0; public override int ProducedStack => _hasValue ? 1 : 0; internal static LeaveExceptionHandlerInstruction Create(int labelIndex, bool hasValue) { if (labelIndex < CacheSize) { int index = (2 * labelIndex) | (hasValue ? 1 : 0); return s_cache[index] ?? (s_cache[index] = new LeaveExceptionHandlerInstruction(labelIndex, hasValue)); } return new LeaveExceptionHandlerInstruction(labelIndex, hasValue); } public override int Run(InterpretedFrame frame) { // CLR rethrows ThreadAbortException when leaving catch handler if abort is requested on the current thread. #if FEATURE_THREAD_ABORT Interpreter.AbortThreadIfRequested(frame, _labelIndex); #endif return GetLabel(frame).Index - frame.InstructionIndex; } } internal sealed class ThrowInstruction : Instruction { internal static readonly ThrowInstruction Throw = new ThrowInstruction(true, false); internal static readonly ThrowInstruction VoidThrow = new ThrowInstruction(false, false); internal static readonly ThrowInstruction Rethrow = new ThrowInstruction(true, true); internal static readonly ThrowInstruction VoidRethrow = new ThrowInstruction(false, true); private readonly bool _hasResult, _rethrow; private ThrowInstruction(bool hasResult, bool isRethrow) { _hasResult = hasResult; _rethrow = isRethrow; } public override string InstructionName => "Throw"; public override int ProducedStack => _hasResult ? 1 : 0; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { Exception? ex = WrapThrownObject(frame.Pop()); if (_rethrow) { throw new RethrowException(); } throw ex!; } private static Exception? WrapThrownObject(object? thrown) => thrown == null ? null : (thrown as Exception ?? new RuntimeWrappedException(thrown)); } internal sealed class IntSwitchInstruction<T> : Instruction where T : notnull { private readonly Dictionary<T, int> _cases; internal IntSwitchInstruction(Dictionary<T, int> cases) { Assert.NotNull(cases); _cases = cases; } public override string InstructionName => "IntSwitch"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { int target; return _cases.TryGetValue((T)frame.Pop()!, out target) ? target : 1; } } internal sealed class StringSwitchInstruction : Instruction { private readonly Dictionary<string, int> _cases; private readonly StrongBox<int> _nullCase; internal StringSwitchInstruction(Dictionary<string, int> cases, StrongBox<int> nullCase) { Assert.NotNull(cases); Assert.NotNull(nullCase); _cases = cases; _nullCase = nullCase; } public override string InstructionName => "StringSwitch"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { object? value = frame.Pop(); if (value == null) { return _nullCase.Value; } int target; return _cases.TryGetValue((string)value, out target) ? target : 1; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic.Utils; using System.Reflection; using System.Runtime.CompilerServices; namespace System.Linq.Expressions.Interpreter { internal abstract class OffsetInstruction : Instruction { internal const int Unknown = int.MinValue; internal const int CacheSize = 32; // the offset to jump to (relative to this instruction): protected int _offset = Unknown; public abstract Instruction[] Cache { get; } public Instruction Fixup(int offset) { Debug.Assert(_offset == Unknown && offset != Unknown); _offset = offset; Instruction[] cache = Cache; if (cache != null && offset >= 0 && offset < cache.Length) { return cache[offset] ?? (cache[offset] = this); } return this; } public override string ToDebugString(int instructionIndex, object? cookie, Func<int, int> labelIndexer, IReadOnlyList<object>? objects) { return ToString() + (_offset != Unknown ? " -> " + (instructionIndex + _offset) : ""); } public override string ToString() { return InstructionName + (_offset == Unknown ? "(?)" : "(" + _offset + ")"); } } internal sealed class BranchFalseInstruction : OffsetInstruction { private static Instruction[]? s_cache; public override Instruction[] Cache { get { if (s_cache == null) { s_cache = new Instruction[CacheSize]; } return s_cache; } } public override string InstructionName => "BranchFalse"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); if (!(bool)frame.Pop()!) { return _offset; } return 1; } } internal sealed class BranchTrueInstruction : OffsetInstruction { private static Instruction[]? s_cache; public override Instruction[] Cache { get { if (s_cache == null) { s_cache = new Instruction[CacheSize]; } return s_cache; } } public override string InstructionName => "BranchTrue"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); if ((bool)frame.Pop()!) { return _offset; } return 1; } } internal sealed class CoalescingBranchInstruction : OffsetInstruction { private static Instruction[]? s_cache; public override Instruction[] Cache { get { if (s_cache == null) { s_cache = new Instruction[CacheSize]; } return s_cache; } } public override string InstructionName => "CoalescingBranch"; public override int ConsumedStack => 1; public override int ProducedStack => 1; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); if (frame.Peek() != null) { return _offset; } return 1; } } internal sealed class BranchInstruction : OffsetInstruction { private static Instruction[][][]? s_caches; public override Instruction[] Cache { get { if (s_caches == null) { s_caches = new Instruction[2][][] { new Instruction[2][], new Instruction[2][] }; } return s_caches[ConsumedStack][ProducedStack] ?? (s_caches[ConsumedStack][ProducedStack] = new Instruction[CacheSize]); } } internal readonly bool _hasResult; internal readonly bool _hasValue; internal BranchInstruction() : this(false, false) { } public BranchInstruction(bool hasResult, bool hasValue) { _hasResult = hasResult; _hasValue = hasValue; } public override string InstructionName => "Branch"; public override int ConsumedStack => _hasValue ? 1 : 0; public override int ProducedStack => _hasResult ? 1 : 0; public override int Run(InterpretedFrame frame) { Debug.Assert(_offset != Unknown); return _offset; } } internal abstract class IndexedBranchInstruction : Instruction { protected const int CacheSize = 32; internal readonly int _labelIndex; public IndexedBranchInstruction(int labelIndex) { _labelIndex = labelIndex; } public RuntimeLabel GetLabel(InterpretedFrame frame) { Debug.Assert(_labelIndex != UnknownInstrIndex); return frame.Interpreter._labels[_labelIndex]; } public override string ToDebugString(int instructionIndex, object? cookie, Func<int, int> labelIndexer, IReadOnlyList<object>? objects) { Debug.Assert(_labelIndex != UnknownInstrIndex); int targetIndex = labelIndexer(_labelIndex); return ToString() + (targetIndex != BranchLabel.UnknownIndex ? " -> " + targetIndex : ""); } public override string ToString() { Debug.Assert(_labelIndex != UnknownInstrIndex); return InstructionName + "[" + _labelIndex + "]"; } } /// <summary> /// This instruction implements a goto expression that can jump out of any expression. /// It pops values (arguments) from the evaluation stack that the expression tree nodes in between /// the goto expression and the target label node pushed and not consumed yet. /// A goto expression can jump into a node that evaluates arguments only if it carries /// a value and jumps right after the first argument (the carried value will be used as the first argument). /// Goto can jump into an arbitrary child of a BlockExpression since the block doesn't accumulate values /// on evaluation stack as its child expressions are being evaluated. /// /// Goto needs to execute any finally blocks on the way to the target label. /// <example> /// { /// f(1, 2, try { g(3, 4, try { goto L } finally { ... }, 6) } finally { ... }, 7, 8) /// L: ... /// } /// </example> /// The goto expression here jumps to label L while having 4 items on evaluation stack (1, 2, 3 and 4). /// The jump needs to execute both finally blocks, the first one on stack level 4 the /// second one on stack level 2. So, it needs to jump the first finally block, pop 2 items from the stack, /// run second finally block and pop another 2 items from the stack and set instruction pointer to label L. /// /// Goto also needs to rethrow ThreadAbortException iff it jumps out of a catch handler and /// the current thread is in "abort requested" state. /// </summary> internal sealed class GotoInstruction : IndexedBranchInstruction { private const int Variants = 8; private static readonly GotoInstruction[] s_cache = new GotoInstruction[Variants * CacheSize]; public override string InstructionName => "Goto"; private readonly bool _hasResult; private readonly bool _hasValue; private readonly bool _labelTargetGetsValue; // Should technically return 1 for ConsumedContinuations and ProducedContinuations for gotos that target a label whose continuation depth // is different from the current continuation depth. This is because we will consume one continuation from the _continuations // and at meantime produce a new _pendingContinuation. However, in case of forward gotos, we don't not know that is the // case until the label is emitted. By then the consumed and produced stack information is useless. // The important thing here is that the stack balance is 0. public override int ConsumedStack => _hasValue ? 1 : 0; public override int ProducedStack => _hasResult ? 1 : 0; private GotoInstruction(int targetIndex, bool hasResult, bool hasValue, bool labelTargetGetsValue) : base(targetIndex) { _hasResult = hasResult; _hasValue = hasValue; _labelTargetGetsValue = labelTargetGetsValue; } internal static GotoInstruction Create(int labelIndex, bool hasResult, bool hasValue, bool labelTargetGetsValue) { if (labelIndex < CacheSize) { int index = Variants * labelIndex | (labelTargetGetsValue ? 4 : 0) | (hasResult ? 2 : 0) | (hasValue ? 1 : 0); return s_cache[index] ?? (s_cache[index] = new GotoInstruction(labelIndex, hasResult, hasValue, labelTargetGetsValue)); } return new GotoInstruction(labelIndex, hasResult, hasValue, labelTargetGetsValue); } public override int Run(InterpretedFrame frame) { // Are we jumping out of catch/finally while aborting the current thread? #if FEATURE_THREAD_ABORT Interpreter.AbortThreadIfRequested(frame, _labelIndex); #endif // goto the target label or the current finally continuation: object? value = _hasValue ? frame.Pop() : Interpreter.NoValue; return frame.Goto(_labelIndex, _labelTargetGetsValue ? value : Interpreter.NoValue, gotoExceptionHandler: false); } } internal sealed class EnterTryCatchFinallyInstruction : IndexedBranchInstruction { private readonly bool _hasFinally; private TryCatchFinallyHandler? _tryHandler; internal void SetTryHandler(TryCatchFinallyHandler tryHandler) { Debug.Assert(_tryHandler == null && tryHandler != null, "the tryHandler can be set only once"); _tryHandler = tryHandler; } internal TryCatchFinallyHandler? Handler => _tryHandler; public override int ProducedContinuations => _hasFinally ? 1 : 0; private EnterTryCatchFinallyInstruction(int targetIndex, bool hasFinally) : base(targetIndex) { _hasFinally = hasFinally; } internal static EnterTryCatchFinallyInstruction CreateTryFinally(int labelIndex) { return new EnterTryCatchFinallyInstruction(labelIndex, true); } internal static EnterTryCatchFinallyInstruction CreateTryCatch() { return new EnterTryCatchFinallyInstruction(UnknownInstrIndex, false); } public override int Run(InterpretedFrame frame) { Debug.Assert(_tryHandler != null, "the tryHandler must be set already"); if (_hasFinally) { // Push finally. frame.PushContinuation(_labelIndex); } int prevInstrIndex = frame.InstructionIndex; frame.InstructionIndex++; // Start to run the try/catch/finally blocks Instruction[] instructions = frame.Interpreter.Instructions.Instructions; try { // run the try block int index = frame.InstructionIndex; while (index >= _tryHandler.TryStartIndex && index < _tryHandler.TryEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } // we finish the try block and is about to jump out of the try/catch blocks if (index == _tryHandler.GotoEndTargetIndex) { // run the 'Goto' that jumps out of the try/catch/finally blocks Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/catch/finally"); frame.InstructionIndex += instructions[index].Run(frame); } } catch (Exception exception) when (_tryHandler.HasHandler(frame, exception, out ExceptionHandler? exHandler, out object? unwrappedException)) { Debug.Assert(!(unwrappedException is RethrowException)); frame.InstructionIndex += frame.Goto(exHandler.LabelIndex, unwrappedException, gotoExceptionHandler: true); #if FEATURE_THREAD_ABORT // stay in the current catch so that ThreadAbortException is not rethrown by CLR: var abort = exception as ThreadAbortException; if (abort != null) { Interpreter.AnyAbortException = abort; frame.CurrentAbortHandler = exHandler; } #endif bool rethrow = false; try { // run the catch block int index = frame.InstructionIndex; while (index >= exHandler.HandlerStartIndex && index < exHandler.HandlerEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } // we finish the catch block and is about to jump out of the try/catch blocks if (index == _tryHandler.GotoEndTargetIndex) { // run the 'Goto' that jumps out of the try/catch/finally blocks Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/catch/finally"); frame.InstructionIndex += instructions[index].Run(frame); } } catch (RethrowException) { // a rethrow instruction in a catch block gets to run rethrow = true; } if (rethrow) { throw; } } finally { if (_tryHandler.IsFinallyBlockExist) { // We get to the finally block in two paths: // 1. Jump from the try/catch blocks. This includes two sub-routes: // a. 'Goto' instruction in the middle of try/catch block // b. try/catch block runs to its end. Then the 'Goto(end)' will be trigger to jump out of the try/catch block // 2. Exception thrown from the try/catch blocks // In the first path, the continuation mechanism works and frame.InstructionIndex will be updated to point to the first instruction of the finally block // In the second path, the continuation mechanism is not involved and frame.InstructionIndex is not updated #if DEBUG bool isFromJump = frame.IsJumpHappened(); Debug.Assert(!isFromJump || (isFromJump && _tryHandler.FinallyStartIndex == frame.InstructionIndex), "we should already jump to the first instruction of the finally"); #endif // run the finally block // we cannot jump out of the finally block, and we cannot have an immediate rethrow in it int index = frame.InstructionIndex = _tryHandler.FinallyStartIndex; while (index >= _tryHandler.FinallyStartIndex && index < _tryHandler.FinallyEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } } } return frame.InstructionIndex - prevInstrIndex; } public override string InstructionName => _hasFinally ? "EnterTryFinally" : "EnterTryCatch"; public override string ToString() => _hasFinally ? "EnterTryFinally[" + _labelIndex + "]" : "EnterTryCatch"; } internal sealed class EnterTryFaultInstruction : IndexedBranchInstruction { private TryFaultHandler? _tryHandler; internal EnterTryFaultInstruction(int targetIndex) : base(targetIndex) { } public override string InstructionName => "EnterTryFault"; public override int ProducedContinuations => 1; internal TryFaultHandler? Handler => _tryHandler; internal void SetTryHandler(TryFaultHandler tryHandler) { Debug.Assert(tryHandler != null); Debug.Assert(_tryHandler == null, "the tryHandler can be set only once"); _tryHandler = tryHandler; } public override int Run(InterpretedFrame frame) { Debug.Assert(_tryHandler != null, "the tryHandler must be set already"); // Push fault. frame.PushContinuation(_labelIndex); int prevInstrIndex = frame.InstructionIndex; frame.InstructionIndex++; // Start to run the try/fault blocks Instruction[] instructions = frame.Interpreter.Instructions.Instructions; // C# 6 has no direct support for fault blocks, but they can be faked or coerced out of the compiler // in several ways. Catch-and-rethrow can work in specific cases, but not generally as the double-pass // will not work correctly with filters higher up the call stack. Iterators can be used to produce real // fault blocks, but it depends on an implementation detail rather than a guarantee, and is rather // indirect. This leaves using a finally block and not doing anything in it if the body ran to // completion, which is the approach used here. bool ranWithoutFault = false; try { // run the try block int index = frame.InstructionIndex; while (index >= _tryHandler.TryStartIndex && index < _tryHandler.TryEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } // run the 'Goto' that jumps out of the try/fault blocks Debug.Assert(instructions[index] is GotoInstruction, "should be the 'Goto' instruction that jumps out the try/fault"); // if we've arrived here there was no exception thrown. As the fault block won't run, we need to // pop the continuation for it here, before Gotoing the end of the try/fault. ranWithoutFault = true; frame.RemoveContinuation(); frame.InstructionIndex += instructions[index].Run(frame); } finally { if (!ranWithoutFault) { // run the fault block // we cannot jump out of the finally block, and we cannot have an immediate rethrow in it int index = frame.InstructionIndex = _tryHandler.FinallyStartIndex; while (index >= _tryHandler.FinallyStartIndex && index < _tryHandler.FinallyEndIndex) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } } } return frame.InstructionIndex - prevInstrIndex; } } /// <summary> /// The first instruction of finally block. /// </summary> internal sealed class EnterFinallyInstruction : IndexedBranchInstruction { private static readonly EnterFinallyInstruction[] s_cache = new EnterFinallyInstruction[CacheSize]; private EnterFinallyInstruction(int labelIndex) : base(labelIndex) { } public override string InstructionName => "EnterFinally"; public override int ProducedStack => 2; public override int ConsumedContinuations => 1; internal static EnterFinallyInstruction Create(int labelIndex) { if (labelIndex < CacheSize) { return s_cache[labelIndex] ?? (s_cache[labelIndex] = new EnterFinallyInstruction(labelIndex)); } return new EnterFinallyInstruction(labelIndex); } public override int Run(InterpretedFrame frame) { // If _pendingContinuation == -1 then we were getting into the finally block because an exception was thrown // in this case we need to set the stack depth // Else we were getting into this finally block from a 'Goto' jump, and the stack depth is already set properly if (!frame.IsJumpHappened()) { frame.SetStackDepth(GetLabel(frame).StackDepth); } frame.PushPendingContinuation(); frame.RemoveContinuation(); return 1; } } /// <summary> /// The last instruction of finally block. /// </summary> internal sealed class LeaveFinallyInstruction : Instruction { internal static readonly Instruction Instance = new LeaveFinallyInstruction(); private LeaveFinallyInstruction() { } public override int ConsumedStack => 2; public override string InstructionName => "LeaveFinally"; public override int Run(InterpretedFrame frame) { frame.PopPendingContinuation(); // If _pendingContinuation == -1 then we were getting into the finally block because an exception was thrown // In this case we just return 1, and the real instruction index will be calculated by GotoHandler later if (!frame.IsJumpHappened()) { return 1; } // jump to goto target or to the next finally: return frame.YieldToPendingContinuation(); } } internal sealed class EnterFaultInstruction : IndexedBranchInstruction { private static readonly EnterFaultInstruction[] s_cache = new EnterFaultInstruction[CacheSize]; private EnterFaultInstruction(int labelIndex) : base(labelIndex) { } public override string InstructionName => "EnterFault"; public override int ProducedStack => 2; internal static EnterFaultInstruction Create(int labelIndex) { if (labelIndex < CacheSize) { return s_cache[labelIndex] ?? (s_cache[labelIndex] = new EnterFaultInstruction(labelIndex)); } return new EnterFaultInstruction(labelIndex); } public override int Run(InterpretedFrame frame) { Debug.Assert(!frame.IsJumpHappened()); frame.SetStackDepth(GetLabel(frame).StackDepth); frame.PushPendingContinuation(); frame.RemoveContinuation(); return 1; } } internal sealed class LeaveFaultInstruction : Instruction { internal static readonly Instruction Instance = new LeaveFaultInstruction(); private LeaveFaultInstruction() { } public override int ConsumedStack => 2; public override int ConsumedContinuations => 1; public override string InstructionName => "LeaveFault"; public override int Run(InterpretedFrame frame) { frame.PopPendingContinuation(); Debug.Assert(!frame.IsJumpHappened()); // Just return 1, and the real instruction index will be calculated by GotoHandler later return 1; } } // no-op: we need this just to balance the stack depth and aid debugging of the instruction list. internal sealed class EnterExceptionFilterInstruction : Instruction { internal static readonly EnterExceptionFilterInstruction Instance = new EnterExceptionFilterInstruction(); private EnterExceptionFilterInstruction() { } public override string InstructionName => "EnterExceptionFilter"; // The exception is pushed onto the stack in the filter runner. public override int ProducedStack => 1; [ExcludeFromCodeCoverage(Justification = "Known to be a no-op, this instruction is skipped on execution")] public override int Run(InterpretedFrame frame) => 1; } // no-op: we need this just to balance the stack depth and aid debugging of the instruction list. internal sealed class LeaveExceptionFilterInstruction : Instruction { internal static readonly LeaveExceptionFilterInstruction Instance = new LeaveExceptionFilterInstruction(); private LeaveExceptionFilterInstruction() { } public override string InstructionName => "LeaveExceptionFilter"; // The exception and the boolean result are popped from the stack in the filter runner. public override int ConsumedStack => 2; [ExcludeFromCodeCoverage(Justification = "Known to be a no-op, this instruction is skipped on execution")] public override int Run(InterpretedFrame frame) => 1; } // no-op: we need this just to balance the stack depth. internal sealed class EnterExceptionHandlerInstruction : Instruction { internal static readonly EnterExceptionHandlerInstruction Void = new EnterExceptionHandlerInstruction(false); internal static readonly EnterExceptionHandlerInstruction NonVoid = new EnterExceptionHandlerInstruction(true); // True if try-expression is non-void. private readonly bool _hasValue; private EnterExceptionHandlerInstruction(bool hasValue) { _hasValue = hasValue; } public override string InstructionName => "EnterExceptionHandler"; // If an exception is throws in try-body the expression result of try-body is not evaluated and loaded to the stack. // So the stack doesn't contain the try-body's value when we start executing the handler. // However, while emitting instructions try block falls thru the catch block with a value on stack. // We need to declare it consumed so that the stack state upon entry to the handler corresponds to the real // stack depth after throw jumped to this catch block. public override int ConsumedStack => _hasValue ? 1 : 0; // A variable storing the current exception is pushed to the stack by exception handling. // Catch handlers: The value is immediately popped and stored into a local. public override int ProducedStack => 1; [ExcludeFromCodeCoverage(Justification = "Known to be a no-op, this instruction is skipped on execution")] public override int Run(InterpretedFrame frame) { // nop (the exception value is pushed by the interpreter in HandleCatch) return 1; } } /// <summary> /// The last instruction of a catch exception handler. /// </summary> internal sealed class LeaveExceptionHandlerInstruction : IndexedBranchInstruction { private static readonly LeaveExceptionHandlerInstruction[] s_cache = new LeaveExceptionHandlerInstruction[2 * CacheSize]; private readonly bool _hasValue; private LeaveExceptionHandlerInstruction(int labelIndex, bool hasValue) : base(labelIndex) { _hasValue = hasValue; } public override string InstructionName => "LeaveExceptionHandler"; // The catch block yields a value if the body is non-void. This value is left on the stack. public override int ConsumedStack => _hasValue ? 1 : 0; public override int ProducedStack => _hasValue ? 1 : 0; internal static LeaveExceptionHandlerInstruction Create(int labelIndex, bool hasValue) { if (labelIndex < CacheSize) { int index = (2 * labelIndex) | (hasValue ? 1 : 0); return s_cache[index] ?? (s_cache[index] = new LeaveExceptionHandlerInstruction(labelIndex, hasValue)); } return new LeaveExceptionHandlerInstruction(labelIndex, hasValue); } public override int Run(InterpretedFrame frame) { // CLR rethrows ThreadAbortException when leaving catch handler if abort is requested on the current thread. #if FEATURE_THREAD_ABORT Interpreter.AbortThreadIfRequested(frame, _labelIndex); #endif return GetLabel(frame).Index - frame.InstructionIndex; } } internal sealed class ThrowInstruction : Instruction { internal static readonly ThrowInstruction Throw = new ThrowInstruction(true, false); internal static readonly ThrowInstruction VoidThrow = new ThrowInstruction(false, false); internal static readonly ThrowInstruction Rethrow = new ThrowInstruction(true, true); internal static readonly ThrowInstruction VoidRethrow = new ThrowInstruction(false, true); private readonly bool _hasResult, _rethrow; private ThrowInstruction(bool hasResult, bool isRethrow) { _hasResult = hasResult; _rethrow = isRethrow; } public override string InstructionName => "Throw"; public override int ProducedStack => _hasResult ? 1 : 0; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { Exception? ex = WrapThrownObject(frame.Pop()); if (_rethrow) { throw new RethrowException(); } throw ex!; } private static Exception? WrapThrownObject(object? thrown) => thrown == null ? null : (thrown as Exception ?? new RuntimeWrappedException(thrown)); } internal sealed class IntSwitchInstruction<T> : Instruction where T : notnull { private readonly Dictionary<T, int> _cases; internal IntSwitchInstruction(Dictionary<T, int> cases) { Assert.NotNull(cases); _cases = cases; } public override string InstructionName => "IntSwitch"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { int target; return _cases.TryGetValue((T)frame.Pop()!, out target) ? target : 1; } } internal sealed class StringSwitchInstruction : Instruction { private readonly Dictionary<string, int> _cases; private readonly StrongBox<int> _nullCase; internal StringSwitchInstruction(Dictionary<string, int> cases, StrongBox<int> nullCase) { Assert.NotNull(cases); Assert.NotNull(nullCase); _cases = cases; _nullCase = nullCase; } public override string InstructionName => "StringSwitch"; public override int ConsumedStack => 1; public override int Run(InterpretedFrame frame) { object? value = frame.Pop(); if (value == null) { return _nullCase.Value; } int target; return _cases.TryGetValue((string)value, out target) ? target : 1; } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/IL_Conformance/Old/Conformance_Base/ldc_ckfinite_r4.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ldc_ckfinite_r4.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ldc_ckfinite_r4.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/HardwareIntrinsics/X86/Sse41/Blend.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics; namespace IntelHardwareIntrinsicTest { class Program { const int Pass = 100; const int Fail = 0; static unsafe int Main(string[] args) { int testResult = Pass; if (Sse41.IsSupported) { using (TestTable<float> floatTable = new TestTable<float>(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) { var vf1 = Unsafe.Read<Vector128<float>>(floatTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<float>>(floatTable.inArray2Ptr); // SDDD var vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DSDD vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) && (z[2] == x[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DDSD vf3 = Sse41.Blend(vf1, vf2, 4); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDSD vf3 = Sse41.Blend(vf1, vf2, 85); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD vf3 = (Vector128<float>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) }); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } using (TestTable<double> doubleTable = new TestTable<double>(new double[2] { 1, -5 }, new double[2] { 22, -1 }, new double[2])) { var vf1 = Unsafe.Read<Vector128<double>>(doubleTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<double>>(doubleTable.inArray2Ptr); // DD var vf3 = Sse41.Blend(vf1, vf2, 0); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SD vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DS vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SS vf3 = Sse41.Blend(vf1, vf2, 51); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == y[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD vf3 = (Vector128<double>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(0) }); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } using (TestTable<short> shortTable = new TestTable<short>(new short[8] { 1, -5, 100, 0, 1, -5, 100, 0 }, new short[8] { 22, -1, -50, 0, 22, -1, -50, 0 }, new short[8])) { var vf1 = Unsafe.Read<Vector128<short>>(shortTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<short>>(shortTable.inArray2Ptr); // SDDD DDDD var vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DSDD DDDD vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DDSD DDDD vf3 = Sse41.Blend(vf1, vf2, 4); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDSD SDSD vf3 = Sse41.Blend(vf1, vf2, 85); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == y[4]) && (z[5] == x[5]) && (z[6] == y[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD DDDD vf3 = (Vector128<short>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) }); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } using (TestTable<ushort> ushortTable = new TestTable<ushort>(new ushort[8] { 1, 5, 100, 0, 1, 5, 100, 0 }, new ushort[8] { 22, 1, 50, 0, 22, 1, 50, 0 }, new ushort[8])) { var vf1 = Unsafe.Read<Vector128<ushort>>(ushortTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<ushort>>(ushortTable.inArray2Ptr); // SDDD DDDD var vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DSDD DDDD vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DDSD DDDD vf3 = Sse41.Blend(vf1, vf2, 4); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDSD SDSD vf3 = Sse41.Blend(vf1, vf2, 85); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == y[4]) && (z[5] == x[5]) && (z[6] == y[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD DDDD vf3 = (Vector128<ushort>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) }); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } } return testResult; } public unsafe struct TestTable<T> : IDisposable where T : struct { public T[] inArray1; public T[] inArray2; public T[] outArray; public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); GCHandle inHandle1; GCHandle inHandle2; GCHandle outHandle; public TestTable(T[] a, T[] b, T[] c) { this.inArray1 = a; this.inArray2 = b; this.outArray = c; inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); } public bool CheckResult(Func<T[], T[], T[], bool> check) { return check(inArray1, inArray2, outArray); } public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics; namespace IntelHardwareIntrinsicTest { class Program { const int Pass = 100; const int Fail = 0; static unsafe int Main(string[] args) { int testResult = Pass; if (Sse41.IsSupported) { using (TestTable<float> floatTable = new TestTable<float>(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) { var vf1 = Unsafe.Read<Vector128<float>>(floatTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<float>>(floatTable.inArray2Ptr); // SDDD var vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DSDD vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) && (z[2] == x[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DDSD vf3 = Sse41.Blend(vf1, vf2, 4); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDSD vf3 = Sse41.Blend(vf1, vf2, 85); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD vf3 = (Vector128<float>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) }); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]))) { Console.WriteLine("SSE41 Blend failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } using (TestTable<double> doubleTable = new TestTable<double>(new double[2] { 1, -5 }, new double[2] { 22, -1 }, new double[2])) { var vf1 = Unsafe.Read<Vector128<double>>(doubleTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<double>>(doubleTable.inArray2Ptr); // DD var vf3 = Sse41.Blend(vf1, vf2, 0); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SD vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DS vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SS vf3 = Sse41.Blend(vf1, vf2, 51); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == y[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD vf3 = (Vector128<double>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(0) }); Unsafe.Write(doubleTable.outArrayPtr, vf3); if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]))) { Console.WriteLine("SSE41 Blend failed on double:"); foreach (var item in doubleTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } using (TestTable<short> shortTable = new TestTable<short>(new short[8] { 1, -5, 100, 0, 1, -5, 100, 0 }, new short[8] { 22, -1, -50, 0, 22, -1, -50, 0 }, new short[8])) { var vf1 = Unsafe.Read<Vector128<short>>(shortTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<short>>(shortTable.inArray2Ptr); // SDDD DDDD var vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DSDD DDDD vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DDSD DDDD vf3 = Sse41.Blend(vf1, vf2, 4); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDSD SDSD vf3 = Sse41.Blend(vf1, vf2, 85); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == y[4]) && (z[5] == x[5]) && (z[6] == y[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD DDDD vf3 = (Vector128<short>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) }); Unsafe.Write(shortTable.outArrayPtr, vf3); if (!shortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on short:"); foreach (var item in shortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } using (TestTable<ushort> ushortTable = new TestTable<ushort>(new ushort[8] { 1, 5, 100, 0, 1, 5, 100, 0 }, new ushort[8] { 22, 1, 50, 0, 22, 1, 50, 0 }, new ushort[8])) { var vf1 = Unsafe.Read<Vector128<ushort>>(ushortTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector128<ushort>>(ushortTable.inArray2Ptr); // SDDD DDDD var vf3 = Sse41.Blend(vf1, vf2, 1); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DSDD DDDD vf3 = Sse41.Blend(vf1, vf2, 2); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // DDSD DDDD vf3 = Sse41.Blend(vf1, vf2, 4); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDSD SDSD vf3 = Sse41.Blend(vf1, vf2, 85); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == y[2]) && (z[3] == x[3]) && (z[4] == y[4]) && (z[5] == x[5]) && (z[6] == y[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } // SDDD DDDD vf3 = (Vector128<ushort>)typeof(Sse41).GetMethod(nameof(Sse41.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) }); Unsafe.Write(ushortTable.outArrayPtr, vf3); if (!ushortTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) && (z[2] == x[2]) && (z[3] == x[3]) && (z[4] == x[4]) && (z[5] == x[5]) && (z[6] == x[6]) && (z[7] == x[7]))) { Console.WriteLine("SSE41 Blend failed on ushort:"); foreach (var item in ushortTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } } return testResult; } public unsafe struct TestTable<T> : IDisposable where T : struct { public T[] inArray1; public T[] inArray2; public T[] outArray; public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); GCHandle inHandle1; GCHandle inHandle2; GCHandle outHandle; public TestTable(T[] a, T[] b, T[] c) { this.inArray1 = a; this.inArray2 = b; this.outArray = c; inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); } public bool CheckResult(Func<T[], T[], T[], bool> check) { return check(inArray1, inArray2, outArray); } public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/native/external/rapidjson/memorybuffer.h
// Tencent is pleased to support the open source community by making RapidJSON available. // // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. // // Licensed under the MIT License (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // http://opensource.org/licenses/MIT // // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. #ifndef RAPIDJSON_MEMORYBUFFER_H_ #define RAPIDJSON_MEMORYBUFFER_H_ #include "stream.h" #include "internal/stack.h" RAPIDJSON_NAMESPACE_BEGIN //! Represents an in-memory output byte stream. /*! This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. Differences between MemoryBuffer and StringBuffer: 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. \tparam Allocator type for allocating memory buffer. \note implements Stream concept */ template <typename Allocator = CrtAllocator> struct GenericMemoryBuffer { typedef char Ch; // byte GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} void Put(Ch c) { *stack_.template Push<Ch>() = c; } void Flush() {} void Clear() { stack_.Clear(); } void ShrinkToFit() { stack_.ShrinkToFit(); } Ch* Push(size_t count) { return stack_.template Push<Ch>(count); } void Pop(size_t count) { stack_.template Pop<Ch>(count); } const Ch* GetBuffer() const { return stack_.template Bottom<Ch>(); } size_t GetSize() const { return stack_.GetSize(); } static const size_t kDefaultCapacity = 256; mutable internal::Stack<Allocator> stack_; }; typedef GenericMemoryBuffer<> MemoryBuffer; //! Implement specialized version of PutN() with memset() for better performance. template<> inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { std::memset(memoryBuffer.stack_.Push<char>(n), c, n * sizeof(c)); } RAPIDJSON_NAMESPACE_END #endif // RAPIDJSON_MEMORYBUFFER_H_
// Tencent is pleased to support the open source community by making RapidJSON available. // // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. // // Licensed under the MIT License (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // http://opensource.org/licenses/MIT // // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. #ifndef RAPIDJSON_MEMORYBUFFER_H_ #define RAPIDJSON_MEMORYBUFFER_H_ #include "stream.h" #include "internal/stack.h" RAPIDJSON_NAMESPACE_BEGIN //! Represents an in-memory output byte stream. /*! This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. Differences between MemoryBuffer and StringBuffer: 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. \tparam Allocator type for allocating memory buffer. \note implements Stream concept */ template <typename Allocator = CrtAllocator> struct GenericMemoryBuffer { typedef char Ch; // byte GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} void Put(Ch c) { *stack_.template Push<Ch>() = c; } void Flush() {} void Clear() { stack_.Clear(); } void ShrinkToFit() { stack_.ShrinkToFit(); } Ch* Push(size_t count) { return stack_.template Push<Ch>(count); } void Pop(size_t count) { stack_.template Pop<Ch>(count); } const Ch* GetBuffer() const { return stack_.template Bottom<Ch>(); } size_t GetSize() const { return stack_.GetSize(); } static const size_t kDefaultCapacity = 256; mutable internal::Stack<Allocator> stack_; }; typedef GenericMemoryBuffer<> MemoryBuffer; //! Implement specialized version of PutN() with memset() for better performance. template<> inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { std::memset(memoryBuffer.stack_.Push<char>(n), c, n * sizeof(c)); } RAPIDJSON_NAMESPACE_END #endif // RAPIDJSON_MEMORYBUFFER_H_
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/Performance/CodeQuality/SIMD/ConsoleMandel/ScalarFloat.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; using System.Threading.Tasks; namespace Algorithms { // This class contains renderers that use scalar floats internal class ScalarFloatRenderer : FractalRenderer { public ScalarFloatRenderer(Action<int, int, int> dp, Func<bool> abortFunc) : base(dp, abortFunc) { } protected const float limit = 4.0f; // Render the fractal using a Complex data type on a single thread with scalar floats public void RenderSingleThreadedWithADT(float xmin, float xmax, float ymin, float ymax, float step) { int yp = 0; for (float y = ymin; y < ymax && !Abort; y += step, yp++) { int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { ComplexFloat num = new ComplexFloat(x, y); ComplexFloat accum = num; int iters = 0; float sqabs = 0f; do { accum = accum.square(); accum += num; iters++; sqabs = accum.sqabs(); } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } } } // Render the fractal with no data type abstraction on a single thread with scalar floats public void RenderSingleThreadedNoADT(float xmin, float xmax, float ymin, float ymax, float step) { int yp = 0; for (float y = ymin; y < ymax && !Abort; y += step, yp++) { int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { float accumx = x; float accumy = y; int iters = 0; float sqabs = 0f; do { float naccumx = accumx * accumx - accumy * accumy; float naccumy = 2.0f * accumx * accumy; accumx = naccumx + x; accumy = naccumy + y; iters++; sqabs = accumx * accumx + accumy * accumy; } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } } } // Render the fractal using a Complex data type on a single thread with scalar floats public void RenderMultiThreadedWithADT(float xmin, float xmax, float ymin, float ymax, float step) { Parallel.For(0, (int)(((ymax - ymin) / step) + .5f), (yp) => { if (Abort) return; float y = ymin + step * yp; int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { ComplexFloat num = new ComplexFloat(x, y); ComplexFloat accum = num; int iters = 0; float sqabs = 0f; do { accum = accum.square(); accum += num; iters++; sqabs = accum.sqabs(); } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } }); } // Render the fractal with no data type abstraction on multiple threads with scalar floats public void RenderMultiThreadedNoADT(float xmin, float xmax, float ymin, float ymax, float step) { Parallel.For(0, (int)(((ymax - ymin) / step) + .5f), (yp) => { if (Abort) return; float y = ymin + step * yp; int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { float accumx = x; float accumy = y; int iters = 0; float sqabs = 0f; do { float naccumx = accumx * accumx - accumy * accumy; float naccumy = 2.0f * accumx * accumy; accumx = naccumx + x; accumy = naccumy + y; iters++; sqabs = accumx * accumx + accumy * accumy; } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } }); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; using System.Threading.Tasks; namespace Algorithms { // This class contains renderers that use scalar floats internal class ScalarFloatRenderer : FractalRenderer { public ScalarFloatRenderer(Action<int, int, int> dp, Func<bool> abortFunc) : base(dp, abortFunc) { } protected const float limit = 4.0f; // Render the fractal using a Complex data type on a single thread with scalar floats public void RenderSingleThreadedWithADT(float xmin, float xmax, float ymin, float ymax, float step) { int yp = 0; for (float y = ymin; y < ymax && !Abort; y += step, yp++) { int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { ComplexFloat num = new ComplexFloat(x, y); ComplexFloat accum = num; int iters = 0; float sqabs = 0f; do { accum = accum.square(); accum += num; iters++; sqabs = accum.sqabs(); } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } } } // Render the fractal with no data type abstraction on a single thread with scalar floats public void RenderSingleThreadedNoADT(float xmin, float xmax, float ymin, float ymax, float step) { int yp = 0; for (float y = ymin; y < ymax && !Abort; y += step, yp++) { int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { float accumx = x; float accumy = y; int iters = 0; float sqabs = 0f; do { float naccumx = accumx * accumx - accumy * accumy; float naccumy = 2.0f * accumx * accumy; accumx = naccumx + x; accumy = naccumy + y; iters++; sqabs = accumx * accumx + accumy * accumy; } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } } } // Render the fractal using a Complex data type on a single thread with scalar floats public void RenderMultiThreadedWithADT(float xmin, float xmax, float ymin, float ymax, float step) { Parallel.For(0, (int)(((ymax - ymin) / step) + .5f), (yp) => { if (Abort) return; float y = ymin + step * yp; int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { ComplexFloat num = new ComplexFloat(x, y); ComplexFloat accum = num; int iters = 0; float sqabs = 0f; do { accum = accum.square(); accum += num; iters++; sqabs = accum.sqabs(); } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } }); } // Render the fractal with no data type abstraction on multiple threads with scalar floats public void RenderMultiThreadedNoADT(float xmin, float xmax, float ymin, float ymax, float step) { Parallel.For(0, (int)(((ymax - ymin) / step) + .5f), (yp) => { if (Abort) return; float y = ymin + step * yp; int xp = 0; for (float x = xmin; x < xmax; x += step, xp++) { float accumx = x; float accumy = y; int iters = 0; float sqabs = 0f; do { float naccumx = accumx * accumx - accumy * accumy; float naccumy = 2.0f * accumx * accumy; accumx = naccumx + x; accumy = naccumy + y; iters++; sqabs = accumx * accumx + accumy * accumy; } while (sqabs < limit && iters < max_iters); DrawPixel(xp, yp, iters); } }); } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/coreclr/hosts/corerun/dotenv.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #include "dotenv.hpp" #include <istream> #include <locale> #include <sstream> #include <algorithm> namespace { bool read_var_name(std::istream& file, std::string& var_name_out) { std::string var_name; char next; file.get(next); while (!file.eof() && isspace(next)) { file.get(next); } if (file.eof()) { return true; } if (next == '#') { // This is a comment, skip the line std::string comment; std::getline(file, comment); } bool key_quoted = next == '\''; if (key_quoted) { file.get(next); } if (!isalpha(next) && next != '_') { return false; } var_name.push_back(next); while (!file.eof()) { if (key_quoted && file.peek() == '\'') { break; } else if (file.peek() == '=') { break; } file.get(next); if (isspace(next)) { continue; } if (next == '#') { // Comments in names are unsupported return false; } if (!isalnum(next) && next != '_') { return false; } var_name.push_back(next); } if (key_quoted && file.get() == '\'') { while (!file.eof() && file.peek() != '=') { file.get(next); if (!isspace(next)) { return false; } } } if (!file.eof()) { // read the = sign (void)file.get(); } var_name_out = var_name; return !file.eof(); } bool check_endline(char current_char, int next_char) { return current_char == '\n' || (current_char == '\r' && next_char == '\n'); } void trim_from_end(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), [](char ch) { return !isspace(ch); }).base(), s.end()); } std::string read_substitution(std::istream& file, std::function<std::string(std::string)> substitution_lookup) { std::string substituted_variable_name; // Read the '{' character (void)file.get(); bool first = false; bool substitute_parse_failure = false; while (!file.eof() && file.peek() != '}') { char var_name_next; file.get(var_name_next); //If the name is not a valid environment variable name in the format, treat is as not a substitution. if (!((first && isalpha(var_name_next)) || isalnum(var_name_next)) && var_name_next != '_') { substitute_parse_failure = true; return std::string{ "${" } + std::move(substituted_variable_name) + std::string{ var_name_next }; } substituted_variable_name.push_back(var_name_next); first = false; } if (!file.eof() && !substitute_parse_failure && file.get() == '}') { return substitution_lookup(substituted_variable_name); } assert(file.eof()); return substituted_variable_name; } bool read_var_value(std::istream& file, std::function<std::string(std::string)> substitution_lookup, std::string& var_value_out) { std::string var_value; char next; file.get(next); while (!file.eof() && isspace(next)) { file.get(next); } if (file.eof()) { return false; } bool is_quoted = next == '\'' || next == '"'; char quote_char = is_quoted ? next : '\0'; bool can_substitute = next != '\''; if (next == '$') { var_value.append(read_substitution(file, substitution_lookup)); } else if (next == '#') { // The rest of the line is a comment. Therefore, the value of the environment variable is empty. var_value_out = var_value; return true; } else if (!is_quoted) { var_value.push_back(next); } while (!file.eof()) { file.get(next); if (file.eof()) { break; } else if (!is_quoted && next == '#') { // This is a comment, skip the rest of the line // and trim any whitespace from the end. std::string comment; std::getline(file, comment); trim_from_end(var_value); var_value_out = var_value; return true; } else if (!is_quoted && check_endline(next, file.eof() ? '\0' : file.peek())) { break; } else if (is_quoted && next == quote_char) { break; } else if (is_quoted && next == '\\') { int escaped = file.get(); if (file.eof()) { return false; } if (quote_char == '\'') { switch (escaped) { case '\\': case '\'': var_value.push_back((char)escaped); break; default: return false; } } else { assert(quote_char == '"'); switch (escaped) { case '\\': case '\'': case '"': var_value.push_back((char)escaped); break; case 'a': var_value.push_back('\a'); break; case 'b': var_value.push_back('\b'); break; case 'f': var_value.push_back('\f'); break; case 'n': var_value.push_back('\n'); break; case 'r': var_value.push_back('\r'); break; case 't': var_value.push_back('\t'); break; case 'v': var_value.push_back('\v'); break; default: return false; } } } else if (next == '$' && can_substitute && file.peek() == '{') { var_value.append(read_substitution(file, substitution_lookup)); } else { var_value.push_back(next); } } var_value_out = var_value; if (is_quoted) { file.get(next); while (!file.eof() && isspace(next)) { if (check_endline(next, file.eof() ? '\0' : file.peek())) { return true; } } return file.eof(); } return true; } } dotenv::dotenv(pal::string_t dotEnvFilePath, std::istream& contents) : _dotenvFilePath{dotEnvFilePath} , _environmentVariables{} { // Peek at the start to set the eof bit if the file is empty while (!contents.eof()) { std::string temp_name; std::string temp_value; if (!read_var_name(contents, temp_name)) { _environmentVariables = {}; break; } if (contents.eof()) { _environmentVariables = {}; break; } // Handle variable expansion scenarios if (!read_var_value(contents, [&](std::string name) { auto dot_env_entry = _environmentVariables.find(name); if (dot_env_entry != _environmentVariables.end()) { return dot_env_entry->second; } return pal::getenvA(name.c_str()); }, temp_value)) { _environmentVariables = {}; break; } _environmentVariables.emplace(temp_name, temp_value); } } void dotenv::load_into_current_process() const { for (std::pair<std::string, std::string> env_vars : _environmentVariables) { pal::string_utf8_t name_string = env_vars.first; pal::string_utf8_t value_string = env_vars.second; pal::setenvA(name_string.c_str(), std::move(value_string)); } } #define THROW_IF_FALSE(stmt) if (!(stmt)) throw W(#stmt); void dotenv::self_test() { { std::istringstream contents{""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables.size() == 0); } { std::istringstream contents{"Foo=Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=Bar # Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=\"Bar # Not a comment\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar # Not a comment"); } { std::istringstream contents{"Foo=# Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == ""); } { std::istringstream contents{"Foo# Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables.size() == 0); } { std::istringstream contents{"Foo=Bar#Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=A"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "A"); } { std::istringstream contents{"Foo="}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == ""); } { std::istringstream contents{"Foo=\r\n"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == ""); } { std::istringstream contents{"A=Foo"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["A"] == "Foo"); } { std::istringstream contents{"Foo =Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{" Foo= Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"'Foo'= Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"'Foo' = Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{" 'Foo' = Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=\"Bar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= \"Bar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= \"Bar\" "}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= 'Bar'"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo='Bar'"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo='Bar' "}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=\"\r\nBar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "\r\nBar"); } { std::istringstream contents{"Foo=\"\\r\\nBar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "\r\nBar"); } { std::istringstream contents{"Foo=Bar\r\nFoo2=Baz42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz42"); } { std::istringstream contents{"Foo=Bar#Comment\r\nFoo2=Baz"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz"); } { std::istringstream contents{"Foo=Bar#Comment\nFoo2=Baz"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz"); } { std::istringstream contents{"Foo=Bar\nFoo2=Baz42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=Baz42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=${_Foo}42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Bar42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=${UnusedEnvironmentVariable}42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=${Invalid-Capture}42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "${Invalid-Capture}42"); } { std::istringstream contents{"Foo=${Foo2}Bar\r\nFoo2=42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "42"); } { pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("1")); std::istringstream contents{"Foo=${CORERUN_DOTENV_SELF_TEST}Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "1Bar"); pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("")); } { pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("4")); std::istringstream contents{"Foo=${CORERUN_DOTENV_SELF_TEST}Bar\r\nCORERUN_DOTENV_SELF_TEST=10"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "4Bar"); THROW_IF_FALSE(env._environmentVariables["CORERUN_DOTENV_SELF_TEST"] == "10"); pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("")); } { THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD")) == W("")); std::istringstream contents{"CORERUN_DOTENV_SELF_TEST_LOAD=20"}; dotenv env{ W("empty.env"), contents }; env.load_into_current_process(); THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD")) == W("20")); } { THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD2")) == W("")); pal::setenv(W("CORERUN_DOTENV_SELF_TEST_LOAD2"), W("25")); std::istringstream contents{"CORERUN_DOTENV_SELF_TEST_LOAD2=A"}; dotenv env{ W("empty.env"), contents }; env.load_into_current_process(); THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD2")) == W("A")); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #include "dotenv.hpp" #include <istream> #include <locale> #include <sstream> #include <algorithm> namespace { bool read_var_name(std::istream& file, std::string& var_name_out) { std::string var_name; char next; file.get(next); while (!file.eof() && isspace(next)) { file.get(next); } if (file.eof()) { return true; } if (next == '#') { // This is a comment, skip the line std::string comment; std::getline(file, comment); } bool key_quoted = next == '\''; if (key_quoted) { file.get(next); } if (!isalpha(next) && next != '_') { return false; } var_name.push_back(next); while (!file.eof()) { if (key_quoted && file.peek() == '\'') { break; } else if (file.peek() == '=') { break; } file.get(next); if (isspace(next)) { continue; } if (next == '#') { // Comments in names are unsupported return false; } if (!isalnum(next) && next != '_') { return false; } var_name.push_back(next); } if (key_quoted && file.get() == '\'') { while (!file.eof() && file.peek() != '=') { file.get(next); if (!isspace(next)) { return false; } } } if (!file.eof()) { // read the = sign (void)file.get(); } var_name_out = var_name; return !file.eof(); } bool check_endline(char current_char, int next_char) { return current_char == '\n' || (current_char == '\r' && next_char == '\n'); } void trim_from_end(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), [](char ch) { return !isspace(ch); }).base(), s.end()); } std::string read_substitution(std::istream& file, std::function<std::string(std::string)> substitution_lookup) { std::string substituted_variable_name; // Read the '{' character (void)file.get(); bool first = false; bool substitute_parse_failure = false; while (!file.eof() && file.peek() != '}') { char var_name_next; file.get(var_name_next); //If the name is not a valid environment variable name in the format, treat is as not a substitution. if (!((first && isalpha(var_name_next)) || isalnum(var_name_next)) && var_name_next != '_') { substitute_parse_failure = true; return std::string{ "${" } + std::move(substituted_variable_name) + std::string{ var_name_next }; } substituted_variable_name.push_back(var_name_next); first = false; } if (!file.eof() && !substitute_parse_failure && file.get() == '}') { return substitution_lookup(substituted_variable_name); } assert(file.eof()); return substituted_variable_name; } bool read_var_value(std::istream& file, std::function<std::string(std::string)> substitution_lookup, std::string& var_value_out) { std::string var_value; char next; file.get(next); while (!file.eof() && isspace(next)) { file.get(next); } if (file.eof()) { return false; } bool is_quoted = next == '\'' || next == '"'; char quote_char = is_quoted ? next : '\0'; bool can_substitute = next != '\''; if (next == '$') { var_value.append(read_substitution(file, substitution_lookup)); } else if (next == '#') { // The rest of the line is a comment. Therefore, the value of the environment variable is empty. var_value_out = var_value; return true; } else if (!is_quoted) { var_value.push_back(next); } while (!file.eof()) { file.get(next); if (file.eof()) { break; } else if (!is_quoted && next == '#') { // This is a comment, skip the rest of the line // and trim any whitespace from the end. std::string comment; std::getline(file, comment); trim_from_end(var_value); var_value_out = var_value; return true; } else if (!is_quoted && check_endline(next, file.eof() ? '\0' : file.peek())) { break; } else if (is_quoted && next == quote_char) { break; } else if (is_quoted && next == '\\') { int escaped = file.get(); if (file.eof()) { return false; } if (quote_char == '\'') { switch (escaped) { case '\\': case '\'': var_value.push_back((char)escaped); break; default: return false; } } else { assert(quote_char == '"'); switch (escaped) { case '\\': case '\'': case '"': var_value.push_back((char)escaped); break; case 'a': var_value.push_back('\a'); break; case 'b': var_value.push_back('\b'); break; case 'f': var_value.push_back('\f'); break; case 'n': var_value.push_back('\n'); break; case 'r': var_value.push_back('\r'); break; case 't': var_value.push_back('\t'); break; case 'v': var_value.push_back('\v'); break; default: return false; } } } else if (next == '$' && can_substitute && file.peek() == '{') { var_value.append(read_substitution(file, substitution_lookup)); } else { var_value.push_back(next); } } var_value_out = var_value; if (is_quoted) { file.get(next); while (!file.eof() && isspace(next)) { if (check_endline(next, file.eof() ? '\0' : file.peek())) { return true; } } return file.eof(); } return true; } } dotenv::dotenv(pal::string_t dotEnvFilePath, std::istream& contents) : _dotenvFilePath{dotEnvFilePath} , _environmentVariables{} { // Peek at the start to set the eof bit if the file is empty while (!contents.eof()) { std::string temp_name; std::string temp_value; if (!read_var_name(contents, temp_name)) { _environmentVariables = {}; break; } if (contents.eof()) { _environmentVariables = {}; break; } // Handle variable expansion scenarios if (!read_var_value(contents, [&](std::string name) { auto dot_env_entry = _environmentVariables.find(name); if (dot_env_entry != _environmentVariables.end()) { return dot_env_entry->second; } return pal::getenvA(name.c_str()); }, temp_value)) { _environmentVariables = {}; break; } _environmentVariables.emplace(temp_name, temp_value); } } void dotenv::load_into_current_process() const { for (std::pair<std::string, std::string> env_vars : _environmentVariables) { pal::string_utf8_t name_string = env_vars.first; pal::string_utf8_t value_string = env_vars.second; pal::setenvA(name_string.c_str(), std::move(value_string)); } } #define THROW_IF_FALSE(stmt) if (!(stmt)) throw W(#stmt); void dotenv::self_test() { { std::istringstream contents{""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables.size() == 0); } { std::istringstream contents{"Foo=Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=Bar # Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=\"Bar # Not a comment\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar # Not a comment"); } { std::istringstream contents{"Foo=# Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == ""); } { std::istringstream contents{"Foo# Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables.size() == 0); } { std::istringstream contents{"Foo=Bar#Comment"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=A"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "A"); } { std::istringstream contents{"Foo="}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == ""); } { std::istringstream contents{"Foo=\r\n"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == ""); } { std::istringstream contents{"A=Foo"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["A"] == "Foo"); } { std::istringstream contents{"Foo =Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{" Foo= Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"'Foo'= Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"'Foo' = Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{" 'Foo' = Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=\"Bar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= \"Bar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= \"Bar\" "}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo= 'Bar'"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo='Bar'"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo='Bar' "}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); } { std::istringstream contents{"Foo=\"\r\nBar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "\r\nBar"); } { std::istringstream contents{"Foo=\"\\r\\nBar\""}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "\r\nBar"); } { std::istringstream contents{"Foo=Bar\r\nFoo2=Baz42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz42"); } { std::istringstream contents{"Foo=Bar#Comment\r\nFoo2=Baz"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz"); } { std::istringstream contents{"Foo=Bar#Comment\nFoo2=Baz"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz"); } { std::istringstream contents{"Foo=Bar\nFoo2=Baz42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=Baz42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Baz42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=${_Foo}42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "Bar42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=${UnusedEnvironmentVariable}42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "42"); } { std::istringstream contents{"_Foo=Bar\r\nFoo2=${Invalid-Capture}42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["_Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "${Invalid-Capture}42"); } { std::istringstream contents{"Foo=${Foo2}Bar\r\nFoo2=42"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "Bar"); THROW_IF_FALSE(env._environmentVariables["Foo2"] == "42"); } { pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("1")); std::istringstream contents{"Foo=${CORERUN_DOTENV_SELF_TEST}Bar"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "1Bar"); pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("")); } { pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("4")); std::istringstream contents{"Foo=${CORERUN_DOTENV_SELF_TEST}Bar\r\nCORERUN_DOTENV_SELF_TEST=10"}; dotenv env{ W("empty.env"), contents }; THROW_IF_FALSE(env._environmentVariables["Foo"] == "4Bar"); THROW_IF_FALSE(env._environmentVariables["CORERUN_DOTENV_SELF_TEST"] == "10"); pal::setenv(W("CORERUN_DOTENV_SELF_TEST"), W("")); } { THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD")) == W("")); std::istringstream contents{"CORERUN_DOTENV_SELF_TEST_LOAD=20"}; dotenv env{ W("empty.env"), contents }; env.load_into_current_process(); THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD")) == W("20")); } { THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD2")) == W("")); pal::setenv(W("CORERUN_DOTENV_SELF_TEST_LOAD2"), W("25")); std::istringstream contents{"CORERUN_DOTENV_SELF_TEST_LOAD2=A"}; dotenv env{ W("empty.env"), contents }; env.load_into_current_process(); THROW_IF_FALSE(pal::getenv(W("CORERUN_DOTENV_SELF_TEST_LOAD2")) == W("A")); } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/mono/mono/tests/bug-81691.cs
using System; using System.IO; using System.Reflection; class Program { static int Main () { string assemblyFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "bug-81691-b.dll"); Assembly assembly = Assembly.LoadFile (assemblyFile); int i; int numExceptions = 0; for (i = 0; i < 100000; ++i) { try { try { Type type = assembly.GetType ("NS.B.TestB"); FieldInfo field =type.GetField ("testb", BindingFlags.NonPublic | BindingFlags.Static); if (field.FieldType == null) return 1; } catch (TypeLoadException ex) { ++numExceptions; } } catch (FileNotFoundException ex) { ++numExceptions; } } if (numExceptions == 100000) return 0; return 1; } }
using System; using System.IO; using System.Reflection; class Program { static int Main () { string assemblyFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "bug-81691-b.dll"); Assembly assembly = Assembly.LoadFile (assemblyFile); int i; int numExceptions = 0; for (i = 0; i < 100000; ++i) { try { try { Type type = assembly.GetType ("NS.B.TestB"); FieldInfo field =type.GetField ("testb", BindingFlags.NonPublic | BindingFlags.Static); if (field.FieldType == null) return 1; } catch (TypeLoadException ex) { ++numExceptions; } } catch (FileNotFoundException ex) { ++numExceptions; } } if (numExceptions == 100000) return 0; return 1; } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/Regression/JitBlue/DevDiv_471670/DevDiv_471670.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib{} .assembly 'DevDiv_471670'{} .assembly extern xunit.core {} .class ILGEN_CLASS { .method static bool ILGEN_METHOD(float64, char, unsigned int32) { .maxstack 65535 .locals init (float64, native unsigned int, unsigned int16, native int, unsigned int16, unsigned int8, int64, float64) ldarg.s 0x00 conv.ovf.u2 ldc.i8 0x5674a8efc99eac21 pop ldloc.s 0x02 conv.ovf.u1.un conv.ovf.u8.un conv.u8 conv.r4 pop ldarg.s 0x02 bgt IL_0037 ldloc.s 0x06 conv.ovf.u8.un ldloc 0x0006 clt.un neg brtrue IL_002b nop IL_002b: nop ldloc 0x0003 ldloc 0x0005 clt pop IL_0037: ldloc.s 0x04 brtrue IL_003f nop IL_003f: ldloc 0x0003 conv.ovf.i2.un ldarg.s 0x01 conv.r8 ldloc.s 0x00 ckfinite mul conv.r4 ldloc.s 0x00 conv.ovf.u8.un conv.r.un clt conv.i8 conv.i4 add.ovf starg.s 0x02 ldc.i8 0x953f9661d4ec7f53 neg neg ldloc.s 0x06 or neg conv.r.un ldc.i4 0x2f6100eb conv.r.un neg stloc 0x0000 ldarg 0x0000 neg neg ldloc.s 0x07 neg conv.r.un add cgt ret } .method static int32 Main() { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .try { ldc.r8 0 ldc.i4 0 dup call bool ILGEN_CLASS::ILGEN_METHOD(float64, char, unsigned int32) pop leave.s done } catch [mscorlib]System.Exception { leave.s done } done: ldc.i4 100 ret } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib{} .assembly 'DevDiv_471670'{} .assembly extern xunit.core {} .class ILGEN_CLASS { .method static bool ILGEN_METHOD(float64, char, unsigned int32) { .maxstack 65535 .locals init (float64, native unsigned int, unsigned int16, native int, unsigned int16, unsigned int8, int64, float64) ldarg.s 0x00 conv.ovf.u2 ldc.i8 0x5674a8efc99eac21 pop ldloc.s 0x02 conv.ovf.u1.un conv.ovf.u8.un conv.u8 conv.r4 pop ldarg.s 0x02 bgt IL_0037 ldloc.s 0x06 conv.ovf.u8.un ldloc 0x0006 clt.un neg brtrue IL_002b nop IL_002b: nop ldloc 0x0003 ldloc 0x0005 clt pop IL_0037: ldloc.s 0x04 brtrue IL_003f nop IL_003f: ldloc 0x0003 conv.ovf.i2.un ldarg.s 0x01 conv.r8 ldloc.s 0x00 ckfinite mul conv.r4 ldloc.s 0x00 conv.ovf.u8.un conv.r.un clt conv.i8 conv.i4 add.ovf starg.s 0x02 ldc.i8 0x953f9661d4ec7f53 neg neg ldloc.s 0x06 or neg conv.r.un ldc.i4 0x2f6100eb conv.r.un neg stloc 0x0000 ldarg 0x0000 neg neg ldloc.s 0x07 neg conv.r.un add cgt ret } .method static int32 Main() { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .try { ldc.r8 0 ldc.i4 0 dup call bool ILGEN_CLASS::ILGEN_METHOD(float64, char, unsigned int32) pop leave.s done } catch [mscorlib]System.Exception { leave.s done } done: ldc.i4 100 ret } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Runtime.Caching/System.Runtime.Caching.sln
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{4DD7C7A6-6F4C-497B-A836-20F2D4F66748}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{11CFC209-EA63-4492-8E76-017781F5FB61}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{974C8D15-BC21-4A49-8E36-788B6C7FE51A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Configuration.ConfigurationManager", "..\System.Configuration.ConfigurationManager\ref\System.Configuration.ConfigurationManager.csproj", "{D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Configuration.ConfigurationManager", "..\System.Configuration.ConfigurationManager\src\System.Configuration.ConfigurationManager.csproj", "{2AC9B23C-C788-4607-86EB-E7F66F14AFDB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{4607440C-7237-4077-ACAB-E0910673B162}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{460D6560-3CD4-4D2D-A961-407564D42D62}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Caching", "ref\System.Runtime.Caching.csproj", "{B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Caching", "src\System.Runtime.Caching.csproj", "{6311C025-F6D3-43A0-A9DA-A58AA6602568}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Caching.Tests", "tests\System.Runtime.Caching.Tests.csproj", "{AA05074D-88AF-482E-A44A-F1AC13494E9F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{ADDFECC7-59EA-4339-9B98-5CB8B91105BF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{447797DB-DF70-4568-A323-F88A45A91026}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.ProtectedData", "..\System.Security.Cryptography.ProtectedData\ref\System.Security.Cryptography.ProtectedData.csproj", "{986272FB-E5C6-4881-9867-DC3427D883AE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.ProtectedData", "..\System.Security.Cryptography.ProtectedData\src\System.Security.Cryptography.ProtectedData.csproj", "{AFBFBBE6-F5EC-4889-9F34-03E07562630D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{45E0A981-A131-4147-94E7-49AAC45F5D14}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{A154C9F1-845A-4596-9061-92C462E971A6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{EC5D61F1-E77B-4E3D-968C-710FCFB9E028}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{28BE2B3F-890C-45EF-B90A-9FA92302365E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{C315269F-EEA6-4F74-BA10-65ECAA6351C8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{5E28270B-1EEB-4D0E-9A3C-6959BEA9647E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Debug|Any CPU.Build.0 = Debug|Any CPU {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Release|Any CPU.ActiveCfg = Release|Any CPU {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Release|Any CPU.Build.0 = Release|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Debug|Any CPU.Build.0 = Debug|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Release|Any CPU.ActiveCfg = Release|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Release|Any CPU.Build.0 = Release|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Debug|Any CPU.Build.0 = Debug|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Release|Any CPU.ActiveCfg = Release|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Release|Any CPU.Build.0 = Release|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Release|Any CPU.Build.0 = Release|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Release|Any CPU.Build.0 = Release|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Debug|Any CPU.Build.0 = Debug|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Release|Any CPU.ActiveCfg = Release|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Release|Any CPU.Build.0 = Release|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Debug|Any CPU.Build.0 = Debug|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Release|Any CPU.ActiveCfg = Release|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Release|Any CPU.Build.0 = Release|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Release|Any CPU.Build.0 = Release|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Debug|Any CPU.Build.0 = Debug|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Release|Any CPU.ActiveCfg = Release|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Release|Any CPU.Build.0 = Release|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Release|Any CPU.Build.0 = Release|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Debug|Any CPU.Build.0 = Debug|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Release|Any CPU.Build.0 = Release|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Debug|Any CPU.Build.0 = Debug|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Release|Any CPU.ActiveCfg = Release|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Release|Any CPU.Build.0 = Release|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Release|Any CPU.Build.0 = Release|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Release|Any CPU.Build.0 = Release|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Debug|Any CPU.Build.0 = Debug|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Release|Any CPU.ActiveCfg = Release|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Release|Any CPU.Build.0 = Release|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Release|Any CPU.Build.0 = Release|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Release|Any CPU.Build.0 = Release|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {4DD7C7A6-6F4C-497B-A836-20F2D4F66748} = {28BE2B3F-890C-45EF-B90A-9FA92302365E} {AA05074D-88AF-482E-A44A-F1AC13494E9F} = {28BE2B3F-890C-45EF-B90A-9FA92302365E} {11CFC209-EA63-4492-8E76-017781F5FB61} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {4607440C-7237-4077-ACAB-E0910673B162} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {986272FB-E5C6-4881-9867-DC3427D883AE} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {45E0A981-A131-4147-94E7-49AAC45F5D14} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {A154C9F1-845A-4596-9061-92C462E971A6} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {974C8D15-BC21-4A49-8E36-788B6C7FE51A} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {2AC9B23C-C788-4607-86EB-E7F66F14AFDB} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {460D6560-3CD4-4D2D-A961-407564D42D62} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {6311C025-F6D3-43A0-A9DA-A58AA6602568} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {AFBFBBE6-F5EC-4889-9F34-03E07562630D} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {EC5D61F1-E77B-4E3D-968C-710FCFB9E028} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {ADDFECC7-59EA-4339-9B98-5CB8B91105BF} = {5E28270B-1EEB-4D0E-9A3C-6959BEA9647E} {447797DB-DF70-4568-A323-F88A45A91026} = {5E28270B-1EEB-4D0E-9A3C-6959BEA9647E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7B9B7D16-2C48-486A-B84B-6FF6D28509F6} EndGlobalSection EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{4DD7C7A6-6F4C-497B-A836-20F2D4F66748}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{11CFC209-EA63-4492-8E76-017781F5FB61}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{974C8D15-BC21-4A49-8E36-788B6C7FE51A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Configuration.ConfigurationManager", "..\System.Configuration.ConfigurationManager\ref\System.Configuration.ConfigurationManager.csproj", "{D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Configuration.ConfigurationManager", "..\System.Configuration.ConfigurationManager\src\System.Configuration.ConfigurationManager.csproj", "{2AC9B23C-C788-4607-86EB-E7F66F14AFDB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\ref\System.Drawing.Common.csproj", "{4607440C-7237-4077-ACAB-E0910673B162}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "..\System.Drawing.Common\src\System.Drawing.Common.csproj", "{460D6560-3CD4-4D2D-A961-407564D42D62}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Caching", "ref\System.Runtime.Caching.csproj", "{B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Caching", "src\System.Runtime.Caching.csproj", "{6311C025-F6D3-43A0-A9DA-A58AA6602568}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Caching.Tests", "tests\System.Runtime.Caching.Tests.csproj", "{AA05074D-88AF-482E-A44A-F1AC13494E9F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{ADDFECC7-59EA-4339-9B98-5CB8B91105BF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{447797DB-DF70-4568-A323-F88A45A91026}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.ProtectedData", "..\System.Security.Cryptography.ProtectedData\ref\System.Security.Cryptography.ProtectedData.csproj", "{986272FB-E5C6-4881-9867-DC3427D883AE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.ProtectedData", "..\System.Security.Cryptography.ProtectedData\src\System.Security.Cryptography.ProtectedData.csproj", "{AFBFBBE6-F5EC-4889-9F34-03E07562630D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\ref\System.Security.Permissions.csproj", "{45E0A981-A131-4147-94E7-49AAC45F5D14}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Permissions", "..\System.Security.Permissions\src\System.Security.Permissions.csproj", "{6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\ref\System.Windows.Extensions.csproj", "{A154C9F1-845A-4596-9061-92C462E971A6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Extensions", "..\System.Windows.Extensions\src\System.Windows.Extensions.csproj", "{EC5D61F1-E77B-4E3D-968C-710FCFB9E028}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{28BE2B3F-890C-45EF-B90A-9FA92302365E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{C315269F-EEA6-4F74-BA10-65ECAA6351C8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{5E28270B-1EEB-4D0E-9A3C-6959BEA9647E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Debug|Any CPU.Build.0 = Debug|Any CPU {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Release|Any CPU.ActiveCfg = Release|Any CPU {4DD7C7A6-6F4C-497B-A836-20F2D4F66748}.Release|Any CPU.Build.0 = Release|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Debug|Any CPU.Build.0 = Debug|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Release|Any CPU.ActiveCfg = Release|Any CPU {11CFC209-EA63-4492-8E76-017781F5FB61}.Release|Any CPU.Build.0 = Release|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Debug|Any CPU.Build.0 = Debug|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Release|Any CPU.ActiveCfg = Release|Any CPU {974C8D15-BC21-4A49-8E36-788B6C7FE51A}.Release|Any CPU.Build.0 = Release|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D}.Release|Any CPU.Build.0 = Release|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AC9B23C-C788-4607-86EB-E7F66F14AFDB}.Release|Any CPU.Build.0 = Release|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Debug|Any CPU.Build.0 = Debug|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Release|Any CPU.ActiveCfg = Release|Any CPU {4607440C-7237-4077-ACAB-E0910673B162}.Release|Any CPU.Build.0 = Release|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Debug|Any CPU.Build.0 = Debug|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Release|Any CPU.ActiveCfg = Release|Any CPU {460D6560-3CD4-4D2D-A961-407564D42D62}.Release|Any CPU.Build.0 = Release|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5}.Release|Any CPU.Build.0 = Release|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Debug|Any CPU.Build.0 = Debug|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Release|Any CPU.ActiveCfg = Release|Any CPU {6311C025-F6D3-43A0-A9DA-A58AA6602568}.Release|Any CPU.Build.0 = Release|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA05074D-88AF-482E-A44A-F1AC13494E9F}.Release|Any CPU.Build.0 = Release|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Debug|Any CPU.Build.0 = Debug|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {ADDFECC7-59EA-4339-9B98-5CB8B91105BF}.Release|Any CPU.Build.0 = Release|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Debug|Any CPU.Build.0 = Debug|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Release|Any CPU.ActiveCfg = Release|Any CPU {447797DB-DF70-4568-A323-F88A45A91026}.Release|Any CPU.Build.0 = Release|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {986272FB-E5C6-4881-9867-DC3427D883AE}.Release|Any CPU.Build.0 = Release|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFBFBBE6-F5EC-4889-9F34-03E07562630D}.Release|Any CPU.Build.0 = Release|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Debug|Any CPU.Build.0 = Debug|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Release|Any CPU.ActiveCfg = Release|Any CPU {45E0A981-A131-4147-94E7-49AAC45F5D14}.Release|Any CPU.Build.0 = Release|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8}.Release|Any CPU.Build.0 = Release|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {A154C9F1-845A-4596-9061-92C462E971A6}.Release|Any CPU.Build.0 = Release|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC5D61F1-E77B-4E3D-968C-710FCFB9E028}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {4DD7C7A6-6F4C-497B-A836-20F2D4F66748} = {28BE2B3F-890C-45EF-B90A-9FA92302365E} {AA05074D-88AF-482E-A44A-F1AC13494E9F} = {28BE2B3F-890C-45EF-B90A-9FA92302365E} {11CFC209-EA63-4492-8E76-017781F5FB61} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {D2CB0E92-8F52-49A3-A2CA-9F77C8ED4A6D} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {4607440C-7237-4077-ACAB-E0910673B162} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {B8D8A7D0-EAE7-4D04-97CA-7B14DA9D0BD5} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {986272FB-E5C6-4881-9867-DC3427D883AE} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {45E0A981-A131-4147-94E7-49AAC45F5D14} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {A154C9F1-845A-4596-9061-92C462E971A6} = {C315269F-EEA6-4F74-BA10-65ECAA6351C8} {974C8D15-BC21-4A49-8E36-788B6C7FE51A} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {2AC9B23C-C788-4607-86EB-E7F66F14AFDB} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {460D6560-3CD4-4D2D-A961-407564D42D62} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {6311C025-F6D3-43A0-A9DA-A58AA6602568} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {AFBFBBE6-F5EC-4889-9F34-03E07562630D} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {6383A7BA-20DC-4025-9BB3-E1C6FEA669E8} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {EC5D61F1-E77B-4E3D-968C-710FCFB9E028} = {7CAD8D92-ABBF-4ED8-ACF7-7121F99F89EC} {ADDFECC7-59EA-4339-9B98-5CB8B91105BF} = {5E28270B-1EEB-4D0E-9A3C-6959BEA9647E} {447797DB-DF70-4568-A323-F88A45A91026} = {5E28270B-1EEB-4D0E-9A3C-6959BEA9647E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7B9B7D16-2C48-486A-B84B-6FF6D28509F6} EndGlobalSection EndGlobal
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/Common/tests/System/Xml/XPath/CoreFunctionLibrary/BooleanFunctionsTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using System; using System.Xml; using System.Xml.XPath; using XPathTests.Common; namespace XPathTests.FunctionalTests.CoreFunctionLibrary { /// <summary> /// Core Function Library - Boolean Functions /// </summary> public static partial class BooleanFunctionsTests { /// <summary> /// Verify result. /// boolean(1) = true /// </summary> [Fact] public static void BooleanFunctionsTest251() { var xml = "dummy.xml"; var testExpression = @"boolean(1)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(0) = false /// </summary> [Fact] public static void BooleanFunctionsTest252() { var xml = "dummy.xml"; var testExpression = @"boolean(0)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// boolean(infinity) = true /// boolean(1 div 0) = true /// </summary> [Fact] public static void BooleanFunctionsTest253() { var xml = "dummy.xml"; var testExpression = @"boolean(1 div 0)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// boolean(NaN) = false /// boolean(0 div 0) = false /// </summary> [Fact] public static void BooleanFunctionsTest254() { var xml = "dummy.xml"; var testExpression = @"boolean(0 div 0)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(-0) = false /// </summary> [Fact] public static void BooleanFunctionsTest255() { var xml = "dummy.xml"; var testExpression = @"boolean(-0)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(2.5) = true /// </summary> [Fact] public static void BooleanFunctionsTest256() { var xml = "dummy.xml"; var testExpression = @"boolean(2.5)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean("test") = true /// </summary> [Fact] public static void BooleanFunctionsTest257() { var xml = "dummy.xml"; var testExpression = @"boolean(""Test"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean("") = false /// </summary> [Fact] public static void BooleanFunctionsTest258() { var xml = "dummy.xml"; var testExpression = @"boolean("""")"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(child::*) = true /// </summary> [Fact] public static void BooleanFunctionsTest259() { var xml = "xp004.xml"; var startingNodePath = "/Doc/Test2"; var testExpression = @"boolean(child::*)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Verify result. /// boolean(child::DoesNotExist) = false /// </summary> [Fact] public static void BooleanFunctionsTest2510() { var xml = "xp004.xml"; var startingNodePath = "/Doc/Test2"; var testExpression = @"boolean(child::DoesNotExist)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Verify result. /// not(false()) = true /// </summary> [Fact] public static void BooleanFunctionsTest2511() { var xml = "dummy.xml"; var testExpression = @"not(false())"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// not(true()) = false /// </summary> [Fact] public static void BooleanFunctionsTest2512() { var xml = "dummy.xml"; var testExpression = @"not(true())"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// not(boolean(child::*)) = false /// </summary> [Fact] public static void BooleanFunctionsTest2513() { var xml = "xp004.xml"; var startingNodePath = "/Doc/Test2"; var testExpression = @"not(boolean(child::*))"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Verify result. /// true() = true /// </summary> [Fact] public static void BooleanFunctionsTest2514() { var xml = "dummy.xml"; var testExpression = @"true()"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// false() = false /// </summary> [Fact] public static void BooleanFunctionsTest2515() { var xml = "dummy.xml"; var testExpression = @"false()"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// expected true /// lang("en") context node has xml:lang="en" /// </summary> [Fact] public static void BooleanFunctionsTest2516() { var xml = "lang.xml"; var startingNodePath = "/bookstore"; var testExpression = @"lang(""en"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// expected true /// lang("en") ancestor has xml:lang = "en" /// </summary> [Fact] public static void BooleanFunctionsTest2517() { var xml = "lang.xml"; var startingNodePath = "/bookstore/book[2]"; var testExpression = @"lang(""en"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// expected false /// lang("en-us") is a sub-category of xml-lang="en" /// </summary> [Fact] public static void BooleanFunctionsTest2518() { var xml = "lang.xml"; var startingNodePath = "/bookstore"; var testExpression = @"lang(""en-us"")"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// expected true /// lang("en") xml:lang = "en-us" is a sub category /// </summary> [Fact] public static void BooleanFunctionsTest2519() { var xml = "lang.xml"; var startingNodePath = "/bookstore/book[3]"; var testExpression = @"lang(""en"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// lang() should match ignoring case, expected : true /// lang("EN") context node has xml:lang = "en" /// </summary> [Fact] public static void BooleanFunctionsTest2520() { var xml = "lang.xml"; var startingNodePath = "/bookstore"; var testExpression = @"lang(""EN"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Code Coverage: Covers the case where lang() is used in an expression /// child::*[lang("en")] /// </summary> [Fact] public static void BooleanFunctionsTest2521() { var xml = "lang.xml"; var testExpression = @"child::*[lang(""en"")]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, HasAttributes = true, LocalName = "bookstore", Name = "bookstore", HasNameTable = true, Value = "\n\t\n\t\tSeven Years in Trenton\n\t\t\n\t\t\tJoe\n\t\t\tBob\n\t\t\tTrenton Literary Review Honorable Mention\n\t\t\tUSA\n\t\t\n\t\t12\n\t\n\t\n\t\tHistory of Trenton\n\t\t\n\t\t\tMary\n\t\t\tBob\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tJoeBob\n\t\t\t\tLoser\n\t\t\t\tUS\n\t\t\t\n\t\t\n\t\t55\n\t\n\t\n\t\tXQL The Golden Years\n\t\t\n\t\t\tMike\n\t\t\tHyman\n\t\t\t\n\t\t\t\tXQL For Dummies\n\t\t\t\tJonathan\n\t\t\t\tMarsh\n\t\t\t\n\t\t\n\t\t55.95\n\t\n\t\n\t\tRoad and Track\n\t\t3.50\n\t\t\n\t\tYes\n\t\n\t\n\t\tPC Week\n\t\tfree\n\t\tZiff Davis\n\t\n\t\n\t\tPC Magazine\n\t\t3.95\n\t\tZiff Davis\n\t\t\n\t\t\tCreate a dream PC\n\t\t\t\tCreate a list of needed hardware\n\t\t\t\n\t\t\tThe future of the web\n\t\t\t\tCan Netscape stay alive with Microsoft eating up its browser share?\n\t\t\t\tMSFT 99.30\n\t\t\t\t1998-06-23\n\t\t\t\n\t\t\tVisual Basic 5.0 - Will it stand the test of time?\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\tSport Cars - Can you really dream?\n\t\t\t\n\t\t\n\t\n\t\n\t\tPC Magazine Best Product of 1997\n\t\n\t\n\t\tHistory of Trenton 2\n\t\t\n\t\t\tMary F\n\t\t\tRobinson\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tMary F\n\t\t\t\tRobinson\n\t\t\t\n\t\t\n\t\t55\n\t\n\t\n\t\tHistory of Trenton Vol 3\n\t\t\n\t\t\tMary F\n\t\t\tRobinson\n\t\t\tFrank\n\t\t\tAnderson\n\t\t\tPulizer\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tMary F\n\t\t\t\tRobinson\n\t\t\t\n\t\t\n\t\t10\n\t\n\t\n\t\tHow To Fix Computers\n\t\t\n\t\t\tHack\n\t\t\ter\n\t\t\tPh.D.\n\t\t\n\t\t08\n\t\n\t\n\t\tTracking Trenton\n\t\t2.50\n\t\t\n\t\n\t\n\t\tTracking Trenton Stocks\n\t\t0.98\n\t\t\n\t\n\t\n\t\tTrenton Today, Trenton Tomorrow\n\t\t\n\t\t\tToni\n\t\t\tBob\n\t\t\tB.A.\n\t\t\tPh.D.\n\t\t\tPulizer\n\t\t\tStill in Trenton\n\t\t\tTrenton Forever\n\t\t\n\t\t6.50\n\t\t\n\t\t\tIt was a dark and stormy night.\n\t\t\tBut then all nights in Trenton seem dark and\n\t\t\tstormy to someone who has gone through what\n\t\t\tI have.\n\t\t\t\n\t\t\t\n\t\t\t\tTrenton\n\t\t\t\tmisery\n\t\t\t\n\t\t\n\t\n\t\n\t\tWho's Who in Trenton\n\t\tRobert Bob\n\t\n\t\n\t\tWhere is Trenton?\n\t\n\t\n\t\tWhere in the world is Trenton?\n\t\n", XmlLang = "en" }); Utils.XPathNodesetTest(xml, testExpression, expected); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using System; using System.Xml; using System.Xml.XPath; using XPathTests.Common; namespace XPathTests.FunctionalTests.CoreFunctionLibrary { /// <summary> /// Core Function Library - Boolean Functions /// </summary> public static partial class BooleanFunctionsTests { /// <summary> /// Verify result. /// boolean(1) = true /// </summary> [Fact] public static void BooleanFunctionsTest251() { var xml = "dummy.xml"; var testExpression = @"boolean(1)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(0) = false /// </summary> [Fact] public static void BooleanFunctionsTest252() { var xml = "dummy.xml"; var testExpression = @"boolean(0)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// boolean(infinity) = true /// boolean(1 div 0) = true /// </summary> [Fact] public static void BooleanFunctionsTest253() { var xml = "dummy.xml"; var testExpression = @"boolean(1 div 0)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// boolean(NaN) = false /// boolean(0 div 0) = false /// </summary> [Fact] public static void BooleanFunctionsTest254() { var xml = "dummy.xml"; var testExpression = @"boolean(0 div 0)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(-0) = false /// </summary> [Fact] public static void BooleanFunctionsTest255() { var xml = "dummy.xml"; var testExpression = @"boolean(-0)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(2.5) = true /// </summary> [Fact] public static void BooleanFunctionsTest256() { var xml = "dummy.xml"; var testExpression = @"boolean(2.5)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean("test") = true /// </summary> [Fact] public static void BooleanFunctionsTest257() { var xml = "dummy.xml"; var testExpression = @"boolean(""Test"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean("") = false /// </summary> [Fact] public static void BooleanFunctionsTest258() { var xml = "dummy.xml"; var testExpression = @"boolean("""")"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// boolean(child::*) = true /// </summary> [Fact] public static void BooleanFunctionsTest259() { var xml = "xp004.xml"; var startingNodePath = "/Doc/Test2"; var testExpression = @"boolean(child::*)"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Verify result. /// boolean(child::DoesNotExist) = false /// </summary> [Fact] public static void BooleanFunctionsTest2510() { var xml = "xp004.xml"; var startingNodePath = "/Doc/Test2"; var testExpression = @"boolean(child::DoesNotExist)"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Verify result. /// not(false()) = true /// </summary> [Fact] public static void BooleanFunctionsTest2511() { var xml = "dummy.xml"; var testExpression = @"not(false())"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// not(true()) = false /// </summary> [Fact] public static void BooleanFunctionsTest2512() { var xml = "dummy.xml"; var testExpression = @"not(true())"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// not(boolean(child::*)) = false /// </summary> [Fact] public static void BooleanFunctionsTest2513() { var xml = "xp004.xml"; var startingNodePath = "/Doc/Test2"; var testExpression = @"not(boolean(child::*))"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Verify result. /// true() = true /// </summary> [Fact] public static void BooleanFunctionsTest2514() { var xml = "dummy.xml"; var testExpression = @"true()"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// Verify result. /// false() = false /// </summary> [Fact] public static void BooleanFunctionsTest2515() { var xml = "dummy.xml"; var testExpression = @"false()"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected); } /// <summary> /// expected true /// lang("en") context node has xml:lang="en" /// </summary> [Fact] public static void BooleanFunctionsTest2516() { var xml = "lang.xml"; var startingNodePath = "/bookstore"; var testExpression = @"lang(""en"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// expected true /// lang("en") ancestor has xml:lang = "en" /// </summary> [Fact] public static void BooleanFunctionsTest2517() { var xml = "lang.xml"; var startingNodePath = "/bookstore/book[2]"; var testExpression = @"lang(""en"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// expected false /// lang("en-us") is a sub-category of xml-lang="en" /// </summary> [Fact] public static void BooleanFunctionsTest2518() { var xml = "lang.xml"; var startingNodePath = "/bookstore"; var testExpression = @"lang(""en-us"")"; var expected = false; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// expected true /// lang("en") xml:lang = "en-us" is a sub category /// </summary> [Fact] public static void BooleanFunctionsTest2519() { var xml = "lang.xml"; var startingNodePath = "/bookstore/book[3]"; var testExpression = @"lang(""en"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// lang() should match ignoring case, expected : true /// lang("EN") context node has xml:lang = "en" /// </summary> [Fact] public static void BooleanFunctionsTest2520() { var xml = "lang.xml"; var startingNodePath = "/bookstore"; var testExpression = @"lang(""EN"")"; var expected = true; Utils.XPathBooleanTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Code Coverage: Covers the case where lang() is used in an expression /// child::*[lang("en")] /// </summary> [Fact] public static void BooleanFunctionsTest2521() { var xml = "lang.xml"; var testExpression = @"child::*[lang(""en"")]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, HasAttributes = true, LocalName = "bookstore", Name = "bookstore", HasNameTable = true, Value = "\n\t\n\t\tSeven Years in Trenton\n\t\t\n\t\t\tJoe\n\t\t\tBob\n\t\t\tTrenton Literary Review Honorable Mention\n\t\t\tUSA\n\t\t\n\t\t12\n\t\n\t\n\t\tHistory of Trenton\n\t\t\n\t\t\tMary\n\t\t\tBob\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tJoeBob\n\t\t\t\tLoser\n\t\t\t\tUS\n\t\t\t\n\t\t\n\t\t55\n\t\n\t\n\t\tXQL The Golden Years\n\t\t\n\t\t\tMike\n\t\t\tHyman\n\t\t\t\n\t\t\t\tXQL For Dummies\n\t\t\t\tJonathan\n\t\t\t\tMarsh\n\t\t\t\n\t\t\n\t\t55.95\n\t\n\t\n\t\tRoad and Track\n\t\t3.50\n\t\t\n\t\tYes\n\t\n\t\n\t\tPC Week\n\t\tfree\n\t\tZiff Davis\n\t\n\t\n\t\tPC Magazine\n\t\t3.95\n\t\tZiff Davis\n\t\t\n\t\t\tCreate a dream PC\n\t\t\t\tCreate a list of needed hardware\n\t\t\t\n\t\t\tThe future of the web\n\t\t\t\tCan Netscape stay alive with Microsoft eating up its browser share?\n\t\t\t\tMSFT 99.30\n\t\t\t\t1998-06-23\n\t\t\t\n\t\t\tVisual Basic 5.0 - Will it stand the test of time?\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\tSport Cars - Can you really dream?\n\t\t\t\n\t\t\n\t\n\t\n\t\tPC Magazine Best Product of 1997\n\t\n\t\n\t\tHistory of Trenton 2\n\t\t\n\t\t\tMary F\n\t\t\tRobinson\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tMary F\n\t\t\t\tRobinson\n\t\t\t\n\t\t\n\t\t55\n\t\n\t\n\t\tHistory of Trenton Vol 3\n\t\t\n\t\t\tMary F\n\t\t\tRobinson\n\t\t\tFrank\n\t\t\tAnderson\n\t\t\tPulizer\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tMary F\n\t\t\t\tRobinson\n\t\t\t\n\t\t\n\t\t10\n\t\n\t\n\t\tHow To Fix Computers\n\t\t\n\t\t\tHack\n\t\t\ter\n\t\t\tPh.D.\n\t\t\n\t\t08\n\t\n\t\n\t\tTracking Trenton\n\t\t2.50\n\t\t\n\t\n\t\n\t\tTracking Trenton Stocks\n\t\t0.98\n\t\t\n\t\n\t\n\t\tTrenton Today, Trenton Tomorrow\n\t\t\n\t\t\tToni\n\t\t\tBob\n\t\t\tB.A.\n\t\t\tPh.D.\n\t\t\tPulizer\n\t\t\tStill in Trenton\n\t\t\tTrenton Forever\n\t\t\n\t\t6.50\n\t\t\n\t\t\tIt was a dark and stormy night.\n\t\t\tBut then all nights in Trenton seem dark and\n\t\t\tstormy to someone who has gone through what\n\t\t\tI have.\n\t\t\t\n\t\t\t\n\t\t\t\tTrenton\n\t\t\t\tmisery\n\t\t\t\n\t\t\n\t\n\t\n\t\tWho's Who in Trenton\n\t\tRobert Bob\n\t\n\t\n\t\tWhere is Trenton?\n\t\n\t\n\t\tWhere in the world is Trenton?\n\t\n", XmlLang = "en" }); Utils.XPathNodesetTest(xml, testExpression, expected); } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> <IsPartialFacadeAssembly>true</IsPartialFacadeAssembly> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <Reference Include="System.Runtime" /> <Reference Include="System.Security.Cryptography" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> <IsPartialFacadeAssembly>true</IsPartialFacadeAssembly> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <Reference Include="System.Runtime" /> <Reference Include="System.Security.Cryptography" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/IntegerValidator.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Configuration { public class IntegerValidator : ConfigurationValidatorBase { private readonly ValidationFlags _flags; private readonly int _maxValue; private readonly int _minValue; private readonly int _resolution; public IntegerValidator(int minValue, int maxValue) : this(minValue, maxValue, false, 1) { } public IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive) : this(minValue, maxValue, rangeIsExclusive, 1) { } public IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive, int resolution) { if (resolution <= 0) throw new ArgumentOutOfRangeException(nameof(resolution)); if (minValue > maxValue) throw new ArgumentOutOfRangeException(nameof(minValue), SR.Validator_min_greater_than_max); _minValue = minValue; _maxValue = maxValue; _resolution = resolution; _flags = rangeIsExclusive ? ValidationFlags.ExclusiveRange : ValidationFlags.None; } public override bool CanValidate(Type type) { return type == typeof(int); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(int)); ValidatorUtils.ValidateScalar((int)value, _minValue, _maxValue, _resolution, _flags == ValidationFlags.ExclusiveRange); } private enum ValidationFlags { None = 0x0000, ExclusiveRange = 0x0001, // If set the value must be outside of the range instead of inside } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Configuration { public class IntegerValidator : ConfigurationValidatorBase { private readonly ValidationFlags _flags; private readonly int _maxValue; private readonly int _minValue; private readonly int _resolution; public IntegerValidator(int minValue, int maxValue) : this(minValue, maxValue, false, 1) { } public IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive) : this(minValue, maxValue, rangeIsExclusive, 1) { } public IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive, int resolution) { if (resolution <= 0) throw new ArgumentOutOfRangeException(nameof(resolution)); if (minValue > maxValue) throw new ArgumentOutOfRangeException(nameof(minValue), SR.Validator_min_greater_than_max); _minValue = minValue; _maxValue = maxValue; _resolution = resolution; _flags = rangeIsExclusive ? ValidationFlags.ExclusiveRange : ValidationFlags.None; } public override bool CanValidate(Type type) { return type == typeof(int); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(int)); ValidatorUtils.ValidateScalar((int)value, _minValue, _maxValue, _resolution, _flags == ValidationFlags.ExclusiveRange); } private enum ValidationFlags { None = 0x0000, ExclusiveRange = 0x0001, // If set the value must be outside of the range instead of inside } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Data.DataSetExtensions/tests/Mono/EnumerableRowCollectionTest.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // EnumerableRowCollectionTest.cs // // Author: // Atsushi Enomoto <[email protected]> // // Copyright (C) 2008 Novell, Inc. http://www.novell.com // // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.Data; using Xunit; namespace MonoTests.System.Data { public class EnumerableRowCollectionTest { private string _testDataSet = "Mono/testdataset1.xml"; [Fact] public void QueryWhere() { var ds = new DataSet(); ds.ReadXml(_testDataSet); var table = ds.Tables[0]; /* schema generated as ... var table = ds.Tables.Add ("ScoreList"); table.Columns.Add ("ID", typeof (int)); table.Columns.Add ("RegisteredDate", typeof (DateTime)); table.Columns.Add ("Name", typeof (string)); table.Columns.Add ("Score", typeof (int)); ds.WriteXml ("Test/System.Data/testdataset1.xsd", XmlWriteMode.WriteSchema); */ var q = from line in table.AsEnumerable() where line.Field<int>("Score") > 80 select line; bool iterated = false; foreach (var line in q) { if (iterated) Assert.True(false, "should match only one raw"); Assert.Equal(100, line["Score"]); iterated = true; } } [Fact] public void QueryWhereSelect () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") > 80 select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; bool iterated = false; foreach (var ql in q) { if (iterated) Assert.True(false, "should match only one raw"); Assert.Equal(100, ql.StudentScore); iterated = true; } } [Fact] public void QueryWhereSelectOrderBy () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<int> ("ID") select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(1, ql.StudentID); break; case 1: Assert.Equal(4, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } [Fact] public void QueryWhereSelectOrderByDescending () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<int> ("ID") descending select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(4, ql.StudentID); break; case 4: Assert.Equal(1, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } [Fact] public void ThenBy () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<bool> ("Gender"), line.Field<int> ("ID") select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(1, ql.StudentID); break; case 1: Assert.Equal(4, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } [Fact] public void ThenByDescending () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<bool> ("Gender"), line.Field<int> ("ID") descending select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(4, ql.StudentID); break; case 4: Assert.Equal(1, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // EnumerableRowCollectionTest.cs // // Author: // Atsushi Enomoto <[email protected]> // // Copyright (C) 2008 Novell, Inc. http://www.novell.com // // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.Data; using Xunit; namespace MonoTests.System.Data { public class EnumerableRowCollectionTest { private string _testDataSet = "Mono/testdataset1.xml"; [Fact] public void QueryWhere() { var ds = new DataSet(); ds.ReadXml(_testDataSet); var table = ds.Tables[0]; /* schema generated as ... var table = ds.Tables.Add ("ScoreList"); table.Columns.Add ("ID", typeof (int)); table.Columns.Add ("RegisteredDate", typeof (DateTime)); table.Columns.Add ("Name", typeof (string)); table.Columns.Add ("Score", typeof (int)); ds.WriteXml ("Test/System.Data/testdataset1.xsd", XmlWriteMode.WriteSchema); */ var q = from line in table.AsEnumerable() where line.Field<int>("Score") > 80 select line; bool iterated = false; foreach (var line in q) { if (iterated) Assert.True(false, "should match only one raw"); Assert.Equal(100, line["Score"]); iterated = true; } } [Fact] public void QueryWhereSelect () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") > 80 select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; bool iterated = false; foreach (var ql in q) { if (iterated) Assert.True(false, "should match only one raw"); Assert.Equal(100, ql.StudentScore); iterated = true; } } [Fact] public void QueryWhereSelectOrderBy () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<int> ("ID") select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(1, ql.StudentID); break; case 1: Assert.Equal(4, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } [Fact] public void QueryWhereSelectOrderByDescending () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<int> ("ID") descending select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(4, ql.StudentID); break; case 4: Assert.Equal(1, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } [Fact] public void ThenBy () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<bool> ("Gender"), line.Field<int> ("ID") select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(1, ql.StudentID); break; case 1: Assert.Equal(4, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } [Fact] public void ThenByDescending () { var ds = new DataSet (); ds.ReadXml (_testDataSet); var table = ds.Tables [0]; var q = from line in table.AsEnumerable () where line.Field<int> ("Score") >= 80 orderby line.Field<bool> ("Gender"), line.Field<int> ("ID") descending select new { StudentID = line.Field<int> ("ID"), StudentName = line.Field<string> ("Name"), StudentScore = line.Field<int> ("Score") }; int prevID = -1; foreach (var ql in q) { switch (prevID) { case -1: Assert.Equal(4, ql.StudentID); break; case 4: Assert.Equal(1, ql.StudentID); break; default: Assert.True(false, "should match only one raw"); break; } prevID = ql.StudentID; } } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Net.HttpListener/tests/HttpListenerResponseTests.Cookies.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; namespace System.Net.Tests { [SkipOnCoreClr("System.Net.Tests may timeout in stress configurations", ~RuntimeConfiguration.Release)] [ActiveIssue("https://github.com/dotnet/runtime/issues/2391", TestRuntimes.Mono)] [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // httpsys component missing in Nano. public class HttpListenerResponseCookiesTests : HttpListenerResponseTestBase { [Fact] public async Task Cookies_GetSet_ReturnsExpected() { HttpListenerResponse response = await GetResponse(); Assert.Same(response.Cookies, response.Cookies); Assert.Empty(response.Cookies); var cookies = new CookieCollection() { new Cookie("name", "value") }; response.Cookies = cookies; Assert.Equal(cookies, response.Cookies); response.Cookies = null; Assert.Empty(response.Cookies); } public static IEnumerable<object[]> Cookies_TestData() { yield return new object[] { new CookieCollection() { new Cookie() }, 120, null, null }; yield return new object[] { new CookieCollection() { new Cookie(), new Cookie("name", "value") }, 144, "Set-Cookie: name=value", null }; yield return new object[] { new CookieCollection() { new Cookie("name", "value") }, 144, "Set-Cookie: name=value", null }; yield return new object[] { new CookieCollection() { new Cookie("foo bar", "value") }, 147, "Set-Cookie: foo bar=value", null }; yield return new object[] { new CookieCollection() { new Cookie("name1", "value1"), new Cookie("name2", "value2") }, 160, "Set-Cookie: name1=value1, name2=value2", null }; yield return new object[] { new CookieCollection() { new Cookie("name1", "value1") { Port = "\"200\"" }, new Cookie("name2", "value2") { Port = "\"300\"" }, }, 207, null, "Set-Cookie2: name1=value1; Port=\"200\"; Version=1, name2=value2; Port=\"300\"; Version=1" }; yield return new object[] { new CookieCollection() { new Cookie("name1", "value1"), new Cookie("name2", "value2") { Port = "\"300\"" }, }, 196, "Set-Cookie: name1=value1", "Set-Cookie2: name2=value2; Port=\"300\"; Version=1" }; } [Theory] [MemberData(nameof(Cookies_TestData))] public async Task Cookies_SetAndSend_ClientReceivesExpectedHeaders(CookieCollection cookies, int expectedBytes, string expectedSetCookie, string expectedSetCookie2) { HttpListenerResponse response = await GetResponse(); response.Cookies = cookies; response.Close(); Assert.Equal(expectedSetCookie?.Replace("Set-Cookie: ", ""), response.Headers["Set-Cookie"]); Assert.Equal(expectedSetCookie2?.Replace("Set-Cookie2: ", ""), response.Headers["Set-Cookie2"]); string clientResponse = GetClientResponse(expectedBytes); if (expectedSetCookie != null) { Assert.Contains($"\r\n{expectedSetCookie}\r\n", clientResponse); } else { Assert.DoesNotContain("Set-Cookie:", clientResponse); } if (expectedSetCookie2 != null) { Assert.Contains($"\r\n{expectedSetCookie2}\r\n", clientResponse); } else { Assert.DoesNotContain("Set-Cookie2:", clientResponse); } } [Fact] public async Task Cookies_SetInHeader_ClientReceivesExpectedHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers["Set-Cookie"] = "name1=value1"; response.Headers["Set-Cookie2"] = "name2=value2"; response.Close(); string clientResponse = GetClientResponse(expectedLength:173); Assert.Contains("\r\nSet-Cookie: name1=value1\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie2: name2=value2\r\n", clientResponse); } [Fact] public async Task Cookies_SetCookie2InHeadersButNotInCookies_RemovesFromHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers["Set-Cookie"] = "name1=value2"; response.Headers["Set-Cookie2"] = "name2=value2"; response.Cookies.Add(new Cookie("name3", "value3") { Port = "\"200\"" }); response.Close(); Assert.Null(response.Headers["Set-Cookie"]); Assert.Equal("name3=value3; Port=\"200\"; Version=1", response.Headers["Set-Cookie2"]); string clientResponse = GetClientResponse(expectedLength:170); Assert.DoesNotContain("Set-Cookie:", clientResponse); Assert.Contains("\r\nSet-Cookie2: name3=value3; Port=\"200\"; Version=1\r\n", clientResponse); } [Fact] public async Task Cookies_SetCookieInHeadersButNotInCookies_RemovesFromHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers["Set-Cookie"] = "name1=value2"; response.Headers["Set-Cookie2"] = "name2=value2"; response.Cookies.Add(new Cookie("name3", "value3")); response.Close(); Assert.Equal("name3=value3", response.Headers["Set-Cookie"]); Assert.Null(response.Headers["Set-Cookie2"]); string clientResponse = GetClientResponse(expectedLength:146); Assert.Contains("\r\nSet-Cookie: name3=value3\r\n", clientResponse); Assert.DoesNotContain("Set-Cookie2", clientResponse); } [Fact] public async Task Cookies_AddMultipleInHeader_ClientReceivesExpectedHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers.Add("Set-Cookie", "name1=value1"); response.Headers.Add("Set-Cookie", "name2=value2"); response.Headers.Add("Set-Cookie", "name3=value3"); response.Headers.Add("Set-Cookie", "name4=value4"); response.Close(); string clientResponse = GetClientResponse(expectedLength:224); Assert.Contains("\r\nSet-Cookie: name1=value1\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie: name2=value2\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie: name3=value3\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie: name4=value4\r\n", clientResponse); } [Fact] public async Task AppendCookie_ValidCookie_AddsCookieToCollection() { HttpListenerResponse response = await GetResponse(); var cookie1 = new Cookie("name1", "value"); var cookie2 = new Cookie("name2", "value2"); response.AppendCookie(cookie1); response.AppendCookie(cookie2); Assert.Equal(new Cookie[] { cookie1, cookie2 }, response.Cookies.Cast<Cookie>()); var cookie3 = new Cookie("name1", "value2"); response.AppendCookie(cookie3); Assert.Equal(new Cookie[] { cookie3, cookie2 }, response.Cookies.Cast<Cookie>()); // Cookies are not cloned. cookie3.Value = "value3"; Assert.Equal("value3", response.Cookies[0].Value); } [Fact] public async Task AppendCookie_NullCookie_ThrowsArgumentNullException() { HttpListenerResponse response = await GetResponse(); AssertExtensions.Throws<ArgumentNullException>("cookie", () => response.AppendCookie(null)); } [Fact] public async Task SetCookie_ValidCookie_AddsCookieToCollection() { HttpListenerResponse response = await GetResponse(); var cookie1 = new Cookie("name1", "value1"); var cookie2 = new Cookie("name2", "value2"); response.SetCookie(cookie1); response.SetCookie(cookie2); Assert.Equal(new Cookie[] { cookie1, cookie2 }, response.Cookies.Cast<Cookie>()); } [Fact] public async Task SetCookie_ValidCookie_ClonesCookie() { HttpListenerResponse response = await GetResponse(); var cookie = new Cookie("name", "value"); response.SetCookie(cookie); // Cookies are cloned. cookie.Value = "value3"; Assert.Equal("value", response.Cookies[0].Value); } [Fact] public async Task SetCookie_NullCookie_ThrowsArgumentNullException() { HttpListenerResponse response = await GetResponse(); AssertExtensions.Throws<ArgumentNullException>("cookie", () => response.SetCookie(null)); } [Fact] public async Task SetCookie_CookieDoesntExist_ThrowsArgumentException() { HttpListenerResponse response = await GetResponse(); var cookie1 = new Cookie("name", "value"); response.SetCookie(cookie1); AssertExtensions.Throws<ArgumentException>("cookie", () => response.SetCookie(cookie1)); var cookie2 = new Cookie("name", "value2"); AssertExtensions.Throws<ArgumentException>("cookie", () => response.SetCookie(cookie2)); Assert.Equal(new Cookie[] { cookie2 }, response.Cookies.Cast<Cookie>()); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; namespace System.Net.Tests { [SkipOnCoreClr("System.Net.Tests may timeout in stress configurations", ~RuntimeConfiguration.Release)] [ActiveIssue("https://github.com/dotnet/runtime/issues/2391", TestRuntimes.Mono)] [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // httpsys component missing in Nano. public class HttpListenerResponseCookiesTests : HttpListenerResponseTestBase { [Fact] public async Task Cookies_GetSet_ReturnsExpected() { HttpListenerResponse response = await GetResponse(); Assert.Same(response.Cookies, response.Cookies); Assert.Empty(response.Cookies); var cookies = new CookieCollection() { new Cookie("name", "value") }; response.Cookies = cookies; Assert.Equal(cookies, response.Cookies); response.Cookies = null; Assert.Empty(response.Cookies); } public static IEnumerable<object[]> Cookies_TestData() { yield return new object[] { new CookieCollection() { new Cookie() }, 120, null, null }; yield return new object[] { new CookieCollection() { new Cookie(), new Cookie("name", "value") }, 144, "Set-Cookie: name=value", null }; yield return new object[] { new CookieCollection() { new Cookie("name", "value") }, 144, "Set-Cookie: name=value", null }; yield return new object[] { new CookieCollection() { new Cookie("foo bar", "value") }, 147, "Set-Cookie: foo bar=value", null }; yield return new object[] { new CookieCollection() { new Cookie("name1", "value1"), new Cookie("name2", "value2") }, 160, "Set-Cookie: name1=value1, name2=value2", null }; yield return new object[] { new CookieCollection() { new Cookie("name1", "value1") { Port = "\"200\"" }, new Cookie("name2", "value2") { Port = "\"300\"" }, }, 207, null, "Set-Cookie2: name1=value1; Port=\"200\"; Version=1, name2=value2; Port=\"300\"; Version=1" }; yield return new object[] { new CookieCollection() { new Cookie("name1", "value1"), new Cookie("name2", "value2") { Port = "\"300\"" }, }, 196, "Set-Cookie: name1=value1", "Set-Cookie2: name2=value2; Port=\"300\"; Version=1" }; } [Theory] [MemberData(nameof(Cookies_TestData))] public async Task Cookies_SetAndSend_ClientReceivesExpectedHeaders(CookieCollection cookies, int expectedBytes, string expectedSetCookie, string expectedSetCookie2) { HttpListenerResponse response = await GetResponse(); response.Cookies = cookies; response.Close(); Assert.Equal(expectedSetCookie?.Replace("Set-Cookie: ", ""), response.Headers["Set-Cookie"]); Assert.Equal(expectedSetCookie2?.Replace("Set-Cookie2: ", ""), response.Headers["Set-Cookie2"]); string clientResponse = GetClientResponse(expectedBytes); if (expectedSetCookie != null) { Assert.Contains($"\r\n{expectedSetCookie}\r\n", clientResponse); } else { Assert.DoesNotContain("Set-Cookie:", clientResponse); } if (expectedSetCookie2 != null) { Assert.Contains($"\r\n{expectedSetCookie2}\r\n", clientResponse); } else { Assert.DoesNotContain("Set-Cookie2:", clientResponse); } } [Fact] public async Task Cookies_SetInHeader_ClientReceivesExpectedHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers["Set-Cookie"] = "name1=value1"; response.Headers["Set-Cookie2"] = "name2=value2"; response.Close(); string clientResponse = GetClientResponse(expectedLength:173); Assert.Contains("\r\nSet-Cookie: name1=value1\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie2: name2=value2\r\n", clientResponse); } [Fact] public async Task Cookies_SetCookie2InHeadersButNotInCookies_RemovesFromHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers["Set-Cookie"] = "name1=value2"; response.Headers["Set-Cookie2"] = "name2=value2"; response.Cookies.Add(new Cookie("name3", "value3") { Port = "\"200\"" }); response.Close(); Assert.Null(response.Headers["Set-Cookie"]); Assert.Equal("name3=value3; Port=\"200\"; Version=1", response.Headers["Set-Cookie2"]); string clientResponse = GetClientResponse(expectedLength:170); Assert.DoesNotContain("Set-Cookie:", clientResponse); Assert.Contains("\r\nSet-Cookie2: name3=value3; Port=\"200\"; Version=1\r\n", clientResponse); } [Fact] public async Task Cookies_SetCookieInHeadersButNotInCookies_RemovesFromHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers["Set-Cookie"] = "name1=value2"; response.Headers["Set-Cookie2"] = "name2=value2"; response.Cookies.Add(new Cookie("name3", "value3")); response.Close(); Assert.Equal("name3=value3", response.Headers["Set-Cookie"]); Assert.Null(response.Headers["Set-Cookie2"]); string clientResponse = GetClientResponse(expectedLength:146); Assert.Contains("\r\nSet-Cookie: name3=value3\r\n", clientResponse); Assert.DoesNotContain("Set-Cookie2", clientResponse); } [Fact] public async Task Cookies_AddMultipleInHeader_ClientReceivesExpectedHeaders() { HttpListenerResponse response = await GetResponse(); response.Headers.Add("Set-Cookie", "name1=value1"); response.Headers.Add("Set-Cookie", "name2=value2"); response.Headers.Add("Set-Cookie", "name3=value3"); response.Headers.Add("Set-Cookie", "name4=value4"); response.Close(); string clientResponse = GetClientResponse(expectedLength:224); Assert.Contains("\r\nSet-Cookie: name1=value1\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie: name2=value2\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie: name3=value3\r\n", clientResponse); Assert.Contains("\r\nSet-Cookie: name4=value4\r\n", clientResponse); } [Fact] public async Task AppendCookie_ValidCookie_AddsCookieToCollection() { HttpListenerResponse response = await GetResponse(); var cookie1 = new Cookie("name1", "value"); var cookie2 = new Cookie("name2", "value2"); response.AppendCookie(cookie1); response.AppendCookie(cookie2); Assert.Equal(new Cookie[] { cookie1, cookie2 }, response.Cookies.Cast<Cookie>()); var cookie3 = new Cookie("name1", "value2"); response.AppendCookie(cookie3); Assert.Equal(new Cookie[] { cookie3, cookie2 }, response.Cookies.Cast<Cookie>()); // Cookies are not cloned. cookie3.Value = "value3"; Assert.Equal("value3", response.Cookies[0].Value); } [Fact] public async Task AppendCookie_NullCookie_ThrowsArgumentNullException() { HttpListenerResponse response = await GetResponse(); AssertExtensions.Throws<ArgumentNullException>("cookie", () => response.AppendCookie(null)); } [Fact] public async Task SetCookie_ValidCookie_AddsCookieToCollection() { HttpListenerResponse response = await GetResponse(); var cookie1 = new Cookie("name1", "value1"); var cookie2 = new Cookie("name2", "value2"); response.SetCookie(cookie1); response.SetCookie(cookie2); Assert.Equal(new Cookie[] { cookie1, cookie2 }, response.Cookies.Cast<Cookie>()); } [Fact] public async Task SetCookie_ValidCookie_ClonesCookie() { HttpListenerResponse response = await GetResponse(); var cookie = new Cookie("name", "value"); response.SetCookie(cookie); // Cookies are cloned. cookie.Value = "value3"; Assert.Equal("value", response.Cookies[0].Value); } [Fact] public async Task SetCookie_NullCookie_ThrowsArgumentNullException() { HttpListenerResponse response = await GetResponse(); AssertExtensions.Throws<ArgumentNullException>("cookie", () => response.SetCookie(null)); } [Fact] public async Task SetCookie_CookieDoesntExist_ThrowsArgumentException() { HttpListenerResponse response = await GetResponse(); var cookie1 = new Cookie("name", "value"); response.SetCookie(cookie1); AssertExtensions.Throws<ArgumentException>("cookie", () => response.SetCookie(cookie1)); var cookie2 = new Cookie("name", "value2"); AssertExtensions.Throws<ArgumentException>("cookie", () => response.SetCookie(cookie2)); Assert.Equal(new Cookie[] { cookie2 }, response.Cookies.Cast<Cookie>()); } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfoEnumerator.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; using System.Diagnostics; namespace System.Security.Cryptography.Pkcs { public sealed class SignerInfoEnumerator : IEnumerator { private readonly SignerInfoCollection _signerInfos; private int _position; internal SignerInfoEnumerator(SignerInfoCollection signerInfos) { Debug.Assert(signerInfos != null); _signerInfos = signerInfos; _position = -1; } public SignerInfo Current => _signerInfos[_position]; object IEnumerator.Current => _signerInfos[_position]; public bool MoveNext() { int next = _position + 1; if (next >= _signerInfos.Count) return false; _position = next; return true; } public void Reset() { _position = -1; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; using System.Diagnostics; namespace System.Security.Cryptography.Pkcs { public sealed class SignerInfoEnumerator : IEnumerator { private readonly SignerInfoCollection _signerInfos; private int _position; internal SignerInfoEnumerator(SignerInfoCollection signerInfos) { Debug.Assert(signerInfos != null); _signerInfos = signerInfos; _position = -1; } public SignerInfo Current => _signerInfos[_position]; object IEnumerator.Current => _signerInfos[_position]; public bool MoveNext() { int next = _position + 1; if (next >= _signerInfos.Count) return false; _position = next; return true; } public void Reset() { _position = -1; } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Data.Common; using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { /// <summary> /// Represents an 8-bit unsigned integer to be stored in /// or retrieved from a database. /// </summary> [Serializable] [StructLayout(LayoutKind.Sequential)] [XmlSchemaProvider("GetXsdType")] [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct SqlByte : INullable, IComparable, IXmlSerializable, IEquatable<SqlByte> { private bool m_fNotNull; // false if null. Do not rename (binary serialization) private byte m_value; // Do not rename (binary serialization) private const int s_iBitNotByteMax = ~0xff; // constructor // construct a Null private SqlByte(bool fNull) { m_fNotNull = false; m_value = 0; } public SqlByte(byte value) { m_value = value; m_fNotNull = true; } // INullable public bool IsNull { get { return !m_fNotNull; } } // property: Value public byte Value { get { if (m_fNotNull) return m_value; else throw new SqlNullValueException(); } } // Implicit conversion from byte to SqlByte public static implicit operator SqlByte(byte x) { return new SqlByte(x); } // Explicit conversion from SqlByte to byte. Throw exception if x is Null. public static explicit operator byte(SqlByte x) { return x.Value; } public override string ToString() { return IsNull ? SQLResource.NullString : m_value.ToString((IFormatProvider)null!); } public static SqlByte Parse(string s) { if (s == SQLResource.NullString) return SqlByte.Null; else return new SqlByte(byte.Parse(s, null)); } // Unary operators public static SqlByte operator ~(SqlByte x) { return x.IsNull ? Null : new SqlByte(unchecked((byte)~x.m_value)); } // Binary operators // Arithmetic operators public static SqlByte operator +(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; int iResult = x.m_value + y.m_value; if ((iResult & s_iBitNotByteMax) != 0) throw new OverflowException(SQLResource.ArithOverflowMessage); else return new SqlByte((byte)iResult); } public static SqlByte operator -(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; int iResult = x.m_value - y.m_value; if ((iResult & s_iBitNotByteMax) != 0) throw new OverflowException(SQLResource.ArithOverflowMessage); else return new SqlByte((byte)iResult); } public static SqlByte operator *(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; int iResult = x.m_value * y.m_value; if ((iResult & s_iBitNotByteMax) != 0) throw new OverflowException(SQLResource.ArithOverflowMessage); else return new SqlByte((byte)iResult); } public static SqlByte operator /(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; if (y.m_value != 0) { return new SqlByte((byte)(x.m_value / y.m_value)); } else throw new DivideByZeroException(SQLResource.DivideByZeroMessage); } public static SqlByte operator %(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; if (y.m_value != 0) { return new SqlByte((byte)(x.m_value % y.m_value)); } else throw new DivideByZeroException(SQLResource.DivideByZeroMessage); } // Bitwise operators public static SqlByte operator &(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? Null : new SqlByte((byte)(x.m_value & y.m_value)); } public static SqlByte operator |(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? Null : new SqlByte((byte)(x.m_value | y.m_value)); } public static SqlByte operator ^(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? Null : new SqlByte((byte)(x.m_value ^ y.m_value)); } // Implicit conversions // Implicit conversion from SqlBoolean to SqlByte public static explicit operator SqlByte(SqlBoolean x) { return x.IsNull ? Null : new SqlByte(x.ByteValue); } // Explicit conversions // Explicit conversion from SqlMoney to SqlByte public static explicit operator SqlByte(SqlMoney x) { return x.IsNull ? Null : new SqlByte(checked((byte)x.ToInt32())); } // Explicit conversion from SqlInt16 to SqlByte public static explicit operator SqlByte(SqlInt16 x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlInt32 to SqlByte public static explicit operator SqlByte(SqlInt32 x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlInt64 to SqlByte public static explicit operator SqlByte(SqlInt64 x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlSingle to SqlByte public static explicit operator SqlByte(SqlSingle x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlDouble to SqlByte public static explicit operator SqlByte(SqlDouble x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlDecimal to SqlByte public static explicit operator SqlByte(SqlDecimal x) { return (SqlByte)(SqlInt32)x; } // Implicit conversion from SqlString to SqlByte // Throws FormatException or OverflowException if necessary. public static explicit operator SqlByte(SqlString x) { return x.IsNull ? Null : new SqlByte(byte.Parse(x.Value, null)); } // Overloading comparison operators public static SqlBoolean operator ==(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value == y.m_value); } public static SqlBoolean operator !=(SqlByte x, SqlByte y) { return !(x == y); } public static SqlBoolean operator <(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value < y.m_value); } public static SqlBoolean operator >(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value > y.m_value); } public static SqlBoolean operator <=(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value <= y.m_value); } public static SqlBoolean operator >=(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value >= y.m_value); } //-------------------------------------------------- // Alternative methods for overloaded operators //-------------------------------------------------- // Alternative method for operator ~ public static SqlByte OnesComplement(SqlByte x) { return ~x; } // Alternative method for operator + public static SqlByte Add(SqlByte x, SqlByte y) { return x + y; } // Alternative method for operator - public static SqlByte Subtract(SqlByte x, SqlByte y) { return x - y; } // Alternative method for operator * public static SqlByte Multiply(SqlByte x, SqlByte y) { return x * y; } // Alternative method for operator / public static SqlByte Divide(SqlByte x, SqlByte y) { return x / y; } // Alternative method for operator % public static SqlByte Mod(SqlByte x, SqlByte y) { return x % y; } public static SqlByte Modulus(SqlByte x, SqlByte y) { return x % y; } // Alternative method for operator & public static SqlByte BitwiseAnd(SqlByte x, SqlByte y) { return x & y; } // Alternative method for operator | public static SqlByte BitwiseOr(SqlByte x, SqlByte y) { return x | y; } // Alternative method for operator ^ public static SqlByte Xor(SqlByte x, SqlByte y) { return x ^ y; } // Alternative method for operator == public static SqlBoolean Equals(SqlByte x, SqlByte y) { return (x == y); } // Alternative method for operator != public static SqlBoolean NotEquals(SqlByte x, SqlByte y) { return (x != y); } // Alternative method for operator < public static SqlBoolean LessThan(SqlByte x, SqlByte y) { return (x < y); } // Alternative method for operator > public static SqlBoolean GreaterThan(SqlByte x, SqlByte y) { return (x > y); } // Alternative method for operator <= public static SqlBoolean LessThanOrEqual(SqlByte x, SqlByte y) { return (x <= y); } // Alternative method for operator >= public static SqlBoolean GreaterThanOrEqual(SqlByte x, SqlByte y) { return (x >= y); } // Alternative method for conversions. public SqlBoolean ToSqlBoolean() { return (SqlBoolean)this; } public SqlDouble ToSqlDouble() { return this; } public SqlInt16 ToSqlInt16() { return this; } public SqlInt32 ToSqlInt32() { return this; } public SqlInt64 ToSqlInt64() { return this; } public SqlMoney ToSqlMoney() { return this; } public SqlDecimal ToSqlDecimal() { return this; } public SqlSingle ToSqlSingle() { return this; } public SqlString ToSqlString() { return (SqlString)this; } // IComparable // Compares this object to another object, returning an integer that // indicates the relationship. // Returns a value less than zero if this < object, zero if this = object, // or a value greater than zero if this > object. // null is considered to be less than any instance. // If object is not of same type, this method throws an ArgumentException. public int CompareTo(object? value) { if (value is SqlByte) { SqlByte i = (SqlByte)value; return CompareTo(i); } throw ADP.WrongType(value!.GetType(), typeof(SqlByte)); } public int CompareTo(SqlByte value) { // If both Null, consider them equal. // Otherwise, Null is less than anything. if (IsNull) return value.IsNull ? 0 : -1; else if (value.IsNull) return 1; if (this < value) return -1; if (this > value) return 1; return 0; } // Compares this instance with a specified object public override bool Equals([NotNullWhen(true)] object? value) => value is SqlByte other && Equals(other); /// <summary>Indicates whether the current instance is equal to another instance of the same type.</summary> /// <param name="other">An instance to compare with this instance.</param> /// <returns>true if the current instance is equal to the other instance; otherwise, false.</returns> public bool Equals(SqlByte other) => other.IsNull || IsNull ? other.IsNull && IsNull : (this == other).Value; // For hashing purpose public override int GetHashCode() => IsNull ? 0 : Value.GetHashCode(); XmlSchema? IXmlSerializable.GetSchema() { return null; } void IXmlSerializable.ReadXml(XmlReader reader) { string? isNull = reader.GetAttribute("nil", XmlSchema.InstanceNamespace); if (isNull != null && XmlConvert.ToBoolean(isNull)) { // Read the next value. reader.ReadElementString(); m_fNotNull = false; } else { m_value = XmlConvert.ToByte(reader.ReadElementString()); m_fNotNull = true; } } void IXmlSerializable.WriteXml(XmlWriter writer) { if (IsNull) { writer.WriteAttributeString("xsi", "nil", XmlSchema.InstanceNamespace, "true"); } else { writer.WriteString(XmlConvert.ToString(m_value)); } } public static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet) { return new XmlQualifiedName("unsignedByte", XmlSchema.Namespace); } public static readonly SqlByte Null = new SqlByte(true); public static readonly SqlByte Zero = new SqlByte(0); public static readonly SqlByte MinValue = new SqlByte(byte.MinValue); public static readonly SqlByte MaxValue = new SqlByte(byte.MaxValue); } // SqlByte } // namespace System
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Data.Common; using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { /// <summary> /// Represents an 8-bit unsigned integer to be stored in /// or retrieved from a database. /// </summary> [Serializable] [StructLayout(LayoutKind.Sequential)] [XmlSchemaProvider("GetXsdType")] [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct SqlByte : INullable, IComparable, IXmlSerializable, IEquatable<SqlByte> { private bool m_fNotNull; // false if null. Do not rename (binary serialization) private byte m_value; // Do not rename (binary serialization) private const int s_iBitNotByteMax = ~0xff; // constructor // construct a Null private SqlByte(bool fNull) { m_fNotNull = false; m_value = 0; } public SqlByte(byte value) { m_value = value; m_fNotNull = true; } // INullable public bool IsNull { get { return !m_fNotNull; } } // property: Value public byte Value { get { if (m_fNotNull) return m_value; else throw new SqlNullValueException(); } } // Implicit conversion from byte to SqlByte public static implicit operator SqlByte(byte x) { return new SqlByte(x); } // Explicit conversion from SqlByte to byte. Throw exception if x is Null. public static explicit operator byte(SqlByte x) { return x.Value; } public override string ToString() { return IsNull ? SQLResource.NullString : m_value.ToString((IFormatProvider)null!); } public static SqlByte Parse(string s) { if (s == SQLResource.NullString) return SqlByte.Null; else return new SqlByte(byte.Parse(s, null)); } // Unary operators public static SqlByte operator ~(SqlByte x) { return x.IsNull ? Null : new SqlByte(unchecked((byte)~x.m_value)); } // Binary operators // Arithmetic operators public static SqlByte operator +(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; int iResult = x.m_value + y.m_value; if ((iResult & s_iBitNotByteMax) != 0) throw new OverflowException(SQLResource.ArithOverflowMessage); else return new SqlByte((byte)iResult); } public static SqlByte operator -(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; int iResult = x.m_value - y.m_value; if ((iResult & s_iBitNotByteMax) != 0) throw new OverflowException(SQLResource.ArithOverflowMessage); else return new SqlByte((byte)iResult); } public static SqlByte operator *(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; int iResult = x.m_value * y.m_value; if ((iResult & s_iBitNotByteMax) != 0) throw new OverflowException(SQLResource.ArithOverflowMessage); else return new SqlByte((byte)iResult); } public static SqlByte operator /(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; if (y.m_value != 0) { return new SqlByte((byte)(x.m_value / y.m_value)); } else throw new DivideByZeroException(SQLResource.DivideByZeroMessage); } public static SqlByte operator %(SqlByte x, SqlByte y) { if (x.IsNull || y.IsNull) return Null; if (y.m_value != 0) { return new SqlByte((byte)(x.m_value % y.m_value)); } else throw new DivideByZeroException(SQLResource.DivideByZeroMessage); } // Bitwise operators public static SqlByte operator &(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? Null : new SqlByte((byte)(x.m_value & y.m_value)); } public static SqlByte operator |(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? Null : new SqlByte((byte)(x.m_value | y.m_value)); } public static SqlByte operator ^(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? Null : new SqlByte((byte)(x.m_value ^ y.m_value)); } // Implicit conversions // Implicit conversion from SqlBoolean to SqlByte public static explicit operator SqlByte(SqlBoolean x) { return x.IsNull ? Null : new SqlByte(x.ByteValue); } // Explicit conversions // Explicit conversion from SqlMoney to SqlByte public static explicit operator SqlByte(SqlMoney x) { return x.IsNull ? Null : new SqlByte(checked((byte)x.ToInt32())); } // Explicit conversion from SqlInt16 to SqlByte public static explicit operator SqlByte(SqlInt16 x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlInt32 to SqlByte public static explicit operator SqlByte(SqlInt32 x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlInt64 to SqlByte public static explicit operator SqlByte(SqlInt64 x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlSingle to SqlByte public static explicit operator SqlByte(SqlSingle x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlDouble to SqlByte public static explicit operator SqlByte(SqlDouble x) { if (x.IsNull) return Null; if (x.Value > byte.MaxValue || x.Value < byte.MinValue) throw new OverflowException(SQLResource.ArithOverflowMessage); return x.IsNull ? Null : new SqlByte((byte)(x.Value)); } // Explicit conversion from SqlDecimal to SqlByte public static explicit operator SqlByte(SqlDecimal x) { return (SqlByte)(SqlInt32)x; } // Implicit conversion from SqlString to SqlByte // Throws FormatException or OverflowException if necessary. public static explicit operator SqlByte(SqlString x) { return x.IsNull ? Null : new SqlByte(byte.Parse(x.Value, null)); } // Overloading comparison operators public static SqlBoolean operator ==(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value == y.m_value); } public static SqlBoolean operator !=(SqlByte x, SqlByte y) { return !(x == y); } public static SqlBoolean operator <(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value < y.m_value); } public static SqlBoolean operator >(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value > y.m_value); } public static SqlBoolean operator <=(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value <= y.m_value); } public static SqlBoolean operator >=(SqlByte x, SqlByte y) { return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x.m_value >= y.m_value); } //-------------------------------------------------- // Alternative methods for overloaded operators //-------------------------------------------------- // Alternative method for operator ~ public static SqlByte OnesComplement(SqlByte x) { return ~x; } // Alternative method for operator + public static SqlByte Add(SqlByte x, SqlByte y) { return x + y; } // Alternative method for operator - public static SqlByte Subtract(SqlByte x, SqlByte y) { return x - y; } // Alternative method for operator * public static SqlByte Multiply(SqlByte x, SqlByte y) { return x * y; } // Alternative method for operator / public static SqlByte Divide(SqlByte x, SqlByte y) { return x / y; } // Alternative method for operator % public static SqlByte Mod(SqlByte x, SqlByte y) { return x % y; } public static SqlByte Modulus(SqlByte x, SqlByte y) { return x % y; } // Alternative method for operator & public static SqlByte BitwiseAnd(SqlByte x, SqlByte y) { return x & y; } // Alternative method for operator | public static SqlByte BitwiseOr(SqlByte x, SqlByte y) { return x | y; } // Alternative method for operator ^ public static SqlByte Xor(SqlByte x, SqlByte y) { return x ^ y; } // Alternative method for operator == public static SqlBoolean Equals(SqlByte x, SqlByte y) { return (x == y); } // Alternative method for operator != public static SqlBoolean NotEquals(SqlByte x, SqlByte y) { return (x != y); } // Alternative method for operator < public static SqlBoolean LessThan(SqlByte x, SqlByte y) { return (x < y); } // Alternative method for operator > public static SqlBoolean GreaterThan(SqlByte x, SqlByte y) { return (x > y); } // Alternative method for operator <= public static SqlBoolean LessThanOrEqual(SqlByte x, SqlByte y) { return (x <= y); } // Alternative method for operator >= public static SqlBoolean GreaterThanOrEqual(SqlByte x, SqlByte y) { return (x >= y); } // Alternative method for conversions. public SqlBoolean ToSqlBoolean() { return (SqlBoolean)this; } public SqlDouble ToSqlDouble() { return this; } public SqlInt16 ToSqlInt16() { return this; } public SqlInt32 ToSqlInt32() { return this; } public SqlInt64 ToSqlInt64() { return this; } public SqlMoney ToSqlMoney() { return this; } public SqlDecimal ToSqlDecimal() { return this; } public SqlSingle ToSqlSingle() { return this; } public SqlString ToSqlString() { return (SqlString)this; } // IComparable // Compares this object to another object, returning an integer that // indicates the relationship. // Returns a value less than zero if this < object, zero if this = object, // or a value greater than zero if this > object. // null is considered to be less than any instance. // If object is not of same type, this method throws an ArgumentException. public int CompareTo(object? value) { if (value is SqlByte) { SqlByte i = (SqlByte)value; return CompareTo(i); } throw ADP.WrongType(value!.GetType(), typeof(SqlByte)); } public int CompareTo(SqlByte value) { // If both Null, consider them equal. // Otherwise, Null is less than anything. if (IsNull) return value.IsNull ? 0 : -1; else if (value.IsNull) return 1; if (this < value) return -1; if (this > value) return 1; return 0; } // Compares this instance with a specified object public override bool Equals([NotNullWhen(true)] object? value) => value is SqlByte other && Equals(other); /// <summary>Indicates whether the current instance is equal to another instance of the same type.</summary> /// <param name="other">An instance to compare with this instance.</param> /// <returns>true if the current instance is equal to the other instance; otherwise, false.</returns> public bool Equals(SqlByte other) => other.IsNull || IsNull ? other.IsNull && IsNull : (this == other).Value; // For hashing purpose public override int GetHashCode() => IsNull ? 0 : Value.GetHashCode(); XmlSchema? IXmlSerializable.GetSchema() { return null; } void IXmlSerializable.ReadXml(XmlReader reader) { string? isNull = reader.GetAttribute("nil", XmlSchema.InstanceNamespace); if (isNull != null && XmlConvert.ToBoolean(isNull)) { // Read the next value. reader.ReadElementString(); m_fNotNull = false; } else { m_value = XmlConvert.ToByte(reader.ReadElementString()); m_fNotNull = true; } } void IXmlSerializable.WriteXml(XmlWriter writer) { if (IsNull) { writer.WriteAttributeString("xsi", "nil", XmlSchema.InstanceNamespace, "true"); } else { writer.WriteString(XmlConvert.ToString(m_value)); } } public static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet) { return new XmlQualifiedName("unsignedByte", XmlSchema.Namespace); } public static readonly SqlByte Null = new SqlByte(true); public static readonly SqlByte Zero = new SqlByte(0); public static readonly SqlByte MinValue = new SqlByte(byte.MinValue); public static readonly SqlByte MaxValue = new SqlByte(byte.MaxValue); } // SqlByte } // namespace System
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumFormatETC.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; namespace System.Runtime.InteropServices.ComTypes { /// <summary> /// The IEnumFORMATETC interface is used to enumerate an array of FORMATETC /// structures. IEnumFORMATETC has the same methods as all enumerator interfaces: /// Next, Skip, Reset, and Clone. /// </summary> [ComImport] [Guid("00000103-0000-0000-C000-000000000046")] [EditorBrowsable(EditorBrowsableState.Never)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumFORMATETC { /// <summary> /// Retrieves the next celt items in the enumeration sequence. If there are /// fewer than the requested number of elements left in the sequence, it /// retrieves the remaining elements. The number of elements actually /// retrieved is returned through pceltFetched (unless the caller passed /// in NULL for that parameter). /// </summary> [PreserveSig] int Next(int celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] FORMATETC[] rgelt, [Out, MarshalAs(UnmanagedType.LPArray)] int[] pceltFetched); /// <summary> /// Skips over the next specified number of elements in the enumeration sequence. /// </summary> [PreserveSig] int Skip(int celt); /// <summary> /// Resets the enumeration sequence to the beginning. /// </summary> [PreserveSig] int Reset(); /// <summary> /// Creates another enumerator that contains the same enumeration state as /// the current one. Using this function, a client can record a particular /// point in the enumeration sequence and then return to that point at a /// later time. The new enumerator supports the same interface as the original one. /// </summary> void Clone(out IEnumFORMATETC newEnum); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; namespace System.Runtime.InteropServices.ComTypes { /// <summary> /// The IEnumFORMATETC interface is used to enumerate an array of FORMATETC /// structures. IEnumFORMATETC has the same methods as all enumerator interfaces: /// Next, Skip, Reset, and Clone. /// </summary> [ComImport] [Guid("00000103-0000-0000-C000-000000000046")] [EditorBrowsable(EditorBrowsableState.Never)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumFORMATETC { /// <summary> /// Retrieves the next celt items in the enumeration sequence. If there are /// fewer than the requested number of elements left in the sequence, it /// retrieves the remaining elements. The number of elements actually /// retrieved is returned through pceltFetched (unless the caller passed /// in NULL for that parameter). /// </summary> [PreserveSig] int Next(int celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] FORMATETC[] rgelt, [Out, MarshalAs(UnmanagedType.LPArray)] int[] pceltFetched); /// <summary> /// Skips over the next specified number of elements in the enumeration sequence. /// </summary> [PreserveSig] int Skip(int celt); /// <summary> /// Resets the enumeration sequence to the beginning. /// </summary> [PreserveSig] int Reset(); /// <summary> /// Creates another enumerator that contains the same enumeration state as /// the current one. Using this function, a client can record a particular /// point in the enumeration sequence and then return to that point at a /// later time. The new enumerator supports the same interface as the original one. /// </summary> void Clone(out IEnumFORMATETC newEnum); } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetTimestamp.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Sys { [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTimestamp")] [SuppressGCTransition] internal static partial ulong GetTimestamp(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Sys { [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTimestamp")] [SuppressGCTransition] internal static partial ulong GetTimestamp(); } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Runtime.Loader/tests/ContextualReflectionDependency/System.Runtime.Loader.Test.ContextualReflectionDependency.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> </PropertyGroup> <ItemGroup> <Compile Include="ContextualReflectionDependency.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> </PropertyGroup> <ItemGroup> <Compile Include="ContextualReflectionDependency.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/IL_Conformance/Old/Conformance_Base/cgt_un_r8.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <RestorePackages>true</RestorePackages> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="cgt_un_r8.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <RestorePackages>true</RestorePackages> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="cgt_un_r8.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/CodeGenBringUpTests/ModConst_d.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ModConst.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ModConst.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/IL_Conformance/Old/Conformance_Base/sub_ovf_i1.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern legacy library mscorlib {} .class public sub_ovf_i1 { .method public static int32 i1(int32,int32,int32) { .locals (class [mscorlib]System.OverflowException, int8) .maxstack 2 try_start: ldarg 0 ldarg 1 sub conv.ovf.i1 stloc.1 leave.s try_end try_end: ldloc.1 ldarg 2 ceq br END aHandler: isinst [mscorlib]System.OverflowException stloc 0 leave HEnd HEnd: ldloc 0 brfalse FAIL ldarg 2 ldc.i4 0xEEEEEEEE ceq br END FAIL: ldc.i4 0x00000000 END: ret .try try_start to try_end catch [mscorlib]System.OverflowException handler aHandler to HEnd } .method public void sub_ovf_i1() { .maxstack 0 ret } .method public static int32 main(class [mscorlib]System.String[]) { .entrypoint .maxstack 5 ldc.i4 0xFFFFFF80 ldc.i4 0xFFFFFF80 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFF81 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x00000000 ldc.i4 0xFFFFFF80 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x00000001 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x0000007F ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x00000055 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFFD6 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFF80 ldc.i4 0x0000007F call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFFFF ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x00000000 ldc.i4 0xFFFFFFFF call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x00000001 ldc.i4 0xFFFFFFFE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x0000007F ldc.i4 0xFFFFFF80 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x00000055 ldc.i4 0xFFFFFFAA call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFFAA ldc.i4 0x00000055 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0xFFFFFFFF ldc.i4 0x00000001 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x00000000 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x00000001 ldc.i4 0xFFFFFFFF call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x0000007F ldc.i4 0xFFFFFF81 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x00000055 ldc.i4 0xFFFFFFAB call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0xFFFFFFAA ldc.i4 0x00000056 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0xFFFFFFFF ldc.i4 0x00000002 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x00000000 ldc.i4 0x00000001 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x00000001 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x0000007F ldc.i4 0xFFFFFF82 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x00000055 ldc.i4 0xFFFFFFAC call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0xFFFFFFAA ldc.i4 0x00000057 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0xFFFFFFFF ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x00000000 ldc.i4 0x0000007F call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x00000001 ldc.i4 0x0000007E call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x0000007F ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x00000055 ldc.i4 0x0000002A call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0xFFFFFFAA ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0xFFFFFFFF ldc.i4 0x00000056 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x00000000 ldc.i4 0x00000055 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x00000001 ldc.i4 0x00000054 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x0000007F ldc.i4 0xFFFFFFD6 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x00000055 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0xFFFFFFAA ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFF80 ldc.i4 0x0000002A call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFFAB call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x00000000 ldc.i4 0xFFFFFFAA call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x00000001 ldc.i4 0xFFFFFFA9 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x0000007F ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x00000055 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFFAA ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL PASS: ldc.i4 100 br END FAIL: ldc.i4 0x00000000 END: ret } } .assembly sub_ovf_i1{}
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern legacy library mscorlib {} .class public sub_ovf_i1 { .method public static int32 i1(int32,int32,int32) { .locals (class [mscorlib]System.OverflowException, int8) .maxstack 2 try_start: ldarg 0 ldarg 1 sub conv.ovf.i1 stloc.1 leave.s try_end try_end: ldloc.1 ldarg 2 ceq br END aHandler: isinst [mscorlib]System.OverflowException stloc 0 leave HEnd HEnd: ldloc 0 brfalse FAIL ldarg 2 ldc.i4 0xEEEEEEEE ceq br END FAIL: ldc.i4 0x00000000 END: ret .try try_start to try_end catch [mscorlib]System.OverflowException handler aHandler to HEnd } .method public void sub_ovf_i1() { .maxstack 0 ret } .method public static int32 main(class [mscorlib]System.String[]) { .entrypoint .maxstack 5 ldc.i4 0xFFFFFF80 ldc.i4 0xFFFFFF80 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFF81 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x00000000 ldc.i4 0xFFFFFF80 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x00000001 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x0000007F ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0x00000055 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFF80 ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFFD6 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFF80 ldc.i4 0x0000007F call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFFFF ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x00000000 ldc.i4 0xFFFFFFFF call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x00000001 ldc.i4 0xFFFFFFFE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x0000007F ldc.i4 0xFFFFFF80 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0x00000055 ldc.i4 0xFFFFFFAA call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFFAA ldc.i4 0x00000055 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0xFFFFFFFF ldc.i4 0x00000001 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x00000000 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x00000001 ldc.i4 0xFFFFFFFF call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x0000007F ldc.i4 0xFFFFFF81 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0x00000055 ldc.i4 0xFFFFFFAB call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000000 ldc.i4 0xFFFFFFAA ldc.i4 0x00000056 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0xFFFFFFFF ldc.i4 0x00000002 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x00000000 ldc.i4 0x00000001 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x00000001 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x0000007F ldc.i4 0xFFFFFF82 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0x00000055 ldc.i4 0xFFFFFFAC call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000001 ldc.i4 0xFFFFFFAA ldc.i4 0x00000057 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0xFFFFFFFF ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x00000000 ldc.i4 0x0000007F call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x00000001 ldc.i4 0x0000007E call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x0000007F ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0x00000055 ldc.i4 0x0000002A call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x0000007F ldc.i4 0xFFFFFFAA ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0xFFFFFF80 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0xFFFFFFFF ldc.i4 0x00000056 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x00000000 ldc.i4 0x00000055 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x00000001 ldc.i4 0x00000054 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x0000007F ldc.i4 0xFFFFFFD6 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0x00000055 ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0x00000055 ldc.i4 0xFFFFFFAA ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFF80 ldc.i4 0x0000002A call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFFFF ldc.i4 0xFFFFFFAB call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x00000000 ldc.i4 0xFFFFFFAA call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x00000001 ldc.i4 0xFFFFFFA9 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x0000007F ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0x00000055 ldc.i4 0xEEEEEEEE call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL ldc.i4 0xFFFFFFAA ldc.i4 0xFFFFFFAA ldc.i4 0x00000000 call int32 sub_ovf_i1::i1(int32,int32,int32) brfalse FAIL PASS: ldc.i4 100 br END FAIL: ldc.i4 0x00000000 END: ret } } .assembly sub_ovf_i1{}
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/Common/src/System/CodeDom/CodeObject.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable using System.Collections; using System.Collections.Specialized; #if CODEDOM namespace System.CodeDom #else namespace System.Runtime.Serialization #endif { #if CODEDOM public class CodeObject #else internal class CodeObject #endif { private IDictionary? _userData; public CodeObject() { } public IDictionary UserData => _userData ?? (_userData = new ListDictionary()); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable using System.Collections; using System.Collections.Specialized; #if CODEDOM namespace System.CodeDom #else namespace System.Runtime.Serialization #endif { #if CODEDOM public class CodeObject #else internal class CodeObject #endif { private IDictionary? _userData; public CodeObject() { } public IDictionary UserData => _userData ?? (_userData = new ListDictionary()); } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/HardwareIntrinsics/General/Vector64/GreaterThanOrEqualAll.Byte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void GreaterThanOrEqualAllByte() { var test = new VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Byte> _fld1; public Vector64<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte testClass) { var result = Vector64.GreaterThanOrEqualAll(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector64<Byte> _clsVar1; private static Vector64<Byte> _clsVar2; private Vector64<Byte> _fld1; private Vector64<Byte> _fld2; private DataTable _dataTable; static VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.GreaterThanOrEqualAll( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector64).GetMethod(nameof(Vector64.GreaterThanOrEqualAll), new Type[] { typeof(Vector64<Byte>), typeof(Vector64<Byte>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.GreaterThanOrEqualAll), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Byte)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.GreaterThanOrEqualAll( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr); var result = Vector64.GreaterThanOrEqualAll(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte(); var result = Vector64.GreaterThanOrEqualAll(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector64.GreaterThanOrEqualAll(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector64.GreaterThanOrEqualAll(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector64<Byte> op1, Vector64<Byte> op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "") { bool succeeded = true; var expectedResult = true; for (var i = 0; i < Op1ElementCount; i++) { expectedResult &= (left[i] >= right[i]); } succeeded = (expectedResult == result); if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.GreaterThanOrEqualAll)}<Byte>(Vector64<Byte>, Vector64<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({result})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void GreaterThanOrEqualAllByte() { var test = new VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Byte> _fld1; public Vector64<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte testClass) { var result = Vector64.GreaterThanOrEqualAll(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector64<Byte> _clsVar1; private static Vector64<Byte> _clsVar2; private Vector64<Byte> _fld1; private Vector64<Byte> _fld2; private DataTable _dataTable; static VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.GreaterThanOrEqualAll( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector64).GetMethod(nameof(Vector64.GreaterThanOrEqualAll), new Type[] { typeof(Vector64<Byte>), typeof(Vector64<Byte>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.GreaterThanOrEqualAll), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Byte)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.GreaterThanOrEqualAll( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr); var result = Vector64.GreaterThanOrEqualAll(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBooleanBinaryOpTest__GreaterThanOrEqualAllByte(); var result = Vector64.GreaterThanOrEqualAll(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector64.GreaterThanOrEqualAll(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector64.GreaterThanOrEqualAll(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector64<Byte> op1, Vector64<Byte> op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "") { bool succeeded = true; var expectedResult = true; for (var i = 0; i < Op1ElementCount; i++) { expectedResult &= (left[i] >= right[i]); } succeeded = (expectedResult == result); if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.GreaterThanOrEqualAll)}<Byte>(Vector64<Byte>, Vector64<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({result})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Sentinels.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { // // These sentinel instances are used only for lazy-evaluation latches when "null" is a valid value for that property. // internal static class Sentinels { public static readonly RoType RoType = new SentinelType(); public static readonly RoMethod RoMethod = new SentinelMethod(); private sealed class SentinelType : RoStubType { internal SentinelType() : base() { } } private sealed class SentinelAssembly : RoStubAssembly { internal SentinelAssembly() : base() { } } private sealed class SentinelMethod : RoMethod { internal SentinelMethod() : base(Sentinels.RoType) { } internal sealed override RoType GetRoDeclaringType() => throw null!; internal sealed override RoModule GetRoModule() => throw null!; public sealed override int MetadataToken => throw null!; public sealed override IEnumerable<CustomAttributeData> CustomAttributes => throw null!; public sealed override bool IsConstructedGenericMethod => throw null!; public sealed override bool IsGenericMethodDefinition => throw null!; public sealed override bool Equals(object? obj) => throw null!; public sealed override MethodInfo GetGenericMethodDefinition() => throw null!; public sealed override int GetHashCode() => throw null!; public sealed override MethodBody GetMethodBody() => throw null!; [RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")] public sealed override MethodInfo MakeGenericMethod(params Type[] typeArguments) => throw null!; protected sealed override MethodAttributes ComputeAttributes() => throw null!; protected sealed override CallingConventions ComputeCallingConvention() => throw null!; protected sealed override RoType[] ComputeGenericArgumentsOrParameters() => throw null!; protected sealed override MethodImplAttributes ComputeMethodImplementationFlags() => throw null!; protected sealed override MethodSig<RoParameter> ComputeMethodSig() => throw null!; protected sealed override MethodSig<RoType> ComputeCustomModifiers() => throw null!; protected sealed override MethodSig<string> ComputeMethodSigStrings() => throw null!; protected sealed override string ComputeName() => throw null!; internal sealed override RoType[] GetGenericTypeArgumentsNoCopy() => throw null!; internal sealed override RoType[] GetGenericTypeParametersNoCopy() => throw null!; public sealed override TypeContext TypeContext => throw null!; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { // // These sentinel instances are used only for lazy-evaluation latches when "null" is a valid value for that property. // internal static class Sentinels { public static readonly RoType RoType = new SentinelType(); public static readonly RoMethod RoMethod = new SentinelMethod(); private sealed class SentinelType : RoStubType { internal SentinelType() : base() { } } private sealed class SentinelAssembly : RoStubAssembly { internal SentinelAssembly() : base() { } } private sealed class SentinelMethod : RoMethod { internal SentinelMethod() : base(Sentinels.RoType) { } internal sealed override RoType GetRoDeclaringType() => throw null!; internal sealed override RoModule GetRoModule() => throw null!; public sealed override int MetadataToken => throw null!; public sealed override IEnumerable<CustomAttributeData> CustomAttributes => throw null!; public sealed override bool IsConstructedGenericMethod => throw null!; public sealed override bool IsGenericMethodDefinition => throw null!; public sealed override bool Equals(object? obj) => throw null!; public sealed override MethodInfo GetGenericMethodDefinition() => throw null!; public sealed override int GetHashCode() => throw null!; public sealed override MethodBody GetMethodBody() => throw null!; [RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")] public sealed override MethodInfo MakeGenericMethod(params Type[] typeArguments) => throw null!; protected sealed override MethodAttributes ComputeAttributes() => throw null!; protected sealed override CallingConventions ComputeCallingConvention() => throw null!; protected sealed override RoType[] ComputeGenericArgumentsOrParameters() => throw null!; protected sealed override MethodImplAttributes ComputeMethodImplementationFlags() => throw null!; protected sealed override MethodSig<RoParameter> ComputeMethodSig() => throw null!; protected sealed override MethodSig<RoType> ComputeCustomModifiers() => throw null!; protected sealed override MethodSig<string> ComputeMethodSigStrings() => throw null!; protected sealed override string ComputeName() => throw null!; internal sealed override RoType[] GetGenericTypeArgumentsNoCopy() => throw null!; internal sealed override RoType[] GetGenericTypeParametersNoCopy() => throw null!; public sealed override TypeContext TypeContext => throw null!; } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Data.Common/src/System/Data/Common/DbProviderSpecificTypePropertyAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Data.Common { [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public sealed class DbProviderSpecificTypePropertyAttribute : System.Attribute { public DbProviderSpecificTypePropertyAttribute(bool isProviderSpecificTypeProperty) { IsProviderSpecificTypeProperty = isProviderSpecificTypeProperty; } public bool IsProviderSpecificTypeProperty { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Data.Common { [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public sealed class DbProviderSpecificTypePropertyAttribute : System.Attribute { public DbProviderSpecificTypePropertyAttribute(bool isProviderSpecificTypeProperty) { IsProviderSpecificTypeProperty = isProviderSpecificTypeProperty; } public bool IsProviderSpecificTypeProperty { get; } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/SmallSparseInitonlyArray.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Composition.Hosting.Util { // Extremely performance-sensitive. // Always safe for reading, even under concurrent writes, // only one writer at a time allowed. internal sealed class SmallSparseInitonlyArray { private sealed class Element { public int Index; public object Value; } private const int ElementsCapacity = 128; private const int ElementIndexMask = 127; private const int LocalOffsetMax = 3; private Element[] _elements; private SmallSparseInitonlyArray _overflow; public void Add(int index, object value) { if (_elements == null) _elements = new Element[ElementsCapacity]; var newElement = new Element { Index = index, Value = value }; var elementIndex = index & ElementIndexMask; var e = _elements[elementIndex]; if (e == null) { _elements[elementIndex] = newElement; return; } if (e.Index == index) { throw new ArgumentException(SR.Format(SR.Key_Already_Exist, index), nameof(index)); } for (int offset = 1; offset <= LocalOffsetMax; ++offset) { var nextIndex = (index + offset) & ElementIndexMask; e = _elements[nextIndex]; if (e == null) { _elements[nextIndex] = newElement; return; } if (e.Index == index) { throw new ArgumentException(SR.Format(SR.Key_Already_Exist, index), nameof(index)); } } if (_overflow == null) _overflow = new SmallSparseInitonlyArray(); _overflow.Add(index, value); } public bool TryGetValue(int index, out object value) { if (_elements == null) { value = null; return false; } var elementIndex = index & ElementIndexMask; var e = _elements[elementIndex]; if (e != null && e.Index == index) { value = e.Value; return true; } for (int offset = 1; offset <= LocalOffsetMax; ++offset) { e = _elements[(index + offset) & ElementIndexMask]; if (e == null) { value = null; return false; } if (e.Index == index) { value = e.Value; return true; } } if (_overflow != null) return _overflow.TryGetValue(index, out value); value = null; return false; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Composition.Hosting.Util { // Extremely performance-sensitive. // Always safe for reading, even under concurrent writes, // only one writer at a time allowed. internal sealed class SmallSparseInitonlyArray { private sealed class Element { public int Index; public object Value; } private const int ElementsCapacity = 128; private const int ElementIndexMask = 127; private const int LocalOffsetMax = 3; private Element[] _elements; private SmallSparseInitonlyArray _overflow; public void Add(int index, object value) { if (_elements == null) _elements = new Element[ElementsCapacity]; var newElement = new Element { Index = index, Value = value }; var elementIndex = index & ElementIndexMask; var e = _elements[elementIndex]; if (e == null) { _elements[elementIndex] = newElement; return; } if (e.Index == index) { throw new ArgumentException(SR.Format(SR.Key_Already_Exist, index), nameof(index)); } for (int offset = 1; offset <= LocalOffsetMax; ++offset) { var nextIndex = (index + offset) & ElementIndexMask; e = _elements[nextIndex]; if (e == null) { _elements[nextIndex] = newElement; return; } if (e.Index == index) { throw new ArgumentException(SR.Format(SR.Key_Already_Exist, index), nameof(index)); } } if (_overflow == null) _overflow = new SmallSparseInitonlyArray(); _overflow.Add(index, value); } public bool TryGetValue(int index, out object value) { if (_elements == null) { value = null; return false; } var elementIndex = index & ElementIndexMask; var e = _elements[elementIndex]; if (e != null && e.Index == index) { value = e.Value; return true; } for (int offset = 1; offset <= LocalOffsetMax; ++offset) { e = _elements[(index + offset) & ElementIndexMask]; if (e == null) { value = null; return false; } if (e.Index == index) { value = e.Value; return true; } } if (_overflow != null) return _overflow.TryGetValue(index, out value); value = null; return false; } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/coreclr/pal/src/libunwind/include/tdep-sh/libunwind_i.h
/* libunwind - a platform-independent unwind library Copyright (C) 2008 CodeSourcery Copyright (C) 2012 Tommi Rantala <[email protected]> This file is part of libunwind. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef SH_LIBUNWIND_I_H #define SH_LIBUNWIND_I_H /* Target-dependent definitions that are internal to libunwind but need to be shared with target-independent code. */ #include <stdlib.h> #include <libunwind.h> #include <stdatomic.h> #include "elf32.h" #include "mempool.h" #include "dwarf.h" typedef struct { /* no sh-specific fast trace */ } unw_tdep_frame_t; struct unw_addr_space { struct unw_accessors acc; int big_endian; unw_caching_policy_t caching_policy; _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; struct unw_debug_frame_list *debug_frames; }; struct cursor { struct dwarf_cursor dwarf; /* must be first */ enum { SH_SCF_NONE, /* no signal frame */ SH_SCF_LINUX_SIGFRAME, /* non-RT signal frame */ SH_SCF_LINUX_RT_SIGFRAME, /* RT signal frame */ } sigcontext_format; unw_word_t sigcontext_addr; unw_word_t sigcontext_sp; unw_word_t sigcontext_pc; }; #define DWARF_GET_LOC(l) ((l).val) #ifdef UNW_LOCAL_ONLY # define DWARF_NULL_LOC DWARF_LOC (0, 0) # define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) # define DWARF_IS_REG_LOC(l) 0 # define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ tdep_uc_addr((c)->as_arg, (r)), 0)) # define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) # define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ tdep_uc_addr((c)->as_arg, (r)), 0)) static inline int dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) { if (!DWARF_GET_LOC (loc)) return -1; *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); return 0; } static inline int dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) { if (!DWARF_GET_LOC (loc)) return -1; *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; return 0; } static inline int dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) { if (!DWARF_GET_LOC (loc)) return -1; *val = *(unw_word_t *) DWARF_GET_LOC (loc); return 0; } static inline int dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) { if (!DWARF_GET_LOC (loc)) return -1; *(unw_word_t *) DWARF_GET_LOC (loc) = val; return 0; } #else /* !UNW_LOCAL_ONLY */ # define DWARF_LOC_TYPE_FP (1 << 0) # define DWARF_LOC_TYPE_REG (1 << 1) # define DWARF_NULL_LOC DWARF_LOC (0, 0) # define DWARF_IS_NULL_LOC(l) \ ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) # define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) # define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) # define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) # define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) # define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ | DWARF_LOC_TYPE_FP)) static inline int dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) { char *valp = (char *) &val; unw_word_t addr; int ret; if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); addr = DWARF_GET_LOC (loc); if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, 0, c->as_arg)) < 0) return ret; return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, c->as_arg); } static inline int dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) { char *valp = (char *) &val; unw_word_t addr; int ret; if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), &val, 1, c->as_arg); addr = DWARF_GET_LOC (loc); if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, 1, c->as_arg)) < 0) return ret; return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 1, c->as_arg); } static inline int dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) { if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; /* If a code-generator were to save a value of type unw_word_t in a floating-point register, we would have to support this case. I suppose it could happen with MMX registers, but does it really happen? */ assert (!DWARF_IS_FP_LOC (loc)); if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); else return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); } static inline int dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) { if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; /* If a code-generator were to save a value of type unw_word_t in a floating-point register, we would have to support this case. I suppose it could happen with MMX registers, but does it really happen? */ assert (!DWARF_IS_FP_LOC (loc)); if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, 1, c->as_arg); else return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, 1, c->as_arg); } #endif /* !UNW_LOCAL_ONLY */ #define tdep_getcontext_trace unw_getcontext #define tdep_init_done UNW_OBJ(init_done) #define tdep_init UNW_OBJ(init) /* Platforms that support UNW_INFO_FORMAT_TABLE need to define tdep_search_unwind_table. */ #define tdep_search_unwind_table dwarf_search_unwind_table #define tdep_find_unwind_table dwarf_find_unwind_table #define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) #define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) #define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) #define tdep_access_reg UNW_OBJ(access_reg) #define tdep_access_fpreg UNW_OBJ(access_fpreg) #define tdep_fetch_frame(c,ip,n) do {} while(0) #define tdep_cache_frame(c) 0 #define tdep_reuse_frame(c,frame) do {} while(0) #define tdep_stash_frame(c,rs) do {} while(0) #define tdep_trace(cur,addr,n) (-UNW_ENOINFO) #ifdef UNW_LOCAL_ONLY # define tdep_find_proc_info(c,ip,n) \ dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ (c)->as_arg) # define tdep_put_unwind_info(as,pi,arg) \ dwarf_put_unwind_info((as), (pi), (arg)) #else # define tdep_find_proc_info(c,ip,n) \ (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ (c)->as_arg) # define tdep_put_unwind_info(as,pi,arg) \ (*(as)->acc.put_unwind_info)((as), (pi), (arg)) #endif #define tdep_get_as(c) ((c)->dwarf.as) #define tdep_get_as_arg(c) ((c)->dwarf.as_arg) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) ((as)->big_endian) extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, unw_dyn_info_t *di, unw_proc_info_t *pi, int need_unwind_info, void *arg); extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen); extern void tdep_get_exe_image_path (char *path); extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, int write); extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, int write); #endif /* SH_LIBUNWIND_I_H */
/* libunwind - a platform-independent unwind library Copyright (C) 2008 CodeSourcery Copyright (C) 2012 Tommi Rantala <[email protected]> This file is part of libunwind. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef SH_LIBUNWIND_I_H #define SH_LIBUNWIND_I_H /* Target-dependent definitions that are internal to libunwind but need to be shared with target-independent code. */ #include <stdlib.h> #include <libunwind.h> #include <stdatomic.h> #include "elf32.h" #include "mempool.h" #include "dwarf.h" typedef struct { /* no sh-specific fast trace */ } unw_tdep_frame_t; struct unw_addr_space { struct unw_accessors acc; int big_endian; unw_caching_policy_t caching_policy; _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; struct unw_debug_frame_list *debug_frames; }; struct cursor { struct dwarf_cursor dwarf; /* must be first */ enum { SH_SCF_NONE, /* no signal frame */ SH_SCF_LINUX_SIGFRAME, /* non-RT signal frame */ SH_SCF_LINUX_RT_SIGFRAME, /* RT signal frame */ } sigcontext_format; unw_word_t sigcontext_addr; unw_word_t sigcontext_sp; unw_word_t sigcontext_pc; }; #define DWARF_GET_LOC(l) ((l).val) #ifdef UNW_LOCAL_ONLY # define DWARF_NULL_LOC DWARF_LOC (0, 0) # define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) # define DWARF_IS_REG_LOC(l) 0 # define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ tdep_uc_addr((c)->as_arg, (r)), 0)) # define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) # define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ tdep_uc_addr((c)->as_arg, (r)), 0)) static inline int dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) { if (!DWARF_GET_LOC (loc)) return -1; *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); return 0; } static inline int dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) { if (!DWARF_GET_LOC (loc)) return -1; *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; return 0; } static inline int dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) { if (!DWARF_GET_LOC (loc)) return -1; *val = *(unw_word_t *) DWARF_GET_LOC (loc); return 0; } static inline int dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) { if (!DWARF_GET_LOC (loc)) return -1; *(unw_word_t *) DWARF_GET_LOC (loc) = val; return 0; } #else /* !UNW_LOCAL_ONLY */ # define DWARF_LOC_TYPE_FP (1 << 0) # define DWARF_LOC_TYPE_REG (1 << 1) # define DWARF_NULL_LOC DWARF_LOC (0, 0) # define DWARF_IS_NULL_LOC(l) \ ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) # define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) # define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) # define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) # define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) # define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ | DWARF_LOC_TYPE_FP)) static inline int dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) { char *valp = (char *) &val; unw_word_t addr; int ret; if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); addr = DWARF_GET_LOC (loc); if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, 0, c->as_arg)) < 0) return ret; return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, c->as_arg); } static inline int dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) { char *valp = (char *) &val; unw_word_t addr; int ret; if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), &val, 1, c->as_arg); addr = DWARF_GET_LOC (loc); if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, 1, c->as_arg)) < 0) return ret; return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 1, c->as_arg); } static inline int dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) { if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; /* If a code-generator were to save a value of type unw_word_t in a floating-point register, we would have to support this case. I suppose it could happen with MMX registers, but does it really happen? */ assert (!DWARF_IS_FP_LOC (loc)); if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); else return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); } static inline int dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) { if (DWARF_IS_NULL_LOC (loc)) return -UNW_EBADREG; /* If a code-generator were to save a value of type unw_word_t in a floating-point register, we would have to support this case. I suppose it could happen with MMX registers, but does it really happen? */ assert (!DWARF_IS_FP_LOC (loc)); if (DWARF_IS_REG_LOC (loc)) return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, 1, c->as_arg); else return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, 1, c->as_arg); } #endif /* !UNW_LOCAL_ONLY */ #define tdep_getcontext_trace unw_getcontext #define tdep_init_done UNW_OBJ(init_done) #define tdep_init UNW_OBJ(init) /* Platforms that support UNW_INFO_FORMAT_TABLE need to define tdep_search_unwind_table. */ #define tdep_search_unwind_table dwarf_search_unwind_table #define tdep_find_unwind_table dwarf_find_unwind_table #define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) #define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) #define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) #define tdep_access_reg UNW_OBJ(access_reg) #define tdep_access_fpreg UNW_OBJ(access_fpreg) #define tdep_fetch_frame(c,ip,n) do {} while(0) #define tdep_cache_frame(c) 0 #define tdep_reuse_frame(c,frame) do {} while(0) #define tdep_stash_frame(c,rs) do {} while(0) #define tdep_trace(cur,addr,n) (-UNW_ENOINFO) #ifdef UNW_LOCAL_ONLY # define tdep_find_proc_info(c,ip,n) \ dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ (c)->as_arg) # define tdep_put_unwind_info(as,pi,arg) \ dwarf_put_unwind_info((as), (pi), (arg)) #else # define tdep_find_proc_info(c,ip,n) \ (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ (c)->as_arg) # define tdep_put_unwind_info(as,pi,arg) \ (*(as)->acc.put_unwind_info)((as), (pi), (arg)) #endif #define tdep_get_as(c) ((c)->dwarf.as) #define tdep_get_as_arg(c) ((c)->dwarf.as_arg) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) ((as)->big_endian) extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, unw_dyn_info_t *di, unw_proc_info_t *pi, int need_unwind_info, void *arg); extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen); extern void tdep_get_exe_image_path (char *path); extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, int write); extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, int write); #endif /* SH_LIBUNWIND_I_H */
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.Date.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; using System.Buffers.Text; using System.Diagnostics; using System.Runtime.CompilerServices; namespace System.Text.Json { internal static partial class JsonWriterHelper { private static readonly StandardFormat s_dateTimeStandardFormat = new StandardFormat('O'); public static void WriteDateTimeTrimmed(Span<byte> buffer, DateTime value, out int bytesWritten) { Span<byte> tempSpan = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength]; bool result = Utf8Formatter.TryFormat(value, tempSpan, out bytesWritten, s_dateTimeStandardFormat); Debug.Assert(result); TrimDateTimeOffset(tempSpan.Slice(0, bytesWritten), out bytesWritten); tempSpan.Slice(0, bytesWritten).CopyTo(buffer); } public static void WriteDateTimeOffsetTrimmed(Span<byte> buffer, DateTimeOffset value, out int bytesWritten) { Span<byte> tempSpan = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength]; bool result = Utf8Formatter.TryFormat(value, tempSpan, out bytesWritten, s_dateTimeStandardFormat); Debug.Assert(result); TrimDateTimeOffset(tempSpan.Slice(0, bytesWritten), out bytesWritten); tempSpan.Slice(0, bytesWritten).CopyTo(buffer); } // // Trims roundtrippable DateTime(Offset) input. // If the milliseconds part of the date is zero, we omit the fraction part of the date, // else we write the fraction up to 7 decimal places with no trailing zeros. i.e. the output format is // YYYY-MM-DDThh:mm:ss[.s]TZD where TZD = Z or +-hh:mm. // e.g. // --------------------------------- // 2017-06-12T05:30:45.768-07:00 // 2017-06-12T05:30:45.00768Z (Z is short for "+00:00" but also distinguishes DateTimeKind.Utc from DateTimeKind.Local) // 2017-06-12T05:30:45 (interpreted as local time wrt to current time zone) public static void TrimDateTimeOffset(Span<byte> buffer, out int bytesWritten) { const int maxDateTimeLength = JsonConstants.MaximumFormatDateTimeLength; // Assert buffer is the right length for: // YYYY-MM-DDThh:mm:ss.fffffff (JsonConstants.MaximumFormatDateTimeLength) // YYYY-MM-DDThh:mm:ss.fffffffZ (JsonConstants.MaximumFormatDateTimeLength + 1) // YYYY-MM-DDThh:mm:ss.fffffff(+|-)hh:mm (JsonConstants.MaximumFormatDateTimeOffsetLength) Debug.Assert(buffer.Length == maxDateTimeLength || buffer.Length == maxDateTimeLength + 1 || buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength); // Find the last significant digit. int curIndex; if (buffer[maxDateTimeLength - 1] == '0') if (buffer[maxDateTimeLength - 2] == '0') if (buffer[maxDateTimeLength - 3] == '0') if (buffer[maxDateTimeLength - 4] == '0') if (buffer[maxDateTimeLength - 5] == '0') if (buffer[maxDateTimeLength - 6] == '0') if (buffer[maxDateTimeLength - 7] == '0') { // All decimal places are 0 so we can delete the decimal point too. curIndex = maxDateTimeLength - 7 - 1; } else { curIndex = maxDateTimeLength - 6; } else { curIndex = maxDateTimeLength - 5; } else { curIndex = maxDateTimeLength - 4; } else { curIndex = maxDateTimeLength - 3; } else { curIndex = maxDateTimeLength - 2; } else { curIndex = maxDateTimeLength - 1; } else { // There is nothing to trim. bytesWritten = buffer.Length; return; } // We are either trimming a DateTimeOffset, or a DateTime with // DateTimeKind.Local or DateTimeKind.Utc if (buffer.Length == maxDateTimeLength) { // There is no offset to copy. bytesWritten = curIndex; } else if (buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength) { // We have a non-UTC offset (+|-)hh:mm that are 6 characters to copy. buffer[curIndex] = buffer[maxDateTimeLength]; buffer[curIndex + 1] = buffer[maxDateTimeLength + 1]; buffer[curIndex + 2] = buffer[maxDateTimeLength + 2]; buffer[curIndex + 3] = buffer[maxDateTimeLength + 3]; buffer[curIndex + 4] = buffer[maxDateTimeLength + 4]; buffer[curIndex + 5] = buffer[maxDateTimeLength + 5]; bytesWritten = curIndex + 6; } else { // There is a single 'Z'. Just write it at the current index. Debug.Assert(buffer[maxDateTimeLength] == 'Z'); buffer[curIndex] = (byte)'Z'; bytesWritten = curIndex + 1; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; using System.Buffers.Text; using System.Diagnostics; using System.Runtime.CompilerServices; namespace System.Text.Json { internal static partial class JsonWriterHelper { private static readonly StandardFormat s_dateTimeStandardFormat = new StandardFormat('O'); public static void WriteDateTimeTrimmed(Span<byte> buffer, DateTime value, out int bytesWritten) { Span<byte> tempSpan = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength]; bool result = Utf8Formatter.TryFormat(value, tempSpan, out bytesWritten, s_dateTimeStandardFormat); Debug.Assert(result); TrimDateTimeOffset(tempSpan.Slice(0, bytesWritten), out bytesWritten); tempSpan.Slice(0, bytesWritten).CopyTo(buffer); } public static void WriteDateTimeOffsetTrimmed(Span<byte> buffer, DateTimeOffset value, out int bytesWritten) { Span<byte> tempSpan = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength]; bool result = Utf8Formatter.TryFormat(value, tempSpan, out bytesWritten, s_dateTimeStandardFormat); Debug.Assert(result); TrimDateTimeOffset(tempSpan.Slice(0, bytesWritten), out bytesWritten); tempSpan.Slice(0, bytesWritten).CopyTo(buffer); } // // Trims roundtrippable DateTime(Offset) input. // If the milliseconds part of the date is zero, we omit the fraction part of the date, // else we write the fraction up to 7 decimal places with no trailing zeros. i.e. the output format is // YYYY-MM-DDThh:mm:ss[.s]TZD where TZD = Z or +-hh:mm. // e.g. // --------------------------------- // 2017-06-12T05:30:45.768-07:00 // 2017-06-12T05:30:45.00768Z (Z is short for "+00:00" but also distinguishes DateTimeKind.Utc from DateTimeKind.Local) // 2017-06-12T05:30:45 (interpreted as local time wrt to current time zone) public static void TrimDateTimeOffset(Span<byte> buffer, out int bytesWritten) { const int maxDateTimeLength = JsonConstants.MaximumFormatDateTimeLength; // Assert buffer is the right length for: // YYYY-MM-DDThh:mm:ss.fffffff (JsonConstants.MaximumFormatDateTimeLength) // YYYY-MM-DDThh:mm:ss.fffffffZ (JsonConstants.MaximumFormatDateTimeLength + 1) // YYYY-MM-DDThh:mm:ss.fffffff(+|-)hh:mm (JsonConstants.MaximumFormatDateTimeOffsetLength) Debug.Assert(buffer.Length == maxDateTimeLength || buffer.Length == maxDateTimeLength + 1 || buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength); // Find the last significant digit. int curIndex; if (buffer[maxDateTimeLength - 1] == '0') if (buffer[maxDateTimeLength - 2] == '0') if (buffer[maxDateTimeLength - 3] == '0') if (buffer[maxDateTimeLength - 4] == '0') if (buffer[maxDateTimeLength - 5] == '0') if (buffer[maxDateTimeLength - 6] == '0') if (buffer[maxDateTimeLength - 7] == '0') { // All decimal places are 0 so we can delete the decimal point too. curIndex = maxDateTimeLength - 7 - 1; } else { curIndex = maxDateTimeLength - 6; } else { curIndex = maxDateTimeLength - 5; } else { curIndex = maxDateTimeLength - 4; } else { curIndex = maxDateTimeLength - 3; } else { curIndex = maxDateTimeLength - 2; } else { curIndex = maxDateTimeLength - 1; } else { // There is nothing to trim. bytesWritten = buffer.Length; return; } // We are either trimming a DateTimeOffset, or a DateTime with // DateTimeKind.Local or DateTimeKind.Utc if (buffer.Length == maxDateTimeLength) { // There is no offset to copy. bytesWritten = curIndex; } else if (buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength) { // We have a non-UTC offset (+|-)hh:mm that are 6 characters to copy. buffer[curIndex] = buffer[maxDateTimeLength]; buffer[curIndex + 1] = buffer[maxDateTimeLength + 1]; buffer[curIndex + 2] = buffer[maxDateTimeLength + 2]; buffer[curIndex + 3] = buffer[maxDateTimeLength + 3]; buffer[curIndex + 4] = buffer[maxDateTimeLength + 4]; buffer[curIndex + 5] = buffer[maxDateTimeLength + 5]; bytesWritten = curIndex + 6; } else { // There is a single 'Z'. Just write it at the current index. Debug.Assert(buffer[maxDateTimeLength] == 'Z'); buffer[curIndex] = (byte)'Z'; bytesWritten = curIndex + 1; } } } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidity.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Xml.Schema { public enum XmlSchemaValidity { NotKnown, Valid, Invalid, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Xml.Schema { public enum XmlSchemaValidity { NotKnown, Valid, Invalid, } }
-1
dotnet/runtime
66,111
Update RegexGenerator to require LangVersion > 10
We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
stephentoub
2022-03-02T21:41:16Z
2022-03-03T04:10:47Z
83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71
c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e
Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired.
./src/tests/JIT/CodeGenBringUpTests/CnsLng1_do.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="CnsLng1.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="CnsLng1.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.Tracing; using System.Collections.Generic; using Microsoft.Diagnostics.Tools.RuntimeClient; using Tracing.Tests.Common; namespace Tracing.Tests.ExceptionThrown_V1 { public class ProviderValidation { public static int Main(string[] args) { var providers = new List<Provider>() { new Provider("Microsoft-DotNETCore-SampleProfiler"), //ExceptionKeyword (0x8000): 0b1000_0000_0000_0000 new Provider("Microsoft-Windows-DotNETRuntime", 0b1000_0000_0000_0000, EventLevel.Warning) }; var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers); return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration); } private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() { { "Microsoft-Windows-DotNETRuntime", new ExpectedEventCount(1000, 0.2f) }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 1000; i++) { if (i % 100 == 0) Logger.logger.Log($"Thrown an excpetion {i} times..."); try { throw new ArgumentNullException("Throw ArgumentNullException"); } catch (Exception e) { //Do nothing } } }; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.Tracing; using System.Collections.Generic; using Tracing.Tests.Common; using Microsoft.Diagnostics.NETCore.Client; namespace Tracing.Tests.ExceptionThrown_V1 { public class ProviderValidation { public static int Main(string[] args) { var providers = new List<EventPipeProvider>() { new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose), //ExceptionKeyword (0x8000): 0b1000_0000_0000_0000 new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Warning, 0b1000_0000_0000_0000) }; return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024); } private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() { { "Microsoft-Windows-DotNETRuntime", new ExpectedEventCount(1000, 0.2f) }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 1000; i++) { if (i % 100 == 0) Logger.logger.Log($"Thrown an excpetion {i} times..."); try { throw new ArgumentNullException("Throw ArgumentNullException"); } catch (Exception e) { //Do nothing } } }; } }
1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <OutputType>exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <JitOptimizationSensitive>true</JitOptimizationSensitive> <!-- This test isn't technically incompatible with GCStress, but it ends up running very slowly in some configurations, e.g. GCStress=3 on Linux/arm32 measured at 15 minutes. --> <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="ExceptionThrown_V1.cs" /> <ProjectReference Include="../common/common.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <OutputType>exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <JitOptimizationSensitive>true</JitOptimizationSensitive> <!-- This test isn't technically incompatible with GCStress, but it ends up running very slowly in some configurations, e.g. GCStress=3 on Linux/arm32 measured at 15 minutes. --> <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="ExceptionThrown_V1.cs" /> <ProjectReference Include="../common/common.csproj" /> <ProjectReference Include="../common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" /> </ItemGroup> </Project>
1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/tracing/eventpipe/eventsvalidation/GCEvents.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.Tracing; using System.Collections.Generic; using Microsoft.Diagnostics.Tools.RuntimeClient; using Microsoft.Diagnostics.Tracing; using Tracing.Tests.Common; namespace Tracing.Tests.GCEvents { public class ProviderValidation { public static int Main(string[] args) { var providers = new List<Provider>() { new Provider("Microsoft-DotNETCore-SampleProfiler"), //GCKeyword (0x1): 0b1 new Provider("Microsoft-Windows-DotNETRuntime", 0b1, EventLevel.Informational) }; var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers); return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _DoesTraceContainEvents); } private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() { { "Microsoft-Windows-DotNETRuntime", -1 }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 50; i++) { if (i % 10 == 0) Logger.logger.Log($"Called GC.Collect() {i} times..."); ProviderValidation providerValidation = new ProviderValidation(); providerValidation = null; GC.Collect(); } }; private static Func<EventPipeEventSource, Func<int>> _DoesTraceContainEvents = (source) => { int GCStartEvents = 0; int GCEndEvents = 0; source.Clr.GCStart += (eventData) => GCStartEvents += 1; source.Clr.GCStop += (eventData) => GCEndEvents += 1; int GCRestartEEStartEvents = 0; int GCRestartEEStopEvents = 0; source.Clr.GCRestartEEStart += (eventData) => GCRestartEEStartEvents += 1; source.Clr.GCRestartEEStop += (eventData) => GCRestartEEStopEvents += 1; int GCSuspendEEEvents = 0; int GCSuspendEEEndEvents = 0; source.Clr.GCSuspendEEStart += (eventData) => GCSuspendEEEvents += 1; source.Clr.GCSuspendEEStop += (eventData) => GCSuspendEEEndEvents += 1; return () => { Logger.logger.Log("Event counts validation"); Logger.logger.Log("GCStartEvents: " + GCStartEvents); Logger.logger.Log("GCEndEvents: " + GCEndEvents); bool GCStartStopResult = GCStartEvents >= 50 && GCEndEvents >= 50 && Math.Abs(GCStartEvents - GCEndEvents) <=2; Logger.logger.Log("GCStartStopResult check: " + GCStartStopResult); Logger.logger.Log("GCRestartEEStartEvents: " + GCRestartEEStartEvents); Logger.logger.Log("GCRestartEEStopEvents: " + GCRestartEEStopEvents); bool GCRestartEEStartStopResult = GCRestartEEStartEvents >= 50 && GCRestartEEStopEvents >= 50; Logger.logger.Log("GCRestartEEStartStopResult check: " + GCRestartEEStartStopResult); Logger.logger.Log("GCSuspendEEEvents: " + GCSuspendEEEvents); Logger.logger.Log("GCSuspendEEEndEvents: " + GCSuspendEEEndEvents); bool GCSuspendEEStartStopResult = GCSuspendEEEvents >= 50 && GCSuspendEEEndEvents >= 50; Logger.logger.Log("GCSuspendEEStartStopResult check: " + GCSuspendEEStartStopResult); return GCStartStopResult && GCRestartEEStartStopResult && GCSuspendEEStartStopResult ? 100 : -1; }; }; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.Tracing; using System.Collections.Generic; using Microsoft.Diagnostics.Tracing; using Tracing.Tests.Common; using Microsoft.Diagnostics.NETCore.Client; namespace Tracing.Tests.GCEvents { public class ProviderValidation { public static int Main(string[] args) { var providers = new List<EventPipeProvider>() { new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose), //GCKeyword (0x1): 0b1 new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1) }; return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents); } private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() { { "Microsoft-Windows-DotNETRuntime", -1 }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 50; i++) { if (i % 10 == 0) Logger.logger.Log($"Called GC.Collect() {i} times..."); ProviderValidation providerValidation = new ProviderValidation(); providerValidation = null; GC.Collect(); } }; private static Func<EventPipeEventSource, Func<int>> _DoesTraceContainEvents = (source) => { int GCStartEvents = 0; int GCEndEvents = 0; source.Clr.GCStart += (eventData) => GCStartEvents += 1; source.Clr.GCStop += (eventData) => GCEndEvents += 1; int GCRestartEEStartEvents = 0; int GCRestartEEStopEvents = 0; source.Clr.GCRestartEEStart += (eventData) => GCRestartEEStartEvents += 1; source.Clr.GCRestartEEStop += (eventData) => GCRestartEEStopEvents += 1; int GCSuspendEEEvents = 0; int GCSuspendEEEndEvents = 0; source.Clr.GCSuspendEEStart += (eventData) => GCSuspendEEEvents += 1; source.Clr.GCSuspendEEStop += (eventData) => GCSuspendEEEndEvents += 1; return () => { Logger.logger.Log("Event counts validation"); Logger.logger.Log("GCStartEvents: " + GCStartEvents); Logger.logger.Log("GCEndEvents: " + GCEndEvents); bool GCStartStopResult = GCStartEvents >= 50 && GCEndEvents >= 50 && Math.Abs(GCStartEvents - GCEndEvents) <=2; Logger.logger.Log("GCStartStopResult check: " + GCStartStopResult); Logger.logger.Log("GCRestartEEStartEvents: " + GCRestartEEStartEvents); Logger.logger.Log("GCRestartEEStopEvents: " + GCRestartEEStopEvents); bool GCRestartEEStartStopResult = GCRestartEEStartEvents >= 50 && GCRestartEEStopEvents >= 50; Logger.logger.Log("GCRestartEEStartStopResult check: " + GCRestartEEStartStopResult); Logger.logger.Log("GCSuspendEEEvents: " + GCSuspendEEEvents); Logger.logger.Log("GCSuspendEEEndEvents: " + GCSuspendEEEndEvents); bool GCSuspendEEStartStopResult = GCSuspendEEEvents >= 50 && GCSuspendEEEndEvents >= 50; Logger.logger.Log("GCSuspendEEStartStopResult check: " + GCSuspendEEStartStopResult); return GCStartStopResult && GCRestartEEStartStopResult && GCSuspendEEStartStopResult ? 100 : -1; }; }; } }
1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/tracing/eventpipe/eventsvalidation/GCEvents.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <OutputType>exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <JitOptimizationSensitive>true</JitOptimizationSensitive> <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="GCEvents.cs" /> <ProjectReference Include="../common/common.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <OutputType>exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <JitOptimizationSensitive>true</JitOptimizationSensitive> <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="GCEvents.cs" /> <ProjectReference Include="../common/common.csproj" /> <ProjectReference Include="../common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" /> </ItemGroup> </Project>
1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.Tracing; using System.Collections.Generic; using Microsoft.Diagnostics.Tools.RuntimeClient; using Microsoft.Diagnostics.Tracing; using Tracing.Tests.Common; namespace Tracing.Tests.GCFinalizers { public class ProviderValidation { public static int Main(string[] args) { var providers = new List<Provider>() { new Provider("Microsoft-DotNETCore-SampleProfiler"), //GCKeyword (0x1): 0b1 new Provider("Microsoft-Windows-DotNETRuntime", 0b1, EventLevel.Informational) }; var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers); return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _DoesTraceContainEvents); } private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() { { "Microsoft-Windows-DotNETRuntime", -1 }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 50; i++) { if (i % 10 == 0) Logger.logger.Log($"Called GC.WaitForPendingFinalizers() {i} times..."); ProviderValidation providerValidation = new ProviderValidation(); providerValidation = null; GC.WaitForPendingFinalizers(); } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }; private static Func<EventPipeEventSource, Func<int>> _DoesTraceContainEvents = (source) => { int GCFinalizersEndEvents = 0; source.Clr.GCFinalizersStop += (eventData) => GCFinalizersEndEvents += 1; int GCFinalizersStartEvents = 0; source.Clr.GCFinalizersStart += (eventData) => GCFinalizersStartEvents += 1; return () => { Logger.logger.Log("Event counts validation"); Logger.logger.Log("GCFinalizersEndEvents: " + GCFinalizersEndEvents); Logger.logger.Log("GCFinalizersStartEvents: " + GCFinalizersStartEvents); return GCFinalizersEndEvents >= 50 && GCFinalizersStartEvents >= 50 ? 100 : -1; }; }; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.Tracing; using System.Collections.Generic; using Microsoft.Diagnostics.NETCore.Client; using Microsoft.Diagnostics.Tracing; using Tracing.Tests.Common; namespace Tracing.Tests.GCFinalizers { public class ProviderValidation { public static int Main(string[] args) { var providers = new List<EventPipeProvider>() { new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose), //GCKeyword (0x1): 0b1 new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1) }; return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents); } private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() { { "Microsoft-Windows-DotNETRuntime", -1 }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 50; i++) { if (i % 10 == 0) Logger.logger.Log($"Called GC.WaitForPendingFinalizers() {i} times..."); ProviderValidation providerValidation = new ProviderValidation(); providerValidation = null; GC.WaitForPendingFinalizers(); } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }; private static Func<EventPipeEventSource, Func<int>> _DoesTraceContainEvents = (source) => { int GCFinalizersEndEvents = 0; source.Clr.GCFinalizersStop += (eventData) => GCFinalizersEndEvents += 1; int GCFinalizersStartEvents = 0; source.Clr.GCFinalizersStart += (eventData) => GCFinalizersStartEvents += 1; return () => { Logger.logger.Log("Event counts validation"); Logger.logger.Log("GCFinalizersEndEvents: " + GCFinalizersEndEvents); Logger.logger.Log("GCFinalizersStartEvents: " + GCFinalizersStartEvents); return GCFinalizersEndEvents >= 50 && GCFinalizersStartEvents >= 50 ? 100 : -1; }; }; } }
1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <OutputType>exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <JitOptimizationSensitive>true</JitOptimizationSensitive> <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="GCFinalizers.cs" /> <ProjectReference Include="../common/common.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <OutputType>exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> <UnloadabilityIncompatible>true</UnloadabilityIncompatible> <JitOptimizationSensitive>true</JitOptimizationSensitive> <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="GCFinalizers.cs" /> <ProjectReference Include="../common/common.csproj" /> <ProjectReference Include="../common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" /> </ItemGroup> </Project>
1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Net.Http/tests/UnitTests/Headers/GenericHeaderParserTest/AuthenticationParserTest.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Headers; using System.Text; using Xunit; namespace System.Net.Http.Tests { public class AuthenticationParserTest { [Fact] public void Properties_ReadValues_MatchExpectation() { HttpHeaderParser parser = GenericHeaderParser.MultipleValueAuthenticationParser; Assert.True(parser.SupportsMultipleValues); Assert.Null(parser.Comparer); parser = GenericHeaderParser.SingleValueAuthenticationParser; Assert.False(parser.SupportsMultipleValues); } [Fact] public void TryParse_SetOfValidValueStrings_ParsedCorrectly() { // Note that there is no difference between setting "SupportMultipleValues" to true or false: The parser // is only able to parse one authentication information per string. Setting "SupportMultipleValues" just // tells the caller (HttpHeaders) that parsing multiple strings is allowed. CheckValidParsedValue("X NTLM ", 1, new AuthenticationHeaderValue("NTLM"), 7, true); CheckValidParsedValue("X NTLM ", 1, new AuthenticationHeaderValue("NTLM"), 7, false); CheckValidParsedValue("custom x=y", 0, new AuthenticationHeaderValue("Custom", "x=y"), 10, true); CheckValidParsedValue("custom x=y", 0, new AuthenticationHeaderValue("Custom", "x=y"), 10, false); CheckValidParsedValue("C x=y, other", 0, new AuthenticationHeaderValue("C", "x=y"), 7, true); CheckValidParsedValue(" ", 0, null, 2, true); CheckValidParsedValue(null, 0, null, 0, true); CheckValidParsedValue("", 0, null, 0, true); } [Fact] public void TryParse_SetOfInvalidValueStrings_ReturnsFalse() { CheckInvalidParsedValue("NTLM[", 0, true); // only delimiter ',' allowed after last range CheckInvalidParsedValue("NTLM[", 0, false); // only delimiter ',' allowed after last range CheckInvalidParsedValue("]NTLM", 0, true); CheckInvalidParsedValue("]NTLM", 0, false); CheckInvalidParsedValue("C x=y, other", 0, false); CheckInvalidParsedValue("C x=y,", 0, false); CheckInvalidParsedValue(" ", 0, false); CheckInvalidParsedValue(null, 0, false); CheckInvalidParsedValue(string.Empty, 0, false); } #region Helper methods private void CheckValidParsedValue(string input, int startIndex, AuthenticationHeaderValue expectedResult, int expectedIndex, bool supportMultipleValues) { HttpHeaderParser parser = null; if (supportMultipleValues) { parser = GenericHeaderParser.MultipleValueAuthenticationParser; } else { parser = GenericHeaderParser.SingleValueAuthenticationParser; } object result = null; Assert.True(parser.TryParseValue(input, null, ref startIndex, out result), string.Format("TryParse returned false. Input: '{0}'", input)); Assert.Equal(expectedIndex, startIndex); Assert.Equal(result, expectedResult); } private void CheckInvalidParsedValue(string input, int startIndex, bool supportMultipleValues) { HttpHeaderParser parser = null; if (supportMultipleValues) { parser = GenericHeaderParser.MultipleValueAuthenticationParser; } else { parser = GenericHeaderParser.SingleValueAuthenticationParser; } object result = null; int newIndex = startIndex; Assert.False(parser.TryParseValue(input, null, ref newIndex, out result), string.Format("TryParse returned true. Input: '{0}'", input)); Assert.Null(result); Assert.Equal(startIndex, newIndex); } #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Headers; using System.Text; using Xunit; namespace System.Net.Http.Tests { public class AuthenticationParserTest { [Fact] public void Properties_ReadValues_MatchExpectation() { HttpHeaderParser parser = GenericHeaderParser.MultipleValueAuthenticationParser; Assert.True(parser.SupportsMultipleValues); Assert.Null(parser.Comparer); parser = GenericHeaderParser.SingleValueAuthenticationParser; Assert.False(parser.SupportsMultipleValues); } [Fact] public void TryParse_SetOfValidValueStrings_ParsedCorrectly() { // Note that there is no difference between setting "SupportMultipleValues" to true or false: The parser // is only able to parse one authentication information per string. Setting "SupportMultipleValues" just // tells the caller (HttpHeaders) that parsing multiple strings is allowed. CheckValidParsedValue("X NTLM ", 1, new AuthenticationHeaderValue("NTLM"), 7, true); CheckValidParsedValue("X NTLM ", 1, new AuthenticationHeaderValue("NTLM"), 7, false); CheckValidParsedValue("custom x=y", 0, new AuthenticationHeaderValue("Custom", "x=y"), 10, true); CheckValidParsedValue("custom x=y", 0, new AuthenticationHeaderValue("Custom", "x=y"), 10, false); CheckValidParsedValue("C x=y, other", 0, new AuthenticationHeaderValue("C", "x=y"), 7, true); CheckValidParsedValue(" ", 0, null, 2, true); CheckValidParsedValue(null, 0, null, 0, true); CheckValidParsedValue("", 0, null, 0, true); } [Fact] public void TryParse_SetOfInvalidValueStrings_ReturnsFalse() { CheckInvalidParsedValue("NTLM[", 0, true); // only delimiter ',' allowed after last range CheckInvalidParsedValue("NTLM[", 0, false); // only delimiter ',' allowed after last range CheckInvalidParsedValue("]NTLM", 0, true); CheckInvalidParsedValue("]NTLM", 0, false); CheckInvalidParsedValue("C x=y, other", 0, false); CheckInvalidParsedValue("C x=y,", 0, false); CheckInvalidParsedValue(" ", 0, false); CheckInvalidParsedValue(null, 0, false); CheckInvalidParsedValue(string.Empty, 0, false); } #region Helper methods private void CheckValidParsedValue(string input, int startIndex, AuthenticationHeaderValue expectedResult, int expectedIndex, bool supportMultipleValues) { HttpHeaderParser parser = null; if (supportMultipleValues) { parser = GenericHeaderParser.MultipleValueAuthenticationParser; } else { parser = GenericHeaderParser.SingleValueAuthenticationParser; } object result = null; Assert.True(parser.TryParseValue(input, null, ref startIndex, out result), string.Format("TryParse returned false. Input: '{0}'", input)); Assert.Equal(expectedIndex, startIndex); Assert.Equal(result, expectedResult); } private void CheckInvalidParsedValue(string input, int startIndex, bool supportMultipleValues) { HttpHeaderParser parser = null; if (supportMultipleValues) { parser = GenericHeaderParser.MultipleValueAuthenticationParser; } else { parser = GenericHeaderParser.SingleValueAuthenticationParser; } object result = null; int newIndex = startIndex; Assert.False(parser.TryParseValue(input, null, ref newIndex, out result), string.Format("TryParse returned true. Input: '{0}'", input)); Assert.Null(result); Assert.Equal(startIndex, newIndex); } #endregion } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.CodeDom/src/System/CodeDom/CodePropertyReferenceExpression.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.CodeDom { public class CodePropertyReferenceExpression : CodeExpression { private string _propertyName; public CodePropertyReferenceExpression() { } public CodePropertyReferenceExpression(CodeExpression targetObject, string propertyName) { TargetObject = targetObject; PropertyName = propertyName; } public CodeExpression TargetObject { get; set; } public string PropertyName { get => _propertyName ?? string.Empty; set => _propertyName = value; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.CodeDom { public class CodePropertyReferenceExpression : CodeExpression { private string _propertyName; public CodePropertyReferenceExpression() { } public CodePropertyReferenceExpression(CodeExpression targetObject, string propertyName) { TargetObject = targetObject; PropertyName = propertyName; } public CodeExpression TargetObject { get; set; } public string PropertyName { get => _propertyName ?? string.Empty; set => _propertyName = value; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PerformanceCounterOptions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Kernel32 { internal static partial class PerformanceCounterOptions { internal const int SDDL_REVISION_1 = 1; public const int PERF_NO_INSTANCES = -1; // no instances (see NumInstances above) public const int PERF_SIZE_DWORD = 0x00000000; public const int PERF_SIZE_LARGE = 0x00000100; public const int PERF_SIZE_ZERO = 0x00000200; // for Zero Length fields public const int PERF_SIZE_VARIABLE_LEN = 0x00000300; // length is In CounterLength field public const int PERF_NO_UNIQUE_ID = -1; // // select one of the following values to indicate the counter field usage // public const int PERF_TYPE_NUMBER = 0x00000000; // a number (not a counter) public const int PERF_TYPE_COUNTER = 0x00000400; // an increasing numeric value public const int PERF_TYPE_TEXT = 0x00000800; // a text field public const int PERF_TYPE_ZERO = 0x00000C00; // displays a zero // // If the PERF_TYPE_NUMBER field was selected, then select one of the // following to describe the Number // public const int PERF_NUMBER_HEX = 0x00000000; // display as HEX value public const int PERF_NUMBER_DECIMAL = 0x00010000; // display as a decimal integer public const int PERF_NUMBER_DEC_1000 = 0x00020000; // display as a decimal/1000 // // If the PERF_TYPE_COUNTER value was selected then select one of the // following to indicate the type of counter // public const int PERF_COUNTER_VALUE = 0x00000000; // display counter value public const int PERF_COUNTER_RATE = 0x00010000; // divide ctr / delta time public const int PERF_COUNTER_FRACTION = 0x00020000; // divide ctr / base public const int PERF_COUNTER_BASE = 0x00030000; // base value used In fractions public const int PERF_COUNTER_ELAPSED = 0x00040000; // subtract counter from current time public const int PERF_COUNTER_QUEUELEN = 0x00050000; // Use Queuelen processing func. public const int PERF_COUNTER_HISTOGRAM = 0x00060000; // Counter begins or ends a histogram public const int PERF_COUNTER_PRECISION = 0x00070000; // divide ctr / private clock // // If the PERF_TYPE_TEXT value was selected, then select one of the // following to indicate the type of TEXT data. // public const int PERF_TEXT_UNICODE = 0x00000000; // type of text In text field public const int PERF_TEXT_ASCII = 0x00010000; // ASCII using the CodePage field // // Timer SubTypes // public const int PERF_TIMER_TICK = 0x00000000; // use system perf. freq for base public const int PERF_TIMER_100NS = 0x00100000; // use 100 NS timer time base units public const int PERF_OBJECT_TIMER = 0x00200000; // use the object timer freq // // Any types that have calculations performed can use one or more of // the following calculation modification flags listed here // public const int PERF_DELTA_COUNTER = 0x00400000; // compute difference first public const int PERF_DELTA_BASE = 0x00800000; // compute base diff as well public const int PERF_INVERSE_COUNTER = 0x01000000; // show as 1.00-value (assumes: public const int PERF_MULTI_COUNTER = 0x02000000; // sum of multiple instances // // Select one of the following values to indicate the display suffix (if any) // public const int PERF_DISPLAY_NO_SUFFIX = 0x00000000; // no suffix public const int PERF_DISPLAY_PER_SEC = 0x10000000; // "/sec" public const int PERF_DISPLAY_PERCENT = 0x20000000; // "%" public const int PERF_DISPLAY_SECONDS = 0x30000000; // "secs" public const int PERF_DISPLAY_NOSHOW = 0x40000000; // value is not displayed // // Predefined counter types // // 32-bit Counter. Divide delta by delta time. Display suffix: "/sec" public const int PERF_COUNTER_COUNTER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC); // 64-bit Timer. Divide delta by delta time. Display suffix: "%" public const int PERF_COUNTER_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_QUEUELEN_TYPE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_LARGE_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product using 100 Ns timebase. // Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_100NS_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product using Object specific timebase. // Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // 64-bit Counter. Divide delta by delta time. Display Suffix: "/sec" public const int PERF_COUNTER_BULK_COUNT = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC); // Indicates the counter is not a counter but rather Unicode text Display as text. public const int PERF_COUNTER_TEXT = (PERF_SIZE_VARIABLE_LEN | PERF_TYPE_TEXT | PERF_TEXT_UNICODE | PERF_DISPLAY_NO_SUFFIX); // Indicates the data is a counter which should not be // time averaged on display (such as an error counter on a serial line) // Display as is. No Display Suffix. public const int PERF_COUNTER_RAWCOUNT = (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX); // Same as PERF_COUNTER_RAWCOUNT except its size is a large integer public const int PERF_COUNTER_LARGE_RAWCOUNT = (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX); // Special case for RAWCOUNT that want to be displayed In hex // Indicates the data is a counter which should not be // time averaged on display (such as an error counter on a serial line) // Display as is. No Display Suffix. public const int PERF_COUNTER_RAWCOUNT_HEX = (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_HEX | PERF_DISPLAY_NO_SUFFIX); // Same as PERF_COUNTER_RAWCOUNT_HEX except its size is a large integer public const int PERF_COUNTER_LARGE_RAWCOUNT_HEX = (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_HEX | PERF_DISPLAY_NO_SUFFIX); // A count which is either 1 or 0 on each sampling interrupt (% busy) // Divide delta by delta base. Display Suffix: "%" public const int PERF_SAMPLE_FRACTION = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DELTA_COUNTER | PERF_DELTA_BASE | PERF_DISPLAY_PERCENT); // A count which is sampled on each sampling interrupt (queue length) // Divide delta by delta time. No Display Suffix. public const int PERF_SAMPLE_COUNTER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // A label: no data is associated with this counter (it has 0 length) // Do not display. public const int PERF_COUNTER_NODATA = (PERF_SIZE_ZERO | PERF_DISPLAY_NOSHOW); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 - delta divided by delta time. Display suffix: "%" public const int PERF_COUNTER_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // The divisor for a sample, used with the previous counter to form a // sampled %. You must check for >0 before dividing by this! This // counter will directly follow the numerator counter. It should not // be displayed to the user. public const int PERF_SAMPLE_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000001); // for compatibility with pre-beta versions // A timer which, when divided by an average base, produces a time // In seconds which is the average time of some operation. This // timer times total operations, and the base is the number of opera- // tions. Display Suffix: "sec" public const int PERF_AVERAGE_TIMER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_SECONDS); // Used as the denominator In the computation of time or count // averages. Must directly follow the numerator counter. Not dis- // played to the user. public const int PERF_AVERAGE_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000002); // for compatibility with pre-beta versions // 64-bit Timer in object specific units. Display delta divided by // delta time as returned in the object type header structure. Display suffix: "%" public const int PERF_OBJ_TIME_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // A bulk count which, when divided (typically) by the number of // operations, gives (typically) the number of bytes per operation. // No Display Suffix. public const int PERF_AVERAGE_BULK = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_NOSHOW); // 64-bit Timer in object specific units. Display delta divided by // delta time as returned in the object type header structure. Display suffix: "%" public const int PERF_OBJ_TIME_TIME = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer In 100 nsec units. Display delta divided by // delta time. Display suffix: "%" public const int PERF_100NSEC_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 - delta divided by delta time. Display suffix: "%" public const int PERF_100NSEC_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer. Divide delta by delta time. Display suffix: "%" // Timer for multiple instances, so result can exceed 100%. public const int PERF_COUNTER_MULTI_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_DELTA_COUNTER | PERF_TIMER_TICK | PERF_MULTI_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 * _MULTI_BASE - delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result // can exceed 100%. Followed by a counter of type _MULTI_BASE. public const int PERF_COUNTER_MULTI_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_DELTA_COUNTER | PERF_MULTI_COUNTER | PERF_TIMER_TICK | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // Number of instances to which the preceding _MULTI_..._INV counter // applies. Used as a factor to get the percentage. public const int PERF_COUNTER_MULTI_BASE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_MULTI_COUNTER | PERF_DISPLAY_NOSHOW); // 64-bit Timer In 100 nsec units. Display delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result can exceed 100%. public const int PERF_100NSEC_MULTI_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 * _MULTI_BASE - delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result // can exceed 100%. Followed by a counter of type _MULTI_BASE. public const int PERF_100NSEC_MULTI_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // Indicates the data is a fraction of the following counter which // should not be time averaged on display (such as free space over // total space.) Display as is. Display the quotient as "%". public const int PERF_RAW_FRACTION = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_PERCENT); public const int PERF_LARGE_RAW_FRACTION = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_PERCENT); // Indicates the data is a base for the preceding counter which should // not be time averaged on display (such as free space over total space.) public const int PERF_RAW_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000003); // for compatibility with pre-beta versions public const int PERF_LARGE_RAW_BASE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW); // The data collected In this counter is actually the start time of the // item being measured. For display, this data is subtracted from the // sample time to yield the elapsed time as the difference between the two. // In the definition below, the PerfTime field of the Object contains // the sample time as indicated by the PERF_OBJECT_TIMER bit and the // difference is scaled by the PerfFreq of the Object to convert the time // units into seconds. public const int PERF_ELAPSED_TIME = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_ELAPSED | PERF_OBJECT_TIMER | PERF_DISPLAY_SECONDS); // // The following counter type can be used with the preceding types to // define a range of values to be displayed In a histogram. // // // This counter is used to display the difference from one sample // to the next. The counter value is a constantly increasing number // and the value displayed is the difference between the current // value and the previous value. Negative numbers are not allowed // which shouldn't be a problem as long as the counter value is // increasing or unchanged. // public const int PERF_COUNTER_DELTA = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); public const int PERF_COUNTER_LARGE_DELTA = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // The timer used has the same frequency as the System Performance Timer public const int PERF_PRECISION_SYSTEM_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // // The timer used has the same frequency as the 100 NanoSecond Timer public const int PERF_PRECISION_100NS_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // // The timer used is of the frequency specified in the Object header's // PerfFreq field (PerfTime is ignored) public const int PERF_PRECISION_OBJECT_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); public const uint PDH_FMT_DOUBLE = 0x00000200; public const uint PDH_FMT_NOSCALE = 0x00001000; public const uint PDH_FMT_NOCAP100 = 0x00008000; [StructLayout(LayoutKind.Sequential)] public struct PDH_RAW_COUNTER { public int CStatus; public long TimeStamp; public long FirstValue; public long SecondValue; public int MultiCount; } [StructLayout(LayoutKind.Sequential)] public struct PDH_FMT_COUNTERVALUE { public int CStatus; public double data; } public const int PDH_NO_DATA = unchecked((int)0x800007D5); public const int PDH_CALC_NEGATIVE_DENOMINATOR = unchecked((int)0x800007D6); public const int PDH_CALC_NEGATIVE_VALUE = unchecked((int)0x800007D8); // // The following are used to determine the level of detail associated // with the counter. The user will be setting the level of detail // that should be displayed at any given time. // public const int PERF_DETAIL_NOVICE = 100; // The uninformed can understand it public const int PERF_DETAIL_ADVANCED = 200; // For the advanced user public const int PERF_DETAIL_EXPERT = 300; // For the expert user public const int PERF_DETAIL_WIZARD = 400; // For the system designer } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Kernel32 { internal static partial class PerformanceCounterOptions { internal const int SDDL_REVISION_1 = 1; public const int PERF_NO_INSTANCES = -1; // no instances (see NumInstances above) public const int PERF_SIZE_DWORD = 0x00000000; public const int PERF_SIZE_LARGE = 0x00000100; public const int PERF_SIZE_ZERO = 0x00000200; // for Zero Length fields public const int PERF_SIZE_VARIABLE_LEN = 0x00000300; // length is In CounterLength field public const int PERF_NO_UNIQUE_ID = -1; // // select one of the following values to indicate the counter field usage // public const int PERF_TYPE_NUMBER = 0x00000000; // a number (not a counter) public const int PERF_TYPE_COUNTER = 0x00000400; // an increasing numeric value public const int PERF_TYPE_TEXT = 0x00000800; // a text field public const int PERF_TYPE_ZERO = 0x00000C00; // displays a zero // // If the PERF_TYPE_NUMBER field was selected, then select one of the // following to describe the Number // public const int PERF_NUMBER_HEX = 0x00000000; // display as HEX value public const int PERF_NUMBER_DECIMAL = 0x00010000; // display as a decimal integer public const int PERF_NUMBER_DEC_1000 = 0x00020000; // display as a decimal/1000 // // If the PERF_TYPE_COUNTER value was selected then select one of the // following to indicate the type of counter // public const int PERF_COUNTER_VALUE = 0x00000000; // display counter value public const int PERF_COUNTER_RATE = 0x00010000; // divide ctr / delta time public const int PERF_COUNTER_FRACTION = 0x00020000; // divide ctr / base public const int PERF_COUNTER_BASE = 0x00030000; // base value used In fractions public const int PERF_COUNTER_ELAPSED = 0x00040000; // subtract counter from current time public const int PERF_COUNTER_QUEUELEN = 0x00050000; // Use Queuelen processing func. public const int PERF_COUNTER_HISTOGRAM = 0x00060000; // Counter begins or ends a histogram public const int PERF_COUNTER_PRECISION = 0x00070000; // divide ctr / private clock // // If the PERF_TYPE_TEXT value was selected, then select one of the // following to indicate the type of TEXT data. // public const int PERF_TEXT_UNICODE = 0x00000000; // type of text In text field public const int PERF_TEXT_ASCII = 0x00010000; // ASCII using the CodePage field // // Timer SubTypes // public const int PERF_TIMER_TICK = 0x00000000; // use system perf. freq for base public const int PERF_TIMER_100NS = 0x00100000; // use 100 NS timer time base units public const int PERF_OBJECT_TIMER = 0x00200000; // use the object timer freq // // Any types that have calculations performed can use one or more of // the following calculation modification flags listed here // public const int PERF_DELTA_COUNTER = 0x00400000; // compute difference first public const int PERF_DELTA_BASE = 0x00800000; // compute base diff as well public const int PERF_INVERSE_COUNTER = 0x01000000; // show as 1.00-value (assumes: public const int PERF_MULTI_COUNTER = 0x02000000; // sum of multiple instances // // Select one of the following values to indicate the display suffix (if any) // public const int PERF_DISPLAY_NO_SUFFIX = 0x00000000; // no suffix public const int PERF_DISPLAY_PER_SEC = 0x10000000; // "/sec" public const int PERF_DISPLAY_PERCENT = 0x20000000; // "%" public const int PERF_DISPLAY_SECONDS = 0x30000000; // "secs" public const int PERF_DISPLAY_NOSHOW = 0x40000000; // value is not displayed // // Predefined counter types // // 32-bit Counter. Divide delta by delta time. Display suffix: "/sec" public const int PERF_COUNTER_COUNTER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC); // 64-bit Timer. Divide delta by delta time. Display suffix: "%" public const int PERF_COUNTER_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_QUEUELEN_TYPE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_LARGE_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product using 100 Ns timebase. // Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_100NS_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product using Object specific timebase. // Divide delta by delta time. No Display Suffix. public const int PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // 64-bit Counter. Divide delta by delta time. Display Suffix: "/sec" public const int PERF_COUNTER_BULK_COUNT = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC); // Indicates the counter is not a counter but rather Unicode text Display as text. public const int PERF_COUNTER_TEXT = (PERF_SIZE_VARIABLE_LEN | PERF_TYPE_TEXT | PERF_TEXT_UNICODE | PERF_DISPLAY_NO_SUFFIX); // Indicates the data is a counter which should not be // time averaged on display (such as an error counter on a serial line) // Display as is. No Display Suffix. public const int PERF_COUNTER_RAWCOUNT = (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX); // Same as PERF_COUNTER_RAWCOUNT except its size is a large integer public const int PERF_COUNTER_LARGE_RAWCOUNT = (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX); // Special case for RAWCOUNT that want to be displayed In hex // Indicates the data is a counter which should not be // time averaged on display (such as an error counter on a serial line) // Display as is. No Display Suffix. public const int PERF_COUNTER_RAWCOUNT_HEX = (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_HEX | PERF_DISPLAY_NO_SUFFIX); // Same as PERF_COUNTER_RAWCOUNT_HEX except its size is a large integer public const int PERF_COUNTER_LARGE_RAWCOUNT_HEX = (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_HEX | PERF_DISPLAY_NO_SUFFIX); // A count which is either 1 or 0 on each sampling interrupt (% busy) // Divide delta by delta base. Display Suffix: "%" public const int PERF_SAMPLE_FRACTION = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DELTA_COUNTER | PERF_DELTA_BASE | PERF_DISPLAY_PERCENT); // A count which is sampled on each sampling interrupt (queue length) // Divide delta by delta time. No Display Suffix. public const int PERF_SAMPLE_COUNTER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // A label: no data is associated with this counter (it has 0 length) // Do not display. public const int PERF_COUNTER_NODATA = (PERF_SIZE_ZERO | PERF_DISPLAY_NOSHOW); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 - delta divided by delta time. Display suffix: "%" public const int PERF_COUNTER_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // The divisor for a sample, used with the previous counter to form a // sampled %. You must check for >0 before dividing by this! This // counter will directly follow the numerator counter. It should not // be displayed to the user. public const int PERF_SAMPLE_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000001); // for compatibility with pre-beta versions // A timer which, when divided by an average base, produces a time // In seconds which is the average time of some operation. This // timer times total operations, and the base is the number of opera- // tions. Display Suffix: "sec" public const int PERF_AVERAGE_TIMER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_SECONDS); // Used as the denominator In the computation of time or count // averages. Must directly follow the numerator counter. Not dis- // played to the user. public const int PERF_AVERAGE_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000002); // for compatibility with pre-beta versions // 64-bit Timer in object specific units. Display delta divided by // delta time as returned in the object type header structure. Display suffix: "%" public const int PERF_OBJ_TIME_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // A bulk count which, when divided (typically) by the number of // operations, gives (typically) the number of bytes per operation. // No Display Suffix. public const int PERF_AVERAGE_BULK = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_NOSHOW); // 64-bit Timer in object specific units. Display delta divided by // delta time as returned in the object type header structure. Display suffix: "%" public const int PERF_OBJ_TIME_TIME = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer In 100 nsec units. Display delta divided by // delta time. Display suffix: "%" public const int PERF_100NSEC_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 - delta divided by delta time. Display suffix: "%" public const int PERF_100NSEC_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer. Divide delta by delta time. Display suffix: "%" // Timer for multiple instances, so result can exceed 100%. public const int PERF_COUNTER_MULTI_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_DELTA_COUNTER | PERF_TIMER_TICK | PERF_MULTI_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 * _MULTI_BASE - delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result // can exceed 100%. Followed by a counter of type _MULTI_BASE. public const int PERF_COUNTER_MULTI_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_DELTA_COUNTER | PERF_MULTI_COUNTER | PERF_TIMER_TICK | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // Number of instances to which the preceding _MULTI_..._INV counter // applies. Used as a factor to get the percentage. public const int PERF_COUNTER_MULTI_BASE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_MULTI_COUNTER | PERF_DISPLAY_NOSHOW); // 64-bit Timer In 100 nsec units. Display delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result can exceed 100%. public const int PERF_100NSEC_MULTI_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 * _MULTI_BASE - delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result // can exceed 100%. Followed by a counter of type _MULTI_BASE. public const int PERF_100NSEC_MULTI_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // Indicates the data is a fraction of the following counter which // should not be time averaged on display (such as free space over // total space.) Display as is. Display the quotient as "%". public const int PERF_RAW_FRACTION = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_PERCENT); public const int PERF_LARGE_RAW_FRACTION = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_PERCENT); // Indicates the data is a base for the preceding counter which should // not be time averaged on display (such as free space over total space.) public const int PERF_RAW_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000003); // for compatibility with pre-beta versions public const int PERF_LARGE_RAW_BASE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW); // The data collected In this counter is actually the start time of the // item being measured. For display, this data is subtracted from the // sample time to yield the elapsed time as the difference between the two. // In the definition below, the PerfTime field of the Object contains // the sample time as indicated by the PERF_OBJECT_TIMER bit and the // difference is scaled by the PerfFreq of the Object to convert the time // units into seconds. public const int PERF_ELAPSED_TIME = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_ELAPSED | PERF_OBJECT_TIMER | PERF_DISPLAY_SECONDS); // // The following counter type can be used with the preceding types to // define a range of values to be displayed In a histogram. // // // This counter is used to display the difference from one sample // to the next. The counter value is a constantly increasing number // and the value displayed is the difference between the current // value and the previous value. Negative numbers are not allowed // which shouldn't be a problem as long as the counter value is // increasing or unchanged. // public const int PERF_COUNTER_DELTA = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); public const int PERF_COUNTER_LARGE_DELTA = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // The timer used has the same frequency as the System Performance Timer public const int PERF_PRECISION_SYSTEM_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // // The timer used has the same frequency as the 100 NanoSecond Timer public const int PERF_PRECISION_100NS_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // // The timer used is of the frequency specified in the Object header's // PerfFreq field (PerfTime is ignored) public const int PERF_PRECISION_OBJECT_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); public const uint PDH_FMT_DOUBLE = 0x00000200; public const uint PDH_FMT_NOSCALE = 0x00001000; public const uint PDH_FMT_NOCAP100 = 0x00008000; [StructLayout(LayoutKind.Sequential)] public struct PDH_RAW_COUNTER { public int CStatus; public long TimeStamp; public long FirstValue; public long SecondValue; public int MultiCount; } [StructLayout(LayoutKind.Sequential)] public struct PDH_FMT_COUNTERVALUE { public int CStatus; public double data; } public const int PDH_NO_DATA = unchecked((int)0x800007D5); public const int PDH_CALC_NEGATIVE_DENOMINATOR = unchecked((int)0x800007D6); public const int PDH_CALC_NEGATIVE_VALUE = unchecked((int)0x800007D8); // // The following are used to determine the level of detail associated // with the counter. The user will be setting the level of detail // that should be displayed at any given time. // public const int PERF_DETAIL_NOVICE = 100; // The uninformed can understand it public const int PERF_DETAIL_ADVANCED = 200; // For the advanced user public const int PERF_DETAIL_EXPERT = 300; // For the expert user public const int PERF_DETAIL_WIZARD = 400; // For the system designer } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/jit64/valuetypes/nullable/castclass/generics/castclass-generics018.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // <Area> Nullable - CastClass </Area> // <Title> Nullable type with castclass expr </Title> // <Description> // checking type of ByteE using cast expr // </Description> // <RelatedBugs> </RelatedBugs> //<Expects Status=success></Expects> // <Code> using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQ<T>(T o) { return Helper.Compare((ByteE)(ValueType)(object)o, Helper.Create(default(ByteE))); } private static bool BoxUnboxToQ<T>(T o) { return Helper.Compare((ByteE?)(ValueType)(object)o, Helper.Create(default(ByteE))); } private static int Main() { ByteE? s = Helper.Create(default(ByteE)); if (BoxUnboxToNQ(s) && BoxUnboxToQ(s)) return ExitCode.Passed; else return ExitCode.Failed; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // <Area> Nullable - CastClass </Area> // <Title> Nullable type with castclass expr </Title> // <Description> // checking type of ByteE using cast expr // </Description> // <RelatedBugs> </RelatedBugs> //<Expects Status=success></Expects> // <Code> using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQ<T>(T o) { return Helper.Compare((ByteE)(ValueType)(object)o, Helper.Create(default(ByteE))); } private static bool BoxUnboxToQ<T>(T o) { return Helper.Compare((ByteE?)(ValueType)(object)o, Helper.Create(default(ByteE))); } private static int Main() { ByteE? s = Helper.Create(default(ByteE)); if (BoxUnboxToNQ(s) && BoxUnboxToQ(s)) return ExitCode.Passed; else return ExitCode.Failed; } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/Methodical/divrem/div/i4div_cs_d.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="i4div.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="i4div.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Data.Odbc/src/Common/System/Data/Common/AdapterUtil.Odbc.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; using System.Text; namespace System { internal static partial class SR { internal static string GetString(string value) { return value; } internal static string GetString(string format, params object?[] args) { return SR.Format(format, args); } } } namespace System.Data.Common { internal static partial class ADP { // The class ADP defines the exceptions that are specific to the Adapters.f // The class contains functions that take the proper informational variables and then construct // the appropriate exception with an error string obtained from the resource Framework.txt. // The exception is then returned to the caller, so that the caller may then throw from its // location so that the catcher of the exception will have the appropriate call stack. // This class is used so that there will be compile time checking of error messages. // The resource Framework.txt will ensure proper string text based on the appropriate // locale. internal static Exception ExceptionWithStackTrace(Exception e) { try { throw e; } catch (Exception caught) { return caught; } } // // COM+ exceptions // internal static TimeoutException TimeoutException(string error) { TimeoutException e = new TimeoutException(error); TraceExceptionAsReturnValue(e); return e; } internal static InvalidOperationException InvalidOperation(string error, Exception? inner) { InvalidOperationException e = new InvalidOperationException(error, inner); TraceExceptionAsReturnValue(e); return e; } internal static InvalidCastException InvalidCast() { InvalidCastException e = new InvalidCastException(); TraceExceptionAsReturnValue(e); return e; } // // Helper Functions // internal static void CheckArgumentLength(string value, string parameterName) { CheckArgumentNull(value, parameterName); if (0 == value.Length) { throw Argument(SR.GetString(SR.ADP_EmptyString, parameterName)); // MDAC 94859 } } // IDbCommand.CommandType internal static ArgumentOutOfRangeException InvalidCommandType(CommandType value) { #if DEBUG switch (value) { case CommandType.Text: case CommandType.StoredProcedure: case CommandType.TableDirect: Debug.Fail("valid CommandType " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(CommandType), (int)value); } // IDataParameter.SourceVersion internal static ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion value) { #if DEBUG switch (value) { case DataRowVersion.Default: case DataRowVersion.Current: case DataRowVersion.Original: case DataRowVersion.Proposed: Debug.Fail("valid DataRowVersion " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(DataRowVersion), (int)value); } // IDbConnection.BeginTransaction, OleDbTransaction.Begin internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value) { #if DEBUG switch (value) { case IsolationLevel.Unspecified: case IsolationLevel.Chaos: case IsolationLevel.ReadUncommitted: case IsolationLevel.ReadCommitted: case IsolationLevel.RepeatableRead: case IsolationLevel.Serializable: case IsolationLevel.Snapshot: Debug.Fail("valid IsolationLevel " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(IsolationLevel), (int)value); } // DBDataPermissionAttribute.KeyRestrictionBehavior internal static ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value) { #if DEBUG switch (value) { case KeyRestrictionBehavior.PreventUsage: case KeyRestrictionBehavior.AllowOnly: Debug.Fail("valid KeyRestrictionBehavior " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value); } // IDataParameter.Direction internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value) { #if DEBUG switch (value) { case ParameterDirection.Input: case ParameterDirection.Output: case ParameterDirection.InputOutput: case ParameterDirection.ReturnValue: Debug.Fail("valid ParameterDirection " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(ParameterDirection), (int)value); } // IDbCommand.UpdateRowSource internal static ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSource value) { #if DEBUG switch (value) { case UpdateRowSource.None: case UpdateRowSource.OutputParameters: case UpdateRowSource.FirstReturnedRecord: case UpdateRowSource.Both: Debug.Fail("valid UpdateRowSource " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(UpdateRowSource), (int)value); } // // DbConnectionOptions, DataAccess // internal static InvalidOperationException InvalidDataDirectory() { return ADP.InvalidOperation(SR.GetString(SR.ADP_InvalidDataDirectory)); } internal static ArgumentException InvalidKeyname(string? parameterName) { return Argument(SR.GetString(SR.ADP_InvalidKey), parameterName); } internal static ArgumentException InvalidValue(string parameterName) { return Argument(SR.GetString(SR.ADP_InvalidValue), parameterName); } // // DbConnection // internal static InvalidOperationException NoConnectionString() { return InvalidOperation(SR.GetString(SR.ADP_NoConnectionString)); } internal static Exception MethodNotImplemented([CallerMemberName] string methodName = "") { return System.NotImplemented.ByDesignWithMessage(methodName); } // // : DbConnectionOptions, DataAccess, SqlClient // internal static Exception OdbcNoTypesFromProvider() { return InvalidOperation(SR.GetString(SR.ADP_OdbcNoTypesFromProvider)); } // // DbConnectionPool and related // internal static Exception PooledOpenTimeout() { return ADP.InvalidOperation(SR.GetString(SR.ADP_PooledOpenTimeout)); } internal static Exception NonPooledOpenTimeout() { return ADP.TimeoutException(SR.GetString(SR.ADP_NonPooledOpenTimeout)); } // // DbProviderException // internal static InvalidOperationException TransactionConnectionMismatch() { return Provider(SR.GetString(SR.ADP_TransactionConnectionMismatch)); } internal static InvalidOperationException TransactionRequired(string method) { return Provider(SR.GetString(SR.ADP_TransactionRequired, method)); } // // IDbCommand // internal static Exception CommandTextRequired(string method) { return InvalidOperation(SR.GetString(SR.ADP_CommandTextRequired, method)); } internal static InvalidOperationException ConnectionRequired(string method) { return InvalidOperation(SR.GetString(SR.ADP_ConnectionRequired, method)); } internal static InvalidOperationException OpenConnectionRequired(string method, ConnectionState state) { return InvalidOperation(SR.GetString(SR.ADP_OpenConnectionRequired, method, ADP.ConnectionStateMsg(state))); } internal static Exception OpenReaderExists() { return OpenReaderExists(null); } internal static Exception OpenReaderExists(Exception? e) { return InvalidOperation(SR.GetString(SR.ADP_OpenReaderExists), e); } // // DbDataReader // internal static Exception NonSeqByteAccess(long badIndex, long currIndex, string method) { return InvalidOperation(SR.GetString(SR.ADP_NonSeqByteAccess, badIndex.ToString(CultureInfo.InvariantCulture), currIndex.ToString(CultureInfo.InvariantCulture), method)); } internal static Exception NumericToDecimalOverflow() { return InvalidCast(SR.GetString(SR.ADP_NumericToDecimalOverflow)); } // // : IDbCommand // internal static Exception InvalidCommandTimeout(int value) { return Argument(SR.GetString(SR.ADP_InvalidCommandTimeout, value.ToString(CultureInfo.InvariantCulture)), ADP.CommandTimeout); } internal static Exception DeriveParametersNotSupported(IDbCommand value) { return DataAdapter(SR.GetString(SR.ADP_DeriveParametersNotSupported, value.GetType().Name, value.CommandType.ToString())); } internal static Exception UninitializedParameterSize(int index, Type dataType) { return InvalidOperation(SR.GetString(SR.ADP_UninitializedParameterSize, index.ToString(CultureInfo.InvariantCulture), dataType.Name)); } internal static InvalidOperationException QuotePrefixNotSet(string method) { return InvalidOperation(SR.GetString(SR.ADP_QuotePrefixNotSet, method)); } // // : ConnectionUtil // internal static Exception ConnectionIsDisabled(Exception? InnerException) { return InvalidOperation(SR.GetString(SR.ADP_ConnectionIsDisabled), InnerException); } internal static Exception ClosedConnectionError() { return InvalidOperation(SR.GetString(SR.ADP_ClosedConnectionError)); } internal static Exception ConnectionAlreadyOpen(ConnectionState state) { return InvalidOperation(SR.GetString(SR.ADP_ConnectionAlreadyOpen, ADP.ConnectionStateMsg(state))); } internal static Exception OpenConnectionPropertySet(string property, ConnectionState state) { return InvalidOperation(SR.GetString(SR.ADP_OpenConnectionPropertySet, property, ADP.ConnectionStateMsg(state))); } internal static Exception EmptyDatabaseName() { return Argument(SR.GetString(SR.ADP_EmptyDatabaseName)); } internal static Exception DatabaseNameTooLong() { return Argument(SR.GetString(SR.ADP_DatabaseNameTooLong)); } internal enum ConnectionError { BeginGetConnectionReturnsNull, GetConnectionReturnsNull, ConnectionOptionsMissing, CouldNotSwitchToClosedPreviouslyOpenedState, } internal static Exception InternalConnectionError(ConnectionError internalError) { return InvalidOperation(SR.GetString(SR.ADP_InternalConnectionError, (int)internalError)); } // // : DbDataReader // internal static Exception DataReaderNoData() { return InvalidOperation(SR.GetString(SR.ADP_DataReaderNoData)); } // // : IDataParameter // internal static ArgumentException InvalidDataType(TypeCode typecode) { return Argument(SR.GetString(SR.ADP_InvalidDataType, typecode.ToString())); } internal static ArgumentException UnknownDataType(Type dataType) { return Argument(SR.GetString(SR.ADP_UnknownDataType, dataType.FullName!)); } internal static ArgumentException DbTypeNotSupported(System.Data.DbType type, Type enumtype) { return Argument(SR.GetString(SR.ADP_DbTypeNotSupported, type.ToString(), enumtype.Name)); } internal static ArgumentException UnknownDataTypeCode(Type dataType, TypeCode typeCode) { return Argument(SR.GetString(SR.ADP_UnknownDataTypeCode, ((int)typeCode).ToString(CultureInfo.InvariantCulture), dataType.FullName!)); } internal static ArgumentException InvalidOffsetValue(int value) { return Argument(SR.GetString(SR.ADP_InvalidOffsetValue, value.ToString(CultureInfo.InvariantCulture))); } internal static ArgumentException InvalidSizeValue(int value) { return Argument(SR.GetString(SR.ADP_InvalidSizeValue, value.ToString(CultureInfo.InvariantCulture))); } internal static Exception ParameterConversionFailed(object value, Type destType, Exception inner) { // WebData 75433 Debug.Assert(null != value, "null value on conversion failure"); Debug.Assert(null != inner, "null inner on conversion failure"); Exception e; string message = SR.GetString(SR.ADP_ParameterConversionFailed, value.GetType().Name, destType.Name); if (inner is ArgumentException) { e = new ArgumentException(message, inner); } else if (inner is FormatException) { e = new FormatException(message, inner); } else if (inner is InvalidCastException) { e = new InvalidCastException(message, inner); } else if (inner is OverflowException) { e = new OverflowException(message, inner); } else { e = inner; } TraceExceptionAsReturnValue(e); return e; } // // : IDataParameterCollection // internal static Exception ParametersMappingIndex(int index, IDataParameterCollection collection) { return CollectionIndexInt32(index, collection.GetType(), collection.Count); } internal static Exception ParametersSourceIndex(string parameterName, IDataParameterCollection collection, Type parameterType) { return CollectionIndexString(parameterType, ADP.ParameterName, parameterName, collection.GetType()); } internal static Exception ParameterNull(string parameter, IDataParameterCollection collection, Type parameterType) { return CollectionNullValue(parameter, collection.GetType(), parameterType); } internal static Exception InvalidParameterType(IDataParameterCollection collection, Type parameterType, object invalidValue) { return CollectionInvalidType(collection.GetType(), parameterType, invalidValue); } // // : IDbTransaction // internal static Exception ParallelTransactionsNotSupported(IDbConnection obj) { return InvalidOperation(SR.GetString(SR.ADP_ParallelTransactionsNotSupported, obj.GetType().Name)); } internal static Exception TransactionZombied(IDbTransaction obj) { return InvalidOperation(SR.GetString(SR.ADP_TransactionZombied, obj.GetType().Name)); } internal static Exception OffsetOutOfRangeException() { return InvalidOperation(SR.GetString(SR.ADP_OffsetOutOfRangeException)); } // // : DbMetaDataFactory // internal static Exception AmbigousCollectionName(string collectionName) { return Argument(SR.GetString(SR.MDF_AmbigousCollectionName, collectionName)); } internal static Exception CollectionNameIsNotUnique(string collectionName) { return Argument(SR.GetString(SR.MDF_CollectionNameISNotUnique, collectionName)); } internal static Exception DataTableDoesNotExist(string collectionName) { return Argument(SR.GetString(SR.MDF_DataTableDoesNotExist, collectionName)); } internal static Exception IncorrectNumberOfDataSourceInformationRows() { return Argument(SR.GetString(SR.MDF_IncorrectNumberOfDataSourceInformationRows)); } internal static ArgumentException InvalidRestrictionValue(string collectionName, string restrictionName, string? restrictionValue) { return ADP.Argument(SR.GetString(SR.MDF_InvalidRestrictionValue, collectionName, restrictionName, restrictionValue)); } internal static Exception InvalidXml() { return Argument(SR.GetString(SR.MDF_InvalidXml)); } internal static Exception InvalidXmlMissingColumn(string collectionName, string columnName) { return Argument(SR.GetString(SR.MDF_InvalidXmlMissingColumn, collectionName, columnName)); } internal static Exception InvalidXmlInvalidValue(string collectionName, string columnName) { return Argument(SR.GetString(SR.MDF_InvalidXmlInvalidValue, collectionName, columnName)); } internal static Exception MissingDataSourceInformationColumn() { return Argument(SR.GetString(SR.MDF_MissingDataSourceInformationColumn)); } internal static Exception MissingRestrictionColumn() { return Argument(SR.GetString(SR.MDF_MissingRestrictionColumn)); } internal static Exception MissingRestrictionRow() { return Argument(SR.GetString(SR.MDF_MissingRestrictionRow)); } internal static Exception NoColumns() { return Argument(SR.GetString(SR.MDF_NoColumns)); } internal static Exception QueryFailed(string collectionName, Exception e) { return InvalidOperation(SR.GetString(SR.MDF_QueryFailed, collectionName), e); } internal static Exception TooManyRestrictions(string collectionName) { return Argument(SR.GetString(SR.MDF_TooManyRestrictions, collectionName)); } internal static Exception UnableToBuildCollection(string collectionName) { return Argument(SR.GetString(SR.MDF_UnableToBuildCollection, collectionName)); } internal static Exception UndefinedCollection(string collectionName) { return Argument(SR.GetString(SR.MDF_UndefinedCollection, collectionName)); } internal static Exception UndefinedPopulationMechanism(string populationMechanism) { return Argument(SR.GetString(SR.MDF_UndefinedPopulationMechanism, populationMechanism)); } internal static Exception UnsupportedVersion(string collectionName) { return Argument(SR.GetString(SR.MDF_UnsupportedVersion, collectionName)); } // global constant strings internal const string BeginTransaction = "BeginTransaction"; internal const string ChangeDatabase = "ChangeDatabase"; internal const string CommitTransaction = "CommitTransaction"; internal const string CommandTimeout = "CommandTimeout"; internal const string DeriveParameters = "DeriveParameters"; internal const string ExecuteReader = "ExecuteReader"; internal const string ExecuteNonQuery = "ExecuteNonQuery"; internal const string ExecuteScalar = "ExecuteScalar"; internal const string GetSchema = "GetSchema"; internal const string GetSchemaTable = "GetSchemaTable"; internal const string Parameter = "Parameter"; internal const string ParameterName = "ParameterName"; internal const string Prepare = "Prepare"; internal const string RollbackTransaction = "RollbackTransaction"; internal const string QuoteIdentifier = "QuoteIdentifier"; internal const string UnquoteIdentifier = "UnquoteIdentifier"; internal const int DecimalMaxPrecision = 29; internal const int DecimalMaxPrecision28 = 28; // there are some cases in Odbc where we need that ... internal const int DefaultCommandTimeout = 30; internal static readonly IntPtr PtrZero = new IntPtr(0); // IntPtr.Zero internal static readonly int PtrSize = IntPtr.Size; internal static Delegate? FindBuilder(MulticastDelegate mcd) { // V1.2.3300 if (null != mcd) { Delegate[] d = mcd.GetInvocationList(); for (int i = 0; i < d.Length; i++) { if (d[i].Target is DbCommandBuilder) return d[i]; } } return null; } internal static bool NeedManualEnlistment() { return false; } internal static long TimerCurrent() { return DateTime.UtcNow.ToFileTimeUtc(); } internal static long TimerFromSeconds(int seconds) { long result = checked((long)seconds * TimeSpan.TicksPerSecond); return result; } internal static bool TimerHasExpired(long timerExpire) { bool result = TimerCurrent() > timerExpire; return result; } internal static long TimerRemaining(long timerExpire) { long timerNow = TimerCurrent(); long result = checked(timerExpire - timerNow); return result; } internal static long TimerRemainingMilliseconds(long timerExpire) { long result = TimerToMilliseconds(TimerRemaining(timerExpire)); return result; } internal static long TimerToMilliseconds(long timerValue) { long result = timerValue / TimeSpan.TicksPerMillisecond; return result; } internal static void EscapeSpecialCharacters(string unescapedString, StringBuilder escapedString) { // note special characters list is from character escapes // in the MSDN regular expression language elements documentation // added ] since escaping it seems necessary const string specialCharacters = ".$^{[(|)*+?\\]"; foreach (char currentChar in unescapedString) { if (specialCharacters.IndexOf(currentChar) >= 0) { escapedString.Append('\\'); } escapedString.Append(currentChar); } } internal static string GetFullPath(string filename) { // MDAC 77686 return Path.GetFullPath(filename); } internal static int StringLength(string? inputString) { return ((null != inputString) ? inputString.Length : 0); } internal static IntPtr IntPtrOffset(IntPtr pbase, int offset) { if (4 == ADP.PtrSize) { return (IntPtr)checked(pbase.ToInt32() + offset); } Debug.Assert(8 == ADP.PtrSize, "8 != IntPtr.Size"); // MDAC 73747 return (IntPtr)checked(pbase.ToInt64() + offset); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; using System.Text; namespace System { internal static partial class SR { internal static string GetString(string value) { return value; } internal static string GetString(string format, params object?[] args) { return SR.Format(format, args); } } } namespace System.Data.Common { internal static partial class ADP { // The class ADP defines the exceptions that are specific to the Adapters.f // The class contains functions that take the proper informational variables and then construct // the appropriate exception with an error string obtained from the resource Framework.txt. // The exception is then returned to the caller, so that the caller may then throw from its // location so that the catcher of the exception will have the appropriate call stack. // This class is used so that there will be compile time checking of error messages. // The resource Framework.txt will ensure proper string text based on the appropriate // locale. internal static Exception ExceptionWithStackTrace(Exception e) { try { throw e; } catch (Exception caught) { return caught; } } // // COM+ exceptions // internal static TimeoutException TimeoutException(string error) { TimeoutException e = new TimeoutException(error); TraceExceptionAsReturnValue(e); return e; } internal static InvalidOperationException InvalidOperation(string error, Exception? inner) { InvalidOperationException e = new InvalidOperationException(error, inner); TraceExceptionAsReturnValue(e); return e; } internal static InvalidCastException InvalidCast() { InvalidCastException e = new InvalidCastException(); TraceExceptionAsReturnValue(e); return e; } // // Helper Functions // internal static void CheckArgumentLength(string value, string parameterName) { CheckArgumentNull(value, parameterName); if (0 == value.Length) { throw Argument(SR.GetString(SR.ADP_EmptyString, parameterName)); // MDAC 94859 } } // IDbCommand.CommandType internal static ArgumentOutOfRangeException InvalidCommandType(CommandType value) { #if DEBUG switch (value) { case CommandType.Text: case CommandType.StoredProcedure: case CommandType.TableDirect: Debug.Fail("valid CommandType " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(CommandType), (int)value); } // IDataParameter.SourceVersion internal static ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion value) { #if DEBUG switch (value) { case DataRowVersion.Default: case DataRowVersion.Current: case DataRowVersion.Original: case DataRowVersion.Proposed: Debug.Fail("valid DataRowVersion " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(DataRowVersion), (int)value); } // IDbConnection.BeginTransaction, OleDbTransaction.Begin internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value) { #if DEBUG switch (value) { case IsolationLevel.Unspecified: case IsolationLevel.Chaos: case IsolationLevel.ReadUncommitted: case IsolationLevel.ReadCommitted: case IsolationLevel.RepeatableRead: case IsolationLevel.Serializable: case IsolationLevel.Snapshot: Debug.Fail("valid IsolationLevel " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(IsolationLevel), (int)value); } // DBDataPermissionAttribute.KeyRestrictionBehavior internal static ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value) { #if DEBUG switch (value) { case KeyRestrictionBehavior.PreventUsage: case KeyRestrictionBehavior.AllowOnly: Debug.Fail("valid KeyRestrictionBehavior " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value); } // IDataParameter.Direction internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value) { #if DEBUG switch (value) { case ParameterDirection.Input: case ParameterDirection.Output: case ParameterDirection.InputOutput: case ParameterDirection.ReturnValue: Debug.Fail("valid ParameterDirection " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(ParameterDirection), (int)value); } // IDbCommand.UpdateRowSource internal static ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSource value) { #if DEBUG switch (value) { case UpdateRowSource.None: case UpdateRowSource.OutputParameters: case UpdateRowSource.FirstReturnedRecord: case UpdateRowSource.Both: Debug.Fail("valid UpdateRowSource " + value.ToString()); break; } #endif return InvalidEnumerationValue(typeof(UpdateRowSource), (int)value); } // // DbConnectionOptions, DataAccess // internal static InvalidOperationException InvalidDataDirectory() { return ADP.InvalidOperation(SR.GetString(SR.ADP_InvalidDataDirectory)); } internal static ArgumentException InvalidKeyname(string? parameterName) { return Argument(SR.GetString(SR.ADP_InvalidKey), parameterName); } internal static ArgumentException InvalidValue(string parameterName) { return Argument(SR.GetString(SR.ADP_InvalidValue), parameterName); } // // DbConnection // internal static InvalidOperationException NoConnectionString() { return InvalidOperation(SR.GetString(SR.ADP_NoConnectionString)); } internal static Exception MethodNotImplemented([CallerMemberName] string methodName = "") { return System.NotImplemented.ByDesignWithMessage(methodName); } // // : DbConnectionOptions, DataAccess, SqlClient // internal static Exception OdbcNoTypesFromProvider() { return InvalidOperation(SR.GetString(SR.ADP_OdbcNoTypesFromProvider)); } // // DbConnectionPool and related // internal static Exception PooledOpenTimeout() { return ADP.InvalidOperation(SR.GetString(SR.ADP_PooledOpenTimeout)); } internal static Exception NonPooledOpenTimeout() { return ADP.TimeoutException(SR.GetString(SR.ADP_NonPooledOpenTimeout)); } // // DbProviderException // internal static InvalidOperationException TransactionConnectionMismatch() { return Provider(SR.GetString(SR.ADP_TransactionConnectionMismatch)); } internal static InvalidOperationException TransactionRequired(string method) { return Provider(SR.GetString(SR.ADP_TransactionRequired, method)); } // // IDbCommand // internal static Exception CommandTextRequired(string method) { return InvalidOperation(SR.GetString(SR.ADP_CommandTextRequired, method)); } internal static InvalidOperationException ConnectionRequired(string method) { return InvalidOperation(SR.GetString(SR.ADP_ConnectionRequired, method)); } internal static InvalidOperationException OpenConnectionRequired(string method, ConnectionState state) { return InvalidOperation(SR.GetString(SR.ADP_OpenConnectionRequired, method, ADP.ConnectionStateMsg(state))); } internal static Exception OpenReaderExists() { return OpenReaderExists(null); } internal static Exception OpenReaderExists(Exception? e) { return InvalidOperation(SR.GetString(SR.ADP_OpenReaderExists), e); } // // DbDataReader // internal static Exception NonSeqByteAccess(long badIndex, long currIndex, string method) { return InvalidOperation(SR.GetString(SR.ADP_NonSeqByteAccess, badIndex.ToString(CultureInfo.InvariantCulture), currIndex.ToString(CultureInfo.InvariantCulture), method)); } internal static Exception NumericToDecimalOverflow() { return InvalidCast(SR.GetString(SR.ADP_NumericToDecimalOverflow)); } // // : IDbCommand // internal static Exception InvalidCommandTimeout(int value) { return Argument(SR.GetString(SR.ADP_InvalidCommandTimeout, value.ToString(CultureInfo.InvariantCulture)), ADP.CommandTimeout); } internal static Exception DeriveParametersNotSupported(IDbCommand value) { return DataAdapter(SR.GetString(SR.ADP_DeriveParametersNotSupported, value.GetType().Name, value.CommandType.ToString())); } internal static Exception UninitializedParameterSize(int index, Type dataType) { return InvalidOperation(SR.GetString(SR.ADP_UninitializedParameterSize, index.ToString(CultureInfo.InvariantCulture), dataType.Name)); } internal static InvalidOperationException QuotePrefixNotSet(string method) { return InvalidOperation(SR.GetString(SR.ADP_QuotePrefixNotSet, method)); } // // : ConnectionUtil // internal static Exception ConnectionIsDisabled(Exception? InnerException) { return InvalidOperation(SR.GetString(SR.ADP_ConnectionIsDisabled), InnerException); } internal static Exception ClosedConnectionError() { return InvalidOperation(SR.GetString(SR.ADP_ClosedConnectionError)); } internal static Exception ConnectionAlreadyOpen(ConnectionState state) { return InvalidOperation(SR.GetString(SR.ADP_ConnectionAlreadyOpen, ADP.ConnectionStateMsg(state))); } internal static Exception OpenConnectionPropertySet(string property, ConnectionState state) { return InvalidOperation(SR.GetString(SR.ADP_OpenConnectionPropertySet, property, ADP.ConnectionStateMsg(state))); } internal static Exception EmptyDatabaseName() { return Argument(SR.GetString(SR.ADP_EmptyDatabaseName)); } internal static Exception DatabaseNameTooLong() { return Argument(SR.GetString(SR.ADP_DatabaseNameTooLong)); } internal enum ConnectionError { BeginGetConnectionReturnsNull, GetConnectionReturnsNull, ConnectionOptionsMissing, CouldNotSwitchToClosedPreviouslyOpenedState, } internal static Exception InternalConnectionError(ConnectionError internalError) { return InvalidOperation(SR.GetString(SR.ADP_InternalConnectionError, (int)internalError)); } // // : DbDataReader // internal static Exception DataReaderNoData() { return InvalidOperation(SR.GetString(SR.ADP_DataReaderNoData)); } // // : IDataParameter // internal static ArgumentException InvalidDataType(TypeCode typecode) { return Argument(SR.GetString(SR.ADP_InvalidDataType, typecode.ToString())); } internal static ArgumentException UnknownDataType(Type dataType) { return Argument(SR.GetString(SR.ADP_UnknownDataType, dataType.FullName!)); } internal static ArgumentException DbTypeNotSupported(System.Data.DbType type, Type enumtype) { return Argument(SR.GetString(SR.ADP_DbTypeNotSupported, type.ToString(), enumtype.Name)); } internal static ArgumentException UnknownDataTypeCode(Type dataType, TypeCode typeCode) { return Argument(SR.GetString(SR.ADP_UnknownDataTypeCode, ((int)typeCode).ToString(CultureInfo.InvariantCulture), dataType.FullName!)); } internal static ArgumentException InvalidOffsetValue(int value) { return Argument(SR.GetString(SR.ADP_InvalidOffsetValue, value.ToString(CultureInfo.InvariantCulture))); } internal static ArgumentException InvalidSizeValue(int value) { return Argument(SR.GetString(SR.ADP_InvalidSizeValue, value.ToString(CultureInfo.InvariantCulture))); } internal static Exception ParameterConversionFailed(object value, Type destType, Exception inner) { // WebData 75433 Debug.Assert(null != value, "null value on conversion failure"); Debug.Assert(null != inner, "null inner on conversion failure"); Exception e; string message = SR.GetString(SR.ADP_ParameterConversionFailed, value.GetType().Name, destType.Name); if (inner is ArgumentException) { e = new ArgumentException(message, inner); } else if (inner is FormatException) { e = new FormatException(message, inner); } else if (inner is InvalidCastException) { e = new InvalidCastException(message, inner); } else if (inner is OverflowException) { e = new OverflowException(message, inner); } else { e = inner; } TraceExceptionAsReturnValue(e); return e; } // // : IDataParameterCollection // internal static Exception ParametersMappingIndex(int index, IDataParameterCollection collection) { return CollectionIndexInt32(index, collection.GetType(), collection.Count); } internal static Exception ParametersSourceIndex(string parameterName, IDataParameterCollection collection, Type parameterType) { return CollectionIndexString(parameterType, ADP.ParameterName, parameterName, collection.GetType()); } internal static Exception ParameterNull(string parameter, IDataParameterCollection collection, Type parameterType) { return CollectionNullValue(parameter, collection.GetType(), parameterType); } internal static Exception InvalidParameterType(IDataParameterCollection collection, Type parameterType, object invalidValue) { return CollectionInvalidType(collection.GetType(), parameterType, invalidValue); } // // : IDbTransaction // internal static Exception ParallelTransactionsNotSupported(IDbConnection obj) { return InvalidOperation(SR.GetString(SR.ADP_ParallelTransactionsNotSupported, obj.GetType().Name)); } internal static Exception TransactionZombied(IDbTransaction obj) { return InvalidOperation(SR.GetString(SR.ADP_TransactionZombied, obj.GetType().Name)); } internal static Exception OffsetOutOfRangeException() { return InvalidOperation(SR.GetString(SR.ADP_OffsetOutOfRangeException)); } // // : DbMetaDataFactory // internal static Exception AmbigousCollectionName(string collectionName) { return Argument(SR.GetString(SR.MDF_AmbigousCollectionName, collectionName)); } internal static Exception CollectionNameIsNotUnique(string collectionName) { return Argument(SR.GetString(SR.MDF_CollectionNameISNotUnique, collectionName)); } internal static Exception DataTableDoesNotExist(string collectionName) { return Argument(SR.GetString(SR.MDF_DataTableDoesNotExist, collectionName)); } internal static Exception IncorrectNumberOfDataSourceInformationRows() { return Argument(SR.GetString(SR.MDF_IncorrectNumberOfDataSourceInformationRows)); } internal static ArgumentException InvalidRestrictionValue(string collectionName, string restrictionName, string? restrictionValue) { return ADP.Argument(SR.GetString(SR.MDF_InvalidRestrictionValue, collectionName, restrictionName, restrictionValue)); } internal static Exception InvalidXml() { return Argument(SR.GetString(SR.MDF_InvalidXml)); } internal static Exception InvalidXmlMissingColumn(string collectionName, string columnName) { return Argument(SR.GetString(SR.MDF_InvalidXmlMissingColumn, collectionName, columnName)); } internal static Exception InvalidXmlInvalidValue(string collectionName, string columnName) { return Argument(SR.GetString(SR.MDF_InvalidXmlInvalidValue, collectionName, columnName)); } internal static Exception MissingDataSourceInformationColumn() { return Argument(SR.GetString(SR.MDF_MissingDataSourceInformationColumn)); } internal static Exception MissingRestrictionColumn() { return Argument(SR.GetString(SR.MDF_MissingRestrictionColumn)); } internal static Exception MissingRestrictionRow() { return Argument(SR.GetString(SR.MDF_MissingRestrictionRow)); } internal static Exception NoColumns() { return Argument(SR.GetString(SR.MDF_NoColumns)); } internal static Exception QueryFailed(string collectionName, Exception e) { return InvalidOperation(SR.GetString(SR.MDF_QueryFailed, collectionName), e); } internal static Exception TooManyRestrictions(string collectionName) { return Argument(SR.GetString(SR.MDF_TooManyRestrictions, collectionName)); } internal static Exception UnableToBuildCollection(string collectionName) { return Argument(SR.GetString(SR.MDF_UnableToBuildCollection, collectionName)); } internal static Exception UndefinedCollection(string collectionName) { return Argument(SR.GetString(SR.MDF_UndefinedCollection, collectionName)); } internal static Exception UndefinedPopulationMechanism(string populationMechanism) { return Argument(SR.GetString(SR.MDF_UndefinedPopulationMechanism, populationMechanism)); } internal static Exception UnsupportedVersion(string collectionName) { return Argument(SR.GetString(SR.MDF_UnsupportedVersion, collectionName)); } // global constant strings internal const string BeginTransaction = "BeginTransaction"; internal const string ChangeDatabase = "ChangeDatabase"; internal const string CommitTransaction = "CommitTransaction"; internal const string CommandTimeout = "CommandTimeout"; internal const string DeriveParameters = "DeriveParameters"; internal const string ExecuteReader = "ExecuteReader"; internal const string ExecuteNonQuery = "ExecuteNonQuery"; internal const string ExecuteScalar = "ExecuteScalar"; internal const string GetSchema = "GetSchema"; internal const string GetSchemaTable = "GetSchemaTable"; internal const string Parameter = "Parameter"; internal const string ParameterName = "ParameterName"; internal const string Prepare = "Prepare"; internal const string RollbackTransaction = "RollbackTransaction"; internal const string QuoteIdentifier = "QuoteIdentifier"; internal const string UnquoteIdentifier = "UnquoteIdentifier"; internal const int DecimalMaxPrecision = 29; internal const int DecimalMaxPrecision28 = 28; // there are some cases in Odbc where we need that ... internal const int DefaultCommandTimeout = 30; internal static readonly IntPtr PtrZero = new IntPtr(0); // IntPtr.Zero internal static readonly int PtrSize = IntPtr.Size; internal static Delegate? FindBuilder(MulticastDelegate mcd) { // V1.2.3300 if (null != mcd) { Delegate[] d = mcd.GetInvocationList(); for (int i = 0; i < d.Length; i++) { if (d[i].Target is DbCommandBuilder) return d[i]; } } return null; } internal static bool NeedManualEnlistment() { return false; } internal static long TimerCurrent() { return DateTime.UtcNow.ToFileTimeUtc(); } internal static long TimerFromSeconds(int seconds) { long result = checked((long)seconds * TimeSpan.TicksPerSecond); return result; } internal static bool TimerHasExpired(long timerExpire) { bool result = TimerCurrent() > timerExpire; return result; } internal static long TimerRemaining(long timerExpire) { long timerNow = TimerCurrent(); long result = checked(timerExpire - timerNow); return result; } internal static long TimerRemainingMilliseconds(long timerExpire) { long result = TimerToMilliseconds(TimerRemaining(timerExpire)); return result; } internal static long TimerToMilliseconds(long timerValue) { long result = timerValue / TimeSpan.TicksPerMillisecond; return result; } internal static void EscapeSpecialCharacters(string unescapedString, StringBuilder escapedString) { // note special characters list is from character escapes // in the MSDN regular expression language elements documentation // added ] since escaping it seems necessary const string specialCharacters = ".$^{[(|)*+?\\]"; foreach (char currentChar in unescapedString) { if (specialCharacters.IndexOf(currentChar) >= 0) { escapedString.Append('\\'); } escapedString.Append(currentChar); } } internal static string GetFullPath(string filename) { // MDAC 77686 return Path.GetFullPath(filename); } internal static int StringLength(string? inputString) { return ((null != inputString) ? inputString.Length : 0); } internal static IntPtr IntPtrOffset(IntPtr pbase, int offset) { if (4 == ADP.PtrSize) { return (IntPtr)checked(pbase.ToInt32() + offset); } Debug.Assert(8 == ADP.PtrSize, "8 != IntPtr.Size"); // MDAC 73747 return (IntPtr)checked(pbase.ToInt64() + offset); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_Contains_ns.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using Xunit.Abstractions; using System.Xml.Schema; namespace System.Xml.Tests { //[TestCase(Name = "TC_SchemaSet_Contains_ns", Desc = "")] public class TC_SchemaSet_Contains_ns : TC_SchemaSetBase { private ITestOutputHelper _output; public TC_SchemaSet_Contains_ns(ITestOutputHelper output) { _output = output; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v1 - Contains with null")] public void v1() { XmlSchemaSet sc = new XmlSchemaSet(); Assert.False(sc.Contains((string)null)); return; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v2 - Contains with non existing ns", Priority = 0)] public void v2() { XmlSchemaSet sc = new XmlSchemaSet(); sc.Add("xsdauthor", TestData._XsdAuthor); Assert.False(sc.Contains("test")); return; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v3 - Contains with existing schema, Remove it, Contains again")] public void v3() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchema Schema = sc.Add("xsdauthor", TestData._XsdAuthor); Assert.True(sc.Contains("xsdauthor")); sc.Remove(Schema); Assert.False(sc.Contains("xsdauthor")); return; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v4 - Contains for 2 existing schemas, Remove one, Contains again", Priority = 0)] public void v4() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchema Schema1 = sc.Add("xsdauthor", TestData._XsdAuthor); XmlSchema Schema2 = sc.Add("xsdauthor", TestData._XsdNoNs); Assert.True(sc.Contains("xsdauthor")); sc.Remove(Schema1); Assert.True(sc.Contains("xsdauthor")); return; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using Xunit.Abstractions; using System.Xml.Schema; namespace System.Xml.Tests { //[TestCase(Name = "TC_SchemaSet_Contains_ns", Desc = "")] public class TC_SchemaSet_Contains_ns : TC_SchemaSetBase { private ITestOutputHelper _output; public TC_SchemaSet_Contains_ns(ITestOutputHelper output) { _output = output; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v1 - Contains with null")] public void v1() { XmlSchemaSet sc = new XmlSchemaSet(); Assert.False(sc.Contains((string)null)); return; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v2 - Contains with non existing ns", Priority = 0)] public void v2() { XmlSchemaSet sc = new XmlSchemaSet(); sc.Add("xsdauthor", TestData._XsdAuthor); Assert.False(sc.Contains("test")); return; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v3 - Contains with existing schema, Remove it, Contains again")] public void v3() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchema Schema = sc.Add("xsdauthor", TestData._XsdAuthor); Assert.True(sc.Contains("xsdauthor")); sc.Remove(Schema); Assert.False(sc.Contains("xsdauthor")); return; } //----------------------------------------------------------------------------------- [Fact] //[Variation(Desc = "v4 - Contains for 2 existing schemas, Remove one, Contains again", Priority = 0)] public void v4() { XmlSchemaSet sc = new XmlSchemaSet(); XmlSchema Schema1 = sc.Add("xsdauthor", TestData._XsdAuthor); XmlSchema Schema2 = sc.Add("xsdauthor", TestData._XsdNoNs); Assert.True(sc.Contains("xsdauthor")); sc.Remove(Schema1); Assert.True(sc.Contains("xsdauthor")); return; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/Helpers/VariableLengthIntegerHelper.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; using System.Buffers.Binary; using System.Diagnostics; namespace System.Net.Http { /// <summary> /// Variable length integer encoding and decoding methods. Based on https://tools.ietf.org/html/draft-ietf-quic-transport-24#section-16. /// A variable-length integer can use 1, 2, 4, or 8 bytes. /// </summary> internal static class VariableLengthIntegerHelper { public const int MaximumEncodedLength = 8; // The high 4 bits indicate the length of the integer. // 00 = length 1 // 01 = length 2 // 10 = length 4 // 11 = length 8 private const byte LengthMask = 0xC0; private const byte InitialOneByteLengthMask = 0x00; private const byte InitialTwoByteLengthMask = 0x40; private const byte InitialFourByteLengthMask = 0x80; private const byte InitialEightByteLengthMask = 0xC0; // Bits to subtract to remove the length. private const uint TwoByteLengthMask = 0x4000; private const uint FourByteLengthMask = 0x80000000; private const ulong EightByteLengthMask = 0xC000000000000000; // public for internal use in aspnetcore public const uint OneByteLimit = (1U << 6) - 1; public const uint TwoByteLimit = (1U << 14) - 1; public const uint FourByteLimit = (1U << 30) - 1; public const long EightByteLimit = (1L << 62) - 1; public static bool TryRead(ReadOnlySpan<byte> buffer, out long value, out int bytesRead) { if (buffer.Length != 0) { byte firstByte = buffer[0]; switch (firstByte & LengthMask) { case InitialOneByteLengthMask: value = firstByte; bytesRead = 1; return true; case InitialTwoByteLengthMask: if (BinaryPrimitives.TryReadUInt16BigEndian(buffer, out ushort serializedShort)) { value = serializedShort - TwoByteLengthMask; bytesRead = 2; return true; } break; case InitialFourByteLengthMask: if (BinaryPrimitives.TryReadUInt32BigEndian(buffer, out uint serializedInt)) { value = serializedInt - FourByteLengthMask; bytesRead = 4; return true; } break; default: // InitialEightByteLengthMask Debug.Assert((firstByte & LengthMask) == InitialEightByteLengthMask); if (BinaryPrimitives.TryReadUInt64BigEndian(buffer, out ulong serializedLong)) { value = (long)(serializedLong - EightByteLengthMask); Debug.Assert(value >= 0 && value <= EightByteLimit, "Serialized values are within [0, 2^62)."); bytesRead = 8; return true; } break; } } value = 0; bytesRead = 0; return false; } public static bool TryRead(ref SequenceReader<byte> reader, out long value) { // Hot path: we probably have the entire integer in one unbroken span. if (TryRead(reader.UnreadSpan, out value, out int bytesRead)) { reader.Advance(bytesRead); return true; } // Cold path: copy to a temporary buffer before calling span-based read. return TryReadSlow(ref reader, out value); static bool TryReadSlow(ref SequenceReader<byte> reader, out long value) { ReadOnlySpan<byte> span = reader.CurrentSpan; if (reader.TryPeek(out byte firstByte)) { int length = (firstByte & LengthMask) switch { InitialOneByteLengthMask => 1, InitialTwoByteLengthMask => 2, InitialFourByteLengthMask => 4, _ => 8 // LengthEightByte }; Span<byte> temp = (stackalloc byte[8])[..length]; if (reader.TryCopyTo(temp)) { bool result = TryRead(temp, out value, out int bytesRead); Debug.Assert(result == true); Debug.Assert(bytesRead == length); reader.Advance(bytesRead); return true; } } value = 0; return false; } } public static long GetInteger(in ReadOnlySequence<byte> buffer, out SequencePosition consumed, out SequencePosition examined) { var reader = new SequenceReader<byte>(buffer); if (TryRead(ref reader, out long value)) { consumed = examined = buffer.GetPosition(reader.Consumed); return value; } else { consumed = default; examined = buffer.End; return -1; } } public static bool TryWrite(Span<byte> buffer, long longToEncode, out int bytesWritten) { Debug.Assert(longToEncode >= 0); Debug.Assert(longToEncode <= EightByteLimit); if (longToEncode <= OneByteLimit) { if (buffer.Length != 0) { buffer[0] = (byte)longToEncode; bytesWritten = 1; return true; } } else if (longToEncode <= TwoByteLimit) { if (BinaryPrimitives.TryWriteUInt16BigEndian(buffer, (ushort)((uint)longToEncode | TwoByteLengthMask))) { bytesWritten = 2; return true; } } else if (longToEncode <= FourByteLimit) { if (BinaryPrimitives.TryWriteUInt32BigEndian(buffer, (uint)longToEncode | FourByteLengthMask)) { bytesWritten = 4; return true; } } else // EightByteLimit { if (BinaryPrimitives.TryWriteUInt64BigEndian(buffer, (ulong)longToEncode | EightByteLengthMask)) { bytesWritten = 8; return true; } } bytesWritten = 0; return false; } public static int WriteInteger(Span<byte> buffer, long longToEncode) { bool res = TryWrite(buffer, longToEncode, out int bytesWritten); Debug.Assert(res == true); return bytesWritten; } public static int GetByteCount(long value) { Debug.Assert(value >= 0); Debug.Assert(value <= EightByteLimit); return value <= OneByteLimit ? 1 : value <= TwoByteLimit ? 2 : value <= FourByteLimit ? 4 : 8; // EightByteLimit } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; using System.Buffers.Binary; using System.Diagnostics; namespace System.Net.Http { /// <summary> /// Variable length integer encoding and decoding methods. Based on https://tools.ietf.org/html/draft-ietf-quic-transport-24#section-16. /// A variable-length integer can use 1, 2, 4, or 8 bytes. /// </summary> internal static class VariableLengthIntegerHelper { public const int MaximumEncodedLength = 8; // The high 4 bits indicate the length of the integer. // 00 = length 1 // 01 = length 2 // 10 = length 4 // 11 = length 8 private const byte LengthMask = 0xC0; private const byte InitialOneByteLengthMask = 0x00; private const byte InitialTwoByteLengthMask = 0x40; private const byte InitialFourByteLengthMask = 0x80; private const byte InitialEightByteLengthMask = 0xC0; // Bits to subtract to remove the length. private const uint TwoByteLengthMask = 0x4000; private const uint FourByteLengthMask = 0x80000000; private const ulong EightByteLengthMask = 0xC000000000000000; // public for internal use in aspnetcore public const uint OneByteLimit = (1U << 6) - 1; public const uint TwoByteLimit = (1U << 14) - 1; public const uint FourByteLimit = (1U << 30) - 1; public const long EightByteLimit = (1L << 62) - 1; public static bool TryRead(ReadOnlySpan<byte> buffer, out long value, out int bytesRead) { if (buffer.Length != 0) { byte firstByte = buffer[0]; switch (firstByte & LengthMask) { case InitialOneByteLengthMask: value = firstByte; bytesRead = 1; return true; case InitialTwoByteLengthMask: if (BinaryPrimitives.TryReadUInt16BigEndian(buffer, out ushort serializedShort)) { value = serializedShort - TwoByteLengthMask; bytesRead = 2; return true; } break; case InitialFourByteLengthMask: if (BinaryPrimitives.TryReadUInt32BigEndian(buffer, out uint serializedInt)) { value = serializedInt - FourByteLengthMask; bytesRead = 4; return true; } break; default: // InitialEightByteLengthMask Debug.Assert((firstByte & LengthMask) == InitialEightByteLengthMask); if (BinaryPrimitives.TryReadUInt64BigEndian(buffer, out ulong serializedLong)) { value = (long)(serializedLong - EightByteLengthMask); Debug.Assert(value >= 0 && value <= EightByteLimit, "Serialized values are within [0, 2^62)."); bytesRead = 8; return true; } break; } } value = 0; bytesRead = 0; return false; } public static bool TryRead(ref SequenceReader<byte> reader, out long value) { // Hot path: we probably have the entire integer in one unbroken span. if (TryRead(reader.UnreadSpan, out value, out int bytesRead)) { reader.Advance(bytesRead); return true; } // Cold path: copy to a temporary buffer before calling span-based read. return TryReadSlow(ref reader, out value); static bool TryReadSlow(ref SequenceReader<byte> reader, out long value) { ReadOnlySpan<byte> span = reader.CurrentSpan; if (reader.TryPeek(out byte firstByte)) { int length = (firstByte & LengthMask) switch { InitialOneByteLengthMask => 1, InitialTwoByteLengthMask => 2, InitialFourByteLengthMask => 4, _ => 8 // LengthEightByte }; Span<byte> temp = (stackalloc byte[8])[..length]; if (reader.TryCopyTo(temp)) { bool result = TryRead(temp, out value, out int bytesRead); Debug.Assert(result == true); Debug.Assert(bytesRead == length); reader.Advance(bytesRead); return true; } } value = 0; return false; } } public static long GetInteger(in ReadOnlySequence<byte> buffer, out SequencePosition consumed, out SequencePosition examined) { var reader = new SequenceReader<byte>(buffer); if (TryRead(ref reader, out long value)) { consumed = examined = buffer.GetPosition(reader.Consumed); return value; } else { consumed = default; examined = buffer.End; return -1; } } public static bool TryWrite(Span<byte> buffer, long longToEncode, out int bytesWritten) { Debug.Assert(longToEncode >= 0); Debug.Assert(longToEncode <= EightByteLimit); if (longToEncode <= OneByteLimit) { if (buffer.Length != 0) { buffer[0] = (byte)longToEncode; bytesWritten = 1; return true; } } else if (longToEncode <= TwoByteLimit) { if (BinaryPrimitives.TryWriteUInt16BigEndian(buffer, (ushort)((uint)longToEncode | TwoByteLengthMask))) { bytesWritten = 2; return true; } } else if (longToEncode <= FourByteLimit) { if (BinaryPrimitives.TryWriteUInt32BigEndian(buffer, (uint)longToEncode | FourByteLengthMask)) { bytesWritten = 4; return true; } } else // EightByteLimit { if (BinaryPrimitives.TryWriteUInt64BigEndian(buffer, (ulong)longToEncode | EightByteLengthMask)) { bytesWritten = 8; return true; } } bytesWritten = 0; return false; } public static int WriteInteger(Span<byte> buffer, long longToEncode) { bool res = TryWrite(buffer, longToEncode, out int bytesWritten); Debug.Assert(res == true); return bytesWritten; } public static int GetByteCount(long value) { Debug.Assert(value >= 0); Debug.Assert(value <= EightByteLimit); return value <= OneByteLimit ? 1 : value <= TwoByteLimit ? 2 : value <= FourByteLimit ? 4 : 8; // EightByteLimit } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Private.CoreLib/src/System/EnvironmentVariableTarget.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System { public enum EnvironmentVariableTarget { Process = 0, User = 1, Machine = 2, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System { public enum EnvironmentVariableTarget { Process = 0, User = 1, Machine = 2, } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/installer/tests/HostActivation.Tests/NativeHosting/HostContextResultExtensions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using FluentAssertions; namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting { internal static class HostContextResultExtensions { public static AndConstraint<CommandResultAssertions> ExecuteAssemblyMock(this CommandResultAssertions assertion, string appPath, string[] appArgs) { var constraint = assertion.HaveStdOutContaining("mock coreclr_initialize() called") .And.HaveStdOutContaining("mock coreclr_execute_assembly() called") .And.HaveStdOutContaining($"mock managedAssemblyPath:{appPath}") .And.HaveStdOutContaining($"mock argc:{appArgs.Length}") .And.HaveStdOutContaining("mock coreclr_shutdown_2() called"); for (int i = 0; i < appArgs.Length; ++i) { constraint = constraint.And.HaveStdOutContaining($"mock argv[{i}] = {appArgs[i]}"); } return constraint; } public static AndConstraint<CommandResultAssertions> CreateDelegateMock(this CommandResultAssertions assertion) { return assertion.HaveStdOutContaining("mock coreclr_initialize() called") .And.HaveStdOutContaining("mock coreclr_create_delegate() called"); } public static AndConstraint<CommandResultAssertions> CreateDelegateMock_COM(this CommandResultAssertions assertion) { return assertion.CreateDelegateMock() .And.HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib") .And.HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.ComActivator") .And.HaveStdOutContaining("mock entryPointMethodName:GetClassFactoryForTypeInternal"); } public static AndConstraint<CommandResultAssertions> CreateDelegateMock_InMemoryAssembly(this CommandResultAssertions assertion) { return assertion.CreateDelegateMock() .And.HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib") .And.HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.InMemoryAssemblyLoader") .And.HaveStdOutContaining("mock entryPointMethodName:LoadInMemoryAssembly"); } public static AndConstraint<CommandResultAssertions> HavePropertyMock(this CommandResultAssertions assertion, string name, string value) { return assertion.HaveStdOutContaining($"mock property[{name}] = {value}"); } public static AndConstraint<CommandResultAssertions> NotHavePropertyMock(this CommandResultAssertions assertion, string name) { return assertion.NotHaveStdOutContaining($"mock property[{name}]"); } public static AndConstraint<CommandResultAssertions> InitializeContextForApp(this CommandResultAssertions assertion, string path) { return assertion.HaveStdErrContaining($"Initialized context for app: {path}"); } public static AndConstraint<CommandResultAssertions> InitializeContextForConfig(this CommandResultAssertions assertion, string path) { return assertion.HaveStdErrContaining($"Initialized context for config: {path}"); } public static AndConstraint<CommandResultAssertions> InitializeSecondaryContext(this CommandResultAssertions assertion, string path, int statusCode) { return assertion.HaveStdErrContaining($"Initialized secondary context for config: {path}") .And.HaveStdOutContaining($"hostfxr_initialize_for_runtime_config succeeded: 0x{statusCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> FailToInitializeContextForConfig(this CommandResultAssertions assertion, int errorCode) { return assertion.HaveStdOutContaining($"hostfxr_initialize_for_runtime_config failed: 0x{errorCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> GetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, string value) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_property_value succeeded for property: {name}={value}"); } public static AndConstraint<CommandResultAssertions> FailToGetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_property_value failed for property: {name} - 0x{errorCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> SetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_set_runtime_property_value succeeded for property: {name}"); } public static AndConstraint<CommandResultAssertions> FailToSetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_set_runtime_property_value failed for property: {name} - 0x{errorCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> GetRuntimePropertiesIncludes(this CommandResultAssertions assertion, string prefix, string name, string value) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties succeeded") .And.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}={value}"); } public static AndConstraint<CommandResultAssertions> GetRuntimePropertiesExcludes(this CommandResultAssertions assertion, string prefix, string name) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties succeeded") .And.NotHaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}"); } public static AndConstraint<CommandResultAssertions> FailToGetRuntimeProperties(this CommandResultAssertions assertion, string prefix, int errorCode) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties failed - 0x{errorCode.ToString("x")}"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using FluentAssertions; namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting { internal static class HostContextResultExtensions { public static AndConstraint<CommandResultAssertions> ExecuteAssemblyMock(this CommandResultAssertions assertion, string appPath, string[] appArgs) { var constraint = assertion.HaveStdOutContaining("mock coreclr_initialize() called") .And.HaveStdOutContaining("mock coreclr_execute_assembly() called") .And.HaveStdOutContaining($"mock managedAssemblyPath:{appPath}") .And.HaveStdOutContaining($"mock argc:{appArgs.Length}") .And.HaveStdOutContaining("mock coreclr_shutdown_2() called"); for (int i = 0; i < appArgs.Length; ++i) { constraint = constraint.And.HaveStdOutContaining($"mock argv[{i}] = {appArgs[i]}"); } return constraint; } public static AndConstraint<CommandResultAssertions> CreateDelegateMock(this CommandResultAssertions assertion) { return assertion.HaveStdOutContaining("mock coreclr_initialize() called") .And.HaveStdOutContaining("mock coreclr_create_delegate() called"); } public static AndConstraint<CommandResultAssertions> CreateDelegateMock_COM(this CommandResultAssertions assertion) { return assertion.CreateDelegateMock() .And.HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib") .And.HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.ComActivator") .And.HaveStdOutContaining("mock entryPointMethodName:GetClassFactoryForTypeInternal"); } public static AndConstraint<CommandResultAssertions> CreateDelegateMock_InMemoryAssembly(this CommandResultAssertions assertion) { return assertion.CreateDelegateMock() .And.HaveStdOutContaining("mock entryPointAssemblyName:System.Private.CoreLib") .And.HaveStdOutContaining("mock entryPointTypeName:Internal.Runtime.InteropServices.InMemoryAssemblyLoader") .And.HaveStdOutContaining("mock entryPointMethodName:LoadInMemoryAssembly"); } public static AndConstraint<CommandResultAssertions> HavePropertyMock(this CommandResultAssertions assertion, string name, string value) { return assertion.HaveStdOutContaining($"mock property[{name}] = {value}"); } public static AndConstraint<CommandResultAssertions> NotHavePropertyMock(this CommandResultAssertions assertion, string name) { return assertion.NotHaveStdOutContaining($"mock property[{name}]"); } public static AndConstraint<CommandResultAssertions> InitializeContextForApp(this CommandResultAssertions assertion, string path) { return assertion.HaveStdErrContaining($"Initialized context for app: {path}"); } public static AndConstraint<CommandResultAssertions> InitializeContextForConfig(this CommandResultAssertions assertion, string path) { return assertion.HaveStdErrContaining($"Initialized context for config: {path}"); } public static AndConstraint<CommandResultAssertions> InitializeSecondaryContext(this CommandResultAssertions assertion, string path, int statusCode) { return assertion.HaveStdErrContaining($"Initialized secondary context for config: {path}") .And.HaveStdOutContaining($"hostfxr_initialize_for_runtime_config succeeded: 0x{statusCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> FailToInitializeContextForConfig(this CommandResultAssertions assertion, int errorCode) { return assertion.HaveStdOutContaining($"hostfxr_initialize_for_runtime_config failed: 0x{errorCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> GetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, string value) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_property_value succeeded for property: {name}={value}"); } public static AndConstraint<CommandResultAssertions> FailToGetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_property_value failed for property: {name} - 0x{errorCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> SetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_set_runtime_property_value succeeded for property: {name}"); } public static AndConstraint<CommandResultAssertions> FailToSetRuntimePropertyValue(this CommandResultAssertions assertion, string prefix, string name, int errorCode) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_set_runtime_property_value failed for property: {name} - 0x{errorCode.ToString("x")}"); } public static AndConstraint<CommandResultAssertions> GetRuntimePropertiesIncludes(this CommandResultAssertions assertion, string prefix, string name, string value) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties succeeded") .And.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}={value}"); } public static AndConstraint<CommandResultAssertions> GetRuntimePropertiesExcludes(this CommandResultAssertions assertion, string prefix, string name) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties succeeded") .And.NotHaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties: {name}"); } public static AndConstraint<CommandResultAssertions> FailToGetRuntimeProperties(this CommandResultAssertions assertion, string prefix, int errorCode) { return assertion.HaveStdOutContaining($"{prefix}hostfxr_get_runtime_properties failed - 0x{errorCode.ToString("x")}"); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Byte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void TestZByte() { var test = new BooleanBinaryOpTest__TestZByte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); if (Sse2.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (Sse2.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (Sse2.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (Sse2.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (Sse2.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class BooleanBinaryOpTest__TestZByte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 32 && alignment != 16) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Byte> _fld1; public Vector128<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); return testStruct; } public void RunStructFldScenario(BooleanBinaryOpTest__TestZByte testClass) { var result = Sse41.TestZ(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } public void RunStructFldScenario_Load(BooleanBinaryOpTest__TestZByte testClass) { fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pFld1)), Sse2.LoadVector128((Byte*)(pFld2)) ); testClass.ValidateResult(_fld1, _fld2, result); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private Vector128<Byte> _fld1; private Vector128<Byte> _fld2; private DataTable _dataTable; static BooleanBinaryOpTest__TestZByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); } public BooleanBinaryOpTest__TestZByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse41.TestZ( Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Sse41.TestZ( Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse41.TestZ( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pClsVar1)), Sse2.LoadVector128((Byte*)(pClsVar2)) ); ValidateResult(_clsVar1, _clsVar2, result); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var result = Sse41.TestZ(op1, op2); ValidateResult(op1, op2, result); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var result = Sse41.TestZ(op1, op2); ValidateResult(op1, op2, result); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)); var result = Sse41.TestZ(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new BooleanBinaryOpTest__TestZByte(); var result = Sse41.TestZ(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new BooleanBinaryOpTest__TestZByte(); fixed (Vector128<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pFld1)), Sse2.LoadVector128((Byte*)(pFld2)) ); ValidateResult(test._fld1, test._fld2, result); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pFld1)), Sse2.LoadVector128((Byte*)(pFld2)) ); ValidateResult(_fld1, _fld2, result); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Sse41.TestZ(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(&test._fld1)), Sse2.LoadVector128((Byte*)(&test._fld2)) ); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Byte> op1, Vector128<Byte> op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "") { bool succeeded = true; var expectedResult = true; for (var i = 0; i < Op1ElementCount; i++) { expectedResult &= ((left[i] & right[i]) == 0); } succeeded = (expectedResult == result); if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse41)}.{nameof(Sse41.TestZ)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({result})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void TestZByte() { var test = new BooleanBinaryOpTest__TestZByte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); if (Sse2.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (Sse2.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (Sse2.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (Sse2.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (Sse2.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class BooleanBinaryOpTest__TestZByte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 32 && alignment != 16) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Byte> _fld1; public Vector128<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); return testStruct; } public void RunStructFldScenario(BooleanBinaryOpTest__TestZByte testClass) { var result = Sse41.TestZ(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } public void RunStructFldScenario_Load(BooleanBinaryOpTest__TestZByte testClass) { fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pFld1)), Sse2.LoadVector128((Byte*)(pFld2)) ); testClass.ValidateResult(_fld1, _fld2, result); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private Vector128<Byte> _fld1; private Vector128<Byte> _fld2; private DataTable _dataTable; static BooleanBinaryOpTest__TestZByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); } public BooleanBinaryOpTest__TestZByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse41.TestZ( Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Sse41.TestZ( Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse41.TestZ( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pClsVar1)), Sse2.LoadVector128((Byte*)(pClsVar2)) ); ValidateResult(_clsVar1, _clsVar2, result); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var result = Sse41.TestZ(op1, op2); ValidateResult(op1, op2, result); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var result = Sse41.TestZ(op1, op2); ValidateResult(op1, op2, result); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)); var result = Sse41.TestZ(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new BooleanBinaryOpTest__TestZByte(); var result = Sse41.TestZ(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new BooleanBinaryOpTest__TestZByte(); fixed (Vector128<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pFld1)), Sse2.LoadVector128((Byte*)(pFld2)) ); ValidateResult(test._fld1, test._fld2, result); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(pFld1)), Sse2.LoadVector128((Byte*)(pFld2)) ); ValidateResult(_fld1, _fld2, result); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Sse41.TestZ(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Sse41.TestZ( Sse2.LoadVector128((Byte*)(&test._fld1)), Sse2.LoadVector128((Byte*)(&test._fld2)) ); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Byte> op1, Vector128<Byte> op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "") { bool succeeded = true; var expectedResult = true; for (var i = 0; i < Op1ElementCount; i++) { expectedResult &= ((left[i] & right[i]) == 0); } succeeded = (expectedResult == result); if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse41)}.{nameof(Sse41.TestZ)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({result})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/jit64/hfa/main/testC/hfa_sd1C_r.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="hfa_testC.cs" /> <ProjectReference Include="..\dll\common.csproj" /> <ProjectReference Include="..\dll\hfa_simple_f64_managed.csproj" /> <ProjectReference Include="..\dll\CMakeLists.txt" /> <ProjectReference Include="..\dll\hfa_simple_f64_common.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="hfa_testC.cs" /> <ProjectReference Include="..\dll\common.csproj" /> <ProjectReference Include="..\dll\hfa_simple_f64_managed.csproj" /> <ProjectReference Include="..\dll\CMakeLists.txt" /> <ProjectReference Include="..\dll\hfa_simple_f64_common.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Augments/ReflectionAugments.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Internal.Reflection.Augments // ------------------------------------------------- // Why does this exist?: // Also, IntrospectionServices.GetTypeInfo() and Assembly.Load() // are defined in System.Reflection but need a way to "call into" // Reflection.Core.dll to do the real work. // // This contract adds the additional entrypoints needed to System.Reflection. // // Implemented by: // System.Reflection.dll on RH (may use ILMerging instead) // mscorlib.dll on desktop // // Consumed by: // Reflection.Core.dll using System; using System.Reflection; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using EETypeElementType = Internal.Runtime.EETypeElementType; namespace Internal.Reflection.Augments { [System.Runtime.CompilerServices.ReflectionBlocked] public static class ReflectionAugments { // // One time start up initialization - called by Reflection.Core.dll to provide System.Reflection with a way to call back // into Reflection.Core.dll. // public static void Initialize(ReflectionCoreCallbacks reflectionCoreCallbacks) { s_reflectionCoreCallbacks = reflectionCoreCallbacks; } public static TypeCode GetRuntimeTypeCode(Type type) { Debug.Assert(type != null); EETypePtr eeType; if (!type.TryGetEEType(out eeType)) { // Type exists in metadata only. Aside from the enums, there is no chance a type with a TypeCode would not have an MethodTable, // so if it's not an enum, return the default. if (!type.IsEnum) return TypeCode.Object; Type underlyingType = Enum.GetUnderlyingType(type); eeType = underlyingType.TypeHandle.ToEETypePtr(); } // Note: Type.GetTypeCode() is expected to return the underlying type's TypeCode for enums. EETypePtr.CorElementType does the same, // so this one switch handles both cases. EETypeElementType rhType = eeType.ElementType; switch (rhType) { case EETypeElementType.Boolean: return TypeCode.Boolean; case EETypeElementType.Char: return TypeCode.Char; case EETypeElementType.SByte: return TypeCode.SByte; case EETypeElementType.Byte: return TypeCode.Byte; case EETypeElementType.Int16: return TypeCode.Int16; case EETypeElementType.UInt16: return TypeCode.UInt16; case EETypeElementType.Int32: return TypeCode.Int32; case EETypeElementType.UInt32: return TypeCode.UInt32; case EETypeElementType.Int64: return TypeCode.Int64; case EETypeElementType.UInt64: return TypeCode.UInt64; case EETypeElementType.Single: return TypeCode.Single; case EETypeElementType.Double: return TypeCode.Double; default: break; } if (type == typeof(string)) return TypeCode.String; if (type == typeof(DateTime)) return TypeCode.DateTime; if (type == typeof(decimal)) return TypeCode.Decimal; if (type == typeof(DBNull)) return TypeCode.DBNull; return TypeCode.Object; } public static Type MakeGenericSignatureType(Type genericTypeDefinition, Type[] genericTypeArguments) { return new SignatureConstructedGenericType(genericTypeDefinition, genericTypeArguments); } public static TypeLoadException CreateTypeLoadException(string message, string typeName) { return new TypeLoadException(message, typeName); } internal static ReflectionCoreCallbacks ReflectionCoreCallbacks { get { ReflectionCoreCallbacks callbacks = s_reflectionCoreCallbacks; Debug.Assert(callbacks != null); return callbacks; } } private static ReflectionCoreCallbacks s_reflectionCoreCallbacks; } // // This class is implemented by Internal.Reflection.Core.dll and provides the actual implementation // of Type.GetTypeInfo() and (on Project N) (Assembly.Load()). // [System.Runtime.CompilerServices.ReflectionBlocked] public abstract class ReflectionCoreCallbacks { public abstract Assembly Load(AssemblyName refName, bool throwOnFileNotFound); public abstract Assembly Load(byte[] rawAssembly, byte[] pdbSymbolStore); public abstract Assembly Load(string assemblyPath); public abstract MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle); public abstract MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle); public abstract FieldInfo GetFieldFromHandle(RuntimeFieldHandle runtimeFieldHandle); public abstract FieldInfo GetFieldFromHandle(RuntimeFieldHandle runtimeFieldHandle, RuntimeTypeHandle declaringTypeHandle); public abstract EventInfo GetImplicitlyOverriddenBaseClassEvent(EventInfo e); public abstract MethodInfo GetImplicitlyOverriddenBaseClassMethod(MethodInfo m); public abstract PropertyInfo GetImplicitlyOverriddenBaseClassProperty(PropertyInfo p); public abstract object ActivatorCreateInstance( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, bool nonPublic); public abstract object ActivatorCreateInstance( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture, object?[]? activationAttributes); // V2 api: Creates open or closed delegates to static or instance methods - relaxed signature checking allowed. public abstract Delegate CreateDelegate(Type type, object? firstArgument, MethodInfo method, bool throwOnBindFailure); // V1 api: Creates open delegates to static or instance methods - relaxed signature checking allowed. public abstract Delegate CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure); // V1 api: Creates closed delegates to instance methods only, relaxed signature checking disallowed. [RequiresUnreferencedCode("The target method might be removed")] public abstract Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure); // V1 api: Creates open delegates to static methods only, relaxed signature checking disallowed. public abstract Delegate CreateDelegate(Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target, string method, bool ignoreCase, bool throwOnBindFailure); #if FEATURE_COMINTEROP public abstract Type GetTypeFromCLSID(Guid clsid, string server, bool throwOnError); #endif public abstract IntPtr GetFunctionPointer(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle); public abstract void RunModuleConstructor(Module module); public abstract void MakeTypedReference(object target, FieldInfo[] flds, out Type type, out int offset); public abstract Assembly[] GetLoadedAssemblies(); public abstract EnumInfo GetEnumInfo(Type type); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Internal.Reflection.Augments // ------------------------------------------------- // Why does this exist?: // Also, IntrospectionServices.GetTypeInfo() and Assembly.Load() // are defined in System.Reflection but need a way to "call into" // Reflection.Core.dll to do the real work. // // This contract adds the additional entrypoints needed to System.Reflection. // // Implemented by: // System.Reflection.dll on RH (may use ILMerging instead) // mscorlib.dll on desktop // // Consumed by: // Reflection.Core.dll using System; using System.Reflection; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using EETypeElementType = Internal.Runtime.EETypeElementType; namespace Internal.Reflection.Augments { [System.Runtime.CompilerServices.ReflectionBlocked] public static class ReflectionAugments { // // One time start up initialization - called by Reflection.Core.dll to provide System.Reflection with a way to call back // into Reflection.Core.dll. // public static void Initialize(ReflectionCoreCallbacks reflectionCoreCallbacks) { s_reflectionCoreCallbacks = reflectionCoreCallbacks; } public static TypeCode GetRuntimeTypeCode(Type type) { Debug.Assert(type != null); EETypePtr eeType; if (!type.TryGetEEType(out eeType)) { // Type exists in metadata only. Aside from the enums, there is no chance a type with a TypeCode would not have an MethodTable, // so if it's not an enum, return the default. if (!type.IsEnum) return TypeCode.Object; Type underlyingType = Enum.GetUnderlyingType(type); eeType = underlyingType.TypeHandle.ToEETypePtr(); } // Note: Type.GetTypeCode() is expected to return the underlying type's TypeCode for enums. EETypePtr.CorElementType does the same, // so this one switch handles both cases. EETypeElementType rhType = eeType.ElementType; switch (rhType) { case EETypeElementType.Boolean: return TypeCode.Boolean; case EETypeElementType.Char: return TypeCode.Char; case EETypeElementType.SByte: return TypeCode.SByte; case EETypeElementType.Byte: return TypeCode.Byte; case EETypeElementType.Int16: return TypeCode.Int16; case EETypeElementType.UInt16: return TypeCode.UInt16; case EETypeElementType.Int32: return TypeCode.Int32; case EETypeElementType.UInt32: return TypeCode.UInt32; case EETypeElementType.Int64: return TypeCode.Int64; case EETypeElementType.UInt64: return TypeCode.UInt64; case EETypeElementType.Single: return TypeCode.Single; case EETypeElementType.Double: return TypeCode.Double; default: break; } if (type == typeof(string)) return TypeCode.String; if (type == typeof(DateTime)) return TypeCode.DateTime; if (type == typeof(decimal)) return TypeCode.Decimal; if (type == typeof(DBNull)) return TypeCode.DBNull; return TypeCode.Object; } public static Type MakeGenericSignatureType(Type genericTypeDefinition, Type[] genericTypeArguments) { return new SignatureConstructedGenericType(genericTypeDefinition, genericTypeArguments); } public static TypeLoadException CreateTypeLoadException(string message, string typeName) { return new TypeLoadException(message, typeName); } internal static ReflectionCoreCallbacks ReflectionCoreCallbacks { get { ReflectionCoreCallbacks callbacks = s_reflectionCoreCallbacks; Debug.Assert(callbacks != null); return callbacks; } } private static ReflectionCoreCallbacks s_reflectionCoreCallbacks; } // // This class is implemented by Internal.Reflection.Core.dll and provides the actual implementation // of Type.GetTypeInfo() and (on Project N) (Assembly.Load()). // [System.Runtime.CompilerServices.ReflectionBlocked] public abstract class ReflectionCoreCallbacks { public abstract Assembly Load(AssemblyName refName, bool throwOnFileNotFound); public abstract Assembly Load(byte[] rawAssembly, byte[] pdbSymbolStore); public abstract Assembly Load(string assemblyPath); public abstract MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle); public abstract MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle); public abstract FieldInfo GetFieldFromHandle(RuntimeFieldHandle runtimeFieldHandle); public abstract FieldInfo GetFieldFromHandle(RuntimeFieldHandle runtimeFieldHandle, RuntimeTypeHandle declaringTypeHandle); public abstract EventInfo GetImplicitlyOverriddenBaseClassEvent(EventInfo e); public abstract MethodInfo GetImplicitlyOverriddenBaseClassMethod(MethodInfo m); public abstract PropertyInfo GetImplicitlyOverriddenBaseClassProperty(PropertyInfo p); public abstract object ActivatorCreateInstance( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, bool nonPublic); public abstract object ActivatorCreateInstance( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture, object?[]? activationAttributes); // V2 api: Creates open or closed delegates to static or instance methods - relaxed signature checking allowed. public abstract Delegate CreateDelegate(Type type, object? firstArgument, MethodInfo method, bool throwOnBindFailure); // V1 api: Creates open delegates to static or instance methods - relaxed signature checking allowed. public abstract Delegate CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure); // V1 api: Creates closed delegates to instance methods only, relaxed signature checking disallowed. [RequiresUnreferencedCode("The target method might be removed")] public abstract Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure); // V1 api: Creates open delegates to static methods only, relaxed signature checking disallowed. public abstract Delegate CreateDelegate(Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type target, string method, bool ignoreCase, bool throwOnBindFailure); #if FEATURE_COMINTEROP public abstract Type GetTypeFromCLSID(Guid clsid, string server, bool throwOnError); #endif public abstract IntPtr GetFunctionPointer(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle); public abstract void RunModuleConstructor(Module module); public abstract void MakeTypedReference(object target, FieldInfo[] flds, out Type type, out int offset); public abstract Assembly[] GetLoadedAssemblies(); public abstract EnumInfo GetEnumInfo(Type type); } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/Microsoft.Win32.SystemEvents/tests/SystemEvents.UserPreference.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; using Xunit; using static Interop; namespace Microsoft.Win32.SystemEventsTests { public class UserPreferenceTests : SystemEventsTest { private void SendMessage(int message, int uiAction, string area, bool freeMemory = true) { var areaPtr = Marshal.StringToHGlobalUni(area); try { SendMessage((int)message, (IntPtr)uiAction, areaPtr); } finally { if (freeMemory) { Marshal.FreeHGlobal(areaPtr); } } } private void SendReflectedMessage(int message, int uiAction, string area) { // WM_REFLECT is an internal message where the SystemEvents WndProc will copy // the lParam and pass it back in a posted message. In that case it expects // to be the source of the message and will free the memory itself. SendMessage(User32.WM_REFLECT + message, uiAction, area, freeMemory:false); } public static IEnumerable<object[]> PreferenceChangingCases() => new List<object[]>() { new object[] { User32.WM_SETTINGCHANGE, 0, "Policy", UserPreferenceCategory.Policy }, new object[] { User32.WM_SETTINGCHANGE, 0, "intl", UserPreferenceCategory.Locale }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACCESSTIMEOUT, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFILTERKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETHIGHCONTRAST, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENREADER, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSERIALKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSHOWSOUNDS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSOUNDSENTRY, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSTICKYKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETTOGGLEKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDESKWALLPAPER, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFONTSMOOTHING, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCURSORS, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDESKPATTERN, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETGRIDGRANULARITY, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETWORKAREA, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_ICONHORIZONTALSPACING, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_ICONVERTICALSPACING, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONMETRICS, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONS, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONTITLELOGFONT, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONTITLEWRAP, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDOUBLECLICKTIME, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDOUBLECLKHEIGHT, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDOUBLECLKWIDTH, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSE, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEBUTTONSWAP, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEHOVERHEIGHT, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEHOVERTIME, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSESPEED, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSETRAILS, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSNAPTODEFBUTTON, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETWHEELSCROLLLINES, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCURSORSHADOW, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETHOTTRACKING, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETTOOLTIPANIMATION, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETTOOLTIPFADE, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDDELAY, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDPREF, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDSPEED, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLANGTOGGLE, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUDROPALIGNMENT, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUFADE, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUSHOWDELAY, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUANIMATION, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSELECTIONFADE, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLOWPOWERACTIVE, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLOWPOWERTIMEOUT, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETPOWEROFFACTIVE, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETPOWEROFFTIMEOUT, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENSAVEACTIVE, null, UserPreferenceCategory.Screensaver }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENSAVERRUNNING, null, UserPreferenceCategory.Screensaver }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENSAVETIMEOUT, null, UserPreferenceCategory.Screensaver }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDCUES, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCOMBOBOXANIMATION, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLISTBOXSMOOTHSCROLLING, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETGRADIENTCAPTIONS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETUIEFFECTS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACTIVEWINDOWTRACKING, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACTIVEWNDTRKZORDER, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACTIVEWNDTRKTIMEOUT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETANIMATION, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETBORDER, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCARETWIDTH, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDRAGFULLWINDOWS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDRAGHEIGHT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDRAGWIDTH, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFOREGROUNDFLASHCOUNT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFOREGROUNDLOCKTIMEOUT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMINIMIZEDMETRICS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETNONCLIENTMETRICS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSHOWIMEUI, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SYSCOLORCHANGE, 0, null, UserPreferenceCategory.Color }, }; [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] [MemberData(nameof(PreferenceChangingCases))] public void SignalsUserPreferenceEventsAsynchronously(int message, int uiAction, string area, UserPreferenceCategory expectedCategory) { var changing = new AutoResetEvent(false); var changed = new AutoResetEvent(false); UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing.Set(); }; UserPreferenceChangedEventArgs changedArgs = null; UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs = e; changingDuringChanged = changingArgs; changed.Set(); }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendMessage(message, uiAction, area); Assert.True(changing.WaitOne(PostMessageWait)); Assert.NotNull(changingArgs); Assert.Equal(expectedCategory, changingArgs.Category); Assert.True(changed.WaitOne(PostMessageWait)); Assert.NotNull(changedArgs); Assert.Equal(expectedCategory, changedArgs.Category); // changed must follow changing for the same category Assert.NotNull(changingDuringChanged); Assert.Equal(expectedCategory, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; changing.Dispose(); changed.Dispose(); } } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] public void SignalsUserPreferenceEventsAsynchronouslyOnThemeChanged() { var changing = new AutoResetEvent(false); var changed = new AutoResetEvent(false); UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing.Set(); }; List<UserPreferenceChangedEventArgs> changedArgs = new List<UserPreferenceChangedEventArgs>(); UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs.Add(e); changingDuringChanged = changingArgs; // signal test to continue after two events were received if (changedArgs.Count > 1) { changed.Set(); } }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendMessage(User32.WM_THEMECHANGED, 0, null); Assert.True(changing.WaitOne(PostMessageWait)); Assert.NotNull(changingArgs); Assert.Equal(UserPreferenceCategory.VisualStyle, changingArgs.Category); Assert.True(changed.WaitOne(PostMessageWait)); Assert.Equal(2, changedArgs.Count); Assert.NotNull(changedArgs[0]); Assert.Equal(UserPreferenceCategory.Window, changedArgs[0].Category); Assert.NotNull(changedArgs[1]); Assert.Equal(UserPreferenceCategory.VisualStyle, changedArgs[1].Category); // changed must follow changing for VisualStyle Assert.NotNull(changingDuringChanged); Assert.Equal(UserPreferenceCategory.VisualStyle, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; changing.Dispose(); changed.Dispose(); } } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] [MemberData(nameof(PreferenceChangingCases))] public void SignalsUserPreferenceEventsSynchronously(int message, int uiAction, string area, UserPreferenceCategory expectedCategory) { bool changing = false, changed = false; UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing = true; }; UserPreferenceChangedEventArgs changedArgs = null; UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs = e; changingDuringChanged = changingArgs; changed = true; }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendReflectedMessage(message, uiAction, area); Assert.True(changing); Assert.NotNull(changingArgs); Assert.Equal(expectedCategory, changingArgs.Category); Assert.True(changed); Assert.NotNull(changedArgs); Assert.Equal(expectedCategory, changedArgs.Category); // changed must follow changing for the same category Assert.NotNull(changingDuringChanged); Assert.Equal(expectedCategory, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; } } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] public void SignalsUserPreferenceEventsSynchronouslyOnReflectedThemeChanged() { bool changing = false, changed = false; UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing = true; }; List<UserPreferenceChangedEventArgs> changedArgs = new List<UserPreferenceChangedEventArgs>(); UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs.Add(e); changingDuringChanged = changingArgs; changed = true; }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendReflectedMessage(User32.WM_THEMECHANGED, 0, null); Assert.True(changing); Assert.NotNull(changingArgs); Assert.Equal(UserPreferenceCategory.VisualStyle, changingArgs.Category); Assert.True(changed); Assert.Equal(2, changedArgs.Count); Assert.NotNull(changedArgs[0]); Assert.Equal(UserPreferenceCategory.Window, changedArgs[0].Category); Assert.NotNull(changedArgs[1]); Assert.Equal(UserPreferenceCategory.VisualStyle, changedArgs[1].Category); // changed must follow changing for VisualStyle Assert.NotNull(changingDuringChanged); Assert.Equal(UserPreferenceCategory.VisualStyle, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; using Xunit; using static Interop; namespace Microsoft.Win32.SystemEventsTests { public class UserPreferenceTests : SystemEventsTest { private void SendMessage(int message, int uiAction, string area, bool freeMemory = true) { var areaPtr = Marshal.StringToHGlobalUni(area); try { SendMessage((int)message, (IntPtr)uiAction, areaPtr); } finally { if (freeMemory) { Marshal.FreeHGlobal(areaPtr); } } } private void SendReflectedMessage(int message, int uiAction, string area) { // WM_REFLECT is an internal message where the SystemEvents WndProc will copy // the lParam and pass it back in a posted message. In that case it expects // to be the source of the message and will free the memory itself. SendMessage(User32.WM_REFLECT + message, uiAction, area, freeMemory:false); } public static IEnumerable<object[]> PreferenceChangingCases() => new List<object[]>() { new object[] { User32.WM_SETTINGCHANGE, 0, "Policy", UserPreferenceCategory.Policy }, new object[] { User32.WM_SETTINGCHANGE, 0, "intl", UserPreferenceCategory.Locale }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACCESSTIMEOUT, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFILTERKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETHIGHCONTRAST, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENREADER, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSERIALKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSHOWSOUNDS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSOUNDSENTRY, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSTICKYKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETTOGGLEKEYS, null, UserPreferenceCategory.Accessibility }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDESKWALLPAPER, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFONTSMOOTHING, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCURSORS, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDESKPATTERN, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETGRIDGRANULARITY, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETWORKAREA, null, UserPreferenceCategory.Desktop }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_ICONHORIZONTALSPACING, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_ICONVERTICALSPACING, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONMETRICS, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONS, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONTITLELOGFONT, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETICONTITLEWRAP, null, UserPreferenceCategory.Icon }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDOUBLECLICKTIME, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDOUBLECLKHEIGHT, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDOUBLECLKWIDTH, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSE, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEBUTTONSWAP, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEHOVERHEIGHT, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSEHOVERTIME, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSESPEED, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMOUSETRAILS, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSNAPTODEFBUTTON, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETWHEELSCROLLLINES, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCURSORSHADOW, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETHOTTRACKING, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETTOOLTIPANIMATION, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETTOOLTIPFADE, null, UserPreferenceCategory.Mouse }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDDELAY, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDPREF, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDSPEED, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLANGTOGGLE, null, UserPreferenceCategory.Keyboard }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUDROPALIGNMENT, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUFADE, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUSHOWDELAY, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMENUANIMATION, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSELECTIONFADE, null, UserPreferenceCategory.Menu }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLOWPOWERACTIVE, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLOWPOWERTIMEOUT, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETPOWEROFFACTIVE, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETPOWEROFFTIMEOUT, null, UserPreferenceCategory.Power }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENSAVEACTIVE, null, UserPreferenceCategory.Screensaver }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENSAVERRUNNING, null, UserPreferenceCategory.Screensaver }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSCREENSAVETIMEOUT, null, UserPreferenceCategory.Screensaver }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETKEYBOARDCUES, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCOMBOBOXANIMATION, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETLISTBOXSMOOTHSCROLLING, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETGRADIENTCAPTIONS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETUIEFFECTS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACTIVEWINDOWTRACKING, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACTIVEWNDTRKZORDER, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETACTIVEWNDTRKTIMEOUT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETANIMATION, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETBORDER, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETCARETWIDTH, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDRAGFULLWINDOWS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDRAGHEIGHT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETDRAGWIDTH, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFOREGROUNDFLASHCOUNT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETFOREGROUNDLOCKTIMEOUT, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETMINIMIZEDMETRICS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETNONCLIENTMETRICS, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SETTINGCHANGE, User32.SPI_SETSHOWIMEUI, null, UserPreferenceCategory.Window }, new object[] { User32.WM_SYSCOLORCHANGE, 0, null, UserPreferenceCategory.Color }, }; [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] [MemberData(nameof(PreferenceChangingCases))] public void SignalsUserPreferenceEventsAsynchronously(int message, int uiAction, string area, UserPreferenceCategory expectedCategory) { var changing = new AutoResetEvent(false); var changed = new AutoResetEvent(false); UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing.Set(); }; UserPreferenceChangedEventArgs changedArgs = null; UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs = e; changingDuringChanged = changingArgs; changed.Set(); }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendMessage(message, uiAction, area); Assert.True(changing.WaitOne(PostMessageWait)); Assert.NotNull(changingArgs); Assert.Equal(expectedCategory, changingArgs.Category); Assert.True(changed.WaitOne(PostMessageWait)); Assert.NotNull(changedArgs); Assert.Equal(expectedCategory, changedArgs.Category); // changed must follow changing for the same category Assert.NotNull(changingDuringChanged); Assert.Equal(expectedCategory, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; changing.Dispose(); changed.Dispose(); } } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] public void SignalsUserPreferenceEventsAsynchronouslyOnThemeChanged() { var changing = new AutoResetEvent(false); var changed = new AutoResetEvent(false); UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing.Set(); }; List<UserPreferenceChangedEventArgs> changedArgs = new List<UserPreferenceChangedEventArgs>(); UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs.Add(e); changingDuringChanged = changingArgs; // signal test to continue after two events were received if (changedArgs.Count > 1) { changed.Set(); } }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendMessage(User32.WM_THEMECHANGED, 0, null); Assert.True(changing.WaitOne(PostMessageWait)); Assert.NotNull(changingArgs); Assert.Equal(UserPreferenceCategory.VisualStyle, changingArgs.Category); Assert.True(changed.WaitOne(PostMessageWait)); Assert.Equal(2, changedArgs.Count); Assert.NotNull(changedArgs[0]); Assert.Equal(UserPreferenceCategory.Window, changedArgs[0].Category); Assert.NotNull(changedArgs[1]); Assert.Equal(UserPreferenceCategory.VisualStyle, changedArgs[1].Category); // changed must follow changing for VisualStyle Assert.NotNull(changingDuringChanged); Assert.Equal(UserPreferenceCategory.VisualStyle, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; changing.Dispose(); changed.Dispose(); } } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] [MemberData(nameof(PreferenceChangingCases))] public void SignalsUserPreferenceEventsSynchronously(int message, int uiAction, string area, UserPreferenceCategory expectedCategory) { bool changing = false, changed = false; UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing = true; }; UserPreferenceChangedEventArgs changedArgs = null; UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs = e; changingDuringChanged = changingArgs; changed = true; }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendReflectedMessage(message, uiAction, area); Assert.True(changing); Assert.NotNull(changingArgs); Assert.Equal(expectedCategory, changingArgs.Category); Assert.True(changed); Assert.NotNull(changedArgs); Assert.Equal(expectedCategory, changedArgs.Category); // changed must follow changing for the same category Assert.NotNull(changingDuringChanged); Assert.Equal(expectedCategory, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; } } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] public void SignalsUserPreferenceEventsSynchronouslyOnReflectedThemeChanged() { bool changing = false, changed = false; UserPreferenceChangingEventArgs changingArgs = null; UserPreferenceChangingEventHandler changingHandler = (o, e) => { changingArgs = e; changing = true; }; List<UserPreferenceChangedEventArgs> changedArgs = new List<UserPreferenceChangedEventArgs>(); UserPreferenceChangingEventArgs changingDuringChanged = null; UserPreferenceChangedEventHandler changedHandler = (o, e) => { changedArgs.Add(e); changingDuringChanged = changingArgs; changed = true; }; SystemEvents.UserPreferenceChanging += changingHandler; SystemEvents.UserPreferenceChanged += changedHandler; try { SendReflectedMessage(User32.WM_THEMECHANGED, 0, null); Assert.True(changing); Assert.NotNull(changingArgs); Assert.Equal(UserPreferenceCategory.VisualStyle, changingArgs.Category); Assert.True(changed); Assert.Equal(2, changedArgs.Count); Assert.NotNull(changedArgs[0]); Assert.Equal(UserPreferenceCategory.Window, changedArgs[0].Category); Assert.NotNull(changedArgs[1]); Assert.Equal(UserPreferenceCategory.VisualStyle, changedArgs[1].Category); // changed must follow changing for VisualStyle Assert.NotNull(changingDuringChanged); Assert.Equal(UserPreferenceCategory.VisualStyle, changingDuringChanged.Category); } finally { SystemEvents.UserPreferenceChanging -= changingHandler; SystemEvents.UserPreferenceChanged -= changedHandler; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/General/Vector64_1/As.Int16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void AsInt16() { var test = new VectorAs__AsInt16(); // Validates basic functionality works test.RunBasicScenario(); // Validates basic functionality works using the generic form, rather than the type-specific form of the method test.RunGenericScenario(); // Validates calling via reflection works test.RunReflectionScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorAs__AsInt16 { private static readonly int LargestVectorSize = 8; private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); public bool Succeeded { get; set; } = true; public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); Vector64<Int16> value; value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<byte> byteResult = value.AsByte(); ValidateResult(byteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<double> doubleResult = value.AsDouble(); ValidateResult(doubleResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<short> shortResult = value.AsInt16(); ValidateResult(shortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<int> intResult = value.AsInt32(); ValidateResult(intResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<long> longResult = value.AsInt64(); ValidateResult(longResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<sbyte> sbyteResult = value.AsSByte(); ValidateResult(sbyteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<float> floatResult = value.AsSingle(); ValidateResult(floatResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ushort> ushortResult = value.AsUInt16(); ValidateResult(ushortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<uint> uintResult = value.AsUInt32(); ValidateResult(uintResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ulong> ulongResult = value.AsUInt64(); ValidateResult(ulongResult, value); } public void RunGenericScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunGenericScenario)); Vector64<Int16> value; value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<byte> byteResult = value.As<Int16, byte>(); ValidateResult(byteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<double> doubleResult = value.As<Int16, double>(); ValidateResult(doubleResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<short> shortResult = value.As<Int16, short>(); ValidateResult(shortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<int> intResult = value.As<Int16, int>(); ValidateResult(intResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<long> longResult = value.As<Int16, long>(); ValidateResult(longResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<sbyte> sbyteResult = value.As<Int16, sbyte>(); ValidateResult(sbyteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<float> floatResult = value.As<Int16, float>(); ValidateResult(floatResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ushort> ushortResult = value.As<Int16, ushort>(); ValidateResult(ushortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<uint> uintResult = value.As<Int16, uint>(); ValidateResult(uintResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ulong> ulongResult = value.As<Int16, ulong>(); ValidateResult(ulongResult, value); } public void RunReflectionScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); Vector64<Int16> value; value = Vector64.Create(TestLibrary.Generator.GetInt16()); object byteResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsByte)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<byte>)(byteResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object doubleResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsDouble)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<double>)(doubleResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object shortResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsInt16)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<short>)(shortResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object intResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsInt32)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<int>)(intResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object longResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsInt64)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<long>)(longResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object sbyteResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsSByte)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<sbyte>)(sbyteResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object floatResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsSingle)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<float>)(floatResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object ushortResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsUInt16)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<ushort>)(ushortResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object uintResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsUInt32)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<uint>)(uintResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object ulongResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsUInt64)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<ulong>)(ulongResult), value); } private void ValidateResult<T>(Vector64<T> result, Vector64<Int16> value, [CallerMemberName] string method = "") where T : struct { Int16[] resultElements = new Int16[ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref resultElements[0]), result); Int16[] valueElements = new Int16[ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref valueElements[0]), value); ValidateResult(resultElements, valueElements, typeof(T), method); } private void ValidateResult(Int16[] resultElements, Int16[] valueElements, Type targetType, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < ElementCount; i++) { if (resultElements[i] != valueElements[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"Vector64<Int16>.As{targetType.Name}: {method} failed:"); TestLibrary.TestFramework.LogInformation($" value: ({string.Join(", ", valueElements)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void AsInt16() { var test = new VectorAs__AsInt16(); // Validates basic functionality works test.RunBasicScenario(); // Validates basic functionality works using the generic form, rather than the type-specific form of the method test.RunGenericScenario(); // Validates calling via reflection works test.RunReflectionScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorAs__AsInt16 { private static readonly int LargestVectorSize = 8; private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); public bool Succeeded { get; set; } = true; public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); Vector64<Int16> value; value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<byte> byteResult = value.AsByte(); ValidateResult(byteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<double> doubleResult = value.AsDouble(); ValidateResult(doubleResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<short> shortResult = value.AsInt16(); ValidateResult(shortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<int> intResult = value.AsInt32(); ValidateResult(intResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<long> longResult = value.AsInt64(); ValidateResult(longResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<sbyte> sbyteResult = value.AsSByte(); ValidateResult(sbyteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<float> floatResult = value.AsSingle(); ValidateResult(floatResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ushort> ushortResult = value.AsUInt16(); ValidateResult(ushortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<uint> uintResult = value.AsUInt32(); ValidateResult(uintResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ulong> ulongResult = value.AsUInt64(); ValidateResult(ulongResult, value); } public void RunGenericScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunGenericScenario)); Vector64<Int16> value; value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<byte> byteResult = value.As<Int16, byte>(); ValidateResult(byteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<double> doubleResult = value.As<Int16, double>(); ValidateResult(doubleResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<short> shortResult = value.As<Int16, short>(); ValidateResult(shortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<int> intResult = value.As<Int16, int>(); ValidateResult(intResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<long> longResult = value.As<Int16, long>(); ValidateResult(longResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<sbyte> sbyteResult = value.As<Int16, sbyte>(); ValidateResult(sbyteResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<float> floatResult = value.As<Int16, float>(); ValidateResult(floatResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ushort> ushortResult = value.As<Int16, ushort>(); ValidateResult(ushortResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<uint> uintResult = value.As<Int16, uint>(); ValidateResult(uintResult, value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); Vector64<ulong> ulongResult = value.As<Int16, ulong>(); ValidateResult(ulongResult, value); } public void RunReflectionScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); Vector64<Int16> value; value = Vector64.Create(TestLibrary.Generator.GetInt16()); object byteResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsByte)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<byte>)(byteResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object doubleResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsDouble)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<double>)(doubleResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object shortResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsInt16)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<short>)(shortResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object intResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsInt32)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<int>)(intResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object longResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsInt64)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<long>)(longResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object sbyteResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsSByte)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<sbyte>)(sbyteResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object floatResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsSingle)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<float>)(floatResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object ushortResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsUInt16)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<ushort>)(ushortResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object uintResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsUInt32)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<uint>)(uintResult), value); value = Vector64.Create(TestLibrary.Generator.GetInt16()); object ulongResult = typeof(Vector64) .GetMethod(nameof(Vector64.AsUInt64)) .MakeGenericMethod(typeof(Int16)) .Invoke(null, new object[] { value }); ValidateResult((Vector64<ulong>)(ulongResult), value); } private void ValidateResult<T>(Vector64<T> result, Vector64<Int16> value, [CallerMemberName] string method = "") where T : struct { Int16[] resultElements = new Int16[ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref resultElements[0]), result); Int16[] valueElements = new Int16[ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref valueElements[0]), value); ValidateResult(resultElements, valueElements, typeof(T), method); } private void ValidateResult(Int16[] resultElements, Int16[] valueElements, Type targetType, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < ElementCount; i++) { if (resultElements[i] != valueElements[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"Vector64<Int16>.As{targetType.Name}: {method} failed:"); TestLibrary.TestFramework.LogInformation($" value: ({string.Join(", ", valueElements)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int64.1.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void ShiftLeftLogical128BitLaneInt641() { var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Avx.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Avx.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Avx.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 { private struct TestStruct { public Vector256<Int64> _fld; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref testStruct._fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); return testStruct; } public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 testClass) { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int64>>() / sizeof(Int64); private static Int64[] _data = new Int64[Op1ElementCount]; private static Vector256<Int64> _clsVar; private Vector256<Int64> _fld; private SimpleUnaryOpTest__DataTable<Int64, Int64> _dataTable; static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); } public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } _dataTable = new SimpleUnaryOpTest__DataTable<Int64, Int64>(_data, new Int64[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Avx2.ShiftLeftLogical128BitLane( Unsafe.Read<Vector256<Int64>>(_dataTable.inArrayPtr), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Avx2.ShiftLeftLogical128BitLane( Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Avx2.ShiftLeftLogical128BitLane( Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Avx2).GetMethod(nameof(Avx2.ShiftLeftLogical128BitLane), new Type[] { typeof(Vector256<Int64>), typeof(byte) }) .Invoke(null, new object[] { Unsafe.Read<Vector256<Int64>>(_dataTable.inArrayPtr), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Avx2).GetMethod(nameof(Avx2.ShiftLeftLogical128BitLane), new Type[] { typeof(Vector256<Int64>), typeof(byte) }) .Invoke(null, new object[] { Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Avx2).GetMethod(nameof(Avx2.ShiftLeftLogical128BitLane), new Type[] { typeof(Vector256<Int64>), typeof(byte) }) .Invoke(null, new object[] { Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Avx2.ShiftLeftLogical128BitLane( _clsVar, 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var firstOp = Unsafe.Read<Vector256<Int64>>(_dataTable.inArrayPtr); var result = Avx2.ShiftLeftLogical128BitLane(firstOp, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); var result = Avx2.ShiftLeftLogical128BitLane(firstOp, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); var result = Avx2.ShiftLeftLogical128BitLane(firstOp, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector256<Int64> firstOp, void* result, [CallerMemberName] string method = "") { Int64[] inArray = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int64>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { Int64[] inArray = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int64>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != 2048) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != 2048) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ShiftLeftLogical128BitLane)}<Int64>(Vector256<Int64><9>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void ShiftLeftLogical128BitLaneInt641() { var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Avx.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Avx.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Avx.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 { private struct TestStruct { public Vector256<Int64> _fld; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref testStruct._fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); return testStruct; } public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 testClass) { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int64>>() / sizeof(Int64); private static Int64[] _data = new Int64[Op1ElementCount]; private static Vector256<Int64> _clsVar; private Vector256<Int64> _fld; private SimpleUnaryOpTest__DataTable<Int64, Int64> _dataTable; static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); } public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } _dataTable = new SimpleUnaryOpTest__DataTable<Int64, Int64>(_data, new Int64[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Avx2.ShiftLeftLogical128BitLane( Unsafe.Read<Vector256<Int64>>(_dataTable.inArrayPtr), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Avx2.ShiftLeftLogical128BitLane( Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Avx2.ShiftLeftLogical128BitLane( Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Avx2).GetMethod(nameof(Avx2.ShiftLeftLogical128BitLane), new Type[] { typeof(Vector256<Int64>), typeof(byte) }) .Invoke(null, new object[] { Unsafe.Read<Vector256<Int64>>(_dataTable.inArrayPtr), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Avx2).GetMethod(nameof(Avx2.ShiftLeftLogical128BitLane), new Type[] { typeof(Vector256<Int64>), typeof(byte) }) .Invoke(null, new object[] { Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Avx2).GetMethod(nameof(Avx2.ShiftLeftLogical128BitLane), new Type[] { typeof(Vector256<Int64>), typeof(byte) }) .Invoke(null, new object[] { Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Avx2.ShiftLeftLogical128BitLane( _clsVar, 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var firstOp = Unsafe.Read<Vector256<Int64>>(_dataTable.inArrayPtr); var result = Avx2.ShiftLeftLogical128BitLane(firstOp, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); var result = Avx2.ShiftLeftLogical128BitLane(firstOp, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); var result = Avx2.ShiftLeftLogical128BitLane(firstOp, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector256<Int64> firstOp, void* result, [CallerMemberName] string method = "") { Int64[] inArray = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int64>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { Int64[] inArray = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int64>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != 2048) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != 2048) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ShiftLeftLogical128BitLane)}<Int64>(Vector256<Int64><9>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Drawing.Common/tests/TrimmingTests/IconSave.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Drawing; using System.IO; /// <summary> /// Tests that Icon.Save works when the Icon is loaded from an IntPtr. /// This causes COM to be used to save the Icon. /// </summary> class Program { static int Main(string[] args) { Icon i = SystemIcons.WinLogo; using MemoryStream stream = new(); i.Save(stream); // ensure something was written to the stream if (stream.Position == 0) { return -1; } return 100; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Drawing; using System.IO; /// <summary> /// Tests that Icon.Save works when the Icon is loaded from an IntPtr. /// This causes COM to be used to save the Icon. /// </summary> class Program { static int Main(string[] args) { Icon i = SystemIcons.WinLogo; using MemoryStream stream = new(); i.Save(stream); // ensure something was written to the stream if (stream.Position == 0) { return -1; } return 100; } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/Generics/Coverage/chaos56200037cs.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // /// <summary>Generic chaos types</summary> /// <remarks>CommandLine: ///<code>GenericChaos.exe /mtc:10 /mtcc:10 /mic:5 /ol:Cs /ol:Vb ///</code> ///Data: ///<code>Help: False /// MaxGenerationDepth: 2 /// MaxTypeParameterCount: 1 /// MaxMethodTypeParameterCount: 1 /// MaxTypeCount: 10 /// MaxMethodCallDepth: 1000 /// MaxTypeInheranceCount: 10 /// MaxStaticFieldCount: 2 /// MaxInterfaceCount: 5 /// GenerateInterfaces: True /// GenerateVirtualMethods: True /// GenerateMethods: True /// GenerateGenericMethods: True /// GenerateNonInlinableMethods: True /// GenerateStaticMethods: True /// GenerateInstanceMethods: True /// GenerateRecursiveMethods: True /// GenerateStaticFields: True /// GenerateInstanceFields: True /// IntermediateTypeRealization: True /// GenerateConstructorConstraints: True /// GenerateTypeParameterConstraints: True /// GenerateMethodParameterConstraints: True /// OutputPath: chaos /// OutputLanguages: /// Cs /// Vb /// OutputNamespace: Chaos /// ShowOutputInConsole: False /// CompileAndRun: False /// </code></remarks> namespace Chaos { using System; public class A0A1<T0> : A0, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A1GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A1Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A1(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0 next = new A0A0(); next.RecurseA0A0((depth - 1)); } public void CreateAllTypesA0A1() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A0<A0A3>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A3<A0A0A1>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA1>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A3<A0A0A1>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1A2<A0A0A0A0<A0A0A1>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A3<A0A0A1>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<IA2>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A0A3<A0A0A1>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A1<A0A0A1>.VerifyA0A1NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1<A0A1A2<A0A0A0A0<A0A0A1>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A1GenericStatic<A0A0>(); A0A1<A0A1A2<A0A0A0A0<A0A0A1>>>.VerifyA0A1Static(); A0A1<A0> v21 = new A0A1<A0>(); v21.VerifyA0A1NotInlinedGeneric<A0>(); A0A1<A0A0A3<A0A0A1>> v22 = new A0A1<A0A0A3<A0A0A1>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A4<A0A0A1>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A0A0<A0A3>>(); A0A0A0<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A0A0Static(); A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>> v25 = new A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A0<A0A3> v26 = new A0A0A0<A0A3>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>())); i28.VerifyInterfaceGenericIA2<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A4<A0A0A1>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A3<A0A0A1>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A0A1>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1A1<A0A0A1>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0>.VerifyA0A1A2GenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1A1<A0A0A1>>.VerifyA0A1A2Static(); A0A1A2<A0A0A3<A0A0A1>> v37 = new A0A1A2<A0A0A3<A0A0A1>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1> v38 = new A0A1A2<A0A0A1>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A3<A0A0A1>>())); i40.VerifyInterfaceGenericIA2<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0>.VerifyA0A0A0A0GenericStatic<A0A0>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3> v41 = new A0A0A0A0<A0A3>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A0A0<A0> v42 = new A0A0A0A0<A0>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A1A1<A0A0A1>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3>(); A0A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A4NotInlinedGenericStatic<A0A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A4<A0>.VerifyA0A4NotInlinedStatic(); A0A4<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A4GenericStatic<A0A0A3<A0A0A1>>(); A0A4<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A4Static(); A0A4<A0A3> v45 = new A0A4<A0A3>(); v45.VerifyA0A4NotInlinedGeneric<A0>(); A0A4<A0A0> v46 = new A0A4<A0A0>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A4<A0A0>>.VerifyA0A0A3NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0>.VerifyA0A0A3GenericStatic<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0A3<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A0A3Static(); A0A0A3<A0A0A1> v47 = new A0A0A3<A0A0A1>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1>(); A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>> v48 = new A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A1>.VerifyA0A3A4NotInlinedGenericStatic<A0A0>(); A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A3>.VerifyA0A3A4GenericStatic<A0A4<A0A0>>(); A0A3A4<A0A3>.VerifyA0A3A4Static(); A0A3A4<A0A4<A0A0>> v49 = new A0A3A4<A0A4<A0A0>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A4<A0A0>>(); A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>> v50 = new A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A3>(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A0A1A1GenericStatic<A0A1A2<A0A0A3<A0A0A1>>>(); A0A0A1A1<A0>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>> v51 = new A0A0A1A1<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A4<A0A0>>(); A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>> v52 = new A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0 : object, IA1, IA2 { private static A0A0A3<A0A0A1> _sfA00; private A0A0 _fA01; public void VerifyInterfaceIA1() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void VerifyInterfaceGenericIA1<K>() where K : new() { System.Console.WriteLine(typeof(A0)); K t1 = new K(); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void VerifyInterfaceIA2() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void VerifyInterfaceGenericIA2<K>() where K : new() { System.Console.WriteLine(typeof(A0)); K t1 = new K(); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); T t2 = new T(); A0._sfA00 = new A0A0A3<A0A0A1>(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0NotInlinedStatic() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); } public static void VerifyA0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); T t2 = new T(); A0._sfA00 = new A0A0A3<A0A0A1>(); } public static void VerifyA0Static() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); T t3 = new T(); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0NotInlined() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public virtual void VirtualVerifyGeneric<T>() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public virtual void VirtualVerify() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void RecurseA0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A1A1<A0A1<A0A0A0<A0>>> next = new A0A0A1A1<A0A1<A0A0A0<A0>>>(); next.RecurseA0A0A1A1((depth - 1)); } public void DeepRecursion() { this.RecurseA0(1000); System.Console.WriteLine(); } public void CreateAllTypesA0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3A4<A0A0A3<A0A0A1>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A1<A0A0A0<A0>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A0A0<A0>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A1<A0A0A0<A0>>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A0A0<A0>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A1A2<A0A0A1>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A0A1>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A0A1>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>>(); A0A1<A0A1A2<A0A0A1>>.VerifyA0A1NotInlinedGenericStatic<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); A0A1<A0>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A1A1<A0A1<A0A0A0<A0>>>>.VerifyA0A1GenericStatic<A0A0A3<A0A0A1>>(); A0A1<A0A0A0<A0A1<A0A0A0<A0>>>>.VerifyA0A1Static(); A0A1<A0A3> v21 = new A0A1<A0A3>(); v21.VerifyA0A1NotInlinedGeneric<A0>(); A0A1<A0> v22 = new A0A1<A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0A0<A0>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A3A4<A0A0A3<A0A0A1>>>())); i24.VerifyInterfaceGenericIA2<A0A0A0<A0A1<A0A0A0<A0>>>>(); A0A0A0<A0>.VerifyA0A0A0NotInlinedGenericStatic<A0A3A4<A0A0A3<A0A0A1>>>(); A0A0A0<A0A0>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A3<A0A0A1>>.VerifyA0A0A0GenericStatic<A0A0A0<A0A0A3<A0A0A1>>>(); A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>.VerifyA0A0A0Static(); A0A0A0<A0A0A0A0<A0>> v25 = new A0A0A0<A0A0A0A0<A0>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>>(); A0A0A0<A0A1<A0A3A4<A0A0A3<A0A0A1>>>> v26 = new A0A0A0<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>())); i28.VerifyInterfaceGenericIA2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1A2<A0A0A1>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0A0A0<A0>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A3<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A1>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A3>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A1A2<A0A0A1>>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A0A0<A0>>(); A0A1A2<A0A0A0A0<A0>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A1A2<A0A0A0A0<A0>>>.VerifyA0A1A2GenericStatic<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); A0A1A2<A0A3>.VerifyA0A1A2Static(); A0A1A2<A0A0A0A0<A0>> v37 = new A0A1A2<A0A0A0A0<A0>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A1>(); A0A1A2<A0A0A3<A0A0A1>> v38 = new A0A1A2<A0A0A3<A0A0A1>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>())); i40.VerifyInterfaceGenericIA2<A0A0A0A0<A0>>(); A0A0A0A0<A0A0A3<A0A0A1>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0>.VerifyA0A0A0A0GenericStatic<A0>(); A0A0A0A0<A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3> v41 = new A0A0A0A0<A0A3>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0A0<A0A3>>(); A0A0A0A0<A0A0A1A1<A0A1<A0A0A0<A0>>>> v42 = new A0A0A0A0<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A3<A0A0A1>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1>())); i44.VerifyInterfaceGenericIA2<A0A0>(); A0A4<A0>.VerifyA0A4NotInlinedGenericStatic<A0A0A3<A0A0A1>>(); A0A4<A0A0A1A1<A0A1<A0A0A0<A0>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A4GenericStatic<A0A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A4<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A4Static(); A0A4<A0A3A4<A0A0A3<A0A0A1>>> v45 = new A0A4<A0A3A4<A0A0A3<A0A0A1>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0A0<A0A0A1>>(); A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>> v46 = new A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A3>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A3GenericStatic<A0A0A0A0<A0A0A1>>(); A0A0A3<A0A0A3<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A3Static(); A0A0A3<A0A3A4<A0A0A3<A0A0A1>>> v47 = new A0A0A3<A0A3A4<A0A0A3<A0A0A1>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A3<A0A0> v48 = new A0A0A3<A0A0>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3A4<A0A0A3<A0A0A1>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A3A4<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3A4<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A3A4GenericStatic<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3A4<A0A3A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A0A0A0<A0A0A1>> v49 = new A0A3A4<A0A0A0A0<A0A0A1>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>> v50 = new A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0>(); A0A0A1A1<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0A0<A0A0A1>>.VerifyA0A0A1A1GenericStatic<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>> v51 = new A0A0A1A1<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A1>(); A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>> v52 = new A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A3A4<T0> : A0A3 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3A4NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3A4NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A3A4GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A3A4Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3A4NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3A4NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A3A4(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A3<A0A0A1> next = new A0A0A3<A0A0A1>(); next.RecurseA0A0A3((depth - 1)); } public void CreateAllTypesA0A3A4() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A0<A0A1A2<A0A0>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A3A4<A0>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA2>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A3A4<A0>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<IA2A6<A0A0A0A0<A0A0A1>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A3>(); A0A1<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); A0A1<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A1GenericStatic<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); A0A1<A0A0A1>.VerifyA0A1Static(); A0A1<A0A0A3<A0A0A0<A0A1A2<A0A0>>>> v21 = new A0A1<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A1<A0A0A0<A0A1A2<A0A0>>> v22 = new A0A1<A0A0A0<A0A1A2<A0A0>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A3A4<A0>>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A0A0<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A0A0GenericStatic<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0A0<A0A0>.VerifyA0A0A0Static(); A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>> v25 = new A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A0<A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>> v26 = new A0A0A0<A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A3>())); i28.VerifyInterfaceGenericIA2<A0A3>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A1>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3A4<A0>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A3A4<A0>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0>(); A0A1A2<A0A0>.VerifyA0A1A2NotInlinedGenericStatic<A0>(); A0A1A2<A0A1A2<A0A0>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A0A1>.VerifyA0A1A2GenericStatic<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>> v37 = new A0A1A2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); A0A1A2<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>> v38 = new A0A1A2<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3>())); i40.VerifyInterfaceGenericIA2<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A0A0<A0A0A0<A0A3>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A0A0<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A0A0<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>.VerifyA0A0A0A0GenericStatic<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0A0A0<A0A1A2<A0A3>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0> v41 = new A0A0A0A0<A0>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A3A4<A0>>(); A0A0A0A0<A0A0A1> v42 = new A0A0A0A0<A0A0A1>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0>())); i44.VerifyInterfaceGenericIA2<A0A0A0<A0A3>>(); A0A4<A0A0A1>.VerifyA0A4NotInlinedGenericStatic<A0A0>(); A0A4<A0>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0<A0A3>>.VerifyA0A4GenericStatic<A0A0A0A0<A0A0>>(); A0A4<A0A3A4<A0>>.VerifyA0A4Static(); A0A4<A0A0A0<A0A3>> v45 = new A0A4<A0A0A0<A0A3>>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0<A0A3>>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A0A0<A0A0>>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A0A0A0<A0A0>>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A0A3<A0A3>>.VerifyA0A0A3GenericStatic<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A3<A0A1A2<A0A3>>.VerifyA0A0A3Static(); A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>> v47 = new A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1>(); A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>> v48 = new A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0A0<A0A0>>(); A0A3A4<A0A0A0<A0A3>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0>.VerifyA0A3A4GenericStatic<A0A0>(); A0A3A4<A0A0A1>.VerifyA0A3A4Static(); A0A3A4<A0A0A0<A0A3>> v49 = new A0A3A4<A0A0A0<A0A3>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0<A0A3>>(); A0A3A4<A0A0> v50 = new A0A3A4<A0A0>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A4<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A1A1<A0A4<A0A0A1>>>(); A0A0A1A1<A0A3>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0A0<A0A0>>.VerifyA0A0A1A1GenericStatic<A0A0A0<A0A3>>(); A0A0A1A1<A0A3A4<A0A0>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>> v51 = new A0A0A1A1<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0>(); A0A0A1A1<A0A1A2<A0A3>> v52 = new A0A0A1A1<A0A1A2<A0A3>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A1 : A0A0, IA2 { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1NotInlinedStatic() { } public static void VerifyA0A0A1GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } public static void VerifyA0A0A1Static() { } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1NotInlined() { System.Console.WriteLine(this); } public void RecurseA0A0A1(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A3 next = new A0A3(); next.RecurseA0A3((depth - 1)); } public void CreateAllTypesA0A0A1() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A1A1<A0A0A1>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3A4<A0A1<A0>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A0<A0>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1A1<A0A0A1>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A0<A0>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA1A2<A0A1<A0A0>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1<A0>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<IA2>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A1<A0A3A4<A0A1<A0>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A0A0<A0A0A1>>(); A0A1<A0A3>.VerifyA0A1NotInlinedStatic(); A0A1<A0A3>.VerifyA0A1GenericStatic<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A1<A0A0A1A1<A0A0A1>>.VerifyA0A1Static(); A0A1<A0A3A4<A0A1<A0>>> v21 = new A0A1<A0A3A4<A0A1<A0>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A1>(); A0A1<A0A0> v22 = new A0A1<A0A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A1>())); i24.VerifyInterfaceGenericIA2<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0A3A4<A0A1<A0>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A3>.VerifyA0A0A0GenericStatic<A0A1<A0A0A1>>(); A0A0A0<A0A0A1>.VerifyA0A0A0Static(); A0A0A0<A0A3A4<A0A1<A0>>> v25 = new A0A0A0<A0A3A4<A0A1<A0>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A3A4<A0A1<A0>>>(); A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>> v26 = new A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A0<A0A0>>())); i28.VerifyInterfaceGenericIA2<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A3A4<A0A1<A0>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A4<A0A3>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A1A1<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A1>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3A4<A0A1<A0>>>.VerifyA0A1A2GenericStatic<A0A0A1>(); A0A1A2<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A1A2Static(); A0A1A2<A0A1A2<A0A0A0<A0A0A0<A0A0>>>> v37 = new A0A1A2<A0A1A2<A0A0A0<A0A0A0<A0A0>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A1A2<A0A1A2<A0A0A0<A0A0A0<A0A0>>>>>(); A0A1A2<A0A0A0A0<A0A0A1>> v38 = new A0A1A2<A0A0A0A0<A0A0A1>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A1A2<A0A0A0A0<A0A0A1>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A4<A0A3>>())); i40.VerifyInterfaceGenericIA2<A0A0A1A1<A0A0A1>>(); A0A0A0A0<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A4<A0A3>>(); A0A0A0A0<A0A0A1A1<A0A0A1>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0>.VerifyA0A0A0A0GenericStatic<A0A1<A0A0A1>>(); A0A0A0A0<A0A3A4<A0A1<A0>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>> v41 = new A0A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0<A0A0A0<A0A0>>>(); A0A0A0A0<A0A4<A0A3>> v42 = new A0A0A0A0<A0A4<A0A3>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A1<A0A0A1>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A3A4<A0A1<A0>>>())); i44.VerifyInterfaceGenericIA2<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A4<A0A3>.VerifyA0A4NotInlinedGenericStatic<A0A3A4<A0A1<A0>>>(); A0A4<A0A1A2<A0A4<A0A3>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>.VerifyA0A4GenericStatic<A0A1A2<A0A4<A0A3>>>(); A0A4<A0>.VerifyA0A4Static(); A0A4<A0A1A2<A0A4<A0A3>>> v45 = new A0A4<A0A1A2<A0A4<A0A3>>>(); v45.VerifyA0A4NotInlinedGeneric<A0>(); A0A4<A0A0A0<A0A0A0<A0A0>>> v46 = new A0A4<A0A0A0<A0A0A0<A0A0>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3A4<A0A1<A0>>>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A1>(); A0A0A3<A0A0A1A1<A0A0A1>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A3GenericStatic<A0A0A1A1<A0A0A1>>(); A0A0A3<A0A3A4<A0A1<A0>>>.VerifyA0A0A3Static(); A0A0A3<A0A3A4<A0A1<A0>>> v47 = new A0A0A3<A0A3A4<A0A1<A0>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1A1<A0A0A1>>(); A0A0A3<A0A3> v48 = new A0A0A3<A0A3>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0<A0A0A0<A0A0>>>(); A0A3A4<A0A3>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A3A4GenericStatic<A0>(); A0A3A4<A0A0>.VerifyA0A3A4Static(); A0A3A4<A0A0A3<A0A3>> v49 = new A0A3A4<A0A0A3<A0A3>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0<A0A0A0<A0A0>>>(); A0A3A4<A0A1A2<A0A4<A0A3>>> v50 = new A0A3A4<A0A1A2<A0A4<A0A3>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A0<A0A0A0<A0A0>>>(); A0A0A1A1<A0A0A3<A0A3>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A0A1A1GenericStatic<A0A3A4<A0A1A2<A0A4<A0A3>>>>(); A0A0A1A1<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A4<A0A0A0<A0A0A0<A0A0>>>> v51 = new A0A0A1A1<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A1A2<A0A4<A0A3>>>(); A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>> v52 = new A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0 : A0, IA1, IA2 { private A0A0A1A1<A0> _fA0A01; private static A0 _sfA0A00; [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); T t2 = new T(); A0A0._sfA0A00 = new A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0NotInlinedStatic() { System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); } public static void VerifyA0A0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); T t2 = new T(); A0A0._sfA0A00 = new A0(); } public static void VerifyA0A0Static() { System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); T t3 = new T(); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0NotInlined() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } public override void VirtualVerifyGeneric<T>() { base.VirtualVerifyGeneric<T>(); System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } public override void VirtualVerify() { base.VirtualVerify(); System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } public void RecurseA0A0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0 next = new A0(); next.RecurseA0((depth - 1)); } public void CreateAllTypesA0A0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A3>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A3>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A3>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A1>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A1>(); A0A1<A0A3>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0>>(); A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A0A1>>.VerifyA0A1GenericStatic<A0A0A0A0<A0A0A1>>(); A0A1<A0A0A3<A0A0>>.VerifyA0A1Static(); A0A1<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>> v21 = new A0A1<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0>(); A0A1<A0A0A0A0<A0A0A1>> v22 = new A0A1<A0A0A0A0<A0A0A1>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A0<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A0NotInlinedGenericStatic<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A0<A0A0A3<A0A0>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0>.VerifyA0A0A0GenericStatic<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A0Static(); A0A0A0<A0A0> v25 = new A0A0A0<A0A0>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A0A0<A0A0A1>>(); A0A0A0<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>> v26 = new A0A0A0<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A3>())); i28.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A3>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A0<A0A3>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A0A0<A0A0A1>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A1A2<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A1A2NotInlinedGenericStatic<A0A1A2<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A1A2<A0A0A0<A0A3>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A0A3<A0A0>>.VerifyA0A1A2GenericStatic<A0A0A3<A0A0>>(); A0A1A2<A0A1A2<A0A0A3<A0A0>>>.VerifyA0A1A2Static(); A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>> v37 = new A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>> v38 = new A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A0A0<A0A0A1>>())); i40.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0A0<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A3<A0A0>>.VerifyA0A0A0A0GenericStatic<A0A0A0A0<A0A0A3<A0A0>>>(); A0A0A0A0<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A0<A0A3>> v41 = new A0A0A0A0<A0A0A0<A0A3>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0A0<A0A0A0<A0A3>> v42 = new A0A0A0A0<A0A0A0<A0A3>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3>(); A0A4<A0A3>.VerifyA0A4NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A4<A0A0A0<A0A3>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0<A0A3>>.VerifyA0A4GenericStatic<A0A0A3<A0A0>>(); A0A4<A0A0>.VerifyA0A4Static(); A0A4<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>> v45 = new A0A4<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A0A1>>>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0A3<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A3GenericStatic<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A0A3<A0A3>.VerifyA0A0A3Static(); A0A0A3<A0A4<A0A0A1>> v47 = new A0A0A3<A0A4<A0A0A1>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A4<A0A0A1>>(); A0A0A3<A0A0A1> v48 = new A0A0A3<A0A0A1>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A4<A0A0A1>>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A3A4<A0A0A0<A0A3>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A3<A0A0A1>>.VerifyA0A3A4GenericStatic<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A3A4<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>> v49 = new A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0>(); A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>> v50 = new A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0A0<A0A3>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A1A1<A0A0A1>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A1A1<A0A0A1>>.VerifyA0A0A1A1GenericStatic<A0A0A1>(); A0A0A1A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>> v51 = new A0A0A1A1<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A1>(); A0A0A1A1<A0A0A1> v52 = new A0A0A1A1<A0A0A1>(); v52.VerifyA0A0A1A1NotInlined(); } } public interface IA2 { void VerifyInterfaceIA2(); void VerifyInterfaceGenericIA2<K>() where K : new(); } public class A0A1A2<T0> : A0A1<T0>, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1A2NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1A2NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A1A2GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A1A2Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1A2NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1A2NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A1A2(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A1 next = new A0A0A1(); next.RecurseA0A0A1((depth - 1)); } public void CreateAllTypesA0A1A2() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A3<A0A3>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A1A2<A0A4<A0A3>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1<A0A0A1>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A1A2<A0A4<A0A3>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A0<A0A0A0<A0A0>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A3A4<A0A1A2<A0A4<A0A3>>>>(); A0A1<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A1NotInlinedGenericStatic<A0A3>(); A0A1<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>.VerifyA0A1GenericStatic<A0A3>(); A0A1<A0A0>.VerifyA0A1Static(); A0A1<A0A0A3<A0A3>> v21 = new A0A1<A0A0A3<A0A3>>(); v21.VerifyA0A1NotInlinedGeneric<A0A3>(); A0A1<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>> v22 = new A0A1<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0A0A0<A0A0>>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A1>())); i24.VerifyInterfaceGenericIA2<A0A1A2<A0A4<A0A3>>>(); A0A0A0<A0A4<A0A0A0<A0A0A0<A0A0>>>>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A1>(); A0A0A0<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A0A0Static(); A0A0A0<A0A0A1> v25 = new A0A0A0<A0A0A1>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A1<A0A0A1>>(); A0A0A0<A0A0> v26 = new A0A0A0<A0A0>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A0<A0A0>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A1>())); i28.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0<A0A0A1>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A1A2<A0A4<A0A3>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A3>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A3A4<A0A1A2<A0A4<A0A3>>>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A3<A0A3>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A0<A0A0A1>>(); A0A1A2<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A1A2NotInlinedGenericStatic<A0A3>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A1A2<A0A0A1>>.VerifyA0A1A2GenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0A1A2<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A1A2Static(); A0A1A2<A0A0A0<A0A0A1>> v37 = new A0A1A2<A0A0A0<A0A0A1>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A1>(); A0A1A2<A0A0A3<A0A3>> v38 = new A0A1A2<A0A0A3<A0A3>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A1>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>())); i40.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A0A0A0<A0A0>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1>(); A0A0A0A0<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A1<A0A0A1>>.VerifyA0A0A0A0GenericStatic<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A0A0A0<A0A0A0A0<A0A1<A0A0A1>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>> v41 = new A0A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>>(); A0A0A0A0<A0A0A3<A0A3>> v42 = new A0A0A0A0<A0A0A3<A0A3>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A3<A0A3>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A3<A0A3>>())); i44.VerifyInterfaceGenericIA2<A0>(); A0A4<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A4NotInlinedGenericStatic<A0A1<A0A0A1>>(); A0A4<A0A0A0<A0A0A1>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A4<A0A0A0<A0A0A1>>>.VerifyA0A4GenericStatic<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0A4<A0A0A1>.VerifyA0A4Static(); A0A4<A0A3> v45 = new A0A4<A0A3>(); v45.VerifyA0A4NotInlinedGeneric<A0A0>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0>.VerifyA0A0A3NotInlinedGenericStatic<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0>.VerifyA0A0A3GenericStatic<A0A0A1>(); A0A0A3<A0A0A0A0<A0A0A3<A0A3>>>.VerifyA0A0A3Static(); A0A0A3<A0A0A1> v47 = new A0A0A3<A0A0A1>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A0A0<A0A0A3<A0A3>>>(); A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>> v48 = new A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A1>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A3A4<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A4<A0A0A1>>.VerifyA0A3A4GenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A3A4<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A3A4Static(); A0A3A4<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>> v49 = new A0A3A4<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0<A0A0A1>>(); A0A3A4<A0A4<A0A0A1>> v50 = new A0A3A4<A0A4<A0A0A1>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0A0<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A0<A0A0A1>>(); A0A0A1A1<A0A1<A0A0A1>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>.VerifyA0A0A1A1GenericStatic<A0A1<A0A0A1>>(); A0A0A1A1<A0A0A0A0<A0A0A3<A0A3>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A1> v51 = new A0A0A1A1<A0A0A1>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A0A0<A0A0A3<A0A3>>>(); A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>> v52 = new A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public interface IA1 : IA2 { void VerifyInterfaceIA1(); void VerifyInterfaceGenericIA1<K>() where K : new(); } public interface IA1A2<T0> : IA2 where T0 : new() { } public class Program { public static int Main(string[] args) { A0 v0 = new A0(); v0.CreateAllTypesA0(); A0A0 v1 = new A0A0(); v1.CreateAllTypesA0A0(); A0A1<A0A1<A0A4<A0A0A1>>> v2 = new A0A1<A0A1<A0A4<A0A0A1>>>(); v2.CreateAllTypesA0A1(); A0A0A0<A0A1A2<A0A3>> v3 = new A0A0A0<A0A1A2<A0A3>>(); v3.CreateAllTypesA0A0A0(); A0A3 v4 = new A0A3(); v4.CreateAllTypesA0A3(); A0A0A1 v5 = new A0A0A1(); v5.CreateAllTypesA0A0A1(); A0A1A2<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>> v6 = new A0A1A2<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>>(); v6.CreateAllTypesA0A1A2(); A0A0A0A0<A0A0> v7 = new A0A0A0A0<A0A0>(); v7.CreateAllTypesA0A0A0A0(); A0A4<A0A0A1> v8 = new A0A4<A0A0A1>(); v8.CreateAllTypesA0A4(); A0A0A3<A0A0A3<A0A0A1>> v9 = new A0A0A3<A0A0A3<A0A0A1>>(); v9.CreateAllTypesA0A0A3(); A0A3A4<A0> v10 = new A0A3A4<A0>(); v10.CreateAllTypesA0A3A4(); A0A0A1A1<A0A0A0<A0A1A2<A0A3>>> v11 = new A0A0A1A1<A0A0A0<A0A1A2<A0A3>>>(); v11.CreateAllTypesA0A0A1A1(); System.Console.WriteLine("Test SUCCESS"); return 100; } } public interface IA2A6<T0> where T0 : new() { } public interface IA1A5<T0> : IA2 where T0 : new() { } public class A0A4<T0> : A0 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A4NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A4NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A4GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A4Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A4NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A4NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A4(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A0A0<A0> next = new A0A0A0A0<A0>(); next.RecurseA0A0A0A0((depth - 1)); } public void CreateAllTypesA0A4() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3A4<A0A3>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A1>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A3<A0A3>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A1A2<A0A1A2<A0A0>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A3<A0A3>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A3A4<A0A3>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A1>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); A0A1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0>(); A0A1<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A1GenericStatic<A0A3>(); A0A1<A0>.VerifyA0A1Static(); A0A1<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>> v21 = new A0A1<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>(); A0A1<A0A3> v22 = new A0A1<A0A3>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A1A2<A0A1A2<A0A0>>>())); i24.VerifyInterfaceGenericIA2<A0A3>(); A0A0A0<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A3<A0A3>>.VerifyA0A0A0GenericStatic<A0A4<A0A0A0<A0A0>>>(); A0A0A0<A0A0A3<A0A3>>.VerifyA0A0A0Static(); A0A0A0<A0A0A3<A0A3>> v25 = new A0A0A0<A0A0A3<A0A3>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A3<A0A3>>(); A0A0A0<A0A0A1> v26 = new A0A0A0<A0A0A1>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>())); i28.VerifyInterfaceGenericIA2<A0A3>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A1<A0A1A2<A0A1A2<A0A0>>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A3<A0A3>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A1>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A4<A0A0A0<A0A0>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedGenericStatic<A0A4<A0A0A0<A0A0>>>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3A4<A0A3>>.VerifyA0A1A2GenericStatic<A0A0A1>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>> v37 = new A0A1A2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0>(); A0A1A2<A0A0> v38 = new A0A1A2<A0A0>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0>())); i40.VerifyInterfaceGenericIA2<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); A0A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0>(); A0A0A0A0<A0A1<A0A1A2<A0A1A2<A0A0>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A1<A0A1A2<A0A1A2<A0A0>>>>.VerifyA0A0A0A0GenericStatic<A0A0A3<A0A3>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>> v41 = new A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0>(); A0A0A0A0<A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>> v42 = new A0A0A0A0<A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A1>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0>())); i44.VerifyInterfaceGenericIA2<A0A0>(); A0A4<A0A0A1>.VerifyA0A4NotInlinedGenericStatic<A0A1<A0A1A2<A0A1A2<A0A0>>>>(); A0A4<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0A0<A0A0>>.VerifyA0A4GenericStatic<A0A4<A0A0A0A0<A0A0>>>(); A0A4<A0A0>.VerifyA0A4Static(); A0A4<A0A0A1> v45 = new A0A4<A0A0A1>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A4<A0A3> v46 = new A0A4<A0A3>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A0A0<A0A0>>.VerifyA0A0A3NotInlinedGenericStatic<A0A3>(); A0A0A3<A0A3A4<A0A3>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>.VerifyA0A0A3GenericStatic<A0A1A2<A0A0>>(); A0A0A3<A0A3>.VerifyA0A0A3Static(); A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>> v47 = new A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>(); A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>> v48 = new A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A4<A0A3>>.VerifyA0A3A4NotInlinedGenericStatic<A0A1A2<A0A0>>(); A0A3A4<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>.VerifyA0A3A4GenericStatic<A0A4<A0A3>>(); A0A3A4<A0>.VerifyA0A3A4Static(); A0A3A4<A0A1A2<A0A0>> v49 = new A0A3A4<A0A1A2<A0A0>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0>(); A0A3A4<A0A4<A0A3>> v50 = new A0A3A4<A0A4<A0A3>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0A1A1<A0A0A0A0<A0A0>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A3>.VerifyA0A0A1A1GenericStatic<A0A1A2<A0A0>>(); A0A0A1A1<A0A1A2<A0A0>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A3A4<A0A4<A0A3>>> v51 = new A0A0A1A1<A0A3A4<A0A4<A0A3>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A3>(); A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>> v52 = new A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A0A0<T0> : A0A0A0<T0>, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0A0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0A0NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A0A0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A0A0Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0A0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0A0NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A0A0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A1A2<A0A0A1> next = new A0A1A2<A0A0A1>(); next.RecurseA0A1A2((depth - 1)); } public void CreateAllTypesA0A0A0A0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A0A0<A0A0A3<A0A3>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A0<A0A0A1>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA2>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A1<A0A0A1>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A1<A0A0A1>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A0<A0A0A1>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0>(); A0A1<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); A0A1<A0A0A0<A0A0A1>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0>.VerifyA0A1GenericStatic<A0A0A1>(); A0A1<A0A1<A0A0>>.VerifyA0A1Static(); A0A1<A0A0A0A0<A0A0A3<A0A3>>> v21 = new A0A1<A0A0A0A0<A0A0A3<A0A3>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A1>(); A0A1<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>> v22 = new A0A1<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0A0A1>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A0>(); A0A0A0<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A0<A0A3A4<A0A4<A0A0A1>>>>(); A0A0A0<A0A0A0A0<A0A0A3<A0A3>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A0<A0A0A0A0<A0A0A3<A0A3>>>>.VerifyA0A0A0GenericStatic<A0A4<A0A0A1>>(); A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>.VerifyA0A0A0Static(); A0A0A0<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>> v25 = new A0A0A0<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); A0A0A0<A0A3A4<A0A4<A0A0A1>>> v26 = new A0A0A0<A0A3A4<A0A4<A0A0A1>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0>())); i28.VerifyInterfaceGenericIA2<A0A0>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A4<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A3>(); A0A1A2<A0A0A0<A0A0>>.VerifyA0A1A2NotInlinedGenericStatic<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A1A2<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A4<A0A0A1>>.VerifyA0A1A2GenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0> v37 = new A0A1A2<A0>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A1>(); A0A1A2<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>> v38 = new A0A1A2<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A1A2<A0A0>>())); i40.VerifyInterfaceGenericIA2<A0A1A2<A0A1A2<A0A0>>>(); A0A0A0A0<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A0A0A0GenericStatic<A0A0A0<A0A0>>(); A0A0A0A0<A0A0A0A0<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3A4<A0A4<A0A0A1>>> v41 = new A0A0A0A0<A0A3A4<A0A4<A0A0A1>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A4<A0A0A1>>(); A0A0A0A0<A0A0A1> v42 = new A0A0A0A0<A0A0A1>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3A4<A0A4<A0A0A1>>>(); A0A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A4NotInlinedGenericStatic<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A4<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A4GenericStatic<A0A4<A0A1A2<A0A1A2<A0A0>>>>(); A0A4<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A4Static(); A0A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>> v45 = new A0A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); A0A4<A0A0A0<A0A0>> v46 = new A0A4<A0A0A0<A0A0>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A3>>(); A0A0A3<A0A4<A0A0A0<A0A0>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0>.VerifyA0A0A3GenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A0A3<A0A0A1>.VerifyA0A0A3Static(); A0A0A3<A0A0A0<A0A0>> v47 = new A0A0A3<A0A0A0<A0A0>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A1A2<A0A1A2<A0A0>>>(); A0A0A3<A0A3> v48 = new A0A0A3<A0A3>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A4<A0A0A0<A0A0>>>(); A0A3A4<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A3A4GenericStatic<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); A0A3A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>> v49 = new A0A3A4<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A1A2<A0A1A2<A0A0>>>(); A0A3A4<A0A3> v50 = new A0A3A4<A0A3>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A0<A0A0>>(); A0A0A1A1<A0A0A0<A0A0>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A1A1<A0A0A0<A0A0>>>.VerifyA0A0A1A1GenericStatic<A0>(); A0A0A1A1<A0A0A1A1<A0A0A1A1<A0A0A0<A0A0>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A0<A0A0>> v51 = new A0A0A1A1<A0A0A0<A0A0>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0>(); A0A0A1A1<A0A4<A0A0A0<A0A0>>> v52 = new A0A0A1A1<A0A4<A0A0A0<A0A0>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A1A1<T0> : A0A0A1 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1A1NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1A1NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A1A1GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A1A1Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1A1NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1A1NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A1A1(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A3A4<A0A0A3<A0A0A1>> next = new A0A3A4<A0A0A3<A0A0A1>>(); next.RecurseA0A3A4((depth - 1)); } public void CreateAllTypesA0A0A1A1() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3>(); A0.VerifyA0NotInlinedGenericStatic<A0A0>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A3>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A3A4<A0A0>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A3>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A3A4<A0A0>>(); A0A1<A0A3>.VerifyA0A1NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A1<A0A0A0A0<A0A0>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A1>.VerifyA0A1GenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A1<A0A3>.VerifyA0A1Static(); A0A1<A0A0A1A1<A0A1A2<A0A3>>> v21 = new A0A1<A0A0A1A1<A0A1A2<A0A3>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0A0<A0A0>>(); A0A1<A0A0A1A1<A0A1A2<A0A3>>> v22 = new A0A1<A0A0A1A1<A0A1A2<A0A3>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0A3>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A4<A0A0A1>>())); i24.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0>>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A1>.VerifyA0A0A0GenericStatic<A0A0A1>(); A0A0A0<A0A1A2<A0A3>>.VerifyA0A0A0Static(); A0A0A0<A0A1<A0A4<A0A0A1>>> v25 = new A0A0A0<A0A1<A0A4<A0A0A1>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A1A1<A0A1A2<A0A3>>>(); A0A0A0<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>> v26 = new A0A0A0<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A0A0<A0A0>>())); i28.VerifyInterfaceGenericIA2<A0A0>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0<A0A0A0A0<A0A0>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A0<A0A0A0A0<A0A0>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A1A2<A0A3>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1<A0A4<A0A0A1>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A3>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A1>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A4<A0A0A1>>(); A0A1A2<A0A4<A0A0A1>>.VerifyA0A1A2NotInlinedGenericStatic<A0A0>(); A0A1A2<A0A0A1A1<A0A1A2<A0A3>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A0A1A1<A0A1A2<A0A3>>>.VerifyA0A1A2GenericStatic<A0A4<A0A0A1>>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0A1<A0A4<A0A0A1>>> v37 = new A0A1A2<A0A1<A0A4<A0A0A1>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A4<A0A0A1>>(); A0A1A2<A0A1A2<A0A1<A0A4<A0A0A1>>>> v38 = new A0A1A2<A0A1A2<A0A1<A0A4<A0A0A1>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3>())); i40.VerifyInterfaceGenericIA2<A0A3A4<A0A0>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0GenericStatic<A0A1A2<A0A3>>(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3> v41 = new A0A0A0A0<A0A3>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A1<A0A4<A0A0A1>>>(); A0A0A0A0<A0A0A0<A0A0A0A0<A0A0>>> v42 = new A0A0A0A0<A0A0A0<A0A0A0A0<A0A0>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0>())); i44.VerifyInterfaceGenericIA2<A0A0A0<A0A0A0A0<A0A0>>>(); A0A4<A0>.VerifyA0A4NotInlinedGenericStatic<A0A0A1>(); A0A4<A0A1<A0A4<A0A0A1>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A4<A0A1<A0A4<A0A0A1>>>>.VerifyA0A4GenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A4<A0A0A1>.VerifyA0A4Static(); A0A4<A0A3> v45 = new A0A4<A0A3>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0A0<A0A0>>(); A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>> v46 = new A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A0A3<A0A1<A0A4<A0A0A1>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A0>.VerifyA0A0A3GenericStatic<A0>(); A0A0A3<A0A0A3<A0A0>>.VerifyA0A0A3Static(); A0A0A3<A0> v47 = new A0A0A3<A0>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A3>(); A0A0A3<A0A0A1> v48 = new A0A0A3<A0A0A1>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A3A4<A0A0A3<A0A0A1>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>>.VerifyA0A3A4GenericStatic<A0A0A3<A0A0A1>>(); A0A3A4<A0A1A2<A0A3>>.VerifyA0A3A4Static(); A0A3A4<A0A1A2<A0A3>> v49 = new A0A3A4<A0A1A2<A0A3>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0A0<A0A0>>(); A0A3A4<A0A0A1A1<A0A1A2<A0A3>>> v50 = new A0A3A4<A0A0A1A1<A0A1A2<A0A3>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1A2<A0A3>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A0A1A1<A0A1<A0A4<A0A0A1>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A3>.VerifyA0A0A1A1GenericStatic<A0A0A0A0<A0A0>>(); A0A0A1A1<A0A0A1A1<A0A3>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>> v51 = new A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A3A4<A0A0A1A1<A0A1A2<A0A3>>>>(); A0A0A1A1<A0A0A0<A0A0A0A0<A0A0>>> v52 = new A0A0A1A1<A0A0A0<A0A0A0A0<A0A0>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A0<T0> : A0A0, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A0Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A1<A0A0A0<A0>> next = new A0A1<A0A0A0<A0>>(); next.RecurseA0A1((depth - 1)); } public void CreateAllTypesA0A0A0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA1A5<A0A0A1>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A0A3<A0A0A1>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A1<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A3>(); A0A1<A0A0A1>.VerifyA0A1NotInlinedStatic(); A0A1<A0>.VerifyA0A1GenericStatic<A0>(); A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A1Static(); A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>> v21 = new A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A1<A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>> v22 = new A0A1<A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>())); i24.VerifyInterfaceGenericIA2<A0>(); A0A0A0<A0A4<A0A0>>.VerifyA0A0A0NotInlinedGenericStatic<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>.VerifyA0A0A0GenericStatic<A0A0A0<A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>>(); A0A0A0<A0A0A1>.VerifyA0A0A0Static(); A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v25 = new A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0>(); A0A0A0<A0A0A1> v26 = new A0A0A0<A0A0A1>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>())); i28.VerifyInterfaceGenericIA2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1A2<A0A0A3<A0A0A1>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A1A2<A0A0A3<A0A0A1>>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A4<A0A0>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A1A2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A1A2NotInlinedGenericStatic<A0A3>(); A0A1A2<A0A1A2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3>.VerifyA0A1A2GenericStatic<A0>(); A0A1A2<A0>.VerifyA0A1A2Static(); A0A1A2<A0A1A2<A0>> v37 = new A0A1A2<A0A1A2<A0>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A1A2<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v38 = new A0A1A2<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>())); i40.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A0A0<A0A0>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A0A0GenericStatic<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A0A0<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v41 = new A0A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A1>(); A0A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>> v42 = new A0A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1>())); i44.VerifyInterfaceGenericIA2<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A4<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A4NotInlinedGenericStatic<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A4GenericStatic<A0A0A0A0<A0A0A1>>(); A0A4<A0A4<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>>.VerifyA0A4Static(); A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>> v45 = new A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A1>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A0A1>>(); A0A0A3<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A3>.VerifyA0A0A3GenericStatic<A0A0A1>(); A0A0A3<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A3Static(); A0A0A3<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>> v47 = new A0A0A3<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0A3<A0A0> v48 = new A0A0A3<A0A0>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A3A4<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0A0<A0A0A1>>.VerifyA0A3A4GenericStatic<A0A0>(); A0A3A4<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A3> v49 = new A0A3A4<A0A3>(); v49.VerifyA0A3A4NotInlinedGeneric<A0>(); A0A3A4<A0A4<A0A0A1>> v50 = new A0A3A4<A0A4<A0A0A1>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A4<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A0A1A1GenericStatic<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A0A1A1<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>> v51 = new A0A0A1A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v52 = new A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A3 : A0, IA2 { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3NotInlinedStatic() { } public static void VerifyA0A3GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } public static void VerifyA0A3Static() { } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3NotInlined() { System.Console.WriteLine(this); } public void RecurseA0A3(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A0<A0A1<A0A0A0<A0>>> next = new A0A0A0<A0A1<A0A0A0<A0>>>(); next.RecurseA0A0A0((depth - 1)); } public void CreateAllTypesA0A3() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A3<A0A0>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A3A4<A0A4<A0A0A1>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A1<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A1>(); A0A1<A0A0>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A1GenericStatic<A0A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>>(); A0A1<A0A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>>.VerifyA0A1Static(); A0A1<A0A4<A0A0A1>> v21 = new A0A1<A0A4<A0A0A1>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A1<A0A0> v22 = new A0A1<A0A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0A0<A0A0A1>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0>())); i24.VerifyInterfaceGenericIA2<A0>(); A0A0A0<A0>.VerifyA0A0A0NotInlinedGenericStatic<A0A1<A0>>(); A0A0A0<A0A0>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0>.VerifyA0A0A0Static(); A0A0A0<A0A3A4<A0A4<A0A0A1>>> v25 = new A0A0A0<A0A3A4<A0A4<A0A0A1>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0>(); A0A0A0<A0> v26 = new A0A0A0<A0>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0>())); i28.VerifyInterfaceGenericIA2<A0A3>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A1>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A0A0<A0A0A1>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A1<A0>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A1A2<A0A0A3<A0A0>>.VerifyA0A1A2NotInlinedGenericStatic<A0A0>(); A0A1A2<A0A0A0A0<A0A0A1>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A1A2GenericStatic<A0A1<A0>>(); A0A1A2<A0A0A0A0<A0A0A1>>.VerifyA0A1A2Static(); A0A1A2<A0> v37 = new A0A1A2<A0>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A3>(); A0A1A2<A0A1A2<A0>> v38 = new A0A1A2<A0A1A2<A0>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3A4<A0A4<A0A0A1>>>())); i40.VerifyInterfaceGenericIA2<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A0A0A0<A0A0A1>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1>(); A0A0A0A0<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A0<A0>>.VerifyA0A0A0A0GenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A1> v41 = new A0A0A0A0<A0A0A1>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A3A4<A0A4<A0A0A1>>>(); A0A0A0A0<A0A0> v42 = new A0A0A0A0<A0A0>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A3A4<A0A4<A0A0A1>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1>())); i44.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A4<A0A0A1>.VerifyA0A4NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A4<A0A0A0A0<A0A0A1>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A1<A0>>.VerifyA0A4GenericStatic<A0A0>(); A0A4<A0A0A0A0<A0A0A1>>.VerifyA0A4Static(); A0A4<A0A4<A0A0A0A0<A0A0A1>>> v45 = new A0A4<A0A4<A0A0A0A0<A0A0A1>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A4<A0A3> v46 = new A0A4<A0A3>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedGenericStatic<A0A1<A0>>(); A0A0A3<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>.VerifyA0A0A3GenericStatic<A0A0A0<A0>>(); A0A0A3<A0A3>.VerifyA0A0A3Static(); A0A0A3<A0A0A3<A0A3>> v47 = new A0A0A3<A0A0A3<A0A3>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>> v48 = new A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A1>.VerifyA0A3A4NotInlinedGenericStatic<A0A0>(); A0A3A4<A0>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A1>.VerifyA0A3A4GenericStatic<A0A3A4<A0A0A1>>(); A0A3A4<A0A1<A0>>.VerifyA0A3A4Static(); A0A3A4<A0A0> v49 = new A0A3A4<A0A0>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A3A4<A0A1<A0>> v50 = new A0A3A4<A0A1<A0>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0>(); A0A0A1A1<A0A3>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>.VerifyA0A0A1A1GenericStatic<A0A3A4<A0A1<A0>>>(); A0A0A1A1<A0A4<A0A3>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0> v51 = new A0A0A1A1<A0>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A1>(); A0A0A1A1<A0A0A1> v52 = new A0A0A1A1<A0A0A1>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A3<T0> : A0A0 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A3NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A3NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A3GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A3Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A3NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A3NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A3(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A4<A0A0A0<A0A1<A0A0A0<A0>>>> next = new A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>(); next.RecurseA0A4((depth - 1)); } public void CreateAllTypesA0A0A3() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A3A4<A0A4<A0A3>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>>(); A0A1<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A0>>.VerifyA0A1GenericStatic<A0A1<A0A0A0A0<A0A0>>>(); A0A1<A0A1A2<A0A0>>.VerifyA0A1Static(); A0A1<A0A0A1> v21 = new A0A1<A0A0A1>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A1<A0> v22 = new A0A1<A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0A0<A0A0>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A1>())); i24.VerifyInterfaceGenericIA2<A0A3>(); A0A0A0<A0A0A1>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0A0<A0A0A0<A0A0A1>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0>.VerifyA0A0A0Static(); A0A0A0<A0A0> v25 = new A0A0A0<A0A0>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0>(); A0A0A0<A0A1<A0A0A1>> v26 = new A0A0A0<A0A1<A0A0A1>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A1A2<A0A0>>())); i28.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A4<A0A3>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A1>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1A2<A0A0A0<A0A1A2<A0A0>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A1A2GenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1A2<A0A3A4<A0A4<A0A3>>>.VerifyA0A1A2Static(); A0A1A2<A0A4<A0A3>> v37 = new A0A1A2<A0A4<A0A3>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1A2<A0A4<A0A3>> v38 = new A0A1A2<A0A4<A0A3>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A3A4<A0A4<A0A3>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A0<A0A1A2<A0A0>>>())); i40.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A0A0A0<A0A0A1>.VerifyA0A0A0A0NotInlinedGenericStatic<A0>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A1>.VerifyA0A0A0A0GenericStatic<A0A4<A0A3>>(); A0A0A0A0<A0>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3A4<A0A4<A0A3>>> v41 = new A0A0A0A0<A0A3A4<A0A4<A0A3>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0<A0A1A2<A0A0>>>(); A0A0A0A0<A0A0> v42 = new A0A0A0A0<A0A0>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A3A4<A0A4<A0A3>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3A4<A0A4<A0A3>>>(); A0A4<A0A0A0<A0A1A2<A0A0>>>.VerifyA0A4NotInlinedGenericStatic<A0>(); A0A4<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0>.VerifyA0A4GenericStatic<A0A3A4<A0A4<A0A3>>>(); A0A4<A0A4<A0>>.VerifyA0A4Static(); A0A4<A0> v45 = new A0A4<A0>(); v45.VerifyA0A4NotInlinedGeneric<A0A4<A0>>(); A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>> v46 = new A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A0A3<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A0A3GenericStatic<A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>>(); A0A0A3<A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>>.VerifyA0A0A3Static(); A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>> v47 = new A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A0<A0A1A2<A0A0>>>(); A0A0A3<A0A0A0<A0A1A2<A0A0>>> v48 = new A0A0A3<A0A0A0<A0A1A2<A0A0>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A3A4<A0A0>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A3A4GenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A3A4<A0>.VerifyA0A3A4Static(); A0A3A4<A0A0A3<A0A0A0<A0A1A2<A0A0>>>> v49 = new A0A3A4<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A1<A0A0A1>>(); A0A3A4<A0> v50 = new A0A3A4<A0>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A3>(); A0A0A1A1<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0<A0A1A2<A0A0>>>.VerifyA0A0A1A1GenericStatic<A0A0>(); A0A0A1A1<A0A0A1A1<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A3> v51 = new A0A0A1A1<A0A3>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A1<A0A0A1>>(); A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>> v52 = new A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // /// <summary>Generic chaos types</summary> /// <remarks>CommandLine: ///<code>GenericChaos.exe /mtc:10 /mtcc:10 /mic:5 /ol:Cs /ol:Vb ///</code> ///Data: ///<code>Help: False /// MaxGenerationDepth: 2 /// MaxTypeParameterCount: 1 /// MaxMethodTypeParameterCount: 1 /// MaxTypeCount: 10 /// MaxMethodCallDepth: 1000 /// MaxTypeInheranceCount: 10 /// MaxStaticFieldCount: 2 /// MaxInterfaceCount: 5 /// GenerateInterfaces: True /// GenerateVirtualMethods: True /// GenerateMethods: True /// GenerateGenericMethods: True /// GenerateNonInlinableMethods: True /// GenerateStaticMethods: True /// GenerateInstanceMethods: True /// GenerateRecursiveMethods: True /// GenerateStaticFields: True /// GenerateInstanceFields: True /// IntermediateTypeRealization: True /// GenerateConstructorConstraints: True /// GenerateTypeParameterConstraints: True /// GenerateMethodParameterConstraints: True /// OutputPath: chaos /// OutputLanguages: /// Cs /// Vb /// OutputNamespace: Chaos /// ShowOutputInConsole: False /// CompileAndRun: False /// </code></remarks> namespace Chaos { using System; public class A0A1<T0> : A0, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A1GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A1Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A1(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0 next = new A0A0(); next.RecurseA0A0((depth - 1)); } public void CreateAllTypesA0A1() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A0<A0A3>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A3<A0A0A1>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA1>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A3<A0A0A1>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1A2<A0A0A0A0<A0A0A1>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A3<A0A0A1>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<IA2>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A0A3<A0A0A1>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A1<A0A0A1>.VerifyA0A1NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1<A0A1A2<A0A0A0A0<A0A0A1>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A1GenericStatic<A0A0>(); A0A1<A0A1A2<A0A0A0A0<A0A0A1>>>.VerifyA0A1Static(); A0A1<A0> v21 = new A0A1<A0>(); v21.VerifyA0A1NotInlinedGeneric<A0>(); A0A1<A0A0A3<A0A0A1>> v22 = new A0A1<A0A0A3<A0A0A1>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A4<A0A0A1>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A0A0<A0A3>>(); A0A0A0<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A0A0Static(); A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>> v25 = new A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A0<A0A3> v26 = new A0A0A0<A0A3>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>())); i28.VerifyInterfaceGenericIA2<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A4<A0A0A1>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A3<A0A0A1>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A0A1>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1A1<A0A0A1>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0>.VerifyA0A1A2GenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1A1<A0A0A1>>.VerifyA0A1A2Static(); A0A1A2<A0A0A3<A0A0A1>> v37 = new A0A1A2<A0A0A3<A0A0A1>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A1A2<A0A0A1> v38 = new A0A1A2<A0A0A1>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A3<A0A0A1>>())); i40.VerifyInterfaceGenericIA2<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0>.VerifyA0A0A0A0GenericStatic<A0A0>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3> v41 = new A0A0A0A0<A0A3>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A0A0<A0> v42 = new A0A0A0A0<A0>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A1A1<A0A0A1>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3>(); A0A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A4NotInlinedGenericStatic<A0A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A4<A0>.VerifyA0A4NotInlinedStatic(); A0A4<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A4GenericStatic<A0A0A3<A0A0A1>>(); A0A4<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A4Static(); A0A4<A0A3> v45 = new A0A4<A0A3>(); v45.VerifyA0A4NotInlinedGeneric<A0>(); A0A4<A0A0> v46 = new A0A4<A0A0>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A4<A0A0>>.VerifyA0A0A3NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0>.VerifyA0A0A3GenericStatic<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0A3<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A0A3Static(); A0A0A3<A0A0A1> v47 = new A0A0A3<A0A0A1>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1>(); A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>> v48 = new A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A1>.VerifyA0A3A4NotInlinedGenericStatic<A0A0>(); A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A3>.VerifyA0A3A4GenericStatic<A0A4<A0A0>>(); A0A3A4<A0A3>.VerifyA0A3A4Static(); A0A3A4<A0A4<A0A0>> v49 = new A0A3A4<A0A4<A0A0>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A4<A0A0>>(); A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>> v50 = new A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A3>(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A0A1A1GenericStatic<A0A1A2<A0A0A3<A0A0A1>>>(); A0A0A1A1<A0>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>> v51 = new A0A0A1A1<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A4<A0A0>>(); A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>> v52 = new A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0 : object, IA1, IA2 { private static A0A0A3<A0A0A1> _sfA00; private A0A0 _fA01; public void VerifyInterfaceIA1() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void VerifyInterfaceGenericIA1<K>() where K : new() { System.Console.WriteLine(typeof(A0)); K t1 = new K(); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void VerifyInterfaceIA2() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void VerifyInterfaceGenericIA2<K>() where K : new() { System.Console.WriteLine(typeof(A0)); K t1 = new K(); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); T t2 = new T(); A0._sfA00 = new A0A0A3<A0A0A1>(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0NotInlinedStatic() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); } public static void VerifyA0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); T t2 = new T(); A0._sfA00 = new A0A0A3<A0A0A1>(); } public static void VerifyA0Static() { System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); T t3 = new T(); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0NotInlined() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public virtual void VirtualVerifyGeneric<T>() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public virtual void VirtualVerify() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0)); A0._sfA00 = new A0A0A3<A0A0A1>(); this._fA01 = new A0A0(); } public void RecurseA0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A1A1<A0A1<A0A0A0<A0>>> next = new A0A0A1A1<A0A1<A0A0A0<A0>>>(); next.RecurseA0A0A1A1((depth - 1)); } public void DeepRecursion() { this.RecurseA0(1000); System.Console.WriteLine(); } public void CreateAllTypesA0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3A4<A0A0A3<A0A0A1>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A1<A0A0A0<A0>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A0A0<A0>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A1<A0A0A0<A0>>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A0A0<A0>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A1A2<A0A0A1>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A0A1>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A0A1>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>>(); A0A1<A0A1A2<A0A0A1>>.VerifyA0A1NotInlinedGenericStatic<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); A0A1<A0>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A1A1<A0A1<A0A0A0<A0>>>>.VerifyA0A1GenericStatic<A0A0A3<A0A0A1>>(); A0A1<A0A0A0<A0A1<A0A0A0<A0>>>>.VerifyA0A1Static(); A0A1<A0A3> v21 = new A0A1<A0A3>(); v21.VerifyA0A1NotInlinedGeneric<A0>(); A0A1<A0> v22 = new A0A1<A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0A0<A0>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A3A4<A0A0A3<A0A0A1>>>())); i24.VerifyInterfaceGenericIA2<A0A0A0<A0A1<A0A0A0<A0>>>>(); A0A0A0<A0>.VerifyA0A0A0NotInlinedGenericStatic<A0A3A4<A0A0A3<A0A0A1>>>(); A0A0A0<A0A0>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A3<A0A0A1>>.VerifyA0A0A0GenericStatic<A0A0A0<A0A0A3<A0A0A1>>>(); A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>.VerifyA0A0A0Static(); A0A0A0<A0A0A0A0<A0>> v25 = new A0A0A0<A0A0A0A0<A0>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>>(); A0A0A0<A0A1<A0A3A4<A0A0A3<A0A0A1>>>> v26 = new A0A0A0<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>())); i28.VerifyInterfaceGenericIA2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1A2<A0A0A1>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0A0A0<A0>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A3<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A1>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A3>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A1A2<A0A0A1>>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A0A0<A0>>(); A0A1A2<A0A0A0A0<A0>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A1A2<A0A0A0A0<A0>>>.VerifyA0A1A2GenericStatic<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); A0A1A2<A0A3>.VerifyA0A1A2Static(); A0A1A2<A0A0A0A0<A0>> v37 = new A0A1A2<A0A0A0A0<A0>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A1>(); A0A1A2<A0A0A3<A0A0A1>> v38 = new A0A1A2<A0A0A3<A0A0A1>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>())); i40.VerifyInterfaceGenericIA2<A0A0A0A0<A0>>(); A0A0A0A0<A0A0A3<A0A0A1>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0>.VerifyA0A0A0A0GenericStatic<A0>(); A0A0A0A0<A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3> v41 = new A0A0A0A0<A0A3>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0A0<A0A3>>(); A0A0A0A0<A0A0A1A1<A0A1<A0A0A0<A0>>>> v42 = new A0A0A0A0<A0A0A1A1<A0A1<A0A0A0<A0>>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A3<A0A0A1>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1>())); i44.VerifyInterfaceGenericIA2<A0A0>(); A0A4<A0>.VerifyA0A4NotInlinedGenericStatic<A0A0A3<A0A0A1>>(); A0A4<A0A0A1A1<A0A1<A0A0A0<A0>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A4GenericStatic<A0A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A4<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A4Static(); A0A4<A0A3A4<A0A0A3<A0A0A1>>> v45 = new A0A4<A0A3A4<A0A0A3<A0A0A1>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0A0<A0A0A1>>(); A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>> v46 = new A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A3>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A3GenericStatic<A0A0A0A0<A0A0A1>>(); A0A0A3<A0A0A3<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A3Static(); A0A0A3<A0A3A4<A0A0A3<A0A0A1>>> v47 = new A0A0A3<A0A3A4<A0A0A3<A0A0A1>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A3<A0A0> v48 = new A0A0A3<A0A0>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3A4<A0A0A3<A0A0A1>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A3A4<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3A4<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A3A4GenericStatic<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3A4<A0A3A4<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A0A0A0<A0A0A1>> v49 = new A0A3A4<A0A0A0A0<A0A0A1>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>> v50 = new A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0>(); A0A0A1A1<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0A0<A0A0A1>>.VerifyA0A0A1A1GenericStatic<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>> v51 = new A0A0A1A1<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A1>(); A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>> v52 = new A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A3A4<T0> : A0A3 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3A4NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3A4NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A3A4GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A3A4Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3A4NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3A4NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A3A4(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A3<A0A0A1> next = new A0A0A3<A0A0A1>(); next.RecurseA0A0A3((depth - 1)); } public void CreateAllTypesA0A3A4() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A0<A0A1A2<A0A0>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A3A4<A0>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA2>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A3A4<A0>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<IA2A6<A0A0A0A0<A0A0A1>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A3>(); A0A1<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); A0A1<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A1GenericStatic<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); A0A1<A0A0A1>.VerifyA0A1Static(); A0A1<A0A0A3<A0A0A0<A0A1A2<A0A0>>>> v21 = new A0A1<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A1<A0A0A0<A0A1A2<A0A0>>> v22 = new A0A1<A0A0A0<A0A1A2<A0A0>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A3A4<A0>>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A0A0<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A0A0GenericStatic<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0A0<A0A0>.VerifyA0A0A0Static(); A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>> v25 = new A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A0<A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>> v26 = new A0A0A0<A0A0A0<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A3>())); i28.VerifyInterfaceGenericIA2<A0A3>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A1>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3A4<A0>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A3A4<A0>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0>(); A0A1A2<A0A0>.VerifyA0A1A2NotInlinedGenericStatic<A0>(); A0A1A2<A0A1A2<A0A0>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A0A1>.VerifyA0A1A2GenericStatic<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>> v37 = new A0A1A2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); A0A1A2<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>> v38 = new A0A1A2<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3>())); i40.VerifyInterfaceGenericIA2<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A0A0<A0A0A0<A0A3>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A0A0<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A0A0<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>.VerifyA0A0A0A0GenericStatic<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); A0A0A0A0<A0A1A2<A0A3>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0> v41 = new A0A0A0A0<A0>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A3A4<A0>>(); A0A0A0A0<A0A0A1> v42 = new A0A0A0A0<A0A0A1>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0>())); i44.VerifyInterfaceGenericIA2<A0A0A0<A0A3>>(); A0A4<A0A0A1>.VerifyA0A4NotInlinedGenericStatic<A0A0>(); A0A4<A0>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0<A0A3>>.VerifyA0A4GenericStatic<A0A0A0A0<A0A0>>(); A0A4<A0A3A4<A0>>.VerifyA0A4Static(); A0A4<A0A0A0<A0A3>> v45 = new A0A4<A0A0A0<A0A3>>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0<A0A3>>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A0A0<A0A0>>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A0A0A0<A0A0>>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A0A3<A0A3>>.VerifyA0A0A3GenericStatic<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0A3<A0A1A2<A0A3>>.VerifyA0A0A3Static(); A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>> v47 = new A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1>(); A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>> v48 = new A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0A0<A0A0>>(); A0A3A4<A0A0A0<A0A3>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0>.VerifyA0A3A4GenericStatic<A0A0>(); A0A3A4<A0A0A1>.VerifyA0A3A4Static(); A0A3A4<A0A0A0<A0A3>> v49 = new A0A3A4<A0A0A0<A0A3>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0<A0A3>>(); A0A3A4<A0A0> v50 = new A0A3A4<A0A0>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A4<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A1A1<A0A4<A0A0A1>>>(); A0A0A1A1<A0A3>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0A0<A0A0>>.VerifyA0A0A1A1GenericStatic<A0A0A0<A0A3>>(); A0A0A1A1<A0A3A4<A0A0>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>> v51 = new A0A0A1A1<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0>(); A0A0A1A1<A0A1A2<A0A3>> v52 = new A0A0A1A1<A0A1A2<A0A3>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A1 : A0A0, IA2 { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1NotInlinedStatic() { } public static void VerifyA0A0A1GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } public static void VerifyA0A0A1Static() { } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1NotInlined() { System.Console.WriteLine(this); } public void RecurseA0A0A1(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A3 next = new A0A3(); next.RecurseA0A3((depth - 1)); } public void CreateAllTypesA0A0A1() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A1A1<A0A0A1>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3A4<A0A1<A0>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A0<A0>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1A1<A0A0A1>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A0<A0>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA1A2<A0A1<A0A0>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1<A0>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<IA2>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A1<A0A3A4<A0A1<A0>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A0A0<A0A0A1>>(); A0A1<A0A3>.VerifyA0A1NotInlinedStatic(); A0A1<A0A3>.VerifyA0A1GenericStatic<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A1<A0A0A1A1<A0A0A1>>.VerifyA0A1Static(); A0A1<A0A3A4<A0A1<A0>>> v21 = new A0A1<A0A3A4<A0A1<A0>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A1>(); A0A1<A0A0> v22 = new A0A1<A0A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A1>())); i24.VerifyInterfaceGenericIA2<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0A3A4<A0A1<A0>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A3>.VerifyA0A0A0GenericStatic<A0A1<A0A0A1>>(); A0A0A0<A0A0A1>.VerifyA0A0A0Static(); A0A0A0<A0A3A4<A0A1<A0>>> v25 = new A0A0A0<A0A3A4<A0A1<A0>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A3A4<A0A1<A0>>>(); A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>> v26 = new A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A0<A0A0>>())); i28.VerifyInterfaceGenericIA2<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A3A4<A0A1<A0>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A4<A0A3>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A1A1<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A1>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3A4<A0A1<A0>>>.VerifyA0A1A2GenericStatic<A0A0A1>(); A0A1A2<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A1A2Static(); A0A1A2<A0A1A2<A0A0A0<A0A0A0<A0A0>>>> v37 = new A0A1A2<A0A1A2<A0A0A0<A0A0A0<A0A0>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A1A2<A0A1A2<A0A0A0<A0A0A0<A0A0>>>>>(); A0A1A2<A0A0A0A0<A0A0A1>> v38 = new A0A1A2<A0A0A0A0<A0A0A1>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A1A2<A0A0A0A0<A0A0A1>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A4<A0A3>>())); i40.VerifyInterfaceGenericIA2<A0A0A1A1<A0A0A1>>(); A0A0A0A0<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A4<A0A3>>(); A0A0A0A0<A0A0A1A1<A0A0A1>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0>.VerifyA0A0A0A0GenericStatic<A0A1<A0A0A1>>(); A0A0A0A0<A0A3A4<A0A1<A0>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>> v41 = new A0A0A0A0<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0<A0A0A0<A0A0>>>(); A0A0A0A0<A0A4<A0A3>> v42 = new A0A0A0A0<A0A4<A0A3>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A1<A0A0A1>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A3A4<A0A1<A0>>>())); i44.VerifyInterfaceGenericIA2<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A4<A0A3>.VerifyA0A4NotInlinedGenericStatic<A0A3A4<A0A1<A0>>>(); A0A4<A0A1A2<A0A4<A0A3>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>.VerifyA0A4GenericStatic<A0A1A2<A0A4<A0A3>>>(); A0A4<A0>.VerifyA0A4Static(); A0A4<A0A1A2<A0A4<A0A3>>> v45 = new A0A4<A0A1A2<A0A4<A0A3>>>(); v45.VerifyA0A4NotInlinedGeneric<A0>(); A0A4<A0A0A0<A0A0A0<A0A0>>> v46 = new A0A4<A0A0A0<A0A0A0<A0A0>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3A4<A0A1<A0>>>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A1>(); A0A0A3<A0A0A1A1<A0A0A1>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A3GenericStatic<A0A0A1A1<A0A0A1>>(); A0A0A3<A0A3A4<A0A1<A0>>>.VerifyA0A0A3Static(); A0A0A3<A0A3A4<A0A1<A0>>> v47 = new A0A0A3<A0A3A4<A0A1<A0>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1A1<A0A0A1>>(); A0A0A3<A0A3> v48 = new A0A0A3<A0A3>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0<A0A0A0<A0A0>>>(); A0A3A4<A0A3>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A3A4GenericStatic<A0>(); A0A3A4<A0A0>.VerifyA0A3A4Static(); A0A3A4<A0A0A3<A0A3>> v49 = new A0A3A4<A0A0A3<A0A3>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0<A0A0A0<A0A0>>>(); A0A3A4<A0A1A2<A0A4<A0A3>>> v50 = new A0A3A4<A0A1A2<A0A4<A0A3>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A0<A0A0A0<A0A0>>>(); A0A0A1A1<A0A0A3<A0A3>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A0A1A1GenericStatic<A0A3A4<A0A1A2<A0A4<A0A3>>>>(); A0A0A1A1<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A4<A0A0A0<A0A0A0<A0A0>>>> v51 = new A0A0A1A1<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A1A2<A0A4<A0A3>>>(); A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>> v52 = new A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0 : A0, IA1, IA2 { private A0A0A1A1<A0> _fA0A01; private static A0 _sfA0A00; [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); T t2 = new T(); A0A0._sfA0A00 = new A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0NotInlinedStatic() { System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); } public static void VerifyA0A0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); T t2 = new T(); A0A0._sfA0A00 = new A0(); } public static void VerifyA0A0Static() { System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); T t3 = new T(); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0NotInlined() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } public override void VirtualVerifyGeneric<T>() { base.VirtualVerifyGeneric<T>(); System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } public override void VirtualVerify() { base.VirtualVerify(); System.Console.WriteLine(this); System.Console.WriteLine(typeof(A0A0)); A0A0._sfA0A00 = new A0(); this._fA0A01 = new A0A0A1A1<A0>(); } public void RecurseA0A0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0 next = new A0(); next.RecurseA0((depth - 1)); } public void CreateAllTypesA0A0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A3>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A3>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A3>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A1>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A1>(); A0A1<A0A3>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0>>(); A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A0A1>>.VerifyA0A1GenericStatic<A0A0A0A0<A0A0A1>>(); A0A1<A0A0A3<A0A0>>.VerifyA0A1Static(); A0A1<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>> v21 = new A0A1<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0>(); A0A1<A0A0A0A0<A0A0A1>> v22 = new A0A1<A0A0A0A0<A0A0A1>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A0A0<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A0<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>.VerifyA0A0A0NotInlinedGenericStatic<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A0<A0A0A3<A0A0>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0>.VerifyA0A0A0GenericStatic<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A0Static(); A0A0A0<A0A0> v25 = new A0A0A0<A0A0>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A0A0<A0A0A1>>(); A0A0A0<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>> v26 = new A0A0A0<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A3>())); i28.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A3>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A0<A0A3>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1A2<A0A3A4<A0A0A3<A0A0A1>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A0A0<A0A0A1>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A1A2<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A1A2NotInlinedGenericStatic<A0A1A2<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A1A2<A0A0A0<A0A3>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A0A3<A0A0>>.VerifyA0A1A2GenericStatic<A0A0A3<A0A0>>(); A0A1A2<A0A1A2<A0A0A3<A0A0>>>.VerifyA0A1A2Static(); A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>> v37 = new A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>> v38 = new A0A1A2<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A0A0<A0A0A1>>())); i40.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0A0<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A3<A0A0>>.VerifyA0A0A0A0GenericStatic<A0A0A0A0<A0A0A3<A0A0>>>(); A0A0A0A0<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A0<A0A3>> v41 = new A0A0A0A0<A0A0A0<A0A3>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A0A0A0<A0A0A0<A0A3>> v42 = new A0A0A0A0<A0A0A0<A0A3>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3>(); A0A4<A0A3>.VerifyA0A4NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A4<A0A0A0<A0A3>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0<A0A3>>.VerifyA0A4GenericStatic<A0A0A3<A0A0>>(); A0A4<A0A0>.VerifyA0A4Static(); A0A4<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>> v45 = new A0A4<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A0A1>>>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>(); A0A0A3<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A0A3GenericStatic<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>(); A0A0A3<A0A3>.VerifyA0A0A3Static(); A0A0A3<A0A4<A0A0A1>> v47 = new A0A0A3<A0A4<A0A0A1>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A4<A0A0A1>>(); A0A0A3<A0A0A1> v48 = new A0A0A3<A0A0A1>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A4<A0A0A1>>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0<A0A3>>(); A0A3A4<A0A0A0<A0A3>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A3<A0A0A1>>.VerifyA0A3A4GenericStatic<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>(); A0A3A4<A0A1<A0A3A4<A0A4<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>> v49 = new A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0>(); A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>> v50 = new A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0A0<A0A3>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); A0A0A1A1<A0A0A1>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A1A1<A0A0A1>>.VerifyA0A0A1A1GenericStatic<A0A0A1>(); A0A0A1A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>> v51 = new A0A0A1A1<A0A3A4<A0A1A2<A0A0A0A0<A0A0A1>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A1>(); A0A0A1A1<A0A0A1> v52 = new A0A0A1A1<A0A0A1>(); v52.VerifyA0A0A1A1NotInlined(); } } public interface IA2 { void VerifyInterfaceIA2(); void VerifyInterfaceGenericIA2<K>() where K : new(); } public class A0A1A2<T0> : A0A1<T0>, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1A2NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A1A2NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A1A2GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A1A2Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1A2NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A1A2NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A1A2(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A1 next = new A0A0A1(); next.RecurseA0A0A1((depth - 1)); } public void CreateAllTypesA0A1A2() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A3<A0A3>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A1A2<A0A4<A0A3>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1<A0A0A1>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A1A2<A0A4<A0A3>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A0<A0A0A0<A0A0>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A3A4<A0A1A2<A0A4<A0A3>>>>(); A0A1<A0A0A0<A0A0A0<A0A0>>>.VerifyA0A1NotInlinedGenericStatic<A0A3>(); A0A1<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>.VerifyA0A1GenericStatic<A0A3>(); A0A1<A0A0>.VerifyA0A1Static(); A0A1<A0A0A3<A0A3>> v21 = new A0A1<A0A0A3<A0A3>>(); v21.VerifyA0A1NotInlinedGeneric<A0A3>(); A0A1<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>> v22 = new A0A1<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0A0A0<A0A0>>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A1>())); i24.VerifyInterfaceGenericIA2<A0A1A2<A0A4<A0A3>>>(); A0A0A0<A0A4<A0A0A0<A0A0A0<A0A0>>>>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A1>(); A0A0A0<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1A2<A0A4<A0A3>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A0A0Static(); A0A0A0<A0A0A1> v25 = new A0A0A0<A0A0A1>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A1<A0A0A1>>(); A0A0A0<A0A0> v26 = new A0A0A0<A0A0>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A0<A0A0>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A1>())); i28.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0<A0A0A1>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A1A2<A0A4<A0A3>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A3>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A3A4<A0A1A2<A0A4<A0A3>>>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A3<A0A3>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A0<A0A0A1>>(); A0A1A2<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A1A2NotInlinedGenericStatic<A0A3>(); A0A1A2<A0A0A1>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A1A2<A0A0A1>>.VerifyA0A1A2GenericStatic<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); A0A1A2<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A1A2Static(); A0A1A2<A0A0A0<A0A0A1>> v37 = new A0A1A2<A0A0A0<A0A0A1>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A1>(); A0A1A2<A0A0A3<A0A3>> v38 = new A0A1A2<A0A0A3<A0A3>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A1>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>())); i40.VerifyInterfaceGenericIA2<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A0A0A0<A0A0>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1>(); A0A0A0A0<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A1<A0A0A1>>.VerifyA0A0A0A0GenericStatic<A0A4<A0A0A0<A0A0A0<A0A0>>>>(); A0A0A0A0<A0A0A0A0<A0A1<A0A0A1>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>> v41 = new A0A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>>(); A0A0A0A0<A0A0A3<A0A3>> v42 = new A0A0A0A0<A0A0A3<A0A3>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A3<A0A3>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A3<A0A3>>())); i44.VerifyInterfaceGenericIA2<A0>(); A0A4<A0A3A4<A0A1A2<A0A4<A0A3>>>>.VerifyA0A4NotInlinedGenericStatic<A0A1<A0A0A1>>(); A0A4<A0A0A0<A0A0A1>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A4<A0A0A0<A0A0A1>>>.VerifyA0A4GenericStatic<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0A4<A0A0A1>.VerifyA0A4Static(); A0A4<A0A3> v45 = new A0A4<A0A3>(); v45.VerifyA0A4NotInlinedGeneric<A0A0>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0>.VerifyA0A0A3NotInlinedGenericStatic<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0>.VerifyA0A0A3GenericStatic<A0A0A1>(); A0A0A3<A0A0A0A0<A0A0A3<A0A3>>>.VerifyA0A0A3Static(); A0A0A3<A0A0A1> v47 = new A0A0A3<A0A0A1>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A0A0<A0A0A3<A0A3>>>(); A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>> v48 = new A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A1>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A3A4<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A4<A0A0A1>>.VerifyA0A3A4GenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A3A4<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A3A4Static(); A0A3A4<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>> v49 = new A0A3A4<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0<A0A0A1>>(); A0A3A4<A0A4<A0A0A1>> v50 = new A0A3A4<A0A4<A0A0A1>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0A0<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A0<A0A0A1>>(); A0A0A1A1<A0A1<A0A0A1>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>.VerifyA0A0A1A1GenericStatic<A0A1<A0A0A1>>(); A0A0A1A1<A0A0A0A0<A0A0A3<A0A3>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A1> v51 = new A0A0A1A1<A0A0A1>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A0A0<A0A0A3<A0A3>>>(); A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>> v52 = new A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public interface IA1 : IA2 { void VerifyInterfaceIA1(); void VerifyInterfaceGenericIA1<K>() where K : new(); } public interface IA1A2<T0> : IA2 where T0 : new() { } public class Program { public static int Main(string[] args) { A0 v0 = new A0(); v0.CreateAllTypesA0(); A0A0 v1 = new A0A0(); v1.CreateAllTypesA0A0(); A0A1<A0A1<A0A4<A0A0A1>>> v2 = new A0A1<A0A1<A0A4<A0A0A1>>>(); v2.CreateAllTypesA0A1(); A0A0A0<A0A1A2<A0A3>> v3 = new A0A0A0<A0A1A2<A0A3>>(); v3.CreateAllTypesA0A0A0(); A0A3 v4 = new A0A3(); v4.CreateAllTypesA0A3(); A0A0A1 v5 = new A0A0A1(); v5.CreateAllTypesA0A0A1(); A0A1A2<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>> v6 = new A0A1A2<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>>(); v6.CreateAllTypesA0A1A2(); A0A0A0A0<A0A0> v7 = new A0A0A0A0<A0A0>(); v7.CreateAllTypesA0A0A0A0(); A0A4<A0A0A1> v8 = new A0A4<A0A0A1>(); v8.CreateAllTypesA0A4(); A0A0A3<A0A0A3<A0A0A1>> v9 = new A0A0A3<A0A0A3<A0A0A1>>(); v9.CreateAllTypesA0A0A3(); A0A3A4<A0> v10 = new A0A3A4<A0>(); v10.CreateAllTypesA0A3A4(); A0A0A1A1<A0A0A0<A0A1A2<A0A3>>> v11 = new A0A0A1A1<A0A0A0<A0A1A2<A0A3>>>(); v11.CreateAllTypesA0A0A1A1(); System.Console.WriteLine("Test SUCCESS"); return 100; } } public interface IA2A6<T0> where T0 : new() { } public interface IA1A5<T0> : IA2 where T0 : new() { } public class A0A4<T0> : A0 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A4NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A4NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A4GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A4Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A4NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A4NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A4(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A0A0<A0> next = new A0A0A0A0<A0>(); next.RecurseA0A0A0A0((depth - 1)); } public void CreateAllTypesA0A4() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3A4<A0A3>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A1>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A3<A0A3>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A1A2<A0A1A2<A0A0>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A3<A0A3>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A3A4<A0A3>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A1>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); A0A1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0>(); A0A1<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A1GenericStatic<A0A3>(); A0A1<A0>.VerifyA0A1Static(); A0A1<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>> v21 = new A0A1<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>(); A0A1<A0A3> v22 = new A0A1<A0A3>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A1A2<A0A1A2<A0A0>>>())); i24.VerifyInterfaceGenericIA2<A0A3>(); A0A0A0<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A3<A0A3>>.VerifyA0A0A0GenericStatic<A0A4<A0A0A0<A0A0>>>(); A0A0A0<A0A0A3<A0A3>>.VerifyA0A0A0Static(); A0A0A0<A0A0A3<A0A3>> v25 = new A0A0A0<A0A0A3<A0A3>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A3<A0A3>>(); A0A0A0<A0A0A1> v26 = new A0A0A0<A0A0A1>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>())); i28.VerifyInterfaceGenericIA2<A0A3>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A1<A0A1A2<A0A1A2<A0A0>>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A3<A0A3>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A0A1>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A4<A0A0A0<A0A0>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedGenericStatic<A0A4<A0A0A0<A0A0>>>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3A4<A0A3>>.VerifyA0A1A2GenericStatic<A0A0A1>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>> v37 = new A0A1A2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0>(); A0A1A2<A0A0> v38 = new A0A1A2<A0A0>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0>())); i40.VerifyInterfaceGenericIA2<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); A0A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0>(); A0A0A0A0<A0A1<A0A1A2<A0A1A2<A0A0>>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A1<A0A1A2<A0A1A2<A0A0>>>>.VerifyA0A0A0A0GenericStatic<A0A0A3<A0A3>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>> v41 = new A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0>(); A0A0A0A0<A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>> v42 = new A0A0A0A0<A0A0A0A0<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A1>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0>())); i44.VerifyInterfaceGenericIA2<A0A0>(); A0A4<A0A0A1>.VerifyA0A4NotInlinedGenericStatic<A0A1<A0A1A2<A0A1A2<A0A0>>>>(); A0A4<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A0A0A0<A0A0>>.VerifyA0A4GenericStatic<A0A4<A0A0A0A0<A0A0>>>(); A0A4<A0A0>.VerifyA0A4Static(); A0A4<A0A0A1> v45 = new A0A4<A0A0A1>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A4<A0A3> v46 = new A0A4<A0A3>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A0A0<A0A0>>.VerifyA0A0A3NotInlinedGenericStatic<A0A3>(); A0A0A3<A0A3A4<A0A3>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>.VerifyA0A0A3GenericStatic<A0A1A2<A0A0>>(); A0A0A3<A0A3>.VerifyA0A0A3Static(); A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>> v47 = new A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>(); A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>> v48 = new A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A4<A0A3>>.VerifyA0A3A4NotInlinedGenericStatic<A0A1A2<A0A0>>(); A0A3A4<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A1A1<A0A4<A0A0A0<A0A0>>>>.VerifyA0A3A4GenericStatic<A0A4<A0A3>>(); A0A3A4<A0>.VerifyA0A3A4Static(); A0A3A4<A0A1A2<A0A0>> v49 = new A0A3A4<A0A1A2<A0A0>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0>(); A0A3A4<A0A4<A0A3>> v50 = new A0A3A4<A0A4<A0A3>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0A1A1<A0A0A0A0<A0A0>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A3>.VerifyA0A0A1A1GenericStatic<A0A1A2<A0A0>>(); A0A0A1A1<A0A1A2<A0A0>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A3A4<A0A4<A0A3>>> v51 = new A0A0A1A1<A0A3A4<A0A4<A0A3>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A3>(); A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>> v52 = new A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A0A0<T0> : A0A0A0<T0>, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0A0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0A0NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A0A0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A0A0Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0A0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0A0NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A0A0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A1A2<A0A0A1> next = new A0A1A2<A0A0A1>(); next.RecurseA0A1A2((depth - 1)); } public void CreateAllTypesA0A0A0A0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A0A0<A0A0A3<A0A3>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A0<A0A0A1>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA2>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A1<A0A0A1>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A1<A0A0A1>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A0<A0A0A1>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0>(); A0A1<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); A0A1<A0A0A0<A0A0A1>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0>.VerifyA0A1GenericStatic<A0A0A1>(); A0A1<A0A1<A0A0>>.VerifyA0A1Static(); A0A1<A0A0A0A0<A0A0A3<A0A3>>> v21 = new A0A1<A0A0A0A0<A0A0A3<A0A3>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A1>(); A0A1<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>> v22 = new A0A1<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0A0A1>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>())); i24.VerifyInterfaceGenericIA2<A0A0>(); A0A0A0<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A0<A0A3A4<A0A4<A0A0A1>>>>(); A0A0A0<A0A0A0A0<A0A0A3<A0A3>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A0<A0A0A0A0<A0A0A3<A0A3>>>>.VerifyA0A0A0GenericStatic<A0A4<A0A0A1>>(); A0A0A0<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>.VerifyA0A0A0Static(); A0A0A0<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>> v25 = new A0A0A0<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); A0A0A0<A0A3A4<A0A4<A0A0A1>>> v26 = new A0A0A0<A0A3A4<A0A4<A0A0A1>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0>())); i28.VerifyInterfaceGenericIA2<A0A0>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A3<A0A3>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A1A2<A0A4<A0A0A0<A0A0A0<A0A0>>>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A4<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A3>(); A0A1A2<A0A0A0<A0A0>>.VerifyA0A1A2NotInlinedGenericStatic<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A1A2<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A4<A0A0A1>>.VerifyA0A1A2GenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0> v37 = new A0A1A2<A0>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A1>(); A0A1A2<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>> v38 = new A0A1A2<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A1A2<A0A0>>())); i40.VerifyInterfaceGenericIA2<A0A1A2<A0A1A2<A0A0>>>(); A0A0A0A0<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A0A0A0GenericStatic<A0A0A0<A0A0>>(); A0A0A0A0<A0A0A0A0<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3A4<A0A4<A0A0A1>>> v41 = new A0A0A0A0<A0A3A4<A0A4<A0A0A1>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A4<A0A0A1>>(); A0A0A0A0<A0A0A1> v42 = new A0A0A0A0<A0A0A1>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3A4<A0A4<A0A0A1>>>(); A0A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A4NotInlinedGenericStatic<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); A0A4<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A4GenericStatic<A0A4<A0A1A2<A0A1A2<A0A0>>>>(); A0A4<A0A0A1A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A4Static(); A0A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>> v45 = new A0A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>(); A0A4<A0A0A0<A0A0>> v46 = new A0A4<A0A0A0<A0A0>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A3>>(); A0A0A3<A0A4<A0A0A0<A0A0>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0>.VerifyA0A0A3GenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A0A3<A0A0A1>.VerifyA0A0A3Static(); A0A0A3<A0A0A0<A0A0>> v47 = new A0A0A3<A0A0A0<A0A0>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A1A2<A0A1A2<A0A0>>>(); A0A0A3<A0A3> v48 = new A0A0A3<A0A3>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A4<A0A0A0<A0A0>>>(); A0A3A4<A0A1A2<A0A1A2<A0A0>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A3A4GenericStatic<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>(); A0A3A4<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>> v49 = new A0A3A4<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A1A2<A0A1A2<A0A0>>>(); A0A3A4<A0A3> v50 = new A0A3A4<A0A3>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A0<A0A0>>(); A0A0A1A1<A0A0A0<A0A0>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A1A1<A0A0A0<A0A0>>>.VerifyA0A0A1A1GenericStatic<A0>(); A0A0A1A1<A0A0A1A1<A0A0A1A1<A0A0A0<A0A0>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A0<A0A0>> v51 = new A0A0A1A1<A0A0A0<A0A0>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0>(); A0A0A1A1<A0A4<A0A0A0<A0A0>>> v52 = new A0A0A1A1<A0A4<A0A0A0<A0A0>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A1A1<T0> : A0A0A1 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1A1NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A1A1NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A1A1GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A1A1Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1A1NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A1A1NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A1A1(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A3A4<A0A0A3<A0A0A1>> next = new A0A3A4<A0A0A3<A0A0A1>>(); next.RecurseA0A3A4((depth - 1)); } public void CreateAllTypesA0A0A1A1() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A3>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3>(); A0.VerifyA0NotInlinedGenericStatic<A0A0>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A3>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0>>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A3A4<A0A0>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A3>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A3A4<A0A0>>(); A0A1<A0A3>.VerifyA0A1NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A1<A0A0A0A0<A0A0>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A1>.VerifyA0A1GenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A1<A0A3>.VerifyA0A1Static(); A0A1<A0A0A1A1<A0A1A2<A0A3>>> v21 = new A0A1<A0A0A1A1<A0A1A2<A0A3>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0A0<A0A0>>(); A0A1<A0A0A1A1<A0A1A2<A0A3>>> v22 = new A0A1<A0A0A1A1<A0A1A2<A0A3>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0<A0A3>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A4<A0A0A1>>())); i24.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0>>(); A0A0A0<A0A3>.VerifyA0A0A0NotInlinedGenericStatic<A0>(); A0A0A0<A0>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A1>.VerifyA0A0A0GenericStatic<A0A0A1>(); A0A0A0<A0A1A2<A0A3>>.VerifyA0A0A0Static(); A0A0A0<A0A1<A0A4<A0A0A1>>> v25 = new A0A0A0<A0A1<A0A4<A0A0A1>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0A1A1<A0A1A2<A0A3>>>(); A0A0A0<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>> v26 = new A0A0A0<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A0A0A0<A0A0>>())); i28.VerifyInterfaceGenericIA2<A0A0>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0<A0A0A0A0<A0A0>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0A0<A0A0A0A0<A0A0>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A3>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A1A2<A0A3>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1<A0A4<A0A0A1>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A3>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A1>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A4<A0A0A1>>(); A0A1A2<A0A4<A0A0A1>>.VerifyA0A1A2NotInlinedGenericStatic<A0A0>(); A0A1A2<A0A0A1A1<A0A1A2<A0A3>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A0A1A1<A0A1A2<A0A3>>>.VerifyA0A1A2GenericStatic<A0A4<A0A0A1>>(); A0A1A2<A0A0A1>.VerifyA0A1A2Static(); A0A1A2<A0A1<A0A4<A0A0A1>>> v37 = new A0A1A2<A0A1<A0A4<A0A0A1>>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A4<A0A0A1>>(); A0A1A2<A0A1A2<A0A1<A0A4<A0A0A1>>>> v38 = new A0A1A2<A0A1A2<A0A1<A0A4<A0A0A1>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3>())); i40.VerifyInterfaceGenericIA2<A0A3A4<A0A0>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0GenericStatic<A0A1A2<A0A3>>(); A0A0A0A0<A0A4<A0A0A1>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3> v41 = new A0A0A0A0<A0A3>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A1<A0A4<A0A0A1>>>(); A0A0A0A0<A0A0A0<A0A0A0A0<A0A0>>> v42 = new A0A0A0A0<A0A0A0<A0A0A0A0<A0A0>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0>())); i44.VerifyInterfaceGenericIA2<A0A0A0<A0A0A0A0<A0A0>>>(); A0A4<A0>.VerifyA0A4NotInlinedGenericStatic<A0A0A1>(); A0A4<A0A1<A0A4<A0A0A1>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A4<A0A1<A0A4<A0A0A1>>>>.VerifyA0A4GenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A4<A0A0A1>.VerifyA0A4Static(); A0A4<A0A3> v45 = new A0A4<A0A3>(); v45.VerifyA0A4NotInlinedGeneric<A0A0A0A0<A0A0>>(); A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>> v46 = new A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A0A3<A0A1<A0A4<A0A0A1>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A0>.VerifyA0A0A3GenericStatic<A0>(); A0A0A3<A0A0A3<A0A0>>.VerifyA0A0A3Static(); A0A0A3<A0> v47 = new A0A0A3<A0>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A3>(); A0A0A3<A0A0A1> v48 = new A0A0A3<A0A0A1>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A3A4<A0A0A3<A0A0A1>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>>.VerifyA0A3A4GenericStatic<A0A0A3<A0A0A1>>(); A0A3A4<A0A1A2<A0A3>>.VerifyA0A3A4Static(); A0A3A4<A0A1A2<A0A3>> v49 = new A0A3A4<A0A1A2<A0A3>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A0A0<A0A0>>(); A0A3A4<A0A0A1A1<A0A1A2<A0A3>>> v50 = new A0A3A4<A0A0A1A1<A0A1A2<A0A3>>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1A2<A0A3>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0A1A1<A0A1A2<A0A3>>>(); A0A0A1A1<A0A1<A0A4<A0A0A1>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A3>.VerifyA0A0A1A1GenericStatic<A0A0A0A0<A0A0>>(); A0A0A1A1<A0A0A1A1<A0A3>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>> v51 = new A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A3A4<A0A0A1A1<A0A1A2<A0A3>>>>(); A0A0A1A1<A0A0A0<A0A0A0A0<A0A0>>> v52 = new A0A0A1A1<A0A0A0<A0A0A0A0<A0A0>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A0<T0> : A0A0, IA2 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A0NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A0GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A0Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A0NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A0(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A1<A0A0A0<A0>> next = new A0A1<A0A0A0<A0>>(); next.RecurseA0A1((depth - 1)); } public void CreateAllTypesA0A0A0() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<IA1A5<A0A0A1>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0A0A1>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A1A2<A0A0A3<A0A0A1>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A1<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A3>(); A0A1<A0A0A1>.VerifyA0A1NotInlinedStatic(); A0A1<A0>.VerifyA0A1GenericStatic<A0>(); A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A1Static(); A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>> v21 = new A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A1<A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>> v22 = new A0A1<A0A1<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>())); i24.VerifyInterfaceGenericIA2<A0>(); A0A0A0<A0A4<A0A0>>.VerifyA0A0A0NotInlinedGenericStatic<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>.VerifyA0A0A0GenericStatic<A0A0A0<A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>>(); A0A0A0<A0A0A1>.VerifyA0A0A0Static(); A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v25 = new A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0>(); A0A0A0<A0A0A1> v26 = new A0A0A0<A0A0A1>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>())); i28.VerifyInterfaceGenericIA2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A1A2<A0A0A3<A0A0A1>>>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A1A2<A0A0A3<A0A0A1>>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A4<A0A0>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A1A2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A1A2NotInlinedGenericStatic<A0A3>(); A0A1A2<A0A1A2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3>.VerifyA0A1A2GenericStatic<A0>(); A0A1A2<A0>.VerifyA0A1A2Static(); A0A1A2<A0A1A2<A0>> v37 = new A0A1A2<A0A1A2<A0>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A1A2<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v38 = new A0A1A2<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>())); i40.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A0A0<A0A0>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A0A0GenericStatic<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A0A0<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v41 = new A0A0A0A0<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A1>(); A0A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>> v42 = new A0A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1>())); i44.VerifyInterfaceGenericIA2<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A4<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A4NotInlinedGenericStatic<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A4GenericStatic<A0A0A0A0<A0A0A1>>(); A0A4<A0A4<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>>.VerifyA0A4Static(); A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>> v45 = new A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A4<A0A0A3<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>>(); A0A4<A0A0A1> v46 = new A0A4<A0A0A1>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A0A1>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A3<A0A0A1>>(); A0A0A3<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A3>.VerifyA0A0A3GenericStatic<A0A0A1>(); A0A0A3<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A3Static(); A0A0A3<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>> v47 = new A0A0A3<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>(); A0A0A3<A0A0> v48 = new A0A0A3<A0A0>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3A4<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A3A4NotInlinedGenericStatic<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0A3A4<A0A0A1A1<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A0A0<A0A0A1>>.VerifyA0A3A4GenericStatic<A0A0>(); A0A3A4<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A3A4Static(); A0A3A4<A0A3> v49 = new A0A3A4<A0A3>(); v49.VerifyA0A3A4NotInlinedGeneric<A0>(); A0A3A4<A0A4<A0A0A1>> v50 = new A0A3A4<A0A4<A0A0A1>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A4<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A0A1A1GenericStatic<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A0A1A1<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>> v51 = new A0A0A1A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>> v52 = new A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A3 : A0, IA2 { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A3NotInlinedStatic() { } public static void VerifyA0A3GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T t1 = new T(); } public static void VerifyA0A3Static() { } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A3NotInlined() { System.Console.WriteLine(this); } public void RecurseA0A3(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A0A0<A0A1<A0A0A0<A0>>> next = new A0A0A0<A0A1<A0A0A0<A0>>>(); next.RecurseA0A0A0((depth - 1)); } public void CreateAllTypesA0A3() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0.VerifyA0NotInlinedGenericStatic<A0A0>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A3<A0A0>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A3A4<A0A4<A0A0A1>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A1<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A1>(); A0A1<A0A0>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>.VerifyA0A1GenericStatic<A0A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>>(); A0A1<A0A1<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>>.VerifyA0A1Static(); A0A1<A0A4<A0A0A1>> v21 = new A0A1<A0A4<A0A0A1>>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0<A0A1A2<A0A0A3<A0A0A1>>>>(); A0A1<A0A0> v22 = new A0A1<A0A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0A0<A0A0A1>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0>())); i24.VerifyInterfaceGenericIA2<A0>(); A0A0A0<A0>.VerifyA0A0A0NotInlinedGenericStatic<A0A1<A0>>(); A0A0A0<A0A0>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0>.VerifyA0A0A0Static(); A0A0A0<A0A3A4<A0A4<A0A0A1>>> v25 = new A0A0A0<A0A3A4<A0A4<A0A0A1>>>(); v25.VerifyA0A0A0NotInlinedGeneric<A0>(); A0A0A0<A0> v26 = new A0A0A0<A0>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0>())); i28.VerifyInterfaceGenericIA2<A0A3>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0A0A0A0<A0A0A1>>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A0>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1A2<A0A0A0A0<A0A1<A0A0A0A0<A0A0A1A1<A0A1<A0A3A4<A0A0A3<A0A0A1>>>>>>>>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A0A0<A0A0A1>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A1<A0>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A1A2<A0A0A3<A0A0>>.VerifyA0A1A2NotInlinedGenericStatic<A0A0>(); A0A1A2<A0A0A0A0<A0A0A1>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A1A2GenericStatic<A0A1<A0>>(); A0A1A2<A0A0A0A0<A0A0A1>>.VerifyA0A1A2Static(); A0A1A2<A0> v37 = new A0A1A2<A0>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A3>(); A0A1A2<A0A1A2<A0>> v38 = new A0A1A2<A0A1A2<A0>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A3A4<A0A4<A0A0A1>>>())); i40.VerifyInterfaceGenericIA2<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A0A0A0<A0A0A1>.VerifyA0A0A0A0NotInlinedGenericStatic<A0A0A1>(); A0A0A0A0<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A0<A0>>.VerifyA0A0A0A0GenericStatic<A0A3A4<A0A4<A0A0A1>>>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A0A1> v41 = new A0A0A0A0<A0A0A1>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A3A4<A0A4<A0A0A1>>>(); A0A0A0A0<A0A0> v42 = new A0A0A0A0<A0A0>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A3A4<A0A4<A0A0A1>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A1>())); i44.VerifyInterfaceGenericIA2<A0A0A0A0<A0A0A1>>(); A0A4<A0A0A1>.VerifyA0A4NotInlinedGenericStatic<A0A4<A0A0A1>>(); A0A4<A0A0A0A0<A0A0A1>>.VerifyA0A4NotInlinedStatic(); A0A4<A0A1<A0>>.VerifyA0A4GenericStatic<A0A0>(); A0A4<A0A0A0A0<A0A0A1>>.VerifyA0A4Static(); A0A4<A0A4<A0A0A0A0<A0A0A1>>> v45 = new A0A4<A0A4<A0A0A0A0<A0A0A1>>>(); v45.VerifyA0A4NotInlinedGeneric<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); A0A4<A0A3> v46 = new A0A4<A0A3>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0A3>.VerifyA0A0A3NotInlinedGenericStatic<A0A1<A0>>(); A0A0A3<A0A3A4<A0A4<A0A0A1>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>.VerifyA0A0A3GenericStatic<A0A0A0<A0>>(); A0A0A3<A0A3>.VerifyA0A0A3Static(); A0A0A3<A0A0A3<A0A3>> v47 = new A0A0A3<A0A0A3<A0A3>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A1A1<A0A1<A0A0A0<A0A1A2<A0A0A0A0<A0A0A1>>>>>>(); A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>> v48 = new A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A0A1>.VerifyA0A3A4NotInlinedGenericStatic<A0A0>(); A0A3A4<A0>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A1>.VerifyA0A3A4GenericStatic<A0A3A4<A0A0A1>>(); A0A3A4<A0A1<A0>>.VerifyA0A3A4Static(); A0A3A4<A0A0> v49 = new A0A3A4<A0A0>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A0A3<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>>(); A0A3A4<A0A1<A0>> v50 = new A0A3A4<A0A1<A0>>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A0>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A0>(); A0A0A1A1<A0A3>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A1A2<A0A3A4<A0A4<A0A0A1>>>>.VerifyA0A0A1A1GenericStatic<A0A3A4<A0A1<A0>>>(); A0A0A1A1<A0A4<A0A3>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0> v51 = new A0A0A1A1<A0>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A0A1>(); A0A0A1A1<A0A0A1> v52 = new A0A0A1A1<A0A0A1>(); v52.VerifyA0A0A1A1NotInlined(); } } public class A0A0A3<T0> : A0A0 where T0 : new() { [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A3NotInlinedGenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public static void VerifyA0A0A3NotInlinedStatic() { T0 t0 = new T0(); } public static void VerifyA0A0A3GenericStatic<T>() where T : new() { System.Console.WriteLine(typeof(T)); T0 t1 = new T0(); T t2 = new T(); } public static void VerifyA0A0A3Static() { T0 t0 = new T0(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A3NotInlinedGeneric<T>() where T : new() { System.Console.WriteLine(this); System.Console.WriteLine(typeof(T)); T0 t2 = new T0(); T t3 = new T(); } [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public void VerifyA0A0A3NotInlined() { System.Console.WriteLine(this); T0 t1 = new T0(); } public void RecurseA0A0A3(int depth) { if ((depth < 0)) { return; } System.Console.Write("."); A0A4<A0A0A0<A0A1<A0A0A0<A0>>>> next = new A0A4<A0A0A0<A0A1<A0A0A0<A0>>>>(); next.RecurseA0A4((depth - 1)); } public void CreateAllTypesA0A0A3() { A0 v0 = new A0(); v0.VerifyInterfaceIA1(); A0 v1 = new A0(); v1.VerifyInterfaceGenericIA1<A0A0>(); A0 v2 = new A0(); v2.VerifyInterfaceIA2(); A0 v3 = new A0(); v3.VerifyInterfaceGenericIA2<A0A3>(); A0.VerifyA0NotInlinedGenericStatic<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0.VerifyA0NotInlinedStatic(); A0.VerifyA0GenericStatic<A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>>(); A0.VerifyA0Static(); A0 v4 = new A0(); v4.VerifyA0NotInlinedGeneric<A0A0A1>(); A0 v5 = new A0(); v5.VerifyA0NotInlined(); A0 v6 = new A0(); v6.VirtualVerifyGeneric<A0A3A4<A0A4<A0A3>>>(); A0 v7 = new A0(); v7.VirtualVerify(); A0 v8 = new A0(); v8.DeepRecursion(); IA1 i9 = ((IA1)(new A0())); i9.VerifyInterfaceIA1(); IA1 i10 = ((IA1)(new A0())); i10.VerifyInterfaceGenericIA1<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); IA2 i11 = ((IA2)(new A0())); i11.VerifyInterfaceIA2(); IA2 i12 = ((IA2)(new A0())); i12.VerifyInterfaceGenericIA2<A0>(); A0A0.VerifyA0A0NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0.VerifyA0A0NotInlinedStatic(); A0A0.VerifyA0A0GenericStatic<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A0.VerifyA0A0Static(); A0A0 v13 = new A0A0(); v13.VerifyA0A0NotInlinedGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A0 v14 = new A0A0(); v14.VerifyA0A0NotInlined(); A0A0 v15 = new A0A0(); v15.VirtualVerifyGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A0 v16 = new A0A0(); v16.VirtualVerify(); IA1 i17 = ((IA1)(new A0A0())); i17.VerifyInterfaceIA1(); IA1 i18 = ((IA1)(new A0A0())); i18.VerifyInterfaceGenericIA1<A0>(); IA2 i19 = ((IA2)(new A0A0())); i19.VerifyInterfaceIA2(); IA2 i20 = ((IA2)(new A0A0())); i20.VerifyInterfaceGenericIA2<A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>>(); A0A1<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>.VerifyA0A1NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>.VerifyA0A1NotInlinedStatic(); A0A1<A0A0A0A0<A0A0>>.VerifyA0A1GenericStatic<A0A1<A0A0A0A0<A0A0>>>(); A0A1<A0A1A2<A0A0>>.VerifyA0A1Static(); A0A1<A0A0A1> v21 = new A0A1<A0A0A1>(); v21.VerifyA0A1NotInlinedGeneric<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>(); A0A1<A0> v22 = new A0A1<A0>(); v22.VerifyA0A1NotInlined(); IA2 i23 = ((IA2)(new A0A1<A0A0A0A0<A0A0>>())); i23.VerifyInterfaceIA2(); IA2 i24 = ((IA2)(new A0A1<A0A0A1>())); i24.VerifyInterfaceGenericIA2<A0A3>(); A0A0A0<A0A0A1>.VerifyA0A0A0NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0A0<A0A0A0<A0A0A1>>.VerifyA0A0A0NotInlinedStatic(); A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>.VerifyA0A0A0GenericStatic<A0A3>(); A0A0A0<A0>.VerifyA0A0A0Static(); A0A0A0<A0A0> v25 = new A0A0A0<A0A0>(); v25.VerifyA0A0A0NotInlinedGeneric<A0A0>(); A0A0A0<A0A1<A0A0A1>> v26 = new A0A0A0<A0A1<A0A0A1>>(); v26.VerifyA0A0A0NotInlined(); IA2 i27 = ((IA2)(new A0A0A0<A0A0A1>())); i27.VerifyInterfaceIA2(); IA2 i28 = ((IA2)(new A0A0A0<A0A1A2<A0A0>>())); i28.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A3.VerifyA0A3NotInlinedGenericStatic<A0>(); A0A3.VerifyA0A3NotInlinedStatic(); A0A3.VerifyA0A3GenericStatic<A0A0>(); A0A3.VerifyA0A3Static(); A0A3 v29 = new A0A3(); v29.VerifyA0A3NotInlinedGeneric<A0A4<A0A3>>(); A0A3 v30 = new A0A3(); v30.VerifyA0A3NotInlined(); IA2 i31 = ((IA2)(new A0A3())); i31.VerifyInterfaceIA2(); IA2 i32 = ((IA2)(new A0A3())); i32.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A0A1.VerifyA0A0A1NotInlinedGenericStatic<A0A1<A0A0A1>>(); A0A0A1.VerifyA0A0A1NotInlinedStatic(); A0A0A1.VerifyA0A0A1GenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A0A1.VerifyA0A0A1Static(); A0A0A1 v33 = new A0A0A1(); v33.VerifyA0A0A1NotInlinedGeneric<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A0A1 v34 = new A0A0A1(); v34.VerifyA0A0A1NotInlined(); IA2 i35 = ((IA2)(new A0A0A1())); i35.VerifyInterfaceIA2(); IA2 i36 = ((IA2)(new A0A0A1())); i36.VerifyInterfaceGenericIA2<A0A0A1>(); A0A1A2<A0>.VerifyA0A1A2NotInlinedGenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1A2<A0A0A0<A0A1A2<A0A0>>>.VerifyA0A1A2NotInlinedStatic(); A0A1A2<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A1A2GenericStatic<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1A2<A0A3A4<A0A4<A0A3>>>.VerifyA0A1A2Static(); A0A1A2<A0A4<A0A3>> v37 = new A0A1A2<A0A4<A0A3>>(); v37.VerifyA0A1A2NotInlinedGeneric<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); A0A1A2<A0A4<A0A3>> v38 = new A0A1A2<A0A4<A0A3>>(); v38.VerifyA0A1A2NotInlined(); IA2 i39 = ((IA2)(new A0A1A2<A0A3A4<A0A4<A0A3>>>())); i39.VerifyInterfaceIA2(); IA2 i40 = ((IA2)(new A0A1A2<A0A0A0<A0A1A2<A0A0>>>())); i40.VerifyInterfaceGenericIA2<A0A4<A0A3>>(); A0A0A0A0<A0A0A1>.VerifyA0A0A0A0NotInlinedGenericStatic<A0>(); A0A0A0A0<A0A3>.VerifyA0A0A0A0NotInlinedStatic(); A0A0A0A0<A0A0A1>.VerifyA0A0A0A0GenericStatic<A0A4<A0A3>>(); A0A0A0A0<A0>.VerifyA0A0A0A0Static(); A0A0A0A0<A0A3A4<A0A4<A0A3>>> v41 = new A0A0A0A0<A0A3A4<A0A4<A0A3>>>(); v41.VerifyA0A0A0A0NotInlinedGeneric<A0A0A0<A0A1A2<A0A0>>>(); A0A0A0A0<A0A0> v42 = new A0A0A0A0<A0A0>(); v42.VerifyA0A0A0A0NotInlined(); IA2 i43 = ((IA2)(new A0A0A0A0<A0A3A4<A0A4<A0A3>>>())); i43.VerifyInterfaceIA2(); IA2 i44 = ((IA2)(new A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>())); i44.VerifyInterfaceGenericIA2<A0A3A4<A0A4<A0A3>>>(); A0A4<A0A0A0<A0A1A2<A0A0>>>.VerifyA0A4NotInlinedGenericStatic<A0>(); A0A4<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>.VerifyA0A4NotInlinedStatic(); A0A4<A0>.VerifyA0A4GenericStatic<A0A3A4<A0A4<A0A3>>>(); A0A4<A0A4<A0>>.VerifyA0A4Static(); A0A4<A0> v45 = new A0A4<A0>(); v45.VerifyA0A4NotInlinedGeneric<A0A4<A0>>(); A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>> v46 = new A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>(); v46.VerifyA0A4NotInlined(); A0A0A3<A0>.VerifyA0A0A3NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A0A3<A0A0A0A0<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>.VerifyA0A0A3NotInlinedStatic(); A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A0A3GenericStatic<A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>>(); A0A0A3<A0A0A1A1<A0A1<A0A1A2<A0A1A2<A0A0>>>>>.VerifyA0A0A3Static(); A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>> v47 = new A0A0A3<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>(); v47.VerifyA0A0A3NotInlinedGeneric<A0A0A0<A0A1A2<A0A0>>>(); A0A0A3<A0A0A0<A0A1A2<A0A0>>> v48 = new A0A0A3<A0A0A0<A0A1A2<A0A0>>>(); v48.VerifyA0A0A3NotInlined(); A0A3A4<A0A3>.VerifyA0A3A4NotInlinedGenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A3A4<A0A0>.VerifyA0A3A4NotInlinedStatic(); A0A3A4<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A3A4GenericStatic<A0A0A0<A0A1A2<A0A0>>>(); A0A3A4<A0>.VerifyA0A3A4Static(); A0A3A4<A0A0A3<A0A0A0<A0A1A2<A0A0>>>> v49 = new A0A3A4<A0A0A3<A0A0A0<A0A1A2<A0A0>>>>(); v49.VerifyA0A3A4NotInlinedGeneric<A0A1<A0A0A1>>(); A0A3A4<A0> v50 = new A0A3A4<A0>(); v50.VerifyA0A3A4NotInlined(); A0A0A1A1<A0A1<A0A0A1>>.VerifyA0A0A1A1NotInlinedGenericStatic<A0A3>(); A0A0A1A1<A0A1A2<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A0A1A1NotInlinedStatic(); A0A0A1A1<A0A0A0<A0A1A2<A0A0>>>.VerifyA0A0A1A1GenericStatic<A0A0>(); A0A0A1A1<A0A0A1A1<A0A0A0<A0A1A2<A0A0>>>>.VerifyA0A0A1A1Static(); A0A0A1A1<A0A3> v51 = new A0A0A1A1<A0A3>(); v51.VerifyA0A0A1A1NotInlinedGeneric<A0A1<A0A0A1>>(); A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>> v52 = new A0A0A1A1<A0A4<A0A0A3<A0A0A3<A0A0A0<A0A0A0A0<A0A1<A0A0A3<A0A0A1A1<A0A0A0A0<A0A3A4<A0A1<A0>>>>>>>>>>>>(); v52.VerifyA0A0A1A1NotInlined(); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; namespace System { internal static partial class SpanHelpers // .Char { public static int IndexOf(ref char searchSpace, int searchSpaceLength, ref char value, int valueLength) { Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); if (valueLength == 0) return 0; // A zero-length sequence is always treated as "found" at the start of the search space. int valueTailLength = valueLength - 1; if (valueTailLength == 0) { // for single-char values use plain IndexOf return IndexOf(ref searchSpace, value, searchSpaceLength); } nint offset = 0; char valueHead = value; int searchSpaceMinusValueTailLength = searchSpaceLength - valueTailLength; if (Vector128.IsHardwareAccelerated && searchSpaceMinusValueTailLength >= Vector128<ushort>.Count) { goto SEARCH_TWO_CHARS; } ref byte valueTail = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref value, 1)); int remainingSearchSpaceLength = searchSpaceMinusValueTailLength; while (remainingSearchSpaceLength > 0) { // Do a quick search for the first element of "value". int relativeIndex = IndexOf(ref Unsafe.Add(ref searchSpace, offset), valueHead, remainingSearchSpaceLength); if (relativeIndex < 0) break; remainingSearchSpaceLength -= relativeIndex; offset += relativeIndex; if (remainingSearchSpaceLength <= 0) break; // The unsearched portion is now shorter than the sequence we're looking for. So it can't be there. // Found the first element of "value". See if the tail matches. if (SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + 1)), ref valueTail, (nuint)(uint)valueTailLength * 2)) { return (int)offset; // The tail matched. Return a successful find. } remainingSearchSpaceLength--; offset++; } return -1; // Based on http://0x80.pl/articles/simd-strfind.html#algorithm-1-generic-simd "Algorithm 1: Generic SIMD" by Wojciech Muła // Some details about the implementation can also be found in https://github.com/dotnet/runtime/pull/63285 SEARCH_TWO_CHARS: if (Vector256.IsHardwareAccelerated && searchSpaceMinusValueTailLength - Vector256<ushort>.Count >= 0) { // Find the last unique (which is not equal to ch1) character // the algorithm is fine if both are equal, just a little bit less efficient ushort ch2Val = Unsafe.Add(ref value, valueTailLength); nint ch1ch2Distance = valueTailLength; while (ch2Val == valueHead && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector256<ushort> ch1 = Vector256.Create((ushort)valueHead); Vector256<ushort> ch2 = Vector256.Create(ch2Val); nint searchSpaceMinusValueTailLengthAndVector = searchSpaceMinusValueTailLength - (nint)Vector256<ushort>.Count; do { // Make sure we don't go out of bounds Debug.Assert(offset + ch1ch2Distance + Vector256<ushort>.Count <= searchSpaceLength); Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, LoadVector256(ref searchSpace, offset + ch1ch2Distance)); Vector256<ushort> cmpCh1 = Vector256.Equals(ch1, LoadVector256(ref searchSpace, offset)); Vector256<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros if (cmpAnd != Vector256<byte>.Zero) { goto CANDIDATE_FOUND; } LOOP_FOOTER: offset += Vector256<ushort>.Count; if (offset == searchSpaceMinusValueTailLength) return -1; // Overlap with the current chunk for trailing elements if (offset > searchSpaceMinusValueTailLengthAndVector) offset = searchSpaceMinusValueTailLengthAndVector; continue; CANDIDATE_FOUND: uint mask = cmpAnd.ExtractMostSignificantBits(); do { int bitPos = BitOperations.TrailingZeroCount(mask); // div by 2 (shr) because we work with 2-byte chars nint charPos = (nint)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return (int)(offset + charPos); } // Clear two the lowest set bits if (Bmi1.IsSupported) mask = Bmi1.ResetLowestSetBit(Bmi1.ResetLowestSetBit(mask)); else mask &= ~(uint)(0b11 << bitPos); } while (mask != 0); goto LOOP_FOOTER; } while (true); } else // 128bit vector path (SSE2 or AdvSimd) { // Find the last unique (which is not equal to ch1) character // the algorithm is fine if both are equal, just a little bit less efficient ushort ch2Val = Unsafe.Add(ref value, valueTailLength); nint ch1ch2Distance = valueTailLength; while (ch2Val == valueHead && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector128<ushort> ch1 = Vector128.Create((ushort)valueHead); Vector128<ushort> ch2 = Vector128.Create(ch2Val); nint searchSpaceMinusValueTailLengthAndVector = searchSpaceMinusValueTailLength - (nint)Vector128<ushort>.Count; do { // Make sure we don't go out of bounds Debug.Assert(offset + ch1ch2Distance + Vector128<ushort>.Count <= searchSpaceLength); Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, LoadVector128(ref searchSpace, offset + ch1ch2Distance)); Vector128<ushort> cmpCh1 = Vector128.Equals(ch1, LoadVector128(ref searchSpace, offset)); Vector128<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros if (cmpAnd != Vector128<byte>.Zero) { goto CANDIDATE_FOUND; } LOOP_FOOTER: offset += Vector128<ushort>.Count; if (offset == searchSpaceMinusValueTailLength) return -1; // Overlap with the current chunk for trailing elements if (offset > searchSpaceMinusValueTailLengthAndVector) offset = searchSpaceMinusValueTailLengthAndVector; continue; CANDIDATE_FOUND: uint mask = cmpAnd.ExtractMostSignificantBits(); do { int bitPos = BitOperations.TrailingZeroCount(mask); // div by 2 (shr) because we work with 2-byte chars int charPos = (int)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return (int)(offset + charPos); } // Clear two lowest set bits if (Bmi1.IsSupported) mask = Bmi1.ResetLowestSetBit(Bmi1.ResetLowestSetBit(mask)); else mask &= ~(uint)(0b11 << bitPos); } while (mask != 0); goto LOOP_FOOTER; } while (true); } } public static int LastIndexOf(ref char searchSpace, int searchSpaceLength, ref char value, int valueLength) { Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); if (valueLength == 0) return searchSpaceLength; // A zero-length sequence is always treated as "found" at the end of the search space. int valueTailLength = valueLength - 1; if (valueTailLength == 0) return LastIndexOf(ref searchSpace, value, searchSpaceLength); // for single-char values use plain LastIndexOf int offset = 0; char valueHead = value; int searchSpaceMinusValueTailLength = searchSpaceLength - valueTailLength; if (Vector128.IsHardwareAccelerated && searchSpaceMinusValueTailLength >= Vector128<ushort>.Count) { goto SEARCH_TWO_CHARS; } ref byte valueTail = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref value, 1)); while (true) { Debug.Assert(0 <= offset && offset <= searchSpaceLength); // Ensures no deceptive underflows in the computation of "remainingSearchSpaceLength". int remainingSearchSpaceLength = searchSpaceLength - offset - valueTailLength; if (remainingSearchSpaceLength <= 0) break; // The unsearched portion is now shorter than the sequence we're looking for. So it can't be there. // Do a quick search for the first element of "value". int relativeIndex = LastIndexOf(ref searchSpace, valueHead, remainingSearchSpaceLength); if (relativeIndex == -1) break; // Found the first element of "value". See if the tail matches. if (SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, relativeIndex + 1)), ref valueTail, (nuint)(uint)valueTailLength * 2)) { return relativeIndex; // The tail matched. Return a successful find. } offset += remainingSearchSpaceLength - relativeIndex; } return -1; // Based on http://0x80.pl/articles/simd-strfind.html#algorithm-1-generic-simd "Algorithm 1: Generic SIMD" by Wojciech Muła // Some details about the implementation can also be found in https://github.com/dotnet/runtime/pull/63285 SEARCH_TWO_CHARS: if (Vector256.IsHardwareAccelerated && searchSpaceMinusValueTailLength >= Vector256<ushort>.Count) { offset = searchSpaceMinusValueTailLength - Vector256<ushort>.Count; // Find the last unique (which is not equal to ch1) char // the algorithm is fine if both are equal, just a little bit less efficient char ch2Val = Unsafe.Add(ref value, valueTailLength); int ch1ch2Distance = valueTailLength; while (ch2Val == valueHead && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector256<ushort> ch1 = Vector256.Create((ushort)valueHead); Vector256<ushort> ch2 = Vector256.Create((ushort)ch2Val); do { Vector256<ushort> cmpCh1 = Vector256.Equals(ch1, LoadVector256(ref searchSpace, (nuint)offset)); Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, LoadVector256(ref searchSpace, (nuint)(offset + ch1ch2Distance))); Vector256<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros if (cmpAnd != Vector256<byte>.Zero) { uint mask = cmpAnd.ExtractMostSignificantBits(); do { // unlike IndexOf, here we use LZCNT to process matches starting from the end int bitPos = 30 - BitOperations.LeadingZeroCount(mask); int charPos = (int)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return charPos + offset; } mask &= ~(uint)(0b11 << bitPos); // clear two highest set bits. } while (mask != 0); } offset -= Vector256<ushort>.Count; if (offset == -Vector256<ushort>.Count) return -1; // Overlap with the current chunk if there is not enough room for the next one if (offset < 0) offset = 0; } while (true); } else // 128bit vector path (SSE2 or AdvSimd) { offset = searchSpaceMinusValueTailLength - Vector128<ushort>.Count; // Find the last unique (which is not equal to ch1) char // the algorithm is fine if both are equal, just a little bit less efficient char ch2Val = Unsafe.Add(ref value, valueTailLength); int ch1ch2Distance = valueTailLength; while (ch2Val == value && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector128<ushort> ch1 = Vector128.Create((ushort)value); Vector128<ushort> ch2 = Vector128.Create((ushort)ch2Val); do { Vector128<ushort> cmpCh1 = Vector128.Equals(ch1, LoadVector128(ref searchSpace, (nuint)offset)); Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, LoadVector128(ref searchSpace, (nuint)(offset + ch1ch2Distance))); Vector128<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros // it's especially important for ARM where ExtractMostSignificantBits is not cheap if (cmpAnd != Vector128<byte>.Zero) { uint mask = cmpAnd.ExtractMostSignificantBits(); do { // unlike IndexOf, here we use LZCNT to process matches starting from the end int bitPos = 30 - BitOperations.LeadingZeroCount(mask); int charPos = (int)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return charPos + offset; } mask &= ~(uint)(0b11 << bitPos); // clear two the highest set bits. } while (mask != 0); } offset -= Vector128<ushort>.Count; if (offset == -Vector128<ushort>.Count) return -1; // Overlap with the current chunk if there is not enough room for the next one if (offset < 0) offset = 0; } while (true); } } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength) { Debug.Assert(firstLength >= 0); Debug.Assert(secondLength >= 0); int lengthDelta = firstLength - secondLength; if (Unsafe.AreSame(ref first, ref second)) goto Equal; nuint minLength = (nuint)(((uint)firstLength < (uint)secondLength) ? (uint)firstLength : (uint)secondLength); nuint i = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations if (minLength >= (nuint)(sizeof(nuint) / sizeof(char))) { if (Vector.IsHardwareAccelerated && minLength >= (nuint)Vector<ushort>.Count) { nuint nLength = minLength - (nuint)Vector<ushort>.Count; do { if (Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) != Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) { break; } i += (nuint)Vector<ushort>.Count; } while (nLength >= i); } while (minLength >= (i + (nuint)(sizeof(nuint) / sizeof(char)))) { if (Unsafe.ReadUnaligned<nuint> (ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) != Unsafe.ReadUnaligned<nuint>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) { break; } i += (nuint)(sizeof(nuint) / sizeof(char)); } } #if TARGET_64BIT if (minLength >= (i + sizeof(int) / sizeof(char))) { if (Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) == Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) { i += sizeof(int) / sizeof(char); } } #endif while (i < minLength) { int result = Unsafe.Add(ref first, (nint)i).CompareTo(Unsafe.Add(ref second, (nint)i)); if (result != 0) return result; i += 1; } Equal: return lengthDelta; } // Adapted from IndexOf(...) [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe bool Contains(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); fixed (char* pChars = &searchSpace) { char* pCh = pChars; char* pEndCh = pCh + length; if (Vector.IsHardwareAccelerated && length >= Vector<ushort>.Count * 2) { // Figure out how many characters to read sequentially until we are vector aligned // This is equivalent to: // unaligned = ((int)pCh % Unsafe.SizeOf<Vector<ushort>>()) / elementsPerByte // length = (Vector<ushort>.Count - unaligned) % Vector<ushort>.Count const int elementsPerByte = sizeof(ushort) / sizeof(byte); int unaligned = ((int)pCh & (Unsafe.SizeOf<Vector<ushort>>() - 1)) / elementsPerByte; length = (Vector<ushort>.Count - unaligned) & (Vector<ushort>.Count - 1); } SequentialScan: while (length >= 4) { length -= 4; if (value == *pCh || value == *(pCh + 1) || value == *(pCh + 2) || value == *(pCh + 3)) { goto Found; } pCh += 4; } while (length > 0) { length--; if (value == *pCh) goto Found; pCh++; } // We get past SequentialScan only if IsHardwareAccelerated is true. However, we still have the redundant check to allow // the JIT to see that the code is unreachable and eliminate it when the platform does not have hardware accelerated. if (Vector.IsHardwareAccelerated && pCh < pEndCh) { // Get the highest multiple of Vector<ushort>.Count that is within the search space. // That will be how many times we iterate in the loop below. // This is equivalent to: length = Vector<ushort>.Count * ((int)(pEndCh - pCh) / Vector<ushort>.Count) length = (int)((pEndCh - pCh) & ~(Vector<ushort>.Count - 1)); // Get comparison Vector Vector<ushort> vComparison = new Vector<ushort>(value); while (length > 0) { // Using Unsafe.Read instead of ReadUnaligned since the search space is pinned and pCh is always vector aligned Debug.Assert(((int)pCh & (Unsafe.SizeOf<Vector<ushort>>() - 1)) == 0); Vector<ushort> vMatches = Vector.Equals(vComparison, Unsafe.Read<Vector<ushort>>(pCh)); if (Vector<ushort>.Zero.Equals(vMatches)) { pCh += Vector<ushort>.Count; length -= Vector<ushort>.Count; continue; } goto Found; } if (pCh < pEndCh) { length = (int)(pEndCh - pCh); goto SequentialScan; } } return false; Found: return true; } } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOf(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); nint offset = 0; nint lengthToExamine = length; if (((int)Unsafe.AsPointer(ref searchSpace) & 1) != 0) { // Input isn't char aligned, we won't be able to align it to a Vector } else if (Sse2.IsSupported || AdvSimd.Arm64.IsSupported) { // Avx2 branch also operates on Sse2 sizes, so check is combined. // Needs to be double length to allow us to align the data first. if (length >= Vector128<ushort>.Count * 2) { lengthToExamine = UnalignedCountVector128(ref searchSpace); } } else if (Vector.IsHardwareAccelerated) { // Needs to be double length to allow us to align the data first. if (length >= Vector<ushort>.Count * 2) { lengthToExamine = UnalignedCountVector(ref searchSpace); } } SequentialScan: // In the non-vector case lengthToExamine is the total length. // In the vector case lengthToExamine first aligns to Vector, // then in a second pass after the Vector lengths is the // remaining data that is shorter than a Vector length. while (lengthToExamine >= 4) { ref char current = ref Unsafe.Add(ref searchSpace, offset); if (value == current) goto Found; if (value == Unsafe.Add(ref current, 1)) goto Found1; if (value == Unsafe.Add(ref current, 2)) goto Found2; if (value == Unsafe.Add(ref current, 3)) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { if (value == Unsafe.Add(ref searchSpace, offset)) goto Found; offset++; lengthToExamine--; } // We get past SequentialScan only if IsHardwareAccelerated or intrinsic .IsSupported is true. However, we still have the redundant check to allow // the JIT to see that the code is unreachable and eliminate it when the platform does not have hardware accelerated. if (Avx2.IsSupported) { if (offset < length) { Debug.Assert(length - offset >= Vector128<ushort>.Count); if (((nint)Unsafe.AsPointer(ref Unsafe.Add(ref searchSpace, (nint)offset)) & (nint)(Vector256<byte>.Count - 1)) != 0) { // Not currently aligned to Vector256 (is aligned to Vector128); this can cause a problem for searches // with no upper bound e.g. String.wcslen. Start with a check on Vector128 to align to Vector256, // before moving to processing Vector256. // If the input searchSpan has been fixed or pinned, this ensures we do not fault across memory pages // while searching for an end of string. Specifically that this assumes that the length is either correct // or that the data is pinned otherwise it may cause an AccessViolation from crossing a page boundary into an // unowned page. If the search is unbounded (e.g. null terminator in wcslen) and the search value is not found, // again this will likely cause an AccessViolation. However, correctly bounded searches will return -1 rather // than ever causing an AV. // If the searchSpan has not been fixed or pinned the GC can relocate it during the execution of this // method, so the alignment only acts as best endeavour. The GC cost is likely to dominate over // the misalignment that may occur after; to we default to giving the GC a free hand to relocate and // its up to the caller whether they are operating over fixed data. Vector128<ushort> values = Vector128.Create((ushort)value); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); // Same method as below int matches = Sse2.MoveMask(Sse2.CompareEqual(values, search).AsByte()); if (matches == 0) { // Zero flags set so no matches offset += Vector128<ushort>.Count; } else { // Find bitflag offset of first match and add to current offset return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } } lengthToExamine = GetCharVector256SpanLength(offset, length); if (lengthToExamine > 0) { Vector256<ushort> values = Vector256.Create((ushort)value); do { Debug.Assert(lengthToExamine >= Vector256<ushort>.Count); Vector256<ushort> search = LoadVector256(ref searchSpace, offset); int matches = Avx2.MoveMask(Avx2.CompareEqual(values, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // Zero flags set so no matches offset += Vector256<ushort>.Count; lengthToExamine -= Vector256<ushort>.Count; continue; } // Find bitflag offset of first match and add to current offset, // flags are in bytes so divide for chars return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } while (lengthToExamine > 0); } lengthToExamine = GetCharVector128SpanLength(offset, length); if (lengthToExamine > 0) { Debug.Assert(lengthToExamine >= Vector128<ushort>.Count); Vector128<ushort> values = Vector128.Create((ushort)value); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); // Same method as above int matches = Sse2.MoveMask(Sse2.CompareEqual(values, search).AsByte()); if (matches == 0) { // Zero flags set so no matches offset += Vector128<ushort>.Count; // Don't need to change lengthToExamine here as we don't use its current value again. } else { // Find bitflag offset of first match and add to current offset, // flags are in bytes so divide for chars return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } else if (Sse2.IsSupported) { if (offset < length) { Debug.Assert(length - offset >= Vector128<ushort>.Count); lengthToExamine = GetCharVector128SpanLength(offset, length); if (lengthToExamine > 0) { Vector128<ushort> values = Vector128.Create((ushort)value); do { Debug.Assert(lengthToExamine >= Vector128<ushort>.Count); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); // Same method as above int matches = Sse2.MoveMask(Sse2.CompareEqual(values, search).AsByte()); if (matches == 0) { // Zero flags set so no matches offset += Vector128<ushort>.Count; lengthToExamine -= Vector128<ushort>.Count; continue; } // Find bitflag offset of first match and add to current offset, // flags are in bytes so divide for chars return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } while (lengthToExamine > 0); } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } else if (AdvSimd.Arm64.IsSupported) { if (offset < length) { Debug.Assert(length - offset >= Vector128<ushort>.Count); lengthToExamine = GetCharVector128SpanLength(offset, length); if (lengthToExamine > 0) { Vector128<ushort> values = Vector128.Create((ushort)value); int matchedLane = 0; do { Debug.Assert(lengthToExamine >= Vector128<ushort>.Count); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); Vector128<ushort> compareResult = AdvSimd.CompareEqual(values, search); if (!TryFindFirstMatchedLane(compareResult, ref matchedLane)) { // Zero flags set so no matches offset += Vector128<ushort>.Count; lengthToExamine -= Vector128<ushort>.Count; continue; } return (int)(offset + matchedLane); } while (lengthToExamine > 0); } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } else if (Vector.IsHardwareAccelerated) { if (offset < length) { Debug.Assert(length - offset >= Vector<ushort>.Count); lengthToExamine = GetCharVectorSpanLength(offset, length); if (lengthToExamine > 0) { Vector<ushort> values = new Vector<ushort>((ushort)value); do { Debug.Assert(lengthToExamine >= Vector<ushort>.Count); var matches = Vector.Equals(values, LoadVector(ref searchSpace, offset)); if (Vector<ushort>.Zero.Equals(matches)) { offset += Vector<ushort>.Count; lengthToExamine -= Vector<ushort>.Count; continue; } // Find offset of first match return (int)(offset + LocateFirstFoundChar(matches)); } while (lengthToExamine > 0); } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)(offset); } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // Bitwise Or to combine the flagged matches for the second value to our match flags matches = Avx2.MoveMask( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, char value2, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); Vector256<ushort> values2 = Vector256.Create((ushort)value2); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // Bitwise Or to combine the flagged matches for the second value to our match flags matches = Avx2.MoveMask( Avx2.Or( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)), Avx2.CompareEqual(values2, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask( Avx2.Or( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)), Avx2.CompareEqual(values2, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); Vector128<ushort> values2 = Vector128.Create((ushort)value2); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask( Sse2.Or( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)), Sse2.CompareEqual(values2, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask( Sse2.Or( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)), Sse2.CompareEqual(values2, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> values2 = new Vector<ushort>(value2); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); Vector256<ushort> values2 = Vector256.Create((ushort)value2); Vector256<ushort> values3 = Vector256.Create((ushort)value3); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // We preform the Or at non-Vector level as we are using the maximum number of non-preserved registers, // and more causes them first to be pushed to stack and then popped on exit to preseve their values. matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); Vector128<ushort> values2 = Vector128.Create((ushort)value2); Vector128<ushort> values3 = Vector128.Create((ushort)value3); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> values2 = new Vector<ushort>(value2); Vector<ushort> values3 = new Vector<ushort>(value3); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, char value4, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); Vector256<ushort> values2 = Vector256.Create((ushort)value2); Vector256<ushort> values3 = Vector256.Create((ushort)value3); Vector256<ushort> values4 = Vector256.Create((ushort)value4); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // We preform the Or at non-Vector level as we are using the maximum number of non-preserved registers (+ 1), // and more causes them first to be pushed to stack and then popped on exit to preseve their values. matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values4, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values4, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); Vector128<ushort> values2 = Vector128.Create((ushort)value2); Vector128<ushort> values3 = Vector128.Create((ushort)value3); Vector128<ushort> values4 = Vector128.Create((ushort)value4); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values4, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values4, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> values2 = new Vector<ushort>(value2); Vector<ushort> values3 = new Vector<ushort>(value3); Vector<ushort> values4 = new Vector<ushort>(value4); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)), Vector.Equals(search, values4)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)), Vector.Equals(search, values4)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int LastIndexOf(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); fixed (char* pChars = &searchSpace) { char* pCh = pChars + length; char* pEndCh = pChars; if (Vector.IsHardwareAccelerated && length >= Vector<ushort>.Count * 2) { // Figure out how many characters to read sequentially from the end until we are vector aligned // This is equivalent to: length = ((int)pCh % Unsafe.SizeOf<Vector<ushort>>()) / elementsPerByte const int elementsPerByte = sizeof(ushort) / sizeof(byte); length = ((int)pCh & (Unsafe.SizeOf<Vector<ushort>>() - 1)) / elementsPerByte; } SequentialScan: while (length >= 4) { length -= 4; pCh -= 4; if (*(pCh + 3) == value) goto Found3; if (*(pCh + 2) == value) goto Found2; if (*(pCh + 1) == value) goto Found1; if (*pCh == value) goto Found; } while (length > 0) { length--; pCh--; if (*pCh == value) goto Found; } // We get past SequentialScan only if IsHardwareAccelerated is true. However, we still have the redundant check to allow // the JIT to see that the code is unreachable and eliminate it when the platform does not have hardware accelerated. if (Vector.IsHardwareAccelerated && pCh > pEndCh) { // Get the highest multiple of Vector<ushort>.Count that is within the search space. // That will be how many times we iterate in the loop below. // This is equivalent to: length = Vector<ushort>.Count * ((int)(pCh - pEndCh) / Vector<ushort>.Count) length = (int)((pCh - pEndCh) & ~(Vector<ushort>.Count - 1)); // Get comparison Vector Vector<ushort> vComparison = new Vector<ushort>(value); while (length > 0) { char* pStart = pCh - Vector<ushort>.Count; // Using Unsafe.Read instead of ReadUnaligned since the search space is pinned and pCh (and hence pSart) is always vector aligned Debug.Assert(((int)pStart & (Unsafe.SizeOf<Vector<ushort>>() - 1)) == 0); Vector<ushort> vMatches = Vector.Equals(vComparison, Unsafe.Read<Vector<ushort>>(pStart)); if (Vector<ushort>.Zero.Equals(vMatches)) { pCh -= Vector<ushort>.Count; length -= Vector<ushort>.Count; continue; } // Find offset of last match return (int)(pStart - pEndCh) + LocateLastFoundChar(vMatches); } if (pCh > pEndCh) { length = (int)(pCh - pEndCh); goto SequentialScan; } } return -1; Found: return (int)(pCh - pEndCh); Found1: return (int)(pCh - pEndCh) + 1; Found2: return (int)(pCh - pEndCh) + 2; Found3: return (int)(pCh - pEndCh) + 3; } } // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundChar(Vector<ushort> match) { var vector64 = Vector.AsVectorUInt64(match); ulong candidate = 0; int i = 0; // Pattern unrolled by jit https://github.com/dotnet/coreclr/pull/8001 for (; i < Vector<ulong>.Count; i++) { candidate = vector64[i]; if (candidate != 0) { break; } } // Single LEA instruction with jitted const (using function result) return i * 4 + LocateFirstFoundChar(candidate); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundChar(ulong match) => BitOperations.TrailingZeroCount(match) >> 4; // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundChar(Vector<ushort> match) { var vector64 = Vector.AsVectorUInt64(match); ulong candidate = 0; int i = Vector<ulong>.Count - 1; // This pattern is only unrolled by the Jit if the limit is Vector<T>.Count // As such, we need a dummy iteration variable for that condition to be satisfied for (int j = 0; j < Vector<ulong>.Count; j++) { candidate = vector64[i]; if (candidate != 0) { break; } i--; } // Single LEA instruction with jitted const (using function result) return i * 4 + LocateLastFoundChar(candidate); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundChar(ulong match) => BitOperations.Log2(match) >> 4; [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector<ushort> LoadVector(ref char start, nint offset) => Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector<ushort> LoadVector(ref char start, nuint offset) => Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128<ushort> LoadVector128(ref char start, nint offset) => Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128<ushort> LoadVector128(ref char start, nuint offset) => Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256<ushort> LoadVector256(ref char start, nint offset) => Unsafe.ReadUnaligned<Vector256<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256<ushort> LoadVector256(ref char start, nuint offset) => Unsafe.ReadUnaligned<Vector256<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ref char Add(ref char start, nuint offset) => ref Unsafe.Add(ref start, (nint)offset); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static nint GetCharVectorSpanLength(nint offset, nint length) => (length - offset) & ~(Vector<ushort>.Count - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static nint GetCharVector128SpanLength(nint offset, nint length) => (length - offset) & ~(Vector128<ushort>.Count - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static nint GetCharVector256SpanLength(nint offset, nint length) => (length - offset) & ~(Vector256<ushort>.Count - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static unsafe nint UnalignedCountVector(ref char searchSpace) { const int ElementsPerByte = sizeof(ushort) / sizeof(byte); // Figure out how many characters to read sequentially until we are vector aligned // This is equivalent to: // unaligned = ((int)pCh % Unsafe.SizeOf<Vector<ushort>>()) / ElementsPerByte // length = (Vector<ushort>.Count - unaligned) % Vector<ushort>.Count // This alignment is only valid if the GC does not relocate; so we use ReadUnaligned to get the data. // If a GC does occur and alignment is lost, the GC cost will outweigh any gains from alignment so it // isn't too important to pin to maintain the alignment. return (nint)(uint)(-(int)Unsafe.AsPointer(ref searchSpace) / ElementsPerByte) & (Vector<ushort>.Count - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static unsafe nint UnalignedCountVector128(ref char searchSpace) { const int ElementsPerByte = sizeof(ushort) / sizeof(byte); // This alignment is only valid if the GC does not relocate; so we use ReadUnaligned to get the data. // If a GC does occur and alignment is lost, the GC cost will outweigh any gains from alignment so it // isn't too important to pin to maintain the alignment. return (nint)(uint)(-(int)Unsafe.AsPointer(ref searchSpace) / ElementsPerByte) & (Vector128<ushort>.Count - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryFindFirstMatchedLane(Vector128<ushort> compareResult, ref int matchedLane) { Debug.Assert(AdvSimd.Arm64.IsSupported); Vector128<byte> pairwiseSelectedLane = AdvSimd.Arm64.AddPairwise(compareResult.AsByte(), compareResult.AsByte()); ulong selectedLanes = pairwiseSelectedLane.AsUInt64().ToScalar(); if (selectedLanes == 0) { // all lanes are zero, so nothing matched. return false; } // Find the first lane that is set inside compareResult. matchedLane = BitOperations.TrailingZeroCount(selectedLanes) >> 3; return true; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; namespace System { internal static partial class SpanHelpers // .Char { public static int IndexOf(ref char searchSpace, int searchSpaceLength, ref char value, int valueLength) { Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); if (valueLength == 0) return 0; // A zero-length sequence is always treated as "found" at the start of the search space. int valueTailLength = valueLength - 1; if (valueTailLength == 0) { // for single-char values use plain IndexOf return IndexOf(ref searchSpace, value, searchSpaceLength); } nint offset = 0; char valueHead = value; int searchSpaceMinusValueTailLength = searchSpaceLength - valueTailLength; if (Vector128.IsHardwareAccelerated && searchSpaceMinusValueTailLength >= Vector128<ushort>.Count) { goto SEARCH_TWO_CHARS; } ref byte valueTail = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref value, 1)); int remainingSearchSpaceLength = searchSpaceMinusValueTailLength; while (remainingSearchSpaceLength > 0) { // Do a quick search for the first element of "value". int relativeIndex = IndexOf(ref Unsafe.Add(ref searchSpace, offset), valueHead, remainingSearchSpaceLength); if (relativeIndex < 0) break; remainingSearchSpaceLength -= relativeIndex; offset += relativeIndex; if (remainingSearchSpaceLength <= 0) break; // The unsearched portion is now shorter than the sequence we're looking for. So it can't be there. // Found the first element of "value". See if the tail matches. if (SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + 1)), ref valueTail, (nuint)(uint)valueTailLength * 2)) { return (int)offset; // The tail matched. Return a successful find. } remainingSearchSpaceLength--; offset++; } return -1; // Based on http://0x80.pl/articles/simd-strfind.html#algorithm-1-generic-simd "Algorithm 1: Generic SIMD" by Wojciech Muła // Some details about the implementation can also be found in https://github.com/dotnet/runtime/pull/63285 SEARCH_TWO_CHARS: if (Vector256.IsHardwareAccelerated && searchSpaceMinusValueTailLength - Vector256<ushort>.Count >= 0) { // Find the last unique (which is not equal to ch1) character // the algorithm is fine if both are equal, just a little bit less efficient ushort ch2Val = Unsafe.Add(ref value, valueTailLength); nint ch1ch2Distance = valueTailLength; while (ch2Val == valueHead && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector256<ushort> ch1 = Vector256.Create((ushort)valueHead); Vector256<ushort> ch2 = Vector256.Create(ch2Val); nint searchSpaceMinusValueTailLengthAndVector = searchSpaceMinusValueTailLength - (nint)Vector256<ushort>.Count; do { // Make sure we don't go out of bounds Debug.Assert(offset + ch1ch2Distance + Vector256<ushort>.Count <= searchSpaceLength); Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, LoadVector256(ref searchSpace, offset + ch1ch2Distance)); Vector256<ushort> cmpCh1 = Vector256.Equals(ch1, LoadVector256(ref searchSpace, offset)); Vector256<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros if (cmpAnd != Vector256<byte>.Zero) { goto CANDIDATE_FOUND; } LOOP_FOOTER: offset += Vector256<ushort>.Count; if (offset == searchSpaceMinusValueTailLength) return -1; // Overlap with the current chunk for trailing elements if (offset > searchSpaceMinusValueTailLengthAndVector) offset = searchSpaceMinusValueTailLengthAndVector; continue; CANDIDATE_FOUND: uint mask = cmpAnd.ExtractMostSignificantBits(); do { int bitPos = BitOperations.TrailingZeroCount(mask); // div by 2 (shr) because we work with 2-byte chars nint charPos = (nint)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return (int)(offset + charPos); } // Clear two the lowest set bits if (Bmi1.IsSupported) mask = Bmi1.ResetLowestSetBit(Bmi1.ResetLowestSetBit(mask)); else mask &= ~(uint)(0b11 << bitPos); } while (mask != 0); goto LOOP_FOOTER; } while (true); } else // 128bit vector path (SSE2 or AdvSimd) { // Find the last unique (which is not equal to ch1) character // the algorithm is fine if both are equal, just a little bit less efficient ushort ch2Val = Unsafe.Add(ref value, valueTailLength); nint ch1ch2Distance = valueTailLength; while (ch2Val == valueHead && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector128<ushort> ch1 = Vector128.Create((ushort)valueHead); Vector128<ushort> ch2 = Vector128.Create(ch2Val); nint searchSpaceMinusValueTailLengthAndVector = searchSpaceMinusValueTailLength - (nint)Vector128<ushort>.Count; do { // Make sure we don't go out of bounds Debug.Assert(offset + ch1ch2Distance + Vector128<ushort>.Count <= searchSpaceLength); Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, LoadVector128(ref searchSpace, offset + ch1ch2Distance)); Vector128<ushort> cmpCh1 = Vector128.Equals(ch1, LoadVector128(ref searchSpace, offset)); Vector128<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros if (cmpAnd != Vector128<byte>.Zero) { goto CANDIDATE_FOUND; } LOOP_FOOTER: offset += Vector128<ushort>.Count; if (offset == searchSpaceMinusValueTailLength) return -1; // Overlap with the current chunk for trailing elements if (offset > searchSpaceMinusValueTailLengthAndVector) offset = searchSpaceMinusValueTailLengthAndVector; continue; CANDIDATE_FOUND: uint mask = cmpAnd.ExtractMostSignificantBits(); do { int bitPos = BitOperations.TrailingZeroCount(mask); // div by 2 (shr) because we work with 2-byte chars int charPos = (int)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return (int)(offset + charPos); } // Clear two lowest set bits if (Bmi1.IsSupported) mask = Bmi1.ResetLowestSetBit(Bmi1.ResetLowestSetBit(mask)); else mask &= ~(uint)(0b11 << bitPos); } while (mask != 0); goto LOOP_FOOTER; } while (true); } } public static int LastIndexOf(ref char searchSpace, int searchSpaceLength, ref char value, int valueLength) { Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); if (valueLength == 0) return searchSpaceLength; // A zero-length sequence is always treated as "found" at the end of the search space. int valueTailLength = valueLength - 1; if (valueTailLength == 0) return LastIndexOf(ref searchSpace, value, searchSpaceLength); // for single-char values use plain LastIndexOf int offset = 0; char valueHead = value; int searchSpaceMinusValueTailLength = searchSpaceLength - valueTailLength; if (Vector128.IsHardwareAccelerated && searchSpaceMinusValueTailLength >= Vector128<ushort>.Count) { goto SEARCH_TWO_CHARS; } ref byte valueTail = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref value, 1)); while (true) { Debug.Assert(0 <= offset && offset <= searchSpaceLength); // Ensures no deceptive underflows in the computation of "remainingSearchSpaceLength". int remainingSearchSpaceLength = searchSpaceLength - offset - valueTailLength; if (remainingSearchSpaceLength <= 0) break; // The unsearched portion is now shorter than the sequence we're looking for. So it can't be there. // Do a quick search for the first element of "value". int relativeIndex = LastIndexOf(ref searchSpace, valueHead, remainingSearchSpaceLength); if (relativeIndex == -1) break; // Found the first element of "value". See if the tail matches. if (SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, relativeIndex + 1)), ref valueTail, (nuint)(uint)valueTailLength * 2)) { return relativeIndex; // The tail matched. Return a successful find. } offset += remainingSearchSpaceLength - relativeIndex; } return -1; // Based on http://0x80.pl/articles/simd-strfind.html#algorithm-1-generic-simd "Algorithm 1: Generic SIMD" by Wojciech Muła // Some details about the implementation can also be found in https://github.com/dotnet/runtime/pull/63285 SEARCH_TWO_CHARS: if (Vector256.IsHardwareAccelerated && searchSpaceMinusValueTailLength >= Vector256<ushort>.Count) { offset = searchSpaceMinusValueTailLength - Vector256<ushort>.Count; // Find the last unique (which is not equal to ch1) char // the algorithm is fine if both are equal, just a little bit less efficient char ch2Val = Unsafe.Add(ref value, valueTailLength); int ch1ch2Distance = valueTailLength; while (ch2Val == valueHead && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector256<ushort> ch1 = Vector256.Create((ushort)valueHead); Vector256<ushort> ch2 = Vector256.Create((ushort)ch2Val); do { Vector256<ushort> cmpCh1 = Vector256.Equals(ch1, LoadVector256(ref searchSpace, (nuint)offset)); Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, LoadVector256(ref searchSpace, (nuint)(offset + ch1ch2Distance))); Vector256<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros if (cmpAnd != Vector256<byte>.Zero) { uint mask = cmpAnd.ExtractMostSignificantBits(); do { // unlike IndexOf, here we use LZCNT to process matches starting from the end int bitPos = 30 - BitOperations.LeadingZeroCount(mask); int charPos = (int)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return charPos + offset; } mask &= ~(uint)(0b11 << bitPos); // clear two highest set bits. } while (mask != 0); } offset -= Vector256<ushort>.Count; if (offset == -Vector256<ushort>.Count) return -1; // Overlap with the current chunk if there is not enough room for the next one if (offset < 0) offset = 0; } while (true); } else // 128bit vector path (SSE2 or AdvSimd) { offset = searchSpaceMinusValueTailLength - Vector128<ushort>.Count; // Find the last unique (which is not equal to ch1) char // the algorithm is fine if both are equal, just a little bit less efficient char ch2Val = Unsafe.Add(ref value, valueTailLength); int ch1ch2Distance = valueTailLength; while (ch2Val == value && ch1ch2Distance > 1) ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); Vector128<ushort> ch1 = Vector128.Create((ushort)value); Vector128<ushort> ch2 = Vector128.Create((ushort)ch2Val); do { Vector128<ushort> cmpCh1 = Vector128.Equals(ch1, LoadVector128(ref searchSpace, (nuint)offset)); Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, LoadVector128(ref searchSpace, (nuint)(offset + ch1ch2Distance))); Vector128<byte> cmpAnd = (cmpCh1 & cmpCh2).AsByte(); // Early out: cmpAnd is all zeros // it's especially important for ARM where ExtractMostSignificantBits is not cheap if (cmpAnd != Vector128<byte>.Zero) { uint mask = cmpAnd.ExtractMostSignificantBits(); do { // unlike IndexOf, here we use LZCNT to process matches starting from the end int bitPos = 30 - BitOperations.LeadingZeroCount(mask); int charPos = (int)((uint)bitPos / 2); if (valueLength == 2 || // we already matched two chars SequenceEqual( ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) { return charPos + offset; } mask &= ~(uint)(0b11 << bitPos); // clear two the highest set bits. } while (mask != 0); } offset -= Vector128<ushort>.Count; if (offset == -Vector128<ushort>.Count) return -1; // Overlap with the current chunk if there is not enough room for the next one if (offset < 0) offset = 0; } while (true); } } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength) { Debug.Assert(firstLength >= 0); Debug.Assert(secondLength >= 0); int lengthDelta = firstLength - secondLength; if (Unsafe.AreSame(ref first, ref second)) goto Equal; nuint minLength = (nuint)(((uint)firstLength < (uint)secondLength) ? (uint)firstLength : (uint)secondLength); nuint i = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations if (minLength >= (nuint)(sizeof(nuint) / sizeof(char))) { if (Vector.IsHardwareAccelerated && minLength >= (nuint)Vector<ushort>.Count) { nuint nLength = minLength - (nuint)Vector<ushort>.Count; do { if (Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) != Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) { break; } i += (nuint)Vector<ushort>.Count; } while (nLength >= i); } while (minLength >= (i + (nuint)(sizeof(nuint) / sizeof(char)))) { if (Unsafe.ReadUnaligned<nuint> (ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) != Unsafe.ReadUnaligned<nuint>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) { break; } i += (nuint)(sizeof(nuint) / sizeof(char)); } } #if TARGET_64BIT if (minLength >= (i + sizeof(int) / sizeof(char))) { if (Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) == Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) { i += sizeof(int) / sizeof(char); } } #endif while (i < minLength) { int result = Unsafe.Add(ref first, (nint)i).CompareTo(Unsafe.Add(ref second, (nint)i)); if (result != 0) return result; i += 1; } Equal: return lengthDelta; } // Adapted from IndexOf(...) [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe bool Contains(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); fixed (char* pChars = &searchSpace) { char* pCh = pChars; char* pEndCh = pCh + length; if (Vector.IsHardwareAccelerated && length >= Vector<ushort>.Count * 2) { // Figure out how many characters to read sequentially until we are vector aligned // This is equivalent to: // unaligned = ((int)pCh % Unsafe.SizeOf<Vector<ushort>>()) / elementsPerByte // length = (Vector<ushort>.Count - unaligned) % Vector<ushort>.Count const int elementsPerByte = sizeof(ushort) / sizeof(byte); int unaligned = ((int)pCh & (Unsafe.SizeOf<Vector<ushort>>() - 1)) / elementsPerByte; length = (Vector<ushort>.Count - unaligned) & (Vector<ushort>.Count - 1); } SequentialScan: while (length >= 4) { length -= 4; if (value == *pCh || value == *(pCh + 1) || value == *(pCh + 2) || value == *(pCh + 3)) { goto Found; } pCh += 4; } while (length > 0) { length--; if (value == *pCh) goto Found; pCh++; } // We get past SequentialScan only if IsHardwareAccelerated is true. However, we still have the redundant check to allow // the JIT to see that the code is unreachable and eliminate it when the platform does not have hardware accelerated. if (Vector.IsHardwareAccelerated && pCh < pEndCh) { // Get the highest multiple of Vector<ushort>.Count that is within the search space. // That will be how many times we iterate in the loop below. // This is equivalent to: length = Vector<ushort>.Count * ((int)(pEndCh - pCh) / Vector<ushort>.Count) length = (int)((pEndCh - pCh) & ~(Vector<ushort>.Count - 1)); // Get comparison Vector Vector<ushort> vComparison = new Vector<ushort>(value); while (length > 0) { // Using Unsafe.Read instead of ReadUnaligned since the search space is pinned and pCh is always vector aligned Debug.Assert(((int)pCh & (Unsafe.SizeOf<Vector<ushort>>() - 1)) == 0); Vector<ushort> vMatches = Vector.Equals(vComparison, Unsafe.Read<Vector<ushort>>(pCh)); if (Vector<ushort>.Zero.Equals(vMatches)) { pCh += Vector<ushort>.Count; length -= Vector<ushort>.Count; continue; } goto Found; } if (pCh < pEndCh) { length = (int)(pEndCh - pCh); goto SequentialScan; } } return false; Found: return true; } } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOf(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); nint offset = 0; nint lengthToExamine = length; if (((int)Unsafe.AsPointer(ref searchSpace) & 1) != 0) { // Input isn't char aligned, we won't be able to align it to a Vector } else if (Sse2.IsSupported || AdvSimd.Arm64.IsSupported) { // Avx2 branch also operates on Sse2 sizes, so check is combined. // Needs to be double length to allow us to align the data first. if (length >= Vector128<ushort>.Count * 2) { lengthToExamine = UnalignedCountVector128(ref searchSpace); } } else if (Vector.IsHardwareAccelerated) { // Needs to be double length to allow us to align the data first. if (length >= Vector<ushort>.Count * 2) { lengthToExamine = UnalignedCountVector(ref searchSpace); } } SequentialScan: // In the non-vector case lengthToExamine is the total length. // In the vector case lengthToExamine first aligns to Vector, // then in a second pass after the Vector lengths is the // remaining data that is shorter than a Vector length. while (lengthToExamine >= 4) { ref char current = ref Unsafe.Add(ref searchSpace, offset); if (value == current) goto Found; if (value == Unsafe.Add(ref current, 1)) goto Found1; if (value == Unsafe.Add(ref current, 2)) goto Found2; if (value == Unsafe.Add(ref current, 3)) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { if (value == Unsafe.Add(ref searchSpace, offset)) goto Found; offset++; lengthToExamine--; } // We get past SequentialScan only if IsHardwareAccelerated or intrinsic .IsSupported is true. However, we still have the redundant check to allow // the JIT to see that the code is unreachable and eliminate it when the platform does not have hardware accelerated. if (Avx2.IsSupported) { if (offset < length) { Debug.Assert(length - offset >= Vector128<ushort>.Count); if (((nint)Unsafe.AsPointer(ref Unsafe.Add(ref searchSpace, (nint)offset)) & (nint)(Vector256<byte>.Count - 1)) != 0) { // Not currently aligned to Vector256 (is aligned to Vector128); this can cause a problem for searches // with no upper bound e.g. String.wcslen. Start with a check on Vector128 to align to Vector256, // before moving to processing Vector256. // If the input searchSpan has been fixed or pinned, this ensures we do not fault across memory pages // while searching for an end of string. Specifically that this assumes that the length is either correct // or that the data is pinned otherwise it may cause an AccessViolation from crossing a page boundary into an // unowned page. If the search is unbounded (e.g. null terminator in wcslen) and the search value is not found, // again this will likely cause an AccessViolation. However, correctly bounded searches will return -1 rather // than ever causing an AV. // If the searchSpan has not been fixed or pinned the GC can relocate it during the execution of this // method, so the alignment only acts as best endeavour. The GC cost is likely to dominate over // the misalignment that may occur after; to we default to giving the GC a free hand to relocate and // its up to the caller whether they are operating over fixed data. Vector128<ushort> values = Vector128.Create((ushort)value); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); // Same method as below int matches = Sse2.MoveMask(Sse2.CompareEqual(values, search).AsByte()); if (matches == 0) { // Zero flags set so no matches offset += Vector128<ushort>.Count; } else { // Find bitflag offset of first match and add to current offset return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } } lengthToExamine = GetCharVector256SpanLength(offset, length); if (lengthToExamine > 0) { Vector256<ushort> values = Vector256.Create((ushort)value); do { Debug.Assert(lengthToExamine >= Vector256<ushort>.Count); Vector256<ushort> search = LoadVector256(ref searchSpace, offset); int matches = Avx2.MoveMask(Avx2.CompareEqual(values, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // Zero flags set so no matches offset += Vector256<ushort>.Count; lengthToExamine -= Vector256<ushort>.Count; continue; } // Find bitflag offset of first match and add to current offset, // flags are in bytes so divide for chars return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } while (lengthToExamine > 0); } lengthToExamine = GetCharVector128SpanLength(offset, length); if (lengthToExamine > 0) { Debug.Assert(lengthToExamine >= Vector128<ushort>.Count); Vector128<ushort> values = Vector128.Create((ushort)value); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); // Same method as above int matches = Sse2.MoveMask(Sse2.CompareEqual(values, search).AsByte()); if (matches == 0) { // Zero flags set so no matches offset += Vector128<ushort>.Count; // Don't need to change lengthToExamine here as we don't use its current value again. } else { // Find bitflag offset of first match and add to current offset, // flags are in bytes so divide for chars return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } else if (Sse2.IsSupported) { if (offset < length) { Debug.Assert(length - offset >= Vector128<ushort>.Count); lengthToExamine = GetCharVector128SpanLength(offset, length); if (lengthToExamine > 0) { Vector128<ushort> values = Vector128.Create((ushort)value); do { Debug.Assert(lengthToExamine >= Vector128<ushort>.Count); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); // Same method as above int matches = Sse2.MoveMask(Sse2.CompareEqual(values, search).AsByte()); if (matches == 0) { // Zero flags set so no matches offset += Vector128<ushort>.Count; lengthToExamine -= Vector128<ushort>.Count; continue; } // Find bitflag offset of first match and add to current offset, // flags are in bytes so divide for chars return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); } while (lengthToExamine > 0); } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } else if (AdvSimd.Arm64.IsSupported) { if (offset < length) { Debug.Assert(length - offset >= Vector128<ushort>.Count); lengthToExamine = GetCharVector128SpanLength(offset, length); if (lengthToExamine > 0) { Vector128<ushort> values = Vector128.Create((ushort)value); int matchedLane = 0; do { Debug.Assert(lengthToExamine >= Vector128<ushort>.Count); Vector128<ushort> search = LoadVector128(ref searchSpace, offset); Vector128<ushort> compareResult = AdvSimd.CompareEqual(values, search); if (!TryFindFirstMatchedLane(compareResult, ref matchedLane)) { // Zero flags set so no matches offset += Vector128<ushort>.Count; lengthToExamine -= Vector128<ushort>.Count; continue; } return (int)(offset + matchedLane); } while (lengthToExamine > 0); } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } else if (Vector.IsHardwareAccelerated) { if (offset < length) { Debug.Assert(length - offset >= Vector<ushort>.Count); lengthToExamine = GetCharVectorSpanLength(offset, length); if (lengthToExamine > 0) { Vector<ushort> values = new Vector<ushort>((ushort)value); do { Debug.Assert(lengthToExamine >= Vector<ushort>.Count); var matches = Vector.Equals(values, LoadVector(ref searchSpace, offset)); if (Vector<ushort>.Zero.Equals(matches)) { offset += Vector<ushort>.Count; lengthToExamine -= Vector<ushort>.Count; continue; } // Find offset of first match return (int)(offset + LocateFirstFoundChar(matches)); } while (lengthToExamine > 0); } if (offset < length) { lengthToExamine = length - offset; goto SequentialScan; } } } return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)(offset); } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // Bitwise Or to combine the flagged matches for the second value to our match flags matches = Avx2.MoveMask( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, char value2, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp || value2 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); Vector256<ushort> values2 = Vector256.Create((ushort)value2); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // Bitwise Or to combine the flagged matches for the second value to our match flags matches = Avx2.MoveMask( Avx2.Or( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)), Avx2.CompareEqual(values2, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask( Avx2.Or( Avx2.Or( Avx2.CompareEqual(values0, search), Avx2.CompareEqual(values1, search)), Avx2.CompareEqual(values2, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); Vector128<ushort> values2 = Vector128.Create((ushort)value2); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask( Sse2.Or( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)), Sse2.CompareEqual(values2, search)) .AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask( Sse2.Or( Sse2.Or( Sse2.CompareEqual(values0, search), Sse2.CompareEqual(values1, search)), Sse2.CompareEqual(values2, search)) .AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> values2 = new Vector<ushort>(value2); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); Vector256<ushort> values2 = Vector256.Create((ushort)value2); Vector256<ushort> values3 = Vector256.Create((ushort)value3); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // We preform the Or at non-Vector level as we are using the maximum number of non-preserved registers, // and more causes them first to be pushed to stack and then popped on exit to preseve their values. matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); Vector128<ushort> values2 = Vector128.Create((ushort)value2); Vector128<ushort> values3 = Vector128.Create((ushort)value3); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> values2 = new Vector<ushort>(value2); Vector<ushort> values3 = new Vector<ushort>(value3); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, char value4, int length) { Debug.Assert(length >= 0); nuint offset = 0; // Use nuint for arithmetic to avoid unnecessary 64->32->64 truncations nuint lengthToExamine = (nuint)(uint)length; if (Sse2.IsSupported) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector128<ushort>.Count; if (vectorDiff >= 0) { // >= Sse2 intrinsics are supported and length is enough to use them, so use that path. // We jump forward to the intrinsics at the end of them method so a naive branch predict // will choose the non-intrinsic path so short lengths which don't gain anything aren't // overly disadvantaged by having to jump over a lot of code. Whereas the longer lengths // more than make this back from the intrinsics. lengthToExamine = (nuint)vectorDiff; goto IntrinsicsCompare; } } else if (Vector.IsHardwareAccelerated) { // Calculate lengthToExamine here for test, rather than just testing as it used later, rather than doing it twice. nint vectorDiff = (nint)length - Vector<ushort>.Count; if (vectorDiff >= 0) { // Similar as above for Vector version lengthToExamine = (nuint)vectorDiff; goto VectorCompare; } } int lookUp; while (lengthToExamine >= 4) { ref char current = ref Add(ref searchStart, offset); lookUp = current; if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found; lookUp = Unsafe.Add(ref current, 1); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found1; lookUp = Unsafe.Add(ref current, 2); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found2; lookUp = Unsafe.Add(ref current, 3); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found3; offset += 4; lengthToExamine -= 4; } while (lengthToExamine > 0) { lookUp = Add(ref searchStart, offset); if (value0 == lookUp || value1 == lookUp || value2 == lookUp || value3 == lookUp || value4 == lookUp) goto Found; offset += 1; lengthToExamine -= 1; } NotFound: return -1; Found3: return (int)(offset + 3); Found2: return (int)(offset + 2); Found1: return (int)(offset + 1); Found: return (int)offset; IntrinsicsCompare: // When we move into a Vectorized block, we process everything of Vector size; // and then for any remainder we do a final compare of Vector size but starting at // the end and forwards, which may overlap on an earlier compare. // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (Sse2.IsSupported) { int matches; if (Avx2.IsSupported) { Vector256<ushort> search; // Guard as we may only have a valid size for Vector128; when we will move to the Sse2 // We have already subtracted Vector128<ushort>.Count from lengthToExamine so compare against that // to see if we have double the size for Vector256<ushort>.Count if (lengthToExamine >= (nuint)Vector128<ushort>.Count) { Vector256<ushort> values0 = Vector256.Create((ushort)value0); Vector256<ushort> values1 = Vector256.Create((ushort)value1); Vector256<ushort> values2 = Vector256.Create((ushort)value2); Vector256<ushort> values3 = Vector256.Create((ushort)value3); Vector256<ushort> values4 = Vector256.Create((ushort)value4); // Subtract Vector128<ushort>.Count so we have now subtracted Vector256<ushort>.Count lengthToExamine -= (nuint)Vector128<ushort>.Count; // First time this checks again against 0, however we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector256(ref searchStart, offset); // We preform the Or at non-Vector level as we are using the maximum number of non-preserved registers (+ 1), // and more causes them first to be pushed to stack and then popped on exit to preseve their values. matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values4, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector256<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector256(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Avx2.MoveMask(Avx2.CompareEqual(values0, search).AsByte()); // Bitwise Or to combine the flagged matches for the second, third and fourth values to our match flags matches |= Avx2.MoveMask(Avx2.CompareEqual(values1, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values2, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values3, search).AsByte()); matches |= Avx2.MoveMask(Avx2.CompareEqual(values4, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } goto IntrinsicsMatch; } } // Initial size check was done on method entry. Debug.Assert(length >= Vector128<ushort>.Count); { Vector128<ushort> search; Vector128<ushort> values0 = Vector128.Create((ushort)value0); Vector128<ushort> values1 = Vector128.Create((ushort)value1); Vector128<ushort> values2 = Vector128.Create((ushort)value2); Vector128<ushort> values3 = Vector128.Create((ushort)value3); Vector128<ushort> values4 = Vector128.Create((ushort)value4); // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector128(ref searchStart, offset); matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values4, search).AsByte()); // Note that MoveMask has converted the equal vector elements into a set of bit flags, // So the bit position in 'matches' corresponds to the element offset. if (matches == 0) { // None matched offset += (nuint)Vector128<ushort>.Count; continue; } goto IntrinsicsMatch; } // Move to Vector length from end for final compare search = LoadVector128(ref searchStart, lengthToExamine); offset = lengthToExamine; // Same as method as above matches = Sse2.MoveMask(Sse2.CompareEqual(values0, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values1, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values2, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values3, search).AsByte()); matches |= Sse2.MoveMask(Sse2.CompareEqual(values4, search).AsByte()); if (matches == 0) { // None matched goto NotFound; } } IntrinsicsMatch: // Find bitflag offset of first difference and add to current offset, // flags are in bytes so divide by 2 for chars (shift right by 1) offset += (nuint)(uint)BitOperations.TrailingZeroCount(matches) >> 1; goto Found; } VectorCompare: // We include the Supported check again here even though path will not be taken, so the asm isn't generated if not supported. if (!Sse2.IsSupported && Vector.IsHardwareAccelerated) { Vector<ushort> values0 = new Vector<ushort>(value0); Vector<ushort> values1 = new Vector<ushort>(value1); Vector<ushort> values2 = new Vector<ushort>(value2); Vector<ushort> values3 = new Vector<ushort>(value3); Vector<ushort> values4 = new Vector<ushort>(value4); Vector<ushort> search; // First time this checks against 0 and we will move into final compare if it fails. while (lengthToExamine > offset) { search = LoadVector(ref searchStart, offset); search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)), Vector.Equals(search, values4)); if (Vector<ushort>.Zero.Equals(search)) { // None matched offset += (nuint)Vector<ushort>.Count; continue; } goto VectorMatch; } // Move to Vector length from end for final compare search = LoadVector(ref searchStart, lengthToExamine); offset = lengthToExamine; search = Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.BitwiseOr( Vector.Equals(search, values0), Vector.Equals(search, values1)), Vector.Equals(search, values2)), Vector.Equals(search, values3)), Vector.Equals(search, values4)); if (Vector<ushort>.Zero.Equals(search)) { // None matched goto NotFound; } VectorMatch: offset += (nuint)(uint)LocateFirstFoundChar(search); goto Found; } Debug.Fail("Unreachable"); goto NotFound; } [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int LastIndexOf(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); fixed (char* pChars = &searchSpace) { char* pCh = pChars + length; char* pEndCh = pChars; if (Vector.IsHardwareAccelerated && length >= Vector<ushort>.Count * 2) { // Figure out how many characters to read sequentially from the end until we are vector aligned // This is equivalent to: length = ((int)pCh % Unsafe.SizeOf<Vector<ushort>>()) / elementsPerByte const int elementsPerByte = sizeof(ushort) / sizeof(byte); length = ((int)pCh & (Unsafe.SizeOf<Vector<ushort>>() - 1)) / elementsPerByte; } SequentialScan: while (length >= 4) { length -= 4; pCh -= 4; if (*(pCh + 3) == value) goto Found3; if (*(pCh + 2) == value) goto Found2; if (*(pCh + 1) == value) goto Found1; if (*pCh == value) goto Found; } while (length > 0) { length--; pCh--; if (*pCh == value) goto Found; } // We get past SequentialScan only if IsHardwareAccelerated is true. However, we still have the redundant check to allow // the JIT to see that the code is unreachable and eliminate it when the platform does not have hardware accelerated. if (Vector.IsHardwareAccelerated && pCh > pEndCh) { // Get the highest multiple of Vector<ushort>.Count that is within the search space. // That will be how many times we iterate in the loop below. // This is equivalent to: length = Vector<ushort>.Count * ((int)(pCh - pEndCh) / Vector<ushort>.Count) length = (int)((pCh - pEndCh) & ~(Vector<ushort>.Count - 1)); // Get comparison Vector Vector<ushort> vComparison = new Vector<ushort>(value); while (length > 0) { char* pStart = pCh - Vector<ushort>.Count; // Using Unsafe.Read instead of ReadUnaligned since the search space is pinned and pCh (and hence pSart) is always vector aligned Debug.Assert(((int)pStart & (Unsafe.SizeOf<Vector<ushort>>() - 1)) == 0); Vector<ushort> vMatches = Vector.Equals(vComparison, Unsafe.Read<Vector<ushort>>(pStart)); if (Vector<ushort>.Zero.Equals(vMatches)) { pCh -= Vector<ushort>.Count; length -= Vector<ushort>.Count; continue; } // Find offset of last match return (int)(pStart - pEndCh) + LocateLastFoundChar(vMatches); } if (pCh > pEndCh) { length = (int)(pCh - pEndCh); goto SequentialScan; } } return -1; Found: return (int)(pCh - pEndCh); Found1: return (int)(pCh - pEndCh) + 1; Found2: return (int)(pCh - pEndCh) + 2; Found3: return (int)(pCh - pEndCh) + 3; } } // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundChar(Vector<ushort> match) { var vector64 = Vector.AsVectorUInt64(match); ulong candidate = 0; int i = 0; // Pattern unrolled by jit https://github.com/dotnet/coreclr/pull/8001 for (; i < Vector<ulong>.Count; i++) { candidate = vector64[i]; if (candidate != 0) { break; } } // Single LEA instruction with jitted const (using function result) return i * 4 + LocateFirstFoundChar(candidate); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundChar(ulong match) => BitOperations.TrailingZeroCount(match) >> 4; // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundChar(Vector<ushort> match) { var vector64 = Vector.AsVectorUInt64(match); ulong candidate = 0; int i = Vector<ulong>.Count - 1; // This pattern is only unrolled by the Jit if the limit is Vector<T>.Count // As such, we need a dummy iteration variable for that condition to be satisfied for (int j = 0; j < Vector<ulong>.Count; j++) { candidate = vector64[i]; if (candidate != 0) { break; } i--; } // Single LEA instruction with jitted const (using function result) return i * 4 + LocateLastFoundChar(candidate); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundChar(ulong match) => BitOperations.Log2(match) >> 4; [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector<ushort> LoadVector(ref char start, nint offset) => Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector<ushort> LoadVector(ref char start, nuint offset) => Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128<ushort> LoadVector128(ref char start, nint offset) => Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128<ushort> LoadVector128(ref char start, nuint offset) => Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256<ushort> LoadVector256(ref char start, nint offset) => Unsafe.ReadUnaligned<Vector256<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256<ushort> LoadVector256(ref char start, nuint offset) => Unsafe.ReadUnaligned<Vector256<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset))); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ref char Add(ref char start, nuint offset) => ref Unsafe.Add(ref start, (nint)offset); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static nint GetCharVectorSpanLength(nint offset, nint length) => (length - offset) & ~(Vector<ushort>.Count - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static nint GetCharVector128SpanLength(nint offset, nint length) => (length - offset) & ~(Vector128<ushort>.Count - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static nint GetCharVector256SpanLength(nint offset, nint length) => (length - offset) & ~(Vector256<ushort>.Count - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static unsafe nint UnalignedCountVector(ref char searchSpace) { const int ElementsPerByte = sizeof(ushort) / sizeof(byte); // Figure out how many characters to read sequentially until we are vector aligned // This is equivalent to: // unaligned = ((int)pCh % Unsafe.SizeOf<Vector<ushort>>()) / ElementsPerByte // length = (Vector<ushort>.Count - unaligned) % Vector<ushort>.Count // This alignment is only valid if the GC does not relocate; so we use ReadUnaligned to get the data. // If a GC does occur and alignment is lost, the GC cost will outweigh any gains from alignment so it // isn't too important to pin to maintain the alignment. return (nint)(uint)(-(int)Unsafe.AsPointer(ref searchSpace) / ElementsPerByte) & (Vector<ushort>.Count - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static unsafe nint UnalignedCountVector128(ref char searchSpace) { const int ElementsPerByte = sizeof(ushort) / sizeof(byte); // This alignment is only valid if the GC does not relocate; so we use ReadUnaligned to get the data. // If a GC does occur and alignment is lost, the GC cost will outweigh any gains from alignment so it // isn't too important to pin to maintain the alignment. return (nint)(uint)(-(int)Unsafe.AsPointer(ref searchSpace) / ElementsPerByte) & (Vector128<ushort>.Count - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryFindFirstMatchedLane(Vector128<ushort> compareResult, ref int matchedLane) { Debug.Assert(AdvSimd.Arm64.IsSupported); Vector128<byte> pairwiseSelectedLane = AdvSimd.Arm64.AddPairwise(compareResult.AsByte(), compareResult.AsByte()); ulong selectedLanes = pairwiseSelectedLane.AsUInt64().ToScalar(); if (selectedLanes == 0) { // all lanes are zero, so nothing matched. return false; } // Find the first lane that is set inside compareResult. matchedLane = BitOperations.TrailingZeroCount(selectedLanes) >> 3; return true; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitMemberAccessor.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #if NETFRAMEWORK || NETCOREAPP using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Reflection.Emit; namespace System.Text.Json.Serialization.Metadata { internal sealed class ReflectionEmitMemberAccessor : MemberAccessor { public override JsonTypeInfo.ConstructorDelegate? CreateConstructor( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type) { Debug.Assert(type != null); ConstructorInfo? realMethod = type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null); if (type.IsAbstract) { return null; } if (realMethod == null && !type.IsValueType) { return null; } var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, JsonTypeInfo.ObjectType, Type.EmptyTypes, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); if (realMethod == null) { LocalBuilder local = generator.DeclareLocal(type); generator.Emit(OpCodes.Ldloca_S, local); generator.Emit(OpCodes.Initobj, type); generator.Emit(OpCodes.Ldloc, local); generator.Emit(OpCodes.Box, type); } else { generator.Emit(OpCodes.Newobj, realMethod); if (type.IsValueType) { // Since C# 10 it's now possible to have parameterless constructors in structs generator.Emit(OpCodes.Box, type); } } generator.Emit(OpCodes.Ret); return (JsonTypeInfo.ConstructorDelegate)dynamicMethod.CreateDelegate(typeof(JsonTypeInfo.ConstructorDelegate)); } public override Func<object[], T>? CreateParameterizedConstructor<T>(ConstructorInfo constructor) => CreateDelegate<Func<object[], T>>(CreateParameterizedConstructor(constructor)); private static DynamicMethod? CreateParameterizedConstructor(ConstructorInfo constructor) { Type? type = constructor.DeclaringType; Debug.Assert(type != null); Debug.Assert(!type.IsAbstract); Debug.Assert(constructor.IsPublic && !constructor.IsStatic); ParameterInfo[] parameters = constructor.GetParameters(); int parameterCount = parameters.Length; if (parameterCount > JsonConstants.MaxParameterCount) { return null; } var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, type, new[] { typeof(object[]) }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); for (int i = 0; i < parameterCount; i++) { Type paramType = parameters[i].ParameterType; generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Ldc_I4_S, i); generator.Emit(OpCodes.Ldelem_Ref); generator.Emit(OpCodes.Unbox_Any, paramType); } generator.Emit(OpCodes.Newobj, constructor); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override JsonTypeInfo.ParameterizedConstructorDelegate<T, TArg0, TArg1, TArg2, TArg3>? CreateParameterizedConstructor<T, TArg0, TArg1, TArg2, TArg3>(ConstructorInfo constructor) => CreateDelegate<JsonTypeInfo.ParameterizedConstructorDelegate<T, TArg0, TArg1, TArg2, TArg3>>( CreateParameterizedConstructor(constructor, typeof(TArg0), typeof(TArg1), typeof(TArg2), typeof(TArg3))); private static DynamicMethod? CreateParameterizedConstructor(ConstructorInfo constructor, Type parameterType1, Type parameterType2, Type parameterType3, Type parameterType4) { Type? type = constructor.DeclaringType; Debug.Assert(type != null); Debug.Assert(!type.IsAbstract); Debug.Assert(constructor.IsPublic && !constructor.IsStatic); ParameterInfo[] parameters = constructor.GetParameters(); int parameterCount = parameters.Length; var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, type, new[] { parameterType1, parameterType2, parameterType3, parameterType4 }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); for (int index = 0; index < parameterCount; index++) { Debug.Assert(index <= JsonConstants.UnboxedParameterCountThreshold); generator.Emit( index switch { 0 => OpCodes.Ldarg_0, 1 => OpCodes.Ldarg_1, 2 => OpCodes.Ldarg_2, 3 => OpCodes.Ldarg_3, _ => throw new InvalidOperationException() }); } generator.Emit(OpCodes.Newobj, constructor); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Action<TCollection, object?> CreateAddMethodDelegate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] TCollection>() => CreateDelegate<Action<TCollection, object?>>(CreateAddMethodDelegate(typeof(TCollection))); private static DynamicMethod CreateAddMethodDelegate( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type collectionType) { // We verified this won't be null when we created the converter that calls this method. MethodInfo realMethod = (collectionType.GetMethod("Push") ?? collectionType.GetMethod("Enqueue"))!; var dynamicMethod = new DynamicMethod( realMethod.Name, typeof(void), new[] { collectionType, JsonTypeInfo.ObjectType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Callvirt, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] public override Func<IEnumerable<TElement>, TCollection> CreateImmutableEnumerableCreateRangeDelegate<TCollection, TElement>() => CreateDelegate<Func<IEnumerable<TElement>, TCollection>>( CreateImmutableEnumerableCreateRangeDelegate(typeof(TCollection), typeof(TElement), typeof(IEnumerable<TElement>))); [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] private static DynamicMethod CreateImmutableEnumerableCreateRangeDelegate(Type collectionType, Type elementType, Type enumerableType) { MethodInfo realMethod = collectionType.GetImmutableEnumerableCreateRangeMethod(elementType); var dynamicMethod = new DynamicMethod( realMethod.Name, collectionType, new[] { enumerableType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Call, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] public override Func<IEnumerable<KeyValuePair<TKey, TValue>>, TCollection> CreateImmutableDictionaryCreateRangeDelegate<TCollection, TKey, TValue>() => CreateDelegate<Func<IEnumerable<KeyValuePair<TKey, TValue>>, TCollection>>( CreateImmutableDictionaryCreateRangeDelegate(typeof(TCollection), typeof(TKey), typeof(TValue), typeof(IEnumerable<KeyValuePair<TKey, TValue>>))); [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] private static DynamicMethod CreateImmutableDictionaryCreateRangeDelegate(Type collectionType, Type keyType, Type valueType, Type enumerableType) { MethodInfo realMethod = collectionType.GetImmutableDictionaryCreateRangeMethod(keyType, valueType); var dynamicMethod = new DynamicMethod( realMethod.Name, collectionType, new[] { enumerableType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Call, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Func<object, TProperty> CreatePropertyGetter<TProperty>(PropertyInfo propertyInfo) => CreateDelegate<Func<object, TProperty>>(CreatePropertyGetter(propertyInfo, typeof(TProperty))); private static DynamicMethod CreatePropertyGetter(PropertyInfo propertyInfo, Type runtimePropertyType) { MethodInfo? realMethod = propertyInfo.GetMethod; Debug.Assert(realMethod != null); Type? declaringType = propertyInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredPropertyType = propertyInfo.PropertyType; DynamicMethod dynamicMethod = CreateGetterMethod(propertyInfo.Name, runtimePropertyType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); if (declaringType.IsValueType) { generator.Emit(OpCodes.Unbox, declaringType); generator.Emit(OpCodes.Call, realMethod); } else { generator.Emit(OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Callvirt, realMethod); } // declaredPropertyType: Type of the property // runtimePropertyType: <T> of JsonConverter / JsonPropertyInfo if (declaredPropertyType != runtimePropertyType && declaredPropertyType.IsValueType) { // Not supported scenario: possible if declaredPropertyType == int? and runtimePropertyType == int // We should catch that particular case earlier in converter generation. Debug.Assert(!runtimePropertyType.IsValueType); generator.Emit(OpCodes.Box, declaredPropertyType); } generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Action<object, TProperty> CreatePropertySetter<TProperty>(PropertyInfo propertyInfo) => CreateDelegate<Action<object, TProperty>>(CreatePropertySetter(propertyInfo, typeof(TProperty))); private static DynamicMethod CreatePropertySetter(PropertyInfo propertyInfo, Type runtimePropertyType) { MethodInfo? realMethod = propertyInfo.SetMethod; Debug.Assert(realMethod != null); Type? declaringType = propertyInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredPropertyType = propertyInfo.PropertyType; DynamicMethod dynamicMethod = CreateSetterMethod(propertyInfo.Name, runtimePropertyType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(declaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Ldarg_1); // declaredPropertyType: Type of the property // runtimePropertyType: <T> of JsonConverter / JsonPropertyInfo if (declaredPropertyType != runtimePropertyType && declaredPropertyType.IsValueType) { // Not supported scenario: possible if e.g. declaredPropertyType == int? and runtimePropertyType == int // We should catch that particular case earlier in converter generation. Debug.Assert(!runtimePropertyType.IsValueType); generator.Emit(OpCodes.Unbox_Any, declaredPropertyType); } generator.Emit(declaringType.IsValueType ? OpCodes.Call : OpCodes.Callvirt, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Func<object, TProperty> CreateFieldGetter<TProperty>(FieldInfo fieldInfo) => CreateDelegate<Func<object, TProperty>>(CreateFieldGetter(fieldInfo, typeof(TProperty))); private static DynamicMethod CreateFieldGetter(FieldInfo fieldInfo, Type runtimeFieldType) { Type? declaringType = fieldInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredFieldType = fieldInfo.FieldType; DynamicMethod dynamicMethod = CreateGetterMethod(fieldInfo.Name, runtimeFieldType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit( declaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Ldfld, fieldInfo); // declaredFieldType: Type of the field // runtimeFieldType: <T> of JsonConverter / JsonPropertyInfo if (declaredFieldType.IsValueType && declaredFieldType != runtimeFieldType) { generator.Emit(OpCodes.Box, declaredFieldType); } generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Action<object, TProperty> CreateFieldSetter<TProperty>(FieldInfo fieldInfo) => CreateDelegate<Action<object, TProperty>>(CreateFieldSetter(fieldInfo, typeof(TProperty))); private static DynamicMethod CreateFieldSetter(FieldInfo fieldInfo, Type runtimeFieldType) { Type? declaringType = fieldInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredFieldType = fieldInfo.FieldType; DynamicMethod dynamicMethod = CreateSetterMethod(fieldInfo.Name, runtimeFieldType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(declaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Ldarg_1); // declaredFieldType: Type of the field // runtimeFieldType: <T> of JsonConverter / JsonPropertyInfo if (declaredFieldType != runtimeFieldType && declaredFieldType.IsValueType) { generator.Emit(OpCodes.Unbox_Any, declaredFieldType); } generator.Emit(OpCodes.Stfld, fieldInfo); generator.Emit(OpCodes.Ret); return dynamicMethod; } private static DynamicMethod CreateGetterMethod(string memberName, Type memberType) => new DynamicMethod( memberName + "Getter", memberType, new[] { JsonTypeInfo.ObjectType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); private static DynamicMethod CreateSetterMethod(string memberName, Type memberType) => new DynamicMethod( memberName + "Setter", typeof(void), new[] { JsonTypeInfo.ObjectType, memberType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); [return: NotNullIfNotNull("method")] private static T? CreateDelegate<T>(DynamicMethod? method) where T : Delegate => (T?)method?.CreateDelegate(typeof(T)); } } #endif
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #if NETFRAMEWORK || NETCOREAPP using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Reflection.Emit; namespace System.Text.Json.Serialization.Metadata { internal sealed class ReflectionEmitMemberAccessor : MemberAccessor { public override JsonTypeInfo.ConstructorDelegate? CreateConstructor( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type) { Debug.Assert(type != null); ConstructorInfo? realMethod = type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null); if (type.IsAbstract) { return null; } if (realMethod == null && !type.IsValueType) { return null; } var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, JsonTypeInfo.ObjectType, Type.EmptyTypes, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); if (realMethod == null) { LocalBuilder local = generator.DeclareLocal(type); generator.Emit(OpCodes.Ldloca_S, local); generator.Emit(OpCodes.Initobj, type); generator.Emit(OpCodes.Ldloc, local); generator.Emit(OpCodes.Box, type); } else { generator.Emit(OpCodes.Newobj, realMethod); if (type.IsValueType) { // Since C# 10 it's now possible to have parameterless constructors in structs generator.Emit(OpCodes.Box, type); } } generator.Emit(OpCodes.Ret); return (JsonTypeInfo.ConstructorDelegate)dynamicMethod.CreateDelegate(typeof(JsonTypeInfo.ConstructorDelegate)); } public override Func<object[], T>? CreateParameterizedConstructor<T>(ConstructorInfo constructor) => CreateDelegate<Func<object[], T>>(CreateParameterizedConstructor(constructor)); private static DynamicMethod? CreateParameterizedConstructor(ConstructorInfo constructor) { Type? type = constructor.DeclaringType; Debug.Assert(type != null); Debug.Assert(!type.IsAbstract); Debug.Assert(constructor.IsPublic && !constructor.IsStatic); ParameterInfo[] parameters = constructor.GetParameters(); int parameterCount = parameters.Length; if (parameterCount > JsonConstants.MaxParameterCount) { return null; } var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, type, new[] { typeof(object[]) }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); for (int i = 0; i < parameterCount; i++) { Type paramType = parameters[i].ParameterType; generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Ldc_I4_S, i); generator.Emit(OpCodes.Ldelem_Ref); generator.Emit(OpCodes.Unbox_Any, paramType); } generator.Emit(OpCodes.Newobj, constructor); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override JsonTypeInfo.ParameterizedConstructorDelegate<T, TArg0, TArg1, TArg2, TArg3>? CreateParameterizedConstructor<T, TArg0, TArg1, TArg2, TArg3>(ConstructorInfo constructor) => CreateDelegate<JsonTypeInfo.ParameterizedConstructorDelegate<T, TArg0, TArg1, TArg2, TArg3>>( CreateParameterizedConstructor(constructor, typeof(TArg0), typeof(TArg1), typeof(TArg2), typeof(TArg3))); private static DynamicMethod? CreateParameterizedConstructor(ConstructorInfo constructor, Type parameterType1, Type parameterType2, Type parameterType3, Type parameterType4) { Type? type = constructor.DeclaringType; Debug.Assert(type != null); Debug.Assert(!type.IsAbstract); Debug.Assert(constructor.IsPublic && !constructor.IsStatic); ParameterInfo[] parameters = constructor.GetParameters(); int parameterCount = parameters.Length; var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, type, new[] { parameterType1, parameterType2, parameterType3, parameterType4 }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); for (int index = 0; index < parameterCount; index++) { Debug.Assert(index <= JsonConstants.UnboxedParameterCountThreshold); generator.Emit( index switch { 0 => OpCodes.Ldarg_0, 1 => OpCodes.Ldarg_1, 2 => OpCodes.Ldarg_2, 3 => OpCodes.Ldarg_3, _ => throw new InvalidOperationException() }); } generator.Emit(OpCodes.Newobj, constructor); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Action<TCollection, object?> CreateAddMethodDelegate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] TCollection>() => CreateDelegate<Action<TCollection, object?>>(CreateAddMethodDelegate(typeof(TCollection))); private static DynamicMethod CreateAddMethodDelegate( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type collectionType) { // We verified this won't be null when we created the converter that calls this method. MethodInfo realMethod = (collectionType.GetMethod("Push") ?? collectionType.GetMethod("Enqueue"))!; var dynamicMethod = new DynamicMethod( realMethod.Name, typeof(void), new[] { collectionType, JsonTypeInfo.ObjectType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Callvirt, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] public override Func<IEnumerable<TElement>, TCollection> CreateImmutableEnumerableCreateRangeDelegate<TCollection, TElement>() => CreateDelegate<Func<IEnumerable<TElement>, TCollection>>( CreateImmutableEnumerableCreateRangeDelegate(typeof(TCollection), typeof(TElement), typeof(IEnumerable<TElement>))); [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] private static DynamicMethod CreateImmutableEnumerableCreateRangeDelegate(Type collectionType, Type elementType, Type enumerableType) { MethodInfo realMethod = collectionType.GetImmutableEnumerableCreateRangeMethod(elementType); var dynamicMethod = new DynamicMethod( realMethod.Name, collectionType, new[] { enumerableType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Call, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] public override Func<IEnumerable<KeyValuePair<TKey, TValue>>, TCollection> CreateImmutableDictionaryCreateRangeDelegate<TCollection, TKey, TValue>() => CreateDelegate<Func<IEnumerable<KeyValuePair<TKey, TValue>>, TCollection>>( CreateImmutableDictionaryCreateRangeDelegate(typeof(TCollection), typeof(TKey), typeof(TValue), typeof(IEnumerable<KeyValuePair<TKey, TValue>>))); [RequiresUnreferencedCode(IEnumerableConverterFactoryHelpers.ImmutableConvertersUnreferencedCodeMessage)] private static DynamicMethod CreateImmutableDictionaryCreateRangeDelegate(Type collectionType, Type keyType, Type valueType, Type enumerableType) { MethodInfo realMethod = collectionType.GetImmutableDictionaryCreateRangeMethod(keyType, valueType); var dynamicMethod = new DynamicMethod( realMethod.Name, collectionType, new[] { enumerableType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Call, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Func<object, TProperty> CreatePropertyGetter<TProperty>(PropertyInfo propertyInfo) => CreateDelegate<Func<object, TProperty>>(CreatePropertyGetter(propertyInfo, typeof(TProperty))); private static DynamicMethod CreatePropertyGetter(PropertyInfo propertyInfo, Type runtimePropertyType) { MethodInfo? realMethod = propertyInfo.GetMethod; Debug.Assert(realMethod != null); Type? declaringType = propertyInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredPropertyType = propertyInfo.PropertyType; DynamicMethod dynamicMethod = CreateGetterMethod(propertyInfo.Name, runtimePropertyType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); if (declaringType.IsValueType) { generator.Emit(OpCodes.Unbox, declaringType); generator.Emit(OpCodes.Call, realMethod); } else { generator.Emit(OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Callvirt, realMethod); } // declaredPropertyType: Type of the property // runtimePropertyType: <T> of JsonConverter / JsonPropertyInfo if (declaredPropertyType != runtimePropertyType && declaredPropertyType.IsValueType) { // Not supported scenario: possible if declaredPropertyType == int? and runtimePropertyType == int // We should catch that particular case earlier in converter generation. Debug.Assert(!runtimePropertyType.IsValueType); generator.Emit(OpCodes.Box, declaredPropertyType); } generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Action<object, TProperty> CreatePropertySetter<TProperty>(PropertyInfo propertyInfo) => CreateDelegate<Action<object, TProperty>>(CreatePropertySetter(propertyInfo, typeof(TProperty))); private static DynamicMethod CreatePropertySetter(PropertyInfo propertyInfo, Type runtimePropertyType) { MethodInfo? realMethod = propertyInfo.SetMethod; Debug.Assert(realMethod != null); Type? declaringType = propertyInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredPropertyType = propertyInfo.PropertyType; DynamicMethod dynamicMethod = CreateSetterMethod(propertyInfo.Name, runtimePropertyType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(declaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Ldarg_1); // declaredPropertyType: Type of the property // runtimePropertyType: <T> of JsonConverter / JsonPropertyInfo if (declaredPropertyType != runtimePropertyType && declaredPropertyType.IsValueType) { // Not supported scenario: possible if e.g. declaredPropertyType == int? and runtimePropertyType == int // We should catch that particular case earlier in converter generation. Debug.Assert(!runtimePropertyType.IsValueType); generator.Emit(OpCodes.Unbox_Any, declaredPropertyType); } generator.Emit(declaringType.IsValueType ? OpCodes.Call : OpCodes.Callvirt, realMethod); generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Func<object, TProperty> CreateFieldGetter<TProperty>(FieldInfo fieldInfo) => CreateDelegate<Func<object, TProperty>>(CreateFieldGetter(fieldInfo, typeof(TProperty))); private static DynamicMethod CreateFieldGetter(FieldInfo fieldInfo, Type runtimeFieldType) { Type? declaringType = fieldInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredFieldType = fieldInfo.FieldType; DynamicMethod dynamicMethod = CreateGetterMethod(fieldInfo.Name, runtimeFieldType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit( declaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Ldfld, fieldInfo); // declaredFieldType: Type of the field // runtimeFieldType: <T> of JsonConverter / JsonPropertyInfo if (declaredFieldType.IsValueType && declaredFieldType != runtimeFieldType) { generator.Emit(OpCodes.Box, declaredFieldType); } generator.Emit(OpCodes.Ret); return dynamicMethod; } public override Action<object, TProperty> CreateFieldSetter<TProperty>(FieldInfo fieldInfo) => CreateDelegate<Action<object, TProperty>>(CreateFieldSetter(fieldInfo, typeof(TProperty))); private static DynamicMethod CreateFieldSetter(FieldInfo fieldInfo, Type runtimeFieldType) { Type? declaringType = fieldInfo.DeclaringType; Debug.Assert(declaringType != null); Type declaredFieldType = fieldInfo.FieldType; DynamicMethod dynamicMethod = CreateSetterMethod(fieldInfo.Name, runtimeFieldType); ILGenerator generator = dynamicMethod.GetILGenerator(); generator.Emit(OpCodes.Ldarg_0); generator.Emit(declaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, declaringType); generator.Emit(OpCodes.Ldarg_1); // declaredFieldType: Type of the field // runtimeFieldType: <T> of JsonConverter / JsonPropertyInfo if (declaredFieldType != runtimeFieldType && declaredFieldType.IsValueType) { generator.Emit(OpCodes.Unbox_Any, declaredFieldType); } generator.Emit(OpCodes.Stfld, fieldInfo); generator.Emit(OpCodes.Ret); return dynamicMethod; } private static DynamicMethod CreateGetterMethod(string memberName, Type memberType) => new DynamicMethod( memberName + "Getter", memberType, new[] { JsonTypeInfo.ObjectType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); private static DynamicMethod CreateSetterMethod(string memberName, Type memberType) => new DynamicMethod( memberName + "Setter", typeof(void), new[] { JsonTypeInfo.ObjectType, memberType }, typeof(ReflectionEmitMemberAccessor).Module, skipVisibility: true); [return: NotNullIfNotNull("method")] private static T? CreateDelegate<T>(DynamicMethod? method) where T : Delegate => (T?)method?.CreateDelegate(typeof(T)); } } #endif
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Security.Cryptography/tests/StreamHelpers.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.IO; using Test.Cryptography; namespace System.Security.Cryptography.Tests { internal class DataRepeatingStream : Stream { private int _remaining; private byte[] _data; public DataRepeatingStream(string data, int repeatCount) { _remaining = repeatCount; _data = ByteUtils.AsciiBytes(data); } public override int Read(byte[] buffer, int offset, int count) { if (!CanRead) { throw new NotSupportedException(); } if (_remaining == 0) { return 0; } if (count < _data.Length) { throw new InvalidOperationException(); } // For (about) half of the reads, we'll read one less byte // than was asked for. This is to make sure stream readers // conform to the expectation that Read MAY return less than // was asked for. if (count > 1 && Random.Shared.Next(2) == 0) { count--; } int multiple = count / _data.Length; if (multiple > _remaining) { multiple = _remaining; } int localOffset = offset; for (int i = 0; i < multiple; i++) { Buffer.BlockCopy(_data, 0, buffer, localOffset, _data.Length); localOffset += _data.Length; } _remaining -= multiple; return _data.Length * multiple; } protected override void Dispose(bool disposing) { if (disposing) { _data = null; } } public override void Flush() { } public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public override void SetLength(long value) { throw new NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } public override bool CanRead { get { return _data != null; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return false; } } public override long Length { get { throw new NotSupportedException(); } } public override long Position { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } } internal class UntouchableStream : Stream { public static Stream Instance { get; } = new UntouchableStream(); public override bool CanRead => false; public override bool CanSeek => false; public override bool CanWrite => false; public override long Length => throw new NotSupportedException(); public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); } public override void Flush() { throw new NotSupportedException(); } public override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public override void SetLength(long value) { throw new NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.IO; using Test.Cryptography; namespace System.Security.Cryptography.Tests { internal class DataRepeatingStream : Stream { private int _remaining; private byte[] _data; public DataRepeatingStream(string data, int repeatCount) { _remaining = repeatCount; _data = ByteUtils.AsciiBytes(data); } public override int Read(byte[] buffer, int offset, int count) { if (!CanRead) { throw new NotSupportedException(); } if (_remaining == 0) { return 0; } if (count < _data.Length) { throw new InvalidOperationException(); } // For (about) half of the reads, we'll read one less byte // than was asked for. This is to make sure stream readers // conform to the expectation that Read MAY return less than // was asked for. if (count > 1 && Random.Shared.Next(2) == 0) { count--; } int multiple = count / _data.Length; if (multiple > _remaining) { multiple = _remaining; } int localOffset = offset; for (int i = 0; i < multiple; i++) { Buffer.BlockCopy(_data, 0, buffer, localOffset, _data.Length); localOffset += _data.Length; } _remaining -= multiple; return _data.Length * multiple; } protected override void Dispose(bool disposing) { if (disposing) { _data = null; } } public override void Flush() { } public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public override void SetLength(long value) { throw new NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } public override bool CanRead { get { return _data != null; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return false; } } public override long Length { get { throw new NotSupportedException(); } } public override long Position { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } } internal class UntouchableStream : Stream { public static Stream Instance { get; } = new UntouchableStream(); public override bool CanRead => false; public override bool CanSeek => false; public override bool CanWrite => false; public override long Length => throw new NotSupportedException(); public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); } public override void Flush() { throw new NotSupportedException(); } public override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public override void SetLength(long value) { throw new NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/GC/Scenarios/GCSimulator/GCSimulator_61.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <GCStressIncompatible>true</GCStressIncompatible> <CLRTestExecutionArguments>-t 3 -tp 0 -dz 17 -sdz 8500 -dc 10000 -sdc 5000 -lt 4 -dp 0.8 -dw 0.0</CLRTestExecutionArguments> <IsGCSimulatorTest>true</IsGCSimulatorTest> <CLRTestProjectToRun>GCSimulator.csproj</CLRTestProjectToRun> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="GCSimulator.cs" /> <Compile Include="lifetimefx.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <GCStressIncompatible>true</GCStressIncompatible> <CLRTestExecutionArguments>-t 3 -tp 0 -dz 17 -sdz 8500 -dc 10000 -sdc 5000 -lt 4 -dp 0.8 -dw 0.0</CLRTestExecutionArguments> <IsGCSimulatorTest>true</IsGCSimulatorTest> <CLRTestProjectToRun>GCSimulator.csproj</CLRTestProjectToRun> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="GCSimulator.cs" /> <Compile Include="lifetimefx.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TypeForwardedFromAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false, AllowMultiple = false)] public sealed class TypeForwardedFromAttribute : Attribute { public TypeForwardedFromAttribute(string assemblyFullName) { if (string.IsNullOrEmpty(assemblyFullName)) throw new ArgumentNullException(nameof(assemblyFullName)); AssemblyFullName = assemblyFullName; } public string AssemblyFullName { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false, AllowMultiple = false)] public sealed class TypeForwardedFromAttribute : Attribute { public TypeForwardedFromAttribute(string assemblyFullName) { if (string.IsNullOrEmpty(assemblyFullName)) throw new ArgumentNullException(nameof(assemblyFullName)); AssemblyFullName = assemblyFullName; } public string AssemblyFullName { get; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/Methodical/MDArray/DataTypes/bool_cs_d.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="bool.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="bool.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/ReflectionServices.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Reflection; using System.Diagnostics.CodeAnalysis; using System.Diagnostics; namespace Microsoft.Internal { internal static class ReflectionServices { public static Assembly Assembly(this MemberInfo member) { if (member is Type type) { return type.Assembly; } Debug.Assert(member.DeclaringType != null); return member.DeclaringType.Assembly; } public static bool IsVisible(this ConstructorInfo constructor) { return constructor.DeclaringType!.IsVisible && constructor.IsPublic; } public static bool IsVisible(this FieldInfo field) { Debug.Assert(field.DeclaringType != null); return field.DeclaringType.IsVisible && field.IsPublic; } public static bool IsVisible(this MethodInfo method) { Debug.Assert(method.DeclaringType != null); if (!method.DeclaringType.IsVisible) return false; if (!method.IsPublic) return false; if (method.IsGenericMethod) { // Check type arguments, for example if we're passed 'Activator.CreateInstance<SomeMefInternalType>()' foreach (Type typeArgument in method.GetGenericArguments()) { if (!typeArgument.IsVisible) return false; } } return true; } public static string GetDisplayName(Type declaringType!!, string? name) { return declaringType.GetDisplayName() + "." + name; } public static string GetDisplayName(this MemberInfo member!!) { switch (member.MemberType) { case MemberTypes.TypeInfo: case MemberTypes.NestedType: return AttributedModelServices.GetTypeIdentity(((Type)member)); } return GetDisplayName(member.DeclaringType!, member.Name); } internal static bool TryGetGenericInterfaceType(Type instanceType, Type targetOpenInterfaceType, [NotNullWhen(true)] out Type? targetClosedInterfaceType) { // The interface must be open if (!targetOpenInterfaceType.IsInterface || !targetOpenInterfaceType.IsGenericTypeDefinition || instanceType.IsGenericTypeDefinition) { throw new Exception(SR.Diagnostic_InternalExceptionMessage); } // if instanceType is an interface, we must first check it directly if (instanceType.IsInterface && instanceType.IsGenericType && instanceType.UnderlyingSystemType.GetGenericTypeDefinition() == targetOpenInterfaceType.UnderlyingSystemType) { targetClosedInterfaceType = instanceType; return true; } try { // Purposefully not using FullName here because it results in a significantly // more expensive implementation of GetInterface, this does mean that we're // takign the chance that there aren't too many types which implement multiple // interfaces by the same name... Type? targetInterface = instanceType.GetInterface(targetOpenInterfaceType.Name, false); if (targetInterface != null && targetInterface.UnderlyingSystemType.GetGenericTypeDefinition() == targetOpenInterfaceType.UnderlyingSystemType) { targetClosedInterfaceType = targetInterface; return true; } } catch (AmbiguousMatchException) { // If there are multiple with the same name we should not pick any } targetClosedInterfaceType = null; return false; } internal static IEnumerable<PropertyInfo> GetAllProperties(this Type type) { return type.GetInterfaces().Concat(new Type[] { type }).SelectMany(itf => itf.GetProperties()); } internal static IEnumerable<MethodInfo> GetAllMethods(this Type type) { IEnumerable<MethodInfo> declaredMethods = type.GetDeclaredMethods(); Type? baseType = type.BaseType; Debug.Assert(baseType != null); if (baseType.UnderlyingSystemType != typeof(object)) { return declaredMethods.Concat(baseType.GetAllMethods()); } else { return declaredMethods; } } private static IEnumerable<MethodInfo> GetDeclaredMethods(this Type type) { foreach (MethodInfo method in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) { yield return method; } } public static IEnumerable<FieldInfo> GetAllFields(this Type type) { IEnumerable<FieldInfo> declaredFields = type.GetDeclaredFields(); Type? baseType = type.BaseType; Debug.Assert(baseType != null); if (baseType.UnderlyingSystemType != typeof(object)) { return declaredFields.Concat(baseType.GetAllFields()); } else { return declaredFields; } } private static IEnumerable<FieldInfo> GetDeclaredFields(this Type type) { foreach (FieldInfo m in type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) { yield return m; } } internal static bool HasBaseclassOf(this Type? type, Type baseClass) { if (type == baseClass) { return false; } while (type != null) { if (type == baseClass) return true; type = type.BaseType; } return false; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Reflection; using System.Diagnostics.CodeAnalysis; using System.Diagnostics; namespace Microsoft.Internal { internal static class ReflectionServices { public static Assembly Assembly(this MemberInfo member) { if (member is Type type) { return type.Assembly; } Debug.Assert(member.DeclaringType != null); return member.DeclaringType.Assembly; } public static bool IsVisible(this ConstructorInfo constructor) { return constructor.DeclaringType!.IsVisible && constructor.IsPublic; } public static bool IsVisible(this FieldInfo field) { Debug.Assert(field.DeclaringType != null); return field.DeclaringType.IsVisible && field.IsPublic; } public static bool IsVisible(this MethodInfo method) { Debug.Assert(method.DeclaringType != null); if (!method.DeclaringType.IsVisible) return false; if (!method.IsPublic) return false; if (method.IsGenericMethod) { // Check type arguments, for example if we're passed 'Activator.CreateInstance<SomeMefInternalType>()' foreach (Type typeArgument in method.GetGenericArguments()) { if (!typeArgument.IsVisible) return false; } } return true; } public static string GetDisplayName(Type declaringType!!, string? name) { return declaringType.GetDisplayName() + "." + name; } public static string GetDisplayName(this MemberInfo member!!) { switch (member.MemberType) { case MemberTypes.TypeInfo: case MemberTypes.NestedType: return AttributedModelServices.GetTypeIdentity(((Type)member)); } return GetDisplayName(member.DeclaringType!, member.Name); } internal static bool TryGetGenericInterfaceType(Type instanceType, Type targetOpenInterfaceType, [NotNullWhen(true)] out Type? targetClosedInterfaceType) { // The interface must be open if (!targetOpenInterfaceType.IsInterface || !targetOpenInterfaceType.IsGenericTypeDefinition || instanceType.IsGenericTypeDefinition) { throw new Exception(SR.Diagnostic_InternalExceptionMessage); } // if instanceType is an interface, we must first check it directly if (instanceType.IsInterface && instanceType.IsGenericType && instanceType.UnderlyingSystemType.GetGenericTypeDefinition() == targetOpenInterfaceType.UnderlyingSystemType) { targetClosedInterfaceType = instanceType; return true; } try { // Purposefully not using FullName here because it results in a significantly // more expensive implementation of GetInterface, this does mean that we're // takign the chance that there aren't too many types which implement multiple // interfaces by the same name... Type? targetInterface = instanceType.GetInterface(targetOpenInterfaceType.Name, false); if (targetInterface != null && targetInterface.UnderlyingSystemType.GetGenericTypeDefinition() == targetOpenInterfaceType.UnderlyingSystemType) { targetClosedInterfaceType = targetInterface; return true; } } catch (AmbiguousMatchException) { // If there are multiple with the same name we should not pick any } targetClosedInterfaceType = null; return false; } internal static IEnumerable<PropertyInfo> GetAllProperties(this Type type) { return type.GetInterfaces().Concat(new Type[] { type }).SelectMany(itf => itf.GetProperties()); } internal static IEnumerable<MethodInfo> GetAllMethods(this Type type) { IEnumerable<MethodInfo> declaredMethods = type.GetDeclaredMethods(); Type? baseType = type.BaseType; Debug.Assert(baseType != null); if (baseType.UnderlyingSystemType != typeof(object)) { return declaredMethods.Concat(baseType.GetAllMethods()); } else { return declaredMethods; } } private static IEnumerable<MethodInfo> GetDeclaredMethods(this Type type) { foreach (MethodInfo method in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) { yield return method; } } public static IEnumerable<FieldInfo> GetAllFields(this Type type) { IEnumerable<FieldInfo> declaredFields = type.GetDeclaredFields(); Type? baseType = type.BaseType; Debug.Assert(baseType != null); if (baseType.UnderlyingSystemType != typeof(object)) { return declaredFields.Concat(baseType.GetAllFields()); } else { return declaredFields; } } private static IEnumerable<FieldInfo> GetDeclaredFields(this Type type) { foreach (FieldInfo m in type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) { yield return m; } } internal static bool HasBaseclassOf(this Type? type, Type baseClass) { if (type == baseClass) { return false; } while (type != null) { if (type == baseClass) return true; type = type.BaseType; } return false; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/Loader/classloader/generics/Constraints/Regressions/dev10_512868/dev10_512868.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. //Dev10 bug #512868: Invalid context used for generic types during constraint verification leads to BadImageFormatException using System; public class GenericNode { public GenericNode() { } } public interface IFactory<TNode> where TNode : GenericNode { } public static class FactoryGenerator<TNode> where TNode : GenericNode { public static IFactory<TNode> Instance { get { return null; } } } public class ItemX : InternalItemServices<ContainerX, ItemX> { public ItemX() : base() { } } public class ContainerX : InternalContainerServices<ContainerX, ItemX> { public ContainerX() : base() { } } public abstract class InternalItemServices<TContainer, TItem> : ExternalItemServices<TContainer, TItem> where TContainer : GenericNode where TItem : InternalItemServices<TContainer, TItem> { protected InternalItemServices() : base(FactoryGenerator<TContainer>.Instance, FactoryGenerator<TItem>.Instance) { } } public abstract class ExternalItemServices<TContainer, TItem> : GenericNode where TContainer : GenericNode where TItem : GenericNode { protected ExternalItemServices(IFactory<TContainer> containerFactory, IFactory<TItem> itemFactory) : base() { } } public abstract class ExternalContainerServices<TContainer, TItem> : GenericNode where TContainer : GenericNode where TItem : ExternalItemServices<TContainer, TItem> { protected ExternalContainerServices(IFactory<TItem> itemFactory) : base() { } } public abstract class InternalContainerServices<TContainer, TItem> : ExternalContainerServices<TContainer, TItem> where TContainer : GenericNode where TItem : ExternalItemServices<TContainer, TItem> { protected InternalContainerServices() : base(FactoryGenerator<TItem>.Instance) { } } class Test { static int Main(string[] args) { ItemX treeItem = new ItemX(); Console.WriteLine("Pass"); return 100; } } // The inheritance relationships here are a little hard to follow, however // they are valid and in fact map to conceivable usage models. // // Consider a tree structure with the following properties: // // - All tree elements derive from a GenericNode type. // // - The fundamental tree element is an `item'. The children of an item can // be other items or containers. // // - The children of `containers' can only be items, which can in turn have // additional children of item or container type. // // Say that each tree instance is built using exactly one item type and // exactly one corresponding container type. This means the tree structure is // parameterized on the <container, item> pair. // // The hierarchy shape in this testcase could be used to provide services for // a <ContainerX, ItemX> instance of the tree. // ------------ // // // Generates objects of type TNode. // IFactory<TNode> // where TNode: GenericNode // // // // Static class exposing a property returning a factory interface for a // // specific GenericNode subtype. // FactoryGenerator<TNode> // where TNode: GenericNode // // IFactory<TNode> Factory { get; } // // // // Implements this item, inheriting base types parameterized on an arbitrary // // <container, item> pair that implement common operations that can be applied // // to the specified item in the context of that pair. // ItemX : InternalItemServices<ContainerX, ItemX> // // // Implements one level of item services. The item type is constrained to // // be a subclass of this type. This might be useful for various reasons // // (e.g., so that routines here can access private InternalItemServices // // members in any TItem objects that are passed in). // InternalItemServices<TContainer, TItem> : ExternalItemServices<TContainer, TItem> // where TContainer: GenericNode // where TItem: InternalItemServices<TContainer, TItem> (i.e., is the type of a subclass) // // // Pass factories to the base class for both the container and item // // types. // .ctor() : base(FactoryGenerator<TContainer>.Factory, FactoryGenerator<TItem>.Factory) // // // Implements the next level of item services, leveraging container // // and item factories passed to the .ctor (perhaps to generate child // // nodes). // ExternalItemServices<TContainer, TItem> : GenericNode // where TContainer: GenericNode // where TItem: GenericNode // // .ctor(IFactory<TContainer> useToBuildChildContainers, // IFactory<TItem> useToBuildChildItems) // // // // Implements this container, inheriting base types parameterized on an arbitrary // // <container, item> pair that implement common operations that can be applied // // to the specified container in the context of that pair. // ContainerX : InternalContainerServices<ContainerX, ItemX> // // // Implements one level of container services. The item type is // // constrained in a manner forcing it to in fact be an item type that // // includes the common item services supplied for this <container, item> // // pair. // InternalContainerServices<TContainer, TItem> : ExternalContainerServices<TContainer, TItem> // where TContainer: GenericNode // where TItem: ExternalItemServices<TContainer, TItem> // // // Pass an item factory to the base class. // .ctor() : base(FactoryGenerator<TItem>.Factory) // // // Implements the next level of container services, leveraging an item // // factory passed to the .ctor (perhaps to generate child nodes). // // // // The item type is again constrained in a manner forcing it to in // // fact be an item type that includes the common item services // // supplied for this <container, item> pair. // ExternalContainerServices<TContainer, TItem> : GenericNode // where TContainer: GenericNode // where TItem: ExternalItemServices<TContainer, TItem> // // .ctor(IFactory<TItem> useToBuildChildItems) //
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. //Dev10 bug #512868: Invalid context used for generic types during constraint verification leads to BadImageFormatException using System; public class GenericNode { public GenericNode() { } } public interface IFactory<TNode> where TNode : GenericNode { } public static class FactoryGenerator<TNode> where TNode : GenericNode { public static IFactory<TNode> Instance { get { return null; } } } public class ItemX : InternalItemServices<ContainerX, ItemX> { public ItemX() : base() { } } public class ContainerX : InternalContainerServices<ContainerX, ItemX> { public ContainerX() : base() { } } public abstract class InternalItemServices<TContainer, TItem> : ExternalItemServices<TContainer, TItem> where TContainer : GenericNode where TItem : InternalItemServices<TContainer, TItem> { protected InternalItemServices() : base(FactoryGenerator<TContainer>.Instance, FactoryGenerator<TItem>.Instance) { } } public abstract class ExternalItemServices<TContainer, TItem> : GenericNode where TContainer : GenericNode where TItem : GenericNode { protected ExternalItemServices(IFactory<TContainer> containerFactory, IFactory<TItem> itemFactory) : base() { } } public abstract class ExternalContainerServices<TContainer, TItem> : GenericNode where TContainer : GenericNode where TItem : ExternalItemServices<TContainer, TItem> { protected ExternalContainerServices(IFactory<TItem> itemFactory) : base() { } } public abstract class InternalContainerServices<TContainer, TItem> : ExternalContainerServices<TContainer, TItem> where TContainer : GenericNode where TItem : ExternalItemServices<TContainer, TItem> { protected InternalContainerServices() : base(FactoryGenerator<TItem>.Instance) { } } class Test { static int Main(string[] args) { ItemX treeItem = new ItemX(); Console.WriteLine("Pass"); return 100; } } // The inheritance relationships here are a little hard to follow, however // they are valid and in fact map to conceivable usage models. // // Consider a tree structure with the following properties: // // - All tree elements derive from a GenericNode type. // // - The fundamental tree element is an `item'. The children of an item can // be other items or containers. // // - The children of `containers' can only be items, which can in turn have // additional children of item or container type. // // Say that each tree instance is built using exactly one item type and // exactly one corresponding container type. This means the tree structure is // parameterized on the <container, item> pair. // // The hierarchy shape in this testcase could be used to provide services for // a <ContainerX, ItemX> instance of the tree. // ------------ // // // Generates objects of type TNode. // IFactory<TNode> // where TNode: GenericNode // // // // Static class exposing a property returning a factory interface for a // // specific GenericNode subtype. // FactoryGenerator<TNode> // where TNode: GenericNode // // IFactory<TNode> Factory { get; } // // // // Implements this item, inheriting base types parameterized on an arbitrary // // <container, item> pair that implement common operations that can be applied // // to the specified item in the context of that pair. // ItemX : InternalItemServices<ContainerX, ItemX> // // // Implements one level of item services. The item type is constrained to // // be a subclass of this type. This might be useful for various reasons // // (e.g., so that routines here can access private InternalItemServices // // members in any TItem objects that are passed in). // InternalItemServices<TContainer, TItem> : ExternalItemServices<TContainer, TItem> // where TContainer: GenericNode // where TItem: InternalItemServices<TContainer, TItem> (i.e., is the type of a subclass) // // // Pass factories to the base class for both the container and item // // types. // .ctor() : base(FactoryGenerator<TContainer>.Factory, FactoryGenerator<TItem>.Factory) // // // Implements the next level of item services, leveraging container // // and item factories passed to the .ctor (perhaps to generate child // // nodes). // ExternalItemServices<TContainer, TItem> : GenericNode // where TContainer: GenericNode // where TItem: GenericNode // // .ctor(IFactory<TContainer> useToBuildChildContainers, // IFactory<TItem> useToBuildChildItems) // // // // Implements this container, inheriting base types parameterized on an arbitrary // // <container, item> pair that implement common operations that can be applied // // to the specified container in the context of that pair. // ContainerX : InternalContainerServices<ContainerX, ItemX> // // // Implements one level of container services. The item type is // // constrained in a manner forcing it to in fact be an item type that // // includes the common item services supplied for this <container, item> // // pair. // InternalContainerServices<TContainer, TItem> : ExternalContainerServices<TContainer, TItem> // where TContainer: GenericNode // where TItem: ExternalItemServices<TContainer, TItem> // // // Pass an item factory to the base class. // .ctor() : base(FactoryGenerator<TItem>.Factory) // // // Implements the next level of container services, leveraging an item // // factory passed to the .ctor (perhaps to generate child nodes). // // // // The item type is again constrained in a manner forcing it to in // // fact be an item type that includes the common item services // // supplied for this <container, item> pair. // ExternalContainerServices<TContainer, TItem> : GenericNode // where TContainer: GenericNode // where TItem: ExternalItemServices<TContainer, TItem> // // .ctor(IFactory<TItem> useToBuildChildItems) //
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/General/Vector64/Widen.UInt16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void WidenUInt16() { var test = new VectorWidenTest__WidenUInt16(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorWidenTest__WidenUInt16 { private struct DataTable { private byte[] inArray1; private byte[] outLowerArray; private byte[] outUpperArray; private GCHandle inHandle1; private GCHandle outLowerHandle; private GCHandle outUpperHandle; private ulong alignment; public DataTable(Byte[] inArray1, UInt16[] outLowerArray, UInt16[] outUpperArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutLowerArray = outLowerArray.Length * Unsafe.SizeOf<UInt16>(); int sizeOfoutUpperArray = outUpperArray.Length * Unsafe.SizeOf<UInt16>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutLowerArray|| (alignment * 2) < sizeOfoutUpperArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.outLowerArray = new byte[alignment * 2]; this.outUpperArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.outLowerHandle = GCHandle.Alloc(this.outLowerArray, GCHandleType.Pinned); this.outUpperHandle = GCHandle.Alloc(this.outUpperArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* outLowerArrayPtr => Align((byte*)(outLowerHandle.AddrOfPinnedObject().ToPointer()), alignment); public void* outUpperArrayPtr => Align((byte*)(outUpperHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); outLowerHandle.Free(); outUpperHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Byte> _fld1; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(VectorWidenTest__WidenUInt16 testClass) { var result = Vector64.Widen(_fld1); Unsafe.Write(testClass._dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(testClass._dataTable.outUpperArrayPtr, result.Upper); testClass.ValidateResult(_fld1, testClass._dataTable.outLowerArrayPtr, testClass._dataTable.outUpperArrayPtr); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt16>>() / sizeof(UInt16); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Vector64<Byte> _clsVar1; private Vector64<Byte> _fld1; private DataTable _dataTable; static VectorWidenTest__WidenUInt16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public VectorWidenTest__WidenUInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, new UInt16[RetElementCount], new UInt16[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.Widen( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr) ); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector64).GetMethod(nameof(Vector64.Widen), new Type[] { typeof(Vector64<Byte>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.Widen), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(UInt16)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr) }); Unsafe.Write(_dataTable.outLowerArrayPtr, (((Vector64<UInt16> Lower, Vector64<UInt16> Upper))(result)).Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, (((Vector64<UInt16> Lower, Vector64<UInt16> Upper))(result)).Upper); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.Widen( _clsVar1 ); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(_clsVar1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr); var result = Vector64.Widen(op1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(op1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorWidenTest__WidenUInt16(); var result = Vector64.Widen(test._fld1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(test._fld1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector64.Widen(_fld1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(_fld1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector64.Widen(test._fld1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(test._fld1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector64<Byte> op1, void* lowerResult, void* upperResult, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; UInt16[] outLowerArray = new UInt16[RetElementCount]; UInt16[] outUpperArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outLowerArray[0]), ref Unsafe.AsRef<byte>(lowerResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outUpperArray[0]), ref Unsafe.AsRef<byte>(upperResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); ValidateResult(inArray1, outLowerArray, outUpperArray, method); } private void ValidateResult(void* op1, void* lowerResult, void* upperResult, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; UInt16[] outLowerArray = new UInt16[RetElementCount]; UInt16[] outUpperArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outLowerArray[0]), ref Unsafe.AsRef<byte>(lowerResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outUpperArray[0]), ref Unsafe.AsRef<byte>(upperResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); ValidateResult(inArray1, outLowerArray, outUpperArray, method); } private void ValidateResult(Byte[] firstOp, UInt16[] lowerResult, UInt16[] upperResult, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (lowerResult[i] != (ushort)(firstOp[i])) { succeeded = false; break; } } for (var i = 0; i < RetElementCount; i++) { if (upperResult[i] != (ushort)(firstOp[i + RetElementCount])) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.Widen)}<UInt16>(Vector64<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" lowerResult: ({string.Join(", ", lowerResult)})"); TestLibrary.TestFramework.LogInformation($" upperResult: ({string.Join(", ", upperResult)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void WidenUInt16() { var test = new VectorWidenTest__WidenUInt16(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorWidenTest__WidenUInt16 { private struct DataTable { private byte[] inArray1; private byte[] outLowerArray; private byte[] outUpperArray; private GCHandle inHandle1; private GCHandle outLowerHandle; private GCHandle outUpperHandle; private ulong alignment; public DataTable(Byte[] inArray1, UInt16[] outLowerArray, UInt16[] outUpperArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutLowerArray = outLowerArray.Length * Unsafe.SizeOf<UInt16>(); int sizeOfoutUpperArray = outUpperArray.Length * Unsafe.SizeOf<UInt16>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutLowerArray|| (alignment * 2) < sizeOfoutUpperArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.outLowerArray = new byte[alignment * 2]; this.outUpperArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.outLowerHandle = GCHandle.Alloc(this.outLowerArray, GCHandleType.Pinned); this.outUpperHandle = GCHandle.Alloc(this.outUpperArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* outLowerArrayPtr => Align((byte*)(outLowerHandle.AddrOfPinnedObject().ToPointer()), alignment); public void* outUpperArrayPtr => Align((byte*)(outUpperHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); outLowerHandle.Free(); outUpperHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Byte> _fld1; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(VectorWidenTest__WidenUInt16 testClass) { var result = Vector64.Widen(_fld1); Unsafe.Write(testClass._dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(testClass._dataTable.outUpperArrayPtr, result.Upper); testClass.ValidateResult(_fld1, testClass._dataTable.outLowerArrayPtr, testClass._dataTable.outUpperArrayPtr); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt16>>() / sizeof(UInt16); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Vector64<Byte> _clsVar1; private Vector64<Byte> _fld1; private DataTable _dataTable; static VectorWidenTest__WidenUInt16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public VectorWidenTest__WidenUInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, new UInt16[RetElementCount], new UInt16[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.Widen( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr) ); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector64).GetMethod(nameof(Vector64.Widen), new Type[] { typeof(Vector64<Byte>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.Widen), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(UInt16)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr) }); Unsafe.Write(_dataTable.outLowerArrayPtr, (((Vector64<UInt16> Lower, Vector64<UInt16> Upper))(result)).Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, (((Vector64<UInt16> Lower, Vector64<UInt16> Upper))(result)).Upper); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.Widen( _clsVar1 ); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(_clsVar1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr); var result = Vector64.Widen(op1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(op1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorWidenTest__WidenUInt16(); var result = Vector64.Widen(test._fld1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(test._fld1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector64.Widen(_fld1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(_fld1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector64.Widen(test._fld1); Unsafe.Write(_dataTable.outLowerArrayPtr, result.Lower); Unsafe.Write(_dataTable.outUpperArrayPtr, result.Upper); ValidateResult(test._fld1, _dataTable.outLowerArrayPtr, _dataTable.outUpperArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector64<Byte> op1, void* lowerResult, void* upperResult, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; UInt16[] outLowerArray = new UInt16[RetElementCount]; UInt16[] outUpperArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outLowerArray[0]), ref Unsafe.AsRef<byte>(lowerResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outUpperArray[0]), ref Unsafe.AsRef<byte>(upperResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); ValidateResult(inArray1, outLowerArray, outUpperArray, method); } private void ValidateResult(void* op1, void* lowerResult, void* upperResult, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; UInt16[] outLowerArray = new UInt16[RetElementCount]; UInt16[] outUpperArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outLowerArray[0]), ref Unsafe.AsRef<byte>(lowerResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outUpperArray[0]), ref Unsafe.AsRef<byte>(upperResult), (uint)Unsafe.SizeOf<Vector64<UInt16>>()); ValidateResult(inArray1, outLowerArray, outUpperArray, method); } private void ValidateResult(Byte[] firstOp, UInt16[] lowerResult, UInt16[] upperResult, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (lowerResult[i] != (ushort)(firstOp[i])) { succeeded = false; break; } } for (var i = 0; i < RetElementCount; i++) { if (upperResult[i] != (ushort)(firstOp[i + RetElementCount])) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.Widen)}<UInt16>(Vector64<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" lowerResult: ({string.Join(", ", lowerResult)})"); TestLibrary.TestFramework.LogInformation($" upperResult: ({string.Join(", ", upperResult)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/Loader/classloader/generics/Misc/TestWithManyParams.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // test large number of generic paramters //test large number of nested generic type isntantiations using System; public class Test_TestWithManyParams { public static int i = 0; public static int Main() { int ret1, ret2; try { IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>> t = new Child<int>(); Console.WriteLine("Test1: PASS"); ret1 = 100; } catch (Exception e) { Console.WriteLine("Test1 FAIL: Caught unexpected exception - " + e); ret1 = 101; } try { IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>> t2 = new Child2<int>(); ret2 = 100; Console.WriteLine("Test2: PASS"); } catch (Exception e) { Console.WriteLine("Test2 FAIL: Caught unexpected exception - " + e); ret2 = 101; } if (ret1 == 100 && ret2 == 100) { return 100; } else { Console.WriteLine("FAIL"); return 101; } } } public class GenTypes { public IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>> iParent_Nested; public Child<int> child_int; public IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>> iParent2ManyParams; public Child2<int> child2_int; } public interface IParent<T> { void Method1<Sa>() ; } public interface IParent2<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z> { void Method1<Sa>() ; } public class Child<T> : IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>> { void IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.Method1<Sa>() {} } public class Child2<T> : IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>> { void IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>>.Method1<Sa>() {} }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // test large number of generic paramters //test large number of nested generic type isntantiations using System; public class Test_TestWithManyParams { public static int i = 0; public static int Main() { int ret1, ret2; try { IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>> t = new Child<int>(); Console.WriteLine("Test1: PASS"); ret1 = 100; } catch (Exception e) { Console.WriteLine("Test1 FAIL: Caught unexpected exception - " + e); ret1 = 101; } try { IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>> t2 = new Child2<int>(); ret2 = 100; Console.WriteLine("Test2: PASS"); } catch (Exception e) { Console.WriteLine("Test2 FAIL: Caught unexpected exception - " + e); ret2 = 101; } if (ret1 == 100 && ret2 == 100) { return 100; } else { Console.WriteLine("FAIL"); return 101; } } } public class GenTypes { public IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>> iParent_Nested; public Child<int> child_int; public IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>> iParent2ManyParams; public Child2<int> child2_int; } public interface IParent<T> { void Method1<Sa>() ; } public interface IParent2<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z> { void Method1<Sa>() ; } public class Child<T> : IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>> { void IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<IParent<int>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.Method1<Sa>() {} } public class Child2<T> : IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>> { void IParent2<int,double,String, Object, char, uint, Guid, bool, IParent<int>, IParent<double>, IParent<String>, IParent<Object>, IParent<char>, IParent<uint>, IParent<Guid>,IParent<bool>,IParent<IParent<int>>,IParent<IParent<double>>,IParent<IParent<String>>,IParent<IParent<Object>>, IParent<IParent<char>>,IParent<IParent<uint>>,IParent<IParent<Guid>>,IParent<IParent<bool>>,IParent<char>,IParent<int>>.Method1<Sa>() {} }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/X86/Sse2/SqrtScalar_ro.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup> <DebugType>Embedded</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="SqrtScalar.cs" /> <Compile Include="TestTableSse2.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup> <DebugType>Embedded</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="SqrtScalar.cs" /> <Compile Include="TestTableSse2.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/installer/tests/Assets/TestProjects/StandaloneApp3x/Program.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace StandaloneApp { public static class Program { public static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace StandaloneApp { public static class Program { public static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderIsGenericTypeDefinition.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Reflection.Emit.Tests { public class TypeBuilderIsGenericTypeDefinition { [Fact] public void IsGenericTypeDefinition_GenericType_ReturnsTrue() { ModuleBuilder module = Helpers.DynamicModule(); TypeBuilder type1 = module.DefineType("Sample", TypeAttributes.Class | TypeAttributes.Public); GenericTypeParameterBuilder[] typeParams = type1.DefineGenericParameters("T"); ConstructorBuilder ctor = type1.DefineDefaultConstructor(MethodAttributes.PrivateScope | MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName); FieldBuilder field = type1.DefineField("Field", typeParams[0].AsType(), FieldAttributes.Public); MethodBuilder genericMethod = type1.DefineMethod("GM", MethodAttributes.Public | MethodAttributes.Static); GenericTypeParameterBuilder[] methodParams = genericMethod.DefineGenericParameters("U"); genericMethod.SetSignature(null, null, null, new Type[] { methodParams[0].AsType() }, null, null); ILGenerator ilGenerator = genericMethod.GetILGenerator(); Type genericUType = type1.MakeGenericType(methodParams[0].AsType()); ilGenerator.DeclareLocal(genericUType); ConstructorInfo genericUConstructor = TypeBuilder.GetConstructor(genericUType, ctor); ilGenerator.Emit(OpCodes.Newobj, genericUConstructor); ilGenerator.Emit(OpCodes.Stloc_0); ilGenerator.Emit(OpCodes.Ldloc_0); ilGenerator.Emit(OpCodes.Ldarg_0); FieldInfo genericUField = TypeBuilder.GetField(genericUType, field); ilGenerator.Emit(OpCodes.Stfld, genericUField); ilGenerator.Emit(OpCodes.Ldloc_0); ilGenerator.Emit(OpCodes.Ldfld, genericUField); ilGenerator.Emit(OpCodes.Box, methodParams[0].AsType()); MethodInfo writeLineObj = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(object) }); ilGenerator.EmitCall(OpCodes.Call, writeLineObj, null); ilGenerator.Emit(OpCodes.Ret); TypeBuilder type2 = module.DefineType("Dummy", TypeAttributes.Class | TypeAttributes.NotPublic); MethodBuilder entryPoint = type2.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, null, null); ilGenerator = entryPoint.GetILGenerator(); Type genericIntType = type1.MakeGenericType(typeof(int)); MethodInfo genericIntMethod = TypeBuilder.GetMethod(genericIntType, genericMethod); MethodInfo genericStringMethod = genericIntMethod.MakeGenericMethod(typeof(string)); ilGenerator.Emit(OpCodes.Ldstr, "Hello, world!"); ilGenerator.EmitCall(OpCodes.Call, genericStringMethod, null); ilGenerator.Emit(OpCodes.Ret); type1.CreateTypeInfo().AsType(); Assert.True(type1.IsGenericTypeDefinition); } [Fact] public void IsGenericTypeDefinition_NonGenericType_ReturnsFalse() { TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public); MethodBuilder method = type.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, null, null); ILGenerator ilGenerator = method.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldstr, "Test string here."); MethodInfo writeLine = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }); ilGenerator.EmitCall(OpCodes.Call, writeLine, null); ilGenerator.Emit(OpCodes.Ret); type.CreateTypeInfo().AsType(); Assert.False(type.IsGenericTypeDefinition); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Reflection.Emit.Tests { public class TypeBuilderIsGenericTypeDefinition { [Fact] public void IsGenericTypeDefinition_GenericType_ReturnsTrue() { ModuleBuilder module = Helpers.DynamicModule(); TypeBuilder type1 = module.DefineType("Sample", TypeAttributes.Class | TypeAttributes.Public); GenericTypeParameterBuilder[] typeParams = type1.DefineGenericParameters("T"); ConstructorBuilder ctor = type1.DefineDefaultConstructor(MethodAttributes.PrivateScope | MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName); FieldBuilder field = type1.DefineField("Field", typeParams[0].AsType(), FieldAttributes.Public); MethodBuilder genericMethod = type1.DefineMethod("GM", MethodAttributes.Public | MethodAttributes.Static); GenericTypeParameterBuilder[] methodParams = genericMethod.DefineGenericParameters("U"); genericMethod.SetSignature(null, null, null, new Type[] { methodParams[0].AsType() }, null, null); ILGenerator ilGenerator = genericMethod.GetILGenerator(); Type genericUType = type1.MakeGenericType(methodParams[0].AsType()); ilGenerator.DeclareLocal(genericUType); ConstructorInfo genericUConstructor = TypeBuilder.GetConstructor(genericUType, ctor); ilGenerator.Emit(OpCodes.Newobj, genericUConstructor); ilGenerator.Emit(OpCodes.Stloc_0); ilGenerator.Emit(OpCodes.Ldloc_0); ilGenerator.Emit(OpCodes.Ldarg_0); FieldInfo genericUField = TypeBuilder.GetField(genericUType, field); ilGenerator.Emit(OpCodes.Stfld, genericUField); ilGenerator.Emit(OpCodes.Ldloc_0); ilGenerator.Emit(OpCodes.Ldfld, genericUField); ilGenerator.Emit(OpCodes.Box, methodParams[0].AsType()); MethodInfo writeLineObj = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(object) }); ilGenerator.EmitCall(OpCodes.Call, writeLineObj, null); ilGenerator.Emit(OpCodes.Ret); TypeBuilder type2 = module.DefineType("Dummy", TypeAttributes.Class | TypeAttributes.NotPublic); MethodBuilder entryPoint = type2.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, null, null); ilGenerator = entryPoint.GetILGenerator(); Type genericIntType = type1.MakeGenericType(typeof(int)); MethodInfo genericIntMethod = TypeBuilder.GetMethod(genericIntType, genericMethod); MethodInfo genericStringMethod = genericIntMethod.MakeGenericMethod(typeof(string)); ilGenerator.Emit(OpCodes.Ldstr, "Hello, world!"); ilGenerator.EmitCall(OpCodes.Call, genericStringMethod, null); ilGenerator.Emit(OpCodes.Ret); type1.CreateTypeInfo().AsType(); Assert.True(type1.IsGenericTypeDefinition); } [Fact] public void IsGenericTypeDefinition_NonGenericType_ReturnsFalse() { TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public); MethodBuilder method = type.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, null, null); ILGenerator ilGenerator = method.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldstr, "Test string here."); MethodInfo writeLine = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }); ilGenerator.EmitCall(OpCodes.Call, writeLine, null); ilGenerator.Emit(OpCodes.Ret); type.CreateTypeInfo().AsType(); Assert.False(type.IsGenericTypeDefinition); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Data.OleDb/src/OleDbException.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization; using System.Text; namespace System.Data.OleDb { public sealed class OleDbException : System.Data.Common.DbException { private readonly OleDbErrorCollection oledbErrors; internal OleDbException(string? message, OleDbHResult errorCode, Exception? inner) : base(message, inner) { HResult = (int)errorCode; this.oledbErrors = new OleDbErrorCollection(null); } internal OleDbException(OleDbException previous, Exception? inner) : base(previous.Message, inner) { HResult = previous.ErrorCode; this.oledbErrors = previous.oledbErrors; } private OleDbException(string? message, Exception? inner, string? source, OleDbHResult errorCode, OleDbErrorCollection errors) : base(message, inner) { Debug.Assert(null != errors, "OleDbException without OleDbErrorCollection"); Source = source; HResult = (int)errorCode; this.oledbErrors = errors; } public override void GetObjectData(SerializationInfo si!!, StreamingContext context) { si.AddValue("oledbErrors", oledbErrors, typeof(OleDbErrorCollection)); base.GetObjectData(si, context); } [TypeConverter(typeof(ErrorCodeConverter))] public override int ErrorCode { get { return base.ErrorCode; } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public OleDbErrorCollection Errors { get { OleDbErrorCollection errors = this.oledbErrors; return ((null != errors) ? errors : new OleDbErrorCollection(null)); } } internal static OleDbException CreateException(UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode, Exception? inner) { OleDbErrorCollection errors = new OleDbErrorCollection(errorInfo); errorInfo.GetDescription(out string? message); errorInfo.GetSource(out string? source); int count = errors.Count; if (0 < errors.Count) { StringBuilder builder = new StringBuilder(); if ((null != message) && (message != errors[0].Message)) { builder.Append(message.TrimEnd(ODB.ErrorTrimCharacters)); if (1 < count) { builder.Append(Environment.NewLine); } } for (int i = 0; i < count; ++i) { if (0 < i) { builder.Append(Environment.NewLine); } builder.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters)); } message = builder.ToString(); } if (ADP.IsEmpty(message)) { message = ODB.NoErrorMessage(errorCode); } return new OleDbException(message, inner, source, errorCode, errors); } internal static OleDbException CombineExceptions(List<OleDbException> exceptions) { Debug.Assert(0 < exceptions.Count, "missing exceptions"); if (1 < exceptions.Count) { OleDbErrorCollection errors = new OleDbErrorCollection(null); StringBuilder builder = new StringBuilder(); foreach (OleDbException exception in exceptions) { errors.AddRange(exception.Errors); builder.Append(exception.Message); builder.Append(Environment.NewLine); } return new OleDbException(builder.ToString(), null, exceptions[0].Source, (OleDbHResult)exceptions[0].ErrorCode, errors); } else { return exceptions[0]; } } internal sealed class ErrorCodeConverter : Int32Converter { // converter classes should have public ctor public ErrorCodeConverter() { } public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (destinationType == null) { throw ADP.ArgumentNull("destinationType"); } if ((destinationType == typeof(string)) && (value != null) && (value is int)) { return ODB.ELookup((OleDbHResult)value); } return base.ConvertTo(context, culture, value, destinationType); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Runtime.Serialization; using System.Text; namespace System.Data.OleDb { public sealed class OleDbException : System.Data.Common.DbException { private readonly OleDbErrorCollection oledbErrors; internal OleDbException(string? message, OleDbHResult errorCode, Exception? inner) : base(message, inner) { HResult = (int)errorCode; this.oledbErrors = new OleDbErrorCollection(null); } internal OleDbException(OleDbException previous, Exception? inner) : base(previous.Message, inner) { HResult = previous.ErrorCode; this.oledbErrors = previous.oledbErrors; } private OleDbException(string? message, Exception? inner, string? source, OleDbHResult errorCode, OleDbErrorCollection errors) : base(message, inner) { Debug.Assert(null != errors, "OleDbException without OleDbErrorCollection"); Source = source; HResult = (int)errorCode; this.oledbErrors = errors; } public override void GetObjectData(SerializationInfo si!!, StreamingContext context) { si.AddValue("oledbErrors", oledbErrors, typeof(OleDbErrorCollection)); base.GetObjectData(si, context); } [TypeConverter(typeof(ErrorCodeConverter))] public override int ErrorCode { get { return base.ErrorCode; } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public OleDbErrorCollection Errors { get { OleDbErrorCollection errors = this.oledbErrors; return ((null != errors) ? errors : new OleDbErrorCollection(null)); } } internal static OleDbException CreateException(UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode, Exception? inner) { OleDbErrorCollection errors = new OleDbErrorCollection(errorInfo); errorInfo.GetDescription(out string? message); errorInfo.GetSource(out string? source); int count = errors.Count; if (0 < errors.Count) { StringBuilder builder = new StringBuilder(); if ((null != message) && (message != errors[0].Message)) { builder.Append(message.TrimEnd(ODB.ErrorTrimCharacters)); if (1 < count) { builder.Append(Environment.NewLine); } } for (int i = 0; i < count; ++i) { if (0 < i) { builder.Append(Environment.NewLine); } builder.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters)); } message = builder.ToString(); } if (ADP.IsEmpty(message)) { message = ODB.NoErrorMessage(errorCode); } return new OleDbException(message, inner, source, errorCode, errors); } internal static OleDbException CombineExceptions(List<OleDbException> exceptions) { Debug.Assert(0 < exceptions.Count, "missing exceptions"); if (1 < exceptions.Count) { OleDbErrorCollection errors = new OleDbErrorCollection(null); StringBuilder builder = new StringBuilder(); foreach (OleDbException exception in exceptions) { errors.AddRange(exception.Errors); builder.Append(exception.Message); builder.Append(Environment.NewLine); } return new OleDbException(builder.ToString(), null, exceptions[0].Source, (OleDbHResult)exceptions[0].ErrorCode, errors); } else { return exceptions[0]; } } internal sealed class ErrorCodeConverter : Int32Converter { // converter classes should have public ctor public ErrorCodeConverter() { } public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (destinationType == null) { throw ADP.ArgumentNull("destinationType"); } if ((destinationType == typeof(string)) && (value != null) && (value is int)) { return ODB.ELookup((OleDbHResult)value); } return base.ConvertTo(context, culture, value, destinationType); } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/Directed/pinvoke/sin.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace JitTest { using System; using System.Text; using System.Runtime.InteropServices; internal class Test { [DllImport("msvcrt", EntryPoint = "sin", CallingConvention = CallingConvention.Cdecl)] private static extern double sin(double x); [DllImport("msvcrt", EntryPoint = "acos", CallingConvention = CallingConvention.Cdecl)] private static extern double acos(double x); private static int Main() { for (double x = 0.0; x <= 3.1415926535897; x += 0.14) { if (Math.Abs(sin(x) - Math.Sin(x)) > 0.00001) { Console.WriteLine("=== FAILED ==="); Console.WriteLine("for x = " + x.ToString()); return 101; } } for (double x = -1.0; x <= 1.0; x += 0.1) { if (Math.Abs(acos(x) - Math.Acos(x)) > 0.00001) { Console.WriteLine("=== FAILED ==="); Console.WriteLine("for x = " + x.ToString()); return 102; } } Console.WriteLine("=== PASSED ==="); return 100; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace JitTest { using System; using System.Text; using System.Runtime.InteropServices; internal class Test { [DllImport("msvcrt", EntryPoint = "sin", CallingConvention = CallingConvention.Cdecl)] private static extern double sin(double x); [DllImport("msvcrt", EntryPoint = "acos", CallingConvention = CallingConvention.Cdecl)] private static extern double acos(double x); private static int Main() { for (double x = 0.0; x <= 3.1415926535897; x += 0.14) { if (Math.Abs(sin(x) - Math.Sin(x)) > 0.00001) { Console.WriteLine("=== FAILED ==="); Console.WriteLine("for x = " + x.ToString()); return 101; } } for (double x = -1.0; x <= 1.0; x += 0.1) { if (Math.Abs(acos(x) - Math.Acos(x)) > 0.00001) { Console.WriteLine("=== FAILED ==="); Console.WriteLine("for x = " + x.ToString()); return 102; } } Console.WriteLine("=== PASSED ==="); return 100; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/Arm/Dp/DotProduct.Vector128.Int32.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void DotProduct_Vector128_Int32() { var test = new SimpleTernaryOpTest__DotProduct_Vector128_Int32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleTernaryOpTest__DotProduct_Vector128_Int32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] inArray3; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle inHandle3; private GCHandle outHandle; private ulong alignment; public DataTable(Int32[] inArray1, SByte[] inArray2, SByte[] inArray3, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<SByte>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<SByte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inArray3 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<SByte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<SByte, byte>(ref inArray3[0]), (uint)sizeOfinArray3); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); inHandle3.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int32> _fld1; public Vector128<SByte> _fld2; public Vector128<SByte> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld3), ref Unsafe.As<SByte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); return testStruct; } public void RunStructFldScenario(SimpleTernaryOpTest__DotProduct_Vector128_Int32 testClass) { var result = Dp.DotProduct(_fld1, _fld2, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleTernaryOpTest__DotProduct_Vector128_Int32 testClass) { fixed (Vector128<Int32>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) fixed (Vector128<SByte>* pFld3 = &_fld3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pFld1)), AdvSimd.LoadVector128((SByte*)(pFld2)), AdvSimd.LoadVector128((SByte*)(pFld3)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static readonly int Op3ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static Int32[] _data1 = new Int32[Op1ElementCount]; private static SByte[] _data2 = new SByte[Op2ElementCount]; private static SByte[] _data3 = new SByte[Op3ElementCount]; private static Vector128<Int32> _clsVar1; private static Vector128<SByte> _clsVar2; private static Vector128<SByte> _clsVar3; private Vector128<Int32> _fld1; private Vector128<SByte> _fld2; private Vector128<SByte> _fld3; private DataTable _dataTable; static SimpleTernaryOpTest__DotProduct_Vector128_Int32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar3), ref Unsafe.As<SByte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); } public SimpleTernaryOpTest__DotProduct_Vector128_Int32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld3), ref Unsafe.As<SByte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } _dataTable = new DataTable(_data1, _data2, _data3, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => Dp.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Dp.DotProduct( Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Dp).GetMethod(nameof(Dp.DotProduct), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Dp).GetMethod(nameof(Dp.DotProduct), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Dp.DotProduct( _clsVar1, _clsVar2, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int32>* pClsVar1 = &_clsVar1) fixed (Vector128<SByte>* pClsVar2 = &_clsVar2) fixed (Vector128<SByte>* pClsVar3 = &_clsVar3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pClsVar1)), AdvSimd.LoadVector128((SByte*)(pClsVar2)), AdvSimd.LoadVector128((SByte*)(pClsVar3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr); var op3 = Unsafe.Read<Vector128<SByte>>(_dataTable.inArray3Ptr); var result = Dp.DotProduct(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)); var op3 = AdvSimd.LoadVector128((SByte*)(_dataTable.inArray3Ptr)); var result = Dp.DotProduct(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleTernaryOpTest__DotProduct_Vector128_Int32(); var result = Dp.DotProduct(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleTernaryOpTest__DotProduct_Vector128_Int32(); fixed (Vector128<Int32>* pFld1 = &test._fld1) fixed (Vector128<SByte>* pFld2 = &test._fld2) fixed (Vector128<SByte>* pFld3 = &test._fld3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pFld1)), AdvSimd.LoadVector128((SByte*)(pFld2)), AdvSimd.LoadVector128((SByte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Dp.DotProduct(_fld1, _fld2, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int32>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) fixed (Vector128<SByte>* pFld3 = &_fld3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pFld1)), AdvSimd.LoadVector128((SByte*)(pFld2)), AdvSimd.LoadVector128((SByte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Dp.DotProduct(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(&test._fld1)), AdvSimd.LoadVector128((SByte*)(&test._fld2)), AdvSimd.LoadVector128((SByte*)(&test._fld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int32> op1, Vector128<SByte> op2, Vector128<SByte> op3, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] inArray3 = new SByte[Op3ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), op2); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] inArray3 = new SByte[Op3ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(Int32[] firstOp, SByte[] secondOp, SByte[] thirdOp, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.DotProduct(firstOp[i], secondOp, 4 * i, thirdOp, 4 * i) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Dp)}.{nameof(Dp.DotProduct)}<Int32>(Vector128<Int32>, Vector128<SByte>, Vector128<SByte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void DotProduct_Vector128_Int32() { var test = new SimpleTernaryOpTest__DotProduct_Vector128_Int32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleTernaryOpTest__DotProduct_Vector128_Int32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] inArray3; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle inHandle3; private GCHandle outHandle; private ulong alignment; public DataTable(Int32[] inArray1, SByte[] inArray2, SByte[] inArray3, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<SByte>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<SByte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inArray3 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<SByte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<SByte, byte>(ref inArray3[0]), (uint)sizeOfinArray3); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); inHandle3.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int32> _fld1; public Vector128<SByte> _fld2; public Vector128<SByte> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld3), ref Unsafe.As<SByte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); return testStruct; } public void RunStructFldScenario(SimpleTernaryOpTest__DotProduct_Vector128_Int32 testClass) { var result = Dp.DotProduct(_fld1, _fld2, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleTernaryOpTest__DotProduct_Vector128_Int32 testClass) { fixed (Vector128<Int32>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) fixed (Vector128<SByte>* pFld3 = &_fld3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pFld1)), AdvSimd.LoadVector128((SByte*)(pFld2)), AdvSimd.LoadVector128((SByte*)(pFld3)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static readonly int Op3ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static Int32[] _data1 = new Int32[Op1ElementCount]; private static SByte[] _data2 = new SByte[Op2ElementCount]; private static SByte[] _data3 = new SByte[Op3ElementCount]; private static Vector128<Int32> _clsVar1; private static Vector128<SByte> _clsVar2; private static Vector128<SByte> _clsVar3; private Vector128<Int32> _fld1; private Vector128<SByte> _fld2; private Vector128<SByte> _fld3; private DataTable _dataTable; static SimpleTernaryOpTest__DotProduct_Vector128_Int32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar3), ref Unsafe.As<SByte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); } public SimpleTernaryOpTest__DotProduct_Vector128_Int32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld3), ref Unsafe.As<SByte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSByte(); } _dataTable = new DataTable(_data1, _data2, _data3, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => Dp.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Dp.DotProduct( Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Dp).GetMethod(nameof(Dp.DotProduct), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Dp).GetMethod(nameof(Dp.DotProduct), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Dp.DotProduct( _clsVar1, _clsVar2, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int32>* pClsVar1 = &_clsVar1) fixed (Vector128<SByte>* pClsVar2 = &_clsVar2) fixed (Vector128<SByte>* pClsVar3 = &_clsVar3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pClsVar1)), AdvSimd.LoadVector128((SByte*)(pClsVar2)), AdvSimd.LoadVector128((SByte*)(pClsVar3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr); var op3 = Unsafe.Read<Vector128<SByte>>(_dataTable.inArray3Ptr); var result = Dp.DotProduct(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)); var op3 = AdvSimd.LoadVector128((SByte*)(_dataTable.inArray3Ptr)); var result = Dp.DotProduct(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleTernaryOpTest__DotProduct_Vector128_Int32(); var result = Dp.DotProduct(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleTernaryOpTest__DotProduct_Vector128_Int32(); fixed (Vector128<Int32>* pFld1 = &test._fld1) fixed (Vector128<SByte>* pFld2 = &test._fld2) fixed (Vector128<SByte>* pFld3 = &test._fld3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pFld1)), AdvSimd.LoadVector128((SByte*)(pFld2)), AdvSimd.LoadVector128((SByte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Dp.DotProduct(_fld1, _fld2, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int32>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) fixed (Vector128<SByte>* pFld3 = &_fld3) { var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(pFld1)), AdvSimd.LoadVector128((SByte*)(pFld2)), AdvSimd.LoadVector128((SByte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Dp.DotProduct(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Dp.DotProduct( AdvSimd.LoadVector128((Int32*)(&test._fld1)), AdvSimd.LoadVector128((SByte*)(&test._fld2)), AdvSimd.LoadVector128((SByte*)(&test._fld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int32> op1, Vector128<SByte> op2, Vector128<SByte> op3, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] inArray3 = new SByte[Op3ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), op2); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] inArray3 = new SByte[Op3ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(Int32[] firstOp, SByte[] secondOp, SByte[] thirdOp, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.DotProduct(firstOp[i], secondOp, 4 * i, thirdOp, 4 * i) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Dp)}.{nameof(Dp.DotProduct)}<Int32>(Vector128<Int32>, Vector128<SByte>, Vector128<SByte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Security.Permissions/src/System/Security/Permissions/IsolatedStorageContainment.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Security.Permissions { #if NETCOREAPP [Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif public enum IsolatedStorageContainment { None = 0x00, DomainIsolationByUser = 0x10, ApplicationIsolationByUser = 0x15, AssemblyIsolationByUser = 0x20, DomainIsolationByMachine = 0x30, AssemblyIsolationByMachine = 0x40, ApplicationIsolationByMachine = 0x45, DomainIsolationByRoamingUser = 0x50, AssemblyIsolationByRoamingUser = 0x60, ApplicationIsolationByRoamingUser = 0x65, AdministerIsolatedStorageByUser = 0x70, //AdministerIsolatedStorageByMachine = 0x80, UnrestrictedIsolatedStorage = 0xF0 } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Security.Permissions { #if NETCOREAPP [Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif public enum IsolatedStorageContainment { None = 0x00, DomainIsolationByUser = 0x10, ApplicationIsolationByUser = 0x15, AssemblyIsolationByUser = 0x20, DomainIsolationByMachine = 0x30, AssemblyIsolationByMachine = 0x40, ApplicationIsolationByMachine = 0x45, DomainIsolationByRoamingUser = 0x50, AssemblyIsolationByRoamingUser = 0x60, ApplicationIsolationByRoamingUser = 0x65, AdministerIsolatedStorageByUser = 0x70, //AdministerIsolatedStorageByMachine = 0x80, UnrestrictedIsolatedStorage = 0xF0 } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/Loader/classloader/regressions/dev10_813331/Library2.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Library</OutputType> <CLRTestKind>BuildOnly</CLRTestKind> </PropertyGroup> <ItemGroup> <Compile Include="Library2.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Library</OutputType> <CLRTestKind>BuildOnly</CLRTestKind> </PropertyGroup> <ItemGroup> <Compile Include="Library2.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LSA_STRING.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Advapi32 { [StructLayout(LayoutKind.Sequential)] internal struct LSA_STRING { internal LSA_STRING(IntPtr pBuffer, ushort length) { Length = length; MaximumLength = length; Buffer = pBuffer; } /// <summary> /// Specifies the length, in bytes, of the string in Buffer. This value does not include the terminating null character, if any. /// </summary> internal ushort Length; /// <summary> /// Specifies the total size, in bytes, of Buffer. Up to MaximumLength bytes may be written into the buffer without trampling memory. /// </summary> internal ushort MaximumLength; /// <summary> /// Pointer to an array of characters. Note that strings returned by the LSA may not be null-terminated. /// </summary> internal IntPtr Buffer; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Advapi32 { [StructLayout(LayoutKind.Sequential)] internal struct LSA_STRING { internal LSA_STRING(IntPtr pBuffer, ushort length) { Length = length; MaximumLength = length; Buffer = pBuffer; } /// <summary> /// Specifies the length, in bytes, of the string in Buffer. This value does not include the terminating null character, if any. /// </summary> internal ushort Length; /// <summary> /// Specifies the total size, in bytes, of Buffer. Up to MaximumLength bytes may be written into the buffer without trampling memory. /// </summary> internal ushort MaximumLength; /// <summary> /// Pointer to an array of characters. Note that strings returned by the LSA may not be null-terminated. /// </summary> internal IntPtr Buffer; } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Net.Mail/tests/Functional/MailAddressCollectionTest.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // MailAddressCollectionTest.cs - Unit Test Cases for System.Net.MailAddress.MailAddressCollection // // Authors: // John Luke ([email protected]) // // (C) 2005 John Luke // using System.Net.Mime; using Xunit; namespace System.Net.Mail.Tests { public class MailAddressCollectionTest { MailAddressCollection ac; MailAddress a; public MailAddressCollectionTest() { ac = new MailAddressCollection(); a = new MailAddress("[email protected]"); } [Fact] public void InitialCount() { Assert.Equal(0, ac.Count ); } [Fact] public void AddCount() { ac.Add(a); Assert.Equal(1, ac.Count); } [Fact] public void RemoveCount() { ac.Remove(a); Assert.Equal(0, ac.Count); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // MailAddressCollectionTest.cs - Unit Test Cases for System.Net.MailAddress.MailAddressCollection // // Authors: // John Luke ([email protected]) // // (C) 2005 John Luke // using System.Net.Mime; using Xunit; namespace System.Net.Mail.Tests { public class MailAddressCollectionTest { MailAddressCollection ac; MailAddress a; public MailAddressCollectionTest() { ac = new MailAddressCollection(); a = new MailAddress("[email protected]"); } [Fact] public void InitialCount() { Assert.Equal(0, ac.Count ); } [Fact] public void AddCount() { ac.Add(a); Assert.Equal(1, ac.Count); } [Fact] public void RemoveCount() { ac.Remove(a); Assert.Equal(0, ac.Count); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/coreclr/pal/src/debug/debug.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*++ Module Name: debug.c Abstract: Implementation of Win32 debugging API functions. Revision History: --*/ #include "pal/dbgmsg.h" SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do this first #include "pal/thread.hpp" #include "pal/procobj.hpp" #include "pal/file.hpp" #include "pal/palinternal.h" #include "pal/process.h" #include "pal/context.h" #include "pal/debug.h" #include "pal/environ.h" #include "pal/malloc.hpp" #include "pal/module.h" #include "pal/stackstring.hpp" #include "pal/virtual.h" #include "pal/utils.h" #include <signal.h> #include <unistd.h> #if HAVE_PROCFS_CTL #include <unistd.h> #elif HAVE_TTRACE // HAVE_PROCFS_CTL #include <sys/ttrace.h> #else // HAVE_TTRACE #include <sys/ptrace.h> #endif // HAVE_PROCFS_CTL #if HAVE_VM_READ #include <mach/mach.h> #endif // HAVE_VM_READ #include <errno.h> #include <sys/types.h> #include <sys/wait.h> #if HAVE_PROCFS_H #include <procfs.h> #endif // HAVE_PROCFS_H #ifdef __APPLE__ #include <mach/mach.h> #include <mach/mach_vm.h> #endif // __APPLE__ #if HAVE_MACH_EXCEPTIONS #include "../exception/machexception.h" #endif // HAVE_MACH_EXCEPTIONS using namespace CorUnix; extern "C" void DBG_DebugBreak_End(); extern size_t OffsetWithinPage(off_t addr); #if HAVE_PROCFS_CTL #define CTL_ATTACH "attach" #define CTL_DETACH "detach" #define CTL_WAIT "wait" #endif // HAVE_PROCFS_CTL /* ------------------- Constant definitions ----------------------------------*/ #if !HAVE_VM_READ && !HAVE_PROCFS_CTL const BOOL DBG_ATTACH = TRUE; const BOOL DBG_DETACH = FALSE; #endif static const char PAL_OUTPUTDEBUGSTRING[] = "PAL_OUTPUTDEBUGSTRING"; #ifdef _DEBUG #define ENABLE_RUN_ON_DEBUG_BREAK 1 #endif // _DEBUG #ifdef ENABLE_RUN_ON_DEBUG_BREAK static const char PAL_RUN_ON_DEBUG_BREAK[] = "PAL_RUN_ON_DEBUG_BREAK"; #endif // ENABLE_RUN_ON_DEBUG_BREAK extern "C" { /*++ Function: FlushInstructionCache The FlushInstructionCache function flushes the instruction cache for the specified process. Remarks This is a no-op for x86 architectures where the instruction and data caches are coherent in hardware. For non-X86 architectures, this call usually maps to a kernel API to flush the D-caches on all processors. --*/ BOOL PALAPI FlushInstructionCache( IN HANDLE hProcess, IN LPCVOID lpBaseAddress, IN SIZE_T dwSize) { BOOL Ret; PERF_ENTRY(FlushInstructionCache); ENTRY("FlushInstructionCache (hProcess=%p, lpBaseAddress=%p dwSize=%d)\ \n", hProcess, lpBaseAddress, dwSize); if (lpBaseAddress != NULL) { Ret = DBG_FlushInstructionCache(lpBaseAddress, dwSize); } else { Ret = TRUE; } LOGEXIT("FlushInstructionCache returns BOOL %d\n", Ret); PERF_EXIT(FlushInstructionCache); return Ret; } /*++ Function: OutputDebugStringA See MSDN doc. --*/ VOID PALAPI OutputDebugStringA( IN LPCSTR lpOutputString) { PERF_ENTRY(OutputDebugStringA); ENTRY("OutputDebugStringA (lpOutputString=%p (%s))\n", lpOutputString ? lpOutputString : "NULL", lpOutputString ? lpOutputString : "NULL"); // As we don't support debug events, we are going to output the debug string // to stderr instead of generating OUT_DEBUG_STRING_EVENT. It's safe to tell // EnvironGetenv not to make a copy of the value here since we only want to // check whether it exists, not actually use it. if ((lpOutputString != NULL) && (NULL != EnvironGetenv(PAL_OUTPUTDEBUGSTRING, /* copyValue */ FALSE))) { fprintf(stderr, "%s", lpOutputString); } LOGEXIT("OutputDebugStringA returns\n"); PERF_EXIT(OutputDebugStringA); } /*++ Function: OutputDebugStringW See MSDN doc. --*/ VOID PALAPI OutputDebugStringW( IN LPCWSTR lpOutputString) { CHAR *lpOutputStringA; int strLen; PERF_ENTRY(OutputDebugStringW); ENTRY("OutputDebugStringW (lpOutputString=%p (%S))\n", lpOutputString ? lpOutputString: W16_NULLSTRING, lpOutputString ? lpOutputString: W16_NULLSTRING); if (lpOutputString == NULL) { OutputDebugStringA(""); goto EXIT; } if ((strLen = WideCharToMultiByte(CP_ACP, 0, lpOutputString, -1, NULL, 0, NULL, NULL)) == 0) { ASSERT("failed to get wide chars length\n"); SetLastError(ERROR_INTERNAL_ERROR); goto EXIT; } /* strLen includes the null terminator */ if ((lpOutputStringA = (LPSTR) InternalMalloc((strLen * sizeof(CHAR)))) == NULL) { ERROR("Insufficient memory available !\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto EXIT; } if(! WideCharToMultiByte(CP_ACP, 0, lpOutputString, -1, lpOutputStringA, strLen, NULL, NULL)) { ASSERT("failed to convert wide chars to multibytes\n"); SetLastError(ERROR_INTERNAL_ERROR); free(lpOutputStringA); goto EXIT; } OutputDebugStringA(lpOutputStringA); free(lpOutputStringA); EXIT: LOGEXIT("OutputDebugStringW returns\n"); PERF_EXIT(OutputDebugStringW); } #ifdef ENABLE_RUN_ON_DEBUG_BREAK /* When DebugBreak() is called, if PAL_RUN_ON_DEBUG_BREAK is set, DebugBreak() will execute whatever command is in there. PAL_RUN_ON_DEBUG_BREAK must be no longer than 255 characters. This command string inherits the current process's environment, with two additions: PAL_EXE_PID - the process ID of the current process PAL_EXE_NAME - the name of the executable of the current process When DebugBreak() runs this string, it periodically polls the child process and blocks until it finishes. If you use this mechanism to start a debugger, you can break this poll loop by setting the "spin" variable in run_debug_command()'s frame to 0, and then the parent process can continue. suggested values for PAL_RUN_ON_DEBUG_BREAK: to halt the process for later inspection: 'echo stopping $PAL_EXE_PID; kill -STOP $PAL_EXE_PID; sleep 10' to print out the stack trace: 'pstack $PAL_EXE_PID' to invoke the gdb debugger on the process: 'set -x; gdb $PAL_EXE_NAME $PAL_EXE_PID' to invoke the ddd debugger on the process (requires X11): 'set -x; ddd $PAL_EXE_NAME $PAL_EXE_PID' */ static int run_debug_command (const char *command) { int pid; Volatile<int> spin = 1; if (!command) { return 1; } printf("Spawning command: %s\n", command); pid = fork(); if (pid == -1) { return -1; } if (pid == 0) { const char *argv[4] = { "sh", "-c", command, 0 }; execv("/bin/sh", (char **)argv); exit(127); } /* We continue either when the spawned process has stopped, or when an attached debugger sets spin to 0 */ while (spin != 0) { int status = 0; int ret = waitpid(pid, &status, WNOHANG); if (ret == 0) { int i; /* I tried to use sleep for this, and that works everywhere except FreeBSD. The problem on FreeBSD is that if the process gets a signal while blocked in sleep(), gdb is confused by the stack */ for (i = 0; i < 1000000; i++) ; } else if (ret == -1) { if (errno != EINTR) { return -1; } } else if (WIFEXITED(status)) { return WEXITSTATUS(status); } else { fprintf (stderr, "unexpected return from waitpid\n"); return -1; } }; return 0; } #endif // ENABLE_RUN_ON_DEBUG_BREAK #define PID_TEXT "PAL_EXE_PID=" #define EXE_TEXT "PAL_EXE_NAME=" static int DebugBreakCommand() { #ifdef ENABLE_RUN_ON_DEBUG_BREAK extern MODSTRUCT exe_module; char *command_string = EnvironGetenv(PAL_RUN_ON_DEBUG_BREAK); if (command_string) { char pid_buf[sizeof (PID_TEXT) + 32]; PathCharString exe_bufString; int libNameLength = 10; if (exe_module.lib_name != NULL) { libNameLength = PAL_wcslen(exe_module.lib_name); } SIZE_T dwexe_buf = strlen(EXE_TEXT) + libNameLength + 1; CHAR * exe_buf = exe_bufString.OpenStringBuffer(dwexe_buf); if (NULL == exe_buf) { goto FAILED; } if (snprintf (pid_buf, sizeof (pid_buf), PID_TEXT "%d", getpid()) <= 0) { goto FAILED; } if (snprintf (exe_buf, sizeof (CHAR) * (dwexe_buf + 1), EXE_TEXT "%ls", (wchar_t*)exe_module.lib_name) <= 0) { goto FAILED; } exe_bufString.CloseBuffer(dwexe_buf); /* strictly speaking, we might want to only set these environment variables in the child process, but if we do that we can't check for errors. putenv/setenv can fail when out of memory */ if (!EnvironPutenv (pid_buf, FALSE) || !EnvironPutenv (exe_buf, FALSE)) { goto FAILED; } if (run_debug_command (command_string)) { goto FAILED; } free(command_string); return 1; } return 0; FAILED: if (command_string) { fprintf (stderr, "Failed to execute command: '%s'\n", command_string); free(command_string); } return -1; #else // ENABLE_RUN_ON_DEBUG_BREAK return 0; #endif // ENABLE_RUN_ON_DEBUG_BREAK } /*++ Function: DebugBreak See MSDN doc. --*/ VOID PALAPI DebugBreak( VOID) { PERF_ENTRY(DebugBreak); ENTRY("DebugBreak()\n"); if (DebugBreakCommand() <= 0) { // either didn't do anything, or failed TRACE("Calling DBG_DebugBreak\n"); DBG_DebugBreak(); } LOGEXIT("DebugBreak returns\n"); PERF_EXIT(DebugBreak); } /*++ Function: IsInDebugBreak(addr) Returns true if the address is in DBG_DebugBreak. --*/ BOOL IsInDebugBreak(void *addr) { return (addr >= (void *)DBG_DebugBreak) && (addr <= (void *)DBG_DebugBreak_End); } /*++ Function: GetThreadContext See MSDN doc. --*/ BOOL PALAPI GetThreadContext( IN HANDLE hThread, IN OUT LPCONTEXT lpContext) { PAL_ERROR palError; CPalThread *pThread; CPalThread *pTargetThread; IPalObject *pobjThread = NULL; BOOL ret = FALSE; PERF_ENTRY(GetThreadContext); ENTRY("GetThreadContext (hThread=%p, lpContext=%p)\n",hThread,lpContext); pThread = InternalGetCurrentThread(); palError = InternalGetThreadDataFromHandle( pThread, hThread, &pTargetThread, &pobjThread ); if (NO_ERROR == palError) { if (!pTargetThread->IsDummy()) { ret = CONTEXT_GetThreadContext( GetCurrentProcessId(), pTargetThread->GetPThreadSelf(), lpContext ); } else { ASSERT("Dummy thread handle passed to GetThreadContext\n"); pThread->SetLastError(ERROR_INVALID_HANDLE); } } else { pThread->SetLastError(palError); } if (NULL != pobjThread) { pobjThread->ReleaseReference(pThread); } LOGEXIT("GetThreadContext returns ret:%d\n", ret); PERF_EXIT(GetThreadContext); return ret; } /*++ Function: SetThreadContext See MSDN doc. --*/ BOOL PALAPI SetThreadContext( IN HANDLE hThread, IN CONST CONTEXT *lpContext) { PAL_ERROR palError; CPalThread *pThread; CPalThread *pTargetThread; IPalObject *pobjThread = NULL; BOOL ret = FALSE; PERF_ENTRY(SetThreadContext); ENTRY("SetThreadContext (hThread=%p, lpContext=%p)\n",hThread,lpContext); pThread = InternalGetCurrentThread(); palError = InternalGetThreadDataFromHandle( pThread, hThread, &pTargetThread, &pobjThread ); if (NO_ERROR == palError) { if (!pTargetThread->IsDummy()) { ret = CONTEXT_SetThreadContext( GetCurrentProcessId(), pTargetThread->GetPThreadSelf(), lpContext ); } else { ASSERT("Dummy thread handle passed to SetThreadContext\n"); pThread->SetLastError(ERROR_INVALID_HANDLE); } } else { pThread->SetLastError(palError); } if (NULL != pobjThread) { pobjThread->ReleaseReference(pThread); } return ret; } /*++ Function: PAL_OpenProcessMemory Abstract Creates the handle for PAL_ReadProcessMemory. Parameter processId : process id to read memory pHandle : returns a platform specific handle or UINT32_MAX if failed Return true successful, false invalid process id or not supported. --*/ BOOL PALAPI PAL_OpenProcessMemory( IN DWORD processId, OUT DWORD* pHandle ) { ENTRY("PAL_OpenProcessMemory(pid=%d)\n", processId); _ASSERTE(pHandle != nullptr); *pHandle = UINT32_MAX; #ifdef __APPLE__ mach_port_name_t port; kern_return_t result = ::task_for_pid(mach_task_self(), (int)processId, &port); if (result != KERN_SUCCESS) { ERROR("task_for_pid(%d) FAILED %x %s\n", processId, result, mach_error_string(result)); LOGEXIT("PAL_OpenProcessMemory FALSE\n"); return FALSE; } *pHandle = port; #else char memPath[128]; _snprintf_s(memPath, sizeof(memPath), sizeof(memPath), "/proc/%lu/mem", processId); int fd = open(memPath, O_RDONLY); if (fd == -1) { ERROR("open(%s) FAILED %d (%s)\n", memPath, errno, strerror(errno)); LOGEXIT("PAL_OpenProcessMemory FALSE\n"); return FALSE; } *pHandle = fd; #endif LOGEXIT("PAL_OpenProcessMemory TRUE\n"); return TRUE; } /*++ Function: PAL_CloseProcessMemory Abstract Closes the PAL_OpenProcessMemory handle. Parameter handle : from PAL_OpenProcessMemory Return none --*/ VOID PALAPI PAL_CloseProcessMemory( IN DWORD handle ) { ENTRY("PAL_CloseProcessMemory(handle=%x)\n", handle); if (handle != UINT32_MAX) { #ifdef __APPLE__ kern_return_t result = ::mach_port_deallocate(mach_task_self(), (mach_port_name_t)handle); if (result != KERN_SUCCESS) { ERROR("mach_port_deallocate FAILED %x %s\n", result, mach_error_string(result)); } #else close(handle); #endif } LOGEXIT("PAL_CloseProcessMemory\n"); } /*++ Function: PAL_ReadProcessMemory Abstract Reads process memory. Parameter handle : from PAL_OpenProcessMemory address : address of memory to read buffer : buffer to read memory to size : number of bytes to read numberOfBytesRead: number of bytes read (optional) Return true read memory is successful, false if not. --*/ BOOL PALAPI PAL_ReadProcessMemory( IN DWORD handle, IN ULONG64 address, IN LPVOID buffer, IN SIZE_T size, OUT SIZE_T* numberOfBytesRead) { ENTRY("PAL_ReadProcessMemory(handle=%x, address=%p buffer=%p size=%d)\n", handle, (void*)address, buffer, size); _ASSERTE(handle != 0); _ASSERTE(numberOfBytesRead != nullptr); BOOL result = TRUE; size_t read = 0; #ifdef __APPLE__ vm_map_t task = (vm_map_t)handle; // vm_read_overwrite usually requires that the address be page-aligned // and the size be a multiple of the page size. We can't differentiate // between the cases in which that's required and those in which it // isn't, so we do it all the time. const size_t pageSize = GetVirtualPageSize(); vm_address_t addressAligned = ALIGN_DOWN(address, pageSize); ssize_t offset = OffsetWithinPage(address); ssize_t bytesLeft = size; char *data = (char*)malloc(pageSize); if (data != nullptr) { while (bytesLeft > 0) { vm_size_t bytesRead = pageSize; kern_return_t result = ::vm_read_overwrite(task, addressAligned, pageSize, (vm_address_t)data, &bytesRead); if (result != KERN_SUCCESS || bytesRead != pageSize) { TRACE("PAL_ReadProcessMemory(%p %d): vm_read_overwrite failed bytesLeft %d bytesRead %d from %p: %x %s\n", (void*)address, size, bytesLeft, bytesRead, (void*)addressAligned, result, mach_error_string(result)); break; } ssize_t bytesToCopy = pageSize - offset; if (bytesToCopy > bytesLeft) { bytesToCopy = bytesLeft; } memcpy((LPSTR)buffer + read, data + offset, bytesToCopy); addressAligned = addressAligned + pageSize; read += bytesToCopy; bytesLeft -= bytesToCopy; offset = 0; } result = size == 0 || read > 0; } else { ERROR("malloc(%d) FAILED\n", pageSize); result = FALSE; } if (data != nullptr) { free(data); } #else read = pread(handle, buffer, size, address); if (read == (size_t)-1) { result = FALSE; } #endif *numberOfBytesRead = read; LOGEXIT("PAL_ReadProcessMemory result=%d bytes read=%d\n", result, read); return result; } /*++ Function: PAL_ProbeMemory Abstract Parameter pBuffer : address of memory to validate cbBuffer : size of memory region to validate fWriteAccess : if true, validate writable access, else just readable. Return true if memory is valid, false if not. --*/ BOOL PALAPI PAL_ProbeMemory( PVOID pBuffer, DWORD cbBuffer, BOOL fWriteAccess) { int fds[2]; int flags; if (pipe(fds) != 0) { ASSERT("pipe failed: errno is %d (%s)\n", errno, strerror(errno)); return FALSE; } flags = fcntl(fds[0], F_GETFL, 0); fcntl(fds[0], F_SETFL, flags | O_NONBLOCK); flags = fcntl(fds[1], F_GETFL, 0); fcntl(fds[1], F_SETFL, flags | O_NONBLOCK); PVOID pEnd = (PBYTE)pBuffer + cbBuffer; BOOL result = TRUE; // Validate the first byte in the buffer, then validate the first byte on each page after that. while (pBuffer < pEnd) { int written = write(fds[1], pBuffer, 1); if (written == -1) { if (errno != EFAULT) { ASSERT("write failed: errno is %d (%s)\n", errno, strerror(errno)); } result = FALSE; break; } else { if (fWriteAccess) { int rd = read(fds[0], pBuffer, 1); if (rd == -1) { if (errno != EFAULT) { ASSERT("read failed: errno is %d (%s)\n", errno, strerror(errno)); } result = FALSE; break; } } } // Round to the beginning of the next page pBuffer = PVOID(ALIGN_DOWN((SIZE_T)pBuffer, GetVirtualPageSize()) + GetVirtualPageSize()); } close(fds[0]); close(fds[1]); return result; } } // extern "C"
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*++ Module Name: debug.c Abstract: Implementation of Win32 debugging API functions. Revision History: --*/ #include "pal/dbgmsg.h" SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do this first #include "pal/thread.hpp" #include "pal/procobj.hpp" #include "pal/file.hpp" #include "pal/palinternal.h" #include "pal/process.h" #include "pal/context.h" #include "pal/debug.h" #include "pal/environ.h" #include "pal/malloc.hpp" #include "pal/module.h" #include "pal/stackstring.hpp" #include "pal/virtual.h" #include "pal/utils.h" #include <signal.h> #include <unistd.h> #if HAVE_PROCFS_CTL #include <unistd.h> #elif HAVE_TTRACE // HAVE_PROCFS_CTL #include <sys/ttrace.h> #else // HAVE_TTRACE #include <sys/ptrace.h> #endif // HAVE_PROCFS_CTL #if HAVE_VM_READ #include <mach/mach.h> #endif // HAVE_VM_READ #include <errno.h> #include <sys/types.h> #include <sys/wait.h> #if HAVE_PROCFS_H #include <procfs.h> #endif // HAVE_PROCFS_H #ifdef __APPLE__ #include <mach/mach.h> #include <mach/mach_vm.h> #endif // __APPLE__ #if HAVE_MACH_EXCEPTIONS #include "../exception/machexception.h" #endif // HAVE_MACH_EXCEPTIONS using namespace CorUnix; extern "C" void DBG_DebugBreak_End(); extern size_t OffsetWithinPage(off_t addr); #if HAVE_PROCFS_CTL #define CTL_ATTACH "attach" #define CTL_DETACH "detach" #define CTL_WAIT "wait" #endif // HAVE_PROCFS_CTL /* ------------------- Constant definitions ----------------------------------*/ #if !HAVE_VM_READ && !HAVE_PROCFS_CTL const BOOL DBG_ATTACH = TRUE; const BOOL DBG_DETACH = FALSE; #endif static const char PAL_OUTPUTDEBUGSTRING[] = "PAL_OUTPUTDEBUGSTRING"; #ifdef _DEBUG #define ENABLE_RUN_ON_DEBUG_BREAK 1 #endif // _DEBUG #ifdef ENABLE_RUN_ON_DEBUG_BREAK static const char PAL_RUN_ON_DEBUG_BREAK[] = "PAL_RUN_ON_DEBUG_BREAK"; #endif // ENABLE_RUN_ON_DEBUG_BREAK extern "C" { /*++ Function: FlushInstructionCache The FlushInstructionCache function flushes the instruction cache for the specified process. Remarks This is a no-op for x86 architectures where the instruction and data caches are coherent in hardware. For non-X86 architectures, this call usually maps to a kernel API to flush the D-caches on all processors. --*/ BOOL PALAPI FlushInstructionCache( IN HANDLE hProcess, IN LPCVOID lpBaseAddress, IN SIZE_T dwSize) { BOOL Ret; PERF_ENTRY(FlushInstructionCache); ENTRY("FlushInstructionCache (hProcess=%p, lpBaseAddress=%p dwSize=%d)\ \n", hProcess, lpBaseAddress, dwSize); if (lpBaseAddress != NULL) { Ret = DBG_FlushInstructionCache(lpBaseAddress, dwSize); } else { Ret = TRUE; } LOGEXIT("FlushInstructionCache returns BOOL %d\n", Ret); PERF_EXIT(FlushInstructionCache); return Ret; } /*++ Function: OutputDebugStringA See MSDN doc. --*/ VOID PALAPI OutputDebugStringA( IN LPCSTR lpOutputString) { PERF_ENTRY(OutputDebugStringA); ENTRY("OutputDebugStringA (lpOutputString=%p (%s))\n", lpOutputString ? lpOutputString : "NULL", lpOutputString ? lpOutputString : "NULL"); // As we don't support debug events, we are going to output the debug string // to stderr instead of generating OUT_DEBUG_STRING_EVENT. It's safe to tell // EnvironGetenv not to make a copy of the value here since we only want to // check whether it exists, not actually use it. if ((lpOutputString != NULL) && (NULL != EnvironGetenv(PAL_OUTPUTDEBUGSTRING, /* copyValue */ FALSE))) { fprintf(stderr, "%s", lpOutputString); } LOGEXIT("OutputDebugStringA returns\n"); PERF_EXIT(OutputDebugStringA); } /*++ Function: OutputDebugStringW See MSDN doc. --*/ VOID PALAPI OutputDebugStringW( IN LPCWSTR lpOutputString) { CHAR *lpOutputStringA; int strLen; PERF_ENTRY(OutputDebugStringW); ENTRY("OutputDebugStringW (lpOutputString=%p (%S))\n", lpOutputString ? lpOutputString: W16_NULLSTRING, lpOutputString ? lpOutputString: W16_NULLSTRING); if (lpOutputString == NULL) { OutputDebugStringA(""); goto EXIT; } if ((strLen = WideCharToMultiByte(CP_ACP, 0, lpOutputString, -1, NULL, 0, NULL, NULL)) == 0) { ASSERT("failed to get wide chars length\n"); SetLastError(ERROR_INTERNAL_ERROR); goto EXIT; } /* strLen includes the null terminator */ if ((lpOutputStringA = (LPSTR) InternalMalloc((strLen * sizeof(CHAR)))) == NULL) { ERROR("Insufficient memory available !\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto EXIT; } if(! WideCharToMultiByte(CP_ACP, 0, lpOutputString, -1, lpOutputStringA, strLen, NULL, NULL)) { ASSERT("failed to convert wide chars to multibytes\n"); SetLastError(ERROR_INTERNAL_ERROR); free(lpOutputStringA); goto EXIT; } OutputDebugStringA(lpOutputStringA); free(lpOutputStringA); EXIT: LOGEXIT("OutputDebugStringW returns\n"); PERF_EXIT(OutputDebugStringW); } #ifdef ENABLE_RUN_ON_DEBUG_BREAK /* When DebugBreak() is called, if PAL_RUN_ON_DEBUG_BREAK is set, DebugBreak() will execute whatever command is in there. PAL_RUN_ON_DEBUG_BREAK must be no longer than 255 characters. This command string inherits the current process's environment, with two additions: PAL_EXE_PID - the process ID of the current process PAL_EXE_NAME - the name of the executable of the current process When DebugBreak() runs this string, it periodically polls the child process and blocks until it finishes. If you use this mechanism to start a debugger, you can break this poll loop by setting the "spin" variable in run_debug_command()'s frame to 0, and then the parent process can continue. suggested values for PAL_RUN_ON_DEBUG_BREAK: to halt the process for later inspection: 'echo stopping $PAL_EXE_PID; kill -STOP $PAL_EXE_PID; sleep 10' to print out the stack trace: 'pstack $PAL_EXE_PID' to invoke the gdb debugger on the process: 'set -x; gdb $PAL_EXE_NAME $PAL_EXE_PID' to invoke the ddd debugger on the process (requires X11): 'set -x; ddd $PAL_EXE_NAME $PAL_EXE_PID' */ static int run_debug_command (const char *command) { int pid; Volatile<int> spin = 1; if (!command) { return 1; } printf("Spawning command: %s\n", command); pid = fork(); if (pid == -1) { return -1; } if (pid == 0) { const char *argv[4] = { "sh", "-c", command, 0 }; execv("/bin/sh", (char **)argv); exit(127); } /* We continue either when the spawned process has stopped, or when an attached debugger sets spin to 0 */ while (spin != 0) { int status = 0; int ret = waitpid(pid, &status, WNOHANG); if (ret == 0) { int i; /* I tried to use sleep for this, and that works everywhere except FreeBSD. The problem on FreeBSD is that if the process gets a signal while blocked in sleep(), gdb is confused by the stack */ for (i = 0; i < 1000000; i++) ; } else if (ret == -1) { if (errno != EINTR) { return -1; } } else if (WIFEXITED(status)) { return WEXITSTATUS(status); } else { fprintf (stderr, "unexpected return from waitpid\n"); return -1; } }; return 0; } #endif // ENABLE_RUN_ON_DEBUG_BREAK #define PID_TEXT "PAL_EXE_PID=" #define EXE_TEXT "PAL_EXE_NAME=" static int DebugBreakCommand() { #ifdef ENABLE_RUN_ON_DEBUG_BREAK extern MODSTRUCT exe_module; char *command_string = EnvironGetenv(PAL_RUN_ON_DEBUG_BREAK); if (command_string) { char pid_buf[sizeof (PID_TEXT) + 32]; PathCharString exe_bufString; int libNameLength = 10; if (exe_module.lib_name != NULL) { libNameLength = PAL_wcslen(exe_module.lib_name); } SIZE_T dwexe_buf = strlen(EXE_TEXT) + libNameLength + 1; CHAR * exe_buf = exe_bufString.OpenStringBuffer(dwexe_buf); if (NULL == exe_buf) { goto FAILED; } if (snprintf (pid_buf, sizeof (pid_buf), PID_TEXT "%d", getpid()) <= 0) { goto FAILED; } if (snprintf (exe_buf, sizeof (CHAR) * (dwexe_buf + 1), EXE_TEXT "%ls", (wchar_t*)exe_module.lib_name) <= 0) { goto FAILED; } exe_bufString.CloseBuffer(dwexe_buf); /* strictly speaking, we might want to only set these environment variables in the child process, but if we do that we can't check for errors. putenv/setenv can fail when out of memory */ if (!EnvironPutenv (pid_buf, FALSE) || !EnvironPutenv (exe_buf, FALSE)) { goto FAILED; } if (run_debug_command (command_string)) { goto FAILED; } free(command_string); return 1; } return 0; FAILED: if (command_string) { fprintf (stderr, "Failed to execute command: '%s'\n", command_string); free(command_string); } return -1; #else // ENABLE_RUN_ON_DEBUG_BREAK return 0; #endif // ENABLE_RUN_ON_DEBUG_BREAK } /*++ Function: DebugBreak See MSDN doc. --*/ VOID PALAPI DebugBreak( VOID) { PERF_ENTRY(DebugBreak); ENTRY("DebugBreak()\n"); if (DebugBreakCommand() <= 0) { // either didn't do anything, or failed TRACE("Calling DBG_DebugBreak\n"); DBG_DebugBreak(); } LOGEXIT("DebugBreak returns\n"); PERF_EXIT(DebugBreak); } /*++ Function: IsInDebugBreak(addr) Returns true if the address is in DBG_DebugBreak. --*/ BOOL IsInDebugBreak(void *addr) { return (addr >= (void *)DBG_DebugBreak) && (addr <= (void *)DBG_DebugBreak_End); } /*++ Function: GetThreadContext See MSDN doc. --*/ BOOL PALAPI GetThreadContext( IN HANDLE hThread, IN OUT LPCONTEXT lpContext) { PAL_ERROR palError; CPalThread *pThread; CPalThread *pTargetThread; IPalObject *pobjThread = NULL; BOOL ret = FALSE; PERF_ENTRY(GetThreadContext); ENTRY("GetThreadContext (hThread=%p, lpContext=%p)\n",hThread,lpContext); pThread = InternalGetCurrentThread(); palError = InternalGetThreadDataFromHandle( pThread, hThread, &pTargetThread, &pobjThread ); if (NO_ERROR == palError) { if (!pTargetThread->IsDummy()) { ret = CONTEXT_GetThreadContext( GetCurrentProcessId(), pTargetThread->GetPThreadSelf(), lpContext ); } else { ASSERT("Dummy thread handle passed to GetThreadContext\n"); pThread->SetLastError(ERROR_INVALID_HANDLE); } } else { pThread->SetLastError(palError); } if (NULL != pobjThread) { pobjThread->ReleaseReference(pThread); } LOGEXIT("GetThreadContext returns ret:%d\n", ret); PERF_EXIT(GetThreadContext); return ret; } /*++ Function: SetThreadContext See MSDN doc. --*/ BOOL PALAPI SetThreadContext( IN HANDLE hThread, IN CONST CONTEXT *lpContext) { PAL_ERROR palError; CPalThread *pThread; CPalThread *pTargetThread; IPalObject *pobjThread = NULL; BOOL ret = FALSE; PERF_ENTRY(SetThreadContext); ENTRY("SetThreadContext (hThread=%p, lpContext=%p)\n",hThread,lpContext); pThread = InternalGetCurrentThread(); palError = InternalGetThreadDataFromHandle( pThread, hThread, &pTargetThread, &pobjThread ); if (NO_ERROR == palError) { if (!pTargetThread->IsDummy()) { ret = CONTEXT_SetThreadContext( GetCurrentProcessId(), pTargetThread->GetPThreadSelf(), lpContext ); } else { ASSERT("Dummy thread handle passed to SetThreadContext\n"); pThread->SetLastError(ERROR_INVALID_HANDLE); } } else { pThread->SetLastError(palError); } if (NULL != pobjThread) { pobjThread->ReleaseReference(pThread); } return ret; } /*++ Function: PAL_OpenProcessMemory Abstract Creates the handle for PAL_ReadProcessMemory. Parameter processId : process id to read memory pHandle : returns a platform specific handle or UINT32_MAX if failed Return true successful, false invalid process id or not supported. --*/ BOOL PALAPI PAL_OpenProcessMemory( IN DWORD processId, OUT DWORD* pHandle ) { ENTRY("PAL_OpenProcessMemory(pid=%d)\n", processId); _ASSERTE(pHandle != nullptr); *pHandle = UINT32_MAX; #ifdef __APPLE__ mach_port_name_t port; kern_return_t result = ::task_for_pid(mach_task_self(), (int)processId, &port); if (result != KERN_SUCCESS) { ERROR("task_for_pid(%d) FAILED %x %s\n", processId, result, mach_error_string(result)); LOGEXIT("PAL_OpenProcessMemory FALSE\n"); return FALSE; } *pHandle = port; #else char memPath[128]; _snprintf_s(memPath, sizeof(memPath), sizeof(memPath), "/proc/%lu/mem", processId); int fd = open(memPath, O_RDONLY); if (fd == -1) { ERROR("open(%s) FAILED %d (%s)\n", memPath, errno, strerror(errno)); LOGEXIT("PAL_OpenProcessMemory FALSE\n"); return FALSE; } *pHandle = fd; #endif LOGEXIT("PAL_OpenProcessMemory TRUE\n"); return TRUE; } /*++ Function: PAL_CloseProcessMemory Abstract Closes the PAL_OpenProcessMemory handle. Parameter handle : from PAL_OpenProcessMemory Return none --*/ VOID PALAPI PAL_CloseProcessMemory( IN DWORD handle ) { ENTRY("PAL_CloseProcessMemory(handle=%x)\n", handle); if (handle != UINT32_MAX) { #ifdef __APPLE__ kern_return_t result = ::mach_port_deallocate(mach_task_self(), (mach_port_name_t)handle); if (result != KERN_SUCCESS) { ERROR("mach_port_deallocate FAILED %x %s\n", result, mach_error_string(result)); } #else close(handle); #endif } LOGEXIT("PAL_CloseProcessMemory\n"); } /*++ Function: PAL_ReadProcessMemory Abstract Reads process memory. Parameter handle : from PAL_OpenProcessMemory address : address of memory to read buffer : buffer to read memory to size : number of bytes to read numberOfBytesRead: number of bytes read (optional) Return true read memory is successful, false if not. --*/ BOOL PALAPI PAL_ReadProcessMemory( IN DWORD handle, IN ULONG64 address, IN LPVOID buffer, IN SIZE_T size, OUT SIZE_T* numberOfBytesRead) { ENTRY("PAL_ReadProcessMemory(handle=%x, address=%p buffer=%p size=%d)\n", handle, (void*)address, buffer, size); _ASSERTE(handle != 0); _ASSERTE(numberOfBytesRead != nullptr); BOOL result = TRUE; size_t read = 0; #ifdef __APPLE__ vm_map_t task = (vm_map_t)handle; // vm_read_overwrite usually requires that the address be page-aligned // and the size be a multiple of the page size. We can't differentiate // between the cases in which that's required and those in which it // isn't, so we do it all the time. const size_t pageSize = GetVirtualPageSize(); vm_address_t addressAligned = ALIGN_DOWN(address, pageSize); ssize_t offset = OffsetWithinPage(address); ssize_t bytesLeft = size; char *data = (char*)malloc(pageSize); if (data != nullptr) { while (bytesLeft > 0) { vm_size_t bytesRead = pageSize; kern_return_t result = ::vm_read_overwrite(task, addressAligned, pageSize, (vm_address_t)data, &bytesRead); if (result != KERN_SUCCESS || bytesRead != pageSize) { TRACE("PAL_ReadProcessMemory(%p %d): vm_read_overwrite failed bytesLeft %d bytesRead %d from %p: %x %s\n", (void*)address, size, bytesLeft, bytesRead, (void*)addressAligned, result, mach_error_string(result)); break; } ssize_t bytesToCopy = pageSize - offset; if (bytesToCopy > bytesLeft) { bytesToCopy = bytesLeft; } memcpy((LPSTR)buffer + read, data + offset, bytesToCopy); addressAligned = addressAligned + pageSize; read += bytesToCopy; bytesLeft -= bytesToCopy; offset = 0; } result = size == 0 || read > 0; } else { ERROR("malloc(%d) FAILED\n", pageSize); result = FALSE; } if (data != nullptr) { free(data); } #else read = pread(handle, buffer, size, address); if (read == (size_t)-1) { result = FALSE; } #endif *numberOfBytesRead = read; LOGEXIT("PAL_ReadProcessMemory result=%d bytes read=%d\n", result, read); return result; } /*++ Function: PAL_ProbeMemory Abstract Parameter pBuffer : address of memory to validate cbBuffer : size of memory region to validate fWriteAccess : if true, validate writable access, else just readable. Return true if memory is valid, false if not. --*/ BOOL PALAPI PAL_ProbeMemory( PVOID pBuffer, DWORD cbBuffer, BOOL fWriteAccess) { int fds[2]; int flags; if (pipe(fds) != 0) { ASSERT("pipe failed: errno is %d (%s)\n", errno, strerror(errno)); return FALSE; } flags = fcntl(fds[0], F_GETFL, 0); fcntl(fds[0], F_SETFL, flags | O_NONBLOCK); flags = fcntl(fds[1], F_GETFL, 0); fcntl(fds[1], F_SETFL, flags | O_NONBLOCK); PVOID pEnd = (PBYTE)pBuffer + cbBuffer; BOOL result = TRUE; // Validate the first byte in the buffer, then validate the first byte on each page after that. while (pBuffer < pEnd) { int written = write(fds[1], pBuffer, 1); if (written == -1) { if (errno != EFAULT) { ASSERT("write failed: errno is %d (%s)\n", errno, strerror(errno)); } result = FALSE; break; } else { if (fWriteAccess) { int rd = read(fds[0], pBuffer, 1); if (rd == -1) { if (errno != EFAULT) { ASSERT("read failed: errno is %d (%s)\n", errno, strerror(errno)); } result = FALSE; break; } } } // Round to the beginning of the next page pBuffer = PVOID(ALIGN_DOWN((SIZE_T)pBuffer, GetVirtualPageSize()) + GetVirtualPageSize()); } close(fds[0]); close(fds[1]); return result; } } // extern "C"
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/tests/JIT/HardwareIntrinsics/Arm/Shared/InsertScalarTest.template
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void {TestName}() { var test = new InsertScalarTest__{TestName}(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if ({LoadIsa}.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if ({LoadIsa}.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if ({LoadIsa}.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if ({LoadIsa}.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class InsertScalarTest__{TestName} { private struct DataTable { private byte[] inArray1; private byte[] inArray3; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle3; private GCHandle outHandle; private ulong alignment; public DataTable({Op1BaseType}[] inArray1, {Op3BaseType}[] inArray3, {RetBaseType}[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<{Op3BaseType}>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray3 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), (uint)sizeOfinArray3); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle3.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public {Op1VectorType}<{Op1BaseType}> _fld1; public {Op3VectorType}<{Op3BaseType}> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref testStruct._fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); return testStruct; } public void RunStructFldScenario(InsertScalarTest__{TestName} testClass) { var result = {Isa}.{Method}(_fld1, {ElementIndex}, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(InsertScalarTest__{TestName} testClass) { fixed ({Op1VectorType}<{Op1BaseType}>* pFld1 = &_fld1) fixed ({Op3VectorType}<{Op3BaseType}>* pFld2 = &_fld3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)pFld1), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)pFld2) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); private static readonly int Op3ElementCount = Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>() / sizeof({Op3BaseType}); private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); private static readonly byte ElementIndex = {ElementIndex}; private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; private static {Op3BaseType}[] _data3 = new {Op3BaseType}[Op3ElementCount]; private static {Op1VectorType}<{Op1BaseType}> _clsVar1; private static {Op3VectorType}<{Op3BaseType}> _clsVar3; private {Op1VectorType}<{Op1BaseType}> _fld1; private {Op3VectorType}<{Op3BaseType}> _fld3; private DataTable _dataTable; static InsertScalarTest__{TestName}() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref _clsVar3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); } public InsertScalarTest__{TestName}() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref _fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } _dataTable = new DataTable(_data1, _data3, new {RetBaseType}[RetElementCount], LargestVectorSize); } public bool IsSupported => {Isa}.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = {Isa}.{Method}( Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), {ElementIndex}, Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte), typeof({Op3VectorType}<{Op3BaseType}>) }) .Invoke(null, new object[] { Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), ElementIndex, Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte), typeof({Op3VectorType}<{Op3BaseType}>) }) .Invoke(null, new object[] { {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), ElementIndex, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = {Isa}.{Method}( _clsVar1, {ElementIndex}, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed ({Op1VectorType}<{Op1BaseType}>* pClsVar1 = &_clsVar1) fixed ({Op3VectorType}<{Op3BaseType}>* pClsVar3 = &_clsVar3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(pClsVar1)), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(pClsVar3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); var op3 = Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr); var result = {Isa}.{Method}(op1, {ElementIndex}, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op3, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)); var op3 = {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(_dataTable.inArray3Ptr)); var result = {Isa}.{Method}(op1, {ElementIndex}, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new InsertScalarTest__{TestName}(); var result = {Isa}.{Method}(test._fld1, {ElementIndex}, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new InsertScalarTest__{TestName}(); fixed ({Op1VectorType}<{Op1BaseType}>* pFld1 = &test._fld1) fixed ({Op3VectorType}<{Op3BaseType}>* pFld2 = &test._fld3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)pFld1), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)pFld2) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = {Isa}.{Method}(_fld1, {ElementIndex}, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed ({Op1VectorType}<{Op1BaseType}>* pFld1 = &_fld1) fixed ({Op3VectorType}<{Op3BaseType}>* pFld2 = &_fld3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)pFld1), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)pFld2) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = {Isa}.{Method}(test._fld1, {ElementIndex}, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(&test._fld1)), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(&test._fld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, {Op3VectorType}<{Op3BaseType}> op3, void* result, [CallerMemberName] string method = "") { {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; {Op3BaseType}[] inArray3 = new {Op3BaseType}[Op3ElementCount]; {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); ValidateResult(inArray1, inArray3, outArray, method); } private void ValidateResult(void* op1, void* op3, void* result, [CallerMemberName] string method = "") { {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; {Op3BaseType}[] inArray3 = new {Op3BaseType}[Op3ElementCount]; {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); ValidateResult(inArray1, inArray3, outArray, method); } private void ValidateResult({Op1BaseType}[] firstOp, {Op3BaseType}[] thirdOp, {RetBaseType}[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if ({ValidateIterResult}) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {ElementIndex}, {Op3VectorType}<{Op3BaseType}>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void {TestName}() { var test = new InsertScalarTest__{TestName}(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if ({LoadIsa}.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if ({LoadIsa}.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if ({LoadIsa}.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if ({LoadIsa}.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if ({LoadIsa}.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class InsertScalarTest__{TestName} { private struct DataTable { private byte[] inArray1; private byte[] inArray3; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle3; private GCHandle outHandle; private ulong alignment; public DataTable({Op1BaseType}[] inArray1, {Op3BaseType}[] inArray3, {RetBaseType}[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<{Op3BaseType}>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray3 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), (uint)sizeOfinArray3); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle3.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public {Op1VectorType}<{Op1BaseType}> _fld1; public {Op3VectorType}<{Op3BaseType}> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref testStruct._fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); return testStruct; } public void RunStructFldScenario(InsertScalarTest__{TestName} testClass) { var result = {Isa}.{Method}(_fld1, {ElementIndex}, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(InsertScalarTest__{TestName} testClass) { fixed ({Op1VectorType}<{Op1BaseType}>* pFld1 = &_fld1) fixed ({Op3VectorType}<{Op3BaseType}>* pFld2 = &_fld3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)pFld1), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)pFld2) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); private static readonly int Op3ElementCount = Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>() / sizeof({Op3BaseType}); private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); private static readonly byte ElementIndex = {ElementIndex}; private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; private static {Op3BaseType}[] _data3 = new {Op3BaseType}[Op3ElementCount]; private static {Op1VectorType}<{Op1BaseType}> _clsVar1; private static {Op3VectorType}<{Op3BaseType}> _clsVar3; private {Op1VectorType}<{Op1BaseType}> _fld1; private {Op3VectorType}<{Op3BaseType}> _fld3; private DataTable _dataTable; static InsertScalarTest__{TestName}() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref _clsVar3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); } public InsertScalarTest__{TestName}() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref _fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } _dataTable = new DataTable(_data1, _data3, new {RetBaseType}[RetElementCount], LargestVectorSize); } public bool IsSupported => {Isa}.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = {Isa}.{Method}( Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), {ElementIndex}, Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte), typeof({Op3VectorType}<{Op3BaseType}>) }) .Invoke(null, new object[] { Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), ElementIndex, Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte), typeof({Op3VectorType}<{Op3BaseType}>) }) .Invoke(null, new object[] { {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), ElementIndex, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = {Isa}.{Method}( _clsVar1, {ElementIndex}, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed ({Op1VectorType}<{Op1BaseType}>* pClsVar1 = &_clsVar1) fixed ({Op3VectorType}<{Op3BaseType}>* pClsVar3 = &_clsVar3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(pClsVar1)), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(pClsVar3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); var op3 = Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr); var result = {Isa}.{Method}(op1, {ElementIndex}, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op3, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)); var op3 = {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(_dataTable.inArray3Ptr)); var result = {Isa}.{Method}(op1, {ElementIndex}, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new InsertScalarTest__{TestName}(); var result = {Isa}.{Method}(test._fld1, {ElementIndex}, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new InsertScalarTest__{TestName}(); fixed ({Op1VectorType}<{Op1BaseType}>* pFld1 = &test._fld1) fixed ({Op3VectorType}<{Op3BaseType}>* pFld2 = &test._fld3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)pFld1), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)pFld2) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = {Isa}.{Method}(_fld1, {ElementIndex}, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed ({Op1VectorType}<{Op1BaseType}>* pFld1 = &_fld1) fixed ({Op3VectorType}<{Op3BaseType}>* pFld2 = &_fld3) { var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)pFld1), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)pFld2) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = {Isa}.{Method}(test._fld1, {ElementIndex}, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = {Isa}.{Method}( {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(&test._fld1)), {ElementIndex}, {LoadIsa}.Load{Op3VectorType}(({Op3BaseType}*)(&test._fld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, {Op3VectorType}<{Op3BaseType}> op3, void* result, [CallerMemberName] string method = "") { {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; {Op3BaseType}[] inArray3 = new {Op3BaseType}[Op3ElementCount]; {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); ValidateResult(inArray1, inArray3, outArray, method); } private void ValidateResult(void* op1, void* op3, void* result, [CallerMemberName] string method = "") { {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; {Op3BaseType}[] inArray3 = new {Op3BaseType}[Op3ElementCount]; {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); ValidateResult(inArray1, inArray3, outArray, method); } private void ValidateResult({Op1BaseType}[] firstOp, {Op3BaseType}[] thirdOp, {RetBaseType}[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if ({ValidateIterResult}) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {ElementIndex}, {Op3VectorType}<{Op3BaseType}>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Runtime.Extensions/tests/AssemblyResolveTestApp/ClassesSample.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace AssemblyResolveTestApp { public class PublicClassSample { public PublicClassSample() { } public PublicClassSample(int param) { } } class PrivateClassSample { public PrivateClassSample() { } public PrivateClassSample(int param) { } } public class PublicClassNoDefaultConstructorSample { public PublicClassNoDefaultConstructorSample(int param) { } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace AssemblyResolveTestApp { public class PublicClassSample { public PublicClassSample() { } public PublicClassSample(int param) { } } class PrivateClassSample { public PrivateClassSample() { } public PrivateClassSample(int param) { } } public class PublicClassNoDefaultConstructorSample { public PublicClassNoDefaultConstructorSample(int param) { } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Linq.Parallel/tests/QueryOperators/GroupByTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Linq.Parallel.Tests { public static class GroupByTests { private const int GroupFactor = 8; [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor)) { groupsSeen.Add(group.Key); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key + 1)) / GroupFactor); foreach (int i in group) { Assert.Equal(group.Key, i % GroupFactor); elementsSeen.Add(i / GroupFactor); } elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_Longrunning() { GroupBy_Unordered(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor)) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = group.Key; foreach (int i in group) { Assert.Equal(elementsSeen, i); elementsSeen += GroupFactor; } Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_NotPipelined(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor).ToList()) { groupsSeen.Add(group.Key); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key + 1)) / GroupFactor); Assert.All(group, x => { Assert.Equal(group.Key, x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_NotPipelined_Longrunning() { GroupBy_Unordered_NotPipelined(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor).ToList()) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = group.Key; Assert.All(group, x => { Assert.Equal(elementsSeen, x); elementsSeen += GroupFactor; }); Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_NotPipelined_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_NotPipelined(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_CustomComparator(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x, new ModularCongruenceComparer(GroupFactor))) { groupsSeen.Add(group.Key % GroupFactor); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key % GroupFactor + 1)) / GroupFactor); foreach (int i in group) { Assert.Equal(group.Key % GroupFactor, i % GroupFactor); elementsSeen.Add(i / GroupFactor); } elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_CustomComparator_Longrunning() { GroupBy_Unordered_CustomComparator(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] // GroupBy doesn't select the first 'identical' key. https://github.com/dotnet/runtime/issues/14472 public static void GroupBy_CustomComparator(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x, new ModularCongruenceComparer(GroupFactor))) { int elementsSeen = groupsSeen; Assert.Equal(groupsSeen++, group.Key % GroupFactor); foreach (int i in group) { Assert.Equal(elementsSeen, i); elementsSeen += GroupFactor; } Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_CustomComparator_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_CustomComparator(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ElementSelector(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, x => -x)) { groupsSeen.Add(group.Key); int expected = 1 + (count - (group.Key + 1)) / GroupFactor; IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected); Assert.All(group, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ElementSelector_Longrunning() { GroupBy_Unordered_ElementSelector(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor, x => -x)) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = -group.Key; Assert.All(group, x => { Assert.Equal(elementsSeen, x); elementsSeen -= GroupFactor; }); Assert.Equal(-group.Key - (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ElementSelector(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ElementSelector_NotPipelined(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, y => -y).ToList()) { groupsSeen.Add(group.Key); int expected = 1 + (count - (group.Key + 1)) / GroupFactor; IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected); Assert.All(group, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ElementSelector_NotPipelined_Longrunning() { GroupBy_Unordered_ElementSelector_NotPipelined(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor, y => -y).ToList()) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = -group.Key; Assert.All(group, x => { Assert.Equal(elementsSeen, x); elementsSeen -= GroupFactor; }); Assert.Equal(-group.Key - (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_NotPipelined_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ElementSelector_NotPipelined(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ResultSelector(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (var group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, (key, elements) => KeyValuePair.Create(key, elements))) { groupsSeen.Add(group.Key); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key + 1)) / GroupFactor); Assert.All(group.Value, x => { Assert.Equal(group.Key, x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ResultSelector_Longrunning() { GroupBy_Unordered_ResultSelector(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (var group in query.GroupBy(x => x % GroupFactor, (key, elements) => KeyValuePair.Create(key, elements))) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = group.Key; Assert.All(group.Value, x => { Assert.Equal(elementsSeen, x); elementsSeen += GroupFactor; }); Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ResultSelector(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ResultSelector_CustomComparator(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (var group in UnorderedSources.Default(count).GroupBy(x => x, (key, elements) => KeyValuePair.Create(key, elements), new ModularCongruenceComparer(GroupFactor))) { groupsSeen.Add(group.Key % GroupFactor); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key % GroupFactor + 1)) / GroupFactor); Assert.All(group.Value, x => { Assert.Equal(group.Key % GroupFactor, x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ResultSelector_CustomComparator_Longrunning() { GroupBy_Unordered_ResultSelector_CustomComparator(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector_CustomComparator(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (var group in query.GroupBy(x => x, (key, elements) => KeyValuePair.Create(key, elements), new ModularCongruenceComparer(GroupFactor))) { int elementsSeen = groupsSeen; Assert.Equal(groupsSeen++, group.Key % GroupFactor); Assert.All(group.Value, x => { Assert.Equal(elementsSeen, x); elementsSeen += GroupFactor; }); Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector_CustomComparator_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ResultSelector_CustomComparator(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ElementSelector_ResultSelector(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (var group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, x => -x, (key, elements) => KeyValuePair.Create(key, elements))) { groupsSeen.Add(group.Key); int expected = 1 + (count - (group.Key + 1)) / GroupFactor; IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected); Assert.All(group.Value, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ElementSelector_ResultSelector_Longrunning() { GroupBy_Unordered_ElementSelector_ResultSelector(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_ResultSelector(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (var group in query.GroupBy(x => x % GroupFactor, x => -x, (key, elements) => KeyValuePair.Create(key, elements))) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = -group.Key; Assert.All(group.Value, x => { Assert.Equal(elementsSeen, x); elementsSeen -= GroupFactor; }); Assert.Equal(-group.Key - (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_ResultSelector_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ElementSelector_ResultSelector(labeled, count); } [Fact] public static void GroupBy_ArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, IEnumerable<int>, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, IEnumerable<int>, int>)null, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, i => i, (Func<int, IEnumerable<int>, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, i => i, (Func<int, IEnumerable<int>, int>)null, EqualityComparer<int>.Default)); } [Fact] public static void GroupBy_LargeGroup_ForceInternalArrayToGrow() { const int Key = 42; const int LargeSize = 8192; // larger than GrowingArray's internal default array size IGrouping<int, int>[] result = ParallelEnumerable .Range(0, LargeSize) .AsOrdered() .GroupBy(i => Key) .ToArray(); Assert.NotNull(result); Assert.Equal(1, result.Length); Assert.Equal(Key, result[0].Key); Assert.Equal(LargeSize, result[0].Count()); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Linq.Parallel.Tests { public static class GroupByTests { private const int GroupFactor = 8; [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor)) { groupsSeen.Add(group.Key); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key + 1)) / GroupFactor); foreach (int i in group) { Assert.Equal(group.Key, i % GroupFactor); elementsSeen.Add(i / GroupFactor); } elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_Longrunning() { GroupBy_Unordered(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor)) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = group.Key; foreach (int i in group) { Assert.Equal(elementsSeen, i); elementsSeen += GroupFactor; } Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_NotPipelined(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor).ToList()) { groupsSeen.Add(group.Key); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key + 1)) / GroupFactor); Assert.All(group, x => { Assert.Equal(group.Key, x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_NotPipelined_Longrunning() { GroupBy_Unordered_NotPipelined(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor).ToList()) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = group.Key; Assert.All(group, x => { Assert.Equal(elementsSeen, x); elementsSeen += GroupFactor; }); Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_NotPipelined_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_NotPipelined(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_CustomComparator(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x, new ModularCongruenceComparer(GroupFactor))) { groupsSeen.Add(group.Key % GroupFactor); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key % GroupFactor + 1)) / GroupFactor); foreach (int i in group) { Assert.Equal(group.Key % GroupFactor, i % GroupFactor); elementsSeen.Add(i / GroupFactor); } elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_CustomComparator_Longrunning() { GroupBy_Unordered_CustomComparator(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] // GroupBy doesn't select the first 'identical' key. https://github.com/dotnet/runtime/issues/14472 public static void GroupBy_CustomComparator(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x, new ModularCongruenceComparer(GroupFactor))) { int elementsSeen = groupsSeen; Assert.Equal(groupsSeen++, group.Key % GroupFactor); foreach (int i in group) { Assert.Equal(elementsSeen, i); elementsSeen += GroupFactor; } Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_CustomComparator_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_CustomComparator(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ElementSelector(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, x => -x)) { groupsSeen.Add(group.Key); int expected = 1 + (count - (group.Key + 1)) / GroupFactor; IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected); Assert.All(group, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ElementSelector_Longrunning() { GroupBy_Unordered_ElementSelector(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor, x => -x)) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = -group.Key; Assert.All(group, x => { Assert.Equal(elementsSeen, x); elementsSeen -= GroupFactor; }); Assert.Equal(-group.Key - (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ElementSelector(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ElementSelector_NotPipelined(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (IGrouping<int, int> group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, y => -y).ToList()) { groupsSeen.Add(group.Key); int expected = 1 + (count - (group.Key + 1)) / GroupFactor; IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected); Assert.All(group, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ElementSelector_NotPipelined_Longrunning() { GroupBy_Unordered_ElementSelector_NotPipelined(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (IGrouping<int, int> group in query.GroupBy(x => x % GroupFactor, y => -y).ToList()) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = -group.Key; Assert.All(group, x => { Assert.Equal(elementsSeen, x); elementsSeen -= GroupFactor; }); Assert.Equal(-group.Key - (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_NotPipelined_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ElementSelector_NotPipelined(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ResultSelector(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (var group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, (key, elements) => KeyValuePair.Create(key, elements))) { groupsSeen.Add(group.Key); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key + 1)) / GroupFactor); Assert.All(group.Value, x => { Assert.Equal(group.Key, x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ResultSelector_Longrunning() { GroupBy_Unordered_ResultSelector(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (var group in query.GroupBy(x => x % GroupFactor, (key, elements) => KeyValuePair.Create(key, elements))) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = group.Key; Assert.All(group.Value, x => { Assert.Equal(elementsSeen, x); elementsSeen += GroupFactor; }); Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ResultSelector(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ResultSelector_CustomComparator(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (var group in UnorderedSources.Default(count).GroupBy(x => x, (key, elements) => KeyValuePair.Create(key, elements), new ModularCongruenceComparer(GroupFactor))) { groupsSeen.Add(group.Key % GroupFactor); IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key % GroupFactor + 1)) / GroupFactor); Assert.All(group.Value, x => { Assert.Equal(group.Key % GroupFactor, x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ResultSelector_CustomComparator_Longrunning() { GroupBy_Unordered_ResultSelector_CustomComparator(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector_CustomComparator(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (var group in query.GroupBy(x => x, (key, elements) => KeyValuePair.Create(key, elements), new ModularCongruenceComparer(GroupFactor))) { int elementsSeen = groupsSeen; Assert.Equal(groupsSeen++, group.Key % GroupFactor); Assert.All(group.Value, x => { Assert.Equal(elementsSeen, x); elementsSeen += GroupFactor; }); Assert.Equal(group.Key + (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ResultSelector_CustomComparator_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ResultSelector_CustomComparator(labeled, count); } [Theory] [InlineData(0)] [InlineData(1)] [InlineData(2)] [InlineData(GroupFactor - 1)] [InlineData(GroupFactor)] [InlineData(GroupFactor * 2 - 1)] [InlineData(GroupFactor * 2)] public static void GroupBy_Unordered_ElementSelector_ResultSelector(int count) { IntegerRangeSet groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor)); foreach (var group in UnorderedSources.Default(count).GroupBy(x => x % GroupFactor, x => -x, (key, elements) => KeyValuePair.Create(key, elements))) { groupsSeen.Add(group.Key); int expected = 1 + (count - (group.Key + 1)) / GroupFactor; IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected); Assert.All(group.Value, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); }); elementsSeen.AssertComplete(); } groupsSeen.AssertComplete(); } [Fact] [OuterLoop] public static void GroupBy_Unordered_ElementSelector_ResultSelector_Longrunning() { GroupBy_Unordered_ElementSelector_ResultSelector(Sources.OuterLoopCount / 4); } [Theory] [MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, GroupFactor - 1, GroupFactor, GroupFactor * 2 - 1, GroupFactor * 2 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_ResultSelector(Labeled<ParallelQuery<int>> labeled, int count) { ParallelQuery<int> query = labeled.Item; int groupsSeen = 0; foreach (var group in query.GroupBy(x => x % GroupFactor, x => -x, (key, elements) => KeyValuePair.Create(key, elements))) { Assert.Equal(groupsSeen++, group.Key); int elementsSeen = -group.Key; Assert.All(group.Value, x => { Assert.Equal(elementsSeen, x); elementsSeen -= GroupFactor; }); Assert.Equal(-group.Key - (1 + (count - (group.Key + 1)) / GroupFactor) * GroupFactor, elementsSeen); } Assert.Equal(Math.Min(count, GroupFactor), groupsSeen); } [Theory] [OuterLoop] [MemberData(nameof(Sources.Ranges), new[] { 1024 * 64 }, MemberType = typeof(Sources))] public static void GroupBy_ElementSelector_ResultSelector_Longrunning(Labeled<ParallelQuery<int>> labeled, int count) { GroupBy_ElementSelector_ResultSelector(labeled, count); } [Fact] public static void GroupBy_ArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, IEnumerable<int>, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, IEnumerable<int>, int>)null, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null, (i, j) => i)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, i => i, (Func<int, IEnumerable<int>, int>)null)); AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<int>)null).GroupBy(i => i, i => i, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("keySelector", () => ParallelEnumerable.Range(0, 1).GroupBy((Func<int, int>)null, i => i, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, (Func<int, int>)null, (i, j) => i, EqualityComparer<int>.Default)); AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => ParallelEnumerable.Range(0, 1).GroupBy(i => i, i => i, (Func<int, IEnumerable<int>, int>)null, EqualityComparer<int>.Default)); } [Fact] public static void GroupBy_LargeGroup_ForceInternalArrayToGrow() { const int Key = 42; const int LargeSize = 8192; // larger than GrowingArray's internal default array size IGrouping<int, int>[] result = ParallelEnumerable .Range(0, LargeSize) .AsOrdered() .GroupBy(i => Key) .ToArray(); Assert.NotNull(result); Assert.Equal(1, result.Length); Assert.Equal(Key, result[0].Key); Assert.Equal(LargeSize, result[0].Count()); } } }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/native/external/brotli/tools/brotli.c
/* Copyright 2014 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Command line interface for Brotli library. */ /* Mute strerror/strcpy warnings. */ #if !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <time.h> #include "../common/constants.h" #include "../common/version.h" #include <brotli/decode.h> #include <brotli/encode.h> #if !defined(_WIN32) #include <unistd.h> #include <utime.h> #define MAKE_BINARY(FILENO) (FILENO) #else #include <io.h> #include <share.h> #include <sys/utime.h> #define MAKE_BINARY(FILENO) (_setmode((FILENO), _O_BINARY), (FILENO)) #if !defined(__MINGW32__) #define STDIN_FILENO _fileno(stdin) #define STDOUT_FILENO _fileno(stdout) #define S_IRUSR S_IREAD #define S_IWUSR S_IWRITE #endif #define fdopen _fdopen #define isatty _isatty #define unlink _unlink #define utimbuf _utimbuf #define utime _utime #define fopen ms_fopen #define open ms_open #define chmod(F, P) (0) #define chown(F, O, G) (0) #if defined(_MSC_VER) && (_MSC_VER >= 1400) #define fseek _fseeki64 #define ftell _ftelli64 #endif static FILE* ms_fopen(const char* filename, const char* mode) { FILE* result = 0; fopen_s(&result, filename, mode); return result; } static int ms_open(const char* filename, int oflag, int pmode) { int result = -1; _sopen_s(&result, filename, oflag | O_BINARY, _SH_DENYNO, pmode); return result; } #endif /* WIN32 */ typedef enum { COMMAND_COMPRESS, COMMAND_DECOMPRESS, COMMAND_HELP, COMMAND_INVALID, COMMAND_TEST_INTEGRITY, COMMAND_NOOP, COMMAND_VERSION } Command; #define DEFAULT_LGWIN 24 #define DEFAULT_SUFFIX ".br" #define MAX_OPTIONS 20 typedef struct { /* Parameters */ int quality; int lgwin; int verbosity; BROTLI_BOOL force_overwrite; BROTLI_BOOL junk_source; BROTLI_BOOL copy_stat; BROTLI_BOOL write_to_stdout; BROTLI_BOOL test_integrity; BROTLI_BOOL decompress; BROTLI_BOOL large_window; const char* output_path; const char* suffix; int not_input_indices[MAX_OPTIONS]; size_t longest_path_len; size_t input_count; /* Inner state */ int argc; char** argv; char* modified_path; /* Storage for path with appended / cut suffix */ int iterator; int ignore; BROTLI_BOOL iterator_error; uint8_t* buffer; uint8_t* input; uint8_t* output; const char* current_input_path; const char* current_output_path; int64_t input_file_length; /* -1, if impossible to calculate */ FILE* fin; FILE* fout; /* I/O buffers */ size_t available_in; const uint8_t* next_in; size_t available_out; uint8_t* next_out; /* Reporting */ /* size_t would be large enough, until 4GiB+ files are compressed / decompressed on 32-bit CPUs. */ size_t total_in; size_t total_out; } Context; /* Parse up to 5 decimal digits. */ static BROTLI_BOOL ParseInt(const char* s, int low, int high, int* result) { int value = 0; int i; for (i = 0; i < 5; ++i) { char c = s[i]; if (c == 0) break; if (s[i] < '0' || s[i] > '9') return BROTLI_FALSE; value = (10 * value) + (c - '0'); } if (i == 0) return BROTLI_FALSE; if (i > 1 && s[0] == '0') return BROTLI_FALSE; if (s[i] != 0) return BROTLI_FALSE; if (value < low || value > high) return BROTLI_FALSE; *result = value; return BROTLI_TRUE; } /* Returns "base file name" or its tail, if it contains '/' or '\'. */ static const char* FileName(const char* path) { const char* separator_position = strrchr(path, '/'); if (separator_position) path = separator_position + 1; separator_position = strrchr(path, '\\'); if (separator_position) path = separator_position + 1; return path; } /* Detect if the program name is a special alias that infers a command type. */ static Command ParseAlias(const char* name) { /* TODO: cast name to lower case? */ const char* unbrotli = "unbrotli"; size_t unbrotli_len = strlen(unbrotli); name = FileName(name); /* Partial comparison. On Windows there could be ".exe" suffix. */ if (strncmp(name, unbrotli, unbrotli_len) == 0) { char terminator = name[unbrotli_len]; if (terminator == 0 || terminator == '.') return COMMAND_DECOMPRESS; } return COMMAND_COMPRESS; } static Command ParseParams(Context* params) { int argc = params->argc; char** argv = params->argv; int i; int next_option_index = 0; size_t input_count = 0; size_t longest_path_len = 1; BROTLI_BOOL command_set = BROTLI_FALSE; BROTLI_BOOL quality_set = BROTLI_FALSE; BROTLI_BOOL output_set = BROTLI_FALSE; BROTLI_BOOL keep_set = BROTLI_FALSE; BROTLI_BOOL lgwin_set = BROTLI_FALSE; BROTLI_BOOL suffix_set = BROTLI_FALSE; BROTLI_BOOL after_dash_dash = BROTLI_FALSE; Command command = ParseAlias(argv[0]); for (i = 1; i < argc; ++i) { const char* arg = argv[i]; /* C99 5.1.2.2.1: "members argv[0] through argv[argc-1] inclusive shall contain pointers to strings"; NULL and 0-length are not forbidden. */ size_t arg_len = arg ? strlen(arg) : 0; if (arg_len == 0) { params->not_input_indices[next_option_index++] = i; continue; } /* Too many options. The expected longest option list is: "-q 0 -w 10 -o f -D d -S b -d -f -k -n -v --", i.e. 16 items in total. This check is an additional guard that is never triggered, but provides a guard for future changes. */ if (next_option_index > (MAX_OPTIONS - 2)) { fprintf(stderr, "too many options passed\n"); return COMMAND_INVALID; } /* Input file entry. */ if (after_dash_dash || arg[0] != '-' || arg_len == 1) { input_count++; if (longest_path_len < arg_len) longest_path_len = arg_len; continue; } /* Not a file entry. */ params->not_input_indices[next_option_index++] = i; /* '--' entry stop parsing arguments. */ if (arg_len == 2 && arg[1] == '-') { after_dash_dash = BROTLI_TRUE; continue; } /* Simple / coalesced options. */ if (arg[1] != '-') { size_t j; for (j = 1; j < arg_len; ++j) { char c = arg[j]; if (c >= '0' && c <= '9') { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = BROTLI_TRUE; params->quality = c - '0'; continue; } else if (c == 'c') { if (output_set) { fprintf(stderr, "write to standard output already set\n"); return COMMAND_INVALID; } output_set = BROTLI_TRUE; params->write_to_stdout = BROTLI_TRUE; continue; } else if (c == 'd') { if (command_set) { fprintf(stderr, "command already set when parsing -d\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_DECOMPRESS; continue; } else if (c == 'f') { if (params->force_overwrite) { fprintf(stderr, "force output overwrite already set\n"); return COMMAND_INVALID; } params->force_overwrite = BROTLI_TRUE; continue; } else if (c == 'h') { /* Don't parse further. */ return COMMAND_HELP; } else if (c == 'j' || c == 'k') { if (keep_set) { fprintf(stderr, "argument --rm / -j or --keep / -k already set\n"); return COMMAND_INVALID; } keep_set = BROTLI_TRUE; params->junk_source = TO_BROTLI_BOOL(c == 'j'); continue; } else if (c == 'n') { if (!params->copy_stat) { fprintf(stderr, "argument --no-copy-stat / -n already set\n"); return COMMAND_INVALID; } params->copy_stat = BROTLI_FALSE; continue; } else if (c == 't') { if (command_set) { fprintf(stderr, "command already set when parsing -t\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_TEST_INTEGRITY; continue; } else if (c == 'v') { if (params->verbosity > 0) { fprintf(stderr, "argument --verbose / -v already set\n"); return COMMAND_INVALID; } params->verbosity = 1; continue; } else if (c == 'V') { /* Don't parse further. */ return COMMAND_VERSION; } else if (c == 'Z') { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = BROTLI_TRUE; params->quality = 11; continue; } /* o/q/w/D/S with parameter is expected */ if (c != 'o' && c != 'q' && c != 'w' && c != 'D' && c != 'S') { fprintf(stderr, "invalid argument -%c\n", c); return COMMAND_INVALID; } if (j + 1 != arg_len) { fprintf(stderr, "expected parameter for argument -%c\n", c); return COMMAND_INVALID; } i++; if (i == argc || !argv[i] || argv[i][0] == 0) { fprintf(stderr, "expected parameter for argument -%c\n", c); return COMMAND_INVALID; } params->not_input_indices[next_option_index++] = i; if (c == 'o') { if (output_set) { fprintf(stderr, "write to standard output already set (-o)\n"); return COMMAND_INVALID; } params->output_path = argv[i]; } else if (c == 'q') { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = ParseInt(argv[i], BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY, &params->quality); if (!quality_set) { fprintf(stderr, "error parsing quality value [%s]\n", argv[i]); return COMMAND_INVALID; } } else if (c == 'w') { if (lgwin_set) { fprintf(stderr, "lgwin parameter already set\n"); return COMMAND_INVALID; } lgwin_set = ParseInt(argv[i], 0, BROTLI_MAX_WINDOW_BITS, &params->lgwin); if (!lgwin_set) { fprintf(stderr, "error parsing lgwin value [%s]\n", argv[i]); return COMMAND_INVALID; } if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) { fprintf(stderr, "lgwin parameter (%d) smaller than the minimum (%d)\n", params->lgwin, BROTLI_MIN_WINDOW_BITS); return COMMAND_INVALID; } } else if (c == 'S') { if (suffix_set) { fprintf(stderr, "suffix already set\n"); return COMMAND_INVALID; } suffix_set = BROTLI_TRUE; params->suffix = argv[i]; } } } else { /* Double-dash. */ arg = &arg[2]; if (strcmp("best", arg) == 0) { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = BROTLI_TRUE; params->quality = 11; } else if (strcmp("decompress", arg) == 0) { if (command_set) { fprintf(stderr, "command already set when parsing --decompress\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_DECOMPRESS; } else if (strcmp("force", arg) == 0) { if (params->force_overwrite) { fprintf(stderr, "force output overwrite already set\n"); return COMMAND_INVALID; } params->force_overwrite = BROTLI_TRUE; } else if (strcmp("help", arg) == 0) { /* Don't parse further. */ return COMMAND_HELP; } else if (strcmp("keep", arg) == 0) { if (keep_set) { fprintf(stderr, "argument --rm / -j or --keep / -k already set\n"); return COMMAND_INVALID; } keep_set = BROTLI_TRUE; params->junk_source = BROTLI_FALSE; } else if (strcmp("no-copy-stat", arg) == 0) { if (!params->copy_stat) { fprintf(stderr, "argument --no-copy-stat / -n already set\n"); return COMMAND_INVALID; } params->copy_stat = BROTLI_FALSE; } else if (strcmp("rm", arg) == 0) { if (keep_set) { fprintf(stderr, "argument --rm / -j or --keep / -k already set\n"); return COMMAND_INVALID; } keep_set = BROTLI_TRUE; params->junk_source = BROTLI_TRUE; } else if (strcmp("stdout", arg) == 0) { if (output_set) { fprintf(stderr, "write to standard output already set\n"); return COMMAND_INVALID; } output_set = BROTLI_TRUE; params->write_to_stdout = BROTLI_TRUE; } else if (strcmp("test", arg) == 0) { if (command_set) { fprintf(stderr, "command already set when parsing --test\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_TEST_INTEGRITY; } else if (strcmp("verbose", arg) == 0) { if (params->verbosity > 0) { fprintf(stderr, "argument --verbose / -v already set\n"); return COMMAND_INVALID; } params->verbosity = 1; } else if (strcmp("version", arg) == 0) { /* Don't parse further. */ return COMMAND_VERSION; } else { /* key=value */ const char* value = strrchr(arg, '='); size_t key_len; if (!value || value[1] == 0) { fprintf(stderr, "must pass the parameter as --%s=value\n", arg); return COMMAND_INVALID; } key_len = (size_t)(value - arg); value++; if (strncmp("lgwin", arg, key_len) == 0) { if (lgwin_set) { fprintf(stderr, "lgwin parameter already set\n"); return COMMAND_INVALID; } lgwin_set = ParseInt(value, 0, BROTLI_MAX_WINDOW_BITS, &params->lgwin); if (!lgwin_set) { fprintf(stderr, "error parsing lgwin value [%s]\n", value); return COMMAND_INVALID; } if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) { fprintf(stderr, "lgwin parameter (%d) smaller than the minimum (%d)\n", params->lgwin, BROTLI_MIN_WINDOW_BITS); return COMMAND_INVALID; } } else if (strncmp("large_window", arg, key_len) == 0) { /* This option is intentionally not mentioned in help. */ if (lgwin_set) { fprintf(stderr, "lgwin parameter already set\n"); return COMMAND_INVALID; } lgwin_set = ParseInt(value, 0, BROTLI_LARGE_MAX_WINDOW_BITS, &params->lgwin); if (!lgwin_set) { fprintf(stderr, "error parsing lgwin value [%s]\n", value); return COMMAND_INVALID; } if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) { fprintf(stderr, "lgwin parameter (%d) smaller than the minimum (%d)\n", params->lgwin, BROTLI_MIN_WINDOW_BITS); return COMMAND_INVALID; } } else if (strncmp("output", arg, key_len) == 0) { if (output_set) { fprintf(stderr, "write to standard output already set (--output)\n"); return COMMAND_INVALID; } params->output_path = value; } else if (strncmp("quality", arg, key_len) == 0) { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = ParseInt(value, BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY, &params->quality); if (!quality_set) { fprintf(stderr, "error parsing quality value [%s]\n", value); return COMMAND_INVALID; } } else if (strncmp("suffix", arg, key_len) == 0) { if (suffix_set) { fprintf(stderr, "suffix already set\n"); return COMMAND_INVALID; } suffix_set = BROTLI_TRUE; params->suffix = value; } else { fprintf(stderr, "invalid parameter: [%s]\n", arg); return COMMAND_INVALID; } } } } params->input_count = input_count; params->longest_path_len = longest_path_len; params->decompress = (command == COMMAND_DECOMPRESS); params->test_integrity = (command == COMMAND_TEST_INTEGRITY); if (input_count > 1 && output_set) return COMMAND_INVALID; if (params->test_integrity) { if (params->output_path) return COMMAND_INVALID; if (params->write_to_stdout) return COMMAND_INVALID; } if (strchr(params->suffix, '/') || strchr(params->suffix, '\\')) { return COMMAND_INVALID; } return command; } static void PrintVersion(void) { int major = BROTLI_VERSION >> 24; int minor = (BROTLI_VERSION >> 12) & 0xFFF; int patch = BROTLI_VERSION & 0xFFF; fprintf(stdout, "brotli %d.%d.%d\n", major, minor, patch); } static void PrintHelp(const char* name, BROTLI_BOOL error) { FILE* media = error ? stderr : stdout; /* String is cut to pieces with length less than 509, to conform C90 spec. */ fprintf(media, "Usage: %s [OPTION]... [FILE]...\n", name); fprintf(media, "Options:\n" " -# compression level (0-9)\n" " -c, --stdout write on standard output\n" " -d, --decompress decompress\n" " -f, --force force output file overwrite\n" " -h, --help display this help and exit\n"); fprintf(media, " -j, --rm remove source file(s)\n" " -k, --keep keep source file(s) (default)\n" " -n, --no-copy-stat do not copy source file(s) attributes\n" " -o FILE, --output=FILE output file (only if 1 input file)\n"); fprintf(media, " -q NUM, --quality=NUM compression level (%d-%d)\n", BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY); fprintf(media, " -t, --test test compressed file integrity\n" " -v, --verbose verbose mode\n"); fprintf(media, " -w NUM, --lgwin=NUM set LZ77 window size (0, %d-%d)\n" " window size = 2**NUM - 16\n" " 0 lets compressor choose the optimal value\n", BROTLI_MIN_WINDOW_BITS, BROTLI_MAX_WINDOW_BITS); fprintf(media, " --large_window=NUM use incompatible large-window brotli\n" " bitstream with window size (0, %d-%d)\n" " WARNING: this format is not compatible\n" " with brotli RFC 7932 and may not be\n" " decodable with regular brotli decoders\n", BROTLI_MIN_WINDOW_BITS, BROTLI_LARGE_MAX_WINDOW_BITS); fprintf(media, " -S SUF, --suffix=SUF output file suffix (default:'%s')\n", DEFAULT_SUFFIX); fprintf(media, " -V, --version display version and exit\n" " -Z, --best use best compression level (11) (default)\n" "Simple options could be coalesced, i.e. '-9kf' is equivalent to '-9 -k -f'.\n" "With no FILE, or when FILE is -, read standard input.\n" "All arguments after '--' are treated as files.\n"); } static const char* PrintablePath(const char* path) { return path ? path : "con"; } static BROTLI_BOOL OpenInputFile(const char* input_path, FILE** f) { *f = NULL; if (!input_path) { *f = fdopen(MAKE_BINARY(STDIN_FILENO), "rb"); return BROTLI_TRUE; } *f = fopen(input_path, "rb"); if (!*f) { fprintf(stderr, "failed to open input file [%s]: %s\n", PrintablePath(input_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } static BROTLI_BOOL OpenOutputFile(const char* output_path, FILE** f, BROTLI_BOOL force) { int fd; *f = NULL; if (!output_path) { *f = fdopen(MAKE_BINARY(STDOUT_FILENO), "wb"); return BROTLI_TRUE; } fd = open(output_path, O_CREAT | (force ? 0 : O_EXCL) | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR); if (fd < 0) { fprintf(stderr, "failed to open output file [%s]: %s\n", PrintablePath(output_path), strerror(errno)); return BROTLI_FALSE; } *f = fdopen(fd, "wb"); if (!*f) { fprintf(stderr, "failed to open output file [%s]: %s\n", PrintablePath(output_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } static int64_t FileSize(const char* path) { FILE* f = fopen(path, "rb"); int64_t retval; if (f == NULL) { return -1; } if (fseek(f, 0L, SEEK_END) != 0) { fclose(f); return -1; } retval = ftell(f); if (fclose(f) != 0) { return -1; } return retval; } /* Copy file times and permissions. TODO: this is a "best effort" implementation; honest cross-platform fully featured implementation is way too hacky; add more hacks by request. */ static void CopyStat(const char* input_path, const char* output_path) { struct stat statbuf; struct utimbuf times; int res; if (input_path == 0 || output_path == 0) { return; } if (stat(input_path, &statbuf) != 0) { return; } times.actime = statbuf.st_atime; times.modtime = statbuf.st_mtime; utime(output_path, &times); res = chmod(output_path, statbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)); if (res != 0) { fprintf(stderr, "setting access bits failed for [%s]: %s\n", PrintablePath(output_path), strerror(errno)); } res = chown(output_path, (uid_t)-1, statbuf.st_gid); if (res != 0) { fprintf(stderr, "setting group failed for [%s]: %s\n", PrintablePath(output_path), strerror(errno)); } res = chown(output_path, statbuf.st_uid, (gid_t)-1); if (res != 0) { fprintf(stderr, "setting user failed for [%s]: %s\n", PrintablePath(output_path), strerror(errno)); } } static BROTLI_BOOL NextFile(Context* context) { const char* arg; size_t arg_len; /* Iterator points to last used arg; increment to search for the next one. */ context->iterator++; context->input_file_length = -1; /* No input path; read from console. */ if (context->input_count == 0) { if (context->iterator > 1) return BROTLI_FALSE; context->current_input_path = NULL; /* Either write to the specified path, or to console. */ context->current_output_path = context->output_path; return BROTLI_TRUE; } /* Skip option arguments. */ while (context->iterator == context->not_input_indices[context->ignore]) { context->iterator++; context->ignore++; } /* All args are scanned already. */ if (context->iterator >= context->argc) return BROTLI_FALSE; /* Iterator now points to the input file name. */ arg = context->argv[context->iterator]; arg_len = strlen(arg); /* Read from console. */ if (arg_len == 1 && arg[0] == '-') { context->current_input_path = NULL; context->current_output_path = context->output_path; return BROTLI_TRUE; } context->current_input_path = arg; context->input_file_length = FileSize(arg); context->current_output_path = context->output_path; if (context->output_path) return BROTLI_TRUE; if (context->write_to_stdout) return BROTLI_TRUE; strcpy(context->modified_path, arg); context->current_output_path = context->modified_path; /* If output is not specified, input path suffix should match. */ if (context->decompress) { size_t suffix_len = strlen(context->suffix); char* name = (char*)FileName(context->modified_path); char* name_suffix; size_t name_len = strlen(name); if (name_len < suffix_len + 1) { fprintf(stderr, "empty output file name for [%s] input file\n", PrintablePath(arg)); context->iterator_error = BROTLI_TRUE; return BROTLI_FALSE; } name_suffix = name + name_len - suffix_len; if (strcmp(context->suffix, name_suffix) != 0) { fprintf(stderr, "input file [%s] suffix mismatch\n", PrintablePath(arg)); context->iterator_error = BROTLI_TRUE; return BROTLI_FALSE; } name_suffix[0] = 0; return BROTLI_TRUE; } else { strcpy(context->modified_path + arg_len, context->suffix); return BROTLI_TRUE; } } static BROTLI_BOOL OpenFiles(Context* context) { BROTLI_BOOL is_ok = OpenInputFile(context->current_input_path, &context->fin); if (!context->test_integrity && is_ok) { is_ok = OpenOutputFile( context->current_output_path, &context->fout, context->force_overwrite); } return is_ok; } static BROTLI_BOOL CloseFiles(Context* context, BROTLI_BOOL success) { BROTLI_BOOL is_ok = BROTLI_TRUE; if (!context->test_integrity && context->fout) { if (!success && context->current_output_path) { unlink(context->current_output_path); } if (fclose(context->fout) != 0) { if (success) { fprintf(stderr, "fclose failed [%s]: %s\n", PrintablePath(context->current_output_path), strerror(errno)); } is_ok = BROTLI_FALSE; } /* TOCTOU violation, but otherwise it is impossible to set file times. */ if (success && is_ok && context->copy_stat) { CopyStat(context->current_input_path, context->current_output_path); } } if (context->fin) { if (fclose(context->fin) != 0) { if (is_ok) { fprintf(stderr, "fclose failed [%s]: %s\n", PrintablePath(context->current_input_path), strerror(errno)); } is_ok = BROTLI_FALSE; } } if (success && context->junk_source && context->current_input_path) { unlink(context->current_input_path); } context->fin = NULL; context->fout = NULL; return is_ok; } static const size_t kFileBufferSize = 1 << 19; static void InitializeBuffers(Context* context) { context->available_in = 0; context->next_in = NULL; context->available_out = kFileBufferSize; context->next_out = context->output; context->total_in = 0; context->total_out = 0; } /* This method might give the false-negative result. However, after an empty / incomplete read it should tell the truth. */ static BROTLI_BOOL HasMoreInput(Context* context) { return feof(context->fin) ? BROTLI_FALSE : BROTLI_TRUE; } static BROTLI_BOOL ProvideInput(Context* context) { context->available_in = fread(context->input, 1, kFileBufferSize, context->fin); context->total_in += context->available_in; context->next_in = context->input; if (ferror(context->fin)) { fprintf(stderr, "failed to read input [%s]: %s\n", PrintablePath(context->current_input_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } /* Internal: should be used only in Provide-/Flush-Output. */ static BROTLI_BOOL WriteOutput(Context* context) { size_t out_size = (size_t)(context->next_out - context->output); context->total_out += out_size; if (out_size == 0) return BROTLI_TRUE; if (context->test_integrity) return BROTLI_TRUE; fwrite(context->output, 1, out_size, context->fout); if (ferror(context->fout)) { fprintf(stderr, "failed to write output [%s]: %s\n", PrintablePath(context->current_output_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } static BROTLI_BOOL ProvideOutput(Context* context) { if (!WriteOutput(context)) return BROTLI_FALSE; context->available_out = kFileBufferSize; context->next_out = context->output; return BROTLI_TRUE; } static BROTLI_BOOL FlushOutput(Context* context) { if (!WriteOutput(context)) return BROTLI_FALSE; context->available_out = 0; return BROTLI_TRUE; } static void PrintBytes(size_t value) { if (value < 1024) { fprintf(stderr, "%d B", (int)value); } else if (value < 1048576) { fprintf(stderr, "%0.3f KiB", (double)value / 1024.0); } else if (value < 1073741824) { fprintf(stderr, "%0.3f MiB", (double)value / 1048576.0); } else { fprintf(stderr, "%0.3f GiB", (double)value / 1073741824.0); } } static void PrintFileProcessingProgress(Context* context) { fprintf(stderr, "[%s]: ", PrintablePath(context->current_input_path)); PrintBytes(context->total_in); fprintf(stderr, " -> "); PrintBytes(context->total_out); } static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) { BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT; InitializeBuffers(context); for (;;) { if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) { if (!HasMoreInput(context)) { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } if (!ProvideInput(context)) return BROTLI_FALSE; } else if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) { if (!ProvideOutput(context)) return BROTLI_FALSE; } else if (result == BROTLI_DECODER_RESULT_SUCCESS) { if (!FlushOutput(context)) return BROTLI_FALSE; int has_more_input = (context->available_in != 0) || (fgetc(context->fin) != EOF); if (has_more_input) { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } if (context->verbosity > 0) { fprintf(stderr, "Decompressed "); PrintFileProcessingProgress(context); fprintf(stderr, "\n"); } return BROTLI_TRUE; } else { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } result = BrotliDecoderDecompressStream(s, &context->available_in, &context->next_in, &context->available_out, &context->next_out, 0); } } static BROTLI_BOOL DecompressFiles(Context* context) { while (NextFile(context)) { BROTLI_BOOL is_ok = BROTLI_TRUE; BrotliDecoderState* s = BrotliDecoderCreateInstance(NULL, NULL, NULL); if (!s) { fprintf(stderr, "out of memory\n"); return BROTLI_FALSE; } /* This allows decoding "large-window" streams. Though it creates fragmentation (new builds decode streams that old builds don't), it is better from used experience perspective. */ BrotliDecoderSetParameter(s, BROTLI_DECODER_PARAM_LARGE_WINDOW, 1u); is_ok = OpenFiles(context); if (is_ok && !context->current_input_path && !context->force_overwrite && isatty(STDIN_FILENO)) { fprintf(stderr, "Use -h help. Use -f to force input from a terminal.\n"); is_ok = BROTLI_FALSE; } if (is_ok) is_ok = DecompressFile(context, s); BrotliDecoderDestroyInstance(s); if (!CloseFiles(context, is_ok)) is_ok = BROTLI_FALSE; if (!is_ok) return BROTLI_FALSE; } return BROTLI_TRUE; } static BROTLI_BOOL CompressFile(Context* context, BrotliEncoderState* s) { BROTLI_BOOL is_eof = BROTLI_FALSE; InitializeBuffers(context); for (;;) { if (context->available_in == 0 && !is_eof) { if (!ProvideInput(context)) return BROTLI_FALSE; is_eof = !HasMoreInput(context); } if (!BrotliEncoderCompressStream(s, is_eof ? BROTLI_OPERATION_FINISH : BROTLI_OPERATION_PROCESS, &context->available_in, &context->next_in, &context->available_out, &context->next_out, NULL)) { /* Should detect OOM? */ fprintf(stderr, "failed to compress data [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } if (context->available_out == 0) { if (!ProvideOutput(context)) return BROTLI_FALSE; } if (BrotliEncoderIsFinished(s)) { if (!FlushOutput(context)) return BROTLI_FALSE; if (context->verbosity > 0) { fprintf(stderr, "Compressed "); PrintFileProcessingProgress(context); fprintf(stderr, "\n"); } return BROTLI_TRUE; } } } static BROTLI_BOOL CompressFiles(Context* context) { while (NextFile(context)) { BROTLI_BOOL is_ok = BROTLI_TRUE; BrotliEncoderState* s = BrotliEncoderCreateInstance(NULL, NULL, NULL); if (!s) { fprintf(stderr, "out of memory\n"); return BROTLI_FALSE; } BrotliEncoderSetParameter(s, BROTLI_PARAM_QUALITY, (uint32_t)context->quality); if (context->lgwin > 0) { /* Specified by user. */ /* Do not enable "large-window" extension, if not required. */ if (context->lgwin > BROTLI_MAX_WINDOW_BITS) { BrotliEncoderSetParameter(s, BROTLI_PARAM_LARGE_WINDOW, 1u); } BrotliEncoderSetParameter(s, BROTLI_PARAM_LGWIN, (uint32_t)context->lgwin); } else { /* 0, or not specified by user; could be chosen by compressor. */ uint32_t lgwin = DEFAULT_LGWIN; /* Use file size to limit lgwin. */ if (context->input_file_length >= 0) { lgwin = BROTLI_MIN_WINDOW_BITS; while (BROTLI_MAX_BACKWARD_LIMIT(lgwin) < (uint64_t)context->input_file_length) { lgwin++; if (lgwin == BROTLI_MAX_WINDOW_BITS) break; } } BrotliEncoderSetParameter(s, BROTLI_PARAM_LGWIN, lgwin); } if (context->input_file_length > 0) { uint32_t size_hint = context->input_file_length < (1 << 30) ? (uint32_t)context->input_file_length : (1u << 30); BrotliEncoderSetParameter(s, BROTLI_PARAM_SIZE_HINT, size_hint); } is_ok = OpenFiles(context); if (is_ok && !context->current_output_path && !context->force_overwrite && isatty(STDOUT_FILENO)) { fprintf(stderr, "Use -h help. Use -f to force output to a terminal.\n"); is_ok = BROTLI_FALSE; } if (is_ok) is_ok = CompressFile(context, s); BrotliEncoderDestroyInstance(s); if (!CloseFiles(context, is_ok)) is_ok = BROTLI_FALSE; if (!is_ok) return BROTLI_FALSE; } return BROTLI_TRUE; } int main(int argc, char** argv) { Command command; Context context; BROTLI_BOOL is_ok = BROTLI_TRUE; int i; context.quality = 11; context.lgwin = -1; context.verbosity = 0; context.force_overwrite = BROTLI_FALSE; context.junk_source = BROTLI_FALSE; context.copy_stat = BROTLI_TRUE; context.test_integrity = BROTLI_FALSE; context.write_to_stdout = BROTLI_FALSE; context.decompress = BROTLI_FALSE; context.large_window = BROTLI_FALSE; context.output_path = NULL; context.suffix = DEFAULT_SUFFIX; for (i = 0; i < MAX_OPTIONS; ++i) context.not_input_indices[i] = 0; context.longest_path_len = 1; context.input_count = 0; context.argc = argc; context.argv = argv; context.modified_path = NULL; context.iterator = 0; context.ignore = 0; context.iterator_error = BROTLI_FALSE; context.buffer = NULL; context.current_input_path = NULL; context.current_output_path = NULL; context.fin = NULL; context.fout = NULL; command = ParseParams(&context); if (command == COMMAND_COMPRESS || command == COMMAND_DECOMPRESS || command == COMMAND_TEST_INTEGRITY) { if (is_ok) { size_t modified_path_len = context.longest_path_len + strlen(context.suffix) + 1; context.modified_path = (char*)malloc(modified_path_len); context.buffer = (uint8_t*)malloc(kFileBufferSize * 2); if (!context.modified_path || !context.buffer) { fprintf(stderr, "out of memory\n"); is_ok = BROTLI_FALSE; } else { context.input = context.buffer; context.output = context.buffer + kFileBufferSize; } } } if (!is_ok) command = COMMAND_NOOP; switch (command) { case COMMAND_NOOP: break; case COMMAND_VERSION: PrintVersion(); break; case COMMAND_COMPRESS: is_ok = CompressFiles(&context); break; case COMMAND_DECOMPRESS: case COMMAND_TEST_INTEGRITY: is_ok = DecompressFiles(&context); break; case COMMAND_HELP: case COMMAND_INVALID: default: is_ok = (command == COMMAND_HELP); PrintHelp(FileName(argv[0]), is_ok); break; } if (context.iterator_error) is_ok = BROTLI_FALSE; free(context.modified_path); free(context.buffer); if (!is_ok) exit(1); return 0; }
/* Copyright 2014 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Command line interface for Brotli library. */ /* Mute strerror/strcpy warnings. */ #if !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <time.h> #include "../common/constants.h" #include "../common/version.h" #include <brotli/decode.h> #include <brotli/encode.h> #if !defined(_WIN32) #include <unistd.h> #include <utime.h> #define MAKE_BINARY(FILENO) (FILENO) #else #include <io.h> #include <share.h> #include <sys/utime.h> #define MAKE_BINARY(FILENO) (_setmode((FILENO), _O_BINARY), (FILENO)) #if !defined(__MINGW32__) #define STDIN_FILENO _fileno(stdin) #define STDOUT_FILENO _fileno(stdout) #define S_IRUSR S_IREAD #define S_IWUSR S_IWRITE #endif #define fdopen _fdopen #define isatty _isatty #define unlink _unlink #define utimbuf _utimbuf #define utime _utime #define fopen ms_fopen #define open ms_open #define chmod(F, P) (0) #define chown(F, O, G) (0) #if defined(_MSC_VER) && (_MSC_VER >= 1400) #define fseek _fseeki64 #define ftell _ftelli64 #endif static FILE* ms_fopen(const char* filename, const char* mode) { FILE* result = 0; fopen_s(&result, filename, mode); return result; } static int ms_open(const char* filename, int oflag, int pmode) { int result = -1; _sopen_s(&result, filename, oflag | O_BINARY, _SH_DENYNO, pmode); return result; } #endif /* WIN32 */ typedef enum { COMMAND_COMPRESS, COMMAND_DECOMPRESS, COMMAND_HELP, COMMAND_INVALID, COMMAND_TEST_INTEGRITY, COMMAND_NOOP, COMMAND_VERSION } Command; #define DEFAULT_LGWIN 24 #define DEFAULT_SUFFIX ".br" #define MAX_OPTIONS 20 typedef struct { /* Parameters */ int quality; int lgwin; int verbosity; BROTLI_BOOL force_overwrite; BROTLI_BOOL junk_source; BROTLI_BOOL copy_stat; BROTLI_BOOL write_to_stdout; BROTLI_BOOL test_integrity; BROTLI_BOOL decompress; BROTLI_BOOL large_window; const char* output_path; const char* suffix; int not_input_indices[MAX_OPTIONS]; size_t longest_path_len; size_t input_count; /* Inner state */ int argc; char** argv; char* modified_path; /* Storage for path with appended / cut suffix */ int iterator; int ignore; BROTLI_BOOL iterator_error; uint8_t* buffer; uint8_t* input; uint8_t* output; const char* current_input_path; const char* current_output_path; int64_t input_file_length; /* -1, if impossible to calculate */ FILE* fin; FILE* fout; /* I/O buffers */ size_t available_in; const uint8_t* next_in; size_t available_out; uint8_t* next_out; /* Reporting */ /* size_t would be large enough, until 4GiB+ files are compressed / decompressed on 32-bit CPUs. */ size_t total_in; size_t total_out; } Context; /* Parse up to 5 decimal digits. */ static BROTLI_BOOL ParseInt(const char* s, int low, int high, int* result) { int value = 0; int i; for (i = 0; i < 5; ++i) { char c = s[i]; if (c == 0) break; if (s[i] < '0' || s[i] > '9') return BROTLI_FALSE; value = (10 * value) + (c - '0'); } if (i == 0) return BROTLI_FALSE; if (i > 1 && s[0] == '0') return BROTLI_FALSE; if (s[i] != 0) return BROTLI_FALSE; if (value < low || value > high) return BROTLI_FALSE; *result = value; return BROTLI_TRUE; } /* Returns "base file name" or its tail, if it contains '/' or '\'. */ static const char* FileName(const char* path) { const char* separator_position = strrchr(path, '/'); if (separator_position) path = separator_position + 1; separator_position = strrchr(path, '\\'); if (separator_position) path = separator_position + 1; return path; } /* Detect if the program name is a special alias that infers a command type. */ static Command ParseAlias(const char* name) { /* TODO: cast name to lower case? */ const char* unbrotli = "unbrotli"; size_t unbrotli_len = strlen(unbrotli); name = FileName(name); /* Partial comparison. On Windows there could be ".exe" suffix. */ if (strncmp(name, unbrotli, unbrotli_len) == 0) { char terminator = name[unbrotli_len]; if (terminator == 0 || terminator == '.') return COMMAND_DECOMPRESS; } return COMMAND_COMPRESS; } static Command ParseParams(Context* params) { int argc = params->argc; char** argv = params->argv; int i; int next_option_index = 0; size_t input_count = 0; size_t longest_path_len = 1; BROTLI_BOOL command_set = BROTLI_FALSE; BROTLI_BOOL quality_set = BROTLI_FALSE; BROTLI_BOOL output_set = BROTLI_FALSE; BROTLI_BOOL keep_set = BROTLI_FALSE; BROTLI_BOOL lgwin_set = BROTLI_FALSE; BROTLI_BOOL suffix_set = BROTLI_FALSE; BROTLI_BOOL after_dash_dash = BROTLI_FALSE; Command command = ParseAlias(argv[0]); for (i = 1; i < argc; ++i) { const char* arg = argv[i]; /* C99 5.1.2.2.1: "members argv[0] through argv[argc-1] inclusive shall contain pointers to strings"; NULL and 0-length are not forbidden. */ size_t arg_len = arg ? strlen(arg) : 0; if (arg_len == 0) { params->not_input_indices[next_option_index++] = i; continue; } /* Too many options. The expected longest option list is: "-q 0 -w 10 -o f -D d -S b -d -f -k -n -v --", i.e. 16 items in total. This check is an additional guard that is never triggered, but provides a guard for future changes. */ if (next_option_index > (MAX_OPTIONS - 2)) { fprintf(stderr, "too many options passed\n"); return COMMAND_INVALID; } /* Input file entry. */ if (after_dash_dash || arg[0] != '-' || arg_len == 1) { input_count++; if (longest_path_len < arg_len) longest_path_len = arg_len; continue; } /* Not a file entry. */ params->not_input_indices[next_option_index++] = i; /* '--' entry stop parsing arguments. */ if (arg_len == 2 && arg[1] == '-') { after_dash_dash = BROTLI_TRUE; continue; } /* Simple / coalesced options. */ if (arg[1] != '-') { size_t j; for (j = 1; j < arg_len; ++j) { char c = arg[j]; if (c >= '0' && c <= '9') { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = BROTLI_TRUE; params->quality = c - '0'; continue; } else if (c == 'c') { if (output_set) { fprintf(stderr, "write to standard output already set\n"); return COMMAND_INVALID; } output_set = BROTLI_TRUE; params->write_to_stdout = BROTLI_TRUE; continue; } else if (c == 'd') { if (command_set) { fprintf(stderr, "command already set when parsing -d\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_DECOMPRESS; continue; } else if (c == 'f') { if (params->force_overwrite) { fprintf(stderr, "force output overwrite already set\n"); return COMMAND_INVALID; } params->force_overwrite = BROTLI_TRUE; continue; } else if (c == 'h') { /* Don't parse further. */ return COMMAND_HELP; } else if (c == 'j' || c == 'k') { if (keep_set) { fprintf(stderr, "argument --rm / -j or --keep / -k already set\n"); return COMMAND_INVALID; } keep_set = BROTLI_TRUE; params->junk_source = TO_BROTLI_BOOL(c == 'j'); continue; } else if (c == 'n') { if (!params->copy_stat) { fprintf(stderr, "argument --no-copy-stat / -n already set\n"); return COMMAND_INVALID; } params->copy_stat = BROTLI_FALSE; continue; } else if (c == 't') { if (command_set) { fprintf(stderr, "command already set when parsing -t\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_TEST_INTEGRITY; continue; } else if (c == 'v') { if (params->verbosity > 0) { fprintf(stderr, "argument --verbose / -v already set\n"); return COMMAND_INVALID; } params->verbosity = 1; continue; } else if (c == 'V') { /* Don't parse further. */ return COMMAND_VERSION; } else if (c == 'Z') { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = BROTLI_TRUE; params->quality = 11; continue; } /* o/q/w/D/S with parameter is expected */ if (c != 'o' && c != 'q' && c != 'w' && c != 'D' && c != 'S') { fprintf(stderr, "invalid argument -%c\n", c); return COMMAND_INVALID; } if (j + 1 != arg_len) { fprintf(stderr, "expected parameter for argument -%c\n", c); return COMMAND_INVALID; } i++; if (i == argc || !argv[i] || argv[i][0] == 0) { fprintf(stderr, "expected parameter for argument -%c\n", c); return COMMAND_INVALID; } params->not_input_indices[next_option_index++] = i; if (c == 'o') { if (output_set) { fprintf(stderr, "write to standard output already set (-o)\n"); return COMMAND_INVALID; } params->output_path = argv[i]; } else if (c == 'q') { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = ParseInt(argv[i], BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY, &params->quality); if (!quality_set) { fprintf(stderr, "error parsing quality value [%s]\n", argv[i]); return COMMAND_INVALID; } } else if (c == 'w') { if (lgwin_set) { fprintf(stderr, "lgwin parameter already set\n"); return COMMAND_INVALID; } lgwin_set = ParseInt(argv[i], 0, BROTLI_MAX_WINDOW_BITS, &params->lgwin); if (!lgwin_set) { fprintf(stderr, "error parsing lgwin value [%s]\n", argv[i]); return COMMAND_INVALID; } if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) { fprintf(stderr, "lgwin parameter (%d) smaller than the minimum (%d)\n", params->lgwin, BROTLI_MIN_WINDOW_BITS); return COMMAND_INVALID; } } else if (c == 'S') { if (suffix_set) { fprintf(stderr, "suffix already set\n"); return COMMAND_INVALID; } suffix_set = BROTLI_TRUE; params->suffix = argv[i]; } } } else { /* Double-dash. */ arg = &arg[2]; if (strcmp("best", arg) == 0) { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = BROTLI_TRUE; params->quality = 11; } else if (strcmp("decompress", arg) == 0) { if (command_set) { fprintf(stderr, "command already set when parsing --decompress\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_DECOMPRESS; } else if (strcmp("force", arg) == 0) { if (params->force_overwrite) { fprintf(stderr, "force output overwrite already set\n"); return COMMAND_INVALID; } params->force_overwrite = BROTLI_TRUE; } else if (strcmp("help", arg) == 0) { /* Don't parse further. */ return COMMAND_HELP; } else if (strcmp("keep", arg) == 0) { if (keep_set) { fprintf(stderr, "argument --rm / -j or --keep / -k already set\n"); return COMMAND_INVALID; } keep_set = BROTLI_TRUE; params->junk_source = BROTLI_FALSE; } else if (strcmp("no-copy-stat", arg) == 0) { if (!params->copy_stat) { fprintf(stderr, "argument --no-copy-stat / -n already set\n"); return COMMAND_INVALID; } params->copy_stat = BROTLI_FALSE; } else if (strcmp("rm", arg) == 0) { if (keep_set) { fprintf(stderr, "argument --rm / -j or --keep / -k already set\n"); return COMMAND_INVALID; } keep_set = BROTLI_TRUE; params->junk_source = BROTLI_TRUE; } else if (strcmp("stdout", arg) == 0) { if (output_set) { fprintf(stderr, "write to standard output already set\n"); return COMMAND_INVALID; } output_set = BROTLI_TRUE; params->write_to_stdout = BROTLI_TRUE; } else if (strcmp("test", arg) == 0) { if (command_set) { fprintf(stderr, "command already set when parsing --test\n"); return COMMAND_INVALID; } command_set = BROTLI_TRUE; command = COMMAND_TEST_INTEGRITY; } else if (strcmp("verbose", arg) == 0) { if (params->verbosity > 0) { fprintf(stderr, "argument --verbose / -v already set\n"); return COMMAND_INVALID; } params->verbosity = 1; } else if (strcmp("version", arg) == 0) { /* Don't parse further. */ return COMMAND_VERSION; } else { /* key=value */ const char* value = strrchr(arg, '='); size_t key_len; if (!value || value[1] == 0) { fprintf(stderr, "must pass the parameter as --%s=value\n", arg); return COMMAND_INVALID; } key_len = (size_t)(value - arg); value++; if (strncmp("lgwin", arg, key_len) == 0) { if (lgwin_set) { fprintf(stderr, "lgwin parameter already set\n"); return COMMAND_INVALID; } lgwin_set = ParseInt(value, 0, BROTLI_MAX_WINDOW_BITS, &params->lgwin); if (!lgwin_set) { fprintf(stderr, "error parsing lgwin value [%s]\n", value); return COMMAND_INVALID; } if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) { fprintf(stderr, "lgwin parameter (%d) smaller than the minimum (%d)\n", params->lgwin, BROTLI_MIN_WINDOW_BITS); return COMMAND_INVALID; } } else if (strncmp("large_window", arg, key_len) == 0) { /* This option is intentionally not mentioned in help. */ if (lgwin_set) { fprintf(stderr, "lgwin parameter already set\n"); return COMMAND_INVALID; } lgwin_set = ParseInt(value, 0, BROTLI_LARGE_MAX_WINDOW_BITS, &params->lgwin); if (!lgwin_set) { fprintf(stderr, "error parsing lgwin value [%s]\n", value); return COMMAND_INVALID; } if (params->lgwin != 0 && params->lgwin < BROTLI_MIN_WINDOW_BITS) { fprintf(stderr, "lgwin parameter (%d) smaller than the minimum (%d)\n", params->lgwin, BROTLI_MIN_WINDOW_BITS); return COMMAND_INVALID; } } else if (strncmp("output", arg, key_len) == 0) { if (output_set) { fprintf(stderr, "write to standard output already set (--output)\n"); return COMMAND_INVALID; } params->output_path = value; } else if (strncmp("quality", arg, key_len) == 0) { if (quality_set) { fprintf(stderr, "quality already set\n"); return COMMAND_INVALID; } quality_set = ParseInt(value, BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY, &params->quality); if (!quality_set) { fprintf(stderr, "error parsing quality value [%s]\n", value); return COMMAND_INVALID; } } else if (strncmp("suffix", arg, key_len) == 0) { if (suffix_set) { fprintf(stderr, "suffix already set\n"); return COMMAND_INVALID; } suffix_set = BROTLI_TRUE; params->suffix = value; } else { fprintf(stderr, "invalid parameter: [%s]\n", arg); return COMMAND_INVALID; } } } } params->input_count = input_count; params->longest_path_len = longest_path_len; params->decompress = (command == COMMAND_DECOMPRESS); params->test_integrity = (command == COMMAND_TEST_INTEGRITY); if (input_count > 1 && output_set) return COMMAND_INVALID; if (params->test_integrity) { if (params->output_path) return COMMAND_INVALID; if (params->write_to_stdout) return COMMAND_INVALID; } if (strchr(params->suffix, '/') || strchr(params->suffix, '\\')) { return COMMAND_INVALID; } return command; } static void PrintVersion(void) { int major = BROTLI_VERSION >> 24; int minor = (BROTLI_VERSION >> 12) & 0xFFF; int patch = BROTLI_VERSION & 0xFFF; fprintf(stdout, "brotli %d.%d.%d\n", major, minor, patch); } static void PrintHelp(const char* name, BROTLI_BOOL error) { FILE* media = error ? stderr : stdout; /* String is cut to pieces with length less than 509, to conform C90 spec. */ fprintf(media, "Usage: %s [OPTION]... [FILE]...\n", name); fprintf(media, "Options:\n" " -# compression level (0-9)\n" " -c, --stdout write on standard output\n" " -d, --decompress decompress\n" " -f, --force force output file overwrite\n" " -h, --help display this help and exit\n"); fprintf(media, " -j, --rm remove source file(s)\n" " -k, --keep keep source file(s) (default)\n" " -n, --no-copy-stat do not copy source file(s) attributes\n" " -o FILE, --output=FILE output file (only if 1 input file)\n"); fprintf(media, " -q NUM, --quality=NUM compression level (%d-%d)\n", BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY); fprintf(media, " -t, --test test compressed file integrity\n" " -v, --verbose verbose mode\n"); fprintf(media, " -w NUM, --lgwin=NUM set LZ77 window size (0, %d-%d)\n" " window size = 2**NUM - 16\n" " 0 lets compressor choose the optimal value\n", BROTLI_MIN_WINDOW_BITS, BROTLI_MAX_WINDOW_BITS); fprintf(media, " --large_window=NUM use incompatible large-window brotli\n" " bitstream with window size (0, %d-%d)\n" " WARNING: this format is not compatible\n" " with brotli RFC 7932 and may not be\n" " decodable with regular brotli decoders\n", BROTLI_MIN_WINDOW_BITS, BROTLI_LARGE_MAX_WINDOW_BITS); fprintf(media, " -S SUF, --suffix=SUF output file suffix (default:'%s')\n", DEFAULT_SUFFIX); fprintf(media, " -V, --version display version and exit\n" " -Z, --best use best compression level (11) (default)\n" "Simple options could be coalesced, i.e. '-9kf' is equivalent to '-9 -k -f'.\n" "With no FILE, or when FILE is -, read standard input.\n" "All arguments after '--' are treated as files.\n"); } static const char* PrintablePath(const char* path) { return path ? path : "con"; } static BROTLI_BOOL OpenInputFile(const char* input_path, FILE** f) { *f = NULL; if (!input_path) { *f = fdopen(MAKE_BINARY(STDIN_FILENO), "rb"); return BROTLI_TRUE; } *f = fopen(input_path, "rb"); if (!*f) { fprintf(stderr, "failed to open input file [%s]: %s\n", PrintablePath(input_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } static BROTLI_BOOL OpenOutputFile(const char* output_path, FILE** f, BROTLI_BOOL force) { int fd; *f = NULL; if (!output_path) { *f = fdopen(MAKE_BINARY(STDOUT_FILENO), "wb"); return BROTLI_TRUE; } fd = open(output_path, O_CREAT | (force ? 0 : O_EXCL) | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR); if (fd < 0) { fprintf(stderr, "failed to open output file [%s]: %s\n", PrintablePath(output_path), strerror(errno)); return BROTLI_FALSE; } *f = fdopen(fd, "wb"); if (!*f) { fprintf(stderr, "failed to open output file [%s]: %s\n", PrintablePath(output_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } static int64_t FileSize(const char* path) { FILE* f = fopen(path, "rb"); int64_t retval; if (f == NULL) { return -1; } if (fseek(f, 0L, SEEK_END) != 0) { fclose(f); return -1; } retval = ftell(f); if (fclose(f) != 0) { return -1; } return retval; } /* Copy file times and permissions. TODO: this is a "best effort" implementation; honest cross-platform fully featured implementation is way too hacky; add more hacks by request. */ static void CopyStat(const char* input_path, const char* output_path) { struct stat statbuf; struct utimbuf times; int res; if (input_path == 0 || output_path == 0) { return; } if (stat(input_path, &statbuf) != 0) { return; } times.actime = statbuf.st_atime; times.modtime = statbuf.st_mtime; utime(output_path, &times); res = chmod(output_path, statbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)); if (res != 0) { fprintf(stderr, "setting access bits failed for [%s]: %s\n", PrintablePath(output_path), strerror(errno)); } res = chown(output_path, (uid_t)-1, statbuf.st_gid); if (res != 0) { fprintf(stderr, "setting group failed for [%s]: %s\n", PrintablePath(output_path), strerror(errno)); } res = chown(output_path, statbuf.st_uid, (gid_t)-1); if (res != 0) { fprintf(stderr, "setting user failed for [%s]: %s\n", PrintablePath(output_path), strerror(errno)); } } static BROTLI_BOOL NextFile(Context* context) { const char* arg; size_t arg_len; /* Iterator points to last used arg; increment to search for the next one. */ context->iterator++; context->input_file_length = -1; /* No input path; read from console. */ if (context->input_count == 0) { if (context->iterator > 1) return BROTLI_FALSE; context->current_input_path = NULL; /* Either write to the specified path, or to console. */ context->current_output_path = context->output_path; return BROTLI_TRUE; } /* Skip option arguments. */ while (context->iterator == context->not_input_indices[context->ignore]) { context->iterator++; context->ignore++; } /* All args are scanned already. */ if (context->iterator >= context->argc) return BROTLI_FALSE; /* Iterator now points to the input file name. */ arg = context->argv[context->iterator]; arg_len = strlen(arg); /* Read from console. */ if (arg_len == 1 && arg[0] == '-') { context->current_input_path = NULL; context->current_output_path = context->output_path; return BROTLI_TRUE; } context->current_input_path = arg; context->input_file_length = FileSize(arg); context->current_output_path = context->output_path; if (context->output_path) return BROTLI_TRUE; if (context->write_to_stdout) return BROTLI_TRUE; strcpy(context->modified_path, arg); context->current_output_path = context->modified_path; /* If output is not specified, input path suffix should match. */ if (context->decompress) { size_t suffix_len = strlen(context->suffix); char* name = (char*)FileName(context->modified_path); char* name_suffix; size_t name_len = strlen(name); if (name_len < suffix_len + 1) { fprintf(stderr, "empty output file name for [%s] input file\n", PrintablePath(arg)); context->iterator_error = BROTLI_TRUE; return BROTLI_FALSE; } name_suffix = name + name_len - suffix_len; if (strcmp(context->suffix, name_suffix) != 0) { fprintf(stderr, "input file [%s] suffix mismatch\n", PrintablePath(arg)); context->iterator_error = BROTLI_TRUE; return BROTLI_FALSE; } name_suffix[0] = 0; return BROTLI_TRUE; } else { strcpy(context->modified_path + arg_len, context->suffix); return BROTLI_TRUE; } } static BROTLI_BOOL OpenFiles(Context* context) { BROTLI_BOOL is_ok = OpenInputFile(context->current_input_path, &context->fin); if (!context->test_integrity && is_ok) { is_ok = OpenOutputFile( context->current_output_path, &context->fout, context->force_overwrite); } return is_ok; } static BROTLI_BOOL CloseFiles(Context* context, BROTLI_BOOL success) { BROTLI_BOOL is_ok = BROTLI_TRUE; if (!context->test_integrity && context->fout) { if (!success && context->current_output_path) { unlink(context->current_output_path); } if (fclose(context->fout) != 0) { if (success) { fprintf(stderr, "fclose failed [%s]: %s\n", PrintablePath(context->current_output_path), strerror(errno)); } is_ok = BROTLI_FALSE; } /* TOCTOU violation, but otherwise it is impossible to set file times. */ if (success && is_ok && context->copy_stat) { CopyStat(context->current_input_path, context->current_output_path); } } if (context->fin) { if (fclose(context->fin) != 0) { if (is_ok) { fprintf(stderr, "fclose failed [%s]: %s\n", PrintablePath(context->current_input_path), strerror(errno)); } is_ok = BROTLI_FALSE; } } if (success && context->junk_source && context->current_input_path) { unlink(context->current_input_path); } context->fin = NULL; context->fout = NULL; return is_ok; } static const size_t kFileBufferSize = 1 << 19; static void InitializeBuffers(Context* context) { context->available_in = 0; context->next_in = NULL; context->available_out = kFileBufferSize; context->next_out = context->output; context->total_in = 0; context->total_out = 0; } /* This method might give the false-negative result. However, after an empty / incomplete read it should tell the truth. */ static BROTLI_BOOL HasMoreInput(Context* context) { return feof(context->fin) ? BROTLI_FALSE : BROTLI_TRUE; } static BROTLI_BOOL ProvideInput(Context* context) { context->available_in = fread(context->input, 1, kFileBufferSize, context->fin); context->total_in += context->available_in; context->next_in = context->input; if (ferror(context->fin)) { fprintf(stderr, "failed to read input [%s]: %s\n", PrintablePath(context->current_input_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } /* Internal: should be used only in Provide-/Flush-Output. */ static BROTLI_BOOL WriteOutput(Context* context) { size_t out_size = (size_t)(context->next_out - context->output); context->total_out += out_size; if (out_size == 0) return BROTLI_TRUE; if (context->test_integrity) return BROTLI_TRUE; fwrite(context->output, 1, out_size, context->fout); if (ferror(context->fout)) { fprintf(stderr, "failed to write output [%s]: %s\n", PrintablePath(context->current_output_path), strerror(errno)); return BROTLI_FALSE; } return BROTLI_TRUE; } static BROTLI_BOOL ProvideOutput(Context* context) { if (!WriteOutput(context)) return BROTLI_FALSE; context->available_out = kFileBufferSize; context->next_out = context->output; return BROTLI_TRUE; } static BROTLI_BOOL FlushOutput(Context* context) { if (!WriteOutput(context)) return BROTLI_FALSE; context->available_out = 0; return BROTLI_TRUE; } static void PrintBytes(size_t value) { if (value < 1024) { fprintf(stderr, "%d B", (int)value); } else if (value < 1048576) { fprintf(stderr, "%0.3f KiB", (double)value / 1024.0); } else if (value < 1073741824) { fprintf(stderr, "%0.3f MiB", (double)value / 1048576.0); } else { fprintf(stderr, "%0.3f GiB", (double)value / 1073741824.0); } } static void PrintFileProcessingProgress(Context* context) { fprintf(stderr, "[%s]: ", PrintablePath(context->current_input_path)); PrintBytes(context->total_in); fprintf(stderr, " -> "); PrintBytes(context->total_out); } static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) { BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT; InitializeBuffers(context); for (;;) { if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) { if (!HasMoreInput(context)) { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } if (!ProvideInput(context)) return BROTLI_FALSE; } else if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) { if (!ProvideOutput(context)) return BROTLI_FALSE; } else if (result == BROTLI_DECODER_RESULT_SUCCESS) { if (!FlushOutput(context)) return BROTLI_FALSE; int has_more_input = (context->available_in != 0) || (fgetc(context->fin) != EOF); if (has_more_input) { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } if (context->verbosity > 0) { fprintf(stderr, "Decompressed "); PrintFileProcessingProgress(context); fprintf(stderr, "\n"); } return BROTLI_TRUE; } else { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } result = BrotliDecoderDecompressStream(s, &context->available_in, &context->next_in, &context->available_out, &context->next_out, 0); } } static BROTLI_BOOL DecompressFiles(Context* context) { while (NextFile(context)) { BROTLI_BOOL is_ok = BROTLI_TRUE; BrotliDecoderState* s = BrotliDecoderCreateInstance(NULL, NULL, NULL); if (!s) { fprintf(stderr, "out of memory\n"); return BROTLI_FALSE; } /* This allows decoding "large-window" streams. Though it creates fragmentation (new builds decode streams that old builds don't), it is better from used experience perspective. */ BrotliDecoderSetParameter(s, BROTLI_DECODER_PARAM_LARGE_WINDOW, 1u); is_ok = OpenFiles(context); if (is_ok && !context->current_input_path && !context->force_overwrite && isatty(STDIN_FILENO)) { fprintf(stderr, "Use -h help. Use -f to force input from a terminal.\n"); is_ok = BROTLI_FALSE; } if (is_ok) is_ok = DecompressFile(context, s); BrotliDecoderDestroyInstance(s); if (!CloseFiles(context, is_ok)) is_ok = BROTLI_FALSE; if (!is_ok) return BROTLI_FALSE; } return BROTLI_TRUE; } static BROTLI_BOOL CompressFile(Context* context, BrotliEncoderState* s) { BROTLI_BOOL is_eof = BROTLI_FALSE; InitializeBuffers(context); for (;;) { if (context->available_in == 0 && !is_eof) { if (!ProvideInput(context)) return BROTLI_FALSE; is_eof = !HasMoreInput(context); } if (!BrotliEncoderCompressStream(s, is_eof ? BROTLI_OPERATION_FINISH : BROTLI_OPERATION_PROCESS, &context->available_in, &context->next_in, &context->available_out, &context->next_out, NULL)) { /* Should detect OOM? */ fprintf(stderr, "failed to compress data [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; } if (context->available_out == 0) { if (!ProvideOutput(context)) return BROTLI_FALSE; } if (BrotliEncoderIsFinished(s)) { if (!FlushOutput(context)) return BROTLI_FALSE; if (context->verbosity > 0) { fprintf(stderr, "Compressed "); PrintFileProcessingProgress(context); fprintf(stderr, "\n"); } return BROTLI_TRUE; } } } static BROTLI_BOOL CompressFiles(Context* context) { while (NextFile(context)) { BROTLI_BOOL is_ok = BROTLI_TRUE; BrotliEncoderState* s = BrotliEncoderCreateInstance(NULL, NULL, NULL); if (!s) { fprintf(stderr, "out of memory\n"); return BROTLI_FALSE; } BrotliEncoderSetParameter(s, BROTLI_PARAM_QUALITY, (uint32_t)context->quality); if (context->lgwin > 0) { /* Specified by user. */ /* Do not enable "large-window" extension, if not required. */ if (context->lgwin > BROTLI_MAX_WINDOW_BITS) { BrotliEncoderSetParameter(s, BROTLI_PARAM_LARGE_WINDOW, 1u); } BrotliEncoderSetParameter(s, BROTLI_PARAM_LGWIN, (uint32_t)context->lgwin); } else { /* 0, or not specified by user; could be chosen by compressor. */ uint32_t lgwin = DEFAULT_LGWIN; /* Use file size to limit lgwin. */ if (context->input_file_length >= 0) { lgwin = BROTLI_MIN_WINDOW_BITS; while (BROTLI_MAX_BACKWARD_LIMIT(lgwin) < (uint64_t)context->input_file_length) { lgwin++; if (lgwin == BROTLI_MAX_WINDOW_BITS) break; } } BrotliEncoderSetParameter(s, BROTLI_PARAM_LGWIN, lgwin); } if (context->input_file_length > 0) { uint32_t size_hint = context->input_file_length < (1 << 30) ? (uint32_t)context->input_file_length : (1u << 30); BrotliEncoderSetParameter(s, BROTLI_PARAM_SIZE_HINT, size_hint); } is_ok = OpenFiles(context); if (is_ok && !context->current_output_path && !context->force_overwrite && isatty(STDOUT_FILENO)) { fprintf(stderr, "Use -h help. Use -f to force output to a terminal.\n"); is_ok = BROTLI_FALSE; } if (is_ok) is_ok = CompressFile(context, s); BrotliEncoderDestroyInstance(s); if (!CloseFiles(context, is_ok)) is_ok = BROTLI_FALSE; if (!is_ok) return BROTLI_FALSE; } return BROTLI_TRUE; } int main(int argc, char** argv) { Command command; Context context; BROTLI_BOOL is_ok = BROTLI_TRUE; int i; context.quality = 11; context.lgwin = -1; context.verbosity = 0; context.force_overwrite = BROTLI_FALSE; context.junk_source = BROTLI_FALSE; context.copy_stat = BROTLI_TRUE; context.test_integrity = BROTLI_FALSE; context.write_to_stdout = BROTLI_FALSE; context.decompress = BROTLI_FALSE; context.large_window = BROTLI_FALSE; context.output_path = NULL; context.suffix = DEFAULT_SUFFIX; for (i = 0; i < MAX_OPTIONS; ++i) context.not_input_indices[i] = 0; context.longest_path_len = 1; context.input_count = 0; context.argc = argc; context.argv = argv; context.modified_path = NULL; context.iterator = 0; context.ignore = 0; context.iterator_error = BROTLI_FALSE; context.buffer = NULL; context.current_input_path = NULL; context.current_output_path = NULL; context.fin = NULL; context.fout = NULL; command = ParseParams(&context); if (command == COMMAND_COMPRESS || command == COMMAND_DECOMPRESS || command == COMMAND_TEST_INTEGRITY) { if (is_ok) { size_t modified_path_len = context.longest_path_len + strlen(context.suffix) + 1; context.modified_path = (char*)malloc(modified_path_len); context.buffer = (uint8_t*)malloc(kFileBufferSize * 2); if (!context.modified_path || !context.buffer) { fprintf(stderr, "out of memory\n"); is_ok = BROTLI_FALSE; } else { context.input = context.buffer; context.output = context.buffer + kFileBufferSize; } } } if (!is_ok) command = COMMAND_NOOP; switch (command) { case COMMAND_NOOP: break; case COMMAND_VERSION: PrintVersion(); break; case COMMAND_COMPRESS: is_ok = CompressFiles(&context); break; case COMMAND_DECOMPRESS: case COMMAND_TEST_INTEGRITY: is_ok = DecompressFiles(&context); break; case COMMAND_HELP: case COMMAND_INVALID: default: is_ok = (command == COMMAND_HELP); PrintHelp(FileName(argv[0]), is_ok); break; } if (context.iterator_error) is_ok = BROTLI_FALSE; free(context.modified_path); free(context.buffer); if (!is_ok) exit(1); return 0; }
-1
dotnet/runtime
66,110
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client
Fixes https://github.com/dotnet/runtime/issues/66099
mdh1418
2022-03-02T21:21:59Z
2022-03-03T01:22:51Z
48b6648e2f8ac01b24f26fc563d831f408e14795
73471b51fb55198bc089f342cd75e077cc4762a8
[tests] Update eventsvalidation tests to use intree Microsoft.Diagnostics.NETCore.Client. Fixes https://github.com/dotnet/runtime/issues/66099
./src/libraries/System.Threading.Tasks.Parallel/src/Resources/Strings.resx
<root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="Parallel_Invoke_ActionNull" xml:space="preserve"> <value>One of the actions was null.</value> </data> <data name="Parallel_ForEach_OrderedPartitionerKeysNotNormalized" xml:space="preserve"> <value>This method requires the use of an OrderedPartitioner with the KeysNormalized property set to true.</value> </data> <data name="Parallel_ForEach_PartitionerNotDynamic" xml:space="preserve"> <value>The Partitioner must support dynamic partitioning.</value> </data> <data name="Parallel_ForEach_PartitionerReturnedNull" xml:space="preserve"> <value>The Partitioner returned a null partitioner source.</value> </data> <data name="Parallel_ForEach_NullEnumerator" xml:space="preserve"> <value>The source returned a null enumerator.</value> </data> <data name="ParallelState_Break_InvalidOperationException_BreakAfterStop" xml:space="preserve"> <value>Break was called after Stop was called.</value> </data> <data name="ParallelState_Stop_InvalidOperationException_StopAfterBreak" xml:space="preserve"> <value>Stop was called after Break was called.</value> </data> <data name="ParallelState_NotSupportedException_UnsupportedMethod" xml:space="preserve"> <value>This method is not supported.</value> </data> </root>
<root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="Parallel_Invoke_ActionNull" xml:space="preserve"> <value>One of the actions was null.</value> </data> <data name="Parallel_ForEach_OrderedPartitionerKeysNotNormalized" xml:space="preserve"> <value>This method requires the use of an OrderedPartitioner with the KeysNormalized property set to true.</value> </data> <data name="Parallel_ForEach_PartitionerNotDynamic" xml:space="preserve"> <value>The Partitioner must support dynamic partitioning.</value> </data> <data name="Parallel_ForEach_PartitionerReturnedNull" xml:space="preserve"> <value>The Partitioner returned a null partitioner source.</value> </data> <data name="Parallel_ForEach_NullEnumerator" xml:space="preserve"> <value>The source returned a null enumerator.</value> </data> <data name="ParallelState_Break_InvalidOperationException_BreakAfterStop" xml:space="preserve"> <value>Break was called after Stop was called.</value> </data> <data name="ParallelState_Stop_InvalidOperationException_StopAfterBreak" xml:space="preserve"> <value>Stop was called after Break was called.</value> </data> <data name="ParallelState_NotSupportedException_UnsupportedMethod" xml:space="preserve"> <value>This method is not supported.</value> </data> </root>
-1