Trace function return values after function-exit.

This will allow function return values to be easily seen when stepping
"over." This has the unexpected side benefit of generating slightly
fewer ops when a function has unoptimizable conditional returns.

Change-Id: I48d23de635d3caaddff91aa595593d0371dfcdcb
Bug: skia:12708
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/481076
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-12-07 11:32:12 -05:00 committed by SkCQ
parent 5fb4753483
commit 85cc1bece7
6 changed files with 1353 additions and 1367 deletions

View File

@ -569,6 +569,14 @@ size_t SkVMGenerator::writeFunction(const FunctionDefinition& function,
if (fDebugTrace) {
fBuilder->trace_exit(fTraceHookID, this->mask(), fTraceMask, funcIndex);
if (fProgram.fConfig->fSettings.fAllowTraceVarInSkVMDebugTrace) {
size_t nslots = function.declaration().returnType().slotCount();
for (size_t i = 0; i < nslots; ++i) {
fBuilder->trace_var(fTraceHookID, this->mask(), fTraceMask,
returnSlot + i, i32(fSlots[returnSlot + i].val));
}
}
}
return returnSlot;
@ -1884,10 +1892,8 @@ void SkVMGenerator::writeReturnStatement(const ReturnStatement& r) {
size_t slot = currentFunction().fReturnSlot;
size_t nslots = r.expression()->type().slotCount();
for (size_t i = 0; i < nslots; ++i) {
fSlots[slot + i].writtenTo = false;
skvm::Val conditionalStore = this->writeConditionalStore(fSlots[slot + i].val, val[i],
returnsHere);
this->writeToSlot(slot + i, conditionalStore);
fSlots[slot + i].val = this->writeConditionalStore(fSlots[slot + i].val, val[i],
returnsHere);
}
}

View File

@ -1078,8 +1078,8 @@ enter int main()
comparison = true
line 3
line 4
[less_than].result = true
exit bool less_than(float left, int right)
[less_than].result = true
function_result = true
line 12
loop = 20
@ -1107,8 +1107,8 @@ enter int main()
comparison = false
line 3
line 6
[less_than].result = false
exit bool less_than(float left, int right)
[less_than].result = false
function_result = false
line 12
loop = 30
@ -1136,12 +1136,12 @@ enter int main()
comparison = false
line 3
line 6
[less_than].result = false
exit bool less_than(float left, int right)
[less_than].result = false
function_result = false
line 12
line 18
[main].result = 40
exit int main()
[main].result = 40
)", "Trace output does not match expectation:\n%.*s\n", (int)trace.size(), trace.data());
}

View File

