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