more SkSL interpreter performance work

Bug: skia:
Change-Id: I21da1f1473fb73e8ba1371e7301f3fff2e33e8cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212199
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/sksl/SkSLByteCodeGenerator.cpp b/src/sksl/SkSLByteCodeGenerator.cpp
index 23d8943b..8011c21 100644
--- a/src/sksl/SkSLByteCodeGenerator.cpp
+++ b/src/sksl/SkSLByteCodeGenerator.cpp
@@ -61,6 +61,10 @@
     this->write8(0);
     result->fParameterCount = fParameterCount;
     result->fLocalCount = fLocals.size();
+    const Type& returnType = f.fDeclaration.fReturnType;
+    if (returnType != *fContext.fVoid_Type) {
+        result->fReturnCount = returnType.columns() * returnType.rows();
+    }
     fLocals.clear();
     fFunction = nullptr;
     return result;
@@ -148,8 +152,13 @@
 }
 
 void ByteCodeGenerator::align(int divisor, int remainder) {
-    while ((int) fCode->size() % divisor != remainder) {
-        this->write(ByteCodeInstruction::kNop);
+    switch (remainder - (int) fCode->size() % divisor) {
+        case 0: return;
+        case 3: this->write(ByteCodeInstruction::kNop3); // fall through
+        case 2: this->write(ByteCodeInstruction::kNop2); // fall through
+        case 1: this->write(ByteCodeInstruction::kNop1);
+                break;
+        default: SkASSERT(false);
     }
 }