mirror of
https://github.com/golang/go
synced 2024-11-26 04:58:00 -07:00
internal/bytealg: specify argmaps for exported functions
Functions exported on behalf of other packages need to have their argument stack maps specified explicitly. They don't get an implicit map because they are not in the local package, and if they get defer'd they need argument maps. Fixes #24419 Change-Id: I35b7d8b4a03d4770ba88699e1007cb3fcb5397a9 Reviewed-on: https://go-review.googlesource.com/122676 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
deefcb2623
commit
be9c994609
@ -14,6 +14,7 @@ TEXT ·Compare(SB),NOSPLIT,$0-28
|
||||
JMP cmpbody<>(SB)
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT,$0-28
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVL a_base+0(FP), SI
|
||||
MOVL a_len+4(FP), BX
|
||||
MOVL b_base+12(FP), DI
|
||||
|
@ -14,6 +14,7 @@ TEXT ·Compare(SB),NOSPLIT,$0-56
|
||||
JMP cmpbody<>(SB)
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT,$0-56
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVQ a_base+0(FP), SI
|
||||
MOVQ a_len+8(FP), BX
|
||||
MOVQ b_base+24(FP), DI
|
||||
|
@ -15,6 +15,7 @@ TEXT ·Compare(SB),NOSPLIT,$0-28
|
||||
RET
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT,$0-28
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVL a_base+0(FP), SI
|
||||
MOVL a_len+4(FP), BX
|
||||
MOVL b_base+12(FP), DI
|
||||
|
@ -14,6 +14,7 @@ TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-28
|
||||
B cmpbody<>(SB)
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT|NOFRAME,$0-28
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVW a_base+0(FP), R2
|
||||
MOVW a_len+4(FP), R0
|
||||
MOVW b_base+12(FP), R3
|
||||
|
@ -14,6 +14,7 @@ TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56
|
||||
B cmpbody<>(SB)
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT|NOFRAME,$0-56
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVD a_base+0(FP), R2
|
||||
MOVD a_len+8(FP), R0
|
||||
MOVD b_base+24(FP), R3
|
||||
|
@ -40,6 +40,7 @@ cmp_ret:
|
||||
RET
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT,$0-28
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVW a_base+0(FP), R3
|
||||
MOVW b_base+12(FP), R4
|
||||
MOVW a_len+4(FP), R1
|
||||
|
@ -38,6 +38,7 @@ done:
|
||||
RET
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT|NOFRAME,$0-56
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVD a_base+0(FP), R5
|
||||
MOVD b_base+24(FP), R6
|
||||
MOVD a_len+8(FP), R3
|
||||
|
@ -14,6 +14,7 @@ TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56
|
||||
BR cmpbody<>(SB)
|
||||
|
||||
TEXT bytes·Compare(SB),NOSPLIT|NOFRAME,$0-56
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
MOVD a_base+0(FP), R3
|
||||
MOVD a_len+8(FP), R4
|
||||
MOVD b_base+24(FP), R5
|
||||
|
@ -16,6 +16,7 @@ TEXT ·Compare(SB), NOSPLIT, $0-56
|
||||
RET
|
||||
|
||||
TEXT bytes·Compare(SB), NOSPLIT, $0-56
|
||||
FUNCDATA $0, ·Compare·args_stackmap(SB)
|
||||
Get SP
|
||||
I64Load a_base+0(FP)
|
||||
I64Load a_len+8(FP)
|
||||
|
@ -24,6 +24,7 @@ eq:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-25
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVL a_len+4(FP), BX
|
||||
MOVL b_len+16(FP), CX
|
||||
CMPL BX, CX
|
||||
|
@ -24,6 +24,7 @@ eq:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-49
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVQ a_len+8(FP), BX
|
||||
MOVQ b_len+32(FP), CX
|
||||
CMPQ BX, CX
|
||||
|
@ -25,6 +25,7 @@ eq:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-25
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVL a_len+4(FP), BX
|
||||
MOVL b_len+16(FP), CX
|
||||
CMPL BX, CX
|
||||
|
@ -36,6 +36,7 @@ equal:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-25
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
JMP ·Equal(SB)
|
||||
|
||||
// memequal(a, b unsafe.Pointer, size uintptr) bool
|
||||
|
@ -26,6 +26,7 @@ not_equal:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-49
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVD a_len+8(FP), R1
|
||||
MOVD b_len+32(FP), R3
|
||||
CMP R1, R3
|
||||
|
@ -36,6 +36,7 @@ equal:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-49
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
JMP ·Equal(SB)
|
||||
|
||||
// memequal(a, b unsafe.Pointer, size uintptr) bool
|
||||
|
@ -36,6 +36,7 @@ equal:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-25
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
JMP ·Equal(SB)
|
||||
|
||||
// memequal(a, b unsafe.Pointer, size uintptr) bool
|
||||
|
@ -29,6 +29,7 @@ equal:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT,$0-49
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVD a_len+8(FP), R4
|
||||
MOVD b_len+32(FP), R5
|
||||
CMP R5, R4 // unequal lengths are not equal
|
||||
|
@ -18,6 +18,7 @@ notequal:
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB),NOSPLIT|NOFRAME,$0-49
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVD a_len+8(FP), R2
|
||||
MOVD b_len+32(FP), R6
|
||||
MOVD a_base+0(FP), R3
|
||||
|
@ -26,6 +26,7 @@ TEXT ·Equal(SB), NOSPLIT, $0-49
|
||||
RET
|
||||
|
||||
TEXT bytes·Equal(SB), NOSPLIT, $0-49
|
||||
FUNCDATA $0, ·Equal·args_stackmap(SB)
|
||||
MOVD a_len+8(FP), R0
|
||||
MOVD b_len+32(FP), R1
|
||||
Get R0
|
||||
|
@ -34,7 +34,9 @@ TEXT ·IndexByteString(SB),NOSPLIT,$0-16
|
||||
RET
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT,$0-20
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
JMP ·IndexByte(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT,$0-16
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
JMP ·IndexByteString(SB)
|
||||
|
@ -28,6 +28,7 @@ TEXT ·IndexByteString(SB), NOSPLIT, $0-32
|
||||
// but involves no call overhead.
|
||||
// TODO: remove this hack when midstack inlining is enabled?
|
||||
TEXT bytes·IndexByte(SB), NOSPLIT, $0-40
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
MOVQ b_base+0(FP), SI
|
||||
MOVQ b_len+8(FP), BX
|
||||
MOVB c+24(FP), AL
|
||||
@ -35,6 +36,7 @@ TEXT bytes·IndexByte(SB), NOSPLIT, $0-40
|
||||
JMP indexbytebody<>(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB), NOSPLIT, $0-32
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
MOVQ s_base+0(FP), SI
|
||||
MOVQ s_len+8(FP), BX
|
||||
MOVB c+16(FP), AL
|
||||
|
@ -22,6 +22,7 @@ TEXT ·IndexByteString(SB),NOSPLIT,$0-20
|
||||
RET
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT,$0-20
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
MOVL b_base+0(FP), SI
|
||||
MOVL b_len+4(FP), BX
|
||||
MOVB c+12(FP), AL
|
||||
@ -30,6 +31,7 @@ TEXT bytes·IndexByte(SB),NOSPLIT,$0-20
|
||||
RET
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT,$0-20
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
MOVL s_base+0(FP), SI
|
||||
MOVL s_len+4(FP), BX
|
||||
MOVB c+8(FP), AL
|
||||
|
@ -54,7 +54,9 @@ _sib_notfound:
|
||||
RET
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT,$0-20
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
JMP ·IndexByte(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT,$0-16
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
JMP ·IndexByteString(SB)
|
||||
|
@ -19,6 +19,7 @@ TEXT ·IndexByteString(SB),NOSPLIT,$0-32
|
||||
B indexbytebody<>(SB)
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT,$0-40
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
MOVD b_base+0(FP), R0
|
||||
MOVD b_len+8(FP), R2
|
||||
MOVBU c+24(FP), R1
|
||||
@ -26,6 +27,7 @@ TEXT bytes·IndexByte(SB),NOSPLIT,$0-40
|
||||
B indexbytebody<>(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT,$0-32
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
MOVD s_base+0(FP), R0
|
||||
MOVD s_len+8(FP), R2
|
||||
MOVBU c+16(FP), R1
|
||||
|
@ -54,7 +54,9 @@ notfound:
|
||||
RET
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT,$0-40
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
JMP ·IndexByte(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT,$0-32
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
JMP ·IndexByteString(SB)
|
||||
|
@ -52,7 +52,9 @@ notfound:
|
||||
RET
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT,$0-20
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
JMP ·IndexByte(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT,$0-16
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
JMP ·IndexByteString(SB)
|
||||
|
@ -22,6 +22,7 @@ TEXT ·IndexByteString(SB),NOSPLIT|NOFRAME,$0-32
|
||||
BR indexbytebody<>(SB)
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT|NOFRAME,$0-40
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
MOVD b_base+0(FP), R3 // R3 = byte array pointer
|
||||
MOVD b_len+8(FP), R4 // R4 = length
|
||||
MOVBZ c+24(FP), R5 // R5 = byte
|
||||
@ -29,6 +30,7 @@ TEXT bytes·IndexByte(SB),NOSPLIT|NOFRAME,$0-40
|
||||
BR indexbytebody<>(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT|NOFRAME,$0-32
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
MOVD s_base+0(FP), R3 // R3 = string
|
||||
MOVD s_len+8(FP), R4 // R4 = length
|
||||
MOVBZ c+16(FP), R5 // R5 = byte
|
||||
|
@ -20,6 +20,7 @@ TEXT ·IndexByteString(SB),NOSPLIT|NOFRAME,$0-32
|
||||
BR indexbytebody<>(SB)
|
||||
|
||||
TEXT bytes·IndexByte(SB),NOSPLIT|NOFRAME,$0-40
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
MOVD b_base+0(FP), R3// b_base => R3
|
||||
MOVD b_len+8(FP), R4 // b_len => R4
|
||||
MOVBZ c+24(FP), R5 // c => R5
|
||||
@ -27,6 +28,7 @@ TEXT bytes·IndexByte(SB),NOSPLIT|NOFRAME,$0-40
|
||||
BR indexbytebody<>(SB)
|
||||
|
||||
TEXT strings·IndexByte(SB),NOSPLIT|NOFRAME,$0-32
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
MOVD s_base+0(FP), R3// s_base => R3
|
||||
MOVD s_len+8(FP), R4 // s_len => R4
|
||||
MOVBZ c+16(FP), R5 // c => R5
|
||||
|
@ -50,6 +50,7 @@ TEXT ·IndexByteString(SB), NOSPLIT, $0-32
|
||||
RET
|
||||
|
||||
TEXT bytes·IndexByte(SB), NOSPLIT, $0-40
|
||||
FUNCDATA $0, ·IndexByte·args_stackmap(SB)
|
||||
Get SP
|
||||
I64Load b_base+0(FP)
|
||||
I32WrapI64
|
||||
@ -72,6 +73,7 @@ TEXT bytes·IndexByte(SB), NOSPLIT, $0-40
|
||||
RET
|
||||
|
||||
TEXT strings·IndexByte(SB), NOSPLIT, $0-32
|
||||
FUNCDATA $0, ·IndexByteString·args_stackmap(SB)
|
||||
Get SP
|
||||
I64Load s_base+0(FP)
|
||||
I32WrapI64
|
||||
|
51
test/fixedbugs/issue24419.go
Normal file
51
test/fixedbugs/issue24419.go
Normal file
@ -0,0 +1,51 @@
|
||||
// run
|
||||
|
||||
// Copyright 2018 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.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func growstack(n int) {
|
||||
if n > 0 {
|
||||
growstack(n - 1)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := make(chan struct{})
|
||||
go compare(c)
|
||||
go equal(c)
|
||||
go indexByte(c)
|
||||
go indexByteString(c)
|
||||
<-c
|
||||
<-c
|
||||
<-c
|
||||
<-c
|
||||
}
|
||||
|
||||
func compare(c chan struct{}) {
|
||||
defer bytes.Compare(nil, nil)
|
||||
growstack(10000)
|
||||
c <- struct{}{}
|
||||
}
|
||||
func equal(c chan struct{}) {
|
||||
defer bytes.Equal(nil, nil)
|
||||
growstack(10000)
|
||||
c <- struct{}{}
|
||||
}
|
||||
func indexByte(c chan struct{}) {
|
||||
defer bytes.IndexByte(nil, 0)
|
||||
growstack(10000)
|
||||
c <- struct{}{}
|
||||
}
|
||||
func indexByteString(c chan struct{}) {
|
||||
defer strings.IndexByte("", 0)
|
||||
growstack(10000)
|
||||
c <- struct{}{}
|
||||
}
|
Loading…
Reference in New Issue
Block a user