Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1790)

Issue 7563043: code review 7563043: runtime: fix cgo callbacks on windows/386 (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by rsc
Modified:
11 years, 4 months ago
CC:
golang-dev
Visibility:
Public.

Description

runtime: fix cgo callbacks on windows Fixes issue 4955.

Patch Set 1 #

Patch Set 2 : diff -r 622045a2f25a https://code.google.com/p/go/ #

Patch Set 3 : diff -r 622045a2f25a https://code.google.com/p/go/ #

Patch Set 4 : diff -r 622045a2f25a https://code.google.com/p/go/ #

Total comments: 3

Patch Set 5 : diff -r 622045a2f25a https://code.google.com/p/go/ #

Patch Set 6 : diff -r 622045a2f25a https://code.google.com/p/go/ #

Patch Set 7 : diff -r 790eddf30d5d https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+79 lines, -20 lines) Patch
M misc/cgo/test/cthread.go View 1 1 chunk +1 line, -4 lines 0 comments Download
M src/pkg/runtime/sys_windows_386.s View 1 2 3 4 5 1 chunk +43 lines, -0 lines 0 comments Download
M src/pkg/runtime/sys_windows_amd64.s View 1 2 3 4 1 chunk +32 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_windows.c View 1 2 chunks +3 lines, -16 lines 0 comments Download

Messages

