# HG changeset patch # User Christian Wimmer # Date 1363659661 25200 # Node ID 98b90a7bb764c9a2eaec524b5f3b8a94da2f4401 # Parent 63f909f4ba3a265cb9db90e99e898f70077122a5 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it. diff -r 63f909f4ba3a -r 98b90a7bb764 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Mon Mar 18 20:04:50 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Mon Mar 18 19:21:01 2013 -0700 @@ -1051,8 +1051,7 @@ static RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op) { if (op instanceof MoveOp) { MoveOp move = (MoveOp) op; - if (isStackSlot(move.getInput()) && move.getInput().getKind() != Kind.Object) { - // method argument (condition must be equal to handleMethodArguments) + if (optimizeMethodArgument(move.getInput())) { return RegisterPriority.None; } } @@ -1073,6 +1072,10 @@ return RegisterPriority.MustHaveRegister; } + private static boolean optimizeMethodArgument(Value value) { + return isStackSlot(value) && asStackSlot(value).isInCallerFrame() && (GraalOptions.IncomingMethodArgumentsGCSafe || value.getKind() != Kind.Object); + } + /** * Optimizes moves related to incoming stack based arguments. The interval for the destination * of such moves is assigned the stack slot (which is in the caller's frame) as its spill slot. @@ -1080,8 +1083,8 @@ void handleMethodArguments(LIRInstruction op) { if (op instanceof MoveOp) { MoveOp move = (MoveOp) op; - if (isStackSlot(move.getInput()) && move.getInput().getKind() != Kind.Object) { - StackSlot slot = (StackSlot) move.getInput(); + if (optimizeMethodArgument(move.getInput())) { + StackSlot slot = asStackSlot(move.getInput()); if (GraalOptions.DetailedAsserts) { assert op.id() > 0 : "invalid id"; assert blockForId(op.id()).getPredecessorCount() == 0 : "move from stack must be in first block"; diff -r 63f909f4ba3a -r 98b90a7bb764 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Mar 18 20:04:50 2013 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Mar 18 19:21:01 2013 -0700 @@ -212,6 +212,12 @@ public static boolean IntrinsifyAESMethods = true; /** + * Method arguments that are passed on the stack can be optimized by the register allocator to avoid spilling + * and reloading. However, this requires that the runtime visits method arguments during stack walking. + */ + public static boolean IncomingMethodArgumentsGCSafe = true; + + /** * Counts the various paths taken through snippets. */ public static boolean SnippetCounters = false;