-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reflect: rewrite ·dispatchLabel for ABIInternal
For golang#38783
- Loading branch information
Showing
3 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build amd64 | ||
|
||
package reflect | ||
|
||
import ( | ||
"strconv" | ||
"unsafe" | ||
) | ||
|
||
// getMethodImpl returns the pointer to the closure for the specified key. | ||
// It is called from the ASM dispatch code. | ||
func getMethodImpl( | ||
// forward all possible register args, | ||
// force key and closure onto the stack. | ||
ax, bx, cx, di, si, r8, r9, r10, r11 uintptr, | ||
// FIXME: does sync.Map.Load clobber FP registers? | ||
// If not, we could omit x0 through x14 here. | ||
x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14 float64, | ||
key uintptr, | ||
) ( | ||
rax, rbx, rcx, rdi, rsi, rr8, rr9, rr10, rr11 uintptr, | ||
rx0, rx1, rx2, rx3, rx4, rx5, rx6, rx7, rx8, rx9, | ||
rx10, rx11, rx12, rx13, rx14 float64, | ||
closure unsafe.Pointer, | ||
) { | ||
if x, ok := methodMap.Load(key); !ok { | ||
panic("reflect: method " + strconv.Itoa(int(key)) + " not found") | ||
} else { | ||
return ax, bx, cx, di, si, r8, r9, r10, r11, | ||
x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, | ||
x.(unsafe.Pointer) | ||
} | ||
} |