-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Description
For this example
class A {
foo(unusedArg0) {
baz() {
for (int i = 0; i < 3; ++i) {
print('[$i] $unusedArg0');
}
}
baz();
}
}
main() {
A().foo(null);
}With a small patch to the VM to dump variables:
diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc
index 1bca9a114e..391ceee4a8 100644
--- a/runtime/vm/runtime_entry.cc
+++ b/runtime/vm/runtime_entry.cc
@@ -2315,9 +2315,20 @@ static void HandleStackOverflowTestCases(Thread* thread) {
num_vars = frame->NumLocalVariables();
}
#endif
+ const bool print_vars = strstr(frame->function().ToFullyQualifiedCString(), "baz") != nullptr;
+ if (print_vars) {
+ THR_Print("STACK \n");
+ }
TokenPosition unused = TokenPosition::kNoSource;
+ if (print_vars) {
+ THR_Print(" [%" Pd "] %s (num_vars: %d)\n",
+ i, frame->function().ToFullyQualifiedCString(), num_vars);
+ }
for (intptr_t v = 0; v < num_vars; v++) {
frame->VariableAt(v, &var_name, &unused, &unused, &unused, &var_value);
+ if (print_vars) {
+ THR_Print(" v[%" Pd "] %s\n", v, var_name.ToCString());
+ }
}
}
if (FLAG_stress_async_stacks) {We see a difference:
AST
% tools/build.py -mrelease -ax64 runtime_kernel
% out/ReleaseX64/dart --stacktrace_every=1 --deterministic test.dart
...
STACK
[3] file:///.../test.dart_A_foo_baz (num_vars: 2)
v[0] unusedArg0
v[1] i
STACK
[4] file:///.../test.dart_A_foo_baz (num_vars: 2)
v[0] unusedArg0
v[1] i
...
Bytecode:
% tools/gn.py -mrelease -ax64 --bytecode
% tools/build.py -mrelease -ax64 runtime_kernel
% out/ReleaseX64/dart --stacktrace_every=1 --deterministic test.dart
STACK
[4] file:///.../test.dart_A_foo_baz (num_vars: 3)
v[0] unusedArg0
v[1] this
v[2] i
STACK
[4] file:///.../test.dart_A_foo_baz (num_vars: 3)
v[0] unusedArg0
v[1] this
v[2] i
It's unclear here why this shows up in the local variables for A_foo_baz.
/cc @alexmarkov @crelier
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.