diff options
author | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2012-03-06 12:26:27 +0100 |
---|---|---|
committer | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2012-03-06 12:26:27 +0100 |
commit | e328d853a6e0e790da01fedd8122e2875c7f1442 (patch) | |
tree | 10d1704d5bd909bb80ef7f4b0059ce347ca0a383 /src | |
parent | d9a85b5e67092fba1c37d8facc6dd2d273c26a27 (diff) | |
download | scala-e328d853a6e0e790da01fedd8122e2875c7f1442.tar.gz scala-e328d853a6e0e790da01fedd8122e2875c7f1442.tar.bz2 scala-e328d853a6e0e790da01fedd8122e2875c7f1442.zip |
fewer hops to emit ASTORE and ALOAD
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 0c5debacc7..b8ccccb916 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1275,7 +1275,19 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with genConstant(jcode, const) case LOAD_ARRAY_ITEM(kind) => - jcode.emitALOAD(javaType(kind)) + if(kind.isRefOrArrayType) { jcode.emitAALOAD() } + else { + (kind: @unchecked) match { + case UNIT => throw new IllegalArgumentException("invalid type for aload " + kind) + case BOOL | BYTE => jcode.emitBALOAD() + case SHORT => jcode.emitSALOAD() + case CHAR => jcode.emitCALOAD() + case INT => jcode.emitIALOAD() + case LONG => jcode.emitLALOAD() + case FLOAT => jcode.emitFALOAD() + case DOUBLE => jcode.emitDALOAD() + } + } case LOAD_LOCAL(local) => jcode.emitLOAD(indexOf(local), javaType(local.kind)) @@ -1294,7 +1306,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with javaType(field)) case LOAD_MODULE(module) => - // assert(module.isModule, "Expected module: " + module) + // assert(module.isModule, "Expected module: " + module) debuglog("generating LOAD_MODULE for: " + module + " flags: " + Flags.flagsToString(module.flags)); if (clasz.symbol == module.moduleClass && jmethod.getName() != nme.readResolve.toString) @@ -1305,7 +1317,19 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with javaType(module)) case STORE_ARRAY_ITEM(kind) => - jcode emitASTORE javaType(kind) + if(kind.isRefOrArrayType) { jcode.emitAASTORE() } + else { + (kind: @unchecked) match { + case UNIT => throw new IllegalArgumentException("invalid type for astore " + kind) + case BOOL | BYTE => jcode.emitBASTORE() + case SHORT => jcode.emitSASTORE() + case CHAR => jcode.emitCASTORE() + case INT => jcode.emitIASTORE() + case LONG => jcode.emitLASTORE() + case FLOAT => jcode.emitFASTORE() + case DOUBLE => jcode.emitDASTORE() + } + } case STORE_LOCAL(local) => jcode.emitSTORE(indexOf(local), javaType(local.kind)) |