This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Deactivating Constant Folding?

7 replies
Mirko Stocker
Joined: 2009-09-10,
User offline. Last seen 45 weeks 6 days ago.

Hi all

A change to Scala trunk somewhere between the 3. and 6. January seems to have
changed something related to constant folding. I noticed because I suddenly
get ~40 test failures like the following while generating source code for
trees:

expected: but was:

In the test suite of my refactorings, I'm simply using an instance of
interactive.Global. Is there a new option or another way to disable constant
folding?

Thanks a lot!

Mirko

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Deactivating Constant Folding?


On Fri, Jan 7, 2011 at 12:47 PM, Mirko Stocker <me@misto.ch> wrote:
Hi all

A change to Scala trunk somewhere between the 3. and 6. January seems to have
changed something related to constant folding. I noticed because I suddenly
get ~40 test failures like the following while generating source code for
trees:

expected:<val a = {[4 + 3]  }> but was:<val a = {[7]  }>

I don't know what might have happened here. Anyone else?

 -- Martin
 
In the test suite of my refactorings, I'm simply using an instance of
interactive.Global. Is there a new option or another way to disable constant
folding?

Thanks a lot!

Mirko

--
Mirko Stocker | me@misto.ch
Work: http://ifs.hsr.ch | http://infoq.com
Personal: http://misto.ch | http://twitter.com/m_st



--
--------------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Scala Solutions
PSED, 1015 Lausanne, Switzerland


Mirko Stocker
Joined: 2009-09-10,
User offline. Last seen 45 weeks 6 days ago.
Re: Deactivating Constant Folding?

Hi,

On Saturday 08 January 2011 10:57:27 martin odersky wrote:
> On Fri, Jan 7, 2011 at 12:47 PM, Mirko Stocker wrote:
> > Hi all
> >
> > A change to Scala trunk somewhere between the 3. and 6. January seems to
> > have
> > changed something related to constant folding. I noticed because I
> > suddenly get ~40 test failures like the following while generating
> > source code for trees:
> >
> > expected: but was:
> >
> > I don't know what might have happened here. Anyone else?

I took a closer look at the commits during that period, and I suspect it is
23897, where forInteractive and forScaladoc were introduced. And indeed, when
I override val forScaladoc = true in my global, all my test failures go away.

I hope this helps locating the problem.

Thanks,

Mirko

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Deactivating Constant Folding?

Mirko,

It sounds as if that test expects constant-folding *not* to take place (but
why? constant folding is a good thing :-)

In case you want to explore where constant folding happens, breakpoints can
be placed on the two apply methods in
scala.tools.nsc.typechecker.ConstantFolder,
and then run using the same command-line options as for the test.

For additional context, the usages of

/** Fold constants */
object constfold extends {
val global: Global.this.type = Global.this
} with ConstantFolder

can also be looked up (just three places, all of them in Typers).

Miguel
http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/

Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Deactivating Constant Folding?


On Sat, Jan 8, 2011 at 11:16 AM, Mirko Stocker <me@misto.ch> wrote:
Hi,

On Saturday 08 January 2011 10:57:27 martin odersky wrote:
> On Fri, Jan 7, 2011 at 12:47 PM, Mirko Stocker <me@misto.ch> wrote:
> > Hi all
> >
> > A change to Scala trunk somewhere between the 3. and 6. January seems to
> > have
> > changed something related to constant folding. I noticed because I
> > suddenly get ~40 test failures like the following while generating
> > source code for trees:
> >
> > expected:<val a = {[4 + 3]  }> but was:<val a = {[7]  }>
> >
> > I don't know what might have happened here. Anyone else?

I took a closer look at the commits during that period, and I suspect it is
23897, where forInteractive and forScaladoc were introduced. And indeed, when
I override val forScaladoc = true in my global, all my test failures go away.

Yes, it's that commit. I can disable constant folding in the interactive compiler. Gilles, should it be the same for Scaladoc, or it doesn't matter?
thanks,iulian 

I hope this helps locating the problem.

Thanks,

