Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into mcjit
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Apr 1, 2016
2 parents d348367 + 0deebd9 commit 1a7ff85
Show file tree
Hide file tree
Showing 204 changed files with 965 additions and 482 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -20,7 +20,7 @@ if [ $TRAVIS_OS_NAME == linux ]; then travis_retry ./configure --llvm-config=llv
if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure; fi
script: rake ci
after_success:
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then ./scripts/deploy.sh release github website triggers docker; fi
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then ./scripts/deploy.sh release github website triggers; fi
branches:
only:
- master
Expand Down
4 changes: 0 additions & 4 deletions core/compiled_code.rb
Expand Up @@ -698,8 +698,4 @@ def to_s
end
end
end

# NOTE: Temporary alias for backwards compatibility. CompiledMethod is
# deprecated. Client code should use CompiledCode.
CompiledMethod = CompiledCode
end
5 changes: 0 additions & 5 deletions core/constant_scope.rb
Expand Up @@ -173,9 +173,4 @@ def const_set(name, value)
@module.const_set name, value
end
end

# NOTE: Temporary alias for backwards compatibility. StaticScope will
# eventually be deprecated in favor of ConstantScope.
StaticScope = ConstantScope
end

4 changes: 2 additions & 2 deletions core/deprecations.rb
Expand Up @@ -3,8 +3,8 @@ module Rubinius
# "Description" => "Alternative"
"Ruby 2.1 features that are incompatible with Ruby 2.2 are deprecated." =>
"Use Ruby 2.2 features if they are available.",
"Rubinius::CompiledMethod is deprecated." => "Use Rubinius::CompiledCode instead.",
"Rubinius::StaticScope is deprecated." => "Use Rubinius::ConstantScope instead.",
"Rubinius::KERNEL_PATH is deprecated." => "Use Rubinius::CORE_PATH instead.",
"CallCustom is deprecated." =>
"The replacement will be new executable resolution, cache, and invoke machine instructions.",
}
end
26 changes: 19 additions & 7 deletions core/gc.rb
Expand Up @@ -43,19 +43,27 @@ def garbage_collect
end

def self.count
data = stat
data[:"gc.young.count"] + data[:"gc.immix.count"]
if data = stat
data[:"gc.young.count"] + data[:"gc.immix.count"]
else
0
end
end

def self.time
data = stat
data[:"gc.young.ms"] +
data[:"gc.immix.stop.ms"] +
data[:"gc.large.sweep.us"] * 1_000
if data = stat
data[:"gc.young.ms"] +
data[:"gc.immix.stop.ms"] +
data[:"gc.large.sweep.us"] * 1_000
else
0
end
end

def self.stat
Rubinius::Metrics.data.to_hash
if Rubinius::Metrics.enabled?
return Rubinius::Metrics.data.to_hash
end
end

module Profiler
Expand Down Expand Up @@ -90,6 +98,10 @@ def self.report(out = $stdout)
end

def self.result
unless Rubinius::Metrics.enabled?
return "Rubinius::Metrics is disabled. GC::Profiler results are unavailable"
end

stats = GC.stat

out = <<-OUT
Expand Down
43 changes: 33 additions & 10 deletions core/io.rb
Expand Up @@ -1169,7 +1169,7 @@ def initialize(fd, mode=undefined, options=undefined)
(@external || Encoding.default_external) == Encoding::ASCII_8BIT
@internal = nil
end
elsif @mode != RDONLY
elsif !mode_read_only?
if Encoding.default_external != Encoding.default_internal
@internal = Encoding.default_internal
end
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def <<(obj)
def close_read
return if closed?

if @mode == WRONLY || @mode == RDWR
if mode_write_only? || mode_read_write?
raise IOError, 'closing non-duplex IO for reading'
end
close
Expand All @@ -1300,7 +1300,7 @@ def close_read
def close_write
return if closed?

if @mode == RDONLY || @mode == RDWR
if mode_read_only? || mode_read_write?
raise IOError, 'closing non-duplex IO for writing'
end
close
Expand Down Expand Up @@ -1636,19 +1636,17 @@ def eof?

