From 929e3695ac8cfa13f9a613a77631c6ff067f7f5d Mon Sep 17 00:00:00 2001 From: Alexander Klauer Date: Wed, 6 Sep 2023 21:59:24 +0200 Subject: [PATCH] reflect: cram method dispatch into one memory page For #38783 --- src/cmd/internal/obj/x86/asm6.go | 4 ++-- src/reflect/asm_amd64.s | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index bdd75b4ef884c..fa049d956dc41 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -2044,8 +2044,8 @@ type nopPad struct { // cursym: current function being assembled // returns number of bytes of padding needed func addpad(pc, a int64, ctxt *obj.Link, cursym *obj.LSym) int { - if !((a&(a-1) == 0) && 8 <= a && a <= 2048) { - ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 2048], got %d\n", a) + if !((a&(a-1) == 0) && 8 <= a && a <= 4096) { + ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 4096], got %d\n", a) return 0 } diff --git a/src/reflect/asm_amd64.s b/src/reflect/asm_amd64.s index 8f9a940f3d1c8..f61611848609a 100644 --- a/src/reflect/asm_amd64.s +++ b/src/reflect/asm_amd64.s @@ -83,6 +83,8 @@ TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$312 // the closure which implements the method. // No preamble of any kind, we need to do things manually. TEXT ·dispatchToMethod(SB),(NOSPLIT|NOFRAME),$0-0 + // cram dispatchToMethod and dispatchLabel into a single memory page + PCALIGN $4096 CALL ·dispatchLabel(SB) CALL ·dispatchLabel(SB) CALL ·dispatchLabel(SB)