mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 03:39:47 -06:00
Merge branch 'main' into jr/cache-exec-work
This commit is contained in:
@@ -166,6 +166,7 @@ rules:
|
||||
unicorn/no-useless-undefined:
|
||||
- error
|
||||
- checkArguments: false
|
||||
'unused-imports/no-unused-imports': error
|
||||
'@typescript-eslint/no-empty-function': off
|
||||
'@typescript-eslint/no-unused-vars': off
|
||||
'@typescript-eslint/no-explicit-any': off
|
||||
|
||||
@@ -62,6 +62,7 @@ import {logger, logToLoki, logToPapertrail, makeLogStream, suppressConsoleLog} f
|
||||
import {setupMetricsServer} from './lib/metrics-server.js';
|
||||
import {ClientOptionsHandler} from './lib/options-handler.js';
|
||||
import * as props from './lib/properties.js';
|
||||
import {SetupSentry} from './lib/sentry.js';
|
||||
import {ShortLinkResolver} from './lib/shortener/google.js';
|
||||
import {sources} from './lib/sources/index.js';
|
||||
import {loadSponsorsFromString} from './lib/sponsors.js';
|
||||
@@ -364,15 +365,6 @@ async function setupStaticMiddleware(router: express.Router) {
|
||||
};
|
||||
}
|
||||
|
||||
function shouldRedactRequestData(data: string) {
|
||||
try {
|
||||
const parsed = JSON.parse(data);
|
||||
return !parsed['allowStoreCodeDebug'];
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const googleShortUrlResolver = new ShortLinkResolver();
|
||||
|
||||
function oldGoogleUrlHandler(req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
@@ -451,26 +443,6 @@ function startListening(server: express.Express) {
|
||||
}
|
||||
}
|
||||
|
||||
function setupSentry(sentryDsn: string) {
|
||||
if (!sentryDsn) {
|
||||
logger.info('Not configuring sentry');
|
||||
return;
|
||||
}
|
||||
const sentryEnv = ceProps('sentryEnvironment');
|
||||
Sentry.init({
|
||||
dsn: sentryDsn,
|
||||
release: releaseBuildNumber || gitReleaseName,
|
||||
environment: sentryEnv || defArgs.env[0],
|
||||
beforeSend(event) {
|
||||
if (event.request && event.request.data && shouldRedactRequestData(event.request.data)) {
|
||||
event.request.data = JSON.stringify({redacted: true});
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
logger.info(`Configured with Sentry endpoint ${sentryDsn}`);
|
||||
}
|
||||
|
||||
const awsProps = props.propsFor('aws');
|
||||
|
||||
// eslint-disable-next-line max-statements
|
||||
@@ -479,7 +451,7 @@ async function main() {
|
||||
// Initialise express and then sentry. Sentry as early as possible to catch errors during startup.
|
||||
const webServer = express(),
|
||||
router = express.Router();
|
||||
setupSentry(aws.getConfig('sentryDsn'));
|
||||
SetupSentry(aws.getConfig('sentryDsn'), ceProps, releaseBuildNumber, gitReleaseName, defArgs);
|
||||
|
||||
startWineInit();
|
||||
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
compilers=&nvcc:&clang:&clang_hip
|
||||
defaultCompiler=nvcc91def
|
||||
defaultCompiler=nvcc121
|
||||
supportsBinary=true
|
||||
supportsExecute=false
|
||||
demangler=/opt/compiler-explorer/gcc-6.4.0/bin/c++filt
|
||||
objdumper=/opt/compiler-explorer/gcc-6.4.0/bin/objdump
|
||||
demangler=/usr/bin/c++filt
|
||||
objdumper=/usr/bin/objdump
|
||||
|
||||
group.nvcc.compilers=nvcc91def
|
||||
group.nvcc.options=--compiler-bindir /opt/compiler-explorer/gcc-6.4.0/bin
|
||||
group.nvcc.compilers=nvcc121
|
||||
group.nvcc.options=--keep-device-functions
|
||||
group.nvcc.versionRe=^Cuda.*
|
||||
group.nvcc.compilerType=nvcc
|
||||
group.nvcc.nvdisasm=/opt/compiler-explorer/cuda/9.1.85/bin/nvdisasm
|
||||
group.nvcc.nvdisasm=/opt/cuda/bin/nvdisasm
|
||||
|
||||
compiler.nvcc91def.name=NVCC 9.1
|
||||
compiler.nvcc91def.exe=/opt/compiler-explorer/cuda/9.1.85/bin/nvcc
|
||||
compiler.nvcc91def.alias=nvcc91
|
||||
|
||||
compiler.nvcc121.name=NVCC 9.1
|
||||
compiler.nvcc121.exe=/opt/cuda/bin/nvcc
|
||||
compiler.nvcc121.alias=nvcc
|
||||
|
||||
group.clang.compilers=cltrunkdef
|
||||
group.clang.options=--cuda-path=/opt/compiler-explorer/cuda/9.1.85 --cuda-gpu-arch=sm_35 --cuda-device-only
|
||||
group.clang.options=--cuda-path=/opt/cuda --cuda-gpu-arch=sm_61 --cuda-device-only
|
||||
group.clang.compilerType=clang-cuda
|
||||
group.clang.nvdisasm=/opt/compiler-explorer/cuda/9.1.85/bin/nvdisasm
|
||||
|
||||
@@ -34,3 +35,10 @@ compiler.hiptrunkdef.name=clang/HIP(w/o HIP SDK)
|
||||
compiler.hiptrunkdef.exe=/opt/compiler-explorer/clang-trunk/bin/clang++
|
||||
compiler.hiptrunkdef.objdumper=/opt/compiler-explorer/clang-trunk/bin/llvm-objdump
|
||||
compiler.hiptrunkdef.alias=hiptrunk
|
||||
|
||||
#group.ptxas.instructionSet=ptx
|
||||
#group.nvcc121.nvdisasm.instructionSet=ptx
|
||||
|
||||
#group.nvcc121.instructionSet=ptx
|
||||
#instructionSet=ptx
|
||||
#supportsAsmDocs=true
|
||||
|
||||
@@ -8,6 +8,8 @@ all: \
|
||||
$(GEN_DIR)/asm-docs-evm.ts \
|
||||
$(GEN_DIR)/asm-docs-java.ts \
|
||||
$(GEN_DIR)/asm-docs-llvm.ts \
|
||||
$(GEN_DIR)/asm-docs-ptx.ts \
|
||||
$(GEN_DIR)/asm-docs-sass.ts \
|
||||
$(GEN_DIR)/asm-docs-python.ts
|
||||
|
||||
$(GEN_DIR)/asm-docs-6502.ts: docenizer-6502.py
|
||||
@@ -26,5 +28,9 @@ $(GEN_DIR)/asm-docs-java.ts: docenizer-java.sh docenizer-java.ts
|
||||
./$<
|
||||
$(GEN_DIR)/asm-docs-llvm.ts: docenizer-llvm.sh docenizer-llvm.ts
|
||||
./$<
|
||||
$(GEN_DIR)/asm-docs-ptx.ts: docenizer-ptx-sass.py
|
||||
python3 $< -o $@
|
||||
$(GEN_DIR)/asm-docs-sass.ts: docenizer-ptx-sass.py
|
||||
python3 $< -o $@
|
||||
$(GEN_DIR)/asm-docs-python.ts: docenizer-python.py
|
||||
python3 $< -o $@
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
import collections
|
||||
import copy
|
||||
import json
|
||||
import os.path
|
||||
from collections import defaultdict
|
||||
|
||||
import pandas as pd
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from dataclasses import dataclass
|
||||
|
||||
try:
|
||||
import lxml # for pandas.read_html
|
||||
except ImportError:
|
||||
raise
|
||||
# get PTX docs
|
||||
r = requests.get('https://docs.nvidia.com/cuda/parallel-thread-execution/index.html')
|
||||
r.encoding = 'utf-8'
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
symbol_to_fullname_frag0: defaultdict[str, list[tuple[str, str]]] = collections.defaultdict(list)
|
||||
for links, anchor_text_sep in [
|
||||
(soup.find('a', class_='reference internal', href='#instruction-set').parent.find_all('a'), 'Instructions: '),
|
||||
(soup.find('a', class_='reference internal', href='#directives').parent.find_all('a'), 'Directives: '),
|
||||
(soup.find('a', class_='reference internal', href='#special-registers').parent.find_all('a'),
|
||||
'Special Registers: ')]:
|
||||
for link in links:
|
||||
if anchor_text_sep in link.string:
|
||||
topic, instructions0 = link.string.split(anchor_text_sep)
|
||||
instructions: list[str] = instructions0.replace(' / ', ', ').split(', ')
|
||||
href: str = link.get('href')
|
||||
assert href.startswith('#')
|
||||
frag = href[1:]
|
||||
for instr in instructions:
|
||||
if not instr.startswith('@') and ' ' not in instr and instr != '{}':
|
||||
instr_fullname = instr.lstrip('.').lstrip('%')
|
||||
symbol_to_fullname_frag0[instr_fullname.split('.', 1)[0]].append((instr_fullname, frag))
|
||||
symbol_to_fullname_frag: list[tuple[str, list[tuple[str, str]]]] = sorted(
|
||||
(instr, sorted(set(fullname_frags))) for instr, fullname_frags in symbol_to_fullname_frag0.items())
|
||||
|
||||
|
||||
@dataclass
|
||||
class Doc:
|
||||
title: str
|
||||
text: str
|
||||
html: str
|
||||
|
||||
|
||||
def get_doc(fragment: str) -> Doc:
|
||||
article = copy.copy(soup.find(id=fragment))
|
||||
txt0 = article.text.replace('\n\n', '\n').replace('\n\n', '\n')
|
||||
title, _, txt = txt0.split(' ', 1)[1].split('\n', 2)
|
||||
for i in range(2, 6):
|
||||
if h := article.find(f'h{i}'):
|
||||
h.decompose()
|
||||
break
|
||||
else:
|
||||
print("=====")
|
||||
print(article)
|
||||
raise AssertionError
|
||||
article.p.decompose() # remove the instruction name
|
||||
return Doc(title.rstrip(''), txt, str(article))
|
||||
|
||||
|
||||
def fullname_plus_annotation(fullname: str, fragment: str) -> str:
|
||||
if fragment.startswith('floating-point-instructions-'):
|
||||
return fullname + '(fp)'
|
||||
if fragment.startswith('half-precision-floating-point-instructions-'):
|
||||
return fullname + '(fp16)'
|
||||
if fragment.startswith('integer-arithmetic-instructions-'):
|
||||
return fullname + '(int)'
|
||||
return fullname
|
||||
|
||||
|
||||
def combine_docs(docs: list[Doc], fullname_fragments) -> tuple[str, str]:
|
||||
common_txt = os.path.commonprefix([doc.text for doc in docs])
|
||||
combined_txt = common_txt \
|
||||
if len(common_txt) > 100 else \
|
||||
'\n'.join(f'====={doc.title}\n\n' + doc.text[:400] + '...' for doc in docs)
|
||||
links = ['<a href="https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#' +
|
||||
f'{fragment}" target="_blank" rel="noopener noreferrer">{fullname_plus_annotation(fullname, fragment)}' +
|
||||
' <sup><small class="fas fa-external-link-alt opens-new-window"' +
|
||||
' title="Opens in a new window"></small></sup></a>'
|
||||
for fullname, fragment in fullname_fragments]
|
||||
return combined_txt[:4000] + ' ...', \
|
||||
'For more information, visit ' + ', '.join(links) + '.' + \
|
||||
'\n'.join([f'<h1>{doc.title}</h1>' + doc.html for doc in docs])
|
||||
|
||||
|
||||
symbol_to_doc: list[tuple[str, str, str, list[tuple[str, str]]]] = []
|
||||
for symbol, fullname_fragments in symbol_to_fullname_frag:
|
||||
docs = [get_doc(fragment) for _, fragment in fullname_fragments]
|
||||
symbol_to_doc.append((symbol, *combine_docs(docs, fullname_fragments), fullname_fragments))
|
||||
# get SASS docs
|
||||
tables = pd.read_html('https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html', match='Opcode')
|
||||
sass_docs = sorted(dict(pd.concat(tables).dropna().itertuples(index=False)).items())
|
||||
|
||||
with open('./asm-docs-ptx.ts', 'w') as f:
|
||||
f.write("""
|
||||
import {AssemblyInstructionInfo} from '../base.js';
|
||||
|
||||
export function getAsmOpcode(opcode: string | undefined): AssemblyInstructionInfo | undefined {
|
||||
if (!opcode) return;
|
||||
switch (opcode) {
|
||||
""".lstrip())
|
||||
# PTX
|
||||
for name, tooltip, body, fullname_fragments in symbol_to_doc:
|
||||
f.write(f' case "{name}":\n')
|
||||
f.write(' return {}'.format(json.dumps({
|
||||
"tooltip": tooltip.replace('\n', '\n\n'),
|
||||
"html": body,
|
||||
# there can be multiple doc links for a single instruction
|
||||
"url": "https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#" + fullname_fragments[0][1]
|
||||
}, indent=16, separators=(',', ': '), sort_keys=True))[:-1] + ' };\n\n')
|
||||
f.write("""
|
||||
}
|
||||
}
|
||||
""")
|
||||
with open('./asm-docs-sass.ts', 'w') as f:
|
||||
f.write("""
|
||||
import {AssemblyInstructionInfo} from '../base.js';
|
||||
|
||||
export function getAsmOpcode(opcode: string | undefined): AssemblyInstructionInfo | undefined {
|
||||
if (!opcode) return;
|
||||
switch (opcode) {
|
||||
""".lstrip())
|
||||
# SASS
|
||||
for name, description in sass_docs:
|
||||
f.write(f' case "{name}":\n')
|
||||
f.write(' return {}'.format(json.dumps({
|
||||
"tooltip": description,
|
||||
"html": description +
|
||||
f'<br><br>For more information, visit <a href="https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#id14" target="_blank" rel="noopener noreferrer">'
|
||||
'CUDA Binary Utilities' +
|
||||
' documentation <sup><small class="fas fa-external-link-alt opens-new-window"' +
|
||||
' title="Opens in a new window"></small></sup></a>.',
|
||||
"url": "https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#id14"
|
||||
}, indent=16, separators=(',', ': '), sort_keys=True))[:-1] + ' };\n\n')
|
||||
|
||||
f.write("""
|
||||
}
|
||||
}
|
||||
""")
|
||||
+5
-3
@@ -24,7 +24,7 @@
|
||||
|
||||
module.exports = {
|
||||
root: true,
|
||||
plugins: ['promise', 'requirejs'],
|
||||
plugins: ['promise', 'requirejs', 'unused-imports'],
|
||||
extends: ['./.eslint-ce-lib.yml'],
|
||||
rules: {
|
||||
'promise/catch-or-return': 'off',
|
||||
@@ -57,13 +57,15 @@ module.exports = {
|
||||
project: '../tsconfig.json',
|
||||
},
|
||||
rules: {
|
||||
'import/no-unresolved': 'off',
|
||||
'node/no-missing-imports': 'off',
|
||||
'unused-imports/no-unused-imports': 'error',
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'off', // Too much js code still exists
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
'import/no-unresolved': 'off',
|
||||
'node/no-missing-imports': 'off',
|
||||
// TODO: Disabled for now
|
||||
//'@typescript-eslint/no-unnecessary-condition': 'error',
|
||||
//'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
|
||||
@@ -29,4 +29,6 @@ export {EvmDocumentationProvider} from './evm.js';
|
||||
export {JavaDocumentationProvider} from './java.js';
|
||||
export {LLVMDocumentationProvider} from './llvm.js';
|
||||
export {Mos6502DocumentationProvider} from './mos6502.js';
|
||||
export {PTXDocumentationProvider} from './ptx.js';
|
||||
export {PythonDocumentationProvider} from './python.js';
|
||||
export {SASSDocumentationProvider} from './sass.js';
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ export class Arm32DocumentationProvider extends ArmBaseDocumentationProvider {
|
||||
}
|
||||
|
||||
protected getAsmOpcode(opcode: string): AssemblyInstructionInfo | undefined {
|
||||
return getAsmOpcode32(opcode);
|
||||
return getAsmOpcode32(opcode.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,6 @@ export class ArmArch64DocumentationProvider extends ArmBaseDocumentationProvider
|
||||
}
|
||||
|
||||
protected getAsmOpcode(opcode: string): AssemblyInstructionInfo | undefined {
|
||||
return getAsmOpcode64(opcode);
|
||||
return getAsmOpcode64(opcode.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+1331
File diff suppressed because one or more lines are too long
Generated
+1639
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2021, Compiler Explorer Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {AssemblyInstructionInfo, BaseAssemblyDocumentationProvider} from './base.js';
|
||||
import {getAsmOpcode} from './generated/asm-docs-ptx.js';
|
||||
|
||||
export class PTXDocumentationProvider extends BaseAssemblyDocumentationProvider {
|
||||
public static get key() {
|
||||
return 'ptx';
|
||||
}
|
||||
|
||||
public override getInstructionInformation(instruction: string): AssemblyInstructionInfo | null {
|
||||
return getAsmOpcode(instruction.toLowerCase()) || null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2021, Compiler Explorer Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {AssemblyInstructionInfo, BaseAssemblyDocumentationProvider} from './base.js';
|
||||
import {getAsmOpcode} from './generated/asm-docs-sass.js';
|
||||
|
||||
export class SASSDocumentationProvider extends BaseAssemblyDocumentationProvider {
|
||||
public static get key() {
|
||||
return 'sass';
|
||||
}
|
||||
|
||||
public override getInstructionInformation(instruction: string): AssemblyInstructionInfo | null {
|
||||
return getAsmOpcode(instruction.toUpperCase()) || null;
|
||||
}
|
||||
}
|
||||
+24
-13
@@ -102,6 +102,7 @@ import {
|
||||
CompilerOverrideType,
|
||||
ConfiguredOverrides,
|
||||
} from '../types/compilation/compiler-overrides.interfaces.js';
|
||||
import {LLVMIrBackendOptions} from '../types/compilation/ir.interfaces.js';
|
||||
|
||||
const compilationTimeHistogram = new PromClient.Histogram({
|
||||
name: 'ce_base_compiler_compilation_duration_seconds',
|
||||
@@ -205,7 +206,8 @@ export class BaseCompiler implements ICompiler {
|
||||
}
|
||||
|
||||
this.asm = new AsmParser(this.compilerProps);
|
||||
this.llvmIr = new LlvmIrParser(this.compilerProps);
|
||||
const irDemangler = new LLVMIRDemangler(this.compiler.demangler, this);
|
||||
this.llvmIr = new LlvmIrParser(this.compilerProps, irDemangler);
|
||||
this.llvmPassDumpParser = new LlvmPassDumpParser(this.compilerProps);
|
||||
this.llvmAst = new LlvmAstParser(this.compilerProps);
|
||||
|
||||
@@ -1212,12 +1214,21 @@ export class BaseCompiler implements ICompiler {
|
||||
}
|
||||
}
|
||||
|
||||
async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) {
|
||||
async generateIR(
|
||||
inputFilename: string,
|
||||
options: string[],
|
||||
irOptions: LLVMIrBackendOptions,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
// These options make Clang produce an IR
|
||||
const newOptions = options
|
||||
.filter(option => option !== '-fcolor-diagnostics')
|
||||
.concat(unwrap(this.compiler.irArg));
|
||||
|
||||
if (irOptions.noDiscardValueNames && this.compiler.llvmOptNoDiscardValueNamesArg) {
|
||||
newOptions.push(...this.compiler.llvmOptNoDiscardValueNamesArg);
|
||||
}
|
||||
|
||||
const execOptions = this.getDefaultExecOptions();
|
||||
// A higher max output is needed for when the user includes headers
|
||||
execOptions.maxOutput = 1024 * 1024 * 1024;
|
||||
@@ -1226,16 +1237,15 @@ export class BaseCompiler implements ICompiler {
|
||||
if (output.code !== 0) {
|
||||
return [{text: 'Failed to run compiler to get IR code'}];
|
||||
}
|
||||
const ir = await this.processIrOutput(output, filters);
|
||||
const ir = await this.processIrOutput(output, irOptions, filters);
|
||||
return ir.asm;
|
||||
}
|
||||
|
||||
async processIrOutput(output, filters: ParseFiltersAndOutputOptions) {
|
||||
async processIrOutput(output, irOptions: LLVMIrBackendOptions, filters: ParseFiltersAndOutputOptions) {
|
||||
const irPath = this.getIrOutputFilename(output.inputFilename, filters);
|
||||
if (await fs.pathExists(irPath)) {
|
||||
const output = await fs.readFile(irPath, 'utf8');
|
||||
// uses same filters as main compiler
|
||||
return this.llvmIr.process(output, filters);
|
||||
return this.llvmIr.process(output, irOptions);
|
||||
}
|
||||
return {
|
||||
asm: [{text: 'Internal error; unable to open output path'}],
|
||||
@@ -1294,9 +1304,9 @@ export class BaseCompiler implements ICompiler {
|
||||
const demangler = new LLVMIRDemangler(this.compiler.demangler, this);
|
||||
// collect labels off the raw input
|
||||
if (this.compiler.debugPatched) {
|
||||
await demangler.collect({asm: output.stdout});
|
||||
demangler.collect({asm: output.stdout});
|
||||
} else {
|
||||
await demangler.collect({asm: output.stderr});
|
||||
demangler.collect({asm: output.stderr});
|
||||
}
|
||||
return {
|
||||
results: await demangler.demangleLLVMPasses(llvmOptPipeline),
|
||||
@@ -1424,7 +1434,8 @@ export class BaseCompiler implements ICompiler {
|
||||
return [{text: 'Internal error; unable to open output path'}];
|
||||
}
|
||||
|
||||
getIrOutputFilename(inputFilename: string, filters?: ParseFiltersAndOutputOptions): string {
|
||||
getIrOutputFilename(inputFilename: string, filters: ParseFiltersAndOutputOptions): string {
|
||||
// filters are passed because rust needs to know whether a binary is being produced or not
|
||||
return inputFilename.replace(path.extname(inputFilename), '.ll');
|
||||
}
|
||||
|
||||
@@ -2044,7 +2055,7 @@ export class BaseCompiler implements ICompiler {
|
||||
this.runCompiler(this.compiler.exe, options, inputFilenameSafe, execOptions),
|
||||
makeAst ? this.generateAST(inputFilename, options) : '',
|
||||
makePp ? this.generatePP(inputFilename, options, backendOptions.producePp) : '',
|
||||
makeIr ? this.generateIR(inputFilename, options, filters) : '',
|
||||
makeIr ? this.generateIR(inputFilename, options, backendOptions.produceIr, filters) : '',
|
||||
makeLLVMOptPipeline
|
||||
? this.generateLLVMOptPipeline(inputFilename, options, filters, backendOptions.produceLLVMOptPipeline)
|
||||
: '',
|
||||
@@ -2644,7 +2655,7 @@ export class BaseCompiler implements ICompiler {
|
||||
} else {
|
||||
if (!result.externalParserUsed) {
|
||||
if (result.okToCache) {
|
||||
const res = this.processAsm(result, filters, options);
|
||||
const res = await this.processAsm(result, filters, options);
|
||||
result.asm = res.asm;
|
||||
result.labelDefinitions = res.labelDefinitions;
|
||||
result.parsingTime = res.parsingTime;
|
||||
@@ -2691,9 +2702,9 @@ export class BaseCompiler implements ICompiler {
|
||||
return result;
|
||||
}
|
||||
|
||||
processAsm(result, filters, options) {
|
||||
async processAsm(result, filters, options) {
|
||||
if ((options && options.includes('-emit-llvm')) || this.llvmIr.isLlvmIr(result.asm)) {
|
||||
return this.llvmIr.process(result.asm, filters);
|
||||
return await this.llvmIr.processFromFilters(result.asm, filters);
|
||||
}
|
||||
|
||||
return this.asm.process(result.asm, filters);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import _ from 'underscore';
|
||||
|
||||
import {logger} from '../logger.js';
|
||||
|
||||
Vendored
+2
-3
@@ -22,12 +22,11 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import * as Sentry from '@sentry/node';
|
||||
|
||||
import type {GetResult} from '../../types/cache.interfaces.js';
|
||||
import {logger} from '../logger.js';
|
||||
import {S3Bucket} from '../s3-handler.js';
|
||||
import type {S3HandlerOptions} from '../s3-handler.interfaces.js';
|
||||
import {SentryCapture} from '../sentry.js';
|
||||
|
||||
import {BaseCache} from './base.js';
|
||||
import {StorageClass} from '@aws-sdk/client-s3';
|
||||
@@ -50,7 +49,7 @@ export class S3Cache extends BaseCache {
|
||||
this.onError =
|
||||
onError ||
|
||||
((e, op) => {
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'S3Cache onError');
|
||||
logger.error(`Error while trying to ${op} S3 cache: ${messageFor(e)}`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -334,6 +334,7 @@ export class CompilerFinder {
|
||||
preamble: props<string>('licensePreamble'),
|
||||
},
|
||||
possibleOverrides: [],
|
||||
$order: undefined as unknown as number, // TODO(jeremy-rifkin): Very dirty
|
||||
};
|
||||
|
||||
if (props('demanglerClassFile') !== undefined) {
|
||||
|
||||
@@ -1013,7 +1013,7 @@ export class SwiftParser extends ClangParser {
|
||||
static override async parse(compiler) {
|
||||
const results = await Promise.all([this.getOptions(compiler, '--help')]);
|
||||
const options = Object.assign({}, ...results);
|
||||
await this.setCompilerSettingsFromOptions(compiler, options);
|
||||
this.setCompilerSettingsFromOptions(compiler, options);
|
||||
return compiler;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class C3Compiler extends BaseCompiler {
|
||||
return ['compile-only', '-g', '-l', 'pthread', '--emit-asm'];
|
||||
}
|
||||
|
||||
override getIrOutputFilename(inputFilename: string, filters: ParseFiltersAndOutputOptions): string {
|
||||
override getIrOutputFilename(inputFilename: string): string {
|
||||
return this.filename(path.dirname(inputFilename) + '/output.ll');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ export class CarbonCompiler extends BaseCompiler {
|
||||
return ['--color', `--trace_file=${outputFilename}`];
|
||||
}
|
||||
|
||||
override processAsm(result, filters, options): ParsedAsmResult {
|
||||
override async processAsm(result, filters, options): Promise<ParsedAsmResult> {
|
||||
// Really should write a custom parser, but for now just don't filter anything.
|
||||
return super.processAsm(
|
||||
return await super.processAsm(
|
||||
result,
|
||||
{
|
||||
labels: false,
|
||||
|
||||
@@ -36,7 +36,6 @@ import {AmdgpuAsmParser} from '../parsers/asm-parser-amdgpu.js';
|
||||
import {SassAsmParser} from '../parsers/asm-parser-sass.js';
|
||||
import * as utils from '../utils.js';
|
||||
import {ArtifactType} from '../../types/tool.interfaces.js';
|
||||
import {ClangParser} from './argument-parsers.js';
|
||||
|
||||
const offloadRegexp = /^#\s+__CLANG_OFFLOAD_BUNDLE__(__START__|__END__)\s+(.*)$/gm;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.in
|
||||
|
||||
import {Win32Compiler} from './win32.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
|
||||
|
||||
export class ClangCLCompiler extends Win32Compiler {
|
||||
static override get key() {
|
||||
@@ -45,7 +46,12 @@ export class ClangCLCompiler extends Win32Compiler {
|
||||
this.compiler.includeFlag = '/clang:-isystem';
|
||||
}
|
||||
|
||||
override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) {
|
||||
override async generateIR(
|
||||
inputFilename: string,
|
||||
options: string[],
|
||||
irOptions: LLVMIrBackendOptions,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
// These options make Clang produce an IR
|
||||
const newOptions = options
|
||||
.filter(option => option !== '/FA' && !option.startsWith('/Fa'))
|
||||
@@ -59,11 +65,11 @@ export class ClangCLCompiler extends Win32Compiler {
|
||||
if (output.code !== 0) {
|
||||
return [{text: 'Failed to run compiler to get IR code'}];
|
||||
}
|
||||
const ir = await this.processIrOutput(output, filters);
|
||||
const ir = await this.processIrOutput(output, irOptions, filters);
|
||||
return ir.asm;
|
||||
}
|
||||
|
||||
override getIrOutputFilename(inputFilename: string, filters: ParseFiltersAndOutputOptions): string {
|
||||
override getIrOutputFilename(inputFilename: string): string {
|
||||
return this.filename(path.dirname(inputFilename) + '/output.s.obj');
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,11 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import _ from 'underscore';
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import type {CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import * as utils from '../utils.js';
|
||||
import {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import {CompilationEnvironment} from '../compilation-env.js';
|
||||
|
||||
|
||||
@@ -72,10 +72,10 @@ export class HookCompiler extends BaseCompiler {
|
||||
return super.runCompiler(compiler, options, inputFilename, execOptions);
|
||||
}
|
||||
|
||||
override processAsm(result, filters, options) {
|
||||
override async processAsm(result, filters, options) {
|
||||
// Ignoring `trim` filter because it is not supported by Hook.
|
||||
filters.trim = false;
|
||||
const _result = super.processAsm(result, filters, options);
|
||||
const _result = await super.processAsm(result, filters, options);
|
||||
const commentRegex = /^\s*;(.*)/;
|
||||
const instructionRegex = /^\s{2}(\d+)(.*)/;
|
||||
const asm = _result.asm;
|
||||
|
||||
+14
-3
@@ -32,6 +32,7 @@ import {asSafeVer} from '../utils.js';
|
||||
|
||||
import {ISPCParser} from './argument-parsers.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
|
||||
|
||||
export class ISPCCompiler extends BaseCompiler {
|
||||
static get key() {
|
||||
@@ -56,9 +57,19 @@ export class ISPCCompiler extends BaseCompiler {
|
||||
return options;
|
||||
}
|
||||
|
||||
override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) {
|
||||
const newOptions = [...options, ...unwrap(this.compiler.irArg), '-o', this.getIrOutputFilename(inputFilename)];
|
||||
return super.generateIR(inputFilename, newOptions, filters);
|
||||
override async generateIR(
|
||||
inputFilename: string,
|
||||
options: string[],
|
||||
irOptions: LLVMIrBackendOptions,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
const newOptions = [
|
||||
...options,
|
||||
...unwrap(this.compiler.irArg),
|
||||
'-o',
|
||||
this.getIrOutputFilename(inputFilename, filters),
|
||||
];
|
||||
return super.generateIR(inputFilename, newOptions, irOptions, filters);
|
||||
}
|
||||
|
||||
override getArgumentParser() {
|
||||
|
||||
@@ -238,7 +238,7 @@ export class JavaCompiler extends BaseCompiler {
|
||||
return this.filterUserOptionsWithArg(userOptions, oneArgForbiddenList);
|
||||
}
|
||||
|
||||
override processAsm(result) {
|
||||
override async processAsm(result) {
|
||||
// Handle "error" documents.
|
||||
if (!result.asm.includes('\n') && result.asm[0] === '<') {
|
||||
return [{text: result.asm, source: null}];
|
||||
|
||||
@@ -58,7 +58,7 @@ export class JuliaCompiler extends BaseCompiler {
|
||||
return [];
|
||||
}
|
||||
|
||||
override processAsm(result, filters, options) {
|
||||
override async processAsm(result, filters, options) {
|
||||
const lineRe = /^<(\d+) (\d+) ([^ ]+) ([^>]*)>$/;
|
||||
const bytecodeLines = result.asm.split('\n');
|
||||
const bytecodeResult: ParsedAsmResultLine[] = [];
|
||||
|
||||
@@ -80,7 +80,7 @@ export class MLIRCompiler extends BaseCompiler {
|
||||
return [];
|
||||
}
|
||||
|
||||
override processAsm(result, filters, options) {
|
||||
override async processAsm(result, filters, options) {
|
||||
// at some point maybe a custom parser can be written, for now just don't filter anything
|
||||
return super.processAsm(
|
||||
result,
|
||||
|
||||
@@ -62,7 +62,7 @@ export class FPCCompiler extends BaseCompiler {
|
||||
return [];
|
||||
}
|
||||
|
||||
override processAsm(result, filters) {
|
||||
override async processAsm(result, filters) {
|
||||
// TODO: Pascal doesn't have a demangler exe, it's the only compiler that's weird like this
|
||||
this.demangler = new (unwrap(this.demanglerClass))(null as any, this);
|
||||
return this.asm.process(result.asm, filters);
|
||||
|
||||
@@ -30,6 +30,7 @@ import type {CompilationResult, ExecutionOptions} from '../../types/compilation/
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
|
||||
|
||||
export class PonyCompiler extends BaseCompiler {
|
||||
static get key() {
|
||||
@@ -62,7 +63,12 @@ export class PonyCompiler extends BaseCompiler {
|
||||
return source;
|
||||
}
|
||||
|
||||
override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) {
|
||||
override async generateIR(
|
||||
inputFilename: string,
|
||||
options: string[],
|
||||
irOptions: LLVMIrBackendOptions,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
const newOptions = _.filter(options, option => !['--pass', 'asm'].includes(option)).concat(
|
||||
unwrap(this.compiler.irArg),
|
||||
);
|
||||
@@ -75,7 +81,7 @@ export class PonyCompiler extends BaseCompiler {
|
||||
if (output.code !== 0) {
|
||||
return [{text: 'Failed to run compiler to get IR code'}];
|
||||
}
|
||||
const ir = await this.processIrOutput(output, filters);
|
||||
const ir = await this.processIrOutput(output, irOptions, filters);
|
||||
return ir.asm;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ export class PythonCompiler extends BaseCompiler {
|
||||
resolvePathFromAppRoot('etc', 'scripts', 'disasms', 'dis_all.py');
|
||||
}
|
||||
|
||||
override processAsm(result) {
|
||||
override async processAsm(result) {
|
||||
const lineRe = /^\s{0,4}(\d+)(.*)/;
|
||||
|
||||
const bytecodeLines = result.asm.split('\n');
|
||||
|
||||
@@ -123,7 +123,7 @@ export class RacketCompiler extends BaseCompiler {
|
||||
return result;
|
||||
}
|
||||
|
||||
override processAsm(result: any, filters: any, options: any) {
|
||||
override async processAsm(result: any, filters: any, options: any) {
|
||||
// TODO: Process and highlight decompiled output
|
||||
return {
|
||||
asm: [{text: result.asm}],
|
||||
|
||||
@@ -48,7 +48,7 @@ export class RubyCompiler extends BaseCompiler {
|
||||
return 'asmruby';
|
||||
}
|
||||
|
||||
override processAsm(result) {
|
||||
override async processAsm(result) {
|
||||
const lineRe = /\(\s*(\d+)\)(?:\[[^\]]+])?$/;
|
||||
const fileRe = /ISeq:.*?@(.*?):(\d+) /;
|
||||
const baseFile = path.basename(this.compileFilename);
|
||||
|
||||
@@ -65,7 +65,7 @@ export class SolidityCompiler extends BaseCompiler {
|
||||
return path.join(dirPath, 'contracts/combined.json');
|
||||
}
|
||||
|
||||
override processAsm(result) {
|
||||
override async processAsm(result) {
|
||||
// Handle "error" documents.
|
||||
if (!result.asm.includes('\n') && result.asm[0] === '<') {
|
||||
return {asm: [{text: result.asm}]};
|
||||
|
||||
@@ -35,6 +35,7 @@ import {SPIRVAsmParser} from '../parsers/asm-parser-spirv.js';
|
||||
import * as utils from '../utils.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import type {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js';
|
||||
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
|
||||
|
||||
export class SPIRVCompiler extends BaseCompiler {
|
||||
protected translatorPath: string;
|
||||
@@ -201,7 +202,12 @@ export class SPIRVCompiler extends BaseCompiler {
|
||||
);
|
||||
}
|
||||
|
||||
override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) {
|
||||
override async generateIR(
|
||||
inputFilename: string,
|
||||
options: string[],
|
||||
irOptions: LLVMIrBackendOptions,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
const newOptions = _.filter(options, option => option !== '-fcolor-diagnostics').concat('-emit-llvm');
|
||||
|
||||
const execOptions = this.getDefaultExecOptions();
|
||||
@@ -217,7 +223,7 @@ export class SPIRVCompiler extends BaseCompiler {
|
||||
logger.error('Failed to run compiler to get IR code');
|
||||
return output.stderr;
|
||||
}
|
||||
const ir = await this.processIrOutput(output, filters);
|
||||
const ir = await this.processIrOutput(output, irOptions, filters);
|
||||
return ir.asm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import {BaseCompiler} from '../base-compiler.js';
|
||||
import {asSafeVer} from '../utils.js';
|
||||
|
||||
import {TypeScriptNativeParser} from './argument-parsers.js';
|
||||
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
|
||||
|
||||
export class TypeScriptNativeCompiler extends BaseCompiler {
|
||||
static get key() {
|
||||
@@ -105,7 +106,12 @@ export class TypeScriptNativeCompiler extends BaseCompiler {
|
||||
return {code: 0, timedOut: false, stdout: [], stderr: []};
|
||||
}
|
||||
|
||||
override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) {
|
||||
override async generateIR(
|
||||
inputFilename: string,
|
||||
options: string[],
|
||||
irOptions: LLVMIrBackendOptions,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
// These options make Clang produce an IR
|
||||
let newOptions = ['--emit=llvm', inputFilename];
|
||||
if (this.tscNewOutput) {
|
||||
@@ -134,7 +140,7 @@ export class TypeScriptNativeCompiler extends BaseCompiler {
|
||||
filters.libraryCode = true;
|
||||
filters.directives = true;
|
||||
|
||||
const ir = await this.llvmIr.process(this.tscNewOutput ? output.stdout : output.stderr, filters);
|
||||
const ir = await this.llvmIr.process(this.tscNewOutput ? output.stdout : output.stderr, irOptions);
|
||||
return ir.asm;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ export class V8Compiler extends BaseCompiler {
|
||||
this.demanglerClass = null;
|
||||
}
|
||||
|
||||
override getIrOutputFilename(inputFilename: string, filters: ParseFiltersAndOutputOptions): string {
|
||||
override getIrOutputFilename(inputFilename: string): string {
|
||||
return this.filename(path.dirname(inputFilename) + '/code.asm');
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ export class Win32Compiler extends BaseCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
override processAsm(result, filters /*, options*/) {
|
||||
override async processAsm(result, filters /*, options*/) {
|
||||
if (filters.binary) {
|
||||
filters.dontMaskFilenames = true;
|
||||
return this.binaryAsmParser.process(result.asm, filters);
|
||||
|
||||
@@ -28,7 +28,7 @@ import type {ExecutionOptions} from '../../types/compilation/compilation.interfa
|
||||
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
import {ArtifactType} from '../../types/tool.interfaces.js';
|
||||
import {BaseCompiler, c_default_target_description} from '../base-compiler.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import {logger} from '../logger.js';
|
||||
import {AsmParserZ88dk} from '../parsers/asm-parser-z88dk.js';
|
||||
import * as utils from '../utils.js';
|
||||
|
||||
@@ -26,7 +26,6 @@ import path from 'path';
|
||||
|
||||
import Semver from 'semver';
|
||||
import _ from 'underscore';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
|
||||
@@ -35,14 +35,14 @@ import * as utils from '../utils.js';
|
||||
import {PrefixTree} from './prefix-tree.js';
|
||||
|
||||
export class BaseDemangler extends AsmRegex {
|
||||
demanglerExe: string;
|
||||
readonly demanglerExe: string;
|
||||
demanglerArguments: string[];
|
||||
symbolstore: SymbolStore | null;
|
||||
othersymbols: SymbolStore;
|
||||
result: ParsedAsmResult;
|
||||
input: string[];
|
||||
includeMetadata: boolean;
|
||||
compiler: BaseCompiler;
|
||||
readonly compiler: BaseCompiler;
|
||||
|
||||
readonly jumpDef = /(j\w+|b|bl|blx)\s+([$_a-z][\w$@]*)/i;
|
||||
readonly callDef = /callq?\s+([$._a-z][\w$.@]*)/i;
|
||||
|
||||
+2
-2
@@ -412,10 +412,10 @@ export function startWineInit() {
|
||||
}
|
||||
|
||||
logger.info(`Killing any pre-existing wine-server`);
|
||||
let result = await child_process.exec(`${server} -k || true`, {env: env});
|
||||
let result = child_process.exec(`${server} -k || true`, {env: env});
|
||||
logger.info(`Result: ${result}`);
|
||||
logger.info(`Waiting for any pre-existing server to stop...`);
|
||||
result = await child_process.exec(`${server} -w`, {env: env});
|
||||
result = child_process.exec(`${server} -w`, {env: env});
|
||||
logger.info(`Result: ${result}`);
|
||||
|
||||
// We run a long-lived cmd process, to:
|
||||
|
||||
+2
-2
@@ -22,7 +22,6 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import * as Sentry from '@sentry/node';
|
||||
import bodyParser from 'body-parser';
|
||||
import express from 'express';
|
||||
import _ from 'underscore';
|
||||
@@ -43,6 +42,7 @@ import {withAssemblyDocumentationProviders} from './assembly-documentation.js';
|
||||
import {CompileHandler} from './compile.js';
|
||||
import {FormattingHandler} from './formatting.js';
|
||||
import {getSiteTemplates} from './site-templates.js';
|
||||
import {SentryCapture} from '../sentry.js';
|
||||
|
||||
function methodNotAllowed(req: express.Request, res: express.Response) {
|
||||
res.send('Method Not Allowed');
|
||||
@@ -166,7 +166,7 @@ export class ApiHandler {
|
||||
.catch(err => {
|
||||
logger.warn(`Exception thrown when expanding ${id}: `, err);
|
||||
logger.warn('Exception value:', err);
|
||||
Sentry.captureException(err);
|
||||
SentryCapture(err, 'shortlinkInfoHandler');
|
||||
next({
|
||||
statusCode: 404,
|
||||
message: `ID "${id}" could not be found`,
|
||||
|
||||
@@ -51,6 +51,7 @@ import {
|
||||
import {remove} from '../common-utils.js';
|
||||
import {CompilerOverrideOptions} from '../../types/compilation/compiler-overrides.interfaces.js';
|
||||
import {BypassCache, CompileChildLibraries, ExecutionParams} from '../../types/compilation/compilation.interfaces.js';
|
||||
import {SentryCapture} from '../sentry.js';
|
||||
|
||||
temp.track();
|
||||
|
||||
@@ -166,8 +167,9 @@ export class CompileHandler {
|
||||
),
|
||||
});
|
||||
} else {
|
||||
Sentry.captureException(
|
||||
SentryCapture(
|
||||
new Error(`Unexpected Content-Type received by /compiler/:compiler/compile: ${contentType}`),
|
||||
'lib/handlers/compile.ts proxyReq contentType',
|
||||
);
|
||||
proxyReq.write('Unexpected Content-Type');
|
||||
}
|
||||
@@ -179,7 +181,7 @@ export class CompileHandler {
|
||||
proxyReq.write(bodyData);
|
||||
}
|
||||
} catch (e: any) {
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'lib/handlers/compile.ts proxyReq.write');
|
||||
let json = '<json stringify error>';
|
||||
try {
|
||||
json = JSON.stringify(bodyData);
|
||||
@@ -589,7 +591,7 @@ export class CompileHandler {
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
Sentry.captureException(ex);
|
||||
SentryCapture(ex, 'lib/handlers/compile.ts res.write');
|
||||
res.write(`Error handling request: ${ex}`);
|
||||
}
|
||||
res.end('\n');
|
||||
@@ -601,7 +603,7 @@ export class CompileHandler {
|
||||
} else {
|
||||
if (error.stack) {
|
||||
logger.error('Error during compilation 2: ', error);
|
||||
Sentry.captureException(error);
|
||||
SentryCapture(error, 'compile failed');
|
||||
} else if (error.code) {
|
||||
logger.error('Error during compilation 3: ', error.code);
|
||||
if (typeof error.stderr === 'string') {
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import * as Sentry from '@sentry/node';
|
||||
import express from 'express';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import {CompilationQueue} from '../compilation-queue.js';
|
||||
import {logger} from '../logger.js';
|
||||
import {SentryCapture} from '../sentry.js';
|
||||
|
||||
export class HealthCheckHandler {
|
||||
public readonly handle: (req: any, res: any) => Promise<void>;
|
||||
@@ -57,7 +57,7 @@ export class HealthCheckHandler {
|
||||
res.send(content);
|
||||
} catch (e) {
|
||||
logger.error(`*** HEALTH CHECK FAILURE: while reading file '${this.filePath}' got ${e}`);
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'Health check');
|
||||
res.status(500).end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import * as Sentry from '@sentry/node';
|
||||
import express from 'express';
|
||||
|
||||
import {assert, unwrap} from '../assert.js';
|
||||
@@ -34,6 +33,7 @@ import {StorageBase} from '../storage/index.js';
|
||||
import * as utils from '../utils.js';
|
||||
|
||||
import {ApiHandler} from './api.js';
|
||||
import {SentryCapture} from '../sentry.js';
|
||||
|
||||
export type HandlerConfig = {
|
||||
compileHandler: any;
|
||||
@@ -110,7 +110,7 @@ export class RouteAPI {
|
||||
.catch(err => {
|
||||
logger.debug(`Exception thrown when expanding ${id}: `, err);
|
||||
logger.warn('Exception value:', err);
|
||||
Sentry.captureException(err);
|
||||
SentryCapture(err, 'storedCodeHandler');
|
||||
next({
|
||||
statusCode: 404,
|
||||
message: `ID "${id}/${sessionid}" could not be found`,
|
||||
@@ -201,7 +201,7 @@ export class RouteAPI {
|
||||
.catch(err => {
|
||||
logger.warn(`Exception thrown when expanding ${id}`);
|
||||
logger.warn('Exception value:', err);
|
||||
Sentry.captureException(err);
|
||||
SentryCapture(err, 'storedStateHandlerResetLayout');
|
||||
next({
|
||||
statusCode: 404,
|
||||
message: `ID "${id}" could not be found`,
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
|
||||
logoUrlDark: 'cuda-dark.svg',
|
||||
formatter: null,
|
||||
previewFilter: null,
|
||||
monacoDisassembly: 'ptx',
|
||||
monacoDisassembly: null,
|
||||
},
|
||||
d: {
|
||||
name: 'D',
|
||||
|
||||
+106
-42
@@ -27,15 +27,32 @@ import _ from 'underscore';
|
||||
import type {IRResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
||||
|
||||
import * as utils from './utils.js';
|
||||
import {LLVMIrBackendOptions} from '../types/compilation/ir.interfaces.js';
|
||||
import {LLVMIRDemangler} from './demangler/llvm.js';
|
||||
import {ParseFiltersAndOutputOptions} from '../types/features/filters.interfaces.js';
|
||||
|
||||
type MetaNode = {
|
||||
metaId: string;
|
||||
metaType: string;
|
||||
};
|
||||
|
||||
export class LlvmIrParser {
|
||||
private maxIrLines: number;
|
||||
private debugReference: RegExp;
|
||||
private metaNodeRe: RegExp;
|
||||
private otherMetaDirective: RegExp;
|
||||
private namedMetaDirective: RegExp;
|
||||
private metaNodeOptionsRe: RegExp;
|
||||
private llvmDebug: RegExp;
|
||||
private llvmDebugLine: RegExp;
|
||||
private llvmDebugAnnotation: RegExp;
|
||||
private attributeAnnotation: RegExp;
|
||||
private attributeDirective: RegExp;
|
||||
private moduleMetadata: RegExp;
|
||||
private functionAttrs: RegExp;
|
||||
|
||||
constructor(compilerProps) {
|
||||
// TODO(jeremy-rifkin) can awful state things happen because of soring a demangler? Usually they're constructed
|
||||
// fresh for each compile.
|
||||
constructor(compilerProps, private readonly irDemangler: LLVMIRDemangler) {
|
||||
this.maxIrLines = 5000;
|
||||
if (compilerProps) {
|
||||
this.maxIrLines = compilerProps('maxLinesOfAsm', this.maxIrLines);
|
||||
@@ -43,8 +60,16 @@ export class LlvmIrParser {
|
||||
|
||||
this.debugReference = /!dbg (!\d+)/;
|
||||
this.metaNodeRe = /^(!\d+) = (?:distinct )?!DI([A-Za-z]+)\(([^)]+?)\)/;
|
||||
this.otherMetaDirective = /^(!\d+) = (?:distinct )?!{.*}/;
|
||||
this.namedMetaDirective = /^(![.A-Z_a-z-]+) = (?:distinct )?!{.*}/;
|
||||
this.metaNodeOptionsRe = /(\w+): (!?\d+|\w+|""|"(?:[^"]|\\")*[^\\]")/gi;
|
||||
this.llvmDebug = /^\s*call void @llvm\.dbg\..*$/;
|
||||
|
||||
this.llvmDebugLine = /^\s*call void @llvm\.dbg\..*$/;
|
||||
this.llvmDebugAnnotation = /,? !dbg !\d+/;
|
||||
this.attributeAnnotation = /,? #\d+(?= )/;
|
||||
this.attributeDirective = /^attributes #\d+ = { .+ }$/;
|
||||
this.functionAttrs = /^; Function Attrs: .+$/;
|
||||
this.moduleMetadata = /^((source_filename|target datalayout|target triple) = ".+"|; ModuleID = '.+')$/;
|
||||
}
|
||||
|
||||
getFileName(debugInfo, scope): string | null {
|
||||
@@ -96,7 +121,7 @@ export class LlvmIrParser {
|
||||
}
|
||||
}
|
||||
|
||||
parseMetaNode(line) {
|
||||
parseMetaNode(line: string) {
|
||||
// Metadata Nodes
|
||||
// See: https://llvm.org/docs/LangRef.html#metadata
|
||||
const match = line.match(this.metaNodeRe);
|
||||
@@ -121,14 +146,30 @@ export class LlvmIrParser {
|
||||
return metaNode;
|
||||
}
|
||||
|
||||
processIr(ir, filters) {
|
||||
async processIr(ir: string, options: LLVMIrBackendOptions) {
|
||||
const result: IRResultLine[] = [];
|
||||
const irLines = utils.splitLines(ir);
|
||||
const debugInfo = {};
|
||||
const debugInfo: Record<string, MetaNode> = {};
|
||||
let prevLineEmpty = false;
|
||||
|
||||
// Filters
|
||||
const commentOnly = /^\s*(;.*)$/;
|
||||
const filters: RegExp[] = [];
|
||||
const lineFilters: RegExp[] = [];
|
||||
|
||||
if (options.filterDebugInfo) {
|
||||
filters.push(this.llvmDebugLine);
|
||||
lineFilters.push(this.llvmDebugAnnotation);
|
||||
}
|
||||
if (options.filterIRMetadata) {
|
||||
filters.push(this.moduleMetadata);
|
||||
filters.push(this.metaNodeRe);
|
||||
filters.push(this.otherMetaDirective);
|
||||
filters.push(this.namedMetaDirective);
|
||||
}
|
||||
if (options.filterAttributes) {
|
||||
filters.push(this.attributeDirective);
|
||||
filters.push(this.functionAttrs);
|
||||
lineFilters.push(this.attributeAnnotation);
|
||||
}
|
||||
|
||||
for (const line of irLines) {
|
||||
if (line.trim().length === 0) {
|
||||
@@ -137,37 +178,42 @@ export class LlvmIrParser {
|
||||
result.push({text: ''});
|
||||
}
|
||||
prevLineEmpty = true;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
let newLine = line;
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const temp = newLine;
|
||||
for (const re of lineFilters) {
|
||||
newLine = newLine.replace(re, '');
|
||||
}
|
||||
if (newLine === temp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.commentOnly && commentOnly.test(line)) {
|
||||
continue;
|
||||
}
|
||||
if (filters.debugCalls && this.llvmDebug.test(line)) {
|
||||
continue;
|
||||
}
|
||||
const resultLine: IRResultLine = {
|
||||
text: newLine,
|
||||
};
|
||||
|
||||
// Non-Meta IR line. Metadata is attached to it using "!dbg !123"
|
||||
const match = line.match(this.debugReference);
|
||||
if (match) {
|
||||
result.push({
|
||||
text: filters.trim ? utils.squashHorizontalWhitespace(line) : line,
|
||||
scope: match[1],
|
||||
});
|
||||
// Non-Meta IR line. Metadata is attached to it using "!dbg !123"
|
||||
const debugReferenceMatch = line.match(this.debugReference);
|
||||
if (debugReferenceMatch) {
|
||||
resultLine.scope = debugReferenceMatch[1];
|
||||
}
|
||||
|
||||
const metaNode = this.parseMetaNode(line);
|
||||
if (metaNode) {
|
||||
debugInfo[metaNode.metaId] = metaNode;
|
||||
}
|
||||
|
||||
// Filtering a full line
|
||||
if (filters.some(re => line.match(re))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(resultLine);
|
||||
prevLineEmpty = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
const metaNode = this.parseMetaNode(line);
|
||||
if (metaNode) {
|
||||
debugInfo[metaNode.metaId] = metaNode;
|
||||
}
|
||||
|
||||
if (filters.directives && this.isLineLlvmDirective(line)) {
|
||||
continue;
|
||||
}
|
||||
result.push({text: filters.trim ? utils.squashHorizontalWhitespace(line) : line});
|
||||
prevLineEmpty = false;
|
||||
}
|
||||
|
||||
if (result.length >= this.maxIrLines) {
|
||||
@@ -184,16 +230,30 @@ export class LlvmIrParser {
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
asm: result,
|
||||
labelDefinitions: {},
|
||||
languageId: 'llvm-ir',
|
||||
};
|
||||
if (options.demangle) {
|
||||
return {
|
||||
asm: (await this.irDemangler.process({asm: result})).asm,
|
||||
labelDefinitions: {},
|
||||
languageId: 'llvm-ir',
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
asm: result,
|
||||
labelDefinitions: {},
|
||||
languageId: 'llvm-ir',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
process(ir, filters) {
|
||||
async processFromFilters(ir, filters: ParseFiltersAndOutputOptions) {
|
||||
if (_.isString(ir)) {
|
||||
return this.processIr(ir, filters);
|
||||
return await this.processIr(ir, {
|
||||
filterDebugInfo: !!filters.debugCalls,
|
||||
filterIRMetadata: !!filters.directives,
|
||||
filterAttributes: false,
|
||||
demangle: !!filters.demangle,
|
||||
// discard value names is handled earlier
|
||||
});
|
||||
}
|
||||
return {
|
||||
asm: [],
|
||||
@@ -201,6 +261,10 @@ export class LlvmIrParser {
|
||||
};
|
||||
}
|
||||
|
||||
async process(ir: string, irOptions: LLVMIrBackendOptions) {
|
||||
return await this.processIr(ir, irOptions);
|
||||
}
|
||||
|
||||
isLineLlvmDirective(line) {
|
||||
return !!(
|
||||
/^!\d+ = (distinct )?!(DI|{)/.test(line) ||
|
||||
|
||||
@@ -22,13 +22,9 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {logger} from '../logger.js';
|
||||
import {PropertyGetter} from '../properties.interfaces.js';
|
||||
import * as utils from '../utils.js';
|
||||
|
||||
import {AsmParser} from './asm-parser.js';
|
||||
import {VcAsmParser} from './asm-parser-vc.js';
|
||||
import {AsmRegex} from './asmregex.js';
|
||||
|
||||
export class Vc6AsmParser extends VcAsmParser {
|
||||
constructor(compilerProps?: PropertyGetter) {
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import _ from 'underscore';
|
||||
|
||||
import {
|
||||
LLVMOptPipelineBackendOptions,
|
||||
LLVMOptPipelineResults,
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright (c) 2023, Compiler Explorer Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {logger} from './logger.js';
|
||||
import {PropertyGetter} from './properties.interfaces.js';
|
||||
import {parse} from './stacktrace.js';
|
||||
|
||||
import * as Sentry from '@sentry/node';
|
||||
|
||||
function shouldRedactRequestData(data: string) {
|
||||
try {
|
||||
const parsed = JSON.parse(data);
|
||||
return !parsed['allowStoreCodeDebug'];
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function SetupSentry(
|
||||
sentryDsn: string,
|
||||
ceProps: PropertyGetter,
|
||||
releaseBuildNumber: string | undefined,
|
||||
gitReleaseName: string | undefined,
|
||||
defArgs: any,
|
||||
) {
|
||||
if (!sentryDsn) {
|
||||
logger.info('Not configuring sentry');
|
||||
return;
|
||||
}
|
||||
const sentryEnv = ceProps('sentryEnvironment');
|
||||
Sentry.init({
|
||||
dsn: sentryDsn,
|
||||
release: releaseBuildNumber || gitReleaseName,
|
||||
environment: sentryEnv || defArgs.env[0],
|
||||
beforeSend(event) {
|
||||
if (event.request && event.request.data && shouldRedactRequestData(event.request.data)) {
|
||||
event.request.data = JSON.stringify({redacted: true});
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
logger.info(`Configured with Sentry endpoint ${sentryDsn}`);
|
||||
}
|
||||
|
||||
export function SentryCapture(value: unknown, context?: string) {
|
||||
if (value instanceof Error) {
|
||||
if (context) {
|
||||
value.message += `\nSentryCapture Context: ${context}`;
|
||||
}
|
||||
Sentry.captureException(value);
|
||||
} else {
|
||||
const e = new Error(); // eslint-disable-line unicorn/error-message
|
||||
const trace = parse(e);
|
||||
Sentry.captureMessage(
|
||||
`Non-Error capture:\n` +
|
||||
(context ? `Context: ${context}\n` : '') +
|
||||
`Data:\n${JSON.stringify(value)}\n` +
|
||||
`Trace:\n` +
|
||||
trace
|
||||
.map(frame => `${frame.functionName} ${frame.fileName}:${frame.lineNumber}:${frame.columnNumber}`)
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
// This file is in js due to #3514
|
||||
module.exports = {
|
||||
root: true,
|
||||
plugins: ['promise', 'requirejs'],
|
||||
plugins: ['promise', 'requirejs', 'unused-imports'],
|
||||
extends: ['./.eslint-ce-static.yml'],
|
||||
rules: {
|
||||
'promise/catch-or-return': 'off',
|
||||
@@ -58,6 +58,10 @@ module.exports = {
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
rules: {
|
||||
'import/no-unresolved': 'off',
|
||||
'node/no-missing-imports': 'off',
|
||||
'unused-imports/no-unused-imports': 'error',
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'off', // Needed for now, can't move some
|
||||
@@ -66,8 +70,6 @@ module.exports = {
|
||||
'@typescript-eslint/no-unnecessary-condition': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/prefer-includes': 'error',
|
||||
'import/no-unresolved': 'off',
|
||||
'node/no-missing-imports': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
+2
-8
@@ -23,15 +23,9 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {options} from './options.js';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import {SetupSentry} from './sentry.js';
|
||||
|
||||
if (options.statusTrackingEnabled && options.sentryDsn) {
|
||||
Sentry.init({
|
||||
dsn: options.sentryDsn,
|
||||
release: options.release,
|
||||
environment: options.sentryEnvironment,
|
||||
});
|
||||
}
|
||||
SetupSentry();
|
||||
|
||||
class GAProxy {
|
||||
private hasBeenEnabled = false;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import $ from 'jquery';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import _ from 'underscore';
|
||||
import {LRUCache} from 'lru-cache';
|
||||
import {EventEmitter} from 'golden-layout';
|
||||
@@ -38,6 +37,7 @@ import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||
import {CompilationResult, FiledataPair} from '../types/compilation/compilation.interfaces.js';
|
||||
import {CompilationStatus} from './compiler-service.interfaces.js';
|
||||
import {IncludeDownloads, SourceAndFiles} from './download-service.js';
|
||||
import {SentryCapture} from './sentry.js';
|
||||
|
||||
const ASCII_COLORS_RE = new RegExp(/\x1B\[[\d;]*m(.\[K)?/g);
|
||||
|
||||
@@ -123,7 +123,7 @@ export class CompilerService {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'processFromLangAndCompiler');
|
||||
}
|
||||
// TODO: What now? Found no compilers!
|
||||
return {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import $ from 'jquery';
|
||||
import type {ICompilerShared} from './compiler-shared.interfaces.js';
|
||||
import {CompilerOverridesWidget} from './widgets/compiler-overrides.js';
|
||||
import type {CompilerState} from './panes/compiler.interfaces.js';
|
||||
|
||||
@@ -26,7 +26,6 @@ import {CompilerOutputOptions} from '../types/features/filters.interfaces.js';
|
||||
import {CfgState} from './panes/cfg-view.interfaces.js';
|
||||
import {LLVMOptPipelineViewState} from './panes/llvm-opt-pipeline.interfaces.js';
|
||||
import {GccDumpViewState} from './panes/gccdump-view.interfaces.js';
|
||||
import {PossibleArguments} from './compiler-arguments.interfaces.js';
|
||||
import {ConfiguredOverrides} from './compilation/compiler-overrides.interfaces.js';
|
||||
export const COMPILER_COMPONENT_NAME = 'compiler';
|
||||
export const EXECUTOR_COMPONENT_NAME = 'executor';
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import GoldenLayout from 'golden-layout';
|
||||
|
||||
import {type EventMap} from './event-map.js';
|
||||
import {type Hub} from './hub.js';
|
||||
import {SentryCapture} from './sentry.js';
|
||||
|
||||
export type EventHubCallback<T extends unknown[]> = (...args: T) => void;
|
||||
|
||||
@@ -83,7 +84,7 @@ export class EventHub {
|
||||
this.layoutEventHub.off(subscription.evt, subscription.fn, subscription.ctx);
|
||||
} catch (e) {
|
||||
Sentry.captureMessage(`Can not unsubscribe from ${subscription.evt.toString()}`);
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'event hub unsubscribe');
|
||||
}
|
||||
}
|
||||
this.subscriptions = [];
|
||||
|
||||
+8
-1
@@ -32,6 +32,8 @@ import {GccDumpFiltersState, GccDumpViewSelectedPass} from './panes/gccdump-view
|
||||
import {Motd} from './motd.interfaces.js';
|
||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||
import {CompilationResult} from '../types/compilation/compilation.interfaces.js';
|
||||
import {LLVMOptPipelineBackendOptions} from './compilation/llvm-opt-pipeline-output.interfaces.js';
|
||||
import {LLVMIrBackendOptions} from './compilation/ir.interfaces.js';
|
||||
|
||||
// This list comes from executing
|
||||
// grep -rPo "eventHub\.(on|emit)\('.*'," static/ | cut -d "'" -f2 | sort | uniq
|
||||
@@ -112,7 +114,12 @@ export type EventMap = {
|
||||
irViewOpened: (compilerId: number) => void;
|
||||
llvmOptPipelineViewClosed: (compilerId: number) => void;
|
||||
llvmOptPipelineViewOpened: (compilerId: number) => void;
|
||||
llvmOptPipelineViewOptionsUpdated: (compilerId: number, options: any, recompile: boolean) => void;
|
||||
llvmOptPipelineViewOptionsUpdated: (
|
||||
compilerId: number,
|
||||
options: LLVMOptPipelineBackendOptions,
|
||||
recompile: boolean,
|
||||
) => void;
|
||||
llvmIrViewOptionsUpdated: (compilerId: number, options: LLVMIrBackendOptions, recompile: boolean) => void;
|
||||
languageChange: (editorId: number | boolean, newLangId: string, treeId?: boolean | number) => void;
|
||||
modifySettings: (modifiedSettings: Partial<SiteSettings>) => void;
|
||||
motd: (data: Motd) => void;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
import {AnnotatedCfgDescriptor, AnnotatedNodeDescriptor} from '../types/compilation/cfg.interfaces.js';
|
||||
|
||||
import IntervalTree, {Node} from '@flatten-js/interval-tree';
|
||||
import IntervalTree from '@flatten-js/interval-tree';
|
||||
|
||||
// Much of the algorithm is inspired from
|
||||
// https://cutter.re/docs/api/widgets/classGraphGridLayout.html
|
||||
|
||||
+3
-3
@@ -35,7 +35,6 @@ import _ from 'underscore';
|
||||
import GoldenLayout from 'golden-layout';
|
||||
import JsCookie from 'js-cookie';
|
||||
import clipboard from 'clipboard';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
// We re-assign this
|
||||
let jsCookie = JsCookie;
|
||||
@@ -62,6 +61,7 @@ import {CompilerExplorerOptions} from './global.js';
|
||||
import {ComponentConfig, EmptyCompilerState, StateWithId, StateWithLanguage} from './components.interfaces.js';
|
||||
|
||||
import * as utils from '../lib/common-utils.js';
|
||||
import {SentryCapture} from './sentry.js';
|
||||
|
||||
const logos = require.context('../views/resources/logos', false, /\.(png|svg)$/);
|
||||
|
||||
@@ -212,7 +212,7 @@ function setupButtons(options: CompilerExplorerOptions, hub: Hub) {
|
||||
$('#ces .ces-icons').html(data);
|
||||
})
|
||||
.fail(err => {
|
||||
Sentry.captureException(err);
|
||||
SentryCapture(err, '$.get failed');
|
||||
});
|
||||
|
||||
$('#ces').on('click', () => {
|
||||
@@ -594,7 +594,7 @@ function start() {
|
||||
layout = new GoldenLayout(config, root);
|
||||
hub = new Hub(layout, subLangId, defaultLangId);
|
||||
} catch (e) {
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'goldenlayout/hub setup');
|
||||
|
||||
if (document.URL.includes('/z/')) {
|
||||
document.location = document.URL.replace('/z/', '/resetlayout/');
|
||||
|
||||
+36
-13
@@ -67,7 +67,6 @@ import {
|
||||
} from '../../types/compilation/compilation.interfaces.js';
|
||||
import {ResultLine} from '../../types/resultline/resultline.interfaces.js';
|
||||
import * as utils from '../utils.js';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import {editor} from 'monaco-editor';
|
||||
import IEditorMouseEvent = editor.IEditorMouseEvent;
|
||||
import {Tool, ArtifactType, Artifact} from '../../types/tool.interfaces.js';
|
||||
@@ -78,6 +77,8 @@ import {SourceAndFiles} from '../download-service.js';
|
||||
import fileSaver = require('file-saver');
|
||||
import {ICompilerShared} from '../compiler-shared.interfaces.js';
|
||||
import {CompilerShared} from '../compiler-shared.js';
|
||||
import {SentryCapture} from '../sentry.js';
|
||||
import {LLVMIrBackendOptions} from '../compilation/ir.interfaces.js';
|
||||
|
||||
const toolIcons = require.context('../../views/resources/logos', false, /\.(png|svg)$/);
|
||||
|
||||
@@ -276,6 +277,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
private haskellStgViewOpen: boolean;
|
||||
private haskellCmmViewOpen: boolean;
|
||||
private ppOptions: PPOptions;
|
||||
private llvmIrOptions: LLVMIrBackendOptions;
|
||||
private llvmOptPipelineOptions: LLVMOptPipelineBackendOptions;
|
||||
private isOutputOpened: boolean;
|
||||
private mouseMoveThrottledFunction?: ((e: monaco.editor.IEditorMouseEvent) => void) & _.Cancelable;
|
||||
@@ -1034,7 +1036,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
};
|
||||
} else {
|
||||
// In case this ever stops working, we'll be notified
|
||||
Sentry.captureException(new Error('Context menu hack did not return valid original method'));
|
||||
SentryCapture(new Error('Context menu hack did not return valid original method'));
|
||||
}
|
||||
|
||||
this.editor.addAction({
|
||||
@@ -1200,7 +1202,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
produceCfg: this.cfgViewOpen,
|
||||
produceGnatDebugTree: this.gnatDebugTreeViewOpen,
|
||||
produceGnatDebug: this.gnatDebugViewOpen,
|
||||
produceIr: this.irViewOpen,
|
||||
produceIr: this.irViewOpen ? this.llvmIrOptions : null,
|
||||
produceLLVMOptPipeline: this.llvmOptPipelineViewOpen ? this.llvmOptPipelineOptions : null,
|
||||
produceDevice: this.deviceViewOpen,
|
||||
produceRustMir: this.rustMirViewOpen,
|
||||
@@ -2044,6 +2046,15 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
}
|
||||
}
|
||||
|
||||
onLLVMIrViewOptionsUpdated(id: number, options: LLVMIrBackendOptions, recompile: boolean): void {
|
||||
if (this.id === id) {
|
||||
this.llvmIrOptions = options;
|
||||
if (recompile) {
|
||||
this.compile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onLLVMOptPipelineViewOpened(id: number): void {
|
||||
if (this.id === id) {
|
||||
this.llvmOptPipelineViewOpen = true;
|
||||
@@ -2057,7 +2068,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
}
|
||||
}
|
||||
|
||||
onLLVMOptPipelineViewOptionsUpdated(id: number, options, recompile: boolean): void {
|
||||
onLLVMOptPipelineViewOptionsUpdated(id: number, options: LLVMOptPipelineBackendOptions, recompile: boolean): void {
|
||||
if (this.id === id) {
|
||||
this.llvmOptPipelineOptions = options;
|
||||
if (recompile) {
|
||||
@@ -2801,6 +2812,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.eventHub.on('astViewClosed', this.onAstViewClosed, this);
|
||||
this.eventHub.on('irViewOpened', this.onIrViewOpened, this);
|
||||
this.eventHub.on('irViewClosed', this.onIrViewClosed, this);
|
||||
this.eventHub.on('llvmIrViewOptionsUpdated', this.onLLVMIrViewOptionsUpdated, this);
|
||||
this.eventHub.on('llvmOptPipelineViewOpened', this.onLLVMOptPipelineViewOpened, this);
|
||||
this.eventHub.on('llvmOptPipelineViewClosed', this.onLLVMOptPipelineViewClosed, this);
|
||||
this.eventHub.on('llvmOptPipelineViewOptionsUpdated', this.onLLVMOptPipelineViewOptionsUpdated, this);
|
||||
@@ -3364,24 +3376,35 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
});
|
||||
}
|
||||
|
||||
private readonly hexLike = /^(#?[$]|0x)([0-9a-fA-F]+)$/;
|
||||
private readonly hexLike2 = /^(#?)([0-9a-fA-F]+)H$/;
|
||||
private readonly decimalLike = /^(#?)(-?[0-9]+)$/;
|
||||
private static readonly hexLike = /^(#?[$]|0x)([0-9a-fA-F]+)$/;
|
||||
private static readonly hexLike2 = /^(#?)([0-9a-fA-F]+)H$/;
|
||||
private static readonly decimalLike = /^(#?)(-?[0-9]+)$/;
|
||||
private static readonly ptxFloat32 = /^0[fF]([0-9a-fA-F]{8})$/;
|
||||
private static readonly ptxFloat64 = /^0[dD]([0-9a-fA-F]{16})$/;
|
||||
|
||||
private parseNumericValue(value: string): bigInt.BigInteger | null {
|
||||
private static parseNumericValue(value: string): bigInt.BigInteger | null {
|
||||
const hexMatch = this.hexLike.exec(value) || this.hexLike2.exec(value);
|
||||
if (hexMatch) return bigInt(hexMatch[2], 16);
|
||||
|
||||
const hexMatchPTX = this.ptxFloat32.exec(value) ?? this.ptxFloat64.exec(value);
|
||||
if (hexMatchPTX) return bigInt(hexMatchPTX[1], 16);
|
||||
|
||||
const decMatch = this.decimalLike.exec(value);
|
||||
if (decMatch) return bigInt(decMatch[2]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private getNumericToolTip(value: string) {
|
||||
public static getNumericToolTip(value: string) {
|
||||
const numericValue = this.parseNumericValue(value);
|
||||
if (numericValue === null) return null;
|
||||
|
||||
const buf = new ArrayBuffer(8);
|
||||
// PTX floats
|
||||
new BigUint64Array(buf)[0] = BigInt(numericValue.toString());
|
||||
if (this.ptxFloat32.test(value)) return new Float32Array(buf)[0].toPrecision(9) + 'f';
|
||||
if (this.ptxFloat64.test(value)) return new Float64Array(buf)[0].toPrecision(17);
|
||||
|
||||
// Decimal representation.
|
||||
let result = numericValue.toString(10);
|
||||
|
||||
@@ -3402,7 +3425,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
return result;
|
||||
}
|
||||
|
||||
private async getAsmInfo(
|
||||
public static async getAsmInfo(
|
||||
opcode: string,
|
||||
instructionSet: AssemblyDocumentationInstructionSet,
|
||||
): Promise<AssemblyInstructionInfo | undefined> {
|
||||
@@ -3496,7 +3519,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
e.target.position.lineNumber,
|
||||
currentWord.endColumn,
|
||||
);
|
||||
const numericToolTip = this.getNumericToolTip(word);
|
||||
const numericToolTip = Compiler.getNumericToolTip(word);
|
||||
if (numericToolTip) {
|
||||
this.decorations.numericToolTip = [
|
||||
{
|
||||
@@ -3522,7 +3545,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.isWordAsmKeyword(e.target.position.lineNumber, currentWord)
|
||||
) {
|
||||
try {
|
||||
const response = await this.getAsmInfo(
|
||||
const response = await Compiler.getAsmInfo(
|
||||
currentWord.word,
|
||||
this.compiler.instructionSet as AssemblyDocumentationInstructionSet,
|
||||
);
|
||||
@@ -3601,7 +3624,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
|
||||
try {
|
||||
if (this.compiler?.supportsAsmDocs) {
|
||||
const asmHelp = await this.getAsmInfo(
|
||||
const asmHelp = await Compiler.getAsmInfo(
|
||||
word.word,
|
||||
this.compiler.instructionSet as AssemblyDocumentationInstructionSet,
|
||||
);
|
||||
|
||||
+149
-20
@@ -38,9 +38,13 @@ import {CompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import {CompilationResult} from '../../types/compilation/compilation.interfaces.js';
|
||||
import {ResultLine} from '../../types/resultline/resultline.interfaces.js';
|
||||
import {assert} from '../assert.js';
|
||||
import {AssemblyDocumentationInstructionSet} from '../../types/features/assembly-documentation.interfaces';
|
||||
import {Alert} from '../widgets/alert';
|
||||
import {Compiler} from './compiler';
|
||||
|
||||
|
||||
export class DeviceAsm extends MonacoPane<monaco.editor.IStandaloneCodeEditor, DeviceAsmState> {
|
||||
private decorations: Record<'linkedCode', monaco.editor.IModelDeltaDecoration[]>;
|
||||
private decorations: Record<string, monaco.editor.IModelDeltaDecoration[]>;
|
||||
private prevDecorations: string[];
|
||||
private selectedDevice: string;
|
||||
private devices: Record<string, CompilationResult> | null;
|
||||
@@ -50,6 +54,7 @@ export class DeviceAsm extends MonacoPane<monaco.editor.IStandaloneCodeEditor, D
|
||||
private lastColourScheme: string;
|
||||
private selectize: TomSelect;
|
||||
private linkedFadeTimeoutId: NodeJS.Timeout | null;
|
||||
private alertSystem: Alert;
|
||||
|
||||
public constructor(hub: Hub, container: GoldenLayout.Container, state: DeviceAsmState & MonacoPaneState) {
|
||||
super(hub, container, state);
|
||||
@@ -77,6 +82,7 @@ export class DeviceAsm extends MonacoPane<monaco.editor.IStandaloneCodeEditor, D
|
||||
} else if (state.devices) {
|
||||
this.onDevices(state.devices);
|
||||
}
|
||||
this.alertSystem = new Alert();
|
||||
}
|
||||
|
||||
override getInitialHTML(): string {
|
||||
@@ -123,6 +129,73 @@ export class DeviceAsm extends MonacoPane<monaco.editor.IStandaloneCodeEditor, D
|
||||
}
|
||||
},
|
||||
});
|
||||
this.editor.addAction({
|
||||
id: 'viewasmdoc',
|
||||
label: 'View assembly documentation',
|
||||
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F8],
|
||||
keybindingContext: undefined,
|
||||
// precondition: 'isAsmKeyword',
|
||||
contextMenuGroupId: 'help',
|
||||
contextMenuOrder: 1.5,
|
||||
run: this.onAsmToolTip.bind(this),
|
||||
});
|
||||
}
|
||||
async onAsmToolTip(ed: monaco.editor.ICodeEditor) {
|
||||
ga.proxy('send', {
|
||||
hitType: 'event',
|
||||
eventCategory: 'OpenModalPane',
|
||||
eventAction: 'AsmDocs',
|
||||
});
|
||||
const pos = ed.getPosition();
|
||||
if (!pos || !ed.getModel()) return;
|
||||
const word = ed.getModel()?.getWordAtPosition(pos);
|
||||
if (!word || !word.word) return;
|
||||
const opcode = word.word.toUpperCase();
|
||||
|
||||
function newGitHubIssueUrl(): string {
|
||||
return (
|
||||
'https://github.com/compiler-explorer/compiler-explorer/issues/new?title=' +
|
||||
encodeURIComponent('[BUG] Problem with ' + opcode + ' opcode')
|
||||
);
|
||||
}
|
||||
|
||||
function appendInfo(url: string): string {
|
||||
return (
|
||||
'<br><br>If the documentation for this opcode is wrong or broken in some way, ' +
|
||||
'please feel free to <a href="' +
|
||||
newGitHubIssueUrl() +
|
||||
'" target="_blank" rel="noopener noreferrer">' +
|
||||
'open an issue on GitHub <sup><small class="fas fa-external-link-alt opens-new-window" ' +
|
||||
'title="Opens in a new window"></small></sup></a>.'
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const asmHelp = await Compiler.getAsmInfo(
|
||||
word.word,
|
||||
this.selectedDevice.split(' ')[0].toLowerCase() as AssemblyDocumentationInstructionSet,
|
||||
);
|
||||
if (asmHelp) {
|
||||
this.alertSystem.alert(opcode + ' help', asmHelp.html + appendInfo(asmHelp.url), {
|
||||
onClose: () => {
|
||||
ed.focus();
|
||||
ed.setPosition(pos);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.alertSystem.notify('This token was not found in the documentation. Sorry!', {
|
||||
group: 'notokenindocs',
|
||||
alertClass: 'notification-error',
|
||||
dismissTime: 5000,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
this.alertSystem.notify('There was an error fetching the documentation for this opcode (' + error + ').', {
|
||||
group: 'notokenindocs',
|
||||
alertClass: 'notification-error',
|
||||
dismissTime: 5000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
override registerButtons(state: DeviceAsmState): void {
|
||||
@@ -317,29 +390,85 @@ export class DeviceAsm extends MonacoPane<monaco.editor.IStandaloneCodeEditor, D
|
||||
}
|
||||
}
|
||||
|
||||
onMouseMove(e: monaco.editor.IEditorMouseEvent): void {
|
||||
if (e.target.position === null) return;
|
||||
if (this.settings.hoverShowSource) {
|
||||
this.clearLinkedLines();
|
||||
const hoverCode = this.deviceCode[e.target.position.lineNumber - 1];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (hoverCode && this.compilerInfo.editorId != null) {
|
||||
// We check that we actually have something to show at this point!
|
||||
const sourceLine = hoverCode.source && !hoverCode.source.file ? hoverCode.source.line : -1;
|
||||
this.eventHub.emit('editorLinkLine', this.compilerInfo.editorId, sourceLine, -1, 0, false);
|
||||
this.eventHub.emit(
|
||||
'panesLinkLine',
|
||||
this.compilerInfo.compilerId,
|
||||
sourceLine,
|
||||
-1,
|
||||
0,
|
||||
false,
|
||||
this.getPaneName(),
|
||||
);
|
||||
async onMouseMove(e: any) {
|
||||
if (e === null || e.target === null || e.target.position === null) return;
|
||||
const currentWord = this.editor.getModel()?.getWordAtPosition(e.target.position);
|
||||
if (currentWord?.word) {
|
||||
let word = currentWord.word;
|
||||
let startColumn = currentWord.startColumn;
|
||||
// Avoid throwing an exception if somehow (How?) we have a non-existent lineNumber.
|
||||
// c.f. https://sentry.io/matt-godbolt/compiler-explorer/issues/285270358/
|
||||
if (e.target.position.lineNumber <= (this.editor.getModel()?.getLineCount() ?? 0)) {
|
||||
// Hacky workaround to check for negative numbers.
|
||||
// c.f. https://github.com/compiler-explorer/compiler-explorer/issues/434
|
||||
const lineContent = this.editor.getModel()?.getLineContent(e.target.position.lineNumber);
|
||||
if (lineContent && lineContent[currentWord.startColumn - 2] === '-') {
|
||||
word = '-' + word;
|
||||
startColumn -= 1;
|
||||
}
|
||||
}
|
||||
const range = new monaco.Range(
|
||||
e.target.position.lineNumber,
|
||||
Math.max(startColumn, 1),
|
||||
e.target.position.lineNumber,
|
||||
currentWord.endColumn,
|
||||
);
|
||||
const numericToolTip = Compiler.getNumericToolTip(word);
|
||||
if (numericToolTip) {
|
||||
this.decorations.numericToolTip = [
|
||||
{
|
||||
range: range,
|
||||
options: {
|
||||
isWholeLine: false,
|
||||
hoverMessage: [
|
||||
{
|
||||
// We use double `` as numericToolTip may include a single ` character.
|
||||
value: '``' + numericToolTip + '``',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
this.updateDecorations();
|
||||
}
|
||||
const hoverShowAsmDoc = this.settings.hoverShowAsmDoc;
|
||||
if (hoverShowAsmDoc) {
|
||||
try {
|
||||
const response = await Compiler.getAsmInfo(
|
||||
currentWord.word,
|
||||
this.selectedDevice.split(' ')[0].toLowerCase() as AssemblyDocumentationInstructionSet,
|
||||
);
|
||||
if (!response) return;
|
||||
this.decorations.asmToolTip = [
|
||||
{
|
||||
range: range,
|
||||
options: {
|
||||
isWholeLine: false,
|
||||
hoverMessage: [
|
||||
{
|
||||
value: response.tooltip + '\n\nMore information available in the context menu.',
|
||||
isTrusted: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
this.updateDecorations();
|
||||
} catch {
|
||||
// ignore errors fetching tooltips
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getLineTokens(line: number): monaco.Token[] {
|
||||
const model = this.editor.getModel();
|
||||
if (!model || line > model.getLineCount()) return [];
|
||||
const flavour = model.getLanguageId();
|
||||
const tokens = monaco.editor.tokenize(model.getLineContent(line), flavour);
|
||||
return tokens.length > 0 ? tokens[0] : [];
|
||||
}
|
||||
|
||||
updateDecorations(): void {
|
||||
this.prevDecorations = this.editor.deltaDecorations(
|
||||
this.prevDecorations,
|
||||
|
||||
+12
-8
@@ -1427,11 +1427,15 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
|
||||
this.busyCompilers[compilerId] = true;
|
||||
}
|
||||
|
||||
addSource(arr: ResultLine[] | undefined, sourcePane: string): ResultLineWithSourcePane[] {
|
||||
addSource(
|
||||
arr: ResultLine[] | undefined,
|
||||
sourcePane: string,
|
||||
result: CompilationResult,
|
||||
): ResultLineWithSourcePane[] {
|
||||
if (arr) {
|
||||
if (typeof arr.map !== 'function') {
|
||||
// temporary triage for https://github.com/compiler-explorer/compiler-explorer/issues/4868
|
||||
Sentry.captureMessage(`arr.map isn't a function. arr: ${JSON.stringify(arr)}`, 'error');
|
||||
Sentry.captureMessage(`arr.map isn't a function. Original result: ${JSON.stringify(result)}`, 'error');
|
||||
}
|
||||
const newArr: ResultLineWithSourcePane[] = arr.map(element => {
|
||||
return {
|
||||
@@ -1452,21 +1456,21 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
|
||||
compilerId: number | string,
|
||||
): (ResultLine & {sourcePane: string})[] {
|
||||
const compilerTitle = compilerName + ' #' + compilerId;
|
||||
let all = this.addSource(result.stdout, compilerTitle);
|
||||
let all = this.addSource(result.stdout, compilerTitle, result);
|
||||
|
||||
if (result.buildsteps) {
|
||||
_.each(result.buildsteps, step => {
|
||||
all = all.concat(this.addSource(step.stdout, compilerTitle));
|
||||
all = all.concat(this.addSource(step.stderr, compilerTitle));
|
||||
all = all.concat(this.addSource(step.stdout, compilerTitle, result));
|
||||
all = all.concat(this.addSource(step.stderr, compilerTitle, result));
|
||||
});
|
||||
}
|
||||
if (result.tools) {
|
||||
_.each(result.tools, tool => {
|
||||
all = all.concat(this.addSource(tool.stdout, tool.name + ' #' + compilerId));
|
||||
all = all.concat(this.addSource(tool.stderr, tool.name + ' #' + compilerId));
|
||||
all = all.concat(this.addSource(tool.stdout, tool.name + ' #' + compilerId, result));
|
||||
all = all.concat(this.addSource(tool.stderr, tool.name + ' #' + compilerId, result));
|
||||
});
|
||||
}
|
||||
all = all.concat(this.addSource(result.stderr, compilerTitle));
|
||||
all = all.concat(this.addSource(result.stderr, compilerTitle, result));
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ import {CompilerPicker} from '../widgets/compiler-picker.js';
|
||||
import {SourceAndFiles} from '../download-service.js';
|
||||
import {ICompilerShared} from '../compiler-shared.interfaces.js';
|
||||
import {CompilerShared} from '../compiler-shared.js';
|
||||
import type {ConfiguredOverrides} from '../compilation/compiler-overrides.interfaces.js';
|
||||
import {LangInfo} from './compiler-request.interfaces.js';
|
||||
|
||||
const languages = options.languages;
|
||||
|
||||
@@ -24,4 +24,11 @@
|
||||
|
||||
export interface IrState {
|
||||
irOutput: any;
|
||||
// options/filters
|
||||
// marked as optional so they don't have to be specified in components.ts, just let them default
|
||||
'demangle-symbols'?: boolean;
|
||||
'-fno-discard-value-names'?: boolean;
|
||||
'filter-debug-info'?: boolean;
|
||||
'filter-instruction-metadata'?: boolean;
|
||||
'filter-attributes'?: boolean;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ import {applyColours} from '../colour.js';
|
||||
|
||||
import {Hub} from '../hub.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {Toggles} from '../widgets/toggles.js';
|
||||
|
||||
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
|
||||
|
||||
export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState> {
|
||||
linkedFadeTimeoutId: NodeJS.Timeout | null = null;
|
||||
@@ -44,12 +47,23 @@ export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState>
|
||||
colours: any[] = [];
|
||||
decorations: any = {};
|
||||
previousDecorations: string[] = [];
|
||||
options: Toggles;
|
||||
filters: Toggles;
|
||||
lastOptions: LLVMIrBackendOptions = {
|
||||
filterDebugInfo: true,
|
||||
filterIRMetadata: true,
|
||||
filterAttributes: true,
|
||||
noDiscardValueNames: true,
|
||||
demangle: true,
|
||||
};
|
||||
|
||||
constructor(hub: Hub, container: Container, state: IrState & MonacoPaneState) {
|
||||
super(hub, container, state);
|
||||
if (state.irOutput) {
|
||||
this.showIrResults(state.irOutput);
|
||||
}
|
||||
|
||||
this.onOptionsChange(true);
|
||||
}
|
||||
|
||||
override getInitialHTML(): string {
|
||||
@@ -80,6 +94,14 @@ export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState>
|
||||
return 'LLVM IR Viewer';
|
||||
}
|
||||
|
||||
override registerButtons(state: IrState) {
|
||||
super.registerButtons(state);
|
||||
this.options = new Toggles(this.domRoot.find('.options'), state as unknown as Record<string, boolean>);
|
||||
this.options.on('change', this.onOptionsChange.bind(this));
|
||||
this.filters = new Toggles(this.domRoot.find('.filters'), state as unknown as Record<string, boolean>);
|
||||
this.filters.on('change', this.onOptionsChange.bind(this));
|
||||
}
|
||||
|
||||
override registerEditorActions(): void {
|
||||
this.editor.addAction({
|
||||
id: 'viewsource',
|
||||
@@ -128,6 +150,28 @@ export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState>
|
||||
this.eventHub.emit('requestSettings');
|
||||
}
|
||||
|
||||
onOptionsChange(force = false) {
|
||||
const options = this.options.get();
|
||||
const filters = this.filters.get();
|
||||
const newOptions: LLVMIrBackendOptions = {
|
||||
filterDebugInfo: filters['filter-debug-info'],
|
||||
filterIRMetadata: filters['filter-instruction-metadata'],
|
||||
filterAttributes: filters['filter-attributes'],
|
||||
noDiscardValueNames: options['-fno-discard-value-names'],
|
||||
demangle: options['demangle-symbols'],
|
||||
};
|
||||
let changed = false;
|
||||
for (const k in newOptions) {
|
||||
if (newOptions[k] !== this.lastOptions[k]) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
this.lastOptions = newOptions;
|
||||
if (changed || force) {
|
||||
this.eventHub.emit('llvmIrViewOptionsUpdated', this.compilerInfo.compilerId, newOptions, true);
|
||||
}
|
||||
}
|
||||
|
||||
override onCompileResult(compilerId: number, compiler: any, result: any): void {
|
||||
if (this.compilerInfo.compilerId !== compilerId) return;
|
||||
if (result.hasIrOutput) {
|
||||
|
||||
@@ -27,4 +27,12 @@ export interface LLVMOptPipelineViewState {
|
||||
selectedIndex: number;
|
||||
// may be 0 when first initialized
|
||||
sidebarWidth: number;
|
||||
// options/filters
|
||||
// marked as optional so they don't have to be specified in components.ts, just let them default
|
||||
'dump-full-module'?: boolean;
|
||||
'demangle-symbols'?: boolean;
|
||||
'-fno-discard-value-names'?: boolean;
|
||||
'filter-inconsequential-passes'?: boolean;
|
||||
'filter-debug-info'?: boolean;
|
||||
'filter-instruction-metadata'?: boolean;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2023, Compiler Explorer Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {parse} from '../lib/stacktrace.js';
|
||||
|
||||
import {options} from './options.js';
|
||||
|
||||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
export function SetupSentry() {
|
||||
if (options.statusTrackingEnabled && options.sentryDsn) {
|
||||
Sentry.init({
|
||||
dsn: options.sentryDsn,
|
||||
release: options.release,
|
||||
environment: options.sentryEnvironment,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function SentryCapture(value: unknown, context?: string) {
|
||||
if (value instanceof Error) {
|
||||
if (context) {
|
||||
value.message += `\nSentryCapture Context: ${context}`;
|
||||
}
|
||||
Sentry.captureException(value);
|
||||
} else {
|
||||
const e = new Error(); // eslint-disable-line unicorn/error-message
|
||||
const trace = parse(e);
|
||||
Sentry.captureMessage(
|
||||
`Non-Error capture:\n` +
|
||||
(context ? `Context: ${context}\n` : '') +
|
||||
`Data:\n${JSON.stringify(value)}\n` +
|
||||
`Trace:\n` +
|
||||
trace
|
||||
.map(frame => `${frame.functionName} ${frame.fileName}:${frame.lineNumber}:${frame.columnNumber}`)
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -23,7 +23,6 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import $ from 'jquery';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import GoldenLayout from 'golden-layout';
|
||||
import _ from 'underscore';
|
||||
import ClipboardJS from 'clipboard';
|
||||
@@ -35,6 +34,7 @@ import {options} from './options.js';
|
||||
import ClickEvent = JQuery.ClickEvent;
|
||||
import TriggeredEvent = JQuery.TriggeredEvent;
|
||||
import {Settings, SiteSettings} from './settings.js';
|
||||
import {SentryCapture} from './sentry.js';
|
||||
|
||||
const cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
@@ -129,7 +129,7 @@ export class Sharing {
|
||||
window.history.replaceState(null, '', link);
|
||||
} catch (e) {
|
||||
// This is probably caused by a link that is too long
|
||||
Sentry.captureException(e);
|
||||
SentryCapture(e, 'url update');
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -184,7 +184,7 @@ export class Sharing {
|
||||
if (error || !newUrl) {
|
||||
permalink.prop('disabled', true);
|
||||
permalink.val(error || 'Error providing URL');
|
||||
Sentry.captureException(error);
|
||||
SentryCapture(error, 'Error providing url');
|
||||
} else {
|
||||
if (updateState) {
|
||||
Sharing.storeCurrentConfig(config, extra);
|
||||
@@ -274,7 +274,7 @@ export class Sharing {
|
||||
Sharing.getLinks(config, type, (error: any, newUrl: string, extra: string, updateState: boolean) => {
|
||||
if (error || !newUrl) {
|
||||
this.displayTooltip(this.share, 'Oops, something went wrong');
|
||||
Sentry.captureException(error);
|
||||
SentryCapture(error, 'Getting short link failed');
|
||||
reject();
|
||||
} else {
|
||||
if (updateState) {
|
||||
@@ -291,7 +291,7 @@ export class Sharing {
|
||||
Sharing.getLinks(config, type, (error: any, newUrl: string, extra: string, updateState: boolean) => {
|
||||
if (error || !newUrl) {
|
||||
this.displayTooltip(this.share, 'Oops, something went wrong');
|
||||
Sentry.captureException(error);
|
||||
SentryCapture(error, 'Getting short link failed');
|
||||
} else {
|
||||
if (updateState) {
|
||||
Sharing.storeCurrentConfig(config, extra);
|
||||
|
||||
@@ -528,17 +528,14 @@ textarea.form-control {
|
||||
.rainbow-decoration {
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
right bottom,
|
||||
color-stop(0, red),
|
||||
color-stop(16%, orange),
|
||||
color-stop(32%, yellow),
|
||||
color-stop(48%, green),
|
||||
color-stop(60%, blue),
|
||||
color-stop(76%, indigo),
|
||||
color-stop(1, violet)
|
||||
background-image: linear-gradient(
|
||||
60deg,
|
||||
#ED4242 0,
|
||||
#FFAA44 20%,
|
||||
#FFF344 40%,
|
||||
#43A35B 60%,
|
||||
#447CFF 80%,
|
||||
#9C44A9 100%
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,17 +118,14 @@ a.navbar-brand img.logo.normal {
|
||||
.rainbow-decoration {
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
right bottom,
|
||||
color-stop(0, red),
|
||||
color-stop(16%, orange),
|
||||
color-stop(32%, yellow),
|
||||
color-stop(48%, green),
|
||||
color-stop(60%, blue),
|
||||
color-stop(76%, indigo),
|
||||
color-stop(1, violet)
|
||||
background-image: linear-gradient(
|
||||
60deg,
|
||||
#ED4242 0,
|
||||
#FFAA44 20%,
|
||||
#FFF344 40%,
|
||||
#43A35B 60%,
|
||||
#447CFF 80%,
|
||||
#9C44A9 100%
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -549,17 +549,14 @@ textarea.form-control {
|
||||
.rainbow-decoration {
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
right bottom,
|
||||
color-stop(0, red),
|
||||
color-stop(16%, orange),
|
||||
color-stop(32%, yellow),
|
||||
color-stop(48%, green),
|
||||
color-stop(60%, blue),
|
||||
color-stop(76%, indigo),
|
||||
color-stop(1, violet)
|
||||
background-image: linear-gradient(
|
||||
60deg,
|
||||
#ED4242 0,
|
||||
#FFAA44 20%,
|
||||
#FFF344 40%,
|
||||
#43A35B 60%,
|
||||
#447CFF 80%,
|
||||
#9C44A9 100%
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import $ from 'jquery';
|
||||
import {editor} from 'monaco-editor';
|
||||
import {SiteSettings} from './settings.js';
|
||||
import GoldenLayout from 'golden-layout';
|
||||
import {assert} from './assert.js';
|
||||
import {isString} from '../lib/common-utils.js';
|
||||
|
||||
export type Themes = 'default' | 'dark' | 'darkplus' | 'pink' | 'system';
|
||||
|
||||
@@ -160,47 +160,17 @@ export class CompilerPickerPopup {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
// figure out if there are any empty groups, these will be ignored
|
||||
const groupCounts: Partial<Record<string, number>> = {};
|
||||
for (const compiler of filteredCompilers) {
|
||||
for (const group of compiler.$groups) {
|
||||
groupCounts[group] = (groupCounts[group] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
// add the compiler entries / group headers themselves
|
||||
this.resultsContainer.empty();
|
||||
this.favoritesContainer.empty();
|
||||
const groupMap: Record<string, JQuery> = {};
|
||||
for (const group of this.groups) {
|
||||
if ((groupCounts[group.value] ?? 0) > 0 || group.value === CompilerPicker.favoriteGroupName) {
|
||||
const group_elem = $(
|
||||
`
|
||||
<div class="group-wrapper">
|
||||
<div class="group">
|
||||
<div class="label">${_.escape(group.label)}</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
);
|
||||
if (group.value === CompilerPicker.favoriteGroupName) {
|
||||
group_elem.appendTo(this.favoritesContainer);
|
||||
} else {
|
||||
group_elem.appendTo(this.resultsContainer);
|
||||
}
|
||||
groupMap[group.value] = group_elem.find('.group');
|
||||
}
|
||||
}
|
||||
// if there can only ever be one column, don't bother with room for 2
|
||||
this.resultsContainer.toggleClass(
|
||||
'one-col',
|
||||
this.groups.filter(group => group.value !== CompilerPicker.favoriteGroupName).length <= 1,
|
||||
);
|
||||
const searchRegexes = this.searchResults
|
||||
? remove(
|
||||
this.searchResults.tokens.map(token => token.regex),
|
||||
null,
|
||||
)
|
||||
: undefined;
|
||||
// place compilers into groups
|
||||
const groupMap: Record<string, {elem: JQuery; order: number}[]> = {};
|
||||
for (const group of this.groups) {
|
||||
groupMap[group.value] = [];
|
||||
}
|
||||
for (const compiler of filteredCompilers) {
|
||||
const isFavorited = compiler.$groups.includes(CompilerPicker.favoriteGroupName);
|
||||
const extraClasses = isFavorited ? 'fas fa-star fav' : 'far fa-star';
|
||||
@@ -223,9 +193,46 @@ export class CompilerPickerPopup {
|
||||
if (compiler.id === this.compilerPicker.lastCompilerId) {
|
||||
compiler_elem.addClass('selected');
|
||||
}
|
||||
compiler_elem.appendTo(groupMap[group]);
|
||||
groupMap[group].push({
|
||||
elem: compiler_elem,
|
||||
order: compiler.$order,
|
||||
});
|
||||
}
|
||||
}
|
||||
// sort compilers before placing them into groups
|
||||
for (const [_, compilers] of Object.entries(groupMap)) {
|
||||
compilers.sort((a, b) => a.order - b.order);
|
||||
}
|
||||
// add groups and compilers
|
||||
this.resultsContainer.empty();
|
||||
this.favoritesContainer.empty();
|
||||
for (const group of this.groups) {
|
||||
if (groupMap[group.value].length > 0 || group.value === CompilerPicker.favoriteGroupName) {
|
||||
const groupWrapper = $(
|
||||
`
|
||||
<div class="group-wrapper">
|
||||
<div class="group">
|
||||
<div class="label">${_.escape(group.label)}</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
);
|
||||
if (group.value === CompilerPicker.favoriteGroupName) {
|
||||
groupWrapper.appendTo(this.favoritesContainer);
|
||||
} else {
|
||||
groupWrapper.appendTo(this.resultsContainer);
|
||||
}
|
||||
const groupElem = groupWrapper.find('.group');
|
||||
for (const compiler of groupMap[group.value]) {
|
||||
compiler.elem.appendTo(groupElem);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if there can only ever be one column, don't bother with room for 2
|
||||
this.resultsContainer.toggleClass(
|
||||
'one-col',
|
||||
this.groups.filter(group => group.value !== CompilerPicker.favoriteGroupName).length <= 1,
|
||||
);
|
||||
// group header click events
|
||||
this.compilersContainer.find('.group').append('<div class="folded">⋯</div>');
|
||||
this.compilersContainer.find('.group > .label').on('click', e => {
|
||||
|
||||
@@ -31,7 +31,6 @@ import {EventHub} from '../event-hub.js';
|
||||
import {Hub} from '../hub.js';
|
||||
import {CompilerService} from '../compiler-service.js';
|
||||
import {CompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import {unique} from '../../lib/common-utils.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {CompilerPickerPopup} from './compiler-picker-popup.js';
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import {BaseCompiler} from '../lib/base-compiler.js';
|
||||
import {BuildEnvSetupBase} from '../lib/buildenvsetup/index.js';
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {Win32Compiler} from '../lib/compilers/win32.js';
|
||||
import * as exec from '../lib/exec.js';
|
||||
import {CompilerOverrideType, ConfiguredOverrides} from '../types/compilation/compiler-overrides.interfaces.js';
|
||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import {Readable} from 'stream';
|
||||
|
||||
import {GetObjectCommand, NoSuchKey, PutObjectCommand, S3} from '@aws-sdk/client-s3';
|
||||
import {sdkStreamMixin} from '@aws-sdk/util-stream-node';
|
||||
import {AwsClientStub, AwsError, AwsStub, mockClient} from 'aws-sdk-client-mock';
|
||||
import {AwsClientStub, mockClient} from 'aws-sdk-client-mock';
|
||||
import temp from 'temp';
|
||||
|
||||
import {BaseCache} from '../lib/cache/base.js';
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('Hook compiler', () => {
|
||||
hook.addHookHome({moo: 'moo'}).should.deep.equal({moo: 'moo', HOOK_HOME: '/opt/hook'});
|
||||
});
|
||||
|
||||
it('should process and return correct bytecode result', () => {
|
||||
it('should process and return correct bytecode result', async () => {
|
||||
const asm =
|
||||
'; main in /app/example.hk at 0x56554a556550\n' +
|
||||
'; 0 parameter(s), 0 non-local(s), 0 constant(s), 0 function(s)\n' +
|
||||
@@ -142,7 +142,7 @@ describe('Hook compiler', () => {
|
||||
labelDefinitions: {},
|
||||
};
|
||||
const filters = {trim: false};
|
||||
const result = hook.processAsm({asm: asm}, filters, null);
|
||||
const result = await hook.processAsm({asm: asm}, filters, null);
|
||||
delete result.parsingTime;
|
||||
result.should.deep.equal(expected);
|
||||
});
|
||||
|
||||
@@ -55,6 +55,14 @@ export const TEST_MATRIX: Record<PropertyKey, [string, string, string, string][]
|
||||
'https://developer.arm.com/documentation/',
|
||||
],
|
||||
],
|
||||
aarch64: [
|
||||
[
|
||||
'mov',
|
||||
'Read active elements from the source predicate',
|
||||
'<p>Read active elements from the source predicate',
|
||||
'https://developer.arm.com/documentation/',
|
||||
],
|
||||
],
|
||||
avr: [
|
||||
[
|
||||
'mov',
|
||||
@@ -79,6 +87,15 @@ export const TEST_MATRIX: Record<PropertyKey, [string, string, string, string][]
|
||||
'https://llvm.org/docs/LangRef.html#ret-instruction',
|
||||
],
|
||||
],
|
||||
ptx: [
|
||||
[
|
||||
'add',
|
||||
'Add two values.',
|
||||
'<p>Performs addition and writes the resulting value into a destination register.</p>',
|
||||
'',
|
||||
],
|
||||
],
|
||||
sass: [['FADD', 'FP32 Add', 'FP32 Add', 'https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#id14']],
|
||||
};
|
||||
|
||||
describe('Assembly Documentation API', () => {
|
||||
|
||||
+4
-4
@@ -113,7 +113,7 @@ describe('javap parsing', () => {
|
||||
compiler = new JavaCompiler(info, env);
|
||||
});
|
||||
|
||||
function testJava(baseFolder: string, ...classNames: string[]) {
|
||||
async function testJava(baseFolder: string, ...classNames: string[]) {
|
||||
const compiler = new JavaCompiler(info, env);
|
||||
|
||||
const asm = classNames.map(className => {
|
||||
@@ -142,18 +142,18 @@ describe('javap parsing', () => {
|
||||
asm,
|
||||
};
|
||||
|
||||
const processed = compiler.processAsm(result);
|
||||
const processed = await compiler.processAsm(result);
|
||||
processed.should.have.property('asm');
|
||||
const asmSegments = (processed as {asm: ParsedAsmResultLine[]}).asm;
|
||||
asmSegments.should.deep.equal(expectedSegments);
|
||||
}
|
||||
|
||||
it('should handle errors', () => {
|
||||
it('should handle errors', async () => {
|
||||
const result = {
|
||||
asm: '<Compilation failed>',
|
||||
};
|
||||
|
||||
compiler.processAsm(result).should.deep.equal([{text: '<Compilation failed>', source: null}]);
|
||||
(await compiler.processAsm(result)).should.deep.equal([{text: '<Compilation failed>', source: null}]);
|
||||
});
|
||||
|
||||
it('Parses simple class with one method', () => {
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
import cloneDeep from 'lodash.clonedeep';
|
||||
|
||||
import {LlvmAstParser} from '../lib/llvm-ast.js';
|
||||
import {PropertyValue} from '../lib/properties.interfaces.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
import * as utils from '../lib/utils.js';
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {LLVMIRDemangler} from '../lib/demangler/llvm.js';
|
||||
import {LlvmIrParser} from '../lib/llvm-ir.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
|
||||
@@ -41,7 +42,7 @@ describe('llvm-ir parseMetaNode', function () {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
compilerProps = (fakeProps.get as any).bind(fakeProps, 'c++');
|
||||
|
||||
llvmIrParser = new LlvmIrParser(compilerProps);
|
||||
llvmIrParser = new LlvmIrParser(compilerProps, undefined as unknown as LLVMIRDemangler);
|
||||
});
|
||||
|
||||
it('should parse DILocation node', function () {
|
||||
@@ -108,7 +109,7 @@ describe('llvm-ir getSourceLineNumber', function () {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
compilerProps = (fakeProps.get as any).bind(fakeProps, 'c++');
|
||||
|
||||
llvmIrParser = new LlvmIrParser(compilerProps);
|
||||
llvmIrParser = new LlvmIrParser(compilerProps, undefined as unknown as LLVMIRDemangler);
|
||||
});
|
||||
|
||||
const debugInfo = {
|
||||
@@ -149,7 +150,7 @@ describe('llvm-ir getSourceColumn', function () {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
compilerProps = (fakeProps.get as any).bind(fakeProps, 'c++');
|
||||
|
||||
llvmIrParser = new LlvmIrParser(compilerProps);
|
||||
llvmIrParser = new LlvmIrParser(compilerProps, undefined as unknown as LLVMIRDemangler);
|
||||
});
|
||||
|
||||
const debugInfo = {
|
||||
@@ -191,7 +192,7 @@ describe('llvm-ir getFileName', function () {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
compilerProps = (fakeProps.get as any).bind(fakeProps, 'c++');
|
||||
|
||||
llvmIrParser = new LlvmIrParser(compilerProps);
|
||||
llvmIrParser = new LlvmIrParser(compilerProps, undefined as unknown as LLVMIRDemangler);
|
||||
});
|
||||
const debugInfo = {
|
||||
'!10': {filename: '/test.cpp'},
|
||||
@@ -230,7 +231,7 @@ describe('llvm-ir isLineLlvmDirective', function () {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
compilerProps = (fakeProps.get as any).bind(fakeProps, 'c++');
|
||||
|
||||
llvmIrParser = new LlvmIrParser(compilerProps);
|
||||
llvmIrParser = new LlvmIrParser(compilerProps, undefined as unknown as LLVMIRDemangler);
|
||||
});
|
||||
|
||||
const directives = [
|
||||
|
||||
@@ -29,7 +29,6 @@ import _ from 'underscore';
|
||||
import {BaseCompiler} from '../lib/base-compiler.js';
|
||||
import {ClientOptionsHandler} from '../lib/options-handler.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
import {parseOutput} from '../lib/utils.js';
|
||||
|
||||
import {should} from './utils.js';
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {BaseCompiler} from '../lib/base-compiler.js';
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import {fileURLToPath} from 'url';
|
||||
|
||||
import winston from 'winston';
|
||||
|
||||
import {logger, makeLogStream} from '../lib/logger.js';
|
||||
import {makeLogStream} from '../lib/logger.js';
|
||||
import * as utils from '../lib/utils.js';
|
||||
|
||||
import {fs} from './utils.js';
|
||||
|
||||
@@ -33,6 +33,7 @@ import {ResultLine} from '../resultline/resultline.interfaces.js';
|
||||
import {Artifact, ToolResult} from '../tool.interfaces.js';
|
||||
|
||||
import {ConfiguredOverrides} from './compiler-overrides.interfaces.js';
|
||||
import { LLVMIrBackendOptions } from './ir.interfaces.js';
|
||||
import {LLVMOptPipelineBackendOptions, LLVMOptPipelineOutput} from './llvm-opt-pipeline-output.interfaces.js';
|
||||
|
||||
export type ActiveTools = {
|
||||
@@ -70,7 +71,7 @@ export type CompilationRequestOptions = {
|
||||
produceCfg?: boolean;
|
||||
produceGnatDebugTree?: boolean;
|
||||
produceGnatDebug?: boolean;
|
||||
produceIr?: boolean;
|
||||
produceIr?: LLVMIrBackendOptions | null;
|
||||
produceLLVMOptPipeline?: LLVMOptPipelineBackendOptions | null;
|
||||
produceDevice?: boolean;
|
||||
produceRustMir?: boolean;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2023, Compiler Explorer Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
export type LLVMIrBackendOptions = {
|
||||
filterDebugInfo: boolean;
|
||||
filterIRMetadata: boolean;
|
||||
filterAttributes: boolean;
|
||||
noDiscardValueNames?: boolean;
|
||||
demangle: boolean;
|
||||
};
|
||||
@@ -132,6 +132,7 @@ export type CompilerInfo = {
|
||||
cachedPossibleArguments?: any;
|
||||
nvdisasm?: string;
|
||||
mtime?: any;
|
||||
$order: number;
|
||||
};
|
||||
|
||||
// Compiler information collected by the compiler-finder
|
||||
|
||||
@@ -33,7 +33,9 @@ export type AssemblyDocumentationInstructionSet =
|
||||
| 'java'
|
||||
| 'llvm'
|
||||
| 'mos6502'
|
||||
| 'python';
|
||||
| 'ptx'
|
||||
| 'python'
|
||||
| 'sass';
|
||||
|
||||
export interface AssemblyDocumentationRequest {
|
||||
/** Specifies which instruction set to look for */
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
mixin optionButton(bind, isActive, text, title)
|
||||
.button-checkbox
|
||||
button(type="button" class="dropdown-item btn btn-sm btn-light" + (isActive ? " active" : "") title=title data-bind=bind aria-pressed=isActive ? "true" : "false")
|
||||
span #{text}
|
||||
input.d-none(type="checkbox" checked=isActive)
|
||||
|
||||
#ir
|
||||
.top-bar.btn-toolbar.bg-light(role="toolbar")
|
||||
include ../../font-size
|
||||
.btn-group.btn-group-sm.options(role="group")
|
||||
button.btn.btn-sm.btn-light.dropdown-toggle(type="button" title="LLVM Opt Pass Options" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Set output options")
|
||||
span.fas.fa-anchor
|
||||
span.hideable Options
|
||||
.dropdown-menu
|
||||
+optionButton("demangle-symbols", true, "Demangle Symbols", "Demangle symbols")
|
||||
+optionButton("-fno-discard-value-names", true, "-fno-discard-value-names", "Keep value names instead of LLVM value numbers")
|
||||
.btn-group.btn-group-sm.filters(role="group")
|
||||
button.btn.btn-sm.btn-light.dropdown-toggle(type="button" title="LLVM Opt Pass Filters" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Set output filters")
|
||||
span.fas.fa-filter
|
||||
span.hideable Filters
|
||||
.dropdown-menu
|
||||
+optionButton("filter-debug-info", true, "Hide Debug Info", "Filter debug info intrinsics")
|
||||
+optionButton("filter-instruction-metadata", true, "Hide Instruction Metadata", "Filter all IR metadata")
|
||||
+optionButton("filter-attributes", true, "Filter Attribute Groups", "Filter attribute groups")
|
||||
//- +optionButton("library-functions", true, "Filter Library Functions", "Filter library functions")
|
||||
div.llvm-opt-pipeline-body
|
||||
.monaco-placeholder
|
||||
@@ -20,6 +20,8 @@ mixin monacopane(id)
|
||||
|
||||
include panes/pp
|
||||
|
||||
include panes/ir
|
||||
|
||||
include panes/llvm-opt-pipeline
|
||||
|
||||
include panes/device
|
||||
@@ -58,8 +60,6 @@ mixin monacopane(id)
|
||||
|
||||
+monacopane("ast")
|
||||
|
||||
+monacopane("ir")
|
||||
|
||||
+monacopane("tool-input")
|
||||
|
||||
+monacopane("gnatdebugtree")
|
||||
|
||||
Reference in New Issue
Block a user