def ensure_open_and_readable
ensure_open
write_only = @mode & ACCMODE == WRONLY
raise IOError, "not opened for reading" if write_only
raise IOError, "not opened for reading" if mode_write_only?
end

def ensure_open_and_writable
ensure_open
read_only = @mode & ACCMODE == RDONLY
raise IOError, "not opened for writing" if read_only
raise IOError, "not opened for writing" if mode_read_only?
end

def external_encoding
return @external if @external
return Encoding.default_external if @mode == RDONLY
return Encoding.default_external if mode_read_only?
end

##
Expand Down Expand Up @@ -1747,6 +1745,16 @@ def flush
self
end

def force_read_only
@mode = (@mode & ~ACCMODE ) | RDONLY
end
private :force_read_only

def force_write_only
@mode = (@mode & ~ACCMODE) | WRONLY
end
private :force_write_only

##
# Immediately writes all buffered data in ios to disk. Returns
# nil if the underlying operating system does not support fsync(2).
Expand Down Expand Up @@ -1831,6 +1839,21 @@ def lineno=(line_number)
@lineno = Integer(line_number)
end

def mode_read_only?
(@mode & ACCMODE) == RDONLY
end
private :mode_read_only?

def mode_read_write?
(@mode & ACCMODE) == RDWR
end
private :mode_read_write?

def mode_write_only?
(@mode & ACCMODE) == WRONLY
end
private :mode_write_only?

##
# FIXME
# Returns the process ID of a child process
Expand Down Expand Up @@ -2234,7 +2257,7 @@ def reopen(other, mode=undefined)
mode = @mode
# If this IO was already opened for writing, we should
# create the target file if it doesn't already exist.
if (mode & RDWR == RDWR) || (mode & WRONLY == WRONLY)
if mode_read_write? || mode_write_only?
mode |= CREAT
end
else
Expand Down Expand Up @@ -2301,7 +2324,7 @@ def set_encoding(external, internal=nil, options=undefined)
when String
@external = nil
when nil
if @mode == RDONLY || @external
if mode_read_only? || @external
@external = nil
else
@external = Encoding.default_external
Expand Down
6 changes: 6 additions & 0 deletions core/metrics.rb
@@ -1,5 +1,11 @@
module Rubinius
module Metrics
@enabled = false

def self.enabled?
!!@enabled
end

def self.data
@data ||= Data.new
end
Expand Down
2 changes: 1 addition & 1 deletion gems_list.txt
Expand Up @@ -14,7 +14,7 @@ rubinius-bridge-1.1.0.gem
rubinius-code-3.0.gem
rubinius-compiler-3.1.gem
rubinius-coverage-2.0.3.gem
rubinius-debugger-2.2.1.gem
rubinius-debugger-2.4.gem
rubinius-developer_tools-2.0.0.gem
rubinius-instructions-3.0.gem
rubinius-melbourne-3.4.gem
Expand Down
1 change: 1 addition & 0 deletions library/gauntlet_rubygems.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems'
require 'gauntlet'

Expand Down
85 changes: 74 additions & 11 deletions library/rubygems.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# -*- ruby -*-
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
Expand All @@ -9,7 +10,7 @@
require 'thread'

module Gem
VERSION = '2.5.1'
VERSION = '2.6.2'
end

# Must be first since it unloads the prelude from 1.9.2
Expand Down Expand Up @@ -191,8 +192,13 @@ def self.try_activate path

begin
spec.activate
rescue Gem::LoadError # this could fail due to gem dep collisions, go lax
Gem::Specification.find_by_name(spec.name).activate
rescue Gem::LoadError => e # this could fail due to gem dep collisions, go lax
spec_by_name = Gem::Specification.find_by_name(spec.name)
if spec_by_name.nil?
raise e
else
spec_by_name.activate
end
end

return true
Expand Down Expand Up @@ -229,16 +235,20 @@ def self.bin_path(name, exec_name = nil, *requirements)
requirements = Gem::Requirement.default if
requirements.empty?

find_spec_for_exe(name, exec_name, requirements).bin_file exec_name
end

