~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/runtime/sys_windows_amd64.s

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
TEXT runtime·asmstdcall(SB),NOSPLIT,$0
14
14
        // asmcgocall will put first argument into CX.
15
15
        PUSHQ   CX                      // save for later
16
 
        MOVQ    wincall_fn(CX), AX
17
 
        MOVQ    wincall_args(CX), SI
18
 
        MOVQ    wincall_n(CX), CX
 
16
        MOVQ    libcall_fn(CX), AX
 
17
        MOVQ    libcall_args(CX), SI
 
18
        MOVQ    libcall_n(CX), CX
19
19
 
20
20
        // SetLastError(0).
21
21
        MOVQ    0x30(GS), DI
52
52
 
53
53
        // Return result.
54
54
        POPQ    CX
55
 
        MOVQ    AX, wincall_r1(CX)
 
55
        MOVQ    AX, libcall_r1(CX)
56
56
 
57
57
        // GetLastError().
58
58
        MOVQ    0x30(GS), DI
59
59
        MOVL    0x68(DI), AX
60
 
        MOVQ    AX, wincall_err(CX)
 
60
        MOVQ    AX, libcall_err(CX)
61
61
 
62
62
        RET
63
63
 
95
95
        MOVL    AX, 0x68(CX)
96
96
        RET
97
97
 
98
 
TEXT runtime·sigtramp(SB),NOSPLIT,$0
99
 
        // CX: exception record
100
 
        // R8: context
101
 
 
102
 
        // unwinding?
103
 
        TESTL   $6, 4(CX)               // exception flags
104
 
        MOVL    $1, AX
105
 
        JNZ     sigdone
106
 
 
107
 
        // copy arguments for call to sighandler.
108
 
 
109
 
        // Stack adjustment is here to hide from 6l,
110
 
        // which doesn't understand that sigtramp
111
 
        // runs on essentially unlimited stack.
112
 
        SUBQ    $56, SP
113
 
        MOVQ    CX, 0(SP)
114
 
        MOVQ    R8, 8(SP)
115
 
 
116
 
        get_tls(CX)
117
 
 
118
 
        // check that m exists
119
 
        MOVQ    m(CX), AX
 
98
// Called by Windows as a Vectored Exception Handler (VEH).
 
99
// First argument is pointer to struct containing
 
100
// exception record and context pointers.
 
101
// Return 0 for 'not handled', -1 for handled.
 
102
TEXT runtime·sigtramp(SB),NOSPLIT,$0-0
 
103
        // CX: PEXCEPTION_POINTERS ExceptionInfo
 
104
 
 
105
        // DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved
 
106
        // as required by windows callback convention.
 
107
        PUSHFQ
 
108
        SUBQ    $88, SP
 
109
        MOVQ    DI, 80(SP)
 
110
        MOVQ    SI, 72(SP)
 
111
        MOVQ    BP, 64(SP)
 
112
        MOVQ    BX, 56(SP)
 
113
        MOVQ    R12, 48(SP)
 
114
        MOVQ    R13, 40(SP)
 
115
        MOVQ    R14, 32(SP)
 
116
        MOVQ    R15, 24(SP)
 
117
 
 
118
        MOVQ    0(CX), BX // ExceptionRecord*
 
119
        MOVQ    8(CX), CX // Context*
 
120
 
 
121
        // fetch g
 
122
        get_tls(DX)
 
123
        CMPQ    DX, $0
 
124
        JNE     3(PC)
 
125
        MOVQ    $0, AX // continue
 
126
        JMP     done
 
127
        MOVQ    m(DX), AX
120
128
        CMPQ    AX, $0
121
129
        JNE     2(PC)
122
130
        CALL    runtime·badsignal2(SB)
123
 
 
124
 
        MOVQ    g(CX), CX
125
 
        MOVQ    CX, 16(SP)
126
 
 
127
 
        MOVQ    BX, 24(SP)
128
 
        MOVQ    BP, 32(SP)
129
 
        MOVQ    SI, 40(SP)
130
 
        MOVQ    DI, 48(SP)
131
 
 
 
131
        MOVQ    g(DX), DX
 
132
        // call sighandler(ExceptionRecord*, Context*, G*)
 
