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

Commits on Jan 21, 2015

  1. [Truffle] Make a clearer load order.

    * Define eql? in bootstrap since we need it for Hash literals.
    * Our code should have the ability to override the rest and run last.
    eregon committed Jan 21, 2015
    Copy the full SHA
    4cf525a View commit details
  2. Copy the full SHA
    0b5c39f View commit details
  3. Copy the full SHA
    4a0e292 View commit details
  4. 3
    Copy the full SHA
    b2c81fc View commit details
  5. Copy the full SHA
    cadad84 View commit details
  6. Copy the full SHA
    ec07169 View commit details
  7. [Truffle] Sort our files to load in alphabetical order.

    * Separate method definition and constant definition
      (with trivial values) from the rest.
    eregon committed Jan 21, 2015
    Copy the full SHA
    305b86c View commit details
  8. Copy the full SHA
    0b2ea13 View commit details
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;

import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBignum;
@@ -575,7 +576,7 @@ public Object leftShift(RubyBignum a, int b) {

}

@CoreMethod(names = "abs")
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends BignumCoreMethodNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
@@ -1462,7 +1463,7 @@ public Object rightShiftFallback(VirtualFrame frame, Object a, Object b) {

}

@CoreMethod(names = "abs")
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends CoreMethodNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.DebugOperations;
@@ -559,7 +560,7 @@ public boolean less(@SuppressWarnings("unused") double a, RubyBasicObject other)
}
}

@CoreMethod(names = "abs")
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends CoreMethodNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -736,7 +736,7 @@ public RubyString inspectPackedArray(VirtualFrame frame, RubyHash hash) {

}

