jdk

Форк
0
/
linux_x86_32.S 
518 строк · 15.7 Кб
1
#
2
# Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.
8
#
9
# This code is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
# version 2 for more details (a copy is included in the LICENSE file that
13
# accompanied this code).
14
#
15
# You should have received a copy of the GNU General Public License version
16
# 2 along with this work; if not, write to the Free Software Foundation,
17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
#
19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
# or visit www.oracle.com if you need additional information or have any
21
# questions.
22
#
23

24
#include "defs.S.inc"
25

26
        # NOTE WELL!  The _Copy functions are called directly
27
        # from server-compiler-generated code via CallLeafNoFP,
28
        # which means that they *must* either not use floating
29
        # point or use it in the same manner as does the server
30
        # compiler.
31

32
        .text
33

34
        .p2align 4,,15
35
DECLARE_FUNC(SpinPause):
36
        rep
37
        nop
38
        movl    $1, %eax
39
        ret
40

41
        # Support for void Copy::arrayof_conjoint_bytes(void* from,
42
        #                                               void* to,
43
        #                                               size_t count)
44
        #
45
        .p2align 4,,15
46
DECLARE_FUNC(_Copy_arrayof_conjoint_bytes):
47
        pushl    %esi
48
        movl     4+12(%esp),%ecx      # count
49
        pushl    %edi
50
        movl     8+ 4(%esp),%esi      # from
51
        movl     8+ 8(%esp),%edi      # to
52
        cmpl     %esi,%edi
53
        leal     -1(%esi,%ecx),%eax   # from + count - 1
54
        jbe      acb_CopyRight
55
        cmpl     %eax,%edi
56
        jbe      acb_CopyLeft
57
        # copy from low to high
58
acb_CopyRight:
59
        cmpl     $3,%ecx
60
        jbe      5f
61
1:      movl     %ecx,%eax
62
        shrl     $2,%ecx
63
        jz       4f
64
        cmpl     $32,%ecx
65
        ja       3f
66
        # copy aligned dwords
67
        subl     %esi,%edi
68
        .p2align 4,,15
69
2:      movl     (%esi),%edx
70
        movl     %edx,(%edi,%esi,1)
71
        addl     $4,%esi
72
        subl     $1,%ecx
73
        jnz      2b
74
        addl     %esi,%edi
75
        jmp      4f
76
        # copy aligned dwords
77
3:      rep;     smovl
78
4:      movl     %eax,%ecx
79
5:      andl     $3,%ecx
80
        jz       7f
81
        # copy suffix
82
        xorl     %eax,%eax
83
6:      movb     (%esi,%eax,1),%dl
84
        movb     %dl,(%edi,%eax,1)
85
        addl     $1,%eax
86
        subl     $1,%ecx
87
        jnz      6b
88
7:      popl     %edi
89
        popl     %esi
90
        ret
91
acb_CopyLeft:
92
        std
93
        leal     -4(%edi,%ecx),%edi   # to + count - 4
94
        movl     %eax,%esi            # from + count - 1
95
        movl     %ecx,%eax
96
        subl     $3,%esi              # from + count - 4
97
        cmpl     $3,%ecx
98
        jbe      5f
99
1:      shrl     $2,%ecx
100
        jz       4f
101
        cmpl     $32,%ecx
102
        jbe      2f                   # <= 32 dwords
103
        rep;     smovl
104
        jmp      4f
105
        .space 8
106
2:      subl     %esi,%edi
107
        .p2align 4,,15
108
3:      movl     (%esi),%edx
109
        movl     %edx,(%edi,%esi,1)
110
        subl     $4,%esi
111
        subl     $1,%ecx
112
        jnz      3b
113
        addl     %esi,%edi
114
4:      movl     %eax,%ecx
115
5:      andl     $3,%ecx
116
        jz       7f
117
        subl     %esi,%edi
118
        addl     $3,%esi
119
6:      movb     (%esi),%dl
120
        movb     %dl,(%edi,%esi,1)
121
        subl     $1,%esi
122
        subl     $1,%ecx
123
        jnz      6b
124
7:      cld
125
        popl     %edi
126
        popl     %esi
127
        ret
128

129
        # Support for void Copy::conjoint_jshorts_atomic(void* from,
130
        #                                                void* to,
131
        #                                                size_t count)
132
        .p2align 4,,15
133
DECLARE_FUNC(_Copy_conjoint_jshorts_atomic):
134
        pushl    %esi
135
        movl     4+12(%esp),%ecx      # count
136
        pushl    %edi
137
        movl     8+ 4(%esp),%esi      # from
138
        movl     8+ 8(%esp),%edi      # to
139
        cmpl     %esi,%edi
140
        leal     -2(%esi,%ecx,2),%eax # from + count*2 - 2