133
        MOVQ    BX, 0(SP)
 
134
        MOVQ    CX, 8(SP)
 
135
        MOVQ    DX, 16(SP)
132
136
        CALL    runtime·sighandler(SB)
133
 
 
134
 
        MOVQ    24(SP), BX
135
 
        MOVQ    32(SP), BP
136
 
        MOVQ    40(SP), SI
137
 
        MOVQ    48(SP), DI
138
 
        ADDQ    $56, SP
139
 
 
140
 
sigdone:
 
137
        // AX is set to report result back to Windows
 
138
 
 
139
done:
 
140
        // restore registers as required for windows callback
 
141
        MOVQ    24(SP), R15
 
142
        MOVQ    32(SP), R14
 
143
        MOVQ    40(SP), R13
 
144
        MOVQ    48(SP), R12
 
145
        MOVQ    56(SP), BX
 
146
        MOVQ    64(SP), BP
 
147
        MOVQ    72(SP), SI
 
148
        MOVQ    80(SP), DI
 
149
        ADDQ    $88, SP
 
150
        POPFQ
 
151
 
141
152
        RET
142
153
 
143
154
TEXT runtime·ctrlhandler(SB),NOSPLIT,$8
277
288
        POPQ    -8(CX)(DX*1)      // restore bytes just after the args
278
289
        RET
279
290
 
280
 
TEXT runtime·setstacklimits(SB),NOSPLIT,$0
281
 
        MOVQ    0x30(GS), CX
282
 
        MOVQ    $0, 0x10(CX)
283
 
        MOVQ    $0xffffffffffff, AX
284
 
        MOVQ    AX, 0x08(CX)
285
 
        RET
286
 
 
287
291
// uint32 tstart_stdcall(M *newm);
288
292
TEXT runtime·tstart_stdcall(SB),NOSPLIT,$0
289
293
        // CX contains first arg newm
315
319
        MOVQ    DI, 0x28(GS)
316
320
        RET
317
321
 
318
 
// void install_exception_handler()
319
 
TEXT runtime·install_exception_handler(SB),NOSPLIT,$0
320
 
        CALL    runtime·setstacklimits(SB)
321
 
        RET
322
 
 
323
 
TEXT runtime·remove_exception_handler(SB),NOSPLIT,$0
324
 
        RET
325
 
 
326
322
// Sleep duration is in 100ns units.
327
323
TEXT runtime·usleep1(SB),NOSPLIT,$0
328
324
        MOVL    duration+0(FP), BX
337
333
        CALL    AX
338
334
        RET
339
335
 
340
 
        MOVQ    m(R15), R14
341
 
        MOVQ    m_g0(R14), R14
 
336
        MOVQ    m(R15), R13
 
337
 
 
338
        // leave pc/sp for cpu profiler
 
339
        MOVQ    (SP), R12
 
340
        MOVQ    R12, m_libcallpc(R13)
 
341
        MOVQ    g(R15), R12
 
342
        MOVQ    R12, m_libcallg(R13)
 
343
        // sp must be the last, because once async cpu profiler finds
 
344
        // all three values to be non-zero, it will use them
 
345
        LEAQ    8(SP), R12
 
346
        MOVQ    R12, m_libcallsp(R13)
 
347
 
 
348
        MOVQ    m_g0(R13), R14
342
349
        CMPQ    g(R15), R14
343
 
        JNE     3(PC)
 
350
        JNE     usleep1_switch
344
351
        // executing on m->g0 already
345
352
        CALL    AX
346
 
        RET
 
353
        JMP     usleep1_ret
347
354
 
 
355
usleep1_switch:
348
356
        // Switch to m->g0 stack and back.
349
357
        MOVQ    (g_sched+gobuf_sp)(R14), R14
350
358
        MOVQ    SP, -8(R14)
351
359
        LEAQ    -8(R14), SP
352
360
        CALL    AX
353
361
        MOVQ    0(SP), SP
 
362
 
 
363
usleep1_ret:
 
364
        MOVQ    $0, m_libcallsp(R13)
354
365
        RET
355
366
 
356
367
// Runs on OS stack. duration (in 100ns units) is in BX.