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

Commits on Dec 4, 2014

  1. Copy the full SHA
    c613403 View commit details
  2. Copy the full SHA
    41081aa View commit details
  3. Copy the full SHA
    8281a6a View commit details
  4. Copy the full SHA
    d71f3b5 View commit details
  5. Copy the full SHA
    603b8ed View commit details
Showing with 287 additions and 189 deletions.
  1. +2 −0 core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
  2. +35 −0 core/src/main/java/org/jruby/truffle/nodes/AssignmentWrapperNode.java
  3. +1 −1 core/src/main/java/org/jruby/truffle/nodes/cast/LambdaNode.java
  4. +14 −2 core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  5. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  6. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
  7. +3 −8 core/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  8. +3 −7 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  9. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/TruffleDebugNodes.java
  10. +5 −0 core/src/main/java/org/jruby/truffle/nodes/literal/BooleanLiteralNode.java
  11. +36 −0 core/src/main/java/org/jruby/truffle/nodes/literal/NilLiteralNode.java
  12. +11 −1 core/src/main/java/org/jruby/truffle/nodes/methods/BlockDefinitionNode.java
  13. +15 −0 core/src/main/java/org/jruby/truffle/nodes/methods/locals/ReadLevelVariableNode.java
  14. +10 −3 core/src/main/java/org/jruby/truffle/nodes/methods/locals/ReadLocalVariableNode.java
  15. +6 −0 core/src/main/java/org/jruby/truffle/nodes/methods/locals/WriteLevelVariableNode.java
  16. +5 −0 core/src/main/java/org/jruby/truffle/nodes/methods/locals/WriteLocalVariableNode.java
  17. +0 −2 core/src/main/java/org/jruby/truffle/nodes/objects/SelfNode.java
  18. +5 −0 core/src/main/java/org/jruby/truffle/nodes/objects/WriteClassVariableNode.java
  19. +6 −0 core/src/main/java/org/jruby/truffle/nodes/objects/WriteInstanceVariableNode.java
  20. +1 −1 core/src/main/java/org/jruby/truffle/nodes/supercall/AbstractGeneralSuperCallNode.java
  21. +7 −4 core/src/main/java/org/jruby/truffle/runtime/RubyCallStack.java
  22. +10 −3 core/src/main/java/org/jruby/truffle/runtime/core/RubyProc.java
  23. +59 −75 core/src/main/java/org/jruby/truffle/runtime/core/RubyRegexp.java
  24. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubySymbol.java
  25. +3 −0 core/src/main/java/org/jruby/truffle/runtime/methods/MethodLike.java
  26. +1 −0 core/src/main/java/org/jruby/truffle/runtime/methods/RubyMethod.java
  27. +32 −56 core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  28. +1 −1 core/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java
  29. +8 −0 core/src/main/java/org/jruby/truffle/translator/TranslatorEnvironment.java
  30. +3 −20 spec/truffle/tags/language/defined_tags.txt
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
Original file line number Diff line number Diff line change
@@ -153,6 +153,8 @@ public Object get() {
final RubyRootNode parsedRootNode = truffleContext.getTranslator().parse(truffleContext, source, parserContext, parentFrame, null);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(parsedRootNode);

// TODO(CS): we really need a method here - it's causing problems elsewhere

return callTarget.call(RubyArguments.pack(null, parentFrame, self, null, new Object[]{}));
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.runtime.RubyContext;

public class AssignmentWrapperNode extends RubyNode {

@Child protected RubyNode child;

public AssignmentWrapperNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection);
this.child = child;
}

@Override
public Object execute(VirtualFrame frame) {
return child.execute(frame);
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("assignment");
}

}
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public Object execute(VirtualFrame frame) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.LAMBDA,
method.getSharedMethodInfo(), method.getCallTarget(), method.getCallTarget(),
method.getDeclarationFrame(), RubyArguments.getSelf(frame.getArguments()), null);
method.getDeclarationFrame(), method.getDeclaringModule(), RubyArguments.getSelf(frame.getArguments()), null);
}

@Override
16 changes: 14 additions & 2 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -2366,7 +2366,7 @@ public Object max(VirtualFrame frame, RubyArray array) {

final RubyProc block = new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
maxBlock.getSharedMethodInfo(), maxBlock.getCallTarget(), maxBlock.getCallTarget(),
maximumClosureFrame.materialize(), array, null);
maximumClosureFrame.materialize(), null, array, null);

eachNode.call(frame, array, "each", block);

@@ -2441,10 +2441,16 @@ public FrameSlot getFrameSlot() {
return frameSlot;
}

@Override
public SharedMethodInfo getSharedMethodInfo() {
return sharedMethodInfo;
}

@Override
public RubyModule getDeclaringModule() {
throw new UnsupportedOperationException();
}