141
        jbe      cs_CopyRight
142
        cmpl     %eax,%edi
143
        jbe      cs_CopyLeft
144
        # copy from low to high
145
cs_CopyRight:
146
        # align source address at dword address boundary
147
        movl     %esi,%eax            # original from
148
        andl     $3,%eax              # either 0 or 2
149
        jz       1f                   # no prefix
150
        # copy prefix
151
        subl     $1,%ecx
152
        jl       5f                   # zero count
153
        movw     (%esi),%dx
154
        movw     %dx,(%edi)
155
        addl     %eax,%esi            # %eax == 2
156
        addl     %eax,%edi
157
1:      movl     %ecx,%eax            # word count less prefix
158
        sarl     %ecx                 # dword count
159
        jz       4f                   # no dwords to move
160
        cmpl     $32,%ecx
161
        jbe      2f                   # <= 32 dwords
162
        # copy aligned dwords
163
        rep;     smovl
164
        jmp      4f
165
        # copy aligned dwords
166
2:      subl     %esi,%edi
167
        .p2align 4,,15
168
3:      movl     (%esi),%edx
169
        movl     %edx,(%edi,%esi,1)
170
        addl     $4,%esi
171
        subl     $1,%ecx
172
        jnz      3b
173
        addl     %esi,%edi
174
4:      andl     $1,%eax              # suffix count
175
        jz       5f                   # no suffix
176
        # copy suffix
177
        movw     (%esi),%dx
178
        movw     %dx,(%edi)
179
5:      popl     %edi
180
        popl     %esi
181
        ret
182
        # copy from high to low
183
cs_CopyLeft:
184
        std
185
        leal     -4(%edi,%ecx,2),%edi # to + count*2 - 4
186
        movl     %eax,%esi            # from + count*2 - 2
187
        movl     %ecx,%eax
188
        subl     $2,%esi              # from + count*2 - 4
189
1:      sarl     %ecx                 # dword count
190
        jz       4f                   # no dwords to move
191
        cmpl     $32,%ecx
192
        ja       3f                   # > 32 dwords
193
        subl     %esi,%edi
194
        .p2align 4,,15
195
2:      movl     (%esi),%edx
196
        movl     %edx,(%edi,%esi,1)
197
        subl     $4,%esi
198
        subl     $1,%ecx
199
        jnz      2b
200
        addl     %esi,%edi
201
        jmp      4f
202
3:      rep;     smovl
203
4:      andl     $1,%eax              # suffix count
204
        jz       5f                   # no suffix
205
        # copy suffix
206
        addl     $2,%esi
207
        addl     $2,%edi
208
        movw     (%esi),%dx
209
        movw     %dx,(%edi)
210
5:      cld
211
        popl     %edi
212
        popl     %esi
213
        ret
214

215
        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
216
        #                                                 void* to,
217
        #                                                 size_t count)
218
        .p2align 4,,15
219
DECLARE_FUNC(_Copy_arrayof_conjoint_jshorts):
220
        pushl    %esi
221
        movl     4+12(%esp),%ecx      # count
222
        pushl    %edi
223
        movl     8+ 4(%esp),%esi      # from
224
        movl     8+ 8(%esp),%edi      # to
225
        cmpl     %esi,%edi
226
        leal     -2(%esi,%ecx,2),%eax # from + count*2 - 2
227
        jbe      acs_CopyRight
228
        cmpl     %eax,%edi
229
        jbe      acs_CopyLeft
230
acs_CopyRight:
231
        movl     %ecx,%eax            # word count
232
        sarl     %ecx                 # dword count
233
        jz       4f                   # no dwords to move
234
        cmpl     $32,%ecx
235
        jbe      2f                   # <= 32 dwords
236
        # copy aligned dwords
237
        rep;     smovl
238
        jmp      4f
239
        # copy aligned dwords
240
        .space 5
241
2:      subl     %esi,%edi
242
        .p2align 4,,15
243
3:      movl     (%esi),%edx
244
        movl     %edx,(%edi,%esi,1)
245
        addl     $4,%esi
246
        subl     $1,%ecx
247
        jnz      3b
248
        addl     %esi,%edi
249
4:      andl     $1,%eax              # suffix count
250
        jz       5f                   # no suffix
251
        # copy suffix
252
        movw     (%esi),%dx
253
        movw     %dx,(%edi)
254
5:      popl     %edi
255
        popl     %esi
256
        ret
257
acs_CopyLeft:
258
        std
259
        leal     -4(%edi,%ecx,2),%edi # to + count*2 - 4
260
        movl     %eax,%esi            # from + count*2 - 2
261
        movl     %ecx,%eax
262
        subl     $2,%esi              # from + count*2 - 4
