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: 4f027fe472ae
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f5298f1ca179
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Aug 5, 2015

  1. Copy the full SHA
    b2491a9 View commit details
  2. Copy the full SHA
    f5298f1 View commit details
Original file line number Diff line number Diff line change
@@ -16,18 +16,23 @@
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node.Child;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
import com.oracle.truffle.api.utilities.ValueProfile;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.ModuleNodes;
import org.jruby.truffle.nodes.lexical.GetLexicalScopeNode;
import org.jruby.truffle.nodes.objects.GetCurrentMethodNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.ModuleOperations;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyConstant;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.methods.InternalMethod;

/**
* Caches {@link ModuleOperations#lookupConstant}
@@ -36,6 +41,8 @@
*/
public abstract class LookupConstantWithLexicalScopeNode extends AbstractLookupConstantNode {

@Child GetLexicalScopeNode getLexicalScopeNode = new GetLexicalScopeNode(getContext(), getSourceSection());

public LookupConstantWithLexicalScopeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -85,7 +92,7 @@ protected RubyConstant lookupNotModule(Object module, String name) {
}

protected LexicalScope getLexicalScope(VirtualFrame frame) {
return RubyArguments.getMethod(frame.getArguments()).getLexicalScope();
return getLexicalScopeNode.getLexicalScope(frame);
}

protected boolean guardName(String name, String cachedName, ConditionProfile sameNameProfile) {
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jcodings.Encoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
@@ -44,6 +45,7 @@
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.core.hash.HashNodes;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.lexical.GetLexicalScopeNode;
import org.jruby.truffle.nodes.methods.LookupMethodNode;
import org.jruby.truffle.nodes.methods.LookupMethodNodeGen;
import org.jruby.truffle.nodes.objects.*;
@@ -527,7 +529,8 @@ public Object evalNoBindingCached(
@Cached("privatizeByteList(source)") ByteList cachedSource,
@Cached("compileSource(frame, source)") RootNodeWrapper cachedRootNode,
@Cached("createCallTarget(cachedRootNode)") CallTarget cachedCallTarget,
@Cached("create(cachedCallTarget)") DirectCallNode callNode
@Cached("create(cachedCallTarget)") DirectCallNode callNode,
@Cached("create(getContext(), getSourceSection())") GetLexicalScopeNode getLexicalScopeNode
) {
final RubyBasicObject callerBinding = getCallerBinding(frame);

@@ -539,7 +542,7 @@ public Object evalNoBindingCached(
cachedRootNode.getRootNode().getSharedMethodInfo().getName(),
getContext().getCoreLibrary().getObjectClass(),
Visibility.PUBLIC,
RubyArguments.getMethod(frame.getArguments()).getLexicalScope(),
getLexicalScopeNode.getLexicalScope(frame),
false,
cachedCallTarget, parentFrame);

Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.nodes.objects.GetCurrentMethodNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.methods.InternalMethod;
@@ -23,6 +23,8 @@
*/
public class GetLexicalScopeModuleNode extends RubyNode {

@Child GetCurrentMethodNode getCurrentMethodNode = new GetCurrentMethodNode(getContext(), getSourceSection());

public GetLexicalScopeModuleNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -34,7 +36,7 @@ public Object execute(VirtualFrame frame) {

@Override
public RubyBasicObject executeRubyBasicObject(VirtualFrame frame) {
final InternalMethod method = RubyArguments.getMethod(frame.getArguments());
final InternalMethod method = getCurrentMethodNode.getCurrentMethod(frame);
return method.getLexicalScope().getModule();
}

Original file line number Diff line number Diff line change
@@ -9,24 +9,35 @@
*/
package org.jruby.truffle.nodes.lexical;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.nodes.objects.GetCurrentMethodNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.methods.InternalMethod;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

public class GetLexicalScopeNode extends RubyNode {

public static GetLexicalScopeNode create(RubyContext context, SourceSection sourceSection) {
return new GetLexicalScopeNode(context, sourceSection);
}

@Child GetCurrentMethodNode getCurrentMethodNode = new GetCurrentMethodNode(getContext(), getSourceSection());

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

@Override
public Object execute(VirtualFrame frame) {
final InternalMethod method = RubyArguments.getMethod(frame.getArguments());
final InternalMethod method = getCurrentMethodNode.getCurrentMethod(frame);
return method.getLexicalScope();
}

public LexicalScope getLexicalScope(VirtualFrame frame) {
return (LexicalScope) execute(frame);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2015 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.objects;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ValueProfile;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.methods.InternalMethod;

public class GetCurrentMethodNode extends RubyNode {

private final ValueProfile profileCurrentMethod = ValueProfile.createIdentityProfile();

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

@Override
public Object execute(VirtualFrame frame) {
return profileCurrentMethod.profile(RubyArguments.getMethod(frame.getArguments()));
}

public InternalMethod getCurrentMethod(VirtualFrame frame) {
return (InternalMethod) execute(frame);
}

}
Original file line number Diff line number Diff line change
@@ -2448,7 +2448,7 @@ public RubyNode visitRationalNode(RationalNode node) {
private RubyNode translateRationalComplex(SourceSection sourceSection, String name, RubyNode a, RubyNode b) {
// Translate as Rubinius.privately { Rational.convert(a, b) }

final RubyNode moduleNode = new GetLexicalScopeModuleNode(context, sourceSection);
final RubyNode moduleNode = new LiteralNode(context, sourceSection, context.getCoreLibrary().getObjectClass());
return new RubyCallNode(
context, sourceSection, "convert",
new ReadConstantNode(context, sourceSection, name, moduleNode),