Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: df23dfad8f47
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d534d33567d8
Choose a head ref
  • 4 commits
  • 9 files changed
  • 1 contributor

Commits on Jun 5, 2015

  1. [Truffle] Get the appropriate caller frame for visibility methods.

    * See #3013. In this case ignoring all builtins might make sense.
    eregon committed Jun 5, 2015
    Copy the full SHA
    50a6f77 View commit details
  2. Copy the full SHA
    04be036 View commit details
  3. Copy the full SHA
    dc1a0ff View commit details
  4. Copy the full SHA
    d534d33 View commit details
2 changes: 1 addition & 1 deletion spec/ruby/core/module/name_spec.rb
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
m::N.name.should be_nil
end

it "is nil for a nested module created with the module keyword" do
it "is not nil for a nested module created with the module keyword" do
m = Module.new
module m::N; end
m::N.name.should =~ /#<Module:0x[0-9a-f]+>::N/
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/name_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Module#name is set with a conditional assignment to a nested constant
fails:Module#name preserves the encoding in which the class was defined
fails:Module#name is nil for a nested module created with the module keyword
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/module/private_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:Module#private without arguments sets visibility to following method definitions
fails:Module#private without arguments stops setting visibility if the body encounters other visibility setters without arguments
fails:Module#private without arguments continues setting visibility if the body encounters other visibility setters with arguments
fails:Module#private without arguments affects normally if itself and method definitions are inside a module_eval
fails:Module#private without arguments affects evaled method definitions when itself is outside the eval
fails:Module#private without arguments affects normally if itself and following method definitions are inside a eval
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/module/protected_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:Module#protected without arguments sets visibility to following method definitions
fails:Module#protected without arguments stops setting visibility if the body encounters other visibility setters without arguments
fails:Module#protected without arguments continues setting visibility if the body encounters other visibility setters with arguments
fails:Module#protected without arguments affects normally if itself and method definitions are inside a module_eval
fails:Module#protected without arguments affects evaled method definitions when itself is outside the eval
fails:Module#protected without arguments affects normally if itself and following method definitions are inside a eval
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/module/public_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
fails:Module#public on a superclass method calls the redefined method
fails:Module#public without arguments stops setting visibility if the body encounters other visibility setters without arguments
fails:Module#public without arguments does not affect method definitions when itself is inside an eval and method definitions are outside
fails:Module#public without arguments affects evaled method definitions when itself is outside the eval
fails:Module#public without arguments affects normally if itself and following method definitions are inside a eval
Original file line number Diff line number Diff line change
@@ -300,10 +300,10 @@ public CalleeNameNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubySymbol calleeName(VirtualFrame frame) {
public RubySymbol calleeName() {
CompilerDirectives.transferToInterpreter();
// the "called name" of a method.
return getContext().getSymbolTable().getSymbol(RubyCallStack.getCallingMethod(getContext(), frame).getName());
return getContext().getSymbolTable().getSymbol(RubyCallStack.getCallingMethod(getContext()).getName());
}
}

@@ -1055,10 +1055,10 @@ public MethodNameNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubySymbol methodName(VirtualFrame frame) {
public RubySymbol methodName() {
CompilerDirectives.transferToInterpreter();
// the "original/definition name" of the method.
return getContext().getSymbolTable().getSymbol(RubyCallStack.getCallingMethod(getContext(), frame).getSharedMethodInfo().getName());
return getContext().getSymbolTable().getSymbol(RubyCallStack.getCallingMethod(getContext()).getSharedMethodInfo().getName());
}

}
Original file line number Diff line number Diff line change
@@ -1293,12 +1293,12 @@ public NestingNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyBasicObject nesting(VirtualFrame frame) {
public RubyBasicObject nesting() {
CompilerDirectives.transferToInterpreter();

final List<RubyModule> modules = new ArrayList<>();

InternalMethod method = RubyCallStack.getCallingMethod(getContext(), frame);
InternalMethod method = RubyCallStack.getCallingMethod(getContext());
LexicalScope lexicalScope = method == null ? null : method.getSharedMethodInfo().getLexicalScope();
RubyClass object = getContext().getCoreLibrary().getObjectClass();

@@ -1871,8 +1871,7 @@ RubyModule setVisibility(VirtualFrame frame, RubyModule module, Object[] names)
private void setCurrentVisibility(Visibility visibility) {
CompilerDirectives.transferToInterpreter();

final Frame callerFrame = Truffle.getRuntime().getCallerFrame().getFrame(FrameInstance.FrameAccess.READ_WRITE, false);

final Frame callerFrame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_WRITE, true);
assert callerFrame != null;
assert callerFrame.getFrameDescriptor() != null;

20 changes: 10 additions & 10 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubyCallStack.java
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.source.NullSourceSection;

@@ -28,29 +27,30 @@
public abstract class RubyCallStack {

/** Ignores Kernel#send and aliases */
public static InternalMethod getCallingMethod(final RubyContext context, VirtualFrame frame) {
public static FrameInstance getCallerFrame(final RubyContext context) {
CompilerAsserts.neverPartOfCompilation();

final InternalMethod currentMethod = RubyArguments.getMethod(frame.getArguments());

return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<InternalMethod>() {
return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<FrameInstance>() {
@Override
public InternalMethod visitFrame(FrameInstance frameInstance) {
public FrameInstance visitFrame(FrameInstance frameInstance) {
final InternalMethod method = getMethod(frameInstance);
assert method != null;

if (method != currentMethod && !context.getCoreLibrary().isSend(method)) {
return method;
if (!context.getCoreLibrary().isSend(method)) {
return frameInstance;
} else {
return null;
}
}
});
}

public static InternalMethod getMethod(FrameInstance frame) {
CompilerAsserts.neverPartOfCompilation();
public static InternalMethod getCallingMethod(final RubyContext context) {
return getMethod(getCallerFrame(context));
}

private static InternalMethod getMethod(FrameInstance frame) {
CompilerAsserts.neverPartOfCompilation();
return RubyArguments.getMethod(frame.getFrame(FrameInstance.FrameAccess.READ_ONLY, true).getArguments());
}

Original file line number Diff line number Diff line change
@@ -88,6 +88,9 @@ public static void debugModuleChain(RubyModule module) {

@CompilationFinal protected ModuleChain parentModule;

private final RubyModule lexicalParent;
private final String givenBaseName;
/** Full name, including named parent */
private String name;

private final Map<String, InternalMethod> methods = new ConcurrentHashMap<>();
@@ -109,11 +112,13 @@ public static void debugModuleChain(RubyModule module) {
public RubyModule(RubyContext context, RubyClass selfClass, RubyModule lexicalParent, String name, Node currentNode) {
super(context, selfClass);
this.context = context;
this.lexicalParent = lexicalParent;
this.givenBaseName = name;

unmodifiedAssumption = new CyclicAssumption(name + " is unmodified");

if (lexicalParent == null) {
this.name = name;
if (lexicalParent == null) { // bootstrap or anonymous module
this.name = givenBaseName;
} else {
getAdoptedByLexicalParent(lexicalParent, name, currentNode);
}
@@ -402,6 +407,8 @@ public RubyContext getContext() {
public String getName() {
if (name != null) {
return name;
} else if (givenBaseName != null) {
return lexicalParent.getName() + "::" + givenBaseName;
} else if (getLogicalClass() == this) { // For the case of class Class during initialization
return "#<cyclic>";
} else {
@@ -410,7 +417,7 @@ public String getName() {
}

public boolean hasName() {
return name != null;
return name != null || givenBaseName != null;
}

@Override