mirror of
https://github.com/golang/go
synced 2024-11-22 14:44:50 -07:00
cmd/compile: use exact constant in go_asm.h
Fixes #50523 Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/377074 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Liz Fong-Jones <lizf@honeycomb.io> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
55d10acb72
commit
8b9b365493
@ -31,7 +31,7 @@ func dumpasmhdr() {
|
|||||||
if t == constant.Float || t == constant.Complex {
|
if t == constant.Float || t == constant.Complex {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val())
|
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val().ExactString())
|
||||||
|
|
||||||
case ir.OTYPE:
|
case ir.OTYPE:
|
||||||
t := n.Type()
|
t := n.Type()
|
||||||
|
@ -16,12 +16,15 @@ const (
|
|||||||
bigInt = 0xffffffffffffffff
|
bigInt = 0xffffffffffffffff
|
||||||
|
|
||||||
stringVal = "test"
|
stringVal = "test"
|
||||||
|
|
||||||
|
longStringVal = "this_is_a_string_constant_longer_than_seventy_characters_which_used_to_fail_see_issue_50253"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
smallIntAsm int64
|
smallIntAsm int64
|
||||||
bigIntAsm uint64
|
bigIntAsm uint64
|
||||||
stringAsm [len(stringVal)]byte
|
stringAsm [len(stringVal)]byte
|
||||||
|
longStringAsm [len(longStringVal)]byte
|
||||||
)
|
)
|
||||||
|
|
||||||
type typ struct {
|
type typ struct {
|
||||||
@ -46,6 +49,9 @@ func main() {
|
|||||||
if stringVal != string(stringAsm[:]) {
|
if stringVal != string(stringAsm[:]) {
|
||||||
println("stringVal", stringVal, "!=", string(stringAsm[:]))
|
println("stringVal", stringVal, "!=", string(stringAsm[:]))
|
||||||
}
|
}
|
||||||
|
if longStringVal != string(longStringAsm[:]) {
|
||||||
|
println("longStringVal", longStringVal, "!=", string(longStringAsm[:]))
|
||||||
|
}
|
||||||
|
|
||||||
// We also include boolean consts in go_asm.h, but they're
|
// We also include boolean consts in go_asm.h, but they're
|
||||||
// defined to be "true" or "false", and it's not clear how to
|
// defined to be "true" or "false", and it's not clear how to
|
||||||
|
@ -14,6 +14,9 @@ GLOBL ·bigIntAsm(SB),RODATA,$8
|
|||||||
DATA ·stringAsm(SB)/4, $const_stringVal
|
DATA ·stringAsm(SB)/4, $const_stringVal
|
||||||
GLOBL ·stringAsm(SB),RODATA,$4
|
GLOBL ·stringAsm(SB),RODATA,$4
|
||||||
|
|
||||||
|
DATA ·longStringAsm(SB)/91, $const_longStringVal
|
||||||
|
GLOBL ·longStringAsm(SB),RODATA,$91
|
||||||
|
|
||||||
DATA ·typSize(SB)/8, $typ__size
|
DATA ·typSize(SB)/8, $typ__size
|
||||||
GLOBL ·typSize(SB),RODATA,$8
|
GLOBL ·typSize(SB),RODATA,$8
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user