Skip to content

Commit

Permalink
Introduce a constant in CompilerDNA for methods that can't be recompi…
Browse files Browse the repository at this point in the history
…led.
  • Loading branch information
erik-brangs committed Jul 19, 2017
1 parent c5e9871 commit b2ea187
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
10 changes: 6 additions & 4 deletions rvm/src/org/jikesrvm/adaptive/controller/AnalyticModel.java
Expand Up @@ -12,6 +12,8 @@
*/
package org.jikesrvm.adaptive.controller;

import static org.jikesrvm.adaptive.recompilation.CompilerDNA.CANNOT_RECOMPILE;

import org.jikesrvm.VM;
import org.jikesrvm.adaptive.recompilation.CompilerDNA;
import org.jikesrvm.adaptive.util.AOSLogging;
Expand Down Expand Up @@ -90,8 +92,8 @@ void init() {
ControllerPlan considerHotMethod(CompiledMethod cmpMethod, HotMethodEvent hme) {
// Compiler used for the previous compilation
int prevCompiler = CompilerDNA.getPreviousCompiler(cmpMethod);
if (prevCompiler == -1) {
return null; // Not a method that we can recompile (trap, JNI).
if (prevCompiler == CANNOT_RECOMPILE) {
return null;
}

ControllerPlan plan = ControllerMemory.findMatchingPlan(cmpMethod);
Expand Down Expand Up @@ -251,8 +253,8 @@ void considerHotCallEdge(CompiledMethod cmpMethod, AINewHotEdgeEvent event) {

// Compiler used for the previous compilation
int prevCompiler = CompilerDNA.getPreviousCompiler(cmpMethod);
if (prevCompiler == -1) {
return; // Not a method we can recompile (trap, JNI).
if (prevCompiler == CANNOT_RECOMPILE) {
return;
}

ControllerPlan plan = ControllerMemory.findMatchingPlan(cmpMethod);
Expand Down
23 changes: 18 additions & 5 deletions rvm/src/org/jikesrvm/adaptive/recompilation/CompilerDNA.java
Expand Up @@ -50,6 +50,19 @@ public class CompilerDNA {
static final int OPT1 = 2;
static final int OPT2 = 3;

/**
* Represents the fact that a method can't be recompiled. There are at least three different
* cases here:
* <ul>
* <li>recompilation doesn't make any sense because the method cannot be optimized,
* e.g. for JNI compiled methods and hardware trap methods</li>
* <li>recompilation might make sense but the optimizing compiler doesn't implement
* the special semantics that the methods require</li>
* <li>the method was explicitly barred from opt compilation</li>
* </ul>
*/
public static final int CANNOT_RECOMPILE = -1;

/**
* The number of compilers available
*/
Expand Down Expand Up @@ -331,21 +344,21 @@ public static int getPreviousCompiler(CompiledMethod cmpMethod) {
switch (cmpMethod.getCompilerType()) {
case CompiledMethod.TRAP:
case CompiledMethod.JNI:
return -1; // don't try to optimize these guys!
return CANNOT_RECOMPILE; // don't try to optimize these guys!
case CompiledMethod.BASELINE: {
// Prevent the adaptive system from recompiling certain classes
// of baseline compiled methods.
if (cmpMethod.getMethod().getDeclaringClass().hasDynamicBridgeAnnotation()) {
// The opt compiler does not implement this calling convention.
return -1;
return CANNOT_RECOMPILE;
}
if (cmpMethod.getMethod().getDeclaringClass().hasBridgeFromNativeAnnotation()) {
// The opt compiler does not implement this calling convention.
return -1;
return CANNOT_RECOMPILE;
}
if (cmpMethod.getMethod().hasNoOptCompileAnnotation()) {
// Explict declaration that the method should not be opt compiled.
return -1;
return CANNOT_RECOMPILE;
}
if (!cmpMethod.getMethod().isInterruptible()) {
// A crude filter to identify the subset of core VM methods that
Expand All @@ -364,7 +377,7 @@ public static int getPreviousCompiler(CompiledMethod cmpMethod) {
return getCompilerConstant(optMeth.getOptLevel());
default:
if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED, "Unknown Compiler");
return -1;
return CANNOT_RECOMPILE;
}
}
}

0 comments on commit b2ea187

Please sign in to comment.