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

Commits on Feb 13, 2015

  1. Copy the full SHA
    19a0a78 View commit details
  2. [Truffle] Move signal list definition earlier and process it later.

    * Less Rubinius code modifications.
    * No extra method defined.
    eregon committed Feb 13, 2015
    Copy the full SHA
    b2a7043 View commit details
  3. [Truffle] Implement Module#remove_const.

    * Remove Signal::SIGNAL_LIST once used.
    eregon committed Feb 13, 2015
    Copy the full SHA
    867a548 View commit details
6 changes: 0 additions & 6 deletions spec/truffle/tags/core/module/remove_const_tags.txt

This file was deleted.

1 change: 1 addition & 0 deletions tool/jt.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env ruby
# 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:
Original file line number Diff line number Diff line change
@@ -85,7 +85,6 @@ public void init() {
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, ProcNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, RangeNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, RegexpNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, SignalNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, StringNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, SymbolNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, ThreadNodesFactory.getFactories());
Original file line number Diff line number Diff line change
@@ -24,8 +24,11 @@
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.cast.BooleanCastNode;
import org.jruby.truffle.nodes.cast.BooleanCastNodeFactory;
import org.jruby.truffle.nodes.coerce.ToStrNode;
import org.jruby.truffle.nodes.coerce.ToStrNodeFactory;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.core.KernelNodes.BindingNode;
import org.jruby.truffle.nodes.core.StringNodes.StringNodesHelper;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.methods.SetMethodDeclarationContext;
import org.jruby.truffle.nodes.methods.arguments.CheckArityNode;
@@ -1405,6 +1408,57 @@ public RubyModule removeClassVariable(RubyModule module, RubySymbol name) {

}

@CoreMethod(names = "remove_const", required = 1, visibility = Visibility.PRIVATE)
public abstract static class RemoveConstNode extends CoreMethodNode {

@Child private ToStrNode toStrNode;

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

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

@Specialization
public Object removeConst(RubyModule module, RubyString name) {
notDesignedForCompilation();

return removeConstant(module, name.toString());
}

@Specialization
public Object removeConst(RubyModule module, RubySymbol name) {
notDesignedForCompilation();

return removeConstant(module, name.toString());
}

@Specialization(guards = "!isRubySymbol(arguments[1])")
public Object removeConst(VirtualFrame frame, RubyModule module, Object name) {
notDesignedForCompilation();

if (toStrNode == null) {
CompilerDirectives.transferToInterpreter();
toStrNode = insert(ToStrNodeFactory.create(getContext(), getSourceSection(), null));
}

return removeConstant(module, toStrNode.executeRubyString(frame, name).toString());
}

private Object removeConstant(RubyModule module, String name) {
RubyConstant oldConstant = module.removeConstant(this, name);
if (oldConstant == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().nameErrorConstantNotDefined(module, name, this));
} else {
return oldConstant.getValue();
}
}

}

@CoreMethod(names = "remove_method", required = 1)
public abstract static class RemoveMethodNode extends CoreMethodNode {

This file was deleted.

Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
import org.jruby.truffle.runtime.control.TruffleFatalException;
import org.jruby.truffle.runtime.hash.HashOperations;
import org.jruby.truffle.runtime.hash.KeyValue;
import org.jruby.truffle.runtime.signal.SignalOperations;
import org.jruby.truffle.translator.NodeWrapper;
import org.jruby.truffle.translator.TranslatorDriver;
import org.jruby.util.cli.Options;
@@ -324,6 +325,7 @@ public void initialize() {
initializeGlobalVariables();
initializeConstants();
initializeEncodingConstants();
initializeSignalConstants();

// Common symbols
eachSymbol = getContext().getSymbolTable().getSymbol("each");
@@ -388,6 +390,20 @@ private void initializeConstants() {
fileClass.setConstant(null, "FNM_SYSCASE", 0);
}

private void initializeSignalConstants() {
RubyNode.notDesignedForCompilation();

Object[] signals = new Object[SignalOperations.SIGNALS_LIST.size()];

int i = 0;
for (Map.Entry<String, Integer> signal : SignalOperations.SIGNALS_LIST.entrySet()) {
RubyString signalName = context.makeString(signal.getKey());
signals[i++] = RubyArray.fromObjects(arrayClass, signalName, signal.getValue());
}

signalModule.setConstant(null, "SIGNAL_LIST", new RubyArray(arrayClass, signals, signals.length));
}

private RubyClass defineClass(String name) {
return defineClass(objectClass, name, objectClass.getAllocator());
}
@@ -713,6 +729,11 @@ public RubyException nameError(String message, Node currentNode) {
return new RubyException(nameErrorClass, context.makeString(message), RubyCallStack.getBacktrace(currentNode));
}

public RubyException nameErrorConstantNotDefined(RubyModule module, String name, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return nameError(String.format("constant %s::%s not defined", module.getName(), name), currentNode);
}

public RubyException nameErrorUninitializedConstant(RubyModule module, String name, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return nameError(String.format("uninitialized constant %s::%s", module.getName(), name), currentNode);
Original file line number Diff line number Diff line change
@@ -201,12 +201,13 @@ public void setConstant(RubyNode currentNode, String name, Object value) {
}

@TruffleBoundary
public void removeConstant(RubyNode currentNode, String data) {
public RubyConstant removeConstant(RubyNode currentNode, String name) {
RubyNode.notDesignedForCompilation();

checkFrozen(currentNode);
getConstants().remove(data);
RubyConstant oldConstant = getConstants().remove(name);
newLexicalVersion();
return oldConstant;
}

@TruffleBoundary
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.runtime.signal;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -23,7 +24,7 @@ public class SignalOperations {

private static final ConcurrentMap<Signal, SignalHandler> ORIGINAL_HANDLERS = new ConcurrentHashMap<Signal, SignalHandler>();

public static final Map<String, Integer> SIGNALS_LIST = RubySignal.list();
public static final Map<String, Integer> SIGNALS_LIST = Collections.unmodifiableMap(RubySignal.list());

public static final SignalHandler IGNORE_HANDLER = new SignalHandler() {
@Override
1 change: 1 addition & 0 deletions truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@
require_relative 'core/math'
require_relative 'core/method'
require_relative 'core/module'
require_relative 'core/signal'
require_relative 'core/string'
require_relative 'core/thread'
require_relative 'core/unbound_method'
8 changes: 0 additions & 8 deletions truffle/src/main/ruby/core/rubinius/common/signal.rb
Original file line number Diff line number Diff line change
@@ -24,8 +24,6 @@
# 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.

# Only part of Rubinius' signal.rb

module Signal
Names = {
"EXIT" => 0
@@ -101,10 +99,4 @@ def self.list
Names.dup
end

# Added for Truffle
setup_signal_list do |name, number|
Names[name] = number
Numbers[number] = name
end

end
18 changes: 18 additions & 0 deletions truffle/src/main/ruby/core/signal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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

module Signal

# Fill the Names and Numbers Hash.
SIGNAL_LIST.each do |name, number|
Names[name] = number
Numbers[number] = name
end
remove_const :SIGNAL_LIST

end