public CallTarget getCallTarget() {
return callTarget;
}
@@ -2479,7 +2485,7 @@ public Object min(VirtualFrame frame, RubyArray array) {

final RubyProc block = new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
minBlock.getSharedMethodInfo(), minBlock.getCallTarget(), minBlock.getCallTarget(),
minimumClosureFrame.materialize(), array, null);
minimumClosureFrame.materialize(), null, array, null);

eachNode.call(frame, array, "each", block);

@@ -2554,10 +2560,16 @@ public FrameSlot getFrameSlot() {
return frameSlot;
}

@Override
public SharedMethodInfo getSharedMethodInfo() {
return sharedMethodInfo;
}

@Override
public RubyModule getDeclaringModule() {
throw new UnsupportedOperationException();
}

public CallTarget getCallTarget() {
return callTarget;
}
Original file line number Diff line number Diff line change
@@ -1084,7 +1084,7 @@ public RubyProc proc(RubyProc block) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.LAMBDA,
block.getSharedMethodInfo(), block.getCallTargetForMethods(), block.getCallTargetForMethods(),
block.getDeclarationFrame(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
block.getDeclarationFrame(), block.getDeclaringModule(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
}
}

@@ -1320,7 +1320,7 @@ public RubyProc proc(RubyProc block) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
block.getSharedMethodInfo(), block.getCallTarget(), block.getCallTargetForMethods(), block.getDeclarationFrame(),
block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
block.getDeclaringModule(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
}
}

Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public InitializeNode(InitializeNode prev) {
@Specialization
public RubyNilClass initialize(RubyProc proc, RubyProc block) {
proc.initialize(block.getSharedMethodInfo(), block.getCallTargetForMethods(), block.getCallTargetForMethods(),
block.getDeclarationFrame(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
block.getDeclarationFrame(), block.getDeclaringModule(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());

return getContext().getCoreLibrary().getNilObject();
}
11 changes: 3 additions & 8 deletions core/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.core.*;
import org.jruby.util.ByteList;
@@ -79,7 +78,7 @@ public CaseEqualNode(CaseEqualNode prev) {
public Object match(RubyRegexp regexp, RubyString string) {
notDesignedForCompilation();

return regexp.matchOperator(string.toString()) != getContext().getCoreLibrary().getNilObject();
return regexp.matchCommon(string.getBytes(), true) != getContext().getCoreLibrary().getNilObject();
}

}
@@ -97,9 +96,7 @@ public MatchOperatorNode(MatchOperatorNode prev) {

@Specialization
public Object match(RubyRegexp regexp, RubyString string) {
notDesignedForCompilation();

return regexp.matchOperator(string.toString());
return regexp.matchCommon(string.getBytes(), true);
}

@Specialization
@@ -205,9 +202,7 @@ public MatchNode(MatchNode prev) {

@Specialization
public Object match(RubyRegexp regexp, RubyString string) {
notDesignedForCompilation();

return regexp.match(string);
return regexp.matchCommon(string.getBytes(), false);
}

}
10 changes: 3 additions & 7 deletions core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
Original file line number Diff line number Diff line change
@@ -253,9 +253,7 @@ public MatchOperatorNode(MatchOperatorNode prev) {

@Specialization
public Object match(RubyString string, RubyRegexp regexp) {
notDesignedForCompilation();

return regexp.matchOperator(string.toString());
return regexp.matchCommon(string.getBytes(), true);
}
}

@@ -643,14 +641,12 @@ public Object match(RubyString string, RubyString regexpString) {
notDesignedForCompilation();

final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.toString(), Option.DEFAULT);
return regexp.match(string);
return regexp.matchCommon(string.getBytes(), false);
}

@Specialization
public Object match(RubyString string, RubyRegexp regexp) {
notDesignedForCompilation();

return regexp.match(string);
return regexp.matchCommon(string.getBytes(), false);
}
}

Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ public ParseTreeNode(ParseTreeNode prev) {
public Object parseTree() {
notDesignedForCompilation();

final org.jruby.ast.Node parseTree = RubyCallStack.getCurrentMethod().getSharedMethodInfo().getParseTree();
final org.jruby.ast.Node parseTree = RubyCallStack.getCallingMethod().getSharedMethodInfo().getParseTree();

if (parseTree == null) {
return getContext().getCoreLibrary().getNilObject();
Original file line number Diff line number Diff line change
@@ -36,4 +36,9 @@ public boolean executeBoolean(VirtualFrame frame) {
return value;
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString(value ? "true" : "false");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.literal;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;

@NodeInfo(cost = NodeCost.NONE)
public class NilLiteralNode extends RubyNode {

public NilLiteralNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
public Object execute(VirtualFrame frame) {
return getContext().getCoreLibrary().getNilObject();
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("nil");
}

}
Original file line number Diff line number Diff line change
@@ -46,8 +46,18 @@ public Object execute(VirtualFrame frame) {
declarationFrame = null;
}

final MethodLike methodLike = RubyArguments.getMethod(frame.getArguments());

final RubyModule declaringModule;

if (methodLike == null) {
declaringModule = null;
} else {
declaringModule = methodLike.getDeclaringModule();
}

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC, sharedMethodInfo,
callTarget, callTargetForMethods, declarationFrame, RubyArguments.getSelf(frame.getArguments()),
callTarget, callTargetForMethods, declarationFrame, declaringModule, RubyArguments.getSelf(frame.getArguments()),
RubyArguments.getBlock(frame.getArguments()));
}

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
import com.oracle.truffle.api.frame.*;
import org.jruby.truffle.nodes.*;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.translator.BodyTranslator;

public abstract class ReadLevelVariableNode extends FrameSlotNode implements ReadNode {

@@ -64,4 +65,18 @@ public RubyNode makeWriteNode(RubyNode rhs) {
return WriteLevelVariableNodeFactory.create(getContext(), getSourceSection(), frameSlot, varLevel, rhs);
}

@Override
public Object isDefined(VirtualFrame frame) {
// TODO(CS): copy and paste of ReadLocalVariableNode
if (BodyTranslator.FRAME_LOCAL_GLOBAL_VARIABLES.contains(frameSlot.getIdentifier())) {
if (ReadLocalVariableNode.ALWAYS_DEFINED_GLOBALS.contains(frameSlot.getIdentifier()) || doObject(frame) != getContext().getCoreLibrary().getNilObject()) {
return getContext().makeString("global-variable");
} else {
return getContext().getCoreLibrary().getNilObject();
}
} else {
return getContext().makeString("local-variable");
}
}

}
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.translator.BodyTranslator;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public abstract class ReadLocalVariableNode extends FrameSlotNode implements ReadNode {

public ReadLocalVariableNode(RubyContext context, SourceSection sourceSection, FrameSlot slot) {
@@ -57,13 +61,16 @@ public RubyNode makeWriteNode(RubyNode rhs) {
return WriteLocalVariableNodeFactory.create(getContext(), getSourceSection(), frameSlot, rhs);
}

public static final Set<String> ALWAYS_DEFINED_GLOBALS = new HashSet<>(Arrays.asList("$~"));

@Override
public Object isDefined(VirtualFrame frame) {
// TODO(CS): copy and paste of ReadLevelVariableNode
if (BodyTranslator.FRAME_LOCAL_GLOBAL_VARIABLES.contains(frameSlot.getIdentifier())) {
if (frameSlot.getIdentifier().equals("$+") && getObject(frame) == getContext().getCoreLibrary().getNilObject()) {
return getContext().getCoreLibrary().getNilObject();
} else {
if (ALWAYS_DEFINED_GLOBALS.contains(frameSlot.getIdentifier()) || doObject(frame) != getContext().getCoreLibrary().getNilObject()) {
return getContext().makeString("global-variable");
} else {
return getContext().getCoreLibrary().getNilObject();
}
} else {
return getContext().makeString("local-variable");
Original file line number Diff line number Diff line change
@@ -69,4 +69,10 @@ public Object doObject(VirtualFrame frame, Object value) {
public RubyNode makeReadNode() {
return ReadLevelVariableNodeFactory.create(getContext(), getSourceSection(), frameSlot, varLevel);
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("assignment");
}

}
Original file line number Diff line number Diff line change
@@ -62,4 +62,9 @@ public RubyNode makeReadNode() {
return ReadLocalVariableNodeFactory.create(getContext(), getSourceSection(), frameSlot);
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("assignment");
}

}
Original file line number Diff line number Diff line change
@@ -31,8 +31,6 @@ public Object execute(VirtualFrame frame) {

@Override
public Object isDefined(VirtualFrame frame) {
notDesignedForCompilation();

return getContext().makeString("self");
}

Original file line number Diff line number Diff line change
@@ -46,4 +46,9 @@ public Object execute(VirtualFrame frame) {
return rhsValue;
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("assignment");
}

}
Original file line number Diff line number Diff line change
@@ -139,4 +139,10 @@ public Object execute(VirtualFrame frame) {
public RubyNode makeReadNode() {
return new ReadInstanceVariableNode(getContext(), getSourceSection(), writeNode.getName(), receiver, isGlobal);
}

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("assignment");
}

}
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ protected void lookup(VirtualFrame frame) {
CompilerAsserts.neverPartOfCompilation();

// TODO: this is wrong, we need the lexically enclosing method (or define_method)'s module
final RubyModule declaringModule = RubyCallStack.getCurrentMethod().getDeclaringModule();
final RubyModule declaringModule = RubyCallStack.getCurrentDeclaringModule();
final RubyClass selfMetaClass = getContext().getCoreLibrary().getMetaClass(RubyArguments.getSelf(frame.getArguments()));

method = ModuleOperations.lookupSuperMethod(declaringModule, name, selfMetaClass);
Loading