Mirko

--
Mirko Stocker | me@misto.ch
Work: http://ifs.hsr.ch | http://infoq.com
Personal: http://misto.ch | http://twitter.com/m_st



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Deactivating Constant Folding?
I think constant folding needs to be deactivated for interactive as well. Otherwise we loose a lot of position info.

 -- Martin


On Mon, Jan 10, 2011 at 11:00 AM, iulian dragos <iulian.dragos@epfl.ch> wrote:


On Sat, Jan 8, 2011 at 11:16 AM, Mirko Stocker <me@misto.ch> wrote:
Hi,

On Saturday 08 January 2011 10:57:27 martin odersky wrote:
> On Fri, Jan 7, 2011 at 12:47 PM, Mirko Stocker <me@misto.ch> wrote:
> > Hi all
> >
> > A change to Scala trunk somewhere between the 3. and 6. January seems to
> > have
> > changed something related to constant folding. I noticed because I
> > suddenly get ~40 test failures like the following while generating
> > source code for trees:
> >
> > expected:<val a = {[4 + 3]  }> but was:<val a = {[7]  }>
> >
> > I don't know what might have happened here. Anyone else?

I took a closer look at the commits during that period, and I suspect it is
23897, where forInteractive and forScaladoc were introduced. And indeed, when
I override val forScaladoc = true in my global, all my test failures go away.

Yes, it's that commit. I can disable constant folding in the interactive compiler. Gilles, should it be the same for Scaladoc, or it doesn't matter?
thanks,iulian 

I hope this helps locating the problem.

Thanks,

Mirko

--
Mirko Stocker | me@misto.ch
Work: http://ifs.hsr.ch | http://infoq.com
Personal: http://misto.ch | http://twitter.com/m_st



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais



--
------------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Scala Solutions
PSED, 1015 Lausanne, Switzerland


Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Deactivating Constant Folding?


On Mon, Jan 10, 2011 at 12:44 PM, martin odersky <martin.odersky@epfl.ch> wrote:
I think constant folding needs to be deactivated for interactive as well. Otherwise we loose a lot of position info.

Ok, it's done now. No constant folding when in interactive or scaladoc mode.
iulian 

 -- Martin


On Mon, Jan 10, 2011 at 11:00 AM, iulian dragos <iulian.dragos@epfl.ch> wrote:


On Sat, Jan 8, 2011 at 11:16 AM, Mirko Stocker <me@misto.ch> wrote:
Hi,

On Saturday 08 January 2011 10:57:27 martin odersky wrote:
> On Fri, Jan 7, 2011 at 12:47 PM, Mirko Stocker <me@misto.ch> wrote:
> > Hi all
> >
> > A change to Scala trunk somewhere between the 3. and 6. January seems to
> > have
> > changed something related to constant folding. I noticed because I
> > suddenly get ~40 test failures like the following while generating
> > source code for trees:
> >
> > expected:<val a = {[4 + 3]  }> but was:<val a = {[7]  }>
> >
> > I don't know what might have happened here. Anyone else?

I took a closer look at the commits during that period, and I suspect it is
23897, where forInteractive and forScaladoc were introduced. And indeed, when
I override val forScaladoc = true in my global, all my test failures go away.

Yes, it's that commit. I can disable constant folding in the interactive compiler. Gilles, should it be the same for Scaladoc, or it doesn't matter?
thanks,iulian 

I hope this helps locating the problem.

Thanks,

Mirko

--
Mirko Stocker | me@misto.ch
Work: http://ifs.hsr.ch | http://infoq.com
Personal: http://misto.ch | http://twitter.com/m_st



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais



--
------------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Scala Solutions
PSED, 1015 Lausanne, Switzerland





--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Mirko Stocker
Joined: 2009-09-10,
User offline. Last seen 45 weeks 6 days ago.
Re: Deactivating Constant Folding?

On Monday 10 January 2011 12:52:53 iulian dragos wrote:
> Ok, it's done now. No constant folding when in interactive or scaladoc
> mode.

Thanks!

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland