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

Commits on May 20, 2015

  1. Copy the full SHA
    f981f17 View commit details
  2. Copy the full SHA
    fd8d701 View commit details
  3. Copy the full SHA
    bc9dfb7 View commit details
  4. [Truffle] Create numeric values for all numbers of the configuration.

    * Update Linux config.
    eregon committed May 20, 2015
    Copy the full SHA
    40a4f8a View commit details
  5. Copy the full SHA
    4b2945c View commit details
21 changes: 14 additions & 7 deletions tool/truffle/translate_rubinius_config.rb
Original file line number Diff line number Diff line change
@@ -11,14 +11,21 @@
puts " // Generated from tool/truffle/translate_rubinius_config.rb < ../rubinius/runtime/platform.conf"

ARGF.each do |line|
match = line.match(/(?'var'rbx(\.\w+)*) = (?'value'.+)/)
next unless match
var = match[:var]
value = match[:value]
if /.*\.(offset|size|sizeof)$/ =~ var
code = value.to_s
next unless /^(?<var>rbx(\.\w+)*) = (?<value>.+)$/ =~ line
code = case value
when /^-?\d+$/
case Integer(value)
when (-2**31...2**31)
value
when (-2**63...2**63)
"#{value}L"
else
"newBignum(context, \"#{value}\")"
end
when "true"
value
else
code = "context.makeString(\"#{value}\")"
"context.makeString(\"#{value}\")"
end
puts " configuration.config(\"#{var}\", #{code});"
end
Original file line number Diff line number Diff line change
@@ -41,11 +41,15 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import jnr.constants.platform.Sysconf;
import jnr.posix.Times;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.BasicObjectNodes;
import org.jruby.truffle.nodes.core.BasicObjectNodesFactory;
import org.jruby.truffle.nodes.core.BignumNodes;
import org.jruby.truffle.nodes.core.KernelNodes;
import org.jruby.truffle.nodes.core.KernelNodesFactory;
import org.jruby.truffle.nodes.defined.DefinedWrapperNode;
@@ -62,6 +66,7 @@
import org.jruby.truffle.runtime.signal.SignalOperations;
import org.jruby.truffle.runtime.subsystems.ThreadManager;
import org.jruby.util.io.PosixShim;

import sun.misc.Signal;

import java.lang.management.ManagementFactory;
@@ -494,9 +499,18 @@ public RubyArray getSection(RubyString section) {
final List<RubyArray> sectionKeyValues = new ArrayList<>();

for (String key : getContext().getRubiniusConfiguration().getSection(section.toString())) {
Object value = getContext().getRubiniusConfiguration().get(key);
final String stringValue;
if (RubyGuards.isRubyBignum(value)) {
stringValue = BignumNodes.getBigIntegerValue((RubyBasicObject) value).toString();
} else {
// This toString() is fine as we only have boolean, int, long and RubyString in config.
stringValue = value.toString();
}

sectionKeyValues.add(RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(),
getContext().makeString(key),
getContext().getRubiniusConfiguration().get(key)));
getContext().makeString(stringValue)));
}

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), sectionKeyValues.toArray());
Original file line number Diff line number Diff line change
@@ -40,8 +40,12 @@
import jnr.constants.platform.Fcntl;
import jnr.constants.platform.OpenFlags;
import jnr.posix.FileStat;

import org.jruby.truffle.nodes.core.BignumNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;

import java.math.BigInteger;
import java.util.Arrays;

public abstract class DefaultRubiniusConfiguration {
@@ -75,15 +79,15 @@ public static void load(RubiniusConfiguration configuration, RubyContext context
configuration.config("rbx.platform.file.S_ISVTX", FileStat.S_ISVTX);

for (Fcntl fcntl : Fcntl.values()) {
if (fcntl.name().startsWith("F_")) {
if (fcntl.defined() && fcntl.name().startsWith("F_")) {
configuration.config("rbx.platform.fcntl." + fcntl.name(), fcntl.intValue());
}
}

configuration.config("rbx.platform.fcntl.FD_CLOEXEC", 1); // TODO BJF 15-May-2015 Get from JNR constants or stdlib FFI

for (OpenFlags openFlag : OpenFlags.values()) {
if (openFlag.name().startsWith("O_")) {
if (openFlag.defined() && openFlag.name().startsWith("O_")) {
configuration.config("rbx.platform.file." + openFlag.name(), openFlag.intValue());
}
}
@@ -156,4 +160,8 @@ public static void load(RubiniusConfiguration configuration, RubyContext context
configuration.config("rbx.platform.socket.SOCK_STREAM", context.makeString("1"));
}

protected static RubyBasicObject newBignum(RubyContext context, String value) {
return BignumNodes.createRubyBignum(context.getCoreLibrary().getBignumClass(), new BigInteger(value));
}

}
Loading