~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to erts/emulator/hipe/hipe_amd64_glue.S

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
 
 * 
4
 
 * Copyright Ericsson AB 2004-2009. All Rights Reserved.
5
 
 * 
 
3
 *
 
4
 * Copyright Ericsson AB 2004-2010. All Rights Reserved.
 
5
 *
6
6
 * The contents of this file are subject to the Erlang Public License,
7
7
 * Version 1.1, (the "License"); you may not use this file except in
8
8
 * compliance with the License. You should have received a copy of the
9
9
 * Erlang Public License along with this software. If not, it can be
10
10
 * retrieved online at http://www.erlang.org/.
11
 
 * 
 
11
 *
12
12
 * Software distributed under the License is distributed on an "AS IS"
13
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
 * the License for the specific language governing rights and limitations
15
15
 * under the License.
16
 
 * 
 
16
 *
17
17
 * %CopyrightEnd%
18
18
 */
19
19
/*
56
56
        /* switch to native stack */    \
57
57
        SWITCH_C_TO_ERLANG
58
58
 
59
 
        .section ".text"
 
59
        TEXT
60
60
 
61
61
/*
62
62
 * int x86_call_to_native(Process *p);
63
63
 * Emulated code recursively calls native code.
64
64
 */
65
65
        .align  4
66
 
        .global x86_call_to_native
67
 
        .global nbif_return
68
 
x86_call_to_native:
 
66
        GLOBAL(CSYM(x86_call_to_native))
 
67
        GLOBAL(ASYM(nbif_return))
 
68
CSYM(x86_call_to_native):
69
69
        ENTER_FROM_C
70
70
        /* get argument registers */
71
71
        LOAD_ARG_REGS
77
77
 *
78
78
 * This is where native code returns to emulated code.
79
79
 */
80
 
nbif_return:
 
80
ASYM(nbif_return):
81
81
        movq    %rax, P_ARG0(P)                 # save retval
82
82
        movl    $HIPE_MODE_SWITCH_RES_RETURN, %eax
83
83
/* FALLTHROUGH to .flush_exit
118
118
 * XXX: Different stubs for different number of register parameters?
119
119
 */
120
120
        .align  4
121
 
        .global nbif_callemu
122
 
nbif_callemu:
 
121
        GLOBAL(ASYM(nbif_callemu))
 
122
ASYM(nbif_callemu):
123
123
        STORE_ARG_REGS
124
124
        movl    $HIPE_MODE_SWITCH_RES_CALL, %eax
125
125
        jmp     .suspend_exit
128
128
 * nbif_apply
129
129
 */
130
130
        .align  4
131
 
        .global nbif_apply
132
 
nbif_apply:
 
131
        GLOBAL(ASYM(nbif_apply))
 
132
ASYM(nbif_apply):
133
133
        STORE_ARG_REGS
134
134
        movl    $HIPE_MODE_SWITCH_RES_APPLY, %eax
135
135
        jmp     .suspend_exit
145
145
 */
146
146
#if NR_ARG_REGS >= 6
147
147
        .align  4
148
 
        .global nbif_ccallemu6
149
 
nbif_ccallemu6:
 
148
        GLOBAL(ASYM(nbif_ccallemu6))
 
149
ASYM(nbif_ccallemu6):
150
150
        movq    ARG5, P_ARG5(P)
151
151
#if NR_ARG_REGS > 6
152
152
        movq    ARG6, ARG5
158
158
 
159
159
#if NR_ARG_REGS >= 5
160
160
        .align  4
161
 
        .global nbif_ccallemu5
162
 
nbif_ccallemu5:
 
161
        GLOBAL(ASYM(nbif_ccallemu5))
 
162
ASYM(nbif_ccallemu5):
163
163
        movq    ARG4, P_ARG4(P)
164
164
#if NR_ARG_REGS > 5
165
165
        movq    ARG5, ARG4
171
171
 
172
172
#if NR_ARG_REGS >= 4
173
173
        .align  4
174
 
        .global nbif_ccallemu4
175
 
nbif_ccallemu4:
 
174
        GLOBAL(ASYM(nbif_ccallemu4))
 
175
ASYM(nbif_ccallemu4):
176
176
        movq    ARG3, P_ARG3(P)
177
177
#if NR_ARG_REGS > 4
178
178
        movq    ARG4, ARG3
184
184
 
185
185
#if NR_ARG_REGS >= 3
186
186
        .align  4
187
 
        .global nbif_ccallemu3
188
 
nbif_ccallemu3:
 
187
        GLOBAL(ASYM(nbif_ccallemu3))
 
188
ASYM(nbif_ccallemu3):
189
189
        movq    ARG2, P_ARG2(P)