def self.find_spec_for_exe name, exec_name, requirements
dep = Gem::Dependency.new name, requirements

loaded = Gem.loaded_specs[name]

return loaded.bin_file exec_name if loaded && dep.matches_spec?(loaded)
return loaded if loaded && dep.matches_spec?(loaded)

specs = dep.matching_specs(true)

raise Gem::GemNotFoundException,
"can't find gem #{name} (#{requirements})" if specs.empty?
"can't find gem #{dep}" if specs.empty?

specs = specs.find_all { |spec|
spec.executables.include? exec_name
Expand All @@ -249,6 +259,24 @@ def self.bin_path(name, exec_name = nil, *requirements)
raise Gem::GemNotFoundException, msg
end

spec
end
private_class_method :find_spec_for_exe

##
# Find the full path to the executable for gem +name+. If the +exec_name+
# is not given, the gem's default_executable is chosen, otherwise the
# specified executable's path is returned. +requirements+ allows
# you to specify specific gem versions.
#
# A side effect of this method is that it will activate the gem that
# contains the executable.
#
# This method should *only* be used in bin stub files.

def self.activate_bin_path name, exec_name, requirement # :nodoc:
spec = find_spec_for_exe name, exec_name, [requirement]
Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate }
spec.bin_file exec_name
end

Expand Down Expand Up @@ -325,16 +353,38 @@ def self.deflate(data)
# lookup files.

def self.paths
@paths ||= Gem::PathSupport.new
@paths ||= Gem::PathSupport.new(ENV)
end

# Initialize the filesystem paths to use from +env+.
# +env+ is a hash-like object (typically ENV) that
# is queried for 'GEM_HOME', 'GEM_PATH', and 'GEM_SPEC_CACHE'
# Keys for the +env+ hash should be Strings, and values of the hash should
# be Strings or +nil+.

def self.paths=(env)
clear_paths
@paths = Gem::PathSupport.new env
target = {}
env.each_pair do |k,v|
case k
when 'GEM_HOME', 'GEM_PATH', 'GEM_SPEC_CACHE'
case v
when nil, String
target[k] = v
when Array
unless Gem::Deprecate.skip
warn <<-eowarn
Array values in the parameter are deprecated. Please use a String or nil.
An Array was passed in from #{caller[3]}
eowarn
end
target[k] = v.join File::PATH_SEPARATOR
end
else
target[k] = v
end
end
@paths = Gem::PathSupport.new ENV.to_hash.merge(target)
Gem::Specification.dirs = @paths.path
end

Expand Down Expand Up @@ -429,7 +479,9 @@ def self.find_files(glob, check_load_path=true)

files = find_files_from_load_path glob if check_load_path

files.concat Gem::Specification.stubs.map { |spec|
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs

files.concat gem_specifications.map { |spec|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
}.flatten

Expand Down Expand Up @@ -811,6 +863,15 @@ def self.ruby_api_version
@ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup
end

def self.env_requirement(gem_name)
@env_requirements_by_name ||= {}
@env_requirements_by_name[gem_name] ||= begin
req = ENV["GEM_REQUIREMENT_#{gem_name.upcase}"] || '>= 0'.freeze
Gem::Requirement.create(req)
end
end
post_reset { @env_requirements_by_name = {} }

##
# Returns the latest release-version specification for the gem +name+.

Expand Down Expand Up @@ -938,9 +999,11 @@ def self.ui
# by the unit tests to provide environment isolation.

def self.use_paths(home, *paths)
paths = nil if paths == [nil]
paths = paths.first if Array === Array(paths).first
self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths }
paths.flatten!
paths.compact!
hash = { "GEM_HOME" => home, "GEM_PATH" => paths.empty? ? home : paths.join(File::PATH_SEPARATOR) }
hash.delete_if { |_, v| v.nil? }
self.paths = hash
end

##
Expand Down
1 change: 1 addition & 0 deletions library/rubygems/available_set.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Gem::AvailableSet

include Enumerable
Expand Down

0 comments on commit 1a7ff85

Please sign in to comment.