[dart2wasm] Print debugging info (e.g. in --print-kernel) before generating code

By first printing the debugging information before generating code,
any crash in the code generator will have it prefixed with the
debugging information.

Issue https://github.com/dart-lang/sdk/issues/60583

Change-Id: I4e69e7003c1e0e7c078cbc1d94ae22ae69e302ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436601
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
This commit is contained in:
Martin Kustermann
2025-06-24 03:50:07 -07:00
committed by Commit Queue
parent ae791fb163
commit 2e8a93ce1f
+7 -5
View File
@@ -1893,10 +1893,12 @@ class CompilationTask {
CompilationTask(this.function, this._codeGenerator);
void run(Translator translator, bool printKernel, bool printWasm) {
_codeGenerator.generate(function.body, function.locals.toList(), null);
if (printWasm) {
print("#${function.name} (synthetic)");
print(function.type);
}
_codeGenerator.generate(function.body, function.locals.toList(), null);
if (printWasm) {
print(function.body.trace);
}
}
@@ -1913,9 +1915,6 @@ class AstCompilationTask extends CompilationTask {
void run(Translator translator, bool printKernel, bool printWasm) {
final member = reference.asMember;
final codeGen = getMemberCodeGenerator(translator, function, reference);
codeGen.generate(function.body, function.locals.toList(), null);
if (printKernel || printWasm) {
final (:name, :exportName) = _getNames(translator);
@@ -1927,6 +1926,7 @@ class AstCompilationTask extends CompilationTask {
header = "$header (type checker)";
}
print(header);
print(function.type);
print(member.function
?.computeFunctionType(Nullability.nonNullable)
.toStringInternal());
@@ -1950,8 +1950,10 @@ class AstCompilationTask extends CompilationTask {
if (!printWasm) print("");
}
final codeGen = getMemberCodeGenerator(translator, function, reference);
codeGen.generate(function.body, function.locals.toList(), null);
if (printWasm) {
print(function.type);
print(function.body.trace);
}
}