View mode: basic / threaded / horizontal-split · Log in · Help
December 14, 2012
Re: No bounds checking for dynamic arrays at compile time?
On Friday, 14 December 2012 at 08:40:59 UTC, Walter Bright wrote:
> On 12/13/2012 11:34 PM, Jacob Carlborg wrote:
>> On 2012-12-13 22:26, Walter Bright wrote:
>>
>>> CTFE would catch it.
>>
>> Didn't you just say that flow analysis is needed for that?
>>
>
> CTFE executes at compile time, no flow analysis is needed for 
> that. DFA is something very different - it "executes" all paths 
> simultaneously.

What is the issue with flow analysis and D?

Even on the toy compiler I had to create back in the university 
we implemented flow analysis for a few use cases.

So the question is if toy university compilers have flow analysis 
why not having it in D?

--
Paulo
December 14, 2012
Re: No bounds checking for dynamic arrays at compile time?
On 12/14/12 3:40 AM, Walter Bright wrote:
> On 12/13/2012 11:34 PM, Jacob Carlborg wrote:
>> On 2012-12-13 22:26, Walter Bright wrote:
>>
>>> CTFE would catch it.
>>
>> Didn't you just say that flow analysis is needed for that?
>>
>
> CTFE executes at compile time, no flow analysis is needed for that. DFA
> is something very different - it "executes" all paths simultaneously.

And then there's a other technique called "abstract execution" which is 
in between them!

Andrei
December 14, 2012
Re: No bounds checking for dynamic arrays at compile time?
On Fri, Dec 14, 2012 at 04:08:09PM +0100, Paulo Pinto wrote:
> On Friday, 14 December 2012 at 08:40:59 UTC, Walter Bright wrote:
> >On 12/13/2012 11:34 PM, Jacob Carlborg wrote:
> >>On 2012-12-13 22:26, Walter Bright wrote:
> >>
> >>>CTFE would catch it.
> >>
> >>Didn't you just say that flow analysis is needed for that?
> >>
> >
> >CTFE executes at compile time, no flow analysis is needed for
> >that. DFA is something very different - it "executes" all paths
> >simultaneously.
> 
> What is the issue with flow analysis and D?
> 
> Even on the toy compiler I had to create back in the university we
> implemented flow analysis for a few use cases.
> 
> So the question is if toy university compilers have flow analysis
> why not having it in D?
[...]

Yeah I'm curious about this too. I also have implemented basic flow
analysis in a compiler project in university. For the simple cases, it
doesn't complicate the compiler that much at all. For a sophisticated
compiler such as DMD, basic flow analysis would almost seem trivial.

(But then again, it may add performance bottlenecks that I'm unaware of
-- this was before I learnt the hard way that hotspots often aren't
actually where you think they are.)


T

-- 
Acid falls with the rain; with love comes the pain.
December 15, 2012
Re: No bounds checking for dynamic arrays at compile time?
On 12/14/2012 7:08 AM, Paulo Pinto wrote:
> So the question is if toy university compilers have flow analysis why not having
> it in D?

The compiler does do full data flow analysis in the optimizer pass. But, by 
then, it is intermediate code not D code.
December 15, 2012
Re: No bounds checking for dynamic arrays at compile time?
Am 15.12.2012 03:56, schrieb Walter Bright:
> On 12/14/2012 7:08 AM, Paulo Pinto wrote:
>> So the question is if toy university compilers have flow analysis why
>> not having
>> it in D?
>
> The compiler does do full data flow analysis in the optimizer pass. But,
> by then, it is intermediate code not D code.
>

Ah ok.

I am used to see it being done on the AST level, before doing further 
passes.

--
Paulo
Next ›   Last »
1 2 3 4
Top | Discussion index | About this forum | D home