Total messages: 27
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
11 years, 8 months ago (2013-03-07 04:51:06 UTC) #1
brainman
It fails on my 386: ... # runtime -cpu=1,2,4 panic: test timed out goroutine 255 ...
11 years, 8 months ago (2013-03-07 06:32:04 UTC) #2
rsc
Thanks. In addition to MOVL not working the way I thought it did, I found ...
11 years, 8 months ago (2013-03-07 06:35:54 UTC) #3
brainman
LGTM Thank you. Alex
11 years, 8 months ago (2013-03-07 08:10:10 UTC) #4
rsc
Thanks for pushing back. The old sleep and yield were doing neither, which was making ...
11 years, 8 months ago (2013-03-07 14:17:03 UTC) #5
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=f800157ce425 *** runtime: fix cgo callbacks on windows Fixes issue 4955. R=golang-dev, ...
11 years, 8 months ago (2013-03-07 14:18:52 UTC) #6
hanwen-google
On 2013/03/07 14:18:52, rsc wrote: > *** Submitted as https://code.google.com/p/go/source/detail?r=f800157ce425 *** > > runtime: fix ...
11 years, 4 months ago (2013-07-03 08:14:11 UTC) #7
minux1
On Wed, Jul 3, 2013 at 4:14 PM, <hanwen@google.com> wrote: > On 2013/03/07 14:18:52, rsc ...
11 years, 4 months ago (2013-07-03 08:28:03 UTC) #8
hanwen-google
What is the problem with allocating the extra space? (sorry for the stupid question; I'm ...
11 years, 4 months ago (2013-07-03 08:43:54 UTC) #9
brainman
On 2013/07/03 08:14:11, hanwen wrote: > > Wine does the windows emulation in user space, ...
11 years, 4 months ago (2013-07-03 08:46:16 UTC) #10
brainman
On 2013/07/03 08:46:16, brainman wrote: > On 2013/07/03 08:14:11, hanwen wrote: > ... > Just ...
11 years, 4 months ago (2013-07-03 09:06:23 UTC) #11
minux1
On Wed, Jul 3, 2013 at 4:43 PM, Han-Wen Nienhuys <hanwen@google.com> wrote: > What is ...
11 years, 4 months ago (2013-07-03 09:08:04 UTC) #12
brainman
On 2013/07/03 09:08:04, minux wrote: > On Wed, Jul 3, 2013 at 4:43 PM, Han-Wen ...
11 years, 4 months ago (2013-07-03 09:10:48 UTC) #13
brainman
On 2013/07/03 09:08:04, minux wrote: > > so i think the cause might be that ...
11 years, 4 months ago (2013-07-03 09:15:08 UTC) #14
hanwen-google
I applied this, $ hg diff diff -r 09e39a9ce38e src/pkg/runtime/sys_windows_amd64.s --- a/src/pkg/runtime/sys_windows_amd64.s Wed Jul 03 ...
11 years, 4 months ago (2013-07-03 09:18:03 UTC) #15
hanwen-google
On Wed, Jul 3, 2013 at 11:15 AM, <alex.brainman@gmail.com> wrote: >> so i think the ...
11 years, 4 months ago (2013-07-03 09:25:12 UTC) #16
minux1
On Wed, Jul 3, 2013 at 5:10 PM, <alex.brainman@gmail.com> wrote: > On 2013/07/03 09:08:04, minux ...
11 years, 4 months ago (2013-07-03 09:25:23 UTC) #17
hanwen-google
According to the wine FAQ we can look for wine_get_version in ntdll. If it's there, ...
11 years, 4 months ago (2013-07-03 09:29:53 UTC) #18
brainman
On 2013/07/03 09:18:03, hanwen wrote: > I applied this, > > $ hg diff > ...
11 years, 4 months ago (2013-07-03 11:43:24 UTC) #19
brainman
On 2013/07/03 09:29:53, hanwen wrote: > According to the wine FAQ we can look for ...
11 years, 4 months ago (2013-07-03 11:45:14 UTC) #20
hanwen-google
On Wed, Jul 3, 2013 at 1:43 PM, <alex.brainman@gmail.com> wrote: > On 2013/07/03 09:18:03, hanwen ...
11 years, 4 months ago (2013-07-03 12:26:45 UTC) #21
minux1
On Wed, Jul 3, 2013 at 8:26 PM, Han-Wen Nienhuys <hanwen@google.com> wrote: > > How ...
11 years, 4 months ago (2013-07-03 12:35:53 UTC) #22
brainman
On 2013/07/03 12:26:45, hanwen wrote: > > How big is 'not very large' in this ...
11 years, 4 months ago (2013-07-03 12:38:06 UTC) #23
minux1
On Wed, Jul 3, 2013 at 8:38 PM, <alex.brainman@gmail.com> wrote: > Sure, we could try. ...
11 years, 4 months ago (2013-07-03 12:53:27 UTC) #24
hanwen-google
I tried TEXT runtime·osyield(SB),7,$0 MOVQ runtime·NtYieldExecution(SB), AX CALL AX RET TEXT runtime·usleep(SB),7,$8 MOVQ runtime·NtDelayExecution(SB), AX ...
11 years, 4 months ago (2013-07-03 14:40:15 UTC) #25
brainman
On 2013/07/03 14:40:15, hanwen wrote: > I tried > > TEXT runtime·osyield(SB),7,$0 > MOVQ runtime·NtYieldExecution(SB), ...
11 years, 4 months ago (2013-07-04 06:49:39 UTC) #26
rsc
11 years, 4 months ago (2013-07-11 20:14:11 UTC) #27
It should work to switch to the m stack, which was allocated by
CreateThread and should be "big enough".

Untested:

TEXT runtime·osyield(SB),7,$8
// Tried NtYieldExecution but it doesn't yield hard enough.
// NtWaitForSingleObject being used here as Sleep(0).
// The CALL is safe because NtXxx is a system call wrapper:
// it puts the right system call number in AX, then does
// a SYSENTER and a RET.
MOVQ runtime·NtWaitForSingleObject(SB), AX
MOVQ $1, BX
NEGQ BX
MOVQ SP, R8 // ptime
MOVQ BX, (R8)
MOVQ $-1, CX // handle
MOVQ $0, DX // alertable
 // Execute call on m->g0 stack, in case we are not actually
// calling a system call wrapper, like when running under WINE.
get_tls(R15)
MOVQ m(R15), R14
CMPQ g(R15), m_g0(R14)
JNE 3(PC)
// executing on m->g0 already
CALL AX
RET

// Switch to m->g0 stack and back.
MOVQ m_g0(R14), R14
MOVQ (g_sched+gobuf_sp)(R14), R14
MOVQ SP, -8(R14)
LEAQ -8(R14), SP
CALL AX
MOVQ 0(SP), SP
RET
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b