Repository: nodejs/node
Pull request: deps: V8: cherry-pick 64b36b441179

Cherry-picks V8 commit [`64b36b441179`](https://github.com/v8/v8/commit/64b36b44117949fe03df33d077117e7bd6257669) (ASCII fast path optimization in `WriteUtf8V2`).

This optimizes the `WriteUtf8V2` path for ASCII-only one-byte strings by using SIMD-accelerated validation (`simdutf::validate_ascii`) followed by a bulk `memcpy`, instead of encoding byte-by-byte through the generic UTF-8 path.

**Changes:**
- `deps/v8/src/strings/unicode-inl.h` — Added `IsAsciiOneByteString` template specializations and ASCII fast path in `Encode`
- `deps/v8/src/strings/unicode.h` — Added `IsAsciiOneByteString` declarations
- `common.gypi` — Incremented embedder string (`-node.11` → `-node.12`)

**References:**
- V8 commit: https://github.com/v8/v8/commit/64b36b44117949fe03df33d077117e7bd6257669
- Chromium review: https://chromium-review.googlesource.com/c/v8/v8/+/7124103
- Supersedes: https://github.com/nodejs/node/pull/61698 (was against `v24.x-staging`, maintainers requested rebase to `main`)

Changed files:
filename: deps/v8/src/strings/unicode-inl.h
patch: @@ -206,6 +206,16 @@ bool Utf8::IsValidCharacter(uchar c) {
           c != kBadChar);
 }
 
+template <>
+bool Utf8::IsAsciiOneByteString<uint8_t>(const uint8_t* buffer, size_t size) {
+  return simdutf::validate_ascii(reinterpret_cast<const char*>(buffer), size);
+}
+
+template <>
+bool Utf8::IsAsciiOneByteString<uint16_t>(const uint16_t* buffer, size_t size) {
+  return false;
+}
+
 template <typename Char>
 Utf8::EncodingResult Utf8::Encode(v8::base::Vector<const Char> string,
                                   char* buffer, size_t capacity,
@@ -221,8 +231,17 @@ Utf8::EncodingResult Utf8::Encode(v8::base::Vector<const Char> string,
   const Char* characters = string.begin();
   size_t content_capacity = capacity - write_null;
   CHECK_LE(content_capacity, capacity);
-  uint16_t last = Utf16::kNoPreviousCharacter;
   size_t read_index = 0;
+  if (kSourceIsOneByte) {
+    size_t writeable = std::min(string.size(), content_capacity);
+    // Just memcpy when possible.
+    if (writeable > 0 && Utf8::IsAsciiOneByteString(characters, writeable)) {
+      memcpy(buffer, characters, writeable);
+      read_index = writeable;
+      write_index = writeable;
+    }
+  }
+  uint16_t last = Utf16::kNoPreviousCharacter;
   for (; read_index < string.size(); read_index++) {
     Char character = characters[read_index];
 

filename: deps/v8/src/strings/unicode.h
patch: @@ -212,6 +212,9 @@ class V8_EXPORT_PRIVATE Utf8 {
   // - valid code point range.
   static bool ValidateEncoding(const uint8_t* str, size_t length);
 
+  template <typename Char>
+  static bool IsAsciiOneByteString(const Char* buffer, size_t size);
+
   // Encode the given characters as Utf8 into the provided output buffer.
   struct EncodingResult {
     size_t bytes_written;
@@ -223,6 +226,14 @@ class V8_EXPORT_PRIVATE Utf8 {
                                bool replace_invalid_utf8);
 };
 
+template <>
+inline bool Utf8::IsAsciiOneByteString<uint8_t>(const uint8_t* buffer,
+                                                 size_t size);
+
+template <>
+inline bool Utf8::IsAsciiOneByteString<uint16_t>(const uint16_t* buffer,
+                                                  size_t size);
+
 #if V8_ENABLE_WEBASSEMBLY
 class V8_EXPORT_PRIVATE Wtf8 {
  public: