--- /dev/null
+package core.intrinsics.atomics
+
+#private_file {
+ runtime :: package Runtime
+
+ #if !#defined(runtime.Allow_Multi_Threading) {
+ #error "Multi-threading is not enabled so you cannot include the 'core.intrinsics.atomics' package."
+ }
+}
+
+// __atomic_wait is only valid for i32 and i64
+__atomic_wait :: (addr: ^$T, value: T, timeout: i64 = 0) -> i32 #intrinsic ---
+__atomic_notify :: (addr: rawptr, maximum: i32 = 1) -> i32 #intrinsic ---
+
+__atomic_fence :: () -> void #intrinsic ---
+
+// These are only valid for the eight integer types (i8, u8, i16, u16, i32, u32, i64, u64)
+__atomic_load :: (addr: ^$T) -> T #intrinsic ---
+__atomic_store :: (addr: ^$T, value: T) -> void #intrinsic ---
+__atomic_add :: (addr: ^$T, value: T) -> T #intrinsic ---
+__atomic_sub :: (addr: ^$T, value: T) -> T #intrinsic ---
+__atomic_and :: (addr: ^$T, value: T) -> T #intrinsic ---
+__atomic_or :: (addr: ^$T, value: T) -> T #intrinsic ---
+__atomic_xor :: (addr: ^$T, value: T) -> T #intrinsic ---
+__atomic_xchg :: (addr: ^$T, value: T) -> T #intrinsic ---
+__atomic_cmpxchg :: (addr: ^$T, compare: T, value: T) -> T #intrinsic ---
#if runtime.Runtime != runtime.Runtime_Custom {
#load "./stdio"
}
+
+#if #defined(runtime.Allow_Multi_Threading) {
+ #load "./intrinsics/atomics"
+}
\ No newline at end of file
ONYX_INTRINSIC_I32X4_TRUNC_SAT_F32X4_U,
ONYX_INTRINSIC_F32X4_CONVERT_I32X4_S,
ONYX_INTRINSIC_F32X4_CONVERT_I32X4_U,
+
+ ONYX_INTRINSIC_ATOMIC_WAIT,
+ ONYX_INTRINSIC_ATOMIC_NOTIFY,
+
+ ONYX_INTRINSIC_ATOMIC_FENCE,
+
+ ONYX_INTRINSIC_ATOMIC_LOAD,
+ ONYX_INTRINSIC_ATOMIC_STORE,
+ ONYX_INTRINSIC_ATOMIC_ADD,
+ ONYX_INTRINSIC_ATOMIC_SUB,
+ ONYX_INTRINSIC_ATOMIC_AND,
+ ONYX_INTRINSIC_ATOMIC_OR,
+ ONYX_INTRINSIC_ATOMIC_XOR,
+ ONYX_INTRINSIC_ATOMIC_XCHG,
+ ONYX_INTRINSIC_ATOMIC_CMPXCHG,
} OnyxIntrinsic;
typedef enum CallingConvention {
WasmType param_types[];
} WasmFuncType;
-#define SIMD_INSTR_MASK 0x10000
-#define EXT_INSTR_MASK 0x20000
+#define SIMD_INSTR_MASK 0x10000
+#define EXT_INSTR_MASK 0x20000
+#define ATOMIC_INSTR_MASK 0x40000
typedef enum WasmInstructionType {
WI_UNREACHABLE = 0x00,
WI_MEMORY_COPY = EXT_INSTR_MASK | 0x0a,
WI_MEMORY_FILL = EXT_INSTR_MASK | 0x0b,
+
} WasmInstructionType;
typedef union {
{ "f32x4_convert_i32x4_s", ONYX_INTRINSIC_F32X4_CONVERT_I32X4_S },
{ "f32x4_convert_i32x4_u", ONYX_INTRINSIC_F32X4_CONVERT_I32X4_U },
+ { "__atomic_wait", ONYX_INTRINSIC_ATOMIC_WAIT },
+ { "__atomic_notify", ONYX_INTRINSIC_ATOMIC_NOTIFY },
+
+ { "__atomic_fence", ONYX_INTRINSIC_ATOMIC_FENCE },
+
+ { "__atomic_load", ONYX_INTRINSIC_ATOMIC_LOAD },
+ { "__atomic_store", ONYX_INTRINSIC_ATOMIC_STORE },
+ { "__atomic_add", ONYX_INTRINSIC_ATOMIC_ADD },
+ { "__atomic_sub", ONYX_INTRINSIC_ATOMIC_SUB },
+ { "__atomic_and", ONYX_INTRINSIC_ATOMIC_AND },
+ { "__atomic_or", ONYX_INTRINSIC_ATOMIC_OR },
+ { "__atomic_xor", ONYX_INTRINSIC_ATOMIC_XOR },
+ { "__atomic_xchg", ONYX_INTRINSIC_ATOMIC_XCHG },
+ { "__atomic_cmpxchg", ONYX_INTRINSIC_ATOMIC_CMPXCHG },
+
{ NULL, ONYX_INTRINSIC_UNDEFINED },
};
*pcode = code;
}
+
+EMIT_FUNC(intrinsic_atomic_wait, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_notify, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC_NO_ARGS(intrinsic_atomic_fence) {
+}
+
+EMIT_FUNC(intrinsic_atomic_load, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_store, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_add, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_sub, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_and, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_or, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_xor, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_xchg, Type* type, OnyxToken* where) {
+}
+
+EMIT_FUNC(intrinsic_atomic_cmpxchg, Type* type, OnyxToken* where) {
+}
bh_buffer_write_byte(buff, 0xFC);
leb = uint_to_uleb128((u64) (instr->type &~ EXT_INSTR_MASK), &leb_len);
bh_buffer_append(buff, leb, leb_len);
+
+ } else if (instr->type & ATOMIC_INSTR_MASK) {
+ bh_buffer_write_byte(buff, 0xFE);
+ leb = uint_to_uleb128((u64) (instr->type &~ ATOMIC_INSTR_MASK), &leb_len);
+ bh_buffer_append(buff, leb, leb_len);
} else {
bh_buffer_write_byte(buff, (u8) instr->type);