190
190
#if NR_ARG_REGS > 3
191
191
        movq    ARG3, ARG2
197
197
 
198
198
#if NR_ARG_REGS >= 2
199
199
        .align  4
200
 
        .global nbif_ccallemu2
201
 
nbif_ccallemu2:
 
200
        GLOBAL(ASYM(nbif_ccallemu2))
 
201
ASYM(nbif_ccallemu2):
202
202
        movq    ARG1, P_ARG1(P)
203
203
#if NR_ARG_REGS > 2
204
204
        movq    ARG2, ARG1
210
210
 
211
211
#if NR_ARG_REGS >= 1
212
212
        .align  4
213
 
        .global nbif_ccallemu1
214
 
nbif_ccallemu1:
 
213
        GLOBAL(ASYM(nbif_ccallemu1))
 
214
ASYM(nbif_ccallemu1):
215
215
        movq    ARG0, P_ARG0(P)
216
216
#if NR_ARG_REGS > 1
217
217
        movq    ARG1, ARG0
222
222
#endif
223
223
 
224
224
        .align  4
225
 
        .global nbif_ccallemu0
226
 
nbif_ccallemu0:
 
225
        GLOBAL(ASYM(nbif_ccallemu0))
 
226
ASYM(nbif_ccallemu0):
227
227
        /* We use %rsi not ARG0 here because ARG0 is not
228
228
           defined when NR_ARG_REGS == 0. */
229
229
#if NR_ARG_REGS == 0
237
237
 * This is where native code suspends.
238
238
 */
239
239
        .align  4
240
 
        .global nbif_suspend_0
241
 
nbif_suspend_0:
 
240
        GLOBAL(ASYM(nbif_suspend_0))
 
241
ASYM(nbif_suspend_0):
242
242
        movl    $HIPE_MODE_SWITCH_RES_SUSPEND, %eax
243
243
        jmp     .suspend_exit
244
244
 
246
246
 * Suspend from a receive (waiting for a message)
247
247
 */
248
248
        .align  4
249
 
        .global nbif_suspend_msg
250
 
nbif_suspend_msg:
 
249
        GLOBAL(ASYM(nbif_suspend_msg))
 
250
ASYM(nbif_suspend_msg):
251
251
        movl    $HIPE_MODE_SWITCH_RES_WAIT, %eax
252
252
        jmp     .suspend_exit
253
253
 
257
257
 *      else { return 0; }
258
258
 */
259
259
        .align  4
260
 
        .global nbif_suspend_msg_timeout
261
 
nbif_suspend_msg_timeout:
 
260
        GLOBAL(ASYM(nbif_suspend_msg_timeout))
 
261
ASYM(nbif_suspend_msg_timeout):
262
262
        movq    P_FLAGS(P), %rax
263
263
        /* this relies on F_TIMO (1<<2) fitting in a byte */
264
264
        testb   $F_TIMO, %al                    # F_TIMO set?
275
275
 * Emulated code returns to its native code caller.
276
276
 */
277
277
        .align  4
278
 
        .global x86_return_to_native
279
 
x86_return_to_native:
 
278
        GLOBAL(CSYM(x86_return_to_native))
 
279
CSYM(x86_return_to_native):
280
280
        ENTER_FROM_C
281
281
        /* get return value */
282
282
        movq    P_ARG0(P), %rax
292
292
 * Emulated code tailcalls native code.
293
293
 */
294
294
        .align  4
295
 
        .global x86_tailcall_to_native
296
 
x86_tailcall_to_native:
 
295
        GLOBAL(CSYM(x86_tailcall_to_native))
 
296
CSYM(x86_tailcall_to_native):
297
297
        ENTER_FROM_C
298
298
        /* get argument registers */
299
299
        LOAD_ARG_REGS
305
305
 * Emulated code throws an exception to its native code caller.
306
306
 */
307
307
        .align  4
308
 
        .global x86_throw_to_native
309
 
x86_throw_to_native:
 
308
        GLOBAL(CSYM(x86_throw_to_native))
 
309
CSYM(x86_throw_to_native):
310
310
        ENTER_FROM_C
311
311
        /* invoke the handler */
312
312
        jmp     *P_NCALLEE(P)           # set by hipe_find_handler()
315
315
 * This is the default exception handler for native code.
316
316
 */
317
317
        .align  4
318
 
        .global nbif_fail
319
 
nbif_fail:
 
318
        GLOBAL(ASYM(nbif_fail))
 
319
ASYM(nbif_fail):
320
320
        movl    $HIPE_MODE_SWITCH_RES_THROW, %eax
321
321
        jmp     .flush_exit
322
322
        
323
 
        .global nbif_0_gc_after_bif
324
 
        .global nbif_1_gc_after_bif
