github.com/MerlinKodo/gvisor@v0.0.0-20231110090155-957f62ecf90e/pkg/sentry/arch/arch_arm64_abi_autogen_unsafe.go (about)

     1  // Automatically generated marshal implementation. See tools/go_marshal.
     2  
     3  // If there are issues with build constraint aggregation, see
     4  // tools/go_marshal/gomarshal/generator.go:writeHeader(). The constraints here
     5  // come from the input set of files used to generate this file. This input set
     6  // is filtered based on pre-defined file suffixes related to build constraints,
     7  // see tools/defs.bzl:calculate_sets().
     8  
     9  //go:build arm64 && arm64 && arm64
    10  // +build arm64,arm64,arm64
    11  
    12  package arch
    13  
    14  import (
    15      "github.com/MerlinKodo/gvisor/pkg/abi/linux"
    16      "github.com/MerlinKodo/gvisor/pkg/gohacks"
    17      "github.com/MerlinKodo/gvisor/pkg/hostarch"
    18      "github.com/MerlinKodo/gvisor/pkg/marshal"
    19      "io"
    20      "reflect"
    21      "runtime"
    22      "unsafe"
    23  )
    24  
    25  // Marshallable types used by this file.
    26  var _ marshal.Marshallable = (*FpsimdContext)(nil)
    27  var _ marshal.Marshallable = (*SignalContext64)(nil)
    28  var _ marshal.Marshallable = (*UContext64)(nil)
    29  var _ marshal.Marshallable = (*aarch64Ctx)(nil)
    30  var _ marshal.Marshallable = (*linux.SignalSet)(nil)
    31  var _ marshal.Marshallable = (*linux.SignalStack)(nil)
    32  
    33  // SizeBytes implements marshal.Marshallable.SizeBytes.
    34  func (f *FpsimdContext) SizeBytes() int {
    35      return 8 +
    36          (*aarch64Ctx)(nil).SizeBytes() +
    37          8*64
    38  }
    39  
    40  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
    41  func (f *FpsimdContext) MarshalBytes(dst []byte) []byte {
    42      dst = f.Head.MarshalUnsafe(dst)
    43      hostarch.ByteOrder.PutUint32(dst[:4], uint32(f.Fpsr))
    44      dst = dst[4:]
    45      hostarch.ByteOrder.PutUint32(dst[:4], uint32(f.Fpcr))
    46      dst = dst[4:]
    47      for idx := 0; idx < 64; idx++ {
    48          hostarch.ByteOrder.PutUint64(dst[:8], uint64(f.Vregs[idx]))
    49          dst = dst[8:]
    50      }
    51      return dst
    52  }
    53  
    54  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
    55  func (f *FpsimdContext) UnmarshalBytes(src []byte) []byte {
    56      src = f.Head.UnmarshalUnsafe(src)
    57      f.Fpsr = uint32(hostarch.ByteOrder.Uint32(src[:4]))
    58      src = src[4:]
    59      f.Fpcr = uint32(hostarch.ByteOrder.Uint32(src[:4]))
    60      src = src[4:]
    61      for idx := 0; idx < 64; idx++ {
    62          f.Vregs[idx] = uint64(hostarch.ByteOrder.Uint64(src[:8]))
    63          src = src[8:]
    64      }
    65      return src
    66  }
    67  
    68  // Packed implements marshal.Marshallable.Packed.
    69  //go:nosplit
    70  func (f *FpsimdContext) Packed() bool {
    71      return f.Head.Packed()
    72  }
    73  
    74  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
    75  func (f *FpsimdContext) MarshalUnsafe(dst []byte) []byte {
    76      if f.Head.Packed() {
    77          size := f.SizeBytes()
    78          gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(f), uintptr(size))
    79          return dst[size:]
    80      }
    81      // Type FpsimdContext doesn't have a packed layout in memory, fallback to MarshalBytes.
    82      return f.MarshalBytes(dst)
    83  }
    84  
    85  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
    86  func (f *FpsimdContext) UnmarshalUnsafe(src []byte) []byte {
    87      if f.Head.Packed() {
    88          size := f.SizeBytes()
    89          gohacks.Memmove(unsafe.Pointer(f), unsafe.Pointer(&src[0]), uintptr(size))
    90          return src[size:]
    91      }
    92      // Type FpsimdContext doesn't have a packed layout in memory, fallback to UnmarshalBytes.
    93      return f.UnmarshalBytes(src)
    94  }
    95  
    96  // CopyOutN implements marshal.Marshallable.CopyOutN.
    97  func (f *FpsimdContext) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    98      if !f.Head.Packed() {
    99          // Type FpsimdContext doesn't have a packed layout in memory, fall back to MarshalBytes.
   100          buf := cc.CopyScratchBuffer(f.SizeBytes()) // escapes: okay.
   101          f.MarshalBytes(buf) // escapes: fallback.
   102          return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   103      }
   104  
   105      // Construct a slice backed by dst's underlying memory.
   106      var buf []byte
   107      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   108      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f)))
   109      hdr.Len = f.SizeBytes()
   110      hdr.Cap = f.SizeBytes()
   111  
   112      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   113      // Since we bypassed the compiler's escape analysis, indicate that f
   114      // must live until the use above.
   115      runtime.KeepAlive(f) // escapes: replaced by intrinsic.
   116      return length, err
   117  }
   118  
   119  // CopyOut implements marshal.Marshallable.CopyOut.
   120  func (f *FpsimdContext) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   121      return f.CopyOutN(cc, addr, f.SizeBytes())
   122  }
   123  
   124  // CopyInN implements marshal.Marshallable.CopyInN.
   125  func (f *FpsimdContext) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   126      if !f.Head.Packed() {
   127          // Type FpsimdContext doesn't have a packed layout in memory, fall back to UnmarshalBytes.
   128          buf := cc.CopyScratchBuffer(f.SizeBytes()) // escapes: okay.
   129          length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   130          // Unmarshal unconditionally. If we had a short copy-in, this results in a
   131          // partially unmarshalled struct.
   132          f.UnmarshalBytes(buf) // escapes: fallback.
   133          return length, err
   134      }
   135  
   136      // Construct a slice backed by dst's underlying memory.
   137      var buf []byte
   138      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   139      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f)))
   140      hdr.Len = f.SizeBytes()
   141      hdr.Cap = f.SizeBytes()
   142  
   143      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   144      // Since we bypassed the compiler's escape analysis, indicate that f
   145      // must live until the use above.
   146      runtime.KeepAlive(f) // escapes: replaced by intrinsic.
   147      return length, err
   148  }
   149  
   150  // CopyIn implements marshal.Marshallable.CopyIn.
   151  func (f *FpsimdContext) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   152      return f.CopyInN(cc, addr, f.SizeBytes())
   153  }
   154  
   155  // WriteTo implements io.WriterTo.WriteTo.
   156  func (f *FpsimdContext) WriteTo(writer io.Writer) (int64, error) {
   157      if !f.Head.Packed() {
   158          // Type FpsimdContext doesn't have a packed layout in memory, fall back to MarshalBytes.
   159          buf := make([]byte, f.SizeBytes())
   160          f.MarshalBytes(buf)
   161          length, err := writer.Write(buf)
   162          return int64(length), err
   163      }
   164  
   165      // Construct a slice backed by dst's underlying memory.
   166      var buf []byte
   167      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   168      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f)))
   169      hdr.Len = f.SizeBytes()
   170      hdr.Cap = f.SizeBytes()
   171  
   172      length, err := writer.Write(buf)
   173      // Since we bypassed the compiler's escape analysis, indicate that f
   174      // must live until the use above.
   175      runtime.KeepAlive(f) // escapes: replaced by intrinsic.
   176      return int64(length), err
   177  }
   178  
   179  // SizeBytes implements marshal.Marshallable.SizeBytes.
   180  func (s *SignalContext64) SizeBytes() int {
   181      return 32 +
   182          8*31 +
   183          1*8 +
   184          (*FpsimdContext)(nil).SizeBytes()
   185  }
   186  
   187  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   188  func (s *SignalContext64) MarshalBytes(dst []byte) []byte {
   189      hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.FaultAddr))
   190      dst = dst[8:]
   191      for idx := 0; idx < 31; idx++ {
   192          hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Regs[idx]))
   193          dst = dst[8:]
   194      }
   195      hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Sp))
   196      dst = dst[8:]
   197      hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Pc))
   198      dst = dst[8:]
   199      hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Pstate))
   200      dst = dst[8:]
   201      for idx := 0; idx < 8; idx++ {
   202          dst[0] = byte(s._pad[idx])
   203          dst = dst[1:]
   204      }
   205      dst = s.Fpsimd64.MarshalUnsafe(dst)
   206      return dst
   207  }
   208  
   209  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   210  func (s *SignalContext64) UnmarshalBytes(src []byte) []byte {
   211      s.FaultAddr = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   212      src = src[8:]
   213      for idx := 0; idx < 31; idx++ {
   214          s.Regs[idx] = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   215          src = src[8:]
   216      }
   217      s.Sp = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   218      src = src[8:]
   219      s.Pc = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   220      src = src[8:]
   221      s.Pstate = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   222      src = src[8:]
   223      for idx := 0; idx < 8; idx++ {
   224          s._pad[idx] = src[0]
   225          src = src[1:]
   226      }
   227      src = s.Fpsimd64.UnmarshalUnsafe(src)
   228      return src
   229  }
   230  
   231  // Packed implements marshal.Marshallable.Packed.
   232  //go:nosplit
   233  func (s *SignalContext64) Packed() bool {
   234      return s.Fpsimd64.Packed()
   235  }
   236  
   237  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   238  func (s *SignalContext64) MarshalUnsafe(dst []byte) []byte {
   239      if s.Fpsimd64.Packed() {
   240          size := s.SizeBytes()
   241          gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size))
   242          return dst[size:]
   243      }
   244      // Type SignalContext64 doesn't have a packed layout in memory, fallback to MarshalBytes.
   245      return s.MarshalBytes(dst)
   246  }
   247  
   248  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   249  func (s *SignalContext64) UnmarshalUnsafe(src []byte) []byte {
   250      if s.Fpsimd64.Packed() {
   251          size := s.SizeBytes()
   252          gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size))
   253          return src[size:]
   254      }
   255      // Type SignalContext64 doesn't have a packed layout in memory, fallback to UnmarshalBytes.
   256      return s.UnmarshalBytes(src)
   257  }
   258  
   259  // CopyOutN implements marshal.Marshallable.CopyOutN.
   260  func (s *SignalContext64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   261      if !s.Fpsimd64.Packed() {
   262          // Type SignalContext64 doesn't have a packed layout in memory, fall back to MarshalBytes.
   263          buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay.
   264          s.MarshalBytes(buf) // escapes: fallback.
   265          return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   266      }
   267  
   268      // Construct a slice backed by dst's underlying memory.
   269      var buf []byte
   270      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   271      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s)))
   272      hdr.Len = s.SizeBytes()
   273      hdr.Cap = s.SizeBytes()
   274  
   275      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   276      // Since we bypassed the compiler's escape analysis, indicate that s
   277      // must live until the use above.
   278      runtime.KeepAlive(s) // escapes: replaced by intrinsic.
   279      return length, err
   280  }
   281  
   282  // CopyOut implements marshal.Marshallable.CopyOut.
   283  func (s *SignalContext64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   284      return s.CopyOutN(cc, addr, s.SizeBytes())
   285  }
   286  
   287  // CopyInN implements marshal.Marshallable.CopyInN.
   288  func (s *SignalContext64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   289      if !s.Fpsimd64.Packed() {
   290          // Type SignalContext64 doesn't have a packed layout in memory, fall back to UnmarshalBytes.
   291          buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay.
   292          length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   293          // Unmarshal unconditionally. If we had a short copy-in, this results in a
   294          // partially unmarshalled struct.
   295          s.UnmarshalBytes(buf) // escapes: fallback.
   296          return length, err
   297      }
   298  
   299      // Construct a slice backed by dst's underlying memory.
   300      var buf []byte
   301      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   302      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s)))
   303      hdr.Len = s.SizeBytes()
   304      hdr.Cap = s.SizeBytes()
   305  
   306      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   307      // Since we bypassed the compiler's escape analysis, indicate that s
   308      // must live until the use above.
   309      runtime.KeepAlive(s) // escapes: replaced by intrinsic.
   310      return length, err
   311  }
   312  
   313  // CopyIn implements marshal.Marshallable.CopyIn.
   314  func (s *SignalContext64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   315      return s.CopyInN(cc, addr, s.SizeBytes())
   316  }
   317  
   318  // WriteTo implements io.WriterTo.WriteTo.
   319  func (s *SignalContext64) WriteTo(writer io.Writer) (int64, error) {
   320      if !s.Fpsimd64.Packed() {
   321          // Type SignalContext64 doesn't have a packed layout in memory, fall back to MarshalBytes.
   322          buf := make([]byte, s.SizeBytes())
   323          s.MarshalBytes(buf)
   324          length, err := writer.Write(buf)
   325          return int64(length), err
   326      }
   327  
   328      // Construct a slice backed by dst's underlying memory.
   329      var buf []byte
   330      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   331      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s)))
   332      hdr.Len = s.SizeBytes()
   333      hdr.Cap = s.SizeBytes()
   334  
   335      length, err := writer.Write(buf)
   336      // Since we bypassed the compiler's escape analysis, indicate that s
   337      // must live until the use above.
   338      runtime.KeepAlive(s) // escapes: replaced by intrinsic.
   339      return int64(length), err
   340  }
   341  
   342  // SizeBytes implements marshal.Marshallable.SizeBytes.
   343  func (u *UContext64) SizeBytes() int {
   344      return 16 +
   345          (*linux.SignalStack)(nil).SizeBytes() +
   346          (*linux.SignalSet)(nil).SizeBytes() +
   347          1*120 +
   348          1*8 +
   349          (*SignalContext64)(nil).SizeBytes()
   350  }
   351  
   352  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   353  func (u *UContext64) MarshalBytes(dst []byte) []byte {
   354      hostarch.ByteOrder.PutUint64(dst[:8], uint64(u.Flags))
   355      dst = dst[8:]
   356      hostarch.ByteOrder.PutUint64(dst[:8], uint64(u.Link))
   357      dst = dst[8:]
   358      dst = u.Stack.MarshalUnsafe(dst)
   359      dst = u.Sigset.MarshalUnsafe(dst)
   360      for idx := 0; idx < 120; idx++ {
   361          dst[0] = byte(u._pad[idx])
   362          dst = dst[1:]
   363      }
   364      for idx := 0; idx < 8; idx++ {
   365          dst[0] = byte(u._pad2[idx])
   366          dst = dst[1:]
   367      }
   368      dst = u.MContext.MarshalUnsafe(dst)
   369      return dst
   370  }
   371  
   372  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   373  func (u *UContext64) UnmarshalBytes(src []byte) []byte {
   374      u.Flags = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   375      src = src[8:]
   376      u.Link = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   377      src = src[8:]
   378      src = u.Stack.UnmarshalUnsafe(src)
   379      src = u.Sigset.UnmarshalUnsafe(src)
   380      for idx := 0; idx < 120; idx++ {
   381          u._pad[idx] = src[0]
   382          src = src[1:]
   383      }
   384      for idx := 0; idx < 8; idx++ {
   385          u._pad2[idx] = src[0]
   386          src = src[1:]
   387      }
   388      src = u.MContext.UnmarshalUnsafe(src)
   389      return src
   390  }
   391  
   392  // Packed implements marshal.Marshallable.Packed.
   393  //go:nosplit
   394  func (u *UContext64) Packed() bool {
   395      return u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed()
   396  }
   397  
   398  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   399  func (u *UContext64) MarshalUnsafe(dst []byte) []byte {
   400      if u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() {
   401          size := u.SizeBytes()
   402          gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
   403          return dst[size:]
   404      }
   405      // Type UContext64 doesn't have a packed layout in memory, fallback to MarshalBytes.
   406      return u.MarshalBytes(dst)
   407  }
   408  
   409  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   410  func (u *UContext64) UnmarshalUnsafe(src []byte) []byte {
   411      if u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() {
   412          size := u.SizeBytes()
   413          gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
   414          return src[size:]
   415      }
   416      // Type UContext64 doesn't have a packed layout in memory, fallback to UnmarshalBytes.
   417      return u.UnmarshalBytes(src)
   418  }
   419  
   420  // CopyOutN implements marshal.Marshallable.CopyOutN.
   421  func (u *UContext64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   422      if !u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() {
   423          // Type UContext64 doesn't have a packed layout in memory, fall back to MarshalBytes.
   424          buf := cc.CopyScratchBuffer(u.SizeBytes()) // escapes: okay.
   425          u.MarshalBytes(buf) // escapes: fallback.
   426          return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   427      }
   428  
   429      // Construct a slice backed by dst's underlying memory.
   430      var buf []byte
   431      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   432      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
   433      hdr.Len = u.SizeBytes()
   434      hdr.Cap = u.SizeBytes()
   435  
   436      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   437      // Since we bypassed the compiler's escape analysis, indicate that u
   438      // must live until the use above.
   439      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
   440      return length, err
   441  }
   442  
   443  // CopyOut implements marshal.Marshallable.CopyOut.
   444  func (u *UContext64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   445      return u.CopyOutN(cc, addr, u.SizeBytes())
   446  }
   447  
   448  // CopyInN implements marshal.Marshallable.CopyInN.
   449  func (u *UContext64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   450      if !u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() {
   451          // Type UContext64 doesn't have a packed layout in memory, fall back to UnmarshalBytes.
   452          buf := cc.CopyScratchBuffer(u.SizeBytes()) // escapes: okay.
   453          length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   454          // Unmarshal unconditionally. If we had a short copy-in, this results in a
   455          // partially unmarshalled struct.
   456          u.UnmarshalBytes(buf) // escapes: fallback.
   457          return length, err
   458      }
   459  
   460      // Construct a slice backed by dst's underlying memory.
   461      var buf []byte
   462      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   463      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
   464      hdr.Len = u.SizeBytes()
   465      hdr.Cap = u.SizeBytes()
   466  
   467      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   468      // Since we bypassed the compiler's escape analysis, indicate that u
   469      // must live until the use above.
   470      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
   471      return length, err
   472  }
   473  
   474  // CopyIn implements marshal.Marshallable.CopyIn.
   475  func (u *UContext64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   476      return u.CopyInN(cc, addr, u.SizeBytes())
   477  }
   478  
   479  // WriteTo implements io.WriterTo.WriteTo.
   480  func (u *UContext64) WriteTo(writer io.Writer) (int64, error) {
   481      if !u.MContext.Packed() && u.Sigset.Packed() && u.Stack.Packed() {
   482          // Type UContext64 doesn't have a packed layout in memory, fall back to MarshalBytes.
   483          buf := make([]byte, u.SizeBytes())
   484          u.MarshalBytes(buf)
   485          length, err := writer.Write(buf)
   486          return int64(length), err
   487      }
   488  
   489      // Construct a slice backed by dst's underlying memory.
   490      var buf []byte
   491      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   492      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
   493      hdr.Len = u.SizeBytes()
   494      hdr.Cap = u.SizeBytes()
   495  
   496      length, err := writer.Write(buf)
   497      // Since we bypassed the compiler's escape analysis, indicate that u
   498      // must live until the use above.
   499      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
   500      return int64(length), err
   501  }
   502  
   503  // SizeBytes implements marshal.Marshallable.SizeBytes.
   504  func (a *aarch64Ctx) SizeBytes() int {
   505      return 8
   506  }
   507  
   508  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   509  func (a *aarch64Ctx) MarshalBytes(dst []byte) []byte {
   510      hostarch.ByteOrder.PutUint32(dst[:4], uint32(a.Magic))
   511      dst = dst[4:]
   512      hostarch.ByteOrder.PutUint32(dst[:4], uint32(a.Size))
   513      dst = dst[4:]
   514      return dst
   515  }
   516  
   517  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   518  func (a *aarch64Ctx) UnmarshalBytes(src []byte) []byte {
   519      a.Magic = uint32(hostarch.ByteOrder.Uint32(src[:4]))
   520      src = src[4:]
   521      a.Size = uint32(hostarch.ByteOrder.Uint32(src[:4]))
   522      src = src[4:]
   523      return src
   524  }
   525  
   526  // Packed implements marshal.Marshallable.Packed.
   527  //go:nosplit
   528  func (a *aarch64Ctx) Packed() bool {
   529      return true
   530  }
   531  
   532  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   533  func (a *aarch64Ctx) MarshalUnsafe(dst []byte) []byte {
   534      size := a.SizeBytes()
   535      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(a), uintptr(size))
   536      return dst[size:]
   537  }
   538  
   539  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   540  func (a *aarch64Ctx) UnmarshalUnsafe(src []byte) []byte {
   541      size := a.SizeBytes()
   542      gohacks.Memmove(unsafe.Pointer(a), unsafe.Pointer(&src[0]), uintptr(size))
   543      return src[size:]
   544  }
   545  
   546  // CopyOutN implements marshal.Marshallable.CopyOutN.
   547  func (a *aarch64Ctx) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   548      // Construct a slice backed by dst's underlying memory.
   549      var buf []byte
   550      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   551      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a)))
   552      hdr.Len = a.SizeBytes()
   553      hdr.Cap = a.SizeBytes()
   554  
   555      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   556      // Since we bypassed the compiler's escape analysis, indicate that a
   557      // must live until the use above.
   558      runtime.KeepAlive(a) // escapes: replaced by intrinsic.
   559      return length, err
   560  }
   561  
   562  // CopyOut implements marshal.Marshallable.CopyOut.
   563  func (a *aarch64Ctx) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   564      return a.CopyOutN(cc, addr, a.SizeBytes())
   565  }
   566  
   567  // CopyInN implements marshal.Marshallable.CopyInN.
   568  func (a *aarch64Ctx) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   569      // Construct a slice backed by dst's underlying memory.
   570      var buf []byte
   571      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   572      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a)))
   573      hdr.Len = a.SizeBytes()
   574      hdr.Cap = a.SizeBytes()
   575  
   576      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   577      // Since we bypassed the compiler's escape analysis, indicate that a
   578      // must live until the use above.
   579      runtime.KeepAlive(a) // escapes: replaced by intrinsic.
   580      return length, err
   581  }
   582  
   583  // CopyIn implements marshal.Marshallable.CopyIn.
   584  func (a *aarch64Ctx) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   585      return a.CopyInN(cc, addr, a.SizeBytes())
   586  }
   587  
   588  // WriteTo implements io.WriterTo.WriteTo.
   589  func (a *aarch64Ctx) WriteTo(writer io.Writer) (int64, error) {
   590      // Construct a slice backed by dst's underlying memory.
   591      var buf []byte
   592      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   593      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a)))
   594      hdr.Len = a.SizeBytes()
   595      hdr.Cap = a.SizeBytes()
   596  
   597      length, err := writer.Write(buf)
   598      // Since we bypassed the compiler's escape analysis, indicate that a
   599      // must live until the use above.
   600      runtime.KeepAlive(a) // escapes: replaced by intrinsic.
   601      return int64(length), err
   602  }
   603