github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/marshal/primitive/primitive_abi_autogen_unsafe.go (about)

     1  // Automatically generated marshal implementation. See tools/go_marshal.
     2  
     3  package primitive
     4  
     5  import (
     6  	"github.com/nicocha30/gvisor-ligolo/pkg/gohacks"
     7  	"github.com/nicocha30/gvisor-ligolo/pkg/hostarch"
     8  	"github.com/nicocha30/gvisor-ligolo/pkg/marshal"
     9      "io"
    10      "reflect"
    11      "runtime"
    12      "unsafe"
    13  )
    14  
    15  // Marshallable types used by this file.
    16  var _ marshal.Marshallable = (*Int16)(nil)
    17  var _ marshal.Marshallable = (*Int32)(nil)
    18  var _ marshal.Marshallable = (*Int64)(nil)
    19  var _ marshal.Marshallable = (*Int8)(nil)
    20  var _ marshal.Marshallable = (*Uint16)(nil)
    21  var _ marshal.Marshallable = (*Uint32)(nil)
    22  var _ marshal.Marshallable = (*Uint64)(nil)
    23  var _ marshal.Marshallable = (*Uint8)(nil)
    24  
    25  // SizeBytes implements marshal.Marshallable.SizeBytes.
    26  //go:nosplit
    27  func (i *Int16) SizeBytes() int {
    28      return 2
    29  }
    30  
    31  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
    32  func (i *Int16) MarshalBytes(dst []byte) []byte {
    33      hostarch.ByteOrder.PutUint16(dst[:2], uint16(*i))
    34      return dst[2:]
    35  }
    36  
    37  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
    38  func (i *Int16) UnmarshalBytes(src []byte) []byte {
    39      *i = Int16(int16(hostarch.ByteOrder.Uint16(src[:2])))
    40      return src[2:]
    41  }
    42  
    43  // Packed implements marshal.Marshallable.Packed.
    44  //go:nosplit
    45  func (i *Int16) Packed() bool {
    46      // Scalar newtypes are always packed.
    47      return true
    48  }
    49  
    50  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
    51  func (i *Int16) MarshalUnsafe(dst []byte) []byte {
    52      size := i.SizeBytes()
    53      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
    54      return dst[size:]
    55  }
    56  
    57  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
    58  func (i *Int16) UnmarshalUnsafe(src []byte) []byte {
    59      size := i.SizeBytes()
    60      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
    61      return src[size:]
    62  }
    63  
    64  // CopyOutN implements marshal.Marshallable.CopyOutN.
    65  func (i *Int16) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    66      // Construct a slice backed by dst's underlying memory.
    67      var buf []byte
    68      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
    69      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
    70      hdr.Len = i.SizeBytes()
    71      hdr.Cap = i.SizeBytes()
    72  
    73      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
    74      // Since we bypassed the compiler's escape analysis, indicate that i
    75      // must live until the use above.
    76      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
    77      return length, err
    78  }
    79  
    80  // CopyOut implements marshal.Marshallable.CopyOut.
    81  func (i *Int16) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    82      return i.CopyOutN(cc, addr, i.SizeBytes())
    83  }
    84  
    85  // CopyIn implements marshal.Marshallable.CopyIn.
    86  func (i *Int16) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    87      // Construct a slice backed by dst's underlying memory.
    88      var buf []byte
    89      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
    90      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
    91      hdr.Len = i.SizeBytes()
    92      hdr.Cap = i.SizeBytes()
    93  
    94      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
    95      // Since we bypassed the compiler's escape analysis, indicate that i
    96      // must live until the use above.
    97      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
    98      return length, err
    99  }
   100  
   101  // WriteTo implements io.WriterTo.WriteTo.
   102  func (i *Int16) WriteTo(writer io.Writer) (int64, error) {
   103      // Construct a slice backed by dst's underlying memory.
   104      var buf []byte
   105      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   106      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   107      hdr.Len = i.SizeBytes()
   108      hdr.Cap = i.SizeBytes()
   109  
   110      length, err := writer.Write(buf)
   111      // Since we bypassed the compiler's escape analysis, indicate that i
   112      // must live until the use above.
   113      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   114      return int64(length), err
   115  }
   116  
   117  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
   118  func (i *Int16) CheckedMarshal(dst []byte) ([]byte, bool) {
   119      size := i.SizeBytes()
   120      if size > len(dst) {
   121          return dst, false
   122      }
   123      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   124      return dst[size:], true
   125  }
   126  
   127  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
   128  func (i *Int16) CheckedUnmarshal(src []byte) ([]byte, bool) {
   129      size := i.SizeBytes()
   130      if size > len(src) {
   131          return src, false
   132      }
   133      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   134      return src[size:], true
   135  }
   136  
   137  // CopyInt16SliceIn copies in a slice of int16 objects from the task's memory.
   138  func CopyInt16SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []int16) (int, error) {
   139      count := len(dst)
   140      if count == 0 {
   141          return 0, nil
   142      }
   143      size := (*Int16)(nil).SizeBytes()
   144  
   145      ptr := unsafe.Pointer(&dst)
   146      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   147  
   148      // Construct a slice backed by dst's underlying memory.
   149      var buf []byte
   150      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   151      hdr.Data = uintptr(val)
   152      hdr.Len = size * count
   153      hdr.Cap = size * count
   154  
   155      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   156      // Since we bypassed the compiler's escape analysis, indicate that dst
   157      // must live until the use above.
   158      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
   159      return length, err
   160  }
   161  
   162  // CopyInt16SliceOut copies a slice of int16 objects to the task's memory.
   163  func CopyInt16SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int16) (int, error) {
   164      count := len(src)
   165      if count == 0 {
   166          return 0, nil
   167      }
   168      size := (*Int16)(nil).SizeBytes()
   169  
   170      ptr := unsafe.Pointer(&src)
   171      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   172  
   173      // Construct a slice backed by dst's underlying memory.
   174      var buf []byte
   175      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   176      hdr.Data = uintptr(val)
   177      hdr.Len = size * count
   178      hdr.Cap = size * count
   179  
   180      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
   181      // Since we bypassed the compiler's escape analysis, indicate that src
   182      // must live until the use above.
   183      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
   184      return length, err
   185  }
   186  
   187  // MarshalUnsafeInt16Slice is like Int16.MarshalUnsafe, but for a []Int16.
   188  func MarshalUnsafeInt16Slice(src []Int16, dst []byte) []byte {
   189      count := len(src)
   190      if count == 0 {
   191          return dst
   192      }
   193      size := (*Int16)(nil).SizeBytes()
   194  
   195      buf := dst[:size*count]
   196      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
   197      return dst[size*count:]
   198  }
   199  
   200  // UnmarshalUnsafeInt16Slice is like Int16.UnmarshalUnsafe, but for a []Int16.
   201  func UnmarshalUnsafeInt16Slice(dst []Int16, src []byte) []byte {
   202      count := len(dst)
   203      if count == 0 {
   204          return src
   205      }
   206      size := (*Int16)(nil).SizeBytes()
   207  
   208      buf := src[:size*count]
   209      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
   210      return src[size*count:]
   211  }
   212  
   213  // SizeBytes implements marshal.Marshallable.SizeBytes.
   214  //go:nosplit
   215  func (i *Int32) SizeBytes() int {
   216      return 4
   217  }
   218  
   219  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   220  func (i *Int32) MarshalBytes(dst []byte) []byte {
   221      hostarch.ByteOrder.PutUint32(dst[:4], uint32(*i))
   222      return dst[4:]
   223  }
   224  
   225  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   226  func (i *Int32) UnmarshalBytes(src []byte) []byte {
   227      *i = Int32(int32(hostarch.ByteOrder.Uint32(src[:4])))
   228      return src[4:]
   229  }
   230  
   231  // Packed implements marshal.Marshallable.Packed.
   232  //go:nosplit
   233  func (i *Int32) Packed() bool {
   234      // Scalar newtypes are always packed.
   235      return true
   236  }
   237  
   238  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   239  func (i *Int32) MarshalUnsafe(dst []byte) []byte {
   240      size := i.SizeBytes()
   241      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   242      return dst[size:]
   243  }
   244  
   245  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   246  func (i *Int32) UnmarshalUnsafe(src []byte) []byte {
   247      size := i.SizeBytes()
   248      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   249      return src[size:]
   250  }
   251  
   252  // CopyOutN implements marshal.Marshallable.CopyOutN.
   253  func (i *Int32) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   254      // Construct a slice backed by dst's underlying memory.
   255      var buf []byte
   256      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   257      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   258      hdr.Len = i.SizeBytes()
   259      hdr.Cap = i.SizeBytes()
   260  
   261      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   262      // Since we bypassed the compiler's escape analysis, indicate that i
   263      // must live until the use above.
   264      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   265      return length, err
   266  }
   267  
   268  // CopyOut implements marshal.Marshallable.CopyOut.
   269  func (i *Int32) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   270      return i.CopyOutN(cc, addr, i.SizeBytes())
   271  }
   272  
   273  // CopyIn implements marshal.Marshallable.CopyIn.
   274  func (i *Int32) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   275      // Construct a slice backed by dst's underlying memory.
   276      var buf []byte
   277      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   278      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   279      hdr.Len = i.SizeBytes()
   280      hdr.Cap = i.SizeBytes()
   281  
   282      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   283      // Since we bypassed the compiler's escape analysis, indicate that i
   284      // must live until the use above.
   285      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   286      return length, err
   287  }
   288  
   289  // WriteTo implements io.WriterTo.WriteTo.
   290  func (i *Int32) WriteTo(writer io.Writer) (int64, error) {
   291      // Construct a slice backed by dst's underlying memory.
   292      var buf []byte
   293      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   294      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   295      hdr.Len = i.SizeBytes()
   296      hdr.Cap = i.SizeBytes()
   297  
   298      length, err := writer.Write(buf)
   299      // Since we bypassed the compiler's escape analysis, indicate that i
   300      // must live until the use above.
   301      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   302      return int64(length), err
   303  }
   304  
   305  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
   306  func (i *Int32) CheckedMarshal(dst []byte) ([]byte, bool) {
   307      size := i.SizeBytes()
   308      if size > len(dst) {
   309          return dst, false
   310      }
   311      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   312      return dst[size:], true
   313  }
   314  
   315  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
   316  func (i *Int32) CheckedUnmarshal(src []byte) ([]byte, bool) {
   317      size := i.SizeBytes()
   318      if size > len(src) {
   319          return src, false
   320      }
   321      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   322      return src[size:], true
   323  }
   324  
   325  // CopyInt32SliceIn copies in a slice of int32 objects from the task's memory.
   326  func CopyInt32SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []int32) (int, error) {
   327      count := len(dst)
   328      if count == 0 {
   329          return 0, nil
   330      }
   331      size := (*Int32)(nil).SizeBytes()
   332  
   333      ptr := unsafe.Pointer(&dst)
   334      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   335  
   336      // Construct a slice backed by dst's underlying memory.
   337      var buf []byte
   338      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   339      hdr.Data = uintptr(val)
   340      hdr.Len = size * count
   341      hdr.Cap = size * count
   342  
   343      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   344      // Since we bypassed the compiler's escape analysis, indicate that dst
   345      // must live until the use above.
   346      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
   347      return length, err
   348  }
   349  
   350  // CopyInt32SliceOut copies a slice of int32 objects to the task's memory.
   351  func CopyInt32SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int32) (int, error) {
   352      count := len(src)
   353      if count == 0 {
   354          return 0, nil
   355      }
   356      size := (*Int32)(nil).SizeBytes()
   357  
   358      ptr := unsafe.Pointer(&src)
   359      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   360  
   361      // Construct a slice backed by dst's underlying memory.
   362      var buf []byte
   363      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   364      hdr.Data = uintptr(val)
   365      hdr.Len = size * count
   366      hdr.Cap = size * count
   367  
   368      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
   369      // Since we bypassed the compiler's escape analysis, indicate that src
   370      // must live until the use above.
   371      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
   372      return length, err
   373  }
   374  
   375  // MarshalUnsafeInt32Slice is like Int32.MarshalUnsafe, but for a []Int32.
   376  func MarshalUnsafeInt32Slice(src []Int32, dst []byte) []byte {
   377      count := len(src)
   378      if count == 0 {
   379          return dst
   380      }
   381      size := (*Int32)(nil).SizeBytes()
   382  
   383      buf := dst[:size*count]
   384      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
   385      return dst[size*count:]
   386  }
   387  
   388  // UnmarshalUnsafeInt32Slice is like Int32.UnmarshalUnsafe, but for a []Int32.
   389  func UnmarshalUnsafeInt32Slice(dst []Int32, src []byte) []byte {
   390      count := len(dst)
   391      if count == 0 {
   392          return src
   393      }
   394      size := (*Int32)(nil).SizeBytes()
   395  
   396      buf := src[:size*count]
   397      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
   398      return src[size*count:]
   399  }
   400  
   401  // SizeBytes implements marshal.Marshallable.SizeBytes.
   402  //go:nosplit
   403  func (i *Int64) SizeBytes() int {
   404      return 8
   405  }
   406  
   407  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   408  func (i *Int64) MarshalBytes(dst []byte) []byte {
   409      hostarch.ByteOrder.PutUint64(dst[:8], uint64(*i))
   410      return dst[8:]
   411  }
   412  
   413  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   414  func (i *Int64) UnmarshalBytes(src []byte) []byte {
   415      *i = Int64(int64(hostarch.ByteOrder.Uint64(src[:8])))
   416      return src[8:]
   417  }
   418  
   419  // Packed implements marshal.Marshallable.Packed.
   420  //go:nosplit
   421  func (i *Int64) Packed() bool {
   422      // Scalar newtypes are always packed.
   423      return true
   424  }
   425  
   426  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   427  func (i *Int64) MarshalUnsafe(dst []byte) []byte {
   428      size := i.SizeBytes()
   429      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   430      return dst[size:]
   431  }
   432  
   433  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   434  func (i *Int64) UnmarshalUnsafe(src []byte) []byte {
   435      size := i.SizeBytes()
   436      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   437      return src[size:]
   438  }
   439  
   440  // CopyOutN implements marshal.Marshallable.CopyOutN.
   441  func (i *Int64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   442      // Construct a slice backed by dst's underlying memory.
   443      var buf []byte
   444      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   445      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   446      hdr.Len = i.SizeBytes()
   447      hdr.Cap = i.SizeBytes()
   448  
   449      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   450      // Since we bypassed the compiler's escape analysis, indicate that i
   451      // must live until the use above.
   452      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   453      return length, err
   454  }
   455  
   456  // CopyOut implements marshal.Marshallable.CopyOut.
   457  func (i *Int64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   458      return i.CopyOutN(cc, addr, i.SizeBytes())
   459  }
   460  
   461  // CopyIn implements marshal.Marshallable.CopyIn.
   462  func (i *Int64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   463      // Construct a slice backed by dst's underlying memory.
   464      var buf []byte
   465      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   466      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   467      hdr.Len = i.SizeBytes()
   468      hdr.Cap = i.SizeBytes()
   469  
   470      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   471      // Since we bypassed the compiler's escape analysis, indicate that i
   472      // must live until the use above.
   473      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   474      return length, err
   475  }
   476  
   477  // WriteTo implements io.WriterTo.WriteTo.
   478  func (i *Int64) WriteTo(writer io.Writer) (int64, error) {
   479      // Construct a slice backed by dst's underlying memory.
   480      var buf []byte
   481      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   482      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   483      hdr.Len = i.SizeBytes()
   484      hdr.Cap = i.SizeBytes()
   485  
   486      length, err := writer.Write(buf)
   487      // Since we bypassed the compiler's escape analysis, indicate that i
   488      // must live until the use above.
   489      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   490      return int64(length), err
   491  }
   492  
   493  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
   494  func (i *Int64) CheckedMarshal(dst []byte) ([]byte, bool) {
   495      size := i.SizeBytes()
   496      if size > len(dst) {
   497          return dst, false
   498      }
   499      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   500      return dst[size:], true
   501  }
   502  
   503  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
   504  func (i *Int64) CheckedUnmarshal(src []byte) ([]byte, bool) {
   505      size := i.SizeBytes()
   506      if size > len(src) {
   507          return src, false
   508      }
   509      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   510      return src[size:], true
   511  }
   512  
   513  // CopyInt64SliceIn copies in a slice of int64 objects from the task's memory.
   514  func CopyInt64SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []int64) (int, error) {
   515      count := len(dst)
   516      if count == 0 {
   517          return 0, nil
   518      }
   519      size := (*Int64)(nil).SizeBytes()
   520  
   521      ptr := unsafe.Pointer(&dst)
   522      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   523  
   524      // Construct a slice backed by dst's underlying memory.
   525      var buf []byte
   526      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   527      hdr.Data = uintptr(val)
   528      hdr.Len = size * count
   529      hdr.Cap = size * count
   530  
   531      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   532      // Since we bypassed the compiler's escape analysis, indicate that dst
   533      // must live until the use above.
   534      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
   535      return length, err
   536  }
   537  
   538  // CopyInt64SliceOut copies a slice of int64 objects to the task's memory.
   539  func CopyInt64SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int64) (int, error) {
   540      count := len(src)
   541      if count == 0 {
   542          return 0, nil
   543      }
   544      size := (*Int64)(nil).SizeBytes()
   545  
   546      ptr := unsafe.Pointer(&src)
   547      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   548  
   549      // Construct a slice backed by dst's underlying memory.
   550      var buf []byte
   551      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   552      hdr.Data = uintptr(val)
   553      hdr.Len = size * count
   554      hdr.Cap = size * count
   555  
   556      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
   557      // Since we bypassed the compiler's escape analysis, indicate that src
   558      // must live until the use above.
   559      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
   560      return length, err
   561  }
   562  
   563  // MarshalUnsafeInt64Slice is like Int64.MarshalUnsafe, but for a []Int64.
   564  func MarshalUnsafeInt64Slice(src []Int64, dst []byte) []byte {
   565      count := len(src)
   566      if count == 0 {
   567          return dst
   568      }
   569      size := (*Int64)(nil).SizeBytes()
   570  
   571      buf := dst[:size*count]
   572      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
   573      return dst[size*count:]
   574  }
   575  
   576  // UnmarshalUnsafeInt64Slice is like Int64.UnmarshalUnsafe, but for a []Int64.
   577  func UnmarshalUnsafeInt64Slice(dst []Int64, src []byte) []byte {
   578      count := len(dst)
   579      if count == 0 {
   580          return src
   581      }
   582      size := (*Int64)(nil).SizeBytes()
   583  
   584      buf := src[:size*count]
   585      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
   586      return src[size*count:]
   587  }
   588  
   589  // SizeBytes implements marshal.Marshallable.SizeBytes.
   590  //go:nosplit
   591  func (i *Int8) SizeBytes() int {
   592      return 1
   593  }
   594  
   595  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   596  func (i *Int8) MarshalBytes(dst []byte) []byte {
   597      dst[0] = byte(*i)
   598      return dst[1:]
   599  }
   600  
   601  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   602  func (i *Int8) UnmarshalBytes(src []byte) []byte {
   603      *i = Int8(int8(src[0]))
   604      return src[1:]
   605  }
   606  
   607  // Packed implements marshal.Marshallable.Packed.
   608  //go:nosplit
   609  func (i *Int8) Packed() bool {
   610      // Scalar newtypes are always packed.
   611      return true
   612  }
   613  
   614  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   615  func (i *Int8) MarshalUnsafe(dst []byte) []byte {
   616      size := i.SizeBytes()
   617      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   618      return dst[size:]
   619  }
   620  
   621  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   622  func (i *Int8) UnmarshalUnsafe(src []byte) []byte {
   623      size := i.SizeBytes()
   624      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   625      return src[size:]
   626  }
   627  
   628  // CopyOutN implements marshal.Marshallable.CopyOutN.
   629  func (i *Int8) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   630      // Construct a slice backed by dst's underlying memory.
   631      var buf []byte
   632      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   633      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   634      hdr.Len = i.SizeBytes()
   635      hdr.Cap = i.SizeBytes()
   636  
   637      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   638      // Since we bypassed the compiler's escape analysis, indicate that i
   639      // must live until the use above.
   640      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   641      return length, err
   642  }
   643  
   644  // CopyOut implements marshal.Marshallable.CopyOut.
   645  func (i *Int8) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   646      return i.CopyOutN(cc, addr, i.SizeBytes())
   647  }
   648  
   649  // CopyIn implements marshal.Marshallable.CopyIn.
   650  func (i *Int8) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   651      // Construct a slice backed by dst's underlying memory.
   652      var buf []byte
   653      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   654      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   655      hdr.Len = i.SizeBytes()
   656      hdr.Cap = i.SizeBytes()
   657  
   658      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   659      // Since we bypassed the compiler's escape analysis, indicate that i
   660      // must live until the use above.
   661      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   662      return length, err
   663  }
   664  
   665  // WriteTo implements io.WriterTo.WriteTo.
   666  func (i *Int8) WriteTo(writer io.Writer) (int64, error) {
   667      // Construct a slice backed by dst's underlying memory.
   668      var buf []byte
   669      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   670      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i)))
   671      hdr.Len = i.SizeBytes()
   672      hdr.Cap = i.SizeBytes()
   673  
   674      length, err := writer.Write(buf)
   675      // Since we bypassed the compiler's escape analysis, indicate that i
   676      // must live until the use above.
   677      runtime.KeepAlive(i) // escapes: replaced by intrinsic.
   678      return int64(length), err
   679  }
   680  
   681  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
   682  func (i *Int8) CheckedMarshal(dst []byte) ([]byte, bool) {
   683      size := i.SizeBytes()
   684      if size > len(dst) {
   685          return dst, false
   686      }
   687      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size))
   688      return dst[size:], true
   689  }
   690  
   691  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
   692  func (i *Int8) CheckedUnmarshal(src []byte) ([]byte, bool) {
   693      size := i.SizeBytes()
   694      if size > len(src) {
   695          return src, false
   696      }
   697      gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size))
   698      return src[size:], true
   699  }
   700  
   701  // CopyInt8SliceIn copies in a slice of int8 objects from the task's memory.
   702  func CopyInt8SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []int8) (int, error) {
   703      count := len(dst)
   704      if count == 0 {
   705          return 0, nil
   706      }
   707      size := (*Int8)(nil).SizeBytes()
   708  
   709      ptr := unsafe.Pointer(&dst)
   710      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   711  
   712      // Construct a slice backed by dst's underlying memory.
   713      var buf []byte
   714      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   715      hdr.Data = uintptr(val)
   716      hdr.Len = size * count
   717      hdr.Cap = size * count
   718  
   719      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   720      // Since we bypassed the compiler's escape analysis, indicate that dst
   721      // must live until the use above.
   722      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
   723      return length, err
   724  }
   725  
   726  // CopyInt8SliceOut copies a slice of int8 objects to the task's memory.
   727  func CopyInt8SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []int8) (int, error) {
   728      count := len(src)
   729      if count == 0 {
   730          return 0, nil
   731      }
   732      size := (*Int8)(nil).SizeBytes()
   733  
   734      ptr := unsafe.Pointer(&src)
   735      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   736  
   737      // Construct a slice backed by dst's underlying memory.
   738      var buf []byte
   739      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   740      hdr.Data = uintptr(val)
   741      hdr.Len = size * count
   742      hdr.Cap = size * count
   743  
   744      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
   745      // Since we bypassed the compiler's escape analysis, indicate that src
   746      // must live until the use above.
   747      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
   748      return length, err
   749  }
   750  
   751  // MarshalUnsafeInt8Slice is like Int8.MarshalUnsafe, but for a []Int8.
   752  func MarshalUnsafeInt8Slice(src []Int8, dst []byte) []byte {
   753      count := len(src)
   754      if count == 0 {
   755          return dst
   756      }
   757      size := (*Int8)(nil).SizeBytes()
   758  
   759      buf := dst[:size*count]
   760      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
   761      return dst[size*count:]
   762  }
   763  
   764  // UnmarshalUnsafeInt8Slice is like Int8.UnmarshalUnsafe, but for a []Int8.
   765  func UnmarshalUnsafeInt8Slice(dst []Int8, src []byte) []byte {
   766      count := len(dst)
   767      if count == 0 {
   768          return src
   769      }
   770      size := (*Int8)(nil).SizeBytes()
   771  
   772      buf := src[:size*count]
   773      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
   774      return src[size*count:]
   775  }
   776  
   777  // SizeBytes implements marshal.Marshallable.SizeBytes.
   778  //go:nosplit
   779  func (u *Uint16) SizeBytes() int {
   780      return 2
   781  }
   782  
   783  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   784  func (u *Uint16) MarshalBytes(dst []byte) []byte {
   785      hostarch.ByteOrder.PutUint16(dst[:2], uint16(*u))
   786      return dst[2:]
   787  }
   788  
   789  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   790  func (u *Uint16) UnmarshalBytes(src []byte) []byte {
   791      *u = Uint16(uint16(hostarch.ByteOrder.Uint16(src[:2])))
   792      return src[2:]
   793  }
   794  
   795  // Packed implements marshal.Marshallable.Packed.
   796  //go:nosplit
   797  func (u *Uint16) Packed() bool {
   798      // Scalar newtypes are always packed.
   799      return true
   800  }
   801  
   802  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   803  func (u *Uint16) MarshalUnsafe(dst []byte) []byte {
   804      size := u.SizeBytes()
   805      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
   806      return dst[size:]
   807  }
   808  
   809  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   810  func (u *Uint16) UnmarshalUnsafe(src []byte) []byte {
   811      size := u.SizeBytes()
   812      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
   813      return src[size:]
   814  }
   815  
   816  // CopyOutN implements marshal.Marshallable.CopyOutN.
   817  func (u *Uint16) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   818      // Construct a slice backed by dst's underlying memory.
   819      var buf []byte
   820      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   821      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
   822      hdr.Len = u.SizeBytes()
   823      hdr.Cap = u.SizeBytes()
   824  
   825      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   826      // Since we bypassed the compiler's escape analysis, indicate that u
   827      // must live until the use above.
   828      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
   829      return length, err
   830  }
   831  
   832  // CopyOut implements marshal.Marshallable.CopyOut.
   833  func (u *Uint16) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   834      return u.CopyOutN(cc, addr, u.SizeBytes())
   835  }
   836  
   837  // CopyIn implements marshal.Marshallable.CopyIn.
   838  func (u *Uint16) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   839      // Construct a slice backed by dst's underlying memory.
   840      var buf []byte
   841      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   842      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
   843      hdr.Len = u.SizeBytes()
   844      hdr.Cap = u.SizeBytes()
   845  
   846      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   847      // Since we bypassed the compiler's escape analysis, indicate that u
   848      // must live until the use above.
   849      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
   850      return length, err
   851  }
   852  
   853  // WriteTo implements io.WriterTo.WriteTo.
   854  func (u *Uint16) WriteTo(writer io.Writer) (int64, error) {
   855      // Construct a slice backed by dst's underlying memory.
   856      var buf []byte
   857      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   858      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
   859      hdr.Len = u.SizeBytes()
   860      hdr.Cap = u.SizeBytes()
   861  
   862      length, err := writer.Write(buf)
   863      // Since we bypassed the compiler's escape analysis, indicate that u
   864      // must live until the use above.
   865      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
   866      return int64(length), err
   867  }
   868  
   869  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
   870  func (u *Uint16) CheckedMarshal(dst []byte) ([]byte, bool) {
   871      size := u.SizeBytes()
   872      if size > len(dst) {
   873          return dst, false
   874      }
   875      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
   876      return dst[size:], true
   877  }
   878  
   879  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
   880  func (u *Uint16) CheckedUnmarshal(src []byte) ([]byte, bool) {
   881      size := u.SizeBytes()
   882      if size > len(src) {
   883          return src, false
   884      }
   885      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
   886      return src[size:], true
   887  }
   888  
   889  // CopyUint16SliceIn copies in a slice of uint16 objects from the task's memory.
   890  func CopyUint16SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []uint16) (int, error) {
   891      count := len(dst)
   892      if count == 0 {
   893          return 0, nil
   894      }
   895      size := (*Uint16)(nil).SizeBytes()
   896  
   897      ptr := unsafe.Pointer(&dst)
   898      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   899  
   900      // Construct a slice backed by dst's underlying memory.
   901      var buf []byte
   902      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   903      hdr.Data = uintptr(val)
   904      hdr.Len = size * count
   905      hdr.Cap = size * count
   906  
   907      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   908      // Since we bypassed the compiler's escape analysis, indicate that dst
   909      // must live until the use above.
   910      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
   911      return length, err
   912  }
   913  
   914  // CopyUint16SliceOut copies a slice of uint16 objects to the task's memory.
   915  func CopyUint16SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint16) (int, error) {
   916      count := len(src)
   917      if count == 0 {
   918          return 0, nil
   919      }
   920      size := (*Uint16)(nil).SizeBytes()
   921  
   922      ptr := unsafe.Pointer(&src)
   923      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
   924  
   925      // Construct a slice backed by dst's underlying memory.
   926      var buf []byte
   927      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   928      hdr.Data = uintptr(val)
   929      hdr.Len = size * count
   930      hdr.Cap = size * count
   931  
   932      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
   933      // Since we bypassed the compiler's escape analysis, indicate that src
   934      // must live until the use above.
   935      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
   936      return length, err
   937  }
   938  
   939  // MarshalUnsafeUint16Slice is like Uint16.MarshalUnsafe, but for a []Uint16.
   940  func MarshalUnsafeUint16Slice(src []Uint16, dst []byte) []byte {
   941      count := len(src)
   942      if count == 0 {
   943          return dst
   944      }
   945      size := (*Uint16)(nil).SizeBytes()
   946  
   947      buf := dst[:size*count]
   948      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
   949      return dst[size*count:]
   950  }
   951  
   952  // UnmarshalUnsafeUint16Slice is like Uint16.UnmarshalUnsafe, but for a []Uint16.
   953  func UnmarshalUnsafeUint16Slice(dst []Uint16, src []byte) []byte {
   954      count := len(dst)
   955      if count == 0 {
   956          return src
   957      }
   958      size := (*Uint16)(nil).SizeBytes()
   959  
   960      buf := src[:size*count]
   961      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
   962      return src[size*count:]
   963  }
   964  
   965  // SizeBytes implements marshal.Marshallable.SizeBytes.
   966  //go:nosplit
   967  func (u *Uint32) SizeBytes() int {
   968      return 4
   969  }
   970  
   971  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   972  func (u *Uint32) MarshalBytes(dst []byte) []byte {
   973      hostarch.ByteOrder.PutUint32(dst[:4], uint32(*u))
   974      return dst[4:]
   975  }
   976  
   977  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   978  func (u *Uint32) UnmarshalBytes(src []byte) []byte {
   979      *u = Uint32(uint32(hostarch.ByteOrder.Uint32(src[:4])))
   980      return src[4:]
   981  }
   982  
   983  // Packed implements marshal.Marshallable.Packed.
   984  //go:nosplit
   985  func (u *Uint32) Packed() bool {
   986      // Scalar newtypes are always packed.
   987      return true
   988  }
   989  
   990  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   991  func (u *Uint32) MarshalUnsafe(dst []byte) []byte {
   992      size := u.SizeBytes()
   993      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
   994      return dst[size:]
   995  }
   996  
   997  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   998  func (u *Uint32) UnmarshalUnsafe(src []byte) []byte {
   999      size := u.SizeBytes()
  1000      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
  1001      return src[size:]
  1002  }
  1003  
  1004  // CopyOutN implements marshal.Marshallable.CopyOutN.
  1005  func (u *Uint32) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
  1006      // Construct a slice backed by dst's underlying memory.
  1007      var buf []byte
  1008      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1009      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1010      hdr.Len = u.SizeBytes()
  1011      hdr.Cap = u.SizeBytes()
  1012  
  1013      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
  1014      // Since we bypassed the compiler's escape analysis, indicate that u
  1015      // must live until the use above.
  1016      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1017      return length, err
  1018  }
  1019  
  1020  // CopyOut implements marshal.Marshallable.CopyOut.
  1021  func (u *Uint32) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
  1022      return u.CopyOutN(cc, addr, u.SizeBytes())
  1023  }
  1024  
  1025  // CopyIn implements marshal.Marshallable.CopyIn.
  1026  func (u *Uint32) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
  1027      // Construct a slice backed by dst's underlying memory.
  1028      var buf []byte
  1029      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1030      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1031      hdr.Len = u.SizeBytes()
  1032      hdr.Cap = u.SizeBytes()
  1033  
  1034      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
  1035      // Since we bypassed the compiler's escape analysis, indicate that u
  1036      // must live until the use above.
  1037      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1038      return length, err
  1039  }
  1040  
  1041  // WriteTo implements io.WriterTo.WriteTo.
  1042  func (u *Uint32) WriteTo(writer io.Writer) (int64, error) {
  1043      // Construct a slice backed by dst's underlying memory.
  1044      var buf []byte
  1045      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1046      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1047      hdr.Len = u.SizeBytes()
  1048      hdr.Cap = u.SizeBytes()
  1049  
  1050      length, err := writer.Write(buf)
  1051      // Since we bypassed the compiler's escape analysis, indicate that u
  1052      // must live until the use above.
  1053      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1054      return int64(length), err
  1055  }
  1056  
  1057  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
  1058  func (u *Uint32) CheckedMarshal(dst []byte) ([]byte, bool) {
  1059      size := u.SizeBytes()
  1060      if size > len(dst) {
  1061          return dst, false
  1062      }
  1063      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
  1064      return dst[size:], true
  1065  }
  1066  
  1067  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
  1068  func (u *Uint32) CheckedUnmarshal(src []byte) ([]byte, bool) {
  1069      size := u.SizeBytes()
  1070      if size > len(src) {
  1071          return src, false
  1072      }
  1073      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
  1074      return src[size:], true
  1075  }
  1076  
  1077  // CopyUint32SliceIn copies in a slice of uint32 objects from the task's memory.
  1078  func CopyUint32SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []uint32) (int, error) {
  1079      count := len(dst)
  1080      if count == 0 {
  1081          return 0, nil
  1082      }
  1083      size := (*Uint32)(nil).SizeBytes()
  1084  
  1085      ptr := unsafe.Pointer(&dst)
  1086      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
  1087  
  1088      // Construct a slice backed by dst's underlying memory.
  1089      var buf []byte
  1090      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1091      hdr.Data = uintptr(val)
  1092      hdr.Len = size * count
  1093      hdr.Cap = size * count
  1094  
  1095      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
  1096      // Since we bypassed the compiler's escape analysis, indicate that dst
  1097      // must live until the use above.
  1098      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
  1099      return length, err
  1100  }
  1101  
  1102  // CopyUint32SliceOut copies a slice of uint32 objects to the task's memory.
  1103  func CopyUint32SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint32) (int, error) {
  1104      count := len(src)
  1105      if count == 0 {
  1106          return 0, nil
  1107      }
  1108      size := (*Uint32)(nil).SizeBytes()
  1109  
  1110      ptr := unsafe.Pointer(&src)
  1111      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
  1112  
  1113      // Construct a slice backed by dst's underlying memory.
  1114      var buf []byte
  1115      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1116      hdr.Data = uintptr(val)
  1117      hdr.Len = size * count
  1118      hdr.Cap = size * count
  1119  
  1120      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
  1121      // Since we bypassed the compiler's escape analysis, indicate that src
  1122      // must live until the use above.
  1123      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
  1124      return length, err
  1125  }
  1126  
  1127  // MarshalUnsafeUint32Slice is like Uint32.MarshalUnsafe, but for a []Uint32.
  1128  func MarshalUnsafeUint32Slice(src []Uint32, dst []byte) []byte {
  1129      count := len(src)
  1130      if count == 0 {
  1131          return dst
  1132      }
  1133      size := (*Uint32)(nil).SizeBytes()
  1134  
  1135      buf := dst[:size*count]
  1136      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
  1137      return dst[size*count:]
  1138  }
  1139  
  1140  // UnmarshalUnsafeUint32Slice is like Uint32.UnmarshalUnsafe, but for a []Uint32.
  1141  func UnmarshalUnsafeUint32Slice(dst []Uint32, src []byte) []byte {
  1142      count := len(dst)
  1143      if count == 0 {
  1144          return src
  1145      }
  1146      size := (*Uint32)(nil).SizeBytes()
  1147  
  1148      buf := src[:size*count]
  1149      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
  1150      return src[size*count:]
  1151  }
  1152  
  1153  // SizeBytes implements marshal.Marshallable.SizeBytes.
  1154  //go:nosplit
  1155  func (u *Uint64) SizeBytes() int {
  1156      return 8
  1157  }
  1158  
  1159  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
  1160  func (u *Uint64) MarshalBytes(dst []byte) []byte {
  1161      hostarch.ByteOrder.PutUint64(dst[:8], uint64(*u))
  1162      return dst[8:]
  1163  }
  1164  
  1165  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
  1166  func (u *Uint64) UnmarshalBytes(src []byte) []byte {
  1167      *u = Uint64(uint64(hostarch.ByteOrder.Uint64(src[:8])))
  1168      return src[8:]
  1169  }
  1170  
  1171  // Packed implements marshal.Marshallable.Packed.
  1172  //go:nosplit
  1173  func (u *Uint64) Packed() bool {
  1174      // Scalar newtypes are always packed.
  1175      return true
  1176  }
  1177  
  1178  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
  1179  func (u *Uint64) MarshalUnsafe(dst []byte) []byte {
  1180      size := u.SizeBytes()
  1181      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
  1182      return dst[size:]
  1183  }
  1184  
  1185  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
  1186  func (u *Uint64) UnmarshalUnsafe(src []byte) []byte {
  1187      size := u.SizeBytes()
  1188      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
  1189      return src[size:]
  1190  }
  1191  
  1192  // CopyOutN implements marshal.Marshallable.CopyOutN.
  1193  func (u *Uint64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
  1194      // Construct a slice backed by dst's underlying memory.
  1195      var buf []byte
  1196      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1197      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1198      hdr.Len = u.SizeBytes()
  1199      hdr.Cap = u.SizeBytes()
  1200  
  1201      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
  1202      // Since we bypassed the compiler's escape analysis, indicate that u
  1203      // must live until the use above.
  1204      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1205      return length, err
  1206  }
  1207  
  1208  // CopyOut implements marshal.Marshallable.CopyOut.
  1209  func (u *Uint64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
  1210      return u.CopyOutN(cc, addr, u.SizeBytes())
  1211  }
  1212  
  1213  // CopyIn implements marshal.Marshallable.CopyIn.
  1214  func (u *Uint64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
  1215      // Construct a slice backed by dst's underlying memory.
  1216      var buf []byte
  1217      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1218      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1219      hdr.Len = u.SizeBytes()
  1220      hdr.Cap = u.SizeBytes()
  1221  
  1222      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
  1223      // Since we bypassed the compiler's escape analysis, indicate that u
  1224      // must live until the use above.
  1225      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1226      return length, err
  1227  }
  1228  
  1229  // WriteTo implements io.WriterTo.WriteTo.
  1230  func (u *Uint64) WriteTo(writer io.Writer) (int64, error) {
  1231      // Construct a slice backed by dst's underlying memory.
  1232      var buf []byte
  1233      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1234      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1235      hdr.Len = u.SizeBytes()
  1236      hdr.Cap = u.SizeBytes()
  1237  
  1238      length, err := writer.Write(buf)
  1239      // Since we bypassed the compiler's escape analysis, indicate that u
  1240      // must live until the use above.
  1241      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1242      return int64(length), err
  1243  }
  1244  
  1245  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
  1246  func (u *Uint64) CheckedMarshal(dst []byte) ([]byte, bool) {
  1247      size := u.SizeBytes()
  1248      if size > len(dst) {
  1249          return dst, false
  1250      }
  1251      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
  1252      return dst[size:], true
  1253  }
  1254  
  1255  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
  1256  func (u *Uint64) CheckedUnmarshal(src []byte) ([]byte, bool) {
  1257      size := u.SizeBytes()
  1258      if size > len(src) {
  1259          return src, false
  1260      }
  1261      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
  1262      return src[size:], true
  1263  }
  1264  
  1265  // CopyUint64SliceIn copies in a slice of uint64 objects from the task's memory.
  1266  func CopyUint64SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []uint64) (int, error) {
  1267      count := len(dst)
  1268      if count == 0 {
  1269          return 0, nil
  1270      }
  1271      size := (*Uint64)(nil).SizeBytes()
  1272  
  1273      ptr := unsafe.Pointer(&dst)
  1274      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
  1275  
  1276      // Construct a slice backed by dst's underlying memory.
  1277      var buf []byte
  1278      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1279      hdr.Data = uintptr(val)
  1280      hdr.Len = size * count
  1281      hdr.Cap = size * count
  1282  
  1283      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
  1284      // Since we bypassed the compiler's escape analysis, indicate that dst
  1285      // must live until the use above.
  1286      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
  1287      return length, err
  1288  }
  1289  
  1290  // CopyUint64SliceOut copies a slice of uint64 objects to the task's memory.
  1291  func CopyUint64SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint64) (int, error) {
  1292      count := len(src)
  1293      if count == 0 {
  1294          return 0, nil
  1295      }
  1296      size := (*Uint64)(nil).SizeBytes()
  1297  
  1298      ptr := unsafe.Pointer(&src)
  1299      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
  1300  
  1301      // Construct a slice backed by dst's underlying memory.
  1302      var buf []byte
  1303      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1304      hdr.Data = uintptr(val)
  1305      hdr.Len = size * count
  1306      hdr.Cap = size * count
  1307  
  1308      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
  1309      // Since we bypassed the compiler's escape analysis, indicate that src
  1310      // must live until the use above.
  1311      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
  1312      return length, err
  1313  }
  1314  
  1315  // MarshalUnsafeUint64Slice is like Uint64.MarshalUnsafe, but for a []Uint64.
  1316  func MarshalUnsafeUint64Slice(src []Uint64, dst []byte) []byte {
  1317      count := len(src)
  1318      if count == 0 {
  1319          return dst
  1320      }
  1321      size := (*Uint64)(nil).SizeBytes()
  1322  
  1323      buf := dst[:size*count]
  1324      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
  1325      return dst[size*count:]
  1326  }
  1327  
  1328  // UnmarshalUnsafeUint64Slice is like Uint64.UnmarshalUnsafe, but for a []Uint64.
  1329  func UnmarshalUnsafeUint64Slice(dst []Uint64, src []byte) []byte {
  1330      count := len(dst)
  1331      if count == 0 {
  1332          return src
  1333      }
  1334      size := (*Uint64)(nil).SizeBytes()
  1335  
  1336      buf := src[:size*count]
  1337      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
  1338      return src[size*count:]
  1339  }
  1340  
  1341  // SizeBytes implements marshal.Marshallable.SizeBytes.
  1342  //go:nosplit
  1343  func (u *Uint8) SizeBytes() int {
  1344      return 1
  1345  }
  1346  
  1347  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
  1348  func (u *Uint8) MarshalBytes(dst []byte) []byte {
  1349      dst[0] = byte(*u)
  1350      return dst[1:]
  1351  }
  1352  
  1353  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
  1354  func (u *Uint8) UnmarshalBytes(src []byte) []byte {
  1355      *u = Uint8(uint8(src[0]))
  1356      return src[1:]
  1357  }
  1358  
  1359  // Packed implements marshal.Marshallable.Packed.
  1360  //go:nosplit
  1361  func (u *Uint8) Packed() bool {
  1362      // Scalar newtypes are always packed.
  1363      return true
  1364  }
  1365  
  1366  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
  1367  func (u *Uint8) MarshalUnsafe(dst []byte) []byte {
  1368      size := u.SizeBytes()
  1369      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
  1370      return dst[size:]
  1371  }
  1372  
  1373  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
  1374  func (u *Uint8) UnmarshalUnsafe(src []byte) []byte {
  1375      size := u.SizeBytes()
  1376      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
  1377      return src[size:]
  1378  }
  1379  
  1380  // CopyOutN implements marshal.Marshallable.CopyOutN.
  1381  func (u *Uint8) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
  1382      // Construct a slice backed by dst's underlying memory.
  1383      var buf []byte
  1384      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1385      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1386      hdr.Len = u.SizeBytes()
  1387      hdr.Cap = u.SizeBytes()
  1388  
  1389      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
  1390      // Since we bypassed the compiler's escape analysis, indicate that u
  1391      // must live until the use above.
  1392      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1393      return length, err
  1394  }
  1395  
  1396  // CopyOut implements marshal.Marshallable.CopyOut.
  1397  func (u *Uint8) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
  1398      return u.CopyOutN(cc, addr, u.SizeBytes())
  1399  }
  1400  
  1401  // CopyIn implements marshal.Marshallable.CopyIn.
  1402  func (u *Uint8) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
  1403      // Construct a slice backed by dst's underlying memory.
  1404      var buf []byte
  1405      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1406      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1407      hdr.Len = u.SizeBytes()
  1408      hdr.Cap = u.SizeBytes()
  1409  
  1410      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
  1411      // Since we bypassed the compiler's escape analysis, indicate that u
  1412      // must live until the use above.
  1413      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1414      return length, err
  1415  }
  1416  
  1417  // WriteTo implements io.WriterTo.WriteTo.
  1418  func (u *Uint8) WriteTo(writer io.Writer) (int64, error) {
  1419      // Construct a slice backed by dst's underlying memory.
  1420      var buf []byte
  1421      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1422      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u)))
  1423      hdr.Len = u.SizeBytes()
  1424      hdr.Cap = u.SizeBytes()
  1425  
  1426      length, err := writer.Write(buf)
  1427      // Since we bypassed the compiler's escape analysis, indicate that u
  1428      // must live until the use above.
  1429      runtime.KeepAlive(u) // escapes: replaced by intrinsic.
  1430      return int64(length), err
  1431  }
  1432  
  1433  // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal.
  1434  func (u *Uint8) CheckedMarshal(dst []byte) ([]byte, bool) {
  1435      size := u.SizeBytes()
  1436      if size > len(dst) {
  1437          return dst, false
  1438      }
  1439      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size))
  1440      return dst[size:], true
  1441  }
  1442  
  1443  // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal.
  1444  func (u *Uint8) CheckedUnmarshal(src []byte) ([]byte, bool) {
  1445      size := u.SizeBytes()
  1446      if size > len(src) {
  1447          return src, false
  1448      }
  1449      gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size))
  1450      return src[size:], true
  1451  }
  1452  
  1453  // CopyUint8SliceIn copies in a slice of uint8 objects from the task's memory.
  1454  func CopyUint8SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []uint8) (int, error) {
  1455      count := len(dst)
  1456      if count == 0 {
  1457          return 0, nil
  1458      }
  1459      size := (*Uint8)(nil).SizeBytes()
  1460  
  1461      ptr := unsafe.Pointer(&dst)
  1462      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
  1463  
  1464      // Construct a slice backed by dst's underlying memory.
  1465      var buf []byte
  1466      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1467      hdr.Data = uintptr(val)
  1468      hdr.Len = size * count
  1469      hdr.Cap = size * count
  1470  
  1471      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
  1472      // Since we bypassed the compiler's escape analysis, indicate that dst
  1473      // must live until the use above.
  1474      runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
  1475      return length, err
  1476  }
  1477  
  1478  // CopyUint8SliceOut copies a slice of uint8 objects to the task's memory.
  1479  func CopyUint8SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []uint8) (int, error) {
  1480      count := len(src)
  1481      if count == 0 {
  1482          return 0, nil
  1483      }
  1484      size := (*Uint8)(nil).SizeBytes()
  1485  
  1486      ptr := unsafe.Pointer(&src)
  1487      val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
  1488  
  1489      // Construct a slice backed by dst's underlying memory.
  1490      var buf []byte
  1491      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
  1492      hdr.Data = uintptr(val)
  1493      hdr.Len = size * count
  1494      hdr.Cap = size * count
  1495  
  1496      length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
  1497      // Since we bypassed the compiler's escape analysis, indicate that src
  1498      // must live until the use above.
  1499      runtime.KeepAlive(src) // escapes: replaced by intrinsic.
  1500      return length, err
  1501  }
  1502  
  1503  // MarshalUnsafeUint8Slice is like Uint8.MarshalUnsafe, but for a []Uint8.
  1504  func MarshalUnsafeUint8Slice(src []Uint8, dst []byte) []byte {
  1505      count := len(src)
  1506      if count == 0 {
  1507          return dst
  1508      }
  1509      size := (*Uint8)(nil).SizeBytes()
  1510  
  1511      buf := dst[:size*count]
  1512      gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
  1513      return dst[size*count:]
  1514  }
  1515  
  1516  // UnmarshalUnsafeUint8Slice is like Uint8.UnmarshalUnsafe, but for a []Uint8.
  1517  func UnmarshalUnsafeUint8Slice(dst []Uint8, src []byte) []byte {
  1518      count := len(dst)
  1519      if count == 0 {
  1520          return src
  1521      }
  1522      size := (*Uint8)(nil).SizeBytes()
  1523  
  1524      buf := src[:size*count]
  1525      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
  1526      return src[size*count:]
  1527  }
  1528