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

Commits on May 17, 2016

  1. Copy the full SHA
    46f6ea0 View commit details
  2. Copy the full SHA
    8181fe7 View commit details
  3. Copy the full SHA
    1a705d8 View commit details
  4. Copy the full SHA
    31ef559 View commit details
  5. [Truffle] Unify main.

    chrisseaton committed May 17, 2016
    Copy the full SHA
    24f16fe View commit details
  6. Copy the full SHA
    1e85980 View commit details
  7. [Truffle] Unify signal.

    chrisseaton committed May 17, 2016
    Copy the full SHA
    4d026fc View commit details
  8. Copy the full SHA
    d43caee View commit details
24 changes: 9 additions & 15 deletions truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -28,11 +28,11 @@
Truffle::Boot.require_core 'core/character'
Truffle::Boot.require_core 'core/configuration'
Truffle::Boot.require_core 'core/bootstrap/dir'
Truffle::Boot.require_core 'core/bootstrap/false'
Truffle::Boot.require_core 'core/bootstrap/gc'
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/bootstrap/nil'
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'
@@ -41,7 +41,7 @@
Truffle::Boot.require_core 'core/bootstrap/symbol'
Truffle::Boot.require_core 'core/bootstrap/thread'
Truffle::Boot.require_core 'core/bootstrap/time'
Truffle::Boot.require_core 'core/bootstrap/true'
Truffle::Boot.require_core 'core/true'
Truffle::Boot.require_core 'core/bootstrap/type'
Truffle::Boot.require_core 'core/weakref'

@@ -50,8 +50,8 @@
Truffle::Boot.require_core 'core/library'

Truffle::Boot.require_core 'core/platform/ffi'
Truffle::Boot.require_core 'core/platform/pointer_accessors'
Truffle::Boot.require_core 'core/platform/pointer'
Truffle::Boot.require_core 'core/pointer_accessors'
Truffle::Boot.require_core 'core/pointer'
Truffle::Boot.require_core 'core/platform/env'
Truffle::Boot.require_core 'core/platform/file'
Truffle::Boot.require_core 'core/platform/struct'
@@ -75,7 +75,7 @@
Truffle::Boot.require_core 'core/identity_map'
Truffle::Boot.require_core 'core/comparable'
Truffle::Boot.require_core 'core/numeric_mirror'
Truffle::Boot.require_core 'core/common/numeric'
Truffle::Boot.require_core 'core/numeric'
Truffle::Boot.require_core 'core/ctype'
Truffle::Boot.require_core 'core/common/integer'
Truffle::Boot.require_core 'core/common/bignum'
@@ -85,18 +85,15 @@
Truffle::Boot.require_core 'core/encoding'
Truffle::Boot.require_core 'core/common/env'
Truffle::Boot.require_core 'core/errno'
Truffle::Boot.require_core 'core/common/false'
Truffle::Boot.require_core 'core/common/io'
Truffle::Boot.require_core 'core/common/file'
Truffle::Boot.require_core 'core/common/dir'
Truffle::Boot.require_core 'core/dir_glob'
Truffle::Boot.require_core 'core/common/file_test'
Truffle::Boot.require_core 'core/file_test'
Truffle::Boot.require_core 'core/common/stat'
Truffle::Boot.require_core 'core/common/float'
Truffle::Boot.require_core 'core/immediate'
Truffle::Boot.require_core 'core/common/main'
Truffle::Boot.require_core 'core/marshal'
Truffle::Boot.require_core 'core/common/nil'
Truffle::Boot.require_core 'core/object_space'
Truffle::Boot.require_core 'core/common/string'
Truffle::Boot.require_core 'core/range_mirror'
@@ -106,19 +103,17 @@
Truffle::Boot.require_core 'core/process_mirror'
Truffle::Boot.require_core 'core/common/random'
Truffle::Boot.require_core 'core/common/regexp'
Truffle::Boot.require_core 'core/common/signal'
Truffle::Boot.require_core 'core/signal'
Truffle::Boot.require_core 'core/splitter'
Truffle::Boot.require_core 'core/common/symbol'
Truffle::Boot.require_core 'core/mutex'
Truffle::Boot.require_core 'core/common/thread'
Truffle::Boot.require_core 'core/throw_catch'
Truffle::Boot.require_core 'core/common/time'
Truffle::Boot.require_core 'core/common/true'
Truffle::Boot.require_core 'core/rational'
Truffle::Boot.require_core 'core/rationalizer'
Truffle::Boot.require_core 'core/complex'
Truffle::Boot.require_core 'core/complexifier'
Truffle::Boot.require_core 'core/common/gc'

# Load delta

@@ -140,7 +135,6 @@
Truffle::Boot.require_core 'core/math'
Truffle::Boot.require_core 'core/method'
Truffle::Boot.require_core 'core/module'
Truffle::Boot.require_core 'core/signal'
Truffle::Boot.require_core 'core/string'
Truffle::Boot.require_core 'core/thread'
Truffle::Boot.require_core 'core/unbound_method'
37 changes: 0 additions & 37 deletions truffle/src/main/ruby/core/bootstrap/false.rb

This file was deleted.

70 changes: 0 additions & 70 deletions truffle/src/main/ruby/core/bootstrap/gc.rb

This file was deleted.

37 changes: 0 additions & 37 deletions truffle/src/main/ruby/core/bootstrap/true.rb

This file was deleted.

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

This file was deleted.

47 changes: 0 additions & 47 deletions truffle/src/main/ruby/core/common/nil.rb

This file was deleted.

108 changes: 0 additions & 108 deletions truffle/src/main/ruby/core/common/signal.rb

This file was deleted.

52 changes: 0 additions & 52 deletions truffle/src/main/ruby/core/delta/file_test.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -25,13 +25,19 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class FalseClass

def to_s
"false"
end

alias_method :|, :^

def inspect
# Call #to_s rather than alias it so that people can change #to_s if they
# wish. Yes, sounds dumb.
to_s
end

end

FALSE = false
Original file line number Diff line number Diff line change
@@ -117,4 +117,29 @@ def writable_real?(path)
def zero?(path)
File.zero? path
end

module_function :blockdev?,
:chardev?,
:directory?,
:executable?,
:executable_real?,
:exist?,
:exists?,
:file?,
:grpowned?,
:identical?,
:owned?,
:pipe?,
:readable?,
:readable_real?,
:setgid?,
:setuid?,
:size,
:size?,
:socket?,
:sticky?,
:symlink?,
:writable?,
:writable_real?,
:zero?
end
Original file line number Diff line number Diff line change
@@ -25,6 +25,49 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

module GC
def self.start
run(false)
end

def self.run(force)
Rubinius.primitive :vm_gc_start
raise PrimitiveFailure, "GC.run primitive failed"
end

# Totally fake.
def self.stress
@stress_level ||= false
end

# Totally fake.
def self.stress=(flag)
@stress_level = !!flag
end

# Totally fake.
@enabled = true

def self.enable
# We don't support disable, so sure! enabled!
ret = !@enabled
@enabled = true

return ret
end

# Totally fake.
def self.disable
# Treat this like a request that we don't honor.
ret = !@enabled
@enabled = false

return ret
end

def garbage_collect
GC.start
end

def self.count
data = stat
data[:"gc.young.count"] + data[:"gc.immix.count"]
@@ -33,8 +76,8 @@ def self.count
def self.time
data = stat
data[:"gc.young.ms"] +
data[:"gc.immix.stop.ms"] +
data[:"gc.large.sweep.us"] * 1_000
data[:"gc.immix.stop.ms"] +
data[:"gc.large.sweep.us"] * 1_000
end

def self.stat
63 changes: 63 additions & 0 deletions truffle/src/main/ruby/core/main.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,69 @@
# 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.

# Truffle doesn't have a class MAIN, but it's implied by `self`, so just use that here.
class << self
def include(*mods)
Rubinius.privately do
Object.include(*mods)
end
end

def public(*methods)
Rubinius.privately do
Object.public(*methods)
end

Object
end

def private(*methods)
Rubinius.privately do
Object.private(*methods)
end

Object
end

def define_method(*args, &block)
Rubinius.privately do
Object.define_method(*args, &block)
end
end

def to_s
"main"
end

alias_method :inspect, :to_s
end

if Truffle::Safe.signals_safe?
Signal.trap("INT") do
raise Interrupt
Original file line number Diff line number Diff line change
@@ -56,4 +56,24 @@ def to_f
def to_i
0
end

alias_method :|, :^

def to_r
Rational(0, 1)
end

def rationalize(eps = nil)
to_r
end

def to_c
Complex(0)
end

def to_h
{}
end
end

NIL = nil
File renamed without changes.
File renamed without changes.
111 changes: 104 additions & 7 deletions truffle/src/main/ruby/core/signal.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# 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-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 Signal
Names = {
"EXIT" => 0
}

Numbers = {
0 => "EXIT"
}

# Fill the Names and Numbers Hash.
SIGNAL_LIST.each do |name, number|
@@ -15,4 +40,76 @@ module Signal
end
remove_const :SIGNAL_LIST

@threads = {}
@handlers = {}

def self.trap(sig, prc=nil, &block)
sig = sig.to_s if sig.kind_of?(Symbol)

if sig.kind_of?(String)
osig = sig

if sig.prefix? "SIG"
sig = sig[3..-1]
end

unless number = Names[sig]
raise ArgumentError, "Unknown signal '#{osig}'"
end
else
number = sig.to_i
end

# If no command, use the block.
prc ||= block
prc = prc.to_s if prc.kind_of?(Symbol)

case prc
when "DEFAULT", "SIG_DFL"
had_old = @handlers.key?(number)
old = @handlers.delete(number)

if number != Names["EXIT"]
Rubinius.watch_signal(Numbers[number], 'DEFAULT') # Truffle: adapted to pass the signal name and simpler arguments
end

return "DEFAULT" unless had_old
return old ? old : nil
when "IGNORE", "SIG_IGN"
prc = "IGNORE"
when nil
prc = nil
when "EXIT"
prc = proc { exit }
when String
raise ArgumentError, "Unsupported command '#{prc}'"
else
unless prc.respond_to? :call
raise ArgumentError, "Handler must respond to #call (was #{prc.class})"
end
end

had_old = @handlers.key?(number)

old = @handlers[number]
@handlers[number] = prc

if number != Names["EXIT"]
Rubinius.watch_signal(Numbers[number], (prc.nil? || prc == 'IGNORE') ? nil : prc) # Truffle: adapted to pass the signal name and simpler arguments
end

return "DEFAULT" unless had_old
return old ? old : nil
end

def self.run_handler(sig)
# Ignore nil handlers
if handler = @handlers[sig]
handler.call(sig)
end
end

def self.list
Names.dup
end
end
Original file line number Diff line number Diff line change
@@ -25,11 +25,17 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class TrueClass

def to_s
"true"
end

def inspect
# Call #to_s rather than alias it so that people can change #to_s if they
# wish. Yes, sounds dumb.
to_s
end

end

TRUE = true