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

Commits on May 20, 2016

  1. Copy the full SHA
    1888840 View commit details
  2. Copy the full SHA
    cd5d534 View commit details
  3. Copy the full SHA
    4b7f998 View commit details
  4. Copy the full SHA
    6a91704 View commit details
  5. Copy the full SHA
    b316ea6 View commit details
  6. Copy the full SHA
    82723d6 View commit details
  7. [Truffle] Junk code.

    chrisseaton committed May 20, 2016
    Copy the full SHA
    6513ba1 View commit details
  8. Copy the full SHA
    dff821d View commit details
13 changes: 4 additions & 9 deletions truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -31,9 +31,7 @@
Truffle::Boot.require_core 'core/false'
Truffle::Boot.require_core 'core/gc'
Truffle::Boot.require_core 'core/bootstrap/io'
Truffle::Boot.require_core 'core/bootstrap/kernel'
Truffle::Boot.require_core 'core/nil'
Truffle::Boot.require_core 'core/bootstrap/process'
Truffle::Boot.require_core 'core/bootstrap/regexp'
Truffle::Boot.require_core 'core/bootstrap/rubinius'
Truffle::Boot.require_core 'core/bootstrap/stat'
@@ -50,8 +48,8 @@
Truffle::Boot.require_core 'core/ffi'
Truffle::Boot.require_core 'core/pointer_accessors'
Truffle::Boot.require_core 'core/pointer'
Truffle::Boot.require_core 'core/platform/file'
Truffle::Boot.require_core 'core/platform/struct'
Truffle::Boot.require_core 'core/ffi_file'
Truffle::Boot.require_core 'core/ffi_struct'

# Load common

@@ -75,7 +73,7 @@
Truffle::Boot.require_core 'core/numeric'
Truffle::Boot.require_core 'core/ctype'
Truffle::Boot.require_core 'core/integer'
Truffle::Boot.require_core 'core/common/fixnum'
Truffle::Boot.require_core 'core/fixnum'
Truffle::Boot.require_core 'core/lru_cache'
Truffle::Boot.require_core 'core/encoding'
Truffle::Boot.require_core 'core/env'
@@ -93,7 +91,7 @@
Truffle::Boot.require_core 'core/range_mirror'
Truffle::Boot.require_core 'core/range'
Truffle::Boot.require_core 'core/common/struct'
Truffle::Boot.require_core 'core/common/process'
Truffle::Boot.require_core 'core/process'
Truffle::Boot.require_core 'core/process_mirror'
Truffle::Boot.require_core 'core/random'
Truffle::Boot.require_core 'core/common/regexp'
@@ -114,13 +112,10 @@
Truffle::Boot.require_core 'core/delta/file'
Truffle::Boot.require_core 'core/delta/module'
Truffle::Boot.require_core 'core/class'
Truffle::Boot.require_core 'core/delta/kernel'
Truffle::Boot.require_core 'core/delta/struct'

# Load JRuby+Truffle classes

Truffle::Boot.require_core 'core/binding'
Truffle::Boot.require_core 'core/fixnum'
Truffle::Boot.require_core 'core/kernel'
Truffle::Boot.require_core 'core/math'
Truffle::Boot.require_core 'core/method'
45 changes: 0 additions & 45 deletions truffle/src/main/ruby/core/bootstrap/kernel.rb

This file was deleted.

42 changes: 0 additions & 42 deletions truffle/src/main/ruby/core/bootstrap/process.rb

This file was deleted.

92 changes: 0 additions & 92 deletions truffle/src/main/ruby/core/common/fixnum.rb

This file was deleted.

44 changes: 42 additions & 2 deletions truffle/src/main/ruby/core/common/kernel.rb
Original file line number Diff line number Diff line change
@@ -1012,8 +1012,48 @@ def warning(message)
$stderr.puts message if $VERBOSE
end
module_function :warning
end

module Kernel
def raise(exc=undefined, msg=undefined, ctx=nil)
skip = false
if undefined.equal? exc
exc = $!
if exc
skip = true
else
exc = RuntimeError.new("No current exception")
end
elsif exc.respond_to? :exception
if undefined.equal? msg
exc = exc.exception
else
exc = exc.exception msg
end
raise ::TypeError, 'exception class/object expected' unless exc.kind_of?(::Exception)
elsif exc.kind_of? String
exc = ::RuntimeError.exception exc
else
raise ::TypeError, 'exception class/object expected'
end

unless skip
exc.set_context ctx if ctx
exc.capture_backtrace!(2) unless exc.backtrace?
end

if $DEBUG and $VERBOSE != nil
if bt = exc.backtrace and bt[1]
pos = bt[1]
else
pos = Rubinius::VM.backtrace(1)[0].position
end

STDERR.puts "Exception: `#{exc.class}' #{pos} - #{exc.message}"
end

Rubinius.raise_exception exc
end
module_function :raise

alias_method :fail, :raise
module_function :fail
end
103 changes: 103 additions & 0 deletions truffle/src/main/ruby/core/common/struct.rb
Original file line number Diff line number Diff line change
@@ -279,4 +279,107 @@ def to_a
def values_at(*args)
to_a.values_at(*args)
end

Struct.new 'Tms', :utime, :stime, :cutime, :cstime, :tutime, :tstime

