@@ -1247,142 +1247,6 @@ func freeStackSpans() {
1247
1247
unlock (& stackLarge .lock )
1248
1248
}
1249
1249
1250
- // getStackMap returns the locals and arguments live pointer maps, and
1251
- // stack object list for frame.
1252
- func (frame * stkframe ) getStackMap (cache * pcvalueCache , debug bool ) (locals , args bitvector , objs []stackObjectRecord ) {
1253
- targetpc := frame .continpc
1254
- if targetpc == 0 {
1255
- // Frame is dead. Return empty bitvectors.
1256
- return
1257
- }
1258
-
1259
- f := frame .fn
1260
- pcdata := int32 (- 1 )
1261
- if targetpc != f .entry () {
1262
- // Back up to the CALL. If we're at the function entry
1263
- // point, we want to use the entry map (-1), even if
1264
- // the first instruction of the function changes the
1265
- // stack map.
1266
- targetpc --
1267
- pcdata = pcdatavalue (f , _PCDATA_StackMapIndex , targetpc , cache )
1268
- }
1269
- if pcdata == - 1 {
1270
- // We do not have a valid pcdata value but there might be a
1271
- // stackmap for this function. It is likely that we are looking
1272
- // at the function prologue, assume so and hope for the best.
1273
- pcdata = 0
1274
- }
1275
-
1276
- // Local variables.
1277
- size := frame .varp - frame .sp
1278
- var minsize uintptr
1279
- switch goarch .ArchFamily {
1280
- case goarch .ARM64 :
1281
- minsize = sys .StackAlign
1282
- default :
1283
- minsize = sys .MinFrameSize
1284
- }
1285
- if size > minsize {
1286
- stackid := pcdata
1287
- stkmap := (* stackmap )(funcdata (f , _FUNCDATA_LocalsPointerMaps ))
1288
- if stkmap == nil || stkmap .n <= 0 {
1289
- print ("runtime: frame " , funcname (f ), " untyped locals " , hex (frame .varp - size ), "+" , hex (size ), "\n " )
1290
- throw ("missing stackmap" )
1291
- }
1292
- // If nbit == 0, there's no work to do.
1293
- if stkmap .nbit > 0 {
1294
- if stackid < 0 || stackid >= stkmap .n {
1295
- // don't know where we are
1296
- print ("runtime: pcdata is " , stackid , " and " , stkmap .n , " locals stack map entries for " , funcname (f ), " (targetpc=" , hex (targetpc ), ")\n " )
1297
- throw ("bad symbol table" )
1298
- }
1299
- locals = stackmapdata (stkmap , stackid )
1300
- if stackDebug >= 3 && debug {
1301
- print (" locals " , stackid , "/" , stkmap .n , " " , locals .n , " words " , locals .bytedata , "\n " )
1302
- }
1303
- } else if stackDebug >= 3 && debug {
1304
- print (" no locals to adjust\n " )
1305
- }
1306
- }
1307
-
1308
- // Arguments. First fetch frame size and special-case argument maps.
1309
- var isReflect bool
1310
- args , isReflect = frame .argMapInternal ()
1311
- if args .n > 0 && args .bytedata == nil {
1312
- // Non-empty argument frame, but not a special map.
1313
- // Fetch the argument map at pcdata.
1314
- stackmap := (* stackmap )(funcdata (f , _FUNCDATA_ArgsPointerMaps ))
1315
- if stackmap == nil || stackmap .n <= 0 {
1316
- print ("runtime: frame " , funcname (f ), " untyped args " , hex (frame .argp ), "+" , hex (args .n * goarch .PtrSize ), "\n " )
1317
- throw ("missing stackmap" )
1318
- }
1319
- if pcdata < 0 || pcdata >= stackmap .n {
1320
- // don't know where we are
1321
- print ("runtime: pcdata is " , pcdata , " and " , stackmap .n , " args stack map entries for " , funcname (f ), " (targetpc=" , hex (targetpc ), ")\n " )
1322
- throw ("bad symbol table" )
1323
- }
1324
- if stackmap .nbit == 0 {
1325
- args .n = 0
1326
- } else {
1327
- args = stackmapdata (stackmap , pcdata )
1328
- }
1329
- }
1330
-
1331
- // stack objects.
1332
- if (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "ppc64" || GOARCH == "ppc64le" || GOARCH == "riscv64" ) &&
1333
- unsafe .Sizeof (abi.RegArgs {}) > 0 && isReflect {
1334
- // For reflect.makeFuncStub and reflect.methodValueCall,
1335
- // we need to fake the stack object record.
1336
- // These frames contain an internal/abi.RegArgs at a hard-coded offset.
1337
- // This offset matches the assembly code on amd64 and arm64.
1338
- objs = methodValueCallFrameObjs [:]
1339
- } else {
1340
- p := funcdata (f , _FUNCDATA_StackObjects )
1341
- if p != nil {
1342
- n := * (* uintptr )(p )
1343
- p = add (p , goarch .PtrSize )
1344
- r0 := (* stackObjectRecord )(noescape (p ))
1345
- objs = unsafe .Slice (r0 , int (n ))
1346
- // Note: the noescape above is needed to keep
1347
- // getStackMap from "leaking param content:
1348
- // frame". That leak propagates up to getgcmask, then
1349
- // GCMask, then verifyGCInfo, which converts the stack
1350
- // gcinfo tests into heap gcinfo tests :(
1351
- }
1352
- }
1353
-
1354
- return
1355
- }
1356
-
1357
- var methodValueCallFrameObjs [1 ]stackObjectRecord // initialized in stackobjectinit
1358
-
1359
- func stkobjinit () {
1360
- var abiRegArgsEface any = abi.RegArgs {}
1361
- abiRegArgsType := efaceOf (& abiRegArgsEface )._type
1362
- if abiRegArgsType .kind & kindGCProg != 0 {
1363
- throw ("abiRegArgsType needs GC Prog, update methodValueCallFrameObjs" )
1364
- }
1365
- // Set methodValueCallFrameObjs[0].gcdataoff so that
1366
- // stackObjectRecord.gcdata() will work correctly with it.
1367
- ptr := uintptr (unsafe .Pointer (& methodValueCallFrameObjs [0 ]))
1368
- var mod * moduledata
1369
- for datap := & firstmoduledata ; datap != nil ; datap = datap .next {
1370
- if datap .gofunc <= ptr && ptr < datap .end {
1371
- mod = datap
1372
- break
1373
- }
1374
- }
1375
- if mod == nil {
1376
- throw ("methodValueCallFrameObjs is not in a module" )
1377
- }
1378
- methodValueCallFrameObjs [0 ] = stackObjectRecord {
1379
- off : - int32 (alignUp (abiRegArgsType .size , 8 )), // It's always the highest address local.
1380
- size : int32 (abiRegArgsType .size ),
1381
- _ptrdata : int32 (abiRegArgsType .ptrdata ),
1382
- gcdataoff : uint32 (uintptr (unsafe .Pointer (abiRegArgsType .gcdata )) - mod .rodata ),
1383
- }
1384
- }
1385
-
1386
1250
// A stackObjectRecord is generated by the compiler for each stack object in a stack frame.
1387
1251
// This record must match the generator code in cmd/compile/internal/liveness/plive.go:emitStackObjects.
1388
1252
type stackObjectRecord struct {
0 commit comments