@ -139,8 +139,8 @@ loop:
86 trace_line 0 r53 r53 L38
87 trace_enter 0 r53 r53 F1
88 trace_line 0 r53 r53 L5
89 trace_var 0 r53 r53 $34 = r1
90 trace_exit 0 r53 r53 F1
89 trace_exit 0 r53 r53 F1
90 trace_var 0 r53 r53 $34 = r1
91 trace_enter 0 r53 r53 F2
92 trace_line 0 r53 r53 L10
93 trace_var 0 r53 r53 $36 = r29
@ -162,8 +162,8 @@ loop:
109 trace_var 0 r53 r53 $36 = r37
110 trace_line 0 r53 r53 L11
111 trace_line 0 r53 r53 L14
112 trace_var 0 r53 r53 $35 = r37
113 trace_exit 0 r53 r53 F2
112 trace_exit 0 r53 r53 F2
113 trace_var 0 r53 r53 $35 = r37
114 trace_enter 0 r53 r53 F3
115 trace_line 0 r53 r53 L19
116 trace_var 0 r53 r53 $39 = r38
@ -185,8 +185,8 @@ loop:
132 trace_var 0 r53 r53 $39 = r41
133 trace_line 0 r53 r53 L20
134 trace_line 0 r53 r53 L23
135 trace_var 0 r53 r53 $38 = r41
136 trace_exit 0 r53 r53 F3
135 trace_exit 0 r53 r53 F3
136 trace_var 0 r53 r53 $38 = r41
137 trace_enter 0 r53 r53 F4
138 trace_line 0 r53 r53 L28
139 trace_var 0 r53 r53 $42 = r29
@ -218,13 +218,13 @@ loop:
165 trace_line 0 r53 r53 L30
166 trace_line 0 r53 r53 L29
167 trace_line 0 r53 r53 L34
168 trace_var 0 r53 r53 $41 = r50
169 trace_exit 0 r53 r53 F4
170 trace_var 0 r53 r53 $28 = r1
171 trace_var 0 r53 r53 $29 = r37
172 trace_var 0 r53 r53 $30 = r41
173 trace_var 0 r53 r53 $31 = r50
174 trace_exit 0 r53 r53 F0
168 trace_exit 0 r53 r53 F4
169 trace_var 0 r53 r53 $41 = r50
170 trace_exit 0 r53 r53 F0
171 trace_var 0 r53 r53 $28 = r1
172 trace_var 0 r53 r53 $29 = r37
173 trace_var 0 r53 r53 $30 = r41
174 trace_var 0 r53 r53 $31 = r50
175 trace_done 0 r53
176 store32 ptr1 r1
177 store32 ptr2 r37

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -224,8 +224,8 @@ loop:
64 trace_line 0 r21 r21 L9
65 trace_var 0 r21 r21 $34 = r14
66 trace_line 0 r21 r21 L11
67 trace_var 0 r21 r21 $30 = r10
68 trace_exit 0 r21 r21 F1
67 trace_exit 0 r21 r21 F1
68 trace_var 0 r21 r21 $30 = r10
69 trace_enter 0 r21 r21 F2
70 trace_line 0 r21 r21 L15
71 trace_var 0 r21 r21 $36 = r15
@ -276,8 +276,8 @@ loop:
116 trace_var 0 r21 r21 $70 = r19
117 trace_var 0 r21 r21 $71 = r19
118 trace_line 0 r21 r21 L29
119 trace_var 0 r21 r21 $35 = r10
120 trace_exit 0 r21 r21 F2
119 trace_exit 0 r21 r21 F2
120 trace_var 0 r21 r21 $35 = r10
121 trace_enter 0 r21 r21 F3
122 trace_line 0 r21 r21 L34
123 trace_var 0 r21 r21 $73 = r15
@ -344,8 +344,8 @@ loop:
184 trace_var 0 r21 r21 $129 = r9
185 trace_var 0 r21 r21 $130 = r17
186 trace_line 0 r21 r21 L41
187 trace_var 0 r21 r21 $72 = r10
188 trace_exit 0 r21 r21 F3
187 trace_exit 0 r21 r21 F3
188 trace_var 0 r21 r21 $72 = r10
189 trace_enter 0 r21 r21 F4
190 trace_line 0 r21 r21 L45
191 trace_var 0 r21 r21 $132 = r9
@ -376,28 +376,28 @@ loop:
216 trace_var 0 r21 r21 $140 = r15
217 trace_var 0 r21 r21 $141 = r16
218 trace_line 0 r21 r21 L50
219 trace_var 0 r21 r21 $131 = r10
220 trace_exit 0 r21 r21 F4
219 trace_exit 0 r21 r21 F4
220 trace_var 0 r21 r21 $131 = r10
221 trace_enter 0 r21 r21 F5
222 trace_var 0 r21 r21 $143 = r13
223 trace_line 0 r21 r21 L53
224 trace_var 0 r21 r21 $142 = r10
225 trace_exit 0 r21 r21 F5
224 trace_exit 0 r21 r21 F5
225 trace_var 0 r21 r21 $142 = r10
226 trace_enter 0 r21 r21 F6
227 trace_var 0 r21 r21 $145 = r15
228 trace_line 0 r21 r21 L54
229 trace_var 0 r21 r21 $144 = r10
230 trace_exit 0 r21 r21 F6
229 trace_exit 0 r21 r21 F6
230 trace_var 0 r21 r21 $144 = r10
231 trace_enter 0 r21 r21 F7
232 trace_var 0 r21 r21 $147 = r16
233 trace_line 0 r21 r21 L55
234 trace_var 0 r21 r21 $146 = r10
235 trace_exit 0 r21 r21 F7
236 trace_var 0 r21 r21 $8 = r1
237 trace_var 0 r21 r21 $9 = r2
238 trace_var 0 r21 r21 $10 = r3
239 trace_var 0 r21 r21 $11 = r4
240 trace_exit 0 r21 r21 F0
234 trace_exit 0 r21 r21 F7
235 trace_var 0 r21 r21 $146 = r10
236 trace_exit 0 r21 r21 F0
237 trace_var 0 r21 r21 $8 = r1
238 trace_var 0 r21 r21 $9 = r2
239 trace_var 0 r21 r21 $10 = r3
240 trace_var 0 r21 r21 $11 = r4
241 trace_done 0 r21
242 store32 ptr1 r1
243 store32 ptr2 r2