Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structural invocation in nsc.ast.Scanners, easy to remove performance penalty #3974

Closed
scabug opened this issue Nov 1, 2010 · 3 comments
Closed

Comments

@scabug
Copy link

scabug commented Nov 1, 2010

There's a structural invocation in nsc.ast.parser.Scanners. Not sure whether there's a performance impact, but doing away with it is easy. Rather than defining lookaheadReader (in CharArrayReader.scala) to have a refinement type, give a name to its class:

  /** A new reader that takes off at the current character position */
  def lookaheadReader = new CharArrayReaderForLookahead 

  class CharArrayReaderForLookahead extends CharArrayReader {  
    val buf = self.buf
    charOffset = self.charOffset
    ch = self.ch
    override def decodeUni = self.decodeUni
    def error(offset: Int, msg: String) = self.error(offset, msg)
    /** A mystery why CharArrayReader.nextChar() returns Unit */
    def getc() = { nextChar() ; ch }
  }

Besides that one, there are three other cases of dynamic dispatch in the compiler sources (granted, forMSIL without -optimize) found after placing a breakpoint at CleanUp on:

case ad@ApplyDynamic(qual0, params) =>

(1)
    pos: scala\\tools\\nsc\\typechecker\\Implicits.scala,line-857,offset=39632
    qual = "ImplicitSearch.this.scala$$tools$$nsc$$typechecker$$Implicits$$ImplicitSearch$$$$$$outer().global().erasure().erasure()"
    args = "List(parents)"
    symbol = "method intersectionDominator"

(2) 
    pos: scala\\tools\\nsc\\io\\File.scala,line-31,offset=1334
    qual = "target"
    args = "List()"
    symbol = "method close"

(3) 
    pos: "scala\\tools\\nsc\\io\\ZipArchive.scala,line-265,offset=8462"
    qual = "x.traverser()"
    args = "List()"
    symbol = "method zis"
@scabug
Copy link
Author

scabug commented Nov 1, 2010

@scabug
Copy link
Author

scabug commented Nov 1, 2010

@paulp said:
It occurs to me that the ZipFile bug I've been dealing with for an eternity (which I enclose the stack trace of here because it just hit me again: partest hangs and this is always among the threads) could well be related. I think I will tackle this right now.

"ForkJoinPool-1-worker-3" daemon prio=5 tid=196240800 nid=0x1973de000 runnable [1973dc000]
   java.lang.Thread.State: RUNNABLE
	at java.util.zip.ZipFile.getNextEntry(Native Method)
	at java.util.zip.ZipFile.access$$400(ZipFile.java:29)
	at java.util.zip.ZipFile$$2.nextElement(ZipFile.java:313)
	- locked <141623488> (a java.util.zip.ZipFile)
	at java.util.zip.ZipFile$$2.nextElement(ZipFile.java:299)
	at scala.tools.nsc.io.ZipArchive$$$$anon$$1$$$$anon$$2.next(ZipArchive.scala:253)
	at scala.tools.nsc.io.ZipArchive$$$$anon$$1$$$$anon$$2.next(ZipArchive.scala:250)
	at scala.collection.Iterator$$class.foreach(Iterator.scala:631)
	at scala.tools.nsc.io.ZipArchive$$$$anon$$1$$$$anon$$2.foreach(ZipArchive.scala:250)
	at scala.collection.IterableLike$$class.foreach(IterableLike.scala:79)
	at scala.tools.nsc.io.ZipArchive$$$$anon$$1.foreach(ZipArchive.scala:248)
	at scala.tools.nsc.io.ZipContainer$$ZipRootCreator.apply(ZipArchive.scala:145)
	at scala.tools.nsc.io.ZipArchive.root(ZipArchive.scala:206)
	- locked <1416234e8> (a scala.tools.nsc.io.ZipArchive)
	at scala.tools.nsc.io.ZipContainer$$class.iterator(ZipArchive.scala:172)
	at scala.tools.nsc.io.ZipArchive.iterator(ZipArchive.scala:199)
	at scala.collection.IterableLike$$class.foreach(IterableLike.scala:79)
	at scala.tools.nsc.io.AbstractFile.foreach(AbstractFile.scala:84)
	at scala.collection.TraversableLike$$class.collect(TraversableLike.scala:271)
	at scala.tools.nsc.io.AbstractFile.collect(AbstractFile.scala:84)
	at scala.tools.nsc.util.DirectoryClassPath.classes(ClassPath.scala:315)
	- locked <141623570> (a scala.tools.nsc.util.DirectoryClassPath)
	at scala.tools.nsc.util.MergedClassPath$$$$anonfun$$classes$$3.apply(ClassPath.scala:342)
	at scala.tools.nsc.util.MergedClassPath$$$$anonfun$$classes$$3.apply(ClassPath.scala:342)
	at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:61)
	at scala.collection.immutable.List.foreach(List.scala:45)
	at scala.tools.nsc.util.MergedClassPath.classes(ClassPath.scala:342)
	- locked <141623638> (a scala.tools.nsc.util.JavaClassPath)
	at scala.tools.nsc.symtab.SymbolLoaders$$PackageLoader.doComplete(SymbolLoaders.scala:150)
	at scala.tools.nsc.symtab.SymbolLoaders$$SymbolLoader.complete(SymbolLoaders.scala:58)
	at scala.tools.nsc.symtab.SymbolLoaders$$SymbolLoader.complete(SymbolLoaders.scala:32)
	at scala.tools.nsc.symtab.Symbols$$Symbol.info(Symbols.scala:690)
	at scala.tools.nsc.symtab.Definitions$$definitions$$.init(Definitions.scala:828)
	at scala.tools.nsc.Global$$Run.<init>(Global.scala:602)
	at scala.tools.partest.nest.DirectCompiler.compile(CompileManager.scala:100)
	at scala.tools.partest.nest.CompileManager.shouldCompile(CompileManager.scala:165)
	at scala.tools.partest.nest.Worker$$$$anonfun$$runTestCommon$$1$$1$$$$anonfun$$10.apply(Worker.scala:496)
	at scala.tools.partest.nest.Worker$$$$anonfun$$runTestCommon$$1$$1$$$$anonfun$$10.apply(Worker.scala:496)
	at scala.tools.partest.nest.Worker$$$$anonfun$$runTestCommon$$1$$1.apply(Worker.scala:498)
	at scala.tools.partest.nest.Worker$$$$anonfun$$runTestCommon$$1$$1.apply(Worker.scala:487)
	at scala.tools.partest.nest.Worker.runInContext$$1(Worker.scala:432)
	at scala.tools.partest.nest.Worker.runTestCommon$$1(Worker.scala:487)
	at scala.tools.partest.nest.Worker.processSingleFile$$1(Worker.scala:558)
	at scala.tools.partest.nest.Worker$$$$anonfun$$runTests$$2$$$$anonfun$$apply$$2.apply$$mcV$$sp(Worker.scala:1069)

@scabug
Copy link
Author

scabug commented Nov 1, 2010

@paulp said:
(In r23423) Sprinkling in some names to avoid reflective calls in the compiler
as suggested by magarcia. Closes #3974, no review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant