]> Cypherpunks repositories - gostls13.git/commitdiff
internal/runtime/atomic: updated go assembler comments
authorPrabhav Dogra <prabhavdogra1@gmail.com>
Fri, 7 Mar 2025 09:32:20 +0000 (09:32 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 10 Mar 2025 21:03:16 +0000 (14:03 -0700)
Updated comments in go assembler package

Change-Id: I174e344ca45fae6ef70af2e0b29cd783b003b4c2
GitHub-Last-Rev: 8ab37208891e795561a943269ca82b1ce6e7eef5
GitHub-Pull-Request: golang/go#72048
Reviewed-on: https://go-review.googlesource.com/c/go/+/654478
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: PRABHAV DOGRA <prabhavdogra1@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/internal/runtime/atomic/atomic_386.s
src/internal/runtime/atomic/atomic_amd64.s
src/internal/runtime/atomic/atomic_arm.s
src/internal/runtime/atomic/atomic_arm64.s
src/internal/runtime/atomic/atomic_loong64.s
src/internal/runtime/atomic/atomic_mips64x.s
src/internal/runtime/atomic/atomic_mipsx.s
src/internal/runtime/atomic/atomic_ppc64x.s
src/internal/runtime/atomic/atomic_riscv64.s
src/internal/runtime/atomic/sys_nonlinux_arm.s

index 58a56e63c073aa26a7890ac8ea4a0411111a8b32..e8745a1bb5441d1790883e7300ad2586ddde8e09 100644 (file)
@@ -5,13 +5,14 @@
 #include "textflag.h"
 #include "funcdata.h"
 
-// bool Cas(int32 *val, int32 old, int32 new)
+// func Cas(ptr *int32, old, new int32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     }else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB), NOSPLIT, $0-13
        MOVL    ptr+0(FP), BX
        MOVL    old+4(FP), AX
@@ -63,13 +64,13 @@ TEXT ·Xaddint32(SB), NOSPLIT, $0-12
 TEXT ·Xaddint64(SB), NOSPLIT, $0-20
        JMP     ·Xadd64(SB)
 
-// bool ·Cas64(uint64 *val, uint64 old, uint64 new)
+// func Cas64(ptr *uint64, old, new uint64) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
 //     } else {
-//             return 0;
+//             return false
 //     }
 TEXT ·Cas64(SB), NOSPLIT, $0-21
        NO_LOCAL_POINTERS
@@ -86,13 +87,14 @@ TEXT ·Cas64(SB), NOSPLIT, $0-21
        SETEQ   ret+20(FP)
        RET
 
-// bool Casp1(void **p, void *old, void *new)
+// func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
 // Atomically:
-//     if(*p == old){
-//             *p = new;
-//             return 1;
-//     }else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Casp1(SB), NOSPLIT, $0-13
        MOVL    ptr+0(FP), BX
        MOVL    old+4(FP), AX
index d6dc7a32d668fecc96f17c7baf2fa07851f3970a..301725e6a9dcc9bd8f00c159c8f22d0fa04f98ee 100644 (file)
@@ -19,13 +19,14 @@ TEXT ·Loadint32(SB), NOSPLIT, $0-12
 TEXT ·Loadint64(SB), NOSPLIT, $0-16
        JMP     ·Load64(SB)
 
-// bool Cas(int32 *val, int32 old, int32 new)
+// func Cas(ptr *int32, old, new int32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB),NOSPLIT,$0-17
        MOVQ    ptr+0(FP), BX
        MOVL    old+8(FP), AX
@@ -35,13 +36,13 @@ TEXT ·Cas(SB),NOSPLIT,$0-17
        SETEQ   ret+16(FP)
        RET
 
-// bool        ·Cas64(uint64 *val, uint64 old, uint64 new)
+// func Cas64(ptr *uint64, old, new uint64) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
 //     } else {
-//             return 0;
+//             return false
 //     }
 TEXT ·Cas64(SB), NOSPLIT, $0-25
        MOVQ    ptr+0(FP), BX
@@ -52,13 +53,14 @@ TEXT ·Cas64(SB), NOSPLIT, $0-25
        SETEQ   ret+24(FP)
        RET
 
-// bool Casp1(void **val, void *old, void *new)
+// func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Casp1(SB), NOSPLIT, $0-25
        MOVQ    ptr+0(FP), BX
        MOVQ    old+8(FP), AX
index 85cee049af9993dd6252f1cdf40d4a47c1f2ca1c..103f718a041c5393117a53b7e87f7a2768085e3d 100644 (file)
@@ -6,13 +6,14 @@
 #include "textflag.h"
 #include "funcdata.h"
 
-// bool armcas(int32 *val, int32 old, int32 new)
+// func armcas(ptr *int32, old, new int32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     }else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 //
 // To implement ·cas in sys_$GOOS_arm.s
 // using the native instructions, use:
index 09f3b53c5cdd1860776fec603027da1003f34de6..360f7a28163b04835e4d429e1b4bdd1e1a7e6c16 100644 (file)
@@ -192,13 +192,14 @@ load_store_loop:
        RET
 #endif
 
-// bool Cas(uint32 *ptr, uint32 old, uint32 new)
+// func Cas(ptr *uint32, old, new uint32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB), NOSPLIT, $0-17
        MOVD    ptr+0(FP), R0
        MOVW    old+8(FP), R1
@@ -226,14 +227,14 @@ ok:
        RET
 #endif
 
-// bool ·Cas64(uint64 *ptr, uint64 old, uint64 new)
+// func Cas64(ptr *uint64, old, new uint64) bool
 // Atomically:
-//      if(*val == old){
-//              *val = new;
-//              return 1;
-//      } else {
-//              return 0;
-//      }
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas64(SB), NOSPLIT, $0-25
        MOVD    ptr+0(FP), R0
        MOVD    old+8(FP), R1
index 5222b77e77fa7701d633a376e2839960f70c1213..95d3e2bdab8c869df05e1eec82fd8f80be3cc817 100644 (file)
@@ -5,13 +5,14 @@
 #include "go_asm.h"
 #include "textflag.h"
 
-// bool cas(uint32 *ptr, uint32 old, uint32 new)
+// func Cas(ptr *int32, old, new int32) bool
 // Atomically:
-//     if(*ptr == old){
-//             *ptr = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB), NOSPLIT, $0-17
        MOVV    ptr+0(FP), R4
        MOVW    old+8(FP), R5
@@ -45,13 +46,13 @@ cas_fail1:
        MOVV    $0, R4
        JMP     -4(PC)
 
-// bool        cas64(uint64 *ptr, uint64 old, uint64 new)
+// func Cas64(ptr *uint64, old, new uint64) bool
 // Atomically:
-//     if(*ptr == old){
-//             *ptr = new;
-//             return 1;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
 //     } else {
-//             return 0;
+//             return false
 //     }
 TEXT ·Cas64(SB), NOSPLIT, $0-25
        MOVV    ptr+0(FP), R4
@@ -119,13 +120,14 @@ TEXT ·Xaddint32(SB),NOSPLIT,$0-20
 TEXT ·Xaddint64(SB), NOSPLIT, $0-24
        JMP     ·Xadd64(SB)
 
-// bool casp(void **val, void *old, void *new)
+// func Casp(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Casp1(SB), NOSPLIT, $0-25
        JMP     ·Cas64(SB)
 
index ce0b5c2f73c5395c5b80363ac41b4c025c48130c..ec56cb7c68a5a8344db1bf8201030b42005be84f 100644 (file)
@@ -8,13 +8,14 @@
 
 #define SYNC   WORD $0xf
 
-// bool cas(uint32 *ptr, uint32 old, uint32 new)
+// func cas(ptr *uint32, old, new uint32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB), NOSPLIT, $0-17
        MOVV    ptr+0(FP), R1
        MOVW    old+8(FP), R2
@@ -34,13 +35,13 @@ cas_fail:
        MOVV    $0, R1
        JMP     -4(PC)
 
-// bool        cas64(uint64 *ptr, uint64 old, uint64 new)
+// func        Cas64(ptr *uint64, old, new uint64) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
 //     } else {
-//             return 0;
+//             return false
 //     }
 TEXT ·Cas64(SB), NOSPLIT, $0-25
        MOVV    ptr+0(FP), R1
@@ -103,13 +104,14 @@ TEXT ·Xaddint32(SB), NOSPLIT, $0-20
 TEXT ·Xaddint64(SB), NOSPLIT, $0-24
        JMP     ·Xadd64(SB)
 
-// bool casp(void **val, void *old, void *new)
+// func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Casp1(SB), NOSPLIT, $0-25
        JMP ·Cas64(SB)
 
index b725016f7bc114802d6319a5ad0ebf6583d24403..e4f80c913eb590ee69c9786ca2ec9a66616b14dd 100644 (file)
@@ -6,13 +6,14 @@
 
 #include "textflag.h"
 
-// bool Cas(int32 *val, int32 old, int32 new)
+// func Cas(ptr *int32, old, new int32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB),NOSPLIT,$0-13
        MOVW    ptr+0(FP), R1
        MOVW    old+4(FP), R2
index 184a30c970c0c74bc9ca321d4ef33ae563d81a72..bff7d1902a0e151af5cc8d8052b81d2442090266 100644 (file)
@@ -78,13 +78,14 @@ TEXT ·LoadAcq64(SB),NOSPLIT|NOFRAME,$-8-16
        MOVD   R3, ret+8(FP)
        RET
 
-// bool cas(uint32 *ptr, uint32 old, uint32 new)
+// func Cas(ptr *int32, old, new int32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB), NOSPLIT, $0-17
        MOVD    ptr+0(FP), R3
        MOVWZ   old+8(FP), R4
@@ -105,13 +106,13 @@ cas_fail:
        MOVB    R0, ret+16(FP)
        RET
 
-// bool        ·Cas64(uint64 *ptr, uint64 old, uint64 new)
+// func        Cas64(ptr *uint64, old, new uint64) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
 //     } else {
-//             return 0;
+//             return false
 //     }
 TEXT ·Cas64(SB), NOSPLIT, $0-25
        MOVD    ptr+0(FP), R3
@@ -196,13 +197,14 @@ TEXT ·Xaddint32(SB), NOSPLIT, $0-20
 TEXT ·Xaddint64(SB), NOSPLIT, $0-24
        BR      ·Xadd64(SB)
 
-// bool casp(void **val, void *old, void *new)
+// func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     } else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Casp1(SB), NOSPLIT, $0-25
        BR ·Cas64(SB)
 
index 0aa118cc78108a9c93478e813aafce69eb832e2b..f68a607a8cf594a780c39370481b82c7adbe9e10 100644 (file)
 
 // func Cas(ptr *uint64, old, new uint64) bool
 // Atomically:
-//      if(*val == old){
-//              *val = new;
-//              return 1;
-//      } else {
-//              return 0;
-//      }
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT ·Cas(SB), NOSPLIT, $0-17
        MOV     ptr+0(FP), A0
        MOVW    old+8(FP), A1
index b55bf908a260560d758e3d912cf987bbdb0e71b5..43a41d4edcf304830fa7ac250d245180484c2318 100644 (file)
@@ -7,13 +7,14 @@
 #include "textflag.h"
 
 // TODO(minux): this is only valid for ARMv6+
-// bool armcas(int32 *val, int32 old, int32 new)
+// func armcas(ptr *int32, old int32, new int32) bool
 // Atomically:
-//     if(*val == old){
-//             *val = new;
-//             return 1;
-//     }else
-//             return 0;
+//     if *ptr == old {
+//             *ptr = new
+//             return true
+//     } else {
+//             return false
+//     }
 TEXT   ·Cas(SB),NOSPLIT,$0
        JMP     ·armcas(SB)