Re: druntime investigation troubles

2012-05-25 Thread Jacob Carlborg

On 2012-05-24 21:49, Sean Kelly wrote:


There's a difference in how unittest execution is handled.  This could probably 
be sorted out though.


Yeah, I've noticed that. Does the unit test really need to run when you 
call rt_init from C?


--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-25 Thread Steven Schveighoffer
On Thu, 24 May 2012 16:40:46 -0400, Sean Kelly s...@invisibleduck.org  
wrote:


It's not STI_monitor specifically. STI_anything is a module ctor and  
STD_anything is a module dtor. Or at least that's my recollection. There  
are a few places in the DMC runtime that have initializers like this. I  
think one is somewhere in the floating-point support code.


oh.  That's horrible.

Yeah, we should eliminate this ASAP.  Is there any reason it has to be  
done before C's main?


-Steve


Re: druntime investigation troubles

2012-05-25 Thread Sean Kelly
On May 24, 2012, at 11:25 PM, Jacob Carlborg d...@me.com wrote:

 On 2012-05-24 21:49, Sean Kelly wrote:
 
 There's a difference in how unittest execution is handled.  This could 
 probably be sorted out though.
 
 Yeah, I've noticed that. Does the unit test really need to run when you call 
 rt_init from C?

Not really. I wanted initialization to be the same either way, but unittests 
seem optional. 

Re: druntime investigation troubles

2012-05-24 Thread Jacob Carlborg

On 2012-05-23 21:58, Steven Schveighoffer wrote:


+1

dmain2 has that magic runtime feel where you look at it and are so
confused that you are afraid to touch anything :P

-Steve


I previously made a pull request and tried to fix code duplication in 
dmain2.d. Unfortunately some test case failed, I'm going to look into it 
again.


--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-24 Thread Sean Kelly
On May 23, 2012, at 7:49 AM, Jacob Carlborg wrote:

 On 2012-05-23 13:31, Steven Schveighoffer wrote:
 On Wed, 23 May 2012 02:21:14 -0400, Jacob Carlborg d...@me.com wrote:
 
 On 2012-05-22 23:01, Steven Schveighoffer wrote:
 
 It looks like code that is not called on Windows. Which doesn't make
 sense. It would seem that you must initialize a critical section in
 order to use it.
 
 I can't find any reference to STI_monitor in dmd, dmc, or druntime
 source code, except those calls that are done for Posix only. This isn't
 some closed-source mystery, I think it is just unused code.
 
 Sean, does this make sense? Are we using uninitialized critical
 sections?
 
 -Steve
 
 I found a call now, it's in _d_criticalenter, both in critical.c and
 critical_.d.
 
 
 OK, so does this mean monitor is only used on Posix, and critical is
 used only on windows? This seems a little weird. Especially since we are
 still compiling monitor.c.
 
 -Steve
 
 No, there's a _d_criticalenter for Posix in critical(_).d/c which calls 
 _STI_critical_init. It seems there's a duplicate call for 
 _STI_critical_init on Posix, in dmain2.d and in critical(_).d/c.
 
 Also this actually looks like a big mess:
 
 * critical_.d and critical.c contains the same code. critical_.d is used in 
 the posix makefile. critical.c _and_ critical_.d is used in the win32 makefile
 
 * _STI_critical_init is implemented on both Posix and Windows, but it's 
 only called on Posix
 
 * _STI_critical_init is called on multiple places on Posix. In dmain2.d and 
 in _d_criticalenter.

If I remember correctly, Brad Roberts tried porting the old C critical section 
code to D a while back and something didn't work right.  Both versions of the 
code still exist, and at some point the D code needs to be sorted and the C 
code should be thrown away.  I suppose I should make this my top priority, when 
I find the time.

Re: druntime investigation troubles

