diff options
author | Steve <hez2010@outlook.com> | 2022-02-11 22:22:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 15:22:08 +0100 |
commit | bb1f491b58d7c9727a3bf4962fddba6b8755a6b7 (patch) | |
tree | c555993dec3c4b616145203df34465f3f1933239 /lib/compilers/dotnet.ts | |
parent | ed90053a4c106375fbfdfe309c6f4885bf305948 (diff) | |
download | compiler-explorer-bb1f491b58d7c9727a3bf4962fddba6b8755a6b7.tar.gz compiler-explorer-bb1f491b58d7c9727a3bf4962fddba6b8755a6b7.zip |
Implement asm-parser for dotnet (#3334)gh-1926
Diffstat (limited to 'lib/compilers/dotnet.ts')
-rw-r--r-- | lib/compilers/dotnet.ts | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/lib/compilers/dotnet.ts b/lib/compilers/dotnet.ts index 65d0e9a3a..e3225a2ab 100644 --- a/lib/compilers/dotnet.ts +++ b/lib/compilers/dotnet.ts @@ -27,6 +27,7 @@ import path from 'path'; import fs from 'fs-extra'; /// <reference types="../base-compiler" /> +import { DotNetAsmParser } from '../asm-parser-dotnet'; import { BaseCompiler } from '../base-compiler'; class DotNetCompiler extends BaseCompiler { @@ -37,6 +38,7 @@ class DotNetCompiler extends BaseCompiler { private clrBuildDir: string; private additionalSources: string; private langVersion: string; + protected asm: DotNetAsmParser; constructor(compilerInfo, env) { super(compilerInfo, env); @@ -48,6 +50,7 @@ class DotNetCompiler extends BaseCompiler { this.clrBuildDir = this.compilerProps(`compiler.${this.compiler.id}.clrDir`); this.additionalSources = this.compilerProps(`compiler.${this.compiler.id}.additionalSources`); this.langVersion = this.compilerProps(`compiler.${this.compiler.id}.langVersion`); + this.asm = new DotNetAsmParser(); } get compilerOptions() { @@ -90,7 +93,6 @@ class DotNetCompiler extends BaseCompiler { <PropertyGroup> <TargetFramework>${this.targetFramework}</TargetFramework> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <Nullable>enable</Nullable> <AssemblyName>CompilerExplorer</AssemblyName> <LangVersion>${this.langVersion}</LangVersion> <EnableDefaultCompileItems>false</EnableDefaultCompileItems> @@ -160,36 +162,11 @@ class DotNetCompiler extends BaseCompiler { return this.compilerOptions; } - cleanAsm(stdout) { - let cleanedAsm = ''; - - for (const line of stdout) { - if (line.text.startsWith('; Assembly listing for method')) { - // ; Assembly listing for method ConsoleApplication.Program:Main(System.String[]) - // ^ This character is the 31st character in this string. - // `substring` removes the first 30 characters from it and uses the rest as a label. - cleanedAsm = cleanedAsm.concat(line.text.substring(30) + ':\n'); - continue; - } - - if (line.text.startsWith('Emitting R2R PE file')) { - continue; - } - - if (line.text.startsWith(';') && !line.text.startsWith('; Emitting')) { - continue; - } - - cleanedAsm = cleanedAsm.concat(line.text + '\n'); - } - - return cleanedAsm; - } - async runCrossgen2(compiler, execOptions, crossgen2Path, publishPath, dllPath, options, outputPath) { const crossgen2Options = [ crossgen2Path, '-r', path.join(publishPath, '*'), dllPath, '-o', 'CompilerExplorer.r2r.dll', '--codegenopt', 'NgenDisasm=*', '--codegenopt', 'JitDiffableDasm=1', '--parallelism', '1', + '--inputbubble', '--compilebubblegenerics', ].concat(options); const result = await this.exec(compiler, crossgen2Options, execOptions); @@ -199,7 +176,7 @@ class DotNetCompiler extends BaseCompiler { await fs.writeFile( outputPath, - this.cleanAsm(result.stdout), + result.stdout.map(o => o.text).reduce((a, n) => `${a}\n${n}`), ); return result; |