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

Commits on Apr 14, 2015

  1. Copy the full SHA
    11ea295 View commit details
  2. [Truffle] When randomising array storage strategy, we already checked…

    … for empty before canonicalising.
    chrisseaton committed Apr 14, 2015
    Copy the full SHA
    0af90ff View commit details
  3. Remove random error log.

    chrisseaton committed Apr 14, 2015
    Copy the full SHA
    40e8c62 View commit details
384 changes: 0 additions & 384 deletions core/hs_err_pid20245.log

This file was deleted.

Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.List;

/**
* Rubinius primitives associated with the VM.
@@ -475,4 +477,56 @@ public boolean watchSignal(RubyString signalName, RubyProc proc) {

}

@RubiniusPrimitive(name = "vm_get_config_item", needsSelf = false)
public abstract static class VMGetConfigItemPrimitiveNode extends RubiniusPrimitiveNode {

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

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

@CompilerDirectives.TruffleBoundary
@Specialization
public Object get(RubyString key) {
final Object value = getContext().getRubiniusConfiguration().get(key.toString());

if (value == null) {
return nil();
} else {
return value;
}
}

}

@RubiniusPrimitive(name = "vm_get_config_section", needsSelf = false)
public abstract static class VMGetConfigSectionPrimitiveNode extends RubiniusPrimitiveNode {

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

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

@CompilerDirectives.TruffleBoundary
@Specialization
public RubyArray getSection(RubyString section) {
final List<RubyArray> sectionKeyValues = new ArrayList<>();

for (String key : getContext().getRubiniusConfiguration().getSection(section.toString())) {
sectionKeyValues.add(RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(),
getContext().makeString(key),
getContext().getRubiniusConfiguration().get(key)));
}

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), sectionKeyValues.toArray());
}

}

}
Original file line number Diff line number Diff line change
@@ -43,7 +43,9 @@

import java.io.File;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;

@@ -70,6 +72,7 @@ public class RubyContext extends ExecutionContext {
private final CompilerOptions compilerOptions;
private final RubiniusPrimitiveManager rubiniusPrimitiveManager;
private final InstrumentationServerManager instrumentationServerManager;
private final RubiniusConfiguration rubiniusConfiguration = new RubiniusConfiguration();

private final AtomicLong nextObjectID = new AtomicLong(ObjectIDOperations.FIRST_OBJECT_ID);

@@ -513,4 +516,7 @@ public RubiniusPrimitiveManager getRubiniusPrimitiveManager() {
return rubiniusPrimitiveManager;
}

public RubiniusConfiguration getRubiniusConfiguration() {
return rubiniusConfiguration;
}
}
Original file line number Diff line number Diff line change
@@ -494,7 +494,6 @@ private RubyModule defineModule(RubyModule lexicalParent, String name) {

public void initializeAfterMethodsAdded() {
initializeRubiniusFFI();
initializeRubiniusConfig();

// ENV is supposed to be an object that actually updates the environment, and sees any updates

@@ -544,42 +543,6 @@ private void initializeRubiniusFFI() {
rubiniusFFIModule.setConstant(null, "TYPE_VARARGS", NativeFunctionPrimitiveNodes.TYPE_VARARGS);
}

private void initializeRubiniusConfig() {
final List<KeyValue> config = new ArrayList<>();

config.add(new KeyValue(context.makeString("hash.hamt"), false));

config.add(new KeyValue(context.makeString("rbx.platform.file.S_IRUSR"), FileStat.S_IRUSR));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IWUSR"), FileStat.S_IWUSR));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IXUSR"), FileStat.S_IXUSR));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IRGRP"), FileStat.S_IRGRP));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IWGRP"), FileStat.S_IWGRP));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IXGRP"), FileStat.S_IXGRP));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IROTH"), FileStat.S_IROTH));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IWOTH"), FileStat.S_IWOTH));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IXOTH"), FileStat.S_IXOTH));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFMT"), FileStat.S_IFMT));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFIFO"), FileStat.S_IFIFO));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFCHR"), FileStat.S_IFCHR));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFDIR"), FileStat.S_IFDIR));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFBLK"), FileStat.S_IFBLK));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFREG"), FileStat.S_IFREG));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFLNK"), FileStat.S_IFLNK));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_IFSOCK"), FileStat.S_IFSOCK));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_ISUID"), FileStat.S_ISUID));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_ISGID"), FileStat.S_ISGID));
config.add(new KeyValue(context.makeString("rbx.platform.file.S_ISVTX"), FileStat.S_ISVTX));

/*
* There is also rbx.platform.file.S_IFWHT, which I think is from FreeBSD. We don't support
* this as it isn't part of jnr-posix.
*/

final RubyHash configHash = HashOperations.verySlowFromEntries(getHashClass(), config, false);

rubiniusModule.setConstant(null, "Config", configHash);
}

