@@ -33,6 +33,11 @@ using StaticInfixWitness = SWIFT_CC(swift) bool(OpaqueValue *, OpaqueValue *,
33
33
#define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOTPCREL + 1"
34
34
#endif
35
35
36
+ #if defined(__wasm__)
37
+ // Wasm doesn't support pc relative relocation, so use absolute ptr
38
+ #define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL
39
+ #endif
40
+
36
41
// MachO indirect symbol references.
37
42
#if defined(__MACH__)
38
43
@@ -105,6 +110,16 @@ __asm(
105
110
" .lcomm __swift_tupleEquatable_private, 128, 16\n "
106
111
" .section .rdata, \" dr\"\n "
107
112
#pragma comment(linker, "/EXPORT:_swift_tupleEquatable_conf,DATA")
113
+ #elif defined(__wasm__)
114
+ " .section .rodata,\"\" ,@\n "
115
+ " __swift_tupleEquatable_private:\n "
116
+ " .type __swift_tupleEquatable_private, @object\n "
117
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
118
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
119
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
120
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
121
+ " .size __swift_tupleEquatable_private, 128\n "
122
+ " .type " TUPLE_EQUATABLE_CONF " , @object\n "
108
123
#endif
109
124
" .globl " TUPLE_EQUATABLE_CONF " \n "
110
125
" .p2align 2\n "
@@ -128,7 +143,11 @@ __asm(
128
143
// Equatable == method descriptor.
129
144
" .long " INDIRECT_RELREF_GOTPCREL(EQUATABLE_EE_METHOD_DESCRIPTOR) "\n"
130
145
// This is a direct relative reference to the equals witness defined below.
146
+ #if defined (__wasm__)
147
+ " .long (" TUPLE_EQUATABLE_EQUALS " )\n"
148
+ #else
131
149
" .long (" TUPLE_EQUATABLE_EQUALS " ) - .\n "
150
+ #endif
132
151
// The witness table size in words.
133
152
" .short 0\n "
134
153
// The witness table private size in words & requires instantiation.
@@ -137,8 +156,12 @@ __asm(
137
156
" .long 0\n "
138
157
// This is a direct relative reference to the private data for the
139
158
// conformance.
159
+ #if defined(__wasm__)
160
+ " .long __swift_tupleEquatable_private\n "
161
+ #else
140
162
" .long __swift_tupleEquatable_private - .\n "
141
- #if defined (__ELF__)
163
+ #endif
164
+ #if defined(__ELF__) || defined(__wasm__)
142
165
" .size " TUPLE_EQUATABLE_CONF " , 40\n "
143
166
#endif
144
167
);
@@ -236,17 +259,23 @@ __asm(
236
259
#elif defined(_WIN32)
237
260
" .section .sw5tyrf$B, \" dr\" , discard, \" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \"\n "
238
261
" .globl \" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \"\n "
262
+ #elif defined(__wasm__)
263
+ " .section .rodata.__swift5_typeref,\"\" ,@\n "
239
264
#endif
240
265
" .p2align 1\n "
241
266
" \" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \" :\n "
242
267
" .byte 255\n "
243
268
" .byte 7\n "
244
269
// This is a direct relative reference to the base accessor for Equatable
245
270
// defined below.
271
+ #if defined(__wasm__)
272
+ " .long (" TUPLE_COMPARABLE_BASEACCESSOREQUATABLE " )\n "
273
+ #else
246
274
" .long (" TUPLE_COMPARABLE_BASEACCESSOREQUATABLE " ) - .\n "
275
+ #endif
247
276
// This 0 is our null terminator.
248
277
" .byte 0\n "
249
- #if defined (__ELF__)
278
+ #if defined (__ELF__) || defined(__wasm__)
250
279
" .size \" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \" , 7\n "
251
280
#endif
252
281
);
@@ -268,6 +297,16 @@ __asm(
268
297
" .lcomm __swift_tupleComparable_private, 128, 16\n "
269
298
" .section .rdata, \" dr\"\n "
270
299
#pragma comment(linker, "/EXPORT:_swift_tupleComparable_conf,DATA")
300
+ #elif defined(__wasm__)
301
+ " .section .rodata,\"\" ,@\n "
302
+ " __swift_tupleComparable_private:\n "
303
+ " .type __swift_tupleComparable_private, @object\n "
304
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
305
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
306
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
307
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
308
+ " .size __swift_tupleComparable_private, 128\n "
309
+ " .type " TUPLE_COMPARABLE_CONF " , @object\n "
271
310
#endif
272
311
" .globl " TUPLE_COMPARABLE_CONF " \n "
273
312
" .p2align 2\n "
@@ -293,30 +332,50 @@ __asm(
293
332
// This is a direct relative reference to the associated conformance for
294
333
// Equatable defined above in assembly. NOTE: We + 1 here because the
295
334
// associated conformance structure is 1 aligned.
335
+ #if defined (__wasm__)
336
+ " .long (\" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \" ) + 1\n "
337
+ #else
296
338
" .long (\" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \" ) - . + 1\n "
339
+ #endif
297
340
// This is an indirectable relative reference to the GOT entry for the
298
341
// Comparable.< method descriptor.
299
342
" .long " INDIRECT_RELREF_GOTPCREL(COMPARABLE_LT_METHOD_DESCRIPTOR) "\n"
300
343
// This is a direct relative reference to the less than witness defined below.
344
+ #if defined (__wasm__)
345
+ " .long (" TUPLE_COMPARABLE_LESSTHAN " )\n"
346
+ #else
301
347
" .long (" TUPLE_COMPARABLE_LESSTHAN " ) - .\n "
348
+ #endif
302
349
// This is an indirectable relative reference to the GOT entry for the
303
350
// Comparable.<= method descriptor.
304
351
" .long " INDIRECT_RELREF_GOTPCREL(COMPARBALE_LTE_METHOD_DESCRIPTOR) " \n "
305
352
// This is a direct relative reference to the less than or equal witness
306
353
// defined below.
354
+ #if defined(__wasm__)
355
+ " .long (" TUPLE_COMPARABLE_LESSTHANOREQUAL " )\n "
356
+ #else
307
357
" .long (" TUPLE_COMPARABLE_LESSTHANOREQUAL " ) - .\n "
358
+ #endif
308
359
// This is an indirectable relative reference to the GOT entry for the
309
360
// Comparable.>= method descriptor.
310
361
" .long " INDIRECT_RELREF_GOTPCREL(COMPARABLE_GTE_METHOD_DESCRIPTOR) " \n "
311
362
// This is a direct relative reference to the greater than or equal witness
312
363
// defined below.
364
+ #if defined(__wasm__)
365
+ " .long (" TUPLE_COMPARABLE_GREATERTHANOREQUAL " )\n "
366
+ #else
313
367
" .long (" TUPLE_COMPARABLE_GREATERTHANOREQUAL " ) - .\n "
368
+ #endif
314
369
// This is an indirectable relative reference to the GOT entry for the
315
370
// Comparable.> method descriptor.
316
371
" .long " INDIRECT_RELREF_GOTPCREL(COMPARABLE_GT_METHOD_DESCRIPTOR) " \n "
317
372
// This is a direct relative reference to the greater than witness defined
318
373
// below.
374
+ #if defined(__wasm__)
375
+ " .long (" TUPLE_COMPARABLE_GREATERTHAN " )\n "
376
+ #else
319
377
" .long (" TUPLE_COMPARABLE_GREATERTHAN " ) - .\n "
378
+ #endif
320
379
// The witness table size in words.
321
380
" .short 0\n "
322
381
// The witness table private size in words & requires instantiation.
@@ -325,8 +384,12 @@ __asm(
325
384
" .long 0\n "
326
385
// This is a direct relative reference to the private data for the
327
386
// conformance.
387
+ #if defined(__wasm__)
388
+ " .long __swift_tupleComparable_private\n "
389
+ #else
328
390
" .long __swift_tupleComparable_private - .\n "
329
- #if defined (__ELF__)
391
+ #endif
392
+ #if defined(__ELF__) || defined(__wasm__)
330
393
" .size " TUPLE_COMPARABLE_CONF " , 72\n "
331
394
#endif
332
395
);
@@ -634,6 +697,16 @@ __asm(
634
697
" .lcomm __swift_tupleHashable_private, 128, 16\n "
635
698
" .section .rdata, \" dr\"\n "
636
699
#pragma comment(linker, "/EXPORT:_swift_tupleHashable_conf,DATA")
700
+ #elif defined(__wasm__)
701
+ " .section .rodata,\"\" ,@\n "
702
+ " __swift_tupleHashable_private:\n "
703
+ " .type __swift_tupleHashable_private, @object\n "
704
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
705
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
706
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
707
+ " .8byte 0\n .8byte 0\n .8byte 0\n .8byte 0\n "
708
+ " .size __swift_tupleHashable_private, 128\n "
709
+ " .type " TUPLE_HASHABLE_CONF " , @object\n "
637
710
#endif
638
711
" .globl " TUPLE_HASHABLE_CONF " \n "
639
712
" .p2align 2\n "
@@ -663,17 +736,29 @@ __asm(
663
736
// from its elements whose witness table is located in the same place for both
664
737
// protocols. NOTE: We + 1 here because the associated conformance
665
738
// structure is 1 aligned.
739
+ #if defined (__wasm__)
740
+ " .long (\" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \" ) + 1\n "
741
+ #else
666
742
" .long (\" " TUPLE_COMPARABLE_ASSOCIATEDCONFORMANCE " \" ) - . + 1\n "
743
+ #endif
667
744
// This is an indirectable relative reference to the GOT entry for the
668
745
// Hashable.hashValue method descriptor.
669
746
" .long " INDIRECT_RELREF_GOTPCREL(HASHABLE_HASHVALUE_METHOD_DESCRIPTOR) "\n"
670
747
// This is a direct relative reference to the hashValue witness defined below.
748
+ #if defined (__wasm__)
749
+ " .long (" TUPLE_HASHABLE_HASHVALUE " )\n"
750
+ #else
671
751
" .long (" TUPLE_HASHABLE_HASHVALUE " ) - .\n "
752
+ #endif
672
753
// This is an indirectable relative reference to the GOT entry for the
673
754
// Hashable.hash(into:) method descriptor.
674
755
" .long " INDIRECT_RELREF_GOTPCREL(HASHABLE_HASH_METHOD_DESCRIPTOR) " \n "
675
756
// This is a direct relative reference to the hash(into:) witness defined below.
757
+ #if defined(__wasm__)
758
+ " .long (" TUPLE_HASHABLE_HASH " )\n "
759
+ #else
676
760
" .long (" TUPLE_HASHABLE_HASH " ) - .\n "
761
+ #endif
677
762
// This is an indirectable relative reference to the GOT equivalent for the
678
763
// Hashable._rawHashValue method descriptor.
679
764
" .long " INDIRECT_RELREF_GOTPCREL(HASHABLE_RAWHASHVALUE_METHOD_DESCRIPTOR) " \n "
@@ -688,8 +773,12 @@ __asm(
688
773
" .long 0\n "
689
774
// This is a direct relative reference to the private data for the
690
775
// conformance.
776
+ #if defined(__wasm__)
777
+ " .long __swift_tupleHashable_private\n "
778
+ #else
691
779
" .long __swift_tupleHashable_private - .\n "
692
- #if defined (__ELF__)
780
+ #endif
781
+ #if defined(__ELF__) || defined(__wasm__)
693
782
" .size " TUPLE_HASHABLE_CONF " , 64\n "
694
783
#endif
695
784
);
0 commit comments