Skip to content

Commit

Permalink
Fix performance bug in GenASM.
Browse files Browse the repository at this point in the history
It was going through missingHook looking for android classes
every time something was compiled, which means four failing
missingHook calls for every line in the repl.
  • Loading branch information
paulp committed Oct 31, 2012
1 parent 98e3e47 commit 8d962ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
private def getFile(sym: Symbol, clsName: String, suffix: String): AbstractFile =
getFile(outputDirectory(sym), clsName, suffix)

/** From the reference documentation of the Android SDK:
* The `Parcelable` interface identifies classes whose instances can be written to and restored from a `Parcel`.
* Classes implementing the `Parcelable` interface must also have a static field called `CREATOR`,
* which is an object implementing the `Parcelable.Creator` interface.
*/
private val androidFieldName = newTermName("CREATOR")

private lazy val AndroidParcelableInterface = rootMirror.getClassIfDefined("android.os.Parcelable")
private lazy val AndroidCreatorClass = rootMirror.getClassIfDefined("android.os.Parcelable$Creator")

/** JVM code generation phase
*/
class AsmPhase(prev: Phase) extends ICodePhase(prev) {
Expand Down Expand Up @@ -1202,16 +1212,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
trait JAndroidBuilder {
self: JPlainBuilder =>

/** From the reference documentation of the Android SDK:
* The `Parcelable` interface identifies classes whose instances can be written to and restored from a `Parcel`.
* Classes implementing the `Parcelable` interface must also have a static field called `CREATOR`,
* which is an object implementing the `Parcelable.Creator` interface.
*/
private val androidFieldName = newTermName("CREATOR")

private lazy val AndroidParcelableInterface = rootMirror.getClassIfDefined("android.os.Parcelable")
private lazy val AndroidCreatorClass = rootMirror.getClassIfDefined("android.os.Parcelable$Creator")

def isAndroidParcelableClass(sym: Symbol) =
(AndroidParcelableInterface != NoSymbol) &&
(sym.parentSymbols contains AndroidParcelableInterface)
Expand Down
4 changes: 3 additions & 1 deletion src/reflect/scala/reflect/internal/Mirrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ trait Mirrors extends api.Mirrors {

protected def universeMissingHook(owner: Symbol, name: Name): Symbol = thisUniverse.missingHook(owner, name)

private[scala] def missingHook(owner: Symbol, name: Name): Symbol = mirrorMissingHook(owner, name) orElse universeMissingHook(owner, name)
private[scala] def missingHook(owner: Symbol, name: Name): Symbol = logResult(s"missingHook($owner, $name)")(
mirrorMissingHook(owner, name) orElse universeMissingHook(owner, name)
)

// todo: get rid of most the methods here and keep just staticClass/Module/Package

Expand Down

0 comments on commit 8d962ed

Please sign in to comment.