MSAN fix for interpreter
MSAN points out we oughta initialize anywhere we pull a trick like this,
ptr[*ip+0] = skvx::if_then_else(mask(), POP().fFloat, ptr[*ip+0].fFloat);
Change-Id: I321f0d54b7f0f048df2e942dd70a6fabf6fd4efb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283493
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/src/sksl/SkSLByteCode.cpp b/src/sksl/SkSLByteCode.cpp
index 99f0845..af18c28 100644
--- a/src/sksl/SkSLByteCode.cpp
+++ b/src/sksl/SkSLByteCode.cpp
@@ -586,12 +586,16 @@
// the stack. Update our bottom of stack to point at the first parameter, and our
// sp to point past those parameters (plus space for locals).
int target = READ8();
- const ByteCodeFunction* fun = byteCode->fFunctions[target].get();
+ const ByteCodeFunction* f = byteCode->fFunctions[target].get();
if (skvx::any(mask())) {
- frames.push_back({ code, ip, stack, fun->fParameterCount });
- ip = code = fun->fCode.data();
- stack = sp - fun->fParameterCount + 1;
- sp = stack + fun->fParameterCount + fun->fLocalCount - 1;
+ frames.push_back({ code, ip, stack, f->fParameterCount });
+ ip = code = f->fCode.data();
+ stack = sp - f->fParameterCount + 1;
+ sp = stack + f->fParameterCount + f->fLocalCount - 1;
+ // As we did in runStriped(), zero locals so they're safe to mask-store into.
+ for (int i = f->fParameterCount; i < f->fParameterCount + f->fLocalCount; i++) {
+ stack[i].fFloat = 0.0f;
+ }
}
continue;
}
@@ -1256,6 +1260,15 @@
outReturn = nullptr;
}
+ // The instructions to store to locals and globals mask in the original value,
+ // so they technically need to be initialized (to any value).
+ for (int i = f->fParameterCount; i < f->fParameterCount + f->fLocalCount; i++) {
+ stack[i].fFloat = 0.0f;
+ }
+ for (int i = 0; i < fGlobalSlotCount; i++) {
+ globals[i].fFloat = 0.0f;
+ }
+
int baseIndex = 0;
while (N) {