2012-05-24 Thread Sean Kelly
On May 22, 2012, at 2:01 PM, Steven Schveighoffer wrote:

 On Tue, 22 May 2012 15:16:30 -0400, Denis Shelomovskij 
 verylonglogin@gmail.com wrote:
 
 21.05.2012 2:13, Alex Rønne Petersen написал:
 On 20-05-2012 22:13, Jacob Carlborg wrote:
 On 2012-05-20 18:25, Alex Rønne Petersen wrote:
 
 Seems like I misunderstood what you were saying. Right, the C runtime on
 *Windows* is closed source. But, I don't know why you think that
 function is called by the C runtime; see src/rt/dmain2.d.
 
 Have a look again. It's only called on Posix:
 
 https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364
 
 
 
 
 I stand corrected. I had no idea about the magic involved here!
 
 The proprietary Windows tool chain is seriously problematic...
 
 
 So can anybody do something with it? At least document a bit what does 
 proprietary part do.
 
 
 It looks like code that is not called on Windows.  Which doesn't make sense.  
 It would seem that you must initialize a critical section in order to use it.
 
 I can't find any reference to STI_monitor in dmd, dmc, or druntime source 
 code, except those calls that are done for Posix only.  This isn't some 
 closed-source mystery, I think it is just unused code.
 
 Sean, does this make sense?  Are we using uninitialized critical sections?

This code is before my time, but I believe that DMC implicitly treats STI 
functions as module ctors, and DMD inherits this behavior because it shares a C 
runtime with DMC.  It's been a while since I've looked at all of this, but the 
full C runtime source is shipped with DMC--I have a copy.

Re: druntime investigation troubles

