Skip to content

Commit c92bbd5

Browse files
authored
Remove references to __asmjs__ macro (#12775)
1 parent dc4a8ef commit c92bbd5

File tree

11 files changed

+21
-143
lines changed

11 files changed

+21
-143
lines changed

system/include/emscripten/em_asm.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#else
2727

28-
#ifndef __asmjs__
2928
// In wasm backend, we need to call the emscripten_asm_const_* functions with
3029
// the C vararg calling convention, because we will call it with a variety of
3130
// arguments, but need to generate a coherent import for the wasm module before
@@ -172,28 +171,6 @@ void emscripten_asm_const_async_on_main_thread(
172171
}
173172
#endif // __cplusplus
174173

175-
#else // __asmjs__
176-
177-
#ifdef __cplusplus
178-
extern "C" {
179-
#endif // __cplusplus
180-
181-
#define _EM_ASM_PREP_ARGS(...) , ##__VA_ARGS__
182-
183-
int emscripten_asm_const_int(const char* code, ...);
184-
double emscripten_asm_const_double(const char* code, ...);
185-
186-
int emscripten_asm_const_int_sync_on_main_thread(const char* code, ...);
187-
double emscripten_asm_const_double_sync_on_main_thread(const char* code, ...);
188-
189-
void emscripten_asm_const_async_on_main_thread(const char* code, ...);
190-
191-
#ifdef __cplusplus
192-
}
193-
#endif // __cplusplus
194-
195-
#endif // __asmjs__
196-
197174
// Note: If the code block in the EM_ASM() family of functions below contains a comma,
198175
// then wrap the whole code block inside parentheses (). See tests/core/test_em_asm_2.cpp
199176
// for example code snippets.

system/include/libcxx/__config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
# endif
5555
#endif // _LIBCPP_STD_VER
5656

57-
#if defined(__ELF__) || defined(__asmjs__) // XXX EMSCRIPTEN: Add define to avoid selecting coff format which activates declspec defines (the ELF define is actually never used)
57+
#if defined(__ELF__)
5858
# define _LIBCPP_OBJECT_FORMAT_ELF 1
5959
#elif defined(__MACH__)
6060
# define _LIBCPP_OBJECT_FORMAT_MACHO 1

system/lib/compiler-rt/lib/builtins/int_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#define XSTR(a) STR(a)
4949
#define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name
5050

51-
#if defined(__ELF__) || defined(__MINGW32__) || defined(__wasm__) || defined(__asmjs__)
51+
#if defined(__ELF__) || defined(__MINGW32__) || defined(__wasm__)
5252
#define COMPILER_RT_ALIAS(name, aliasname) \
5353
COMPILER_RT_ABI __typeof(name) aliasname __attribute__((__alias__(#name)));
5454
#elif defined(__APPLE__)

system/lib/compiler-rt/readme.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ Run `system/lib/update_compiler_rt.py path/to/llvm-root`
1414
Local Change
1515
------------
1616

17-
lib/builtins/int_lib.h: __asmjs__ added to list of supported platforms.
1817
lib/builtins/powitf2.c: enable for wasm as well as PPC

system/lib/dlmalloc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11

22
/* XXX Emscripten XXX */
33
#if __EMSCRIPTEN__
4-
#if defined(__EMSCRIPTEN__) && !defined(__asmjs__)
54
// When building for wasm we export `malloc` and `emscripten_builtin_malloc` as
65
// weak alias of the internal `dlmalloc` which is static to this file.
76
#define DLMALLOC_EXPORT static
8-
#else
9-
#define DLMALLOC_EXPORT __attribute__((__weak__))
10-
#endif
117
/* mmap uses malloc, so malloc can't use mmap */
128
#define HAVE_MMAP 0
139
/* we can only grow the heap up anyhow, so don't try to trim */

system/lib/libc/musl/arch/emscripten/atomic_arch.h

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -49,83 +49,6 @@ static inline void a_or_64(volatile uint64_t *p, uint64_t v)
4949
}
5050

5151
#ifdef __EMSCRIPTEN_PTHREADS__
52-
#ifdef __asmjs__
53-
#define a_store_l a_store_l
54-
static inline void a_store_l(volatile void *p, long x)
55-
{
56-
emscripten_atomic_store_u32((void*)p, x);
57-
}
58-
59-
#define a_or_l a_or_l
60-
static inline void a_or_l(volatile void *p, long v)
61-
{
62-
emscripten_atomic_or_u32((void*)p, v);
63-
}
64-
65-
#define a_cas_p a_cas_p
66-
static inline void *a_cas_p(volatile void *p, void *t, void *s)
67-
{
68-
return (void*)emscripten_atomic_cas_u32(p, (uint32_t)t, (uint32_t)s);
69-
}
70-
71-
#define a_cas_l a_cas_l
72-
static inline long a_cas_l(volatile void *p, long t, long s)
73-
{
74-
return emscripten_atomic_cas_u32(p, t, s);
75-
}
76-
77-
#define a_cas a_cas
78-
static inline int a_cas(volatile int *p, int t, int s)
79-
{
80-
return emscripten_atomic_cas_u32(p, t, s);
81-
}
82-
83-
#define a_or a_or
84-
static inline void a_or(volatile void *p, int v)
85-
{
86-
emscripten_atomic_or_u32((void*)p, v);
87-
}
88-
89-
#define a_and a_and
90-
static inline void a_and(volatile void *p, int v)
91-
{
92-
emscripten_atomic_and_u32((void*)p, v);
93-
}
94-
95-
#define a_swap a_swap
96-
static inline int a_swap(volatile int *x, int v)
97-
{
98-
int old;
99-
do {
100-
old = emscripten_atomic_load_u32(x);
101-
} while(emscripten_atomic_cas_u32(x, old, v) != old);
102-
return old;
103-
}
104-
105-
#define a_fetch_add a_fetch_add
106-
static inline int a_fetch_add(volatile int *x, int v)
107-
{
108-
return emscripten_atomic_add_u32(x, v);
109-
}
110-
111-
#define a_inc a_inc
112-
static inline void a_inc(volatile int *x)
113-
{
114-
emscripten_atomic_add_u32((void*)x, 1);
115-
}
116-
117-
#define a_dec a_dec
118-
static inline void a_dec(volatile int *x)
119-
{
120-
emscripten_atomic_sub_u32((void*)x, 1);
121-
}
122-
123-
#define a_store a_store
124-
static inline void a_store(volatile int *p, int x)
125-
{
126-
emscripten_atomic_store_u32((void*)p, x);
127-
}
128-
#else // __asmjs__
12952
#define a_store_l a_store_l
13053
static inline void a_store_l(volatile void *p, long x)
13154
{
@@ -202,7 +125,6 @@ static inline void a_store(volatile int *p, int x)
202125
{
203126
__c11_atomic_store((_Atomic int*)p, x, __ATOMIC_SEQ_CST);
204127
}
205-
#endif // __asmjs__
206128
#else // __EMSCRIPTEN_PTHREADS__
207129
#define a_store_l a_store_l
208130
static inline void a_store_l(volatile void *p, long x)

system/lib/libcxx/readme.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ Local Modification
1313

1414
Local modifications are marked with the comment: 'XXX EMSCRIPTEN'
1515

16-
1. Define _LIBCPP_OBJECT_FORMAT_ELF under __asmjs__ in libcxx/__config.
16+
1. Define _LIBCPP_HAS_THREAD_API_PTHREAD in libcxx/__config./
1717

18-
2. Define _LIBCPP_HAS_THREAD_API_PTHREAD in libcxx/__config./
18+
2. Define _LIBCPP_ELAST in libcxx/include/config_elast.h
1919

20-
3. Define _LIBCPP_ELAST in libcxx/include/config_elast.h
20+
3. Set init_priority of __start_std_streams in libcxx/iostream.cpp
2121

22-
4. Set init_priority of __start_std_streams in libcxx/iostream.cpp
23-
24-
5. Use _LIBCPP_USING_GETENTROPY (like wasi)
22+
4. Use _LIBCPP_USING_GETENTROPY (like wasi)

tests/core/test_longjmp_unwind.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <stdio.h>
1111
#include <assert.h>
1212

13+
#include <emscripten/stack.h>
14+
1315
#define abs(x) ((x) < 0 ? (-x) : (x))
1416

1517
// A minor stack change is ignorable (e.g., printf)
@@ -19,16 +21,9 @@
1921

2022
jmp_buf jb;
2123

22-
__attribute__((noinline)) int get_stack()
23-
{
24-
int dummy;
25-
int ptr = (int)&dummy;
26-
return ptr;
27-
}
28-
2924
__attribute__((noinline)) void bar()
3025
{
31-
printf("before longjmp: %d\n", get_stack());
26+
printf("before longjmp: %d\n", emscripten_stack_get_current());
3227
longjmp(jb, 1);
3328
}
3429

@@ -38,25 +33,20 @@ __attribute__((noinline)) void foo()
3833
{
3934
temp = alloca(MAJOR);
4035
printf("major allocation at: %d\n", (int)temp);
41-
#ifdef __asmjs__
42-
// asmjs stack grows up, but wasm backend stack grows down, so the delta
43-
// between get_stack() and temp isn't related to the size of the alloca for
44-
// wasm backend
45-
assert(abs(get_stack() - (int)temp) >= MAJOR);
46-
#endif
36+
assert(abs(emscripten_stack_get_current() - (int)temp) >= MAJOR);
4737
bar();
4838
}
4939

5040
int main()
5141
{
52-
int before = get_stack();
42+
int before = emscripten_stack_get_current();
5343
printf("before setjmp: %d\n", before);
5444

5545
if (!setjmp(jb)) {
5646
foo();
5747
return 0;
5848
} else {
59-
int after = get_stack();
49+
int after = emscripten_stack_get_current();
6050
printf("before setjmp: %d\n", after);
6151
assert(abs(after - before) < MINOR); // stack has been unwound (but may have minor printf changes
6252
printf("ok.\n");

tests/core/test_stddef.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ void abort(void);
2626

2727
int main() {
2828
// max_align_t on wasm backend is 16 due to sizeof(long double) being 16.
29-
// On asmjs sizeof(long double) is 8.
30-
#if __asmjs__
31-
if (_Alignof(max_align_t) != 8)
32-
abort();
33-
#else
3429
if (_Alignof(max_align_t) != 16)
3530
abort();
36-
#endif
3731
puts("success");
3832
return 0;
3933
}

tests/test_core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,9 @@ def test_bswap64(self):
461461
def test_sha1(self):
462462
self.do_runf(path_from_root('tests', 'sha1.c'), 'SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6')
463463

464-
@no_wasm_backend('test checks that __asmjs__ is #defined')
465-
def test_asmjs_unknown_emscripten(self):
464+
def test_wasm32_unknown_emscripten(self):
466465
# No other configuration is supported, so always run this.
467-
self.do_runf(path_from_root('tests', 'asmjs-unknown-emscripten.c'), '')
466+
self.do_runf(path_from_root('tests', 'wasm32-unknown-emscripten.c'), '')
468467

469468
def test_cube2md5(self):
470469
self.emcc_args += ['--embed-file', 'cube2md5.txt']

tests/asmjs-unknown-emscripten.c renamed to tests/wasm32-unknown-emscripten.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
#ifndef __EMSCRIPTEN__
99
#error __EMSCRIPTEN__ is not defined
1010
#endif
11-
#ifndef __asmjs__
12-
#error __asmjs__ is not defined
11+
#ifndef __wasm__
12+
#error __wasm__ is not defined
13+
#endif
14+
#ifndef __wasm32__
15+
#error __wasm32__ is not defined
1316
#endif
1417
#ifdef __cplusplus
1518
#ifndef _GNU_SOURCE
@@ -94,8 +97,8 @@ int main() {
9497
assert(sizeof(long) == 4);
9598
assert(sizeof(intmax_t) == 8);
9699
assert(__alignof(double) == 8);
97-
assert(sizeof(long double) == 8);
98-
assert(__alignof(long double) == 8);
100+
assert(sizeof(long double) == 16);
101+
assert(__alignof(long double) == 16);
99102
assert(sizeof(intptr_t) == 4);
100103
assert(sizeof(size_t) == 4);
101104
assert(sizeof(ptrdiff_t) == 4);

0 commit comments

Comments
 (0)