325
 
        .global nbif_2_gc_after_bif
326
 
        .global nbif_3_gc_after_bif
 
323
        GLOBAL(nbif_0_gc_after_bif)
 
324
        GLOBAL(nbif_1_gc_after_bif)
 
325
        GLOBAL(nbif_2_gc_after_bif)
 
326
        GLOBAL(nbif_3_gc_after_bif)
327
327
        .align  4
328
328
nbif_0_gc_after_bif:
329
329
        xorl    %edx, %edx
346
346
        subq    $(16-8), %rsp
347
347
        movq    P, %rdi
348
348
        movq    %rax, %rsi
349
 
        call    erts_gc_after_bif_call
 
349
        xorl    %edx, %edx              # Pass NULL in regs
 
350
        xorl    %ecx, %ecx              # Pass 0 in arity
 
351
        call    CSYM(erts_gc_after_bif_call)
350
352
        addq    $(16-8), %rsp
351
353
        movl    $0, P_NARITY(P)         # Note: narity is a 32-bit field
352
354
        ret
356
358
 * exceptional condition.
357
359
 * The stack/heap registers were just read from P.
358
360
 */
359
 
        .global nbif_0_simple_exception
360
 
        .global nbif_1_simple_exception
361
 
        .global nbif_2_simple_exception
362
 
        .global nbif_3_simple_exception
 
361
        GLOBAL(nbif_0_simple_exception)
 
362
        GLOBAL(nbif_1_simple_exception)
 
363
        GLOBAL(nbif_2_simple_exception)
 
364
        GLOBAL(nbif_3_simple_exception)
363
365
        .align  4
364
366
nbif_0_simple_exception:
365
367
        xorl    %eax, %eax
389
391
        /* find and prepare to invoke the handler */
390
392
        SWITCH_ERLANG_TO_C_QUICK        # The cached state is clean and need not be saved.
391
393
        movq    P, %rdi
392
 
        call    hipe_handle_exception   # Note: hipe_handle_exception() conses
 
394
        call    CSYM(hipe_handle_exception)     # Note: hipe_handle_exception() conses
393
395
        SWITCH_C_TO_ERLANG              # %rsp updated by hipe_find_handler()
394
396
        /* now invoke the handler */
395
397
        jmp     *P_NCALLEE(P)           # set by hipe_find_handler()
400
402
         * - the native heap/stack/reds registers are saved in P
401
403
         */
402
404
.handle_trap:
403
 
        movq    %rax, P_NARITY(P)
 
405
        movl    %eax, P_NARITY(P)       # Note: narity is a 32-bit field
404
406
        movl    $HIPE_MODE_SWITCH_RES_TRAP, %eax
405
407
        jmp     .nosave_exit
406
408
 
408
410
 * nbif_stack_trap_ra: trap return address for maintaining
409
411
 * the gray/white stack boundary
410
412
 */
411
 
        .global nbif_stack_trap_ra
 
413
        GLOBAL(ASYM(nbif_stack_trap_ra))
412
414
        .align  4
413
 
nbif_stack_trap_ra:                     # a return address, not a function
 
415
ASYM(nbif_stack_trap_ra):                       # a return address, not a function
414
416
        # This only handles a single return value.
415
417
        # If we have more, we need to save them in the PCB.
416
418
        movq    %rax, TEMP_RV           # save retval
417
419
        SWITCH_ERLANG_TO_C_QUICK
418
420
        movq    P, %rdi
419
 
        call    hipe_handle_stack_trap  # must not cons; preserves TEMP_RV
 
421
        call    CSYM(hipe_handle_stack_trap)    # must not cons; preserves TEMP_RV
420
422
        movq    %rax, %rdx              # original RA
421
423
        SWITCH_C_TO_ERLANG_QUICK
422
424
        movq    TEMP_RV, %rax           # restore retval
425
427
/*
426
428
 * nbif_inc_stack_0
427
429
 */
428
 
        .global nbif_inc_stack_0
 
430
        GLOBAL(ASYM(nbif_inc_stack_0))
429
431
        .align  4
430
 
nbif_inc_stack_0:
 
432
ASYM(nbif_inc_stack_0):
431
433
        SWITCH_ERLANG_TO_C_QUICK
432
434
        STORE_ARG_REGS
433
435
        movq    P, %rdi
434
436
        # hipe_inc_nstack reads and writes NSP and NSP_LIMIT,
435
437
        # but does not access HP or FCALLS (or the non-amd64 NRA).
436
 
        call    hipe_inc_nstack
 
438
        call    CSYM(hipe_inc_nstack)
437
439
        LOAD_ARG_REGS
438
440
        SWITCH_C_TO_ERLANG_QUICK
439
441
        NSP_RET0