blob: d21d498063b55e382a1e473fcb5e6a501be88d36 [file] [log] [blame]
Brad Fitzpatrick51947442016-03-01 22:57:46 +00001// Copyright 2012 The Go Authors. All rights reserved.
Russ Coxba4625c2012-09-24 20:06:32 -04002// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Rob Pike8bca1482014-08-12 17:04:45 -07005#include "textflag.h"
Russ Coxf0d44db2014-09-12 07:29:19 -04006#include "funcdata.h"
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +00007#include "go_asm.h"
8
9// The frames of each of the two functions below contain two locals, at offsets
10// that are known to the runtime.
11//
12// The first local is a bool called retValid with a whole pointer-word reserved
13// for it on the stack. The purpose of this word is so that the runtime knows
14// whether the stack-allocated return space contains valid values for stack
15// scanning.
16//
17// The second local is an abi.RegArgs value whose offset is also known to the
18// runtime, so that a stack map for it can be constructed, since it contains
19// pointers visible to the GC.
20#define LOCAL_RETVALID 32
21#define LOCAL_REGARGS 40
Keith Randall8b789e12013-08-12 10:25:36 -070022
Russ Coxb1b67a32013-02-22 15:23:57 -050023// makeFuncStub is the code half of the function returned by MakeFunc.
Russ Cox3be70362013-03-21 16:59:16 -040024// See the comment on the declaration of makeFuncStub in makefunc.go
Russ Coxba4625c2012-09-24 20:06:32 -040025// for more details.
Russ Coxf0d44db2014-09-12 07:29:19 -040026// No arg size here; runtime pulls arg map out of the func value.
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000027// This frame contains two locals. See the comment above LOCAL_RETVALID.
Cherry Muif6427422021-05-21 18:28:25 -040028TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$312
Russ Coxf0d44db2014-09-12 07:29:19 -040029 NO_LOCAL_POINTERS
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000030 // NO_LOCAL_POINTERS is a lie. The stack map for the two locals in this
31 // frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
32 LEAQ LOCAL_REGARGS(SP), R12
Cherry Muifb42fb72021-05-20 18:55:47 -040033 CALL runtime·spillArgs(SB)
Cherry Zhang4fb74e02021-04-15 11:19:30 -040034 MOVQ DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area
Russ Coxb1b67a32013-02-22 15:23:57 -050035 MOVQ DX, 0(SP)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000036 MOVQ R12, 8(SP)
37 CALL ·moveMakeFuncArgPtrs(SB)
Cherry Zhang4fb74e02021-04-15 11:19:30 -040038 MOVQ 24(SP), DX
39 MOVQ DX, 0(SP)
Russ Cox07720b62013-03-22 12:57:55 -040040 LEAQ argframe+0(FP), CX
Russ Coxb1b67a32013-02-22 15:23:57 -050041 MOVQ CX, 8(SP)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000042 MOVB $0, LOCAL_RETVALID(SP)
43 LEAQ LOCAL_RETVALID(SP), AX
Keith Randallef503732018-09-25 15:54:11 -070044 MOVQ AX, 16(SP)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000045 LEAQ LOCAL_REGARGS(SP), AX
46 MOVQ AX, 24(SP)
Cherry Zhangd446cb72021-04-04 12:10:32 -040047 CALL ·callReflect(SB)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000048 LEAQ LOCAL_REGARGS(SP), R12
Cherry Muifb42fb72021-05-20 18:55:47 -040049 CALL runtime·unspillArgs(SB)
Russ Coxba4625c2012-09-24 20:06:32 -040050 RET
Russ Cox3be70362013-03-21 16:59:16 -040051
52// methodValueCall is the code half of the function returned by makeMethodValue.
53// See the comment on the declaration of methodValueCall in makefunc.go
54// for more details.
Russ Coxf0d44db2014-09-12 07:29:19 -040055// No arg size here; runtime pulls arg map out of the func value.
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000056// This frame contains two locals. See the comment above LOCAL_RETVALID.
Cherry Muif6427422021-05-21 18:28:25 -040057TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$312
Russ Coxf0d44db2014-09-12 07:29:19 -040058 NO_LOCAL_POINTERS
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000059 // NO_LOCAL_POINTERS is a lie. The stack map for the two locals in this
60 // frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
61 LEAQ LOCAL_REGARGS(SP), R12
Cherry Mui6633dc82021-05-27 18:41:12 -040062 CALL runtime·spillArgs(SB)
Cherry Zhang4fb74e02021-04-15 11:19:30 -040063 MOVQ DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area
Russ Cox3be70362013-03-21 16:59:16 -040064 MOVQ DX, 0(SP)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000065 MOVQ R12, 8(SP)
66 CALL ·moveMakeFuncArgPtrs(SB)
Cherry Zhang4fb74e02021-04-15 11:19:30 -040067 MOVQ 24(SP), DX
68 MOVQ DX, 0(SP)
Russ Cox07720b62013-03-22 12:57:55 -040069 LEAQ argframe+0(FP), CX
Russ Cox3be70362013-03-21 16:59:16 -040070 MOVQ CX, 8(SP)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000071 MOVB $0, LOCAL_RETVALID(SP)
72 LEAQ LOCAL_RETVALID(SP), AX
Keith Randallef503732018-09-25 15:54:11 -070073 MOVQ AX, 16(SP)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000074 LEAQ LOCAL_REGARGS(SP), AX
75 MOVQ AX, 24(SP)
Cherry Zhangd446cb72021-04-04 12:10:32 -040076 CALL ·callMethod(SB)
Michael Anthony Knyszek28c5fed2021-01-28 15:23:05 +000077 LEAQ LOCAL_REGARGS(SP), R12
Cherry Mui6633dc82021-05-27 18:41:12 -040078 CALL runtime·unspillArgs(SB)
Russ Cox3be70362013-03-21 16:59:16 -040079 RET