Brad Fitzpatrick | 5194744 | 2016-03-01 22:57:46 +0000 | [diff] [blame] | 1 | // Copyright 2012 The Go Authors. All rights reserved. |
Russ Cox | ba4625c | 2012-09-24 20:06:32 -0400 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Rob Pike | 8bca148 | 2014-08-12 17:04:45 -0700 | [diff] [blame] | 5 | #include "textflag.h" |
Russ Cox | f0d44db | 2014-09-12 07:29:19 -0400 | [diff] [blame] | 6 | #include "funcdata.h" |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 7 | #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 Randall | 8b789e1 | 2013-08-12 10:25:36 -0700 | [diff] [blame] | 22 | |
Russ Cox | b1b67a3 | 2013-02-22 15:23:57 -0500 | [diff] [blame] | 23 | // makeFuncStub is the code half of the function returned by MakeFunc. |
Russ Cox | 3be7036 | 2013-03-21 16:59:16 -0400 | [diff] [blame] | 24 | // See the comment on the declaration of makeFuncStub in makefunc.go |
Russ Cox | ba4625c | 2012-09-24 20:06:32 -0400 | [diff] [blame] | 25 | // for more details. |
Russ Cox | f0d44db | 2014-09-12 07:29:19 -0400 | [diff] [blame] | 26 | // No arg size here; runtime pulls arg map out of the func value. |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 27 | // This frame contains two locals. See the comment above LOCAL_RETVALID. |
Cherry Mui | f642742 | 2021-05-21 18:28:25 -0400 | [diff] [blame] | 28 | TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$312 |
Russ Cox | f0d44db | 2014-09-12 07:29:19 -0400 | [diff] [blame] | 29 | NO_LOCAL_POINTERS |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 30 | // 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 Mui | fb42fb7 | 2021-05-20 18:55:47 -0400 | [diff] [blame] | 33 | CALL runtime·spillArgs(SB) |
Cherry Zhang | 4fb74e0 | 2021-04-15 11:19:30 -0400 | [diff] [blame] | 34 | MOVQ DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area |
Russ Cox | b1b67a3 | 2013-02-22 15:23:57 -0500 | [diff] [blame] | 35 | MOVQ DX, 0(SP) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 36 | MOVQ R12, 8(SP) |
| 37 | CALL ·moveMakeFuncArgPtrs(SB) |
Cherry Zhang | 4fb74e0 | 2021-04-15 11:19:30 -0400 | [diff] [blame] | 38 | MOVQ 24(SP), DX |
| 39 | MOVQ DX, 0(SP) |
Russ Cox | 07720b6 | 2013-03-22 12:57:55 -0400 | [diff] [blame] | 40 | LEAQ argframe+0(FP), CX |
Russ Cox | b1b67a3 | 2013-02-22 15:23:57 -0500 | [diff] [blame] | 41 | MOVQ CX, 8(SP) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 42 | MOVB $0, LOCAL_RETVALID(SP) |
| 43 | LEAQ LOCAL_RETVALID(SP), AX |
Keith Randall | ef50373 | 2018-09-25 15:54:11 -0700 | [diff] [blame] | 44 | MOVQ AX, 16(SP) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 45 | LEAQ LOCAL_REGARGS(SP), AX |
| 46 | MOVQ AX, 24(SP) |
Cherry Zhang | d446cb7 | 2021-04-04 12:10:32 -0400 | [diff] [blame] | 47 | CALL ·callReflect(SB) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 48 | LEAQ LOCAL_REGARGS(SP), R12 |
Cherry Mui | fb42fb7 | 2021-05-20 18:55:47 -0400 | [diff] [blame] | 49 | CALL runtime·unspillArgs(SB) |
Russ Cox | ba4625c | 2012-09-24 20:06:32 -0400 | [diff] [blame] | 50 | RET |
Russ Cox | 3be7036 | 2013-03-21 16:59:16 -0400 | [diff] [blame] | 51 | |
| 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 Cox | f0d44db | 2014-09-12 07:29:19 -0400 | [diff] [blame] | 55 | // No arg size here; runtime pulls arg map out of the func value. |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 56 | // This frame contains two locals. See the comment above LOCAL_RETVALID. |
Cherry Mui | f642742 | 2021-05-21 18:28:25 -0400 | [diff] [blame] | 57 | TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$312 |
Russ Cox | f0d44db | 2014-09-12 07:29:19 -0400 | [diff] [blame] | 58 | NO_LOCAL_POINTERS |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 59 | // 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 Mui | 6633dc8 | 2021-05-27 18:41:12 -0400 | [diff] [blame] | 62 | CALL runtime·spillArgs(SB) |
Cherry Zhang | 4fb74e0 | 2021-04-15 11:19:30 -0400 | [diff] [blame] | 63 | MOVQ DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area |
Russ Cox | 3be7036 | 2013-03-21 16:59:16 -0400 | [diff] [blame] | 64 | MOVQ DX, 0(SP) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 65 | MOVQ R12, 8(SP) |
| 66 | CALL ·moveMakeFuncArgPtrs(SB) |
Cherry Zhang | 4fb74e0 | 2021-04-15 11:19:30 -0400 | [diff] [blame] | 67 | MOVQ 24(SP), DX |
| 68 | MOVQ DX, 0(SP) |
Russ Cox | 07720b6 | 2013-03-22 12:57:55 -0400 | [diff] [blame] | 69 | LEAQ argframe+0(FP), CX |
Russ Cox | 3be7036 | 2013-03-21 16:59:16 -0400 | [diff] [blame] | 70 | MOVQ CX, 8(SP) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 71 | MOVB $0, LOCAL_RETVALID(SP) |
| 72 | LEAQ LOCAL_RETVALID(SP), AX |
Keith Randall | ef50373 | 2018-09-25 15:54:11 -0700 | [diff] [blame] | 73 | MOVQ AX, 16(SP) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 74 | LEAQ LOCAL_REGARGS(SP), AX |
| 75 | MOVQ AX, 24(SP) |
Cherry Zhang | d446cb7 | 2021-04-04 12:10:32 -0400 | [diff] [blame] | 76 | CALL ·callMethod(SB) |
Michael Anthony Knyszek | 28c5fed | 2021-01-28 15:23:05 +0000 | [diff] [blame] | 77 | LEAQ LOCAL_REGARGS(SP), R12 |
Cherry Mui | 6633dc8 | 2021-05-27 18:41:12 -0400 | [diff] [blame] | 78 | CALL runtime·unspillArgs(SB) |
Russ Cox | 3be7036 | 2013-03-21 16:59:16 -0400 | [diff] [blame] | 79 | RET |