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

Commits on May 24, 2016

  1. Copy the full SHA
    5c10f30 View commit details
  2. Copy the full SHA
    36e729f View commit details
Showing with 18 additions and 27 deletions.
  1. +1 −1 truffle/pom.rb
  2. +1 −1 truffle/pom.xml
  3. +6 −8 truffle/src/main/java/org/jruby/truffle/RubyLanguage.java
  4. +10 −17 truffle/src/main/java/org/jruby/truffle/language/LazyRubyRootNode.java
2 changes: 1 addition & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

properties( 'polyglot.dump.pom' => 'pom.xml',
'polyglot.dump.readonly' => true,
'truffle.version' => '47a52ed08706d38820df191be74785d018f60345-SNAPSHOT',
'truffle.version' => '0.14-SNAPSHOT',
'jruby.basedir' => '${basedir}/..',
'maven.test.skip' => 'true' )

2 changes: 1 addition & 1 deletion truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ DO NOT MODIFIY - GENERATED CODE
<jruby.basedir>${basedir}/..</jruby.basedir>
<polyglot.dump.readonly>true</polyglot.dump.readonly>
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
<truffle.version>47a52ed08706d38820df191be74785d018f60345-SNAPSHOT</truffle.version>
<truffle.version>0.14-SNAPSHOT</truffle.version>
</properties>
<dependencies>
<dependency>
14 changes: 6 additions & 8 deletions truffle/src/main/java/org/jruby/truffle/RubyLanguage.java
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.instrumentation.ProvidedTags;
import com.oracle.truffle.api.instrumentation.StandardTags;
import com.oracle.truffle.api.nodes.Node;
@@ -79,8 +78,12 @@ protected void disposeContext(RubyContext context) {
}

@Override
protected CallTarget parse(Source source, Node node, String... argumentNames) throws IOException {
return Truffle.getRuntime().createCallTarget(new LazyRubyRootNode(null, null, source, argumentNames));
protected CallTarget parse(ParsingRequest request) throws IOException {
return Truffle.getRuntime().createCallTarget(
new LazyRubyRootNode(
request.createContextReference(this),
request.getSource(),
request.getArgumentNames()));
}

@Override
@@ -98,11 +101,6 @@ protected boolean isObjectOfLanguage(Object object) {
throw new UnsupportedOperationException();
}

@Override
protected Object evalInContext(Source source, Node node, MaterializedFrame mFrame) throws IOException {
return null;
}

@Override
protected String toString(RubyContext context, Object value) {
if (value == null) {
Original file line number Diff line number Diff line change
@@ -32,46 +32,39 @@
import org.jruby.truffle.language.parser.ParserContext;
import org.jruby.truffle.language.parser.jruby.TranslatorDriver;

import java.lang.ref.Reference;
import java.util.List;

public class LazyRubyRootNode extends RootNode implements InternalRootNode {

private final Reference<RubyContext> contextReference;
private final Source source;
private final String[] argumentNames;
private final List<String> argumentNames;

@CompilationFinal private RubyContext cachedContext;
@CompilationFinal private DynamicObject mainObject;
@CompilationFinal private InternalMethod method;

@Child private Node findContextNode;
@Child private DirectCallNode callNode;

public LazyRubyRootNode(SourceSection sourceSection, FrameDescriptor frameDescriptor, Source source,
String[] argumentNames) {
super(RubyLanguage.class, sourceSection, frameDescriptor);
public LazyRubyRootNode(Reference<RubyContext> contextReference, Source source, List<String> argumentNames) {
super(RubyLanguage.class, null, null);
this.contextReference = contextReference;
this.source = source;
this.argumentNames = argumentNames;
}

@Override
public Object execute(VirtualFrame frame) {
if (findContextNode == null) {
CompilerDirectives.transferToInterpreter();
findContextNode = insert(RubyLanguage.INSTANCE.unprotectedCreateFindContextNode());
}

final RubyContext context = RubyLanguage.INSTANCE.unprotectedFindContext(findContextNode);

if (cachedContext == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
cachedContext = context;
}
final RubyContext context = contextReference.get();

if (callNode == null || context != cachedContext) {
CompilerDirectives.transferToInterpreterAndInvalidate();

final TranslatorDriver translator = new TranslatorDriver(context);

final RubyRootNode rootNode = translator.parse(context, source, UTF8Encoding.INSTANCE,
ParserContext.TOP_LEVEL, argumentNames, null, null, true, null);
ParserContext.TOP_LEVEL, argumentNames.toArray(new String[argumentNames.size()]), null, null, true, null);

final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);