if t.Elem() == nil {
break
}
- w = int64(sizeof_Array)
+ w = int64(sizeof_Slice)
checkwidth(t.Elem())
t.Align = uint8(Widthptr)
)
// note this is the runtime representation
-// of the compilers arrays.
+// of the compilers slices.
//
// typedef struct
// { // must not move anything
// uchar array[8]; // pointer to data
// uchar nel[4]; // number of elements
// uchar cap[4]; // allocated number of elements
-// } Array;
-var array_array int // runtime offsetof(Array,array) - same for String
+// } Slice;
+var slice_array int // runtime offsetof(Slice,array) - same for String
-var array_nel int // runtime offsetof(Array,nel) - same for String
+var slice_nel int // runtime offsetof(Slice,nel) - same for String
-var array_cap int // runtime offsetof(Array,cap)
+var slice_cap int // runtime offsetof(Slice,cap)
-var sizeof_Array int // runtime sizeof(Array)
+var sizeof_Slice int // runtime sizeof(Slice)
// note this is the runtime representation
// of the compilers strings.
a := s.inittemps[r]
n := l.copy()
- n.Xoffset = l.Xoffset + int64(array_array)
+ n.Xoffset = l.Xoffset + int64(slice_array)
gdata(n, nod(OADDR, a, nil), Widthptr)
- n.Xoffset = l.Xoffset + int64(array_nel)
+ n.Xoffset = l.Xoffset + int64(slice_nel)
gdata(n, r.Right, Widthptr)
- n.Xoffset = l.Xoffset + int64(array_cap)
+ n.Xoffset = l.Xoffset + int64(slice_cap)
gdata(n, r.Right, Widthptr)
return true
a := staticname(ta)
s.inittemps[r] = a
n := l.copy()
- n.Xoffset = l.Xoffset + int64(array_array)
+ n.Xoffset = l.Xoffset + int64(slice_array)
gdata(n, nod(OADDR, a, nil), Widthptr)
- n.Xoffset = l.Xoffset + int64(array_nel)
+ n.Xoffset = l.Xoffset + int64(slice_nel)
gdata(n, r.Right, Widthptr)
- n.Xoffset = l.Xoffset + int64(array_cap)
+ n.Xoffset = l.Xoffset + int64(slice_cap)
gdata(n, r.Right, Widthptr)
// Fall through to init underlying array.
v.Type = types.Types[TINT]
setintconst(&v, t.NumElem())
- nam.Xoffset += int64(array_array)
+ nam.Xoffset += int64(slice_array)
gdata(&nam, nod(OADDR, vstat, nil), Widthptr)
- nam.Xoffset += int64(array_nel) - int64(array_array)
+ nam.Xoffset += int64(slice_nel) - int64(slice_array)
gdata(&nam, &v, Widthptr)
- nam.Xoffset += int64(array_cap) - int64(array_nel)
+ nam.Xoffset += int64(slice_cap) - int64(slice_nel)
gdata(&nam, &v, Widthptr)
return
// Tell liveness we're about to build a new slice
s.vars[&memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, sn, s.mem())
}
- capaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, int64(array_cap), addr)
+ capaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, int64(slice_cap), addr)
s.store(types.Types[TINT], capaddr, r[2])
s.store(pt, addr, r[0])
// load the value we just stored to avoid having to spill it
if inplace {
l = s.variable(&lenVar, types.Types[TINT]) // generates phi for len
nl = s.newValue2(s.ssaOp(OADD, types.Types[TINT]), types.Types[TINT], l, s.constInt(types.Types[TINT], nargs))
- lenaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, int64(array_nel), addr)
+ lenaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, int64(slice_nel), addr)
s.store(types.Types[TINT], lenaddr, nl)
}
simtype[TFUNC] = TPTR
simtype[TUNSAFEPTR] = TPTR
- array_array = int(Rnd(0, int64(Widthptr)))
- array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthptr)))
- array_cap = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
- sizeof_Array = int(Rnd(int64(array_cap)+int64(Widthptr), int64(Widthptr)))
+ slice_array = int(Rnd(0, int64(Widthptr)))
+ slice_nel = int(Rnd(int64(slice_array)+int64(Widthptr), int64(Widthptr)))
+ slice_cap = int(Rnd(int64(slice_nel)+int64(Widthptr), int64(Widthptr)))
+ sizeof_Slice = int(Rnd(int64(slice_cap)+int64(Widthptr), int64(Widthptr)))
// string is same as slice wo the cap
- sizeof_String = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
+ sizeof_String = int(Rnd(int64(slice_nel)+int64(Widthptr), int64(Widthptr)))
dowidth(types.Types[TSTRING])
dowidth(types.Idealstring)