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: 71cddf03bbc5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 376560533681
Choose a head ref
  • 5 commits
  • 20 files changed
  • 1 contributor

Commits on Oct 10, 2014

  1. [Truffle] Remove cases using both isModuleMethod and visibility.

    *  Also add a warning (but cannot detect the default PUBLIC visibility).
    eregon committed Oct 10, 2014
    Copy the full SHA
    f51d47b View commit details
  2. [Truffle] Rename isModuleMethod to isModuleFunction.

    * This is colser to Ruby terminology.
    * Also indicates the receiver is likely ignored.
    eregon committed Oct 10, 2014
    Copy the full SHA
    ae1e355 View commit details
  3. [Truffle] Kernel.binding should not need self.

    * Fixes: eval "self", Kernel.binding
    eregon committed Oct 10, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    630d47b View commit details
  4. Copy the full SHA
    2bd4fe6 View commit details
  5. [Truffle] Do not allow module functions to use self as it depends on …

    …context.
    
    * One can use RubyArguments.getSelf(frame.getArguments()) for extraordinary cases.
    * But these tend to never happen, we just need better support for singleton-only methods.
    eregon committed Oct 10, 2014
    Copy the full SHA
    3765605 View commit details
Showing with 122 additions and 130 deletions.
  1. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/CoreMethod.java
  2. +12 −5 core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
  3. +4 −5 core/src/main/java/org/jruby/truffle/nodes/core/DirNodes.java
  4. +3 −3 core/src/main/java/org/jruby/truffle/nodes/core/EncodingNodes.java
  5. +1 −2 core/src/main/java/org/jruby/truffle/nodes/core/FiberNodes.java
  6. +11 −13 core/src/main/java/org/jruby/truffle/nodes/core/FileNodes.java
  7. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/HashNodes.java
  8. +1 −7 core/src/main/java/org/jruby/truffle/nodes/core/IONodes.java
  9. +34 −35 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  10. +26 −27 core/src/main/java/org/jruby/truffle/nodes/core/MathNodes.java
  11. +1 −3 core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  12. +5 −5 core/src/main/java/org/jruby/truffle/nodes/core/ObjectSpaceNodes.java
  13. +1 −2 core/src/main/java/org/jruby/truffle/nodes/core/ProcessNodes.java
  14. +1 −3 core/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  15. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/SignalNodes.java
  16. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/SymbolNodes.java
  17. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
  18. +9 −10 core/src/main/java/org/jruby/truffle/nodes/core/TruffleDebugNodes.java
  19. +6 −3 core/src/main/java/org/jruby/truffle/nodes/rubinius/ByteArrayNodes.java
  20. +1 −1 core/src/main/java/org/jruby/truffle/nodes/rubinius/TypeNodes.java
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@

Visibility visibility() default Visibility.PUBLIC;

boolean isModuleMethod() default false;
boolean isModuleFunction() default false;

boolean needsSelf() default true;

