[dart2wasm] Move _Utf8Decoder.convertGeneral to JSCM patch

This method is only used in JSCM `dart:convert` patch. Move it from the
standard library to JSCM patch file.

This makes it easier to optimize it using dar2wasm internal types.

Change-Id: I17139f0a752b856d17ddfb8b5ff047f17d5aaa70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403986
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart b/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart
index d5521be..3964952 100644
--- a/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart
+++ b/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart
@@ -1503,12 +1503,44 @@
       if (decoded != null) return decoded;
     }
 
-    return convertGeneral(codeUnits, start, maybeEnd, true);
+    return _convertGeneral(codeUnits, start, maybeEnd, true);
   }
 
   @patch
   String convertChunked(List<int> codeUnits, int start, int? maybeEnd) {
-    return convertGeneral(codeUnits, start, maybeEnd, false);
+    return _convertGeneral(codeUnits, start, maybeEnd, false);
+  }
+
+  String _convertGeneral(
+    List<int> codeUnits,
+    int start,
+    int? maybeEnd,
+    bool single,
+  ) {
+    int end = RangeError.checkValidRange(start, maybeEnd, codeUnits.length);
+
+    if (start == end) return "";
+
+    // Have bytes as Uint8List.
+    Uint8List bytes;
+    int errorOffset;
+    if (codeUnits is Uint8List) {
+      bytes = codeUnits;
+      errorOffset = 0;
+    } else {
+      bytes = _makeUint8List(codeUnits, start, end);
+      errorOffset = start;
+      end -= start;
+      start = 0;
+    }
+
+    String result = decodeGeneral(bytes, start, end, single);
+    if (isErrorState(_state)) {
+      String message = errorDescription(_state);
+      _state = initial; // Ready for more input.
+      throw FormatException(message, codeUnits, errorOffset + _charOrIndex);
+    }
+    return result;
   }
 }
 
diff --git a/sdk/lib/convert/utf.dart b/sdk/lib/convert/utf.dart
index 394a47c..ec87b5f 100644
--- a/sdk/lib/convert/utf.dart
+++ b/sdk/lib/convert/utf.dart
@@ -552,38 +552,6 @@
 
   external String convertChunked(List<int> codeUnits, int start, int? maybeEnd);
 
-  String convertGeneral(
-    List<int> codeUnits,
-    int start,
-    int? maybeEnd,
-    bool single,
-  ) {
-    int end = RangeError.checkValidRange(start, maybeEnd, codeUnits.length);
-
-    if (start == end) return "";
-
-    // Have bytes as Uint8List.
-    Uint8List bytes;
-    int errorOffset;
-    if (codeUnits is Uint8List) {
-      bytes = codeUnits;
-      errorOffset = 0;
-    } else {
-      bytes = _makeUint8List(codeUnits, start, end);
-      errorOffset = start;
-      end -= start;
-      start = 0;
-    }
-
-    String result = decodeGeneral(bytes, start, end, single);
-    if (isErrorState(_state)) {
-      String message = errorDescription(_state);
-      _state = initial; // Ready for more input.
-      throw FormatException(message, codeUnits, errorOffset + _charOrIndex);
-    }
-    return result;
-  }
-
   /// Flushes this decoder as if closed.
   ///
   /// This method throws if the input was partial and the decoder was