263
        sarl     %ecx                 # dword count
264
        jz       4f                   # no dwords to move
265
        cmpl     $32,%ecx
266
        ja       3f                   # > 32 dwords
267
        subl     %esi,%edi
268
        .p2align 4,,15
269
2:      movl     (%esi),%edx
270
        movl     %edx,(%edi,%esi,1)
271
        subl     $4,%esi
272
        subl     $1,%ecx
273
        jnz      2b
274
        addl     %esi,%edi
275
        jmp      4f
276
3:      rep;     smovl
277
4:      andl     $1,%eax              # suffix count
278
        jz       5f                   # no suffix
279
        # copy suffix
280
        addl     $2,%esi
281
        addl     $2,%edi
282
        movw     (%esi),%dx
283
        movw     %dx,(%edi)
284
5:      cld
285
        popl     %edi
286
        popl     %esi
287
        ret
288

289
        # Support for void Copy::conjoint_jints_atomic(void* from,
290
        #                                              void* to,
291
        #                                              size_t count)
292
        # Equivalent to
293
        #   arrayof_conjoint_jints
294
        .p2align 4,,15
295
DECLARE_FUNC(_Copy_conjoint_jints_atomic):
296
DECLARE_FUNC(_Copy_arrayof_conjoint_jints):
297
        pushl    %esi
298
        movl     4+12(%esp),%ecx      # count
299
        pushl    %edi
300
        movl     8+ 4(%esp),%esi      # from
301
        movl     8+ 8(%esp),%edi      # to
302
        cmpl     %esi,%edi
303
        leal     -4(%esi,%ecx,4),%eax # from + count*4 - 4
304
        jbe      ci_CopyRight
305
        cmpl     %eax,%edi
306
        jbe      ci_CopyLeft
307
ci_CopyRight:
308
        cmpl     $32,%ecx
309
        jbe      2f                   # <= 32 dwords
310
        rep;     smovl
311
        popl     %edi
312
        popl     %esi
313
        ret
314
        .space 10
315
2:      subl     %esi,%edi
316
        jmp      4f
317
        .p2align 4,,15
318
3:      movl     (%esi),%edx
319
        movl     %edx,(%edi,%esi,1)
320
        addl     $4,%esi
321
4:      subl     $1,%ecx
322
        jge      3b
323
        popl     %edi
324
        popl     %esi
325
        ret
326
ci_CopyLeft:
327
        std
328
        leal     -4(%edi,%ecx,4),%edi # to + count*4 - 4
329
        cmpl     $32,%ecx
330
        ja       4f                   # > 32 dwords
331
        subl     %eax,%edi            # eax == from + count*4 - 4
332
        jmp      3f
333
        .p2align 4,,15
334
2:      movl     (%eax),%edx
335
        movl     %edx,(%edi,%eax,1)
336
        subl     $4,%eax
337
3:      subl     $1,%ecx
338
        jge      2b
339
        cld
340
        popl     %edi
341
        popl     %esi
342
        ret
343
4:      movl     %eax,%esi            # from + count*4 - 4
344
        rep;     smovl
345
        cld
346
        popl     %edi
347
        popl     %esi
348
        ret
349

350
        # Support for void Copy::conjoint_jlongs_atomic(jlong* from,
351
        #                                               jlong* to,
352
        #                                               size_t count)
353
        #
354
        # 32-bit
355
        #
356
        # count treated as signed
357
        /*
358
        #
359
        # if (from > to) {
360
        #   while (--count >= 0) {
361
        #     *to++ = *from++;
362
        #   }
363
        # } else {
364
        #   while (--count >= 0) {
365
        #     to[count] = from[count];
366
        #   }
367
        # }
368
        */
369
        .p2align 4,,15
370
DECLARE_FUNC(_Copy_conjoint_jlongs_atomic):
371
        movl     4+8(%esp),%ecx       # count
372
        movl     4+0(%esp),%eax       # from
373
        movl     4+4(%esp),%edx       # to
374
        cmpl     %eax,%edx
375
        jae      cla_CopyLeft
376
cla_CopyRight:
377
        subl     %eax,%edx
378
        jmp      2f
379
        .p2align 4,,15
380
1:      fildll   (%eax)
381
        fistpll  (%edx,%eax,1)
382
        addl     $8,%eax
383
2:      subl     $1,%ecx
384
        jge      1b
385
        ret
386
        .p2align 4,,15
387
3:      fildll   (%eax,%ecx,8)
388
        fistpll  (%edx,%ecx,8)
389
cla_CopyLeft:
390
        subl     $1,%ecx
391
        jge      3b
392
        ret
393

394
        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
395
        #                                                 void* to,
396
        #                                                 size_t count)
397
        .p2align 4,,15
