Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purego: refactor struct_amd64.go #212

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions struct_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func tryPlaceRegister(v reflect.Value, addFloat func(uintptr), addInt func(uintp
var shift byte // # of bits to shift
var flushed bool
class := _NO_CLASS
flush := func() {
flushIfNeeded := func() {
if flushed {
return
}
flushed = true
if class == _SSE {
addFloat(uintptr(val))
Expand Down Expand Up @@ -167,7 +170,7 @@ func tryPlaceRegister(v reflect.Value, addFloat func(uintptr), addInt func(uintp
}

if shift == 64 {
flush()
flushIfNeeded()
} else if shift > 64 {
// Should never happen, but may if we forget to reset shift after flush (or forget to flush),
// better fall apart here, than corrupt arguments.
Expand All @@ -177,9 +180,7 @@ func tryPlaceRegister(v reflect.Value, addFloat func(uintptr), addInt func(uintp
}

place(v)
if !flushed {
flush()
}
flushIfNeeded()
return ok
}

Expand Down
Loading