Skip to content

Commit

Permalink
Merge branch 'main' into lib_wasm_eh
Browse files Browse the repository at this point in the history
  • Loading branch information
aheejin committed Jan 28, 2025
2 parents 842ee68 + a8385bf commit bfeb718
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 40 deletions.
4 changes: 2 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,8 @@ def compile_source_file(i, input_file):
if get_file_suffix(input_file) in ['.pcm']:
cmd = [c for c in cmd if not c.startswith('-fprebuilt-module-path=')]
cmd += compile_args + ['-c', input_file, '-o', output_file]
if state.mode == Mode.COMPILE_AND_LINK and options.requested_debug == '-gsplit-dwarf':
# When running in COMPILE_AND_LINK mode we compile to temporary location
if options.requested_debug == '-gsplit-dwarf':
# When running in COMPILE_AND_LINK mode we compile objects to a temporary location
# but we want the `.dwo` file to be generated in the current working directory,
# like it is under clang. We could avoid this hack if we use the clang driver
# to generate the temporary files, but that would also involve using the clang
Expand Down
5 changes: 1 addition & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ export default [{
files: ['**/*.mjs'],

rules: {
'no-undef': 'error',
'no-unused-vars': ['error', {
vars: 'all',
args: 'none',
ignoreRestSiblings: false,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
}],
},
Expand Down
8 changes: 4 additions & 4 deletions src/jsifier.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function mangleCSymbolName(f) {
if (f === '__main_argc_argv') {
f = 'main';
}
return f[0] == '$' ? f.substr(1) : '_' + f;
return f[0] == '$' ? f.slice(1) : '_' + f;
}

// Splits out items that pass filter. Returns also the original sans the filtered
Expand Down Expand Up @@ -112,7 +112,7 @@ function resolveAlias(symbol) {
return symbol;
}

function getTransitiveDeps(symbol, debug) {
function getTransitiveDeps(symbol) {
// TODO(sbc): Use some kind of cache to avoid quadratic behaviour here.
const transitiveDeps = new Set();
const seen = new Set();
Expand Down Expand Up @@ -284,7 +284,7 @@ ${argConversions}

// apply LIBRARY_DEBUG if relevant
if (LIBRARY_DEBUG && !isJsOnlySymbol(symbol)) {
snippet = modifyJSFunction(snippet, (args, body, async, oneliner) => {
snippet = modifyJSFunction(snippet, (args, body, _async, oneliner) => {
var run_func;
if (oneliner) {
run_func = `var ret = ${body}`;
Expand Down Expand Up @@ -637,7 +637,7 @@ function(${args}) {
// emits
// 'var foo = [value];'
if (typeof snippet == 'string' && snippet[0] == '=') {
snippet = snippet.substr(1);
snippet = snippet.slice(1);
}
contentText = `var ${mangled} = ${snippet};`;
}
Expand Down
8 changes: 4 additions & 4 deletions src/modules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ if (!BOOTSTRAPPING_STRUCT_INFO) {
// Use proxy objects for C_DEFINES and C_STRUCTS so that we can give useful
// error messages.
const C_STRUCTS = new Proxy(structs, {
get(target, prop, receiver) {
get(target, prop) {
if (!(prop in target)) {
throw new Error(
`Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`,
Expand All @@ -345,7 +345,7 @@ const C_STRUCTS = new Proxy(structs, {
});

const C_DEFINES = new Proxy(defines, {
get(target, prop, receiver) {
get(target, prop) {
if (!(prop in target)) {
throw new Error(
`Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`,
Expand Down Expand Up @@ -374,7 +374,7 @@ function getUnusedLibrarySymbols() {
for (const [ident, value] of Object.entries(LibraryManager.library)) {
if (typeof value === 'function' || typeof value === 'number') {
if (isJsOnlySymbol(ident) && !isDecorator(ident) && !isInternalSymbol(ident)) {
const name = ident.substr(1);
const name = ident.slice(1);
if (!librarySymbolSet.has(name)) {
missingSyms.add(name);
}
Expand Down Expand Up @@ -492,7 +492,7 @@ function exportRuntime() {
let runtimeElementsSet = new Set(runtimeElements);
for (const ident of Object.keys(LibraryManager.library)) {
if (isJsOnlySymbol(ident) && !isDecorator(ident) && !isInternalSymbol(ident)) {
const jsname = ident.substr(1);
const jsname = ident.slice(1);
// Note that this assertion may be hit when a function is moved into the
// JS library. In that case the function should be removed from the list
// of runtime elements above.
Expand Down
22 changes: 11 additions & 11 deletions src/parseTools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export function preprocess(filename) {
showStack.push(truthy ? SHOW : IGNORE);
} else if (first === '#include') {
if (showCurrentLine()) {
let includeFile = line.substr(line.indexOf(' ') + 1);
let includeFile = line.slice(line.indexOf(' ') + 1);
if (includeFile.startsWith('"')) {
includeFile = includeFile.substr(1, includeFile.length - 2);
includeFile = includeFile.slice(1, -1);
}
const absPath = findIncludeFile(includeFile, path.dirname(filename));
if (!absPath) {
Expand Down Expand Up @@ -214,7 +214,7 @@ no matching #endif found (${showStack.length$}' unmatched preprocessing directiv
}

// Returns true if ident is a niceIdent (see toNiceIdent). Also allow () and spaces.
function isNiceIdent(ident, loose) {
function isNiceIdent(ident) {
return /^\(?[$_]+[\w$_\d ]*\)?$/.test(ident);
}

Expand Down Expand Up @@ -328,7 +328,7 @@ function getNativeTypeSize(type) {
return POINTER_SIZE;
}
if (type[0] === 'i') {
const bits = Number(type.substr(1));
const bits = Number(type.slice(1));
assert(bits % 8 === 0, `getNativeTypeSize invalid bits ${bits}, ${type} type`);
return bits / 8;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ function ensureDot(value) {
if (value.includes('.') || /[IN]/.test(value)) return value;
const e = value.indexOf('e');
if (e < 0) return value + '.0';
return value.substr(0, e) + '.0' + value.substr(e);
return value.slice(0, e) + '.0' + value.slice(e);
}

export function isNumber(x) {
Expand Down Expand Up @@ -406,7 +406,7 @@ function asmFloatToInt(x) {
}

// See makeSetValue
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, _ignore, align) {
assert(typeof align === 'undefined', 'makeGetValue no longer supports align parameter');
assert(
typeof noNeedFirst === 'undefined',
Expand Down Expand Up @@ -551,7 +551,7 @@ function getFastValue(a, op, b) {

if (b[0] === '-') {
op = '-';
b = b.substr(1);
b = b.slice(1);
}

return `(${a})${op}(${b})`;
Expand Down Expand Up @@ -785,14 +785,14 @@ export function modifyJSFunction(text, func) {
if (match) {
async_ = match[1] || '';
args = match[3];
rest = text.substr(match[0].length);
rest = text.slice(match[0].length);
} else {
// Match an arrow function
let match = text.match(/^\s*(var (\w+) = )?(async\s+)?\(([^)]*)\)\s+=>\s+/);
if (match) {
async_ = match[3] || '';
args = match[4];
rest = text.substr(match[0].length);
rest = text.slice(match[0].length);
rest = rest.trim();
oneliner = rest[0] != '{';
} else {
Expand All @@ -802,7 +802,7 @@ export function modifyJSFunction(text, func) {
assert(match, `could not match function:\n${text}\n`);
async_ = match[1] || '';
args = match[2];
rest = text.substr(match[0].length);
rest = text.slice(match[0].length);
}
}
let body = rest;
Expand Down Expand Up @@ -970,7 +970,7 @@ function from64(x) {

// Like from64 above but generate an expression instead of an assignment
// statement.
function from64Expr(x, assign = true) {
function from64Expr(x) {
if (!MEMORY64) return x;
return `Number(${x})`;
}
Expand Down
1 change: 1 addition & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ def parameterize(func, parameters):
test functions.
"""
prev = getattr(func, '_parameterize', None)
assert not any(p.startswith('_') for p in parameters)
if prev:
# If we're parameterizing 2nd time, construct a cartesian product for various combinations.
func._parameterize = {
Expand Down
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7016,7 +7016,7 @@ def test(args=None, asserts=False):

@parameterized({
'': ([],),
'_files': (['-DUSE_FILES'],)
'files': (['-DUSE_FILES'],)
})
def test_FS_exports(self, extra_args):
# these used to be exported, but no longer are by default
Expand Down
8 changes: 4 additions & 4 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def test_cmake_explicit_generator(self):
@requires_ninja
@parameterized({
'': [[]],
'_no_gnu': [['-DNO_GNU_EXTENSIONS=1']],
'no_gnu': [['-DNO_GNU_EXTENSIONS=1']],
})
def test_cmake_with_embind_cpp11_mode(self, args):
# Use ninja generator here since we assume its always installed on our build/test machines.
Expand All @@ -1022,7 +1022,7 @@ def test_cmake_bitcode_static_libraries(self):

@parameterized({
'': ['0'],
'_suffix': ['1'],
'suffix': ['1'],
})
def test_cmake_static_lib(self, custom):
# Test that one is able to use custom suffixes for static libraries.
Expand Down Expand Up @@ -14970,8 +14970,8 @@ def test_standalone_whole_archive(self):

@parameterized({
'': ([],),
'_single_file': (['-sSINGLE_FILE'],),
'_single_file_es6': (['-sSINGLE_FILE', '-sEXPORT_ES6', '--extern-post-js', test_file('modularize_post_js.js')],),
'single_file': (['-sSINGLE_FILE'],),
'single_file_es6': (['-sSINGLE_FILE', '-sEXPORT_ES6', '--extern-post-js', test_file('modularize_post_js.js')],),
})
def test_proxy_to_worker(self, args):
self.do_runf('hello_world.c', emcc_args=['--proxy-to-worker'] + args)
Expand Down
20 changes: 10 additions & 10 deletions tools/acorn-optimizer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function JSDCE(ast, aggressive) {
}
function cleanUp(ast, names) {
recursiveWalk(ast, {
VariableDeclaration(node, c) {
VariableDeclaration(node, _c) {
const old = node.declarations;
let removedHere = 0;
node.declarations = node.declarations.filter((node) => {
Expand All @@ -315,15 +315,15 @@ function JSDCE(ast, aggressive) {
node.oldDeclarations = old;
}
},
ExpressionStatement(node, c) {
ExpressionStatement(node, _c) {
if (aggressive && !hasSideEffects(node)) {
if (!isNull(node.expression) && !isUseStrict(node.expression)) {
convertToNullStatement(node);
removed++;
}
}
},
FunctionDeclaration(node, c) {
FunctionDeclaration(node, _c) {
if (Object.prototype.hasOwnProperty.call(names, node.id.name)) {
removed++;
emptyOut(node);
Expand Down Expand Up @@ -436,7 +436,7 @@ function JSDCE(ast, aggressive) {
ArrowFunctionExpression(node, c) {
handleFunction(node, c);
},
Identifier(node, c) {
Identifier(node, _c) {
const name = node.name;
ensureData(scopes[scopes.length - 1], name).use = 1;
},
Expand Down Expand Up @@ -1678,7 +1678,7 @@ function minifyLocals(ast) {
localNames.add(param.name);
}
simpleWalk(fun, {
VariableDeclaration(node, c) {
VariableDeclaration(node, _c) {
for (const dec of node.declarations) {
localNames.add(dec.id.name);
}
Expand All @@ -1704,7 +1704,7 @@ function minifyLocals(ast) {
// Don't actually minify them yet as that might interfere with local
// variable names; just mark them as used, and what their new name will be.
simpleWalk(fun, {
Identifier(node, c) {
Identifier(node, _c) {
const name = node.name;
if (!isLocalName(name)) {
const minified = extraInfo.globals[name];
Expand All @@ -1714,7 +1714,7 @@ function minifyLocals(ast) {
}
}
},
CallExpression(node, c) {
CallExpression(node, _c) {
// We should never call a local name, as in asm.js-style code our
// locals are just numbers, not functions; functions are all declared
// in the outer scope. If a local is called, that is a bug.
Expand Down Expand Up @@ -1775,12 +1775,12 @@ function minifyLocals(ast) {
node.label.name = labelNames.get(node.label.name);
c(node.body);
},
BreakStatement(node, c) {
BreakStatement(node, _c) {
if (node.label) {
node.label.name = labelNames.get(node.label.name);
}
},
ContinueStatement(node, c) {
ContinueStatement(node, _c) {
if (node.label) {
node.label.name = labelNames.get(node.label.name);
}
Expand Down Expand Up @@ -2023,7 +2023,7 @@ const input = read(infile);
const extraInfoStart = input.lastIndexOf('// EXTRA_INFO:');
let extraInfo = null;
if (extraInfoStart > 0) {
extraInfo = JSON.parse(input.substr(extraInfoStart + 14));
extraInfo = JSON.parse(input.slice(extraInfoStart + 14));
}
// Collect all JS code comments to this map so that we can retain them in the
// outputted code if --closureFriendly was requested.
Expand Down

0 comments on commit bfeb718

Please sign in to comment.