This is the gofrontend version of https://golang.org/cl/289152.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339690
-b47bcf942daa9a0c252db9b57b8f138adbfcdaa2
+32590102c464679f845667b5554e1dcce2549ad2
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
// sync/atomic functions and runtime/internal/atomic functions
// are very similar. In order not to duplicate code, we just
// redirect to the latter and let the code below to handle them.
- // In case there is no equivalent functions (slight variance
- // in types), we just make an artificial name (begin with '$').
// Note: no StorePointer, SwapPointer, and CompareAndSwapPointer,
// as they need write barriers.
if (name == "LoadInt32")
- name = "$Loadint32";
+ name = "Loadint32";
else if (name == "LoadInt64")
name = "Loadint64";
else if (name == "LoadUint32")
else if (name == "LoadPointer")
name = "Loadp";
else if (name == "StoreInt32")
- name = "$Storeint32";
+ name = "Storeint32";
else if (name == "StoreInt64")
- name = "$Storeint64";
+ name = "Storeint64";
else if (name == "StoreUint32")
name = "Store";
else if (name == "StoreUint64")
else if (name == "StoreUintptr")
name = "Storeuintptr";
else if (name == "AddInt32")
- name = "$Xaddint32";
+ name = "Xaddint32";
else if (name == "AddInt64")
name = "Xaddint64";
else if (name == "AddUint32")
else if (name == "AddUintptr")
name = "Xadduintptr";
else if (name == "SwapInt32")
- name = "$Xchgint32";
+ name = "Xchgint32";
else if (name == "SwapInt64")
- name = "$Xchgint64";
+ name = "Xchgint64";
else if (name == "SwapUint32")
name = "Xchg";
else if (name == "SwapUint64")
else if (name == "SwapUintptr")
name = "Xchguintptr";
else if (name == "CompareAndSwapInt32")
- name = "$Casint32";
+ name = "Casint32";
else if (name == "CompareAndSwapInt64")
- name = "$Casint64";
+ name = "Casint64";
else if (name == "CompareAndSwapUint32")
name = "Cas";
else if (name == "CompareAndSwapUint64")
if ((name == "Load" || name == "Load64" || name == "Loadint64" || name == "Loadp"
|| name == "Loaduint" || name == "Loaduintptr" || name == "LoadAcq"
- || name == "$Loadint32")
+ || name == "Loadint32")
&& this->args_ != NULL && this->args_->size() == 1)
{
if (int_size < 8 && (name == "Load64" || name == "Loadint64"))
code = Runtime::ATOMIC_LOAD_8;
res_type = uint64_type;
}
- else if (name == "$Loadint32")
+ else if (name == "Loadint32")
{
code = Runtime::ATOMIC_LOAD_4;
res_type = int32_type;
if ((name == "Store" || name == "Store64" || name == "StorepNoWB"
|| name == "Storeuintptr" || name == "StoreRel"
- || name == "$Storeint32" || name == "$Storeint64")
+ || name == "Storeint32" || name == "Storeint64")
&& this->args_ != NULL && this->args_->size() == 2)
{
- if (int_size < 8 && (name == "Store64" || name == "$Storeint64"))
+ if (int_size < 8 && (name == "Store64" || name == "Storeint64"))
return NULL;
Runtime::Function code;
code = Runtime::ATOMIC_STORE_4;
else if (name == "Store64")
code = Runtime::ATOMIC_STORE_8;
- else if (name == "$Storeint32")
+ else if (name == "Storeint32")
code = Runtime::ATOMIC_STORE_4;
- else if (name == "$Storeint64")
+ else if (name == "Storeint64")
code = Runtime::ATOMIC_STORE_8;
else if (name == "Storeuintptr")
code = (ptr_size == 8 ? Runtime::ATOMIC_STORE_8 : Runtime::ATOMIC_STORE_4);
}
if ((name == "Xchg" || name == "Xchg64" || name == "Xchguintptr"
- || name == "$Xchgint32" || name == "$Xchgint64")
+ || name == "Xchgint32" || name == "Xchgint64")
&& this->args_ != NULL && this->args_->size() == 2)
{
if (int_size < 8 && (name == "Xchg64" || name == "Xchgint64"))
code = Runtime::ATOMIC_EXCHANGE_8;
res_type = uint64_type;
}
- else if (name == "$Xchgint32")
+ else if (name == "Xchgint32")
{
code = Runtime::ATOMIC_EXCHANGE_4;
res_type = int32_type;
}
- else if (name == "$Xchgint64")
+ else if (name == "Xchgint64")
{
code = Runtime::ATOMIC_EXCHANGE_8;
res_type = int64_type;
if ((name == "Cas" || name == "Cas64" || name == "Casuintptr"
|| name == "Casp1" || name == "CasRel"
- || name == "$Casint32" || name == "$Casint64")
+ || name == "Casint32" || name == "Casint64")
&& this->args_ != NULL && this->args_->size() == 3)
{
- if (int_size < 8 && (name == "Cas64" || name == "$Casint64"))
+ if (int_size < 8 && (name == "Cas64" || name == "Casint64"))
return NULL;
Runtime::Function code;
code = Runtime::ATOMIC_COMPARE_EXCHANGE_4;
else if (name == "Cas64")
code = Runtime::ATOMIC_COMPARE_EXCHANGE_8;
- else if (name == "$Casint32")
+ else if (name == "Casint32")
code = Runtime::ATOMIC_COMPARE_EXCHANGE_4;
- else if (name == "$Casint64")
+ else if (name == "Casint64")
code = Runtime::ATOMIC_COMPARE_EXCHANGE_8;
else if (name == "Casuintptr")
code = (ptr_size == 8
}
if ((name == "Xadd" || name == "Xadd64" || name == "Xaddint64"
- || name == "Xadduintptr" || name == "$Xaddint32")
+ || name == "Xadduintptr" || name == "Xaddint32")
&& this->args_ != NULL && this->args_->size() == 2)
{
if (int_size < 8 && (name == "Xadd64" || name == "Xaddint64"))
code = Runtime::ATOMIC_ADD_FETCH_8;
res_type = uint64_type;
}
- else if (name == "$Xaddint32")
+ else if (name == "Xaddint32")
{
code = Runtime::ATOMIC_ADD_FETCH_4;
res_type = int32_type;
return __atomic_load_n (ptr, __ATOMIC_SEQ_CST);
}
+int32_t Loadint32 (int32_t *ptr)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Loadint32")
+ __attribute__ ((no_split_stack));
+
+int32_t
+Loadint32 (int32_t *ptr)
+{
+ return __atomic_load_n (ptr, __ATOMIC_SEQ_CST);
+}
+
int64_t Loadint64 (int64_t *ptr)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Loadint64")
__attribute__ ((no_split_stack));
return __atomic_add_fetch (ptr, (uint32_t) delta, __ATOMIC_SEQ_CST);
}
+int32_t Xaddint32 (int32_t *ptr, int32_t delta)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Xaddint32")
+ __attribute__ ((no_split_stack));
+
+int32_t
+Xaddint32 (int32_t *ptr, int32_t delta)
+{
+ return __atomic_add_fetch (ptr, delta, __ATOMIC_SEQ_CST);
+}
+
uint64_t Xadd64 (uint64_t *ptr, int64_t delta)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Xadd64")
__attribute__ ((no_split_stack));
return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST);
}
+int32_t Xchgint32 (int32_t *ptr, int32_t new)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Xchgint32")
+ __attribute__ ((no_split_stack));
+
+int32_t
+Xchgint32 (int32_t *ptr, int32_t new)
+{
+ return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST);
+}
+
uint64_t Xchg64 (uint64_t *ptr, uint64_t new)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Xchg64")
__attribute__ ((no_split_stack));
return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST);
}
+int64_t Xchgint64 (int64_t *ptr, int64_t new)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Xchgint64")
+ __attribute__ ((no_split_stack));
+
+int64_t
+Xchgint64 (int64_t *ptr, int64_t new)
+{
+ return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST);
+}
+
uintptr_t Xchguintptr (uintptr_t *ptr, uintptr_t new)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Xchguintptr")
__attribute__ ((no_split_stack));
return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
}
+_Bool Casint32 (int32_t *ptr, int32_t old, int32_t new)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Casint32")
+ __attribute__ ((no_split_stack));
+
+_Bool
+Casint32 (int32_t *ptr, int32_t old, int32_t new)
+{
+ return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
+}
+
+_Bool Casint64 (int64_t *ptr, int64_t old, int64_t new)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Casint64")
+ __attribute__ ((no_split_stack));
+
+_Bool
+Casint64 (int64_t *ptr, int64_t old, int64_t new)
+{
+ return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
+}
+
_Bool Casp1 (void **ptr, void *old, void *new)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Casp1")
__attribute__ ((no_split_stack));
__atomic_store_n (ptr, val, __ATOMIC_SEQ_CST);
}
+void Storeint32 (int32_t *ptr, int32_t val)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Storeint32")
+ __attribute__ ((no_split_stack));
+
+void
+Storeint32 (int32_t *ptr, int32_t val)
+{
+ __atomic_store_n (ptr, val, __ATOMIC_SEQ_CST);
+}
+
void Store64 (uint64_t *ptr, uint64_t val)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Store64")
__attribute__ ((no_split_stack));
__atomic_store_n (ptr, val, __ATOMIC_RELEASE);
}
+void Storeint64 (int64_t *ptr, int64_t val)
+ __asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.Storeint64")
+ __attribute__ ((no_split_stack));
+
+void
+Storeint64 (int64_t *ptr, int64_t val)
+{
+ __atomic_store_n (ptr, val, __ATOMIC_SEQ_CST);
+}
+
void StoreReluintptr (uintptr_t *ptr, uintptr_t val)
__asm__ (GOSYM_PREFIX "runtime_1internal_1atomic.StoreReluintptr")
__attribute__ ((no_split_stack));
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !wasm
// +build !wasm
package atomic
// NO go:noescape annotation; see atomic_pointer.go.
func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
+//go:noescape
+func Casint32(ptr *int32, old, new int32) bool
+
+//go:noescape
+func Casint64(ptr *int64, old, new int64) bool
+
//go:noescape
func Casuintptr(ptr *uintptr, old, new uintptr) bool
+//go:noescape
+func Storeint32(ptr *int32, new int32)
+
+//go:noescape
+func Storeint64(ptr *int64, new int64)
+
//go:noescape
func Storeuintptr(ptr *uintptr, new uintptr)
// TODO(matloob): Should these functions have the go:noescape annotation?
+//go:noescape
+func Loadint32(ptr *int32) int32
+
//go:noescape
func Loadint64(ptr *int64) int64
+//go:noescape
+func Xaddint32(ptr *int32, delta int32) int32
+
//go:noescape
func Xaddint64(ptr *int64, delta int64) int64
+
+//go:noescape
+func Xchgint32(ptr *int32, new int32) int32
+
+//go:noescape
+func Xchgint64(ptr *int64, new int64) int64