Skip to content
Permalink
Browse files
Merge branch 'master' into truffle-head
  • Loading branch information
chrisseaton committed Dec 15, 2014
2 parents 15473b8 + 156c62d commit a8d608a8ad401d6c2668b7b46d08d2fc1d9294a0
Showing with 221 additions and 263 deletions.
  1. +3 −0 .gitignore
  2. +0 −53 core/.classpath
  3. +0 −14 core/.project
  4. +0 −4 core/.settings/org.eclipse.jdt.apt.core.prefs
  5. +0 −18 core/.settings/org.eclipse.jdt.core.prefs
  6. +0 −60 core/.settings/org.eclipse.jdt.ui.prefs
  7. +7 −1 core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
  8. +28 −0 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  9. +9 −24 core/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  10. +0 −15 core/src/main/java/org/jruby/truffle/runtime/rubinius/RubiniusLibrary.java
  11. +10 −1 core/src/main/java/org/jruby/truffle/runtime/subsystems/FeatureManager.java
  12. +0 −4 core/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java
  13. +20 −0 core/src/main/ruby/jruby/truffle/core.rb
  14. +15 −0 core/src/main/ruby/jruby/truffle/core/float.rb
  15. +4 −63 core/src/main/ruby/jruby/truffle/core/kernel.rb
  16. +72 −0 core/src/main/ruby/jruby/truffle/core/main.rb
  17. +14 −0 core/src/main/ruby/jruby/truffle/core/math.rb
  18. +22 −0 core/src/main/ruby/jruby/truffle/core/rubinius/README.md
  19. +1 −1 core/src/main/ruby/jruby/truffle/core/rubinius/api/bootstrap/channel.rb
  20. +1 −1 core/src/main/ruby/jruby/truffle/core/rubinius/api/common/bytearray.rb
  21. +1 −1 core/src/main/ruby/jruby/truffle/core/rubinius/api/common/channel.rb
  22. +1 −1 core/src/main/ruby/jruby/truffle/core/rubinius/api/common/thread.rb
  23. +1 −1 core/src/main/ruby/jruby/truffle/core/rubinius/api/common/tuple.rb
  24. +1 −1 core/src/main/ruby/jruby/truffle/core/rubinius/api/common/type.rb
  25. +1 −0 spec/truffle/tags/core/dir/fileno_tags.txt
  26. +2 −0 spec/truffle/tags/core/file/flock_tags.txt
  27. +8 −0 test/truffle/test_methods_parity.rb
@@ -93,6 +93,9 @@ nbproject/private

# Eclipse project files
/.metadata
core/.classpath
core/.project
core/.settings

# Truffle benchmark stuff
reference.txt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -13,10 +13,12 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.TruffleBridge;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.TopLevelRaiseHandler;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.RubyContext;
@@ -143,7 +145,11 @@ public Object execute(final TranslatorDriver.ParserContext parserContext, final
return truffleContext.execute(truffleContext, source, parserContext, self, parentFrame, null, new NodeWrapper() {
@Override
public RubyNode wrap(RubyNode node) {
return new TopLevelRaiseHandler(node.getContext(), node.getSourceSection(), node);
RubyContext context = node.getContext();
SourceSection sourceSection = node.getSourceSection();
return SequenceNode.sequence(context, sourceSection,
new SetTopLevelBindingNode(context, sourceSection),
new TopLevelRaiseHandler(context, sourceSection, node));
}
});
}
@@ -1606,6 +1606,34 @@ public boolean require(RubyString feature) {
}
}