398
DECLARE_FUNC(_mmx_Copy_arrayof_conjoint_jshorts):
399
        pushl    %esi
400
        movl     4+12(%esp),%ecx
401
        pushl    %edi
402
        movl     8+ 4(%esp),%esi
403
        movl     8+ 8(%esp),%edi
404
        cmpl     %esi,%edi
405
        leal     -2(%esi,%ecx,2),%eax
406
        jbe      mmx_acs_CopyRight
407
        cmpl     %eax,%edi
408
        jbe      mmx_acs_CopyLeft
409
mmx_acs_CopyRight:
410
        movl     %ecx,%eax
411
        sarl     %ecx
412
        je       5f
413
        cmpl     $33,%ecx
414
        jae      3f
415
1:      subl     %esi,%edi
416
        .p2align 4,,15
417
2:      movl     (%esi),%edx
418
        movl     %edx,(%edi,%esi,1)
419
        addl     $4,%esi
420
        subl     $1,%ecx
421
        jnz      2b
422
        addl     %esi,%edi
423
        jmp      5f
424
3:      smovl # align to 8 bytes, we know we are 4 byte aligned to start
425
        subl     $1,%ecx
426
4:      .p2align 4,,15
427
        movq     0(%esi),%mm0
428
        addl     $64,%edi
429
        movq     8(%esi),%mm1
430
        subl     $16,%ecx
431
        movq     16(%esi),%mm2
432
        movq     %mm0,-64(%edi)
433
        movq     24(%esi),%mm0
434
        movq     %mm1,-56(%edi)
435
        movq     32(%esi),%mm1
436
        movq     %mm2,-48(%edi)
437
        movq     40(%esi),%mm2
438
        movq     %mm0,-40(%edi)
439
        movq     48(%esi),%mm0
440
        movq     %mm1,-32(%edi)
441
        movq     56(%esi),%mm1
442
        movq     %mm2,-24(%edi)
443
        movq     %mm0,-16(%edi)
444
        addl     $64,%esi
445
        movq     %mm1,-8(%edi)
446
        cmpl     $16,%ecx
447
        jge      4b
448
        emms
449
        testl    %ecx,%ecx
450
        ja       1b
451
5:      andl     $1,%eax
452
        je       7f
453
6:      movw     (%esi),%dx
454
        movw     %dx,(%edi)
455
7:	popl     %edi
456
        popl     %esi
457
        ret
458
mmx_acs_CopyLeft:
459
        std
460
        leal     -4(%edi,%ecx,2),%edi
461
        movl     %eax,%esi
462
        movl     %ecx,%eax
463
        subl     $2,%esi
464
        sarl     %ecx
465
        je       4f
466
        cmpl     $32,%ecx
467
        ja       3f
468
        subl     %esi,%edi
469
        .p2align 4,,15
470
2:      movl     (%esi),%edx
471
        movl     %edx,(%edi,%esi,1)
472
        subl     $4,%esi
473
        subl     $1,%ecx
474
        jnz      2b
475
        addl     %esi,%edi
476
        jmp      4f
477
3:      rep;     smovl
478
4:      andl     $1,%eax
479
        je       6f
480
        addl     $2,%esi
481
        addl     $2,%edi
482
5:      movw     (%esi),%dx
483
        movw     %dx,(%edi)
484
6:      cld
485
        popl     %edi
486
        popl     %esi
487
        ret
488

489

490
        # Support for jlong Atomic::cmpxchg(volatile jlong* dest,
491
        #                                   jlong compare_value,
492
        #                                   jlong exchange_value)
493
        #
494
        .p2align 4,,15
495
DECLARE_FUNC(_Atomic_cmpxchg_long):
496
                                   #  8(%esp) : return PC
497
        pushl    %ebx              #  4(%esp) : old %ebx
498
        pushl    %edi              #  0(%esp) : old %edi
499
        movl     12(%esp), %ebx    # 12(%esp) : exchange_value (low)
500
        movl     16(%esp), %ecx    # 16(%esp) : exchange_value (high)
501
        movl     24(%esp), %eax    # 24(%esp) : compare_value (low)
502
        movl     28(%esp), %edx    # 28(%esp) : compare_value (high)
503
        movl     20(%esp), %edi    # 20(%esp) : dest
504
        lock cmpxchg8b (%edi)
505
        popl     %edi
506
        popl     %ebx
507
        ret
508

509

510
        # Support for jlong Atomic::load and Atomic::store.
511
        # void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst)
512
        .p2align 4,,15
513
DECLARE_FUNC(_Atomic_move_long):
514
        movl     4(%esp), %eax   # src
515
        fildll    (%eax)
516
        movl     8(%esp), %eax   # dest
517
        fistpll   (%eax)
518
        ret
519

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.