public void loadRubyCore(String fileName) {
loadRubyCore(fileName, "core:/");
}
Original file line number Diff line number Diff line change
@@ -252,10 +252,6 @@ private static Object randomizeStorageStrategy(Object store, int size) {
// Then promote it at random

if (canonicalStore instanceof int[]) {
if (((int[]) canonicalStore).length == 0 && random.nextBoolean()) {
return null;
}

switch (random.nextInt(3)) {
case 0:
return boxedStore;
@@ -267,30 +263,18 @@ private static Object randomizeStorageStrategy(Object store, int size) {
throw new IllegalStateException();
}
} else if (canonicalStore instanceof long[]) {
if (((long[]) canonicalStore).length == 0 && random.nextBoolean()) {
return null;
}

if (random.nextBoolean()) {
return boxedStore;
} else {
return canonicalStore;
}
} else if (canonicalStore instanceof double[]) {
if (((double[]) canonicalStore).length == 0 && random.nextBoolean()) {
return null;
}

if (random.nextBoolean()) {
return boxedStore;
} else {
return canonicalStore;
}
} else if (canonicalStore instanceof Object[]) {
if (((Object[]) canonicalStore).length == 0 && random.nextBoolean()) {
return null;
}

return canonicalStore;
} else {
throw new UnsupportedOperationException();
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.runtime.subsystems;

import jnr.posix.FileStat;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class RubiniusConfiguration {

private final Map<String, Object> configuration = new HashMap<>();

public RubiniusConfiguration() {
config("hash.hamt", false);

config("rbx.platform.file.S_IRUSR", FileStat.S_IRUSR);
config("rbx.platform.file.S_IWUSR", FileStat.S_IWUSR);
config("rbx.platform.file.S_IXUSR", FileStat.S_IXUSR);
config("rbx.platform.file.S_IRGRP", FileStat.S_IRGRP);
config("rbx.platform.file.S_IWGRP", FileStat.S_IWGRP);
config("rbx.platform.file.S_IXGRP", FileStat.S_IXGRP);
config("rbx.platform.file.S_IROTH", FileStat.S_IROTH);
config("rbx.platform.file.S_IWOTH", FileStat.S_IWOTH);
config("rbx.platform.file.S_IXOTH", FileStat.S_IXOTH);
config("rbx.platform.file.S_IFMT", FileStat.S_IFMT);
config("rbx.platform.file.S_IFIFO", FileStat.S_IFIFO);
config("rbx.platform.file.S_IFCHR", FileStat.S_IFCHR);
config("rbx.platform.file.S_IFDIR", FileStat.S_IFDIR);
config("rbx.platform.file.S_IFBLK", FileStat.S_IFBLK);
config("rbx.platform.file.S_IFREG", FileStat.S_IFREG);
config("rbx.platform.file.S_IFLNK", FileStat.S_IFLNK);
config("rbx.platform.file.S_IFSOCK", FileStat.S_IFSOCK);
config("rbx.platform.file.S_ISUID", FileStat.S_ISUID);
config("rbx.platform.file.S_ISGID", FileStat.S_ISGID);
config("rbx.platform.file.S_ISVTX", FileStat.S_ISVTX);
}

private void config(String key, Object value) {
configuration.put(key, value);
}

public Object get(String key) {
return configuration.get(key);
}

public Collection<String> getSection(String section) {
final Collection<String> sectionKeys = new ArrayList<>();

for (String key : configuration.keySet()) {
if (key.startsWith(section)) {
sectionKeys.add(key);
}
}

return sectionKeys;
}

}
2 changes: 1 addition & 1 deletion truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
#require_relative 'core/rubinius/bootstrap/class'
#require_relative 'core/rubinius/bootstrap/compact_lookup_table'
#require_relative 'core/rubinius/bootstrap/compiled_code'
#require_relative 'core/rubinius/bootstrap/configuration'
require_relative 'core/rubinius/bootstrap/configuration'
#require_relative 'core/rubinius/bootstrap/constant_cache'
#require_relative 'core/rubinius/bootstrap/constant_scope'
#require_relative 'core/rubinius/bootstrap/constant_table'
62 changes: 62 additions & 0 deletions truffle/src/main/ruby/core/rubinius/bootstrap/configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (c) 2007-2014, Evan Phoenix and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Rubinius nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

module Rubinius
class Configuration
def initialize
end

private :initialize

def get_variable(name)
Rubinius.primitive :vm_get_config_item
raise PrimitiveFailure, "Rubinius::Configuration#get_variable primitive failed"
end

def get_section(section)
Rubinius.primitive :vm_get_config_section
raise PrimitiveFailure, "Rubinius::Configuration#get_section primitive failed"
end

def section(section)
ary = get_section(section)
i = 0
while i < ary.size
tup = ary[i]
yield tup[0], tup[1]
i += 1
end
end

def [](name)
get_variable(name)
end

alias_method :get, :[]
end

Config = Configuration.new
end
7 changes: 3 additions & 4 deletions truffle/src/main/ruby/core/rubinius/platform/ffi.rb
Original file line number Diff line number Diff line change
@@ -195,10 +195,9 @@ def errno

# Load all the platform dependent types

# MODIFIED
#Rubinius::Config.section("rbx.platform.typedef.") do |key, value|
# add_typedef(find_type(value.to_sym), key.substring(21, key.length).to_sym)
#end
Rubinius::Config.section("rbx.platform.typedef.") do |key, value|
add_typedef(find_type(value.to_sym), key.substring(21, key.length).to_sym)
end

# It's a class to be compat with the ffi gem.
class Type