Original file line number Diff line number Diff line change
@@ -143,12 +143,19 @@ private static void addMethod(RubyClass rubyObjectClass, MethodDetails methodDet

final Visibility visibility = anno.visibility();

final RubyRootNode rootNode = makeGenericMethod(context, methodDetails);
if (anno.isModuleFunction() && visibility != Visibility.PUBLIC) {
System.err.println("WARNING: visibility ignored when isModuleFunction in " + methodDetails.getIndicativeName());
}

// Do not use needsSelf=true in module functions, it is either the module/class or the instance.
final boolean needsSelf = !anno.isModuleFunction() && anno.needsSelf();

final RubyRootNode rootNode = makeGenericMethod(context, methodDetails, needsSelf);

final RubyMethod method = new RubyMethod(rootNode.getSharedMethodInfo(), canonicalName, module, visibility, false,
Truffle.getRuntime().createCallTarget(rootNode), null);

if (anno.isModuleMethod()) {
if (anno.isModuleFunction()) {
module.addMethod(null, method.withNewVisibility(Visibility.PRIVATE));
module.getSingletonClass(null).addMethod(null, method.withNewVisibility(Visibility.PUBLIC));
} else {
@@ -160,13 +167,13 @@ private static void addMethod(RubyClass rubyObjectClass, MethodDetails methodDet

module.addMethod(null, withAlias);

if (anno.isModuleMethod()) {
if (anno.isModuleFunction()) {
module.getSingletonClass(null).addMethod(null, withAlias.withNewVisibility(Visibility.PUBLIC));
}
}
}

private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails methodDetails) {
private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails methodDetails, boolean needsSelf) {
final CoreSourceSection sourceSection = new CoreSourceSection(methodDetails.getClassAnnotation().name(), methodDetails.getMethodAnnotation().names()[0]);

final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, methodDetails.getIndicativeName(), false, null);
@@ -175,7 +182,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails

final List<RubyNode> argumentsNodes = new ArrayList<>();

if (methodDetails.getMethodAnnotation().needsSelf()) {
if (needsSelf) {
RubyNode readSelfNode = new SelfNode(context, sourceSection);

if (methodDetails.getMethodAnnotation().lowerFixnumSelf()) {
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/truffle/nodes/core/DirNodes.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import java.nio.file.attribute.*;

import com.oracle.truffle.api.CompilerDirectives.SlowPath;
import com.oracle.truffle.api.*;
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*;
@@ -25,7 +24,7 @@
@CoreClass(name = "Dir")
public abstract class DirNodes {

@CoreMethod(names = "[]", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "[]", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class GlobNode extends CoreMethodNode {

public GlobNode(RubyContext context, SourceSection sourceSection) {
@@ -97,7 +96,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO

}

@CoreMethod(names = "chdir", isModuleMethod = true, needsSelf = false, needsBlock = true, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "chdir", isModuleFunction = true, needsBlock = true, minArgs = 1, maxArgs = 1)
public abstract static class ChdirNode extends YieldingCoreMethodNode {

public ChdirNode(RubyContext context, SourceSection sourceSection) {
@@ -130,7 +129,7 @@ public Object chdir(VirtualFrame frame, RubyString path, RubyProc block) {

}

@CoreMethod(names = {"exist?", "exists?"}, isModuleMethod = true, needsSelf = false, maxArgs = 1)
@CoreMethod(names = {"exist?", "exists?"}, isModuleFunction = true, maxArgs = 1)
public abstract static class ExistsNode extends CoreMethodNode {

public ExistsNode(RubyContext context, SourceSection sourceSection) {
@@ -150,7 +149,7 @@ public boolean exists(RubyString path) {

}

@CoreMethod(names = "pwd", isModuleMethod = true, needsSelf = false, maxArgs = 0)
@CoreMethod(names = "pwd", isModuleFunction = true, maxArgs = 0)
public abstract static class PwdNode extends CoreMethodNode {

public PwdNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public boolean equal(RubyEncoding a, RubyEncoding b) {

}

@CoreMethod(names = "default_external", isModuleMethod = true, needsSelf = false, maxArgs = 0)
@CoreMethod(names = "default_external", isModuleFunction = true, maxArgs = 0)
public abstract static class DefaultExternalNode extends CoreMethodNode {

public DefaultExternalNode(RubyContext context, SourceSection sourceSection) {
@@ -65,7 +65,7 @@ public RubyEncoding defaultExternal() {

}

@CoreMethod(names = "default_internal", isModuleMethod = true, needsSelf = false, maxArgs = 0)
@CoreMethod(names = "default_internal", isModuleFunction = true, maxArgs = 0)
public abstract static class DefaultInternalNode extends CoreMethodNode {

public DefaultInternalNode(RubyContext context, SourceSection sourceSection) {
@@ -91,7 +91,7 @@ public RubyEncoding defaultInternal() {

}

@CoreMethod(names = "find", isModuleMethod = true, needsSelf = false, maxArgs = 1, minArgs = 1)
@CoreMethod(names = "find", isModuleFunction = true, maxArgs = 1, minArgs = 1)
public abstract static class FindNode extends CoreMethodNode {

public FindNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.*;
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.dsl.*;
import org.jruby.truffle.runtime.*;
@@ -63,7 +62,7 @@ public NilPlaceholder initialize(RubyFiber fiber, RubyProc block) {

}

@CoreMethod(names = "yield", isModuleMethod = true, needsSelf = false, isSplatted = true)
@CoreMethod(names = "yield", isModuleFunction = true, isSplatted = true)
public abstract static class YieldNode extends CoreMethodNode {

public YieldNode(RubyContext context, SourceSection sourceSection) {
24 changes: 11 additions & 13 deletions core/src/main/java/org/jruby/truffle/nodes/core/FileNodes.java
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@

import java.io.*;

import com.oracle.truffle.api.*;
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*;
@@ -22,8 +21,7 @@

@CoreClass(name = "File")
public abstract class FileNodes {

@CoreMethod(names = "absolute_path", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "absolute_path", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class AbsolutePathNode extends CoreMethodNode {

public AbsolutePathNode(RubyContext context, SourceSection sourceSection) {
@@ -64,7 +62,7 @@ public NilPlaceholder close(RubyFile file) {

}

@CoreMethod(names = "delete", needsSelf = false, isModuleMethod = true, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "delete", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class DeleteNode extends CoreMethodNode {

public DeleteNode(RubyContext context, SourceSection sourceSection) {
@@ -86,7 +84,7 @@ public int delete(RubyString file) {

}

@CoreMethod(names = "directory?", isModuleMethod = true, needsSelf = false, maxArgs = 1)
@CoreMethod(names = "directory?", isModuleFunction = true, maxArgs = 1)
public abstract static class DirectoryNode extends CoreMethodNode {

public DirectoryNode(RubyContext context, SourceSection sourceSection) {
@@ -106,7 +104,7 @@ public boolean directory(RubyString path) {

}

@CoreMethod(names = "dirname", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "dirname", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class DirnameNode extends CoreMethodNode {

public DirnameNode(RubyContext context, SourceSection sourceSection) {
@@ -174,7 +172,7 @@ public NilPlaceholder eachLine(VirtualFrame frame, RubyFile file, RubyProc block

}

@CoreMethod(names = {"exist?", "exists?"}, isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = {"exist?", "exists?"}, isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class ExistsNode extends CoreMethodNode {

public ExistsNode(RubyContext context, SourceSection sourceSection) {
@@ -194,7 +192,7 @@ public boolean exists(RubyString path) {

}

@CoreMethod(names = "executable?", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "executable?", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class ExecutableNode extends CoreMethodNode {

public ExecutableNode(RubyContext context, SourceSection sourceSection) {
@@ -214,7 +212,7 @@ public boolean executable(RubyString path) {

}

@CoreMethod(names = "expand_path", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 2)
@CoreMethod(names = "expand_path", isModuleFunction = true, minArgs = 1, maxArgs = 2)
public abstract static class ExpandPathNode extends CoreMethodNode {

public ExpandPathNode(RubyContext context, SourceSection sourceSection) {
@@ -239,7 +237,7 @@ public RubyString expandPath(RubyString path, RubyString dir) {

}

@CoreMethod(names = "file?", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "file?", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class FileNode extends CoreMethodNode {

public FileNode(RubyContext context, SourceSection sourceSection) {
@@ -259,7 +257,7 @@ public boolean file(RubyString path) {

}

@CoreMethod(names = "join", isModuleMethod = true, needsSelf = false, isSplatted = true)
@CoreMethod(names = "join", isModuleFunction = true, isSplatted = true)
public abstract static class JoinNode extends CoreMethodNode {

public JoinNode(RubyContext context, SourceSection sourceSection) {
@@ -297,7 +295,7 @@ public static void join(StringBuilder builder, Object[] parts) {
}
}

@CoreMethod(names = "open", isModuleMethod = true, needsSelf = false, needsBlock = true, minArgs = 2, maxArgs = 2)
@CoreMethod(names = "open", isModuleFunction = true, needsBlock = true, minArgs = 2, maxArgs = 2)
public abstract static class OpenNode extends YieldingCoreMethodNode {

public OpenNode(RubyContext context, SourceSection sourceSection) {
@@ -394,7 +392,7 @@ public RubyString read(RubyFile file) {

}

@CoreMethod(names = "size?", minArgs = 1, maxArgs = 1, needsSelf = false, isModuleMethod = true)
@CoreMethod(names = "size?", minArgs = 1, maxArgs = 1, isModuleFunction = true)
public abstract static class SizeNode extends CoreMethodNode {

public SizeNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ public boolean equal(RubyHash a, RubySymbol b) {

}

@CoreMethod(names = "[]", isModuleMethod = true, needsSelf = false, isSplatted = true)
@CoreMethod(names = "[]", isModuleFunction = true, isSplatted = true)
public abstract static class ConstructNode extends HashCoreMethodNode {

private final BranchProfile singleObject = new BranchProfile();
8 changes: 1 addition & 7 deletions core/src/main/java/org/jruby/truffle/nodes/core/IONodes.java
Original file line number Diff line number Diff line change
@@ -9,15 +9,9 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.runtime.NilPlaceholder;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyString;

@@ -28,7 +22,7 @@
@CoreClass(name = "IO")
public abstract class IONodes {

@CoreMethod(names = "readlines", isModuleMethod = true, needsSelf = false, minArgs = 1, maxArgs = 1)
@CoreMethod(names = "readlines", isModuleFunction = true, minArgs = 1, maxArgs = 1)
public abstract static class ReadLinesNode extends CoreMethodNode {

public ReadLinesNode(RubyContext context, SourceSection sourceSection) {
Loading