Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of demangleAll helper function #21156

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion site/source/docs/api_reference/preamble.js.rst
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ The :ref:`emscripten-memory-model` uses a typed array buffer (``ArrayBuffer``) t
Module['HEAP'] = HEAP;
Module['IHEAP'] = IHEAP;
function demangle(func)
function demangleAll(text)
function parseJSFunc(jsfunc)
function callRuntimeCallbacks(callbacks)
function preRun()
Expand Down
3 changes: 1 addition & 2 deletions site/source/docs/tools_reference/settings_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,7 @@ Print out exceptions in emscriptened code.
DEMANGLE_SUPPORT
================

If 1, build in libcxxabi's full c++ demangling code, to allow stackTrace()
to emit fully proper demangled c++ names
If 1, export `demangle` and `stackTrace` helper function.

.. _library_debug:

Expand Down
4 changes: 0 additions & 4 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ addToLibrary({
#endif
#if ASSERTIONS
'$ERRNO_MESSAGES', '$ERRNO_CODES',
#endif
#if ASSERTIONS && !MINIMAL_RUNTIME
'$demangleAll',
#endif
],
$FS__postset: function() {
Expand Down Expand Up @@ -1441,7 +1438,6 @@ FS.staticInit();` +
if (this.stack) {
// Define the stack property for Node.js 4, which otherwise errors on the next line.
Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true });
this.stack = demangleAll(this.stack);
}
#endif // ASSERTIONS
};
Expand Down
15 changes: 2 additions & 13 deletions src/library_stack_trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ var LibraryStackTrace = {
#endif // DEMANGLE_SUPPORT
},

$demangleAll__deps: ['$demangle'],
$demangleAll: (text) => {
var regex =
/\b_Z[\w\d_]+/g;
return text.replace(regex,
function(x) {
var y = demangle(x);
return x === y ? x : (y + ' [' + x + ']');
});
},

$jsStackTrace: function() {
var error = new Error();
if (!error.stack) {
Expand All @@ -70,11 +59,11 @@ var LibraryStackTrace = {
return error.stack.toString();
},

$stackTrace__deps: ['$jsStackTrace', '$demangleAll'],
$stackTrace__deps: ['$jsStackTrace'],
$stackTrace: function() {
var js = jsStackTrace();
if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
return demangleAll(js);
return js;
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/memoryprofiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ var emscriptenMemoryProfiler = {
},

printHeapResizeLog(heapResizes) {
var demangler = typeof demangleAll != 'undefined' ? demangleAll : (x) => x;
var html = '';
for (var i = 0; i < heapResizes.length; ++i) {
var j = i+1;
Expand All @@ -448,7 +447,7 @@ var emscriptenMemoryProfiler = {
var resizeFirst = heapResizes[i];
var resizeLast = heapResizes[j-1];
var count = j - i;
html += '<div style="background-color: ' + resizeFirst.color + '"><b>' + resizeFirst.begin + '-' + resizeLast.end + ' (' + count + ' times, ' + emscriptenMemoryProfiler.formatBytes(resizeLast.end-resizeFirst.begin) + ')</b>:' + demangler(resizeFirst.filteredStack || resizeFirst.stack) + '</div><br>';
html += '<div style="background-color: ' + resizeFirst.color + '"><b>' + resizeFirst.begin + '-' + resizeLast.end + ' (' + count + ' times, ' + emscriptenMemoryProfiler.formatBytes(resizeLast.end-resizeFirst.begin) + ')</b>:' + (resizeFirst.filteredStack || resizeFirst.stack) + '</div><br>';
i = j-1;
}
return html;
Expand Down Expand Up @@ -599,7 +598,6 @@ var emscriptenMemoryProfiler = {
html += self.printHeapResizeLog(self.sbrkSources);
html += '</div>'
} else {
var demangler = typeof demangleAll != 'undefined' ? demangleAll : (x) => x;
// Print out statistics of individual allocations if they were tracked.
if (Object.keys(self.allocationsAtLoc).length > 0) {
var calls = [];
Expand All @@ -615,8 +613,7 @@ var emscriptenMemoryProfiler = {
}
html += '<h4>Allocation sites with more than ' + self.formatBytes(self.trackedCallstackMinSizeBytes) + ' of accumulated allocations, or more than ' + self.trackedCallstackMinAllocCount + ' simultaneously outstanding allocations:</h4>'
for (var i in calls) {
if (calls[i].length == 3) calls[i] = [calls[i][0], calls[i][1], calls[i][2], demangler(calls[i][2])];
html += "<b>" + self.formatBytes(calls[i][1]) + '/' + calls[i][0] + " allocs</b>: " + calls[i][3] + "<br />";
html += "<b>" + self.formatBytes(calls[i][1]) + '/' + calls[i][0] + " allocs</b>: " + calls[i][2] + "<br />";
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ var EMULATE_FUNCTION_POINTER_CASTS = false;
// [link]
var EXCEPTION_DEBUG = false;

// If 1, build in libcxxabi's full c++ demangling code, to allow stackTrace()
// to emit fully proper demangled c++ names
// If 1, export `demangle` and `stackTrace` helper function.
// [link]
var DEMANGLE_SUPPORT = false;

Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8412
8408
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23081
23069
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7242
7238
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19705
19693
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58257
58240
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57099
57082