@CoreMethod(names = "require_relative", isModuleFunction = true, required = 1)
public abstract static class RequireRelativeNode extends CoreMethodNode {

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

public RequireRelativeNode(RequireRelativeNode prev) {
super(prev);
}

@Specialization
public boolean require(VirtualFrame frame, RubyString feature) {
notDesignedForCompilation();

final String sourcePath = Truffle.getRuntime().getCallerFrame().getCallNode().getEncapsulatingSourceSection().getSource().getPath();
final String directoryPath = new File(sourcePath).getParent();

try {
getContext().getFeatureManager().requireInPath(directoryPath, feature.toString(), this);
} catch (IOException e) {
throw new RuntimeException(e);
}

return true;
}
}

@CoreMethod(names = "respond_to?", required = 1, optional = 1)
public abstract static class RespondToNode extends CoreMethodNode {

@@ -15,6 +15,7 @@
import com.oracle.truffle.api.source.Source;
import org.jcodings.Encoding;
import org.jcodings.EncodingDB;
import org.jruby.embed.variable.Constant;
import org.jruby.runtime.Constants;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.encoding.EncodingService;
@@ -239,10 +240,10 @@ public void initialize() {

// Set constants

objectClass.setConstant(null, "RUBY_VERSION", RubyString.fromJavaString(stringClass, "2.1.0"));
objectClass.setConstant(null, "RUBY_PATCHLEVEL", 0);
objectClass.setConstant(null, "RUBY_ENGINE", RubyString.fromJavaString(stringClass, "jrubytruffle"));
objectClass.setConstant(null, "RUBY_PLATFORM", RubyString.fromJavaString(stringClass, "jvm"));
objectClass.setConstant(null, "RUBY_VERSION", RubyString.fromJavaString(stringClass, Constants.RUBY_VERSION));
objectClass.setConstant(null, "RUBY_PATCHLEVEL", Constants.RUBY_PATCHLEVEL);
objectClass.setConstant(null, "RUBY_ENGINE", RubyString.fromJavaString(stringClass, Constants.ENGINE + "+truffle"));
objectClass.setConstant(null, "RUBY_PLATFORM", RubyString.fromJavaString(stringClass, Constants.PLATFORM));

final LinkedHashMap<Object, Object> configHashMap = new LinkedHashMap<>();
configHashMap.put(RubyString.fromJavaString(stringClass, "ruby_install_name"), RubyString.fromJavaString(stringClass, "rubytruffle"));
@@ -288,20 +289,10 @@ public void initialize() {
envHash = getSystemEnv();
objectClass.setConstant(null, "ARGV", argv);
objectClass.setConstant(null, "ENV", envHash);
objectClass.setConstant(null, "TRUE", true);
objectClass.setConstant(null, "FALSE", false);
objectClass.setConstant(null, "NIL", nilObject);

final RubyHash configHash = new RubyHash(hashClass, null, null, configHashMap, 0);
configModule.setConstant(null, "CONFIG", configHash);

floatClass.setConstant(null, "EPSILON", org.jruby.RubyFloat.EPSILON);
floatClass.setConstant(null, "INFINITY", org.jruby.RubyFloat.INFINITY);
floatClass.setConstant(null, "NAN", org.jruby.RubyFloat.NAN);

mathModule.setConstant(null, "PI", Math.PI);
mathModule.setConstant(null, "E", Math.E);

fileClass.setConstant(null, "SEPARATOR", RubyString.fromJavaString(stringClass, File.separator));
fileClass.setConstant(null, "Separator", RubyString.fromJavaString(stringClass, File.separator));
fileClass.setConstant(null, "ALT_SEPARATOR", nilObject);
@@ -316,24 +307,18 @@ public void initializeAfterMethodsAdded() {
objectClass.setConstant(null, "RUBY_RELEASE_DATE", context.makeString(Constants.COMPILE_DATE));
objectClass.setConstant(null, "RUBY_DESCRIPTION", context.makeString(OutputStrings.getVersionString()));

if (Options.TRUFFLE_LOAD_CORE.load()) {
final String[] files = new String[]{
"jruby/truffle/core/kernel.rb"
};
rubiniusLibrary = new RubiniusLibrary(this);

for (String file : files) {
loadRubyCore(file);
}
if (Options.TRUFFLE_LOAD_CORE.load()) {
loadRubyCore("jruby/truffle/core.rb");
}

rubiniusLibrary = new RubiniusLibrary(this);
}

public void loadRubyCore(String fileName) {
final Source source;

try {
source = Source.fromReader(new InputStreamReader(context.getRuntime().getLoadService().getClassPathResource(context.getRuntime().getJRubyClassLoader(), fileName).getInputStream()), fileName);
source = Source.fromReader(new InputStreamReader(context.getRuntime().getLoadService().getClassPathResource(context.getRuntime().getJRubyClassLoader(), fileName).getInputStream()), "core:/" + fileName);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -63,21 +63,6 @@ public RubiniusLibrary(CoreLibrary coreLib) {
vmExceptionClass = new RubyClass(context, rubiniusModule, coreLib.getExceptionClass(), "VMException");
objectBoundsExceededErrorClass = new RubyClass(context, rubiniusModule, vmExceptionClass, "ObjectBoundsExceededError");
assertionErrorClass = new RubyClass(context, rubiniusModule, vmExceptionClass, "AssertionError");

final String[] files = new String[]{
"jruby/truffle/core/rubinius/api/bootstrap/channel.rb",
"jruby/truffle/core/rubinius/api/common/bytearray.rb",
"jruby/truffle/core/rubinius/api/common/channel.rb",
"jruby/truffle/core/rubinius/api/common/thread.rb",
"jruby/truffle/core/rubinius/api/common/tuple.rb",
"jruby/truffle/core/rubinius/api/common/type.rb",
"jruby/truffle/core/rubinius/kernel/common/struct.rb"
//"jruby/truffle/core/rubinius/kernel/common/time.rb"
};

for (String file : files) {
coreLib.loadRubyCore(file);
}
}

// helper function, should maybe be moved elsewhere
@@ -13,6 +13,7 @@
import java.net.*;
import java.util.Arrays;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.source.Source;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.*;
@@ -138,7 +139,15 @@ private boolean requireFile(String fileName, RubyNode currentNode) throws IOExce
* is a valid file name, as well as a valid URL. We try as a file path first.
*/

if (new File(fileName).isFile()) {
if (fileName.startsWith("core:/")) {
try {
context.getCoreLibrary().loadRubyCore(fileName.substring("core:/".length()));
return true;
} catch (Exception e) {
// TODO(CS): obviously not the best way to do this
return false;
}
} else if (new File(fileName).isFile()) {
context.loadFile(fileName, currentNode);
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(fileName));
return true;
@@ -186,10 +186,6 @@ public RubyRootNode parse(RubyNode currentNode, RubyContext context, Source sour

truffleNode = wrapper.wrap(truffleNode);

// Binding

truffleNode = SequenceNode.sequence(context, sourceSection, new SetTopLevelBindingNode(context, sourceSection), truffleNode);

// Shell result

return new RubyRootNode(context, truffleNode.getSourceSection(), environment.getFrameDescriptor(), sharedMethodInfo, truffleNode);
@@ -0,0 +1,20 @@
# 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

require_relative 'core/main'
require_relative 'core/kernel'
require_relative 'core/float'
require_relative 'core/math'

require_relative 'core/rubinius/api/bootstrap/channel'
require_relative 'core/rubinius/api/common/bytearray'
require_relative 'core/rubinius/api/common/channel'
require_relative 'core/rubinius/api/common/thread'
require_relative 'core/rubinius/api/common/tuple'
require_relative 'core/rubinius/api/common/type'
require_relative 'core/rubinius/kernel/common/struct'
@@ -0,0 +1,15 @@
# 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

class Float

NAN = 0.0 / 0.0
INFINITY = 1.0 / 0.0
EPSILON = 2.2204460492503131e-16

end

0 comments on commit a8d608a

Please sign in to comment.