2012-05-24 Thread Sean Kelly
On May 23, 2012, at 12:46 PM, Jacob Carlborg wrote:

 On 2012-05-23 19:32, Denis Shelomovskij wrote:
 
 What call have you found in _d_criticalenter?
 
 By the way, `_STI_critical_init` is called before C main (uncomment
 printf's and check), so it is definitely called not by druntime.
 
 
 _STI_critical_init is called here:
 
 * 
 https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical_.d#L149
 
 * 
 https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical.c#L124
 
 * 
 https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L364
 
 Found another one:
 
 * 
 https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L255
 
 I assume, and hope, that only one of these are actually called. That's why I 
 said all this is a big mess.
 
 The last one is only called if the runtime is manually initialized, i.e. via 
 C using the rt_init function. Which is stupid, rt_init should be called 
 from the C main function as well. There's unnecessary code duplication here.

There's a difference in how unittest execution is handled.  This could probably 
be sorted out though.

Re: druntime investigation troubles

2012-05-24 Thread Steven Schveighoffer
On Thu, 24 May 2012 15:44:28 -0400, Sean Kelly s...@invisibleduck.org  
wrote:



On May 22, 2012, at 2:01 PM, Steven Schveighoffer wrote:

On Tue, 22 May 2012 15:16:30 -0400, Denis Shelomovskij  
verylonglogin@gmail.com wrote:



21.05.2012 2:13, Alex Rønne Petersen написал:

On 20-05-2012 22:13, Jacob Carlborg wrote:

On 2012-05-20 18:25, Alex Rønne Petersen wrote:

Seems like I misunderstood what you were saying. Right, the C  
runtime on

*Windows* is closed source. But, I don't know why you think that
function is called by the C runtime; see src/rt/dmain2.d.


Have a look again. It's only called on Posix:

https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364





I stand corrected. I had no idea about the magic involved here!

The proprietary Windows tool chain is seriously problematic...



So can anybody do something with it? At least document a bit what does  
proprietary part do.




It looks like code that is not called on Windows.  Which doesn't make  
sense.  It would seem that you must initialize a critical section in  
order to use it.


I can't find any reference to STI_monitor in dmd, dmc, or druntime  
source code, except those calls that are done for Posix only.  This  
isn't some closed-source mystery, I think it is just unused code.


Sean, does this make sense?  Are we using uninitialized critical  
sections?


This code is before my time, but I believe that DMC implicitly treats  
STI functions as module ctors, and DMD inherits this behavior because it  
shares a C runtime with DMC.  It's been a while since I've looked at all  
of this, but the full C runtime source is shipped with DMC--I have a  
copy.


Yeah, I do too.  I did a full text search for STI_monitor and found  
nothing.


That's why I'm confused...

-Steve


Re: druntime investigation troubles

2012-05-24 Thread Sean Kelly
On May 24, 2012, at 1:27 PM, Steven Schveighoffer schvei...@yahoo.com wrote:

 On Thu, 24 May 2012 15:44:28 -0400, Sean Kelly s...@invisibleduck.org wrote:
 
 On May 22, 2012, at 2:01 PM, Steven Schveighoffer wrote:
 
 On Tue, 22 May 2012 15:16:30 -0400, Denis Shelomovskij 
 verylonglogin@gmail.com wrote:
 
 21.05.2012 2:13, Alex Rønne Petersen написал:
 On 20-05-2012 22:13, Jacob Carlborg wrote:
 On 2012-05-20 18:25, Alex Rønne Petersen wrote:
 
 Seems like I misunderstood what you were saying. Right, the C runtime on
 *Windows* is closed source. But, I don't know why you think that
 function is called by the C runtime; see src/rt/dmain2.d.
 
 Have a look again. It's only called on Posix:
 
 https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364
 
 
 
 
 I stand corrected. I had no idea about the magic involved here!
 
 The proprietary Windows tool chain is seriously problematic...
 
 
 So can anybody do something with it? At least document a bit what does 
 proprietary part do.
 
 
 It looks like code that is not called on Windows.  Which doesn't make 
 sense.  It would seem that you must initialize a critical section in order 
 to use it.
 
 I can't find any reference to STI_monitor in dmd, dmc, or druntime source 
 code, except those calls that are done for Posix only.  This isn't some 
 closed-source mystery, I think it is just unused code.
 
 Sean, does this make sense?  Are we using uninitialized critical sections?
 
 This code is before my time, but I believe that DMC implicitly treats STI 
 functions as module ctors, and DMD inherits this behavior because it shares 
 a C runtime with DMC.  It's been a while since I've looked at all of this, 
 but the full C runtime source is shipped with DMC--I have a copy.
 
 Yeah, I do too.  I did a full text search for STI_monitor and found nothing.
 
 That's why I'm confused...

It's not STI_monitor specifically. STI_anything is a module ctor and 
STD_anything is a module dtor. Or at least that's my recollection. There are a 
few places in the DMC runtime that have initializers like this. I think one is 
somewhere in the floating-point support code. 

Re: druntime investigation troubles

2012-05-23 Thread Jacob Carlborg

On 2012-05-22 23:01, Steven Schveighoffer wrote:


It looks like code that is not called on Windows. Which doesn't make
sense. It would seem that you must initialize a critical section in
order to use it.

I can't find any reference to STI_monitor in dmd, dmc, or druntime
source code, except those calls that are done for Posix only. This isn't
some closed-source mystery, I think it is just unused code.

Sean, does this make sense? Are we using uninitialized critical sections?

-Steve


_STI_critical_init is defined both in critical.c and critical_.d, but 
I can't find a place where it's called on Windows.


--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-23 Thread Jacob Carlborg

On 2012-05-22 23:01, Steven Schveighoffer wrote:


It looks like code that is not called on Windows. Which doesn't make
sense. It would seem that you must initialize a critical section in
order to use it.

I can't find any reference to STI_monitor in dmd, dmc, or druntime
source code, except those calls that are done for Posix only. This isn't
some closed-source mystery, I think it is just unused code.

Sean, does this make sense? Are we using uninitialized critical sections?

-Steve


I found a call now, it's in _d_criticalenter, both in critical.c and 
critical_.d.


--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-23 Thread Steven Schveighoffer

On Wed, 23 May 2012 02:21:14 -0400, Jacob Carlborg d...@me.com wrote:


On 2012-05-22 23:01, Steven Schveighoffer wrote:


It looks like code that is not called on Windows. Which doesn't make
sense. It would seem that you must initialize a critical section in
order to use it.

I can't find any reference to STI_monitor in dmd, dmc, or druntime
source code, except those calls that are done for Posix only. This isn't
some closed-source mystery, I think it is just unused code.

Sean, does this make sense? Are we using uninitialized critical  
sections?


-Steve


I found a call now, it's in _d_criticalenter, both in critical.c and  
critical_.d.




OK, so does this mean monitor is only used on Posix, and critical is used  
only on windows?  This seems a little weird.  Especially since we are  
still compiling monitor.c.


-Steve


Re: druntime investigation troubles

2012-05-23 Thread Jacob Carlborg

On 2012-05-23 13:31, Steven Schveighoffer wrote:

On Wed, 23 May 2012 02:21:14 -0400, Jacob Carlborg d...@me.com wrote:


On 2012-05-22 23:01, Steven Schveighoffer wrote:


It looks like code that is not called on Windows. Which doesn't make
sense. It would seem that you must initialize a critical section in
order to use it.

I can't find any reference to STI_monitor in dmd, dmc, or druntime
source code, except those calls that are done for Posix only. This isn't
some closed-source mystery, I think it is just unused code.

Sean, does this make sense? Are we using uninitialized critical
sections?

-Steve


I found a call now, it's in _d_criticalenter, both in critical.c and
critical_.d.



OK, so does this mean monitor is only used on Posix, and critical is
used only on windows? This seems a little weird. Especially since we are
still compiling monitor.c.

-Steve


No, there's a _d_criticalenter for Posix in critical(_).d/c which 
calls _STI_critical_init. It seems there's a duplicate call for 
_STI_critical_init on Posix, in dmain2.d and in critical(_).d/c.


Also this actually looks like a big mess:

* critical_.d and critical.c contains the same code. critical_.d is used 
in the posix makefile. critical.c _and_ critical_.d is used in the win32 
makefile


* _STI_critical_init is implemented on both Posix and Windows, but 
it's only called on Posix


* _STI_critical_init is called on multiple places on Posix. In 
dmain2.d and in _d_criticalenter.


--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-23 Thread Denis Shelomovskij

23.05.2012 10:21, Jacob Carlborg написал:

On 2012-05-22 23:01, Steven Schveighoffer wrote:


It looks like code that is not called on Windows. Which doesn't make
sense. It would seem that you must initialize a critical section in
order to use it.

I can't find any reference to STI_monitor in dmd, dmc, or druntime
source code, except those calls that are done for Posix only. This isn't
some closed-source mystery, I think it is just unused code.

Sean, does this make sense? Are we using uninitialized critical sections?

-Steve


I found a call now, it's in _d_criticalenter, both in critical.c and
critical_.d.


What call have you found in _d_criticalenter?

By the way, `_STI_critical_init` is called before C main (uncomment 
printf's and check), so it is definitely called not by druntime.


--
Денис В. Шеломовский
Denis V. Shelomovskij


Re: druntime investigation troubles

2012-05-23 Thread Jacob Carlborg

On 2012-05-23 19:32, Denis Shelomovskij wrote:


What call have you found in _d_criticalenter?

By the way, `_STI_critical_init` is called before C main (uncomment
printf's and check), so it is definitely called not by druntime.



_STI_critical_init is called here:

* 
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical_.d#L149


* 
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical.c#L124


* 
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L364


Found another one:

* 
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L255


I assume, and hope, that only one of these are actually called. That's 
why I said all this is a big mess.


The last one is only called if the runtime is manually initialized, i.e. 
via C using the rt_init function. Which is stupid, rt_init should be 
called from the C main function as well. There's unnecessary code 
duplication here.


--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-23 Thread Steven Schveighoffer

On Wed, 23 May 2012 15:46:16 -0400, Jacob Carlborg d...@me.com wrote:


On 2012-05-23 19:32, Denis Shelomovskij wrote:


What call have you found in _d_criticalenter?

By the way, `_STI_critical_init` is called before C main (uncomment
printf's and check), so it is definitely called not by druntime.



_STI_critical_init is called here:

*  
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical_.d#L149


*  
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/critical.c#L124


*  
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L364


Found another one:

*  
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L255


I assume, and hope, that only one of these are actually called. That's  
why I said all this is a big mess.


The last one is only called if the runtime is manually initialized, i.e.  
via C using the rt_init function. Which is stupid, rt_init should be  
called from the C main function as well. There's unnecessary code  
duplication here.




+1

dmain2 has that magic runtime feel where you look at it and are so  
confused that you are afraid to touch anything :P


-Steve


Re: druntime investigation troubles

2012-05-22 Thread Denis Shelomovskij

21.05.2012 2:13, Alex Rønne Petersen написал:

On 20-05-2012 22:13, Jacob Carlborg wrote:

On 2012-05-20 18:25, Alex Rønne Petersen wrote:


Seems like I misunderstood what you were saying. Right, the C runtime on
*Windows* is closed source. But, I don't know why you think that
function is called by the C runtime; see src/rt/dmain2.d.


Have a look again. It's only called on Posix:

https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364





I stand corrected. I had no idea about the magic involved here!

The proprietary Windows tool chain is seriously problematic...



So can anybody do something with it? At least document a bit what does 
proprietary part do.


--
Денис В. Шеломовский
Denis V. Shelomovskij


Re: druntime investigation troubles

2012-05-22 Thread Steven Schveighoffer
On Tue, 22 May 2012 15:16:30 -0400, Denis Shelomovskij  
verylonglogin@gmail.com wrote:



21.05.2012 2:13, Alex Rønne Petersen написал:

On 20-05-2012 22:13, Jacob Carlborg wrote:

On 2012-05-20 18:25, Alex Rønne Petersen wrote:

Seems like I misunderstood what you were saying. Right, the C runtime  
on

*Windows* is closed source. But, I don't know why you think that
function is called by the C runtime; see src/rt/dmain2.d.


Have a look again. It's only called on Posix:

https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364





I stand corrected. I had no idea about the magic involved here!

The proprietary Windows tool chain is seriously problematic...



So can anybody do something with it? At least document a bit what does  
proprietary part do.




It looks like code that is not called on Windows.  Which doesn't make  
sense.  It would seem that you must initialize a critical section in order  
to use it.


I can't find any reference to STI_monitor in dmd, dmc, or druntime source  
code, except those calls that are done for Posix only.  This isn't some  
closed-source mystery, I think it is just unused code.


Sean, does this make sense?  Are we using uninitialized critical sections?

-Steve


Re: druntime investigation troubles

2012-05-20 Thread Alex Rønne Petersen

On 20-05-2012 10:41, Denis Shelomovskij wrote:

Looks like `_STI_monitor_staticctor` is called by C runtime on Windows.
And C runtime isn't open-source.

It creates troubles for investigation druntime (for me at least). Why is
it so? Why not to call everything in C `main`, what's the reason?

If there is no list of stuff done before C `main` druntime isn't
open-source for me because I can't understand what is taking place just
with druntime sources.



Huh? It's perfectly open source. Read src/rt/monitor.c.

--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org


Re: druntime investigation troubles

2012-05-20 Thread Alex Rønne Petersen

On 20-05-2012 18:20, Alex Rønne Petersen wrote:

On 20-05-2012 10:41, Denis Shelomovskij wrote:

Looks like `_STI_monitor_staticctor` is called by C runtime on Windows.
And C runtime isn't open-source.

It creates troubles for investigation druntime (for me at least). Why is
it so? Why not to call everything in C `main`, what's the reason?

If there is no list of stuff done before C `main` druntime isn't
open-source for me because I can't understand what is taking place just
with druntime sources.



Huh? It's perfectly open source. Read src/rt/monitor.c.



Seems like I misunderstood what you were saying. Right, the C runtime on 
*Windows* is closed source. But, I don't know why you think that 
function is called by the C runtime; see src/rt/dmain2.d.


--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org


Re: druntime investigation troubles

2012-05-20 Thread Jacob Carlborg

On 2012-05-20 18:25, Alex Rønne Petersen wrote:


Seems like I misunderstood what you were saying. Right, the C runtime on
*Windows* is closed source. But, I don't know why you think that
function is called by the C runtime; see src/rt/dmain2.d.


Have a look again. It's only called on Posix:

https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364

--
/Jacob Carlborg


Re: druntime investigation troubles

2012-05-20 Thread Alex Rønne Petersen

On 20-05-2012 22:13, Jacob Carlborg wrote:

On 2012-05-20 18:25, Alex Rønne Petersen wrote:


Seems like I misunderstood what you were saying. Right, the C runtime on
*Windows* is closed source. But, I don't know why you think that
function is called by the C runtime; see src/rt/dmain2.d.


Have a look again. It's only called on Posix:

https://github.com/D-Programming-Language/druntime/blob/7d663821d39cfe8874cb95b0df46b5065a770cef/src/rt/dmain2.d#L364




I stand corrected. I had no idea about the magic involved here!

The proprietary Windows tool chain is seriously problematic...

--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org