Files
Ömer Ağacan 11b6bd85d6 [dart2wasm] Add dart2wasm never-inline pragma to a function being checked in a stack trace test
Fixes tests with optimized builds:

- language/stack_trace/full1_test
- language/stack_trace/stack_trace_test

language/stack_trace/demangle_ctors_test will be fixed once we fix
#62523.

Change-Id: I788500e67045fa63783cc316eaf010728d077a3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476100
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-28 04:41:56 -08:00

70 lines
1.8 KiB
Dart

// (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Avoid dart2js optimizations that alter the JavaScript stack trace. (1)
// dart2js inlines methods in the generated JavaScript which leads to missing
// frames in the stack trace. (2) Minification obfuscates names. Both issues can
// be addressed offline by post-processing the stack trace using the source map
// file.
//
// dart2jsOptions=--disable-inlining --no-minify
import "package:expect/expect.dart";
@pragma("vm:entry-point") // Prevents obfuscation
@pragma("wasm:never-inline")
void func1() {
throw new Exception("Test full stacktrace");
}
@pragma("vm:entry-point") // Prevents obfuscation
@pragma("wasm:never-inline")
void func2() {
func1();
}
@pragma("vm:entry-point") // Prevents obfuscation
@pragma("wasm:never-inline")
void func3() {
try {
func2();
} on Object catch (e, s) {
var fullTrace = s.toString();
Expect.isTrue(fullTrace.contains("func1"));
Expect.isTrue(fullTrace.contains("func2"));
Expect.isTrue(fullTrace.contains("func3"));
Expect.isTrue(fullTrace.contains("func4"));
Expect.isTrue(fullTrace.contains("func5"));
Expect.isTrue(fullTrace.contains("func6"));
Expect.isTrue(fullTrace.contains("main"));
}
}
@pragma("vm:entry-point") // Prevents obfuscation
@pragma("wasm:never-inline")
int func4() {
func3();
return 1;
}
@pragma("vm:entry-point") // Prevents obfuscation
@pragma("wasm:never-inline")
int func5() {
func4();
return 1;
}
@pragma("vm:entry-point") // Prevents obfuscation
@pragma("wasm:never-inline")
int func6() {
func5();
return 1;
}
@pragma("wasm:never-inline")
main() {
var i = func6();
Expect.equals(1, i);
}