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

Commits on Sep 8, 2015

  1. [Truffle] add Etc.nprocessors

    called by `rake -T`
    pitr-ch committed Sep 8, 2015
    Copy the full SHA
    c76c89d View commit details
  2. [Truffle] jruby+truffle_runner: add --executable option to run execut…

    …ables of gems
    
    `jruby+truffle run -e rspec spec/concurrent/actor_spec.rb`
    `jruby+truffle run -e rake -- -T`
    pitr-ch committed Sep 8, 2015
    4
    Copy the full SHA
    6d62f88 View commit details
3 changes: 3 additions & 0 deletions lib/ruby/truffle/truffle/etc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Etc
include Truffle::Etc
end
8 changes: 8 additions & 0 deletions tool/truffle/jruby_truffle_runner/lib/jruby+truffle_runner.rb
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ class JRubyTruffleRunner
debug: ['-d', '--debug', 'JVM remote debugging', assign_new_value, false],
require: ['-r', '--require FILE', 'Files to require, same as Ruby\'s -r', add_to_array, []],
load_path: ['-I', '--load-path LOAD_PATH', 'Paths to add to load path, same as Ruby\'s -I', add_to_array, []],
executable: ['-e', '--executable NAME', 'finds and runs an executable of a gem', assign_new_value, nil],
jexception: ['--jexception', 'print Java exceptions', assign_new_value, false]
},
clean: {
@@ -286,6 +287,12 @@ def subcommand_run(rest)
end
end

executable = if @options[:run][:executable]
executables = Dir.glob("#{@options[:global][:truffle_bundle_path]}/jruby+truffle/*/gems/*/{bin,exe}/*")
executables.find { |path| File.basename(path) == @options[:run][:executable] } or
raise "no executable with name '#{@options[:run][:executable]}' found"
end

core_load_path = "#{jruby_path}/truffle/src/main/ruby"

cmd_options = [
@@ -303,6 +310,7 @@ def subcommand_run(rest)
cmd = [(env unless env.empty?),
@options[:global][:jruby_truffle_path],
*cmd_options,
executable,
*rest
].compact

38 changes: 38 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/ext/EtcNodes.java
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.ext;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.core.CoreClass;
import org.jruby.truffle.nodes.core.CoreMethod;
import org.jruby.truffle.nodes.core.CoreMethodNode;
import org.jruby.truffle.runtime.RubyContext;

@CoreClass(name = "Truffle::Etc")
public abstract class EtcNodes {

@CoreMethod(names = "nprocessors", needsSelf = false)
public abstract static class NProcessors extends CoreMethodNode {

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

@TruffleBoundary
@Specialization
public int nprocessors() {
return Runtime.getRuntime().availableProcessors();
}

}

}
Original file line number Diff line number Diff line change
@@ -39,14 +39,14 @@
import org.jruby.truffle.nodes.ext.BigDecimalNodesFactory;
import org.jruby.truffle.nodes.ext.DigestNodesFactory;
import org.jruby.truffle.nodes.ext.ZlibNodesFactory;
import org.jruby.truffle.nodes.ext.EtcNodesFactory;
import org.jruby.truffle.nodes.objects.FreezeNode;
import org.jruby.truffle.nodes.objects.FreezeNodeGen;
import org.jruby.truffle.nodes.objects.SingletonClassNode;
import org.jruby.truffle.nodes.objects.SingletonClassNodeGen;
import org.jruby.truffle.nodes.rubinius.ByteArrayNodesFactory;
import org.jruby.truffle.nodes.rubinius.PosixNodesFactory;
import org.jruby.truffle.nodes.rubinius.RubiniusTypeNodesFactory;
import org.jruby.truffle.runtime.Options;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.BacktraceFormatter;
@@ -432,6 +432,7 @@ public CoreLibrary(RubyContext context) {
defineModule(truffleModule, "Primitive");
defineModule(truffleModule, "Digest");
defineModule(truffleModule, "Zlib");
defineModule(truffleModule, "Etc");
bigDecimalClass = defineClass(truffleModule, numericClass, "BigDecimal");
Layouts.CLASS.setInstanceFactoryUnsafe(bigDecimalClass, Layouts.BIG_DECIMAL.createBigDecimalShape(bigDecimalClass, bigDecimalClass));

@@ -551,6 +552,7 @@ private void addCoreMethods() {
coreMethodNodeManager.addCoreMethodNodes(DigestNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(BigDecimalNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(ZlibNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(EtcNodesFactory.getFactories());
coreMethodNodeManager.allMethodInstalled();

basicObjectSendMethod = Layouts.MODULE.getFields(basicObjectClass).getMethods().get("__send__");