class Tms
def initialize(utime=nil, stime=nil, cutime=nil, cstime=nil,
tutime=nil, tstime=nil)
@utime = utime
@stime = stime
@cutime = cutime
@cstime = cstime
@tutime = tutime
@tstime = tstime
end
end

def self._specialize(attrs)
# Because people are crazy, they subclass Struct directly, ie.
# class Craptastic < Struct
#
# NOT
#
# class Fine < Struct.new(:x, :y)
#
# When they do this craptastic act, they'll sometimes define their
# own #initialize and super into Struct#initialize.
#
# When they do this and then do Craptastic.new(:x, :y), this code
# will accidentally shadow their #initialize. So for now, only run
# the specialize if we're trying new Struct's directly from Struct itself,
# not a craptastic Struct subclass.

return unless superclass.equal? Struct

# To allow for optimization, we generate code with normal ivar
# references for all attributes whose names can be written as
# tIVAR tokens. For example, of the following struct attributes
#
# Struct.new(:a, :@b, :c?, :'d-e')
#
# only the first, :a, can be written as a valid tIVAR token:
#
# * :a can be written as @a
# * :@b becomes @@b and would be interpreted as a tCVAR
# * :c? becomes @c? and be interpreted as the beginning of
# a ternary expression
# * :'d-e' becomes @d-e and would be interpreted as a method
# invocation
#
# Attribute names that cannot be written as tIVAR tokens will
# fall back to using #instance_variable_(get|set).

args, assigns, hashes, vars = [], [], [], []

attrs.each_with_index do |name, i|
name = "@#{name}"

if name =~ /^@[a-z_]\w*$/i
assigns << "#{name} = a#{i}"
vars << name
else
assigns << "instance_variable_set(:#{name.inspect}, a#{i})"
vars << "instance_variable_get(:#{name.inspect})"
end

args << "a#{i} = nil"
hashes << "#{vars[-1]}.hash"
end

code = <<-CODE
def initialize(#{args.join(", ")})
#{assigns.join(';')}
self
end
def hash
hash = #{hashes.size}
return hash if Thread.detect_outermost_recursion(self) do
hash = hash ^ #{hashes.join(' ^ ')}
end
hash
end
def to_a
[#{vars.join(', ')}]
end
def length
#{vars.size}
end
CODE

begin
mod = Module.new do
module_eval code
end
include mod
rescue SyntaxError
# SyntaxError means that something is wrong with the
# specialization code. Just eat the error and don't specialize.
end
end
end
81 changes: 0 additions & 81 deletions truffle/src/main/ruby/core/delta/kernel.rb

This file was deleted.

130 changes: 0 additions & 130 deletions truffle/src/main/ruby/core/delta/struct.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
64 changes: 60 additions & 4 deletions truffle/src/main/ruby/core/fixnum.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. This
# Copyright (c) 2014, 2016 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
# Copyright (c) 2007-2015, Evan Phoenix and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,63 @@
# 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.

class Fixnum
##
#--
# NOTE do not define to_sym or id2name. It's been deprecated for 5 years and
# we've decided to remove it.
#++

class Fixnum < Integer

MIN = -9223372036854775808
MAX = 9223372036854775807

def self.induced_from(obj)
case obj
when Fixnum
return obj
when Float, Bignum
value = obj.to_i
if value.is_a? Bignum
raise RangeError, "Object is out of range for a Fixnum"
else
return value
end
else
value = Rubinius::Type.coerce_to(obj, Integer, :to_int)
return self.induced_from(value)
end
end

#--
# see README-DEVELOPERS regarding safe math compiler plugin
#++

alias_method :modulo, :%

def fdiv(n)
if n.kind_of?(Integer)
to_f / n
else
redo_coerced :fdiv, n
end
end

def imaginary
0
end

def **(o)
Rubinius.primitive :fixnum_pow

if o.is_a?(Float) && self < 0 && o != o.round
return Complex.new(self, 0) ** o
elsif o.is_a?(Integer) && o < 0
return Rational.new(self, 1) ** o
end

redo_coerced :**, o
end

# Have a copy in Fixnum of the Integer version, as MRI does
public :even?, :odd?, :succ
44 changes: 44 additions & 0 deletions truffle/src/main/ruby/core/pre.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,50 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# Copyright (c) 2007-2015 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 Kernel

alias_method :eql?, :equal?

# Truffle: no extra indirection for Kernel#send.
alias_method :send, :__send__ # from BasicObject

def extend(mod)
Rubinius::Type.object_singleton_class(self).include(mod)
self
end

def inspect
"#<#{self.class.name}"
end

end

class Symbol

def to_sym
Original file line number Diff line number Diff line change
@@ -74,6 +74,21 @@ class Rlimit < FFI::Struct
config "rbx.platform.rlimit", :rlim_cur, :rlim_max
end

def self.wait_pid_prim(pid, no_hang)
Rubinius.primitive :vm_wait_pid
raise PrimitiveFailure, "Process.wait_pid primitive failed"
end

def self.time
Rubinius.primitive :vm_time
raise PrimitiveFailure, "Process.time primitive failed"
end

def self.cpu_times
Rubinius.primitive :vm_times
raise PrimitiveFailure, "Process.cpu_times primitive failed"
end

##
# Sets the process title. Calling this method does not affect the value of
# `$0` as per MRI behaviour. This method returns the title set.