@CoreMethod(names = { "has_key?", "key?" }, required = 1)
@CoreMethod(names = { "has_key?", "key?", "include?", "member?" }, required = 1)
public abstract static class KeyNode extends HashCoreMethodNode {

@Child private CallDispatchHeadNode eqlNode;
12 changes: 9 additions & 3 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -951,19 +951,25 @@ public Object initializeDup(VirtualFrame frame, RubyBasicObject self, RubyBasicO
@CoreMethod(names = "instance_of?", required = 1)
public abstract static class InstanceOfNode extends CoreMethodNode {

@Child private ClassNode classNode;

public InstanceOfNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
classNode = ClassNodeFactory.create(context, sourceSection, null);
}

public InstanceOfNode(InstanceOfNode prev) {
super(prev);
classNode = prev.classNode;
}

@TruffleBoundary
@Specialization
public boolean instanceOf(Object self, RubyClass rubyClass) {
// TODO(CS): fast path
return getContext().getCoreLibrary().getLogicalClass(self) == rubyClass;
notDesignedForCompilation();

// TODO(CS): faster path for this?
return classNode.executeGetClass(self) == rubyClass;
}

}
@@ -1171,8 +1177,8 @@ public boolean isA(RubyBasicObject self, RubyNilClass nil) {
@TruffleBoundary
@Specialization
public boolean isA(Object self, RubyClass rubyClass) {
// TODO(CS): fast path
notDesignedForCompilation();
// TODO(CS): fast path
return ModuleOperations.assignableTo(getContext().getCoreLibrary().getMetaClass(self), rubyClass);
}

70 changes: 40 additions & 30 deletions core/src/main/ruby/jruby/truffle/core.rb
Original file line number Diff line number Diff line change
@@ -6,59 +6,69 @@
# 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/config'
require_relative 'core/float'
require_relative 'core/math'
require_relative 'core/thread'
require_relative 'core/module'
require_relative 'core/hash'
require_relative 'core/fixnum'
require_relative 'core/method'

# Load Rubinius API
require_relative 'core/rubinius/api/compat/type'

require_relative 'core/rubinius/api/kernel/common/thread'
require_relative 'core/rubinius/api/kernel/common/type'

# Patch rubinius-core-api to make it work for us
require_relative 'core/rubinius/api/shims/rubinius'
require_relative 'core/rubinius/api/shims/lookuptable'
require_relative 'core/rubinius/api/shims/thread'
require_relative 'core/rubinius/api/shims/enumerator'
require_relative 'core/rubinius/api/shims/undefined'
require_relative 'core/rubinius/api/shims/metrics'

# Load bootstrap (ordered according to Rubinius' load_order.txt)
require_relative 'core/rubinius/kernel/bootstrap/basic_object'
require_relative 'core/rubinius/kernel/bootstrap/time'
require_relative 'core/rubinius/kernel/bootstrap/type'
require_relative 'core/rubinius/kernel/bootstrap/string'

require_relative 'core/rubinius/kernel/bootstrap/false'
require_relative 'core/rubinius/kernel/bootstrap/gc'
require_relative 'core/rubinius/kernel/bootstrap/kernel'
require_relative 'core/rubinius/kernel/bootstrap/nil'
require_relative 'core/rubinius/kernel/bootstrap/string'
require_relative 'core/rubinius/kernel/bootstrap/time'
require_relative 'core/rubinius/kernel/bootstrap/true'
require_relative 'core/rubinius/kernel/bootstrap/false'
require_relative 'core/rubinius/kernel/bootstrap/type'

require_relative 'core/rubinius/kernel/common/kernel'
require_relative 'core/rubinius/kernel/common/array'
require_relative 'core/rubinius/kernel/common/rational'
require_relative 'core/rubinius/kernel/common/struct'
# Load common (ordered according to Rubinius' load_order.txt)
require_relative 'core/rubinius/kernel/common/enumerable'
require_relative 'core/rubinius/kernel/common/undefined'
require_relative 'core/rubinius/kernel/common/time'
require_relative 'core/rubinius/kernel/common/type'
require_relative 'core/rubinius/kernel/common/array'
require_relative 'core/rubinius/kernel/common/kernel'
require_relative 'core/rubinius/kernel/common/numeric'
require_relative 'core/rubinius/kernel/common/integer'
require_relative 'core/rubinius/kernel/common/fixnum'

require_relative 'core/rubinius/kernel/common/false'
require_relative 'core/rubinius/kernel/common/float'
require_relative 'core/rubinius/kernel/common/numeric'
require_relative 'core/rubinius/kernel/common/string'
require_relative 'core/rubinius/kernel/common/gc'
require_relative 'core/rubinius/kernel/common/object_space'
require_relative 'core/rubinius/kernel/common/nil'
require_relative 'core/rubinius/kernel/common/immediate'
require_relative 'core/rubinius/kernel/common/main'
require_relative 'core/rubinius/kernel/common/nil'
require_relative 'core/rubinius/kernel/common/object_space'
require_relative 'core/rubinius/kernel/common/string'
require_relative 'core/rubinius/kernel/common/struct'
require_relative 'core/rubinius/kernel/common/regexp'
require_relative 'core/rubinius/kernel/common/time'
require_relative 'core/rubinius/kernel/common/true'
require_relative 'core/rubinius/kernel/common/false'

require_relative 'core/rubinius/kernel/common/rational'
require_relative 'core/rubinius/kernel/common/complex'
require_relative 'core/rubinius/kernel/common/fixnum'
require_relative 'core/rubinius/kernel/common/regexp'
require_relative 'core/rubinius/kernel/common/main'
require_relative 'core/rubinius/kernel/common/gc'

# Load JRuby+Truffle classes
require_relative 'core/fixnum'
require_relative 'core/float'
require_relative 'core/hash'
require_relative 'core/kernel'
require_relative 'core/math'
require_relative 'core/method'
require_relative 'core/module'
require_relative 'core/thread'

require_relative 'core/shims'

# Start running Ruby code outside classes
require_relative 'core/config'
require_relative 'core/main'
14 changes: 0 additions & 14 deletions core/src/main/ruby/jruby/truffle/core/kernel.rb
Original file line number Diff line number Diff line change
@@ -41,22 +41,8 @@ def printf(*args)
print sprintf(*args)
end

# from BasicObject
alias_method :eql?, :equal?
alias_method :send, :__send__

alias_method :trust, :untaint
alias_method :untrust, :taint
alias_method :untrusted?, :tainted?

end

# Here temporarily

class Hash

def include?(key)
keys.include? key
end

end
79 changes: 0 additions & 79 deletions core/src/main/ruby/jruby/truffle/core/main.rb
Original file line number Diff line number Diff line change
@@ -9,82 +9,3 @@
Signal.trap("INT") do
raise Interrupt
end


module STDIN
def self.external_encoding
@external || Encoding.default_external
end

def self.internal_encoding
@internal
end

def self.set_encoding(external, internal)
@external = external
@internal = internal
end
end

module STDOUT
def self.puts(*values)
Kernel.send(:puts, *values)
end

def self.print(*values)
Kernel.send(:print, *values)
end

def self.printf(*values)
Kernel.send(:printf, *values)
end

def self.write(value)
print value
end

def self.flush
Truffle::Debug.flush_stdout
end

def self.sync
false
end

def self.sync=(value)
end

def self.external_encoding
@external
end

def self.internal_encoding
@internal
end

def self.set_encoding(external, internal)
@external = external
@internal = internal
end
end

$stdout = STDOUT

module STDERR
def self.puts(*values)
Kernel.send(:puts, *values)
end

def self.external_encoding
@external
end

def self.internal_encoding
@internal
end

def self.set_encoding(external, internal)
@external = external
@internal = internal
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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

# 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.

# Only part of Rubinius' kernel.rb

module Kernel
alias_method :eql?, :equal?

# Truffle: no extra indirection for Kernel#send.
alias_method :send, :__send__ # from BasicObject
end
Original file line number Diff line number Diff line change
@@ -28,6 +28,11 @@

class Numeric

def eql?(other)
return false unless other.instance_of? self.class
self == other
end

#--
# We deviate from MRI behavior here because we ensure that Fixnum op Bignum
# => Bignum (possibly normalized to Fixnum)
@@ -38,6 +43,10 @@ class Numeric
# b.coerce a => [Bignum, Bignum]
#++

def abs
self < 0 ? -self : self
end

def coerce(other)
if other.instance_of? self.class
return [other, self]
@@ -97,8 +106,10 @@ def fdiv(other)
self.to_f / other
end

alias_method :magnitude, :abs

def real?
true
end

end
Loading