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

cmd/compile: SSA, use CMPconst for write barrier #14587

Closed
randall77 opened this issue Mar 1, 2016 · 2 comments
Closed

cmd/compile: SSA, use CMPconst for write barrier #14587

randall77 opened this issue Mar 1, 2016 · 2 comments

Comments

@randall77
Copy link
Contributor

right now we generate this code for a write barrier test:

MOVL    runtime.writeBarrier(SB), AX
TESTB   AL, AL
JNE ...

We should really do:

CMPB    $1, runtime.writeBarrier(SB)
JEQ ...

One less instruction, no register required.
It's not easy to do now because flagalloc doesn't like operations that take a memory input and generate a flag output (because it wants to be able to move the flag-generation instructions around).

Figure out a way to fix this. Maybe introduce a new block type BlockWBCheck that takes a memory control value and has 2 successors. It has the CMPx implicit inside it. It would need to be marked as clobbering flags.

@drchase

@minux
Copy link
Member

minux commented Mar 1, 2016

If the only use of a load is a CMP with const,
I think we could combine the load and CMP
into CMP $const, MEM.

Actually, this transform should be generic
for x86 and not necessarily limited to CMP.

I think having a package global bool that
is queried often is a pretty common scenario.
(it probably also makes sense to align such
variable to cache line size, so that there is
no false sharing.)

@randall77
Copy link
Contributor Author

This is done.

@golang golang locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants