Skip to content

Commit

Permalink
Split scoped frame fields (backref, last line) from non-scoped in Ann…
Browse files Browse the repository at this point in the history
…otationBinder, so we don't stand up scopes for methods that just make frame-aware calls. Previous logic stood up a scope for any method marked frame = true or which professed to access any frame fields.
  • Loading branch information
headius committed Apr 12, 2010
1 parent 61a000f commit c637eb9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
50 changes: 41 additions & 9 deletions src/org/jruby/anno/AnnotationBinder.java
Expand Up @@ -126,7 +126,7 @@ public void visitClassDeclaration(ClassDeclaration cd) {
Map<String, List<MethodDeclaration>> annotatedMethods1_9 = new HashMap<String, List<MethodDeclaration>>();
Map<String, List<MethodDeclaration>> staticAnnotatedMethods1_9 = new HashMap<String, List<MethodDeclaration>>();

Set<String> frameOrScopeAwareMethods = new HashSet<String>();
Set<String> frameAwareMethods = new HashSet<String>();
Set<String> scopeAwareMethods = new HashSet<String>();

int methodCount = 0;
Expand Down Expand Up @@ -180,10 +180,33 @@ public void visitClassDeclaration(ClassDeclaration cd) {
methodDescs.add(md);

// check for frame field reads or writes
if (anno.frame() || (anno.reads() != null && anno.reads().length >= 1) || (anno.writes() != null && anno.writes().length >= 1)) {
// add all names for this annotation
frameOrScopeAwareMethods.addAll(Arrays.asList(anno.name()));
boolean frame = false;
boolean scope = false;
if (anno.frame()) {
frame = true;
}
if (anno.reads() != null) for (FrameField read : anno.reads()) {
switch (read) {
case BACKREF:
case LASTLINE:
scope = true;
break;
default:
frame = true;
}
}
if (anno.writes() != null) for (FrameField write : anno.writes()) {
switch (write) {
case BACKREF:
case LASTLINE:
scope = true;
break;
default:
frame = true;
}
}
if (frame) frameAwareMethods.addAll(Arrays.asList(anno.name()));
if (scope) scopeAwareMethods.addAll(Arrays.asList(anno.name()));
}

if (methodCount == 0) {
Expand Down Expand Up @@ -224,19 +247,28 @@ public void visitClassDeclaration(ClassDeclaration cd) {
out.println(" }");

// write out a static initializer for frame names, so it only fires once
if (!frameOrScopeAwareMethods.isEmpty()) {
out.println(" static {");
if (!frameAwareMethods.isEmpty()) {
StringBuffer frameMethodsString = new StringBuffer();
boolean first = true;
for (String name : frameOrScopeAwareMethods) {
for (String name : frameAwareMethods) {
if (!first) frameMethodsString.append(',');
first = false;
frameMethodsString.append('"').append(name).append('"');
}
out.println(" static {");
out.println(" ASTInspector.addFrameAwareMethods(" + frameMethodsString + ");");
out.println(" ASTInspector.addScopeAwareMethods(" + frameMethodsString + ");");
out.println(" }");
}
if (!scopeAwareMethods.isEmpty()) {
StringBuffer scopeMethodsString = new StringBuffer();
boolean first = true;
for (String name : scopeAwareMethods) {
if (!first) scopeMethodsString.append(',');
first = false;
scopeMethodsString.append('"').append(name).append('"');
}
out.println(" ASTInspector.addScopeAwareMethods(" + scopeMethodsString + ");");
}
out.println(" }");

out.println("}");
out.close();
Expand Down
2 changes: 1 addition & 1 deletion src/org/jruby/compiler/JITCompiler.java
Expand Up @@ -389,7 +389,7 @@ static void log(DefaultMethod method, String name, String message, String... rea

if (className == null) className = "<anon class>";

System.err.print(message + ":" + className + "." + name);
System.err.print(message + ":" + className + "." + name + " at " + method.getPosition());

if (reason.length > 0) {
System.err.print(" because of: \"");
Expand Down
Expand Up @@ -232,7 +232,7 @@ public DynamicMethod getCompiledMethod(
callConfig = CallConfiguration.FrameBacktraceScopeFull;
break;
case FrameNoneScopeNone:
callConfig = CallConfiguration.FrameBacktraceScopeDummy;
callConfig = CallConfiguration.FrameBacktraceScopeNone;
break;
}
}
Expand Down

0 comments on commit c637eb9

Please sign in to comment.