Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin' into 1.8.7
Conflicts:
	Gemfile.lock
	gems_list.txt
	kernel/common/array.rb
	kernel/common/enumerable.rb
	kernel/common/enumerator.rb
	kernel/common/struct.rb
	spec/ruby/core/enumerable/each_cons_spec.rb
	spec/ruby/core/enumerator/lazy/take_spec.rb
	spec/ruby/core/struct/each_pair_spec.rb
	vm/include/capi/ruby/ruby.h
	vm/shared_state.hpp
  • Loading branch information
brixen committed Jun 12, 2015
2 parents c20de9e + 57cc497 commit a97b41b
Show file tree
Hide file tree
Showing 29 changed files with 342 additions and 220 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Expand Up @@ -8,15 +8,15 @@ before_install:
- echo $LANG
- echo $LC_ALL
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update && sudo apt-get install -y llvm-3.4 llvm-3.4-dev; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install llvm && brew link --force llvm; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install llvm35 && brew link --force llvm35; fi
- rvm use $RVM --install --binary --fuzzy
- gem update --system
- gem --version

before_script:
- travis_retry bundle
- if [ $TRAVIS_OS_NAME == linux ]; then travis_retry ./configure --llvm-config llvm-config-3.4; fi
- if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure --llvm-config /usr/local/opt/llvm/bin/llvm-config; fi
- if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure; fi

script: rake ci

Expand Down Expand Up @@ -49,6 +49,4 @@ env:

os:
- linux
# - osx

osx_image: xcode61
- osx
3 changes: 0 additions & 3 deletions Gemfile.lock
Expand Up @@ -27,6 +27,3 @@ DEPENDENCIES
redcard (~> 1.0)
rubinius-bridge (~> 1.0)
rubinius-build_tools (~> 1.0)

BUNDLED WITH
1.10.3
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
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
Expand Down
4 changes: 2 additions & 2 deletions configure
Expand Up @@ -574,8 +574,8 @@ class Configure
if macports?
config = macports_llvm_config
else
out = Bundler.with_clean_env { `brew list llvm | grep '/llvm-config$'` }
config = out.chomp if $?.success?
out = Bundler.with_clean_env { `brew --prefix llvm35` }.chomp
config = "#{out}/bin/llvm-config-3.5" if $?.success?
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions gems_list.txt
@@ -1,10 +1,10 @@
bundler-1.10.3.gem
bundler-1.9.9.gem
ffi2-generators-0.1.1.gem
json-1.8.3.gem
json-1.8.2.gem
minitest-4.7.5.gem
racc-1.4.12.gem
rake-10.4.2.gem
rb-readline-0.5.3.gem
rb-readline-0.5.2.gem
rdoc-4.2.0.gem
rubinius-ast-1.3.0.gem
rubinius-build_tools-1.0.0.gem
Expand All @@ -18,7 +18,7 @@ rubinius-profiler-2.0.2.gem
rubinius-toolset-2.3.1.gem
rubysl-1.1.0.gem
rubysl-abbrev-1.0.1.gem
rubysl-base64-1.0.1.gem
rubysl-base64-1.0.0.gem
rubysl-benchmark-1.0.0.gem
rubysl-bigdecimal-1.0.0.gem
rubysl-cgi-1.0.0.gem
Expand All @@ -28,7 +28,7 @@ rubysl-csv-1.0.1.gem
rubysl-curses-1.0.0.gem
rubysl-date-1.0.1.gem
rubysl-delegate-1.0.0.gem
rubysl-digest-1.2.0.gem
rubysl-digest-1.0.1.gem
rubysl-drb-1.0.0.gem
rubysl-e2mmap-1.0.0.gem
rubysl-english-1.0.0.gem
Expand Down
2 changes: 2 additions & 0 deletions kernel/bootstrap/thunk.rb
Expand Up @@ -4,6 +4,8 @@ def self.new(value)
Rubinius.primitive :thunk_create
raise PrimitiveFailure, "Thunk.new primitive failed"
end

attr_accessor :value
end

class CallUnit
Expand Down
13 changes: 12 additions & 1 deletion kernel/common/array.rb
Expand Up @@ -1599,7 +1599,18 @@ def zip(*others)
size.times do |i|
slot = out.at(i)
slot << @tuple.at(@start + i)
others.each { |ary| slot << ary.at(i) }
others.each do |other|
slot << case other
when Array
other.at i
else
begin
other.next
rescue StopIteration
nil
end
end
end
end

if block_given?
Expand Down
63 changes: 35 additions & 28 deletions kernel/loader.rb
Expand Up @@ -704,6 +704,11 @@ def flush_stdio
STDERR.flush unless STDERR.closed?
end

def exit_with_exception(e)
@exit_code = 1
Rubinius::Logger.log_exception "An exception occurred #{@stage}", e
end

# Cleanup and at_exit processing.
def epilogue
@stage = "running at_exit handlers"
Expand All @@ -723,8 +728,7 @@ def epilogue
flush_stdio

rescue Object => e
Rubinius::Logger.log_exception "An exception occurred #{@stage}", e
@exit_code = 1
exit_with_exception e
end

# Exit.
Expand Down Expand Up @@ -776,6 +780,34 @@ def done
Process.exit! @exit_code
end

def handle_exception(e)
case e
when SystemExit
@exit_code = e.status
when SyntaxError
@exit_code = 1

show_syntax_error(e)

STDERR.puts "\nBacktrace:"
STDERR.puts
STDERR.puts e.awesome_backtrace.show
when Interrupt
exit_with_exception e
when SignalException
Signal.trap(e.signo, "SIG_DFL")
Process.kill e.signo, Process.pid
when nil
# what?
else
exit_with_exception e
end
rescue Object => e
exit_with_exception e
ensure
epilogue
end

# Orchestrate everything.
def main
preamble
Expand All @@ -795,33 +827,8 @@ def main
script
repl

rescue SystemExit => e
@exit_code = e.status

epilogue
rescue SyntaxError => e
@exit_code = 1

show_syntax_error(e)

STDERR.puts "\nBacktrace:"
STDERR.puts
STDERR.puts e.awesome_backtrace.show
epilogue
rescue Interrupt => e
@exit_code = 1

Rubinius::Logger.log_exception "An exception occurred #{@stage}:", e
epilogue
rescue SignalException => e
Signal.trap(e.signo, "SIG_DFL")
Process.kill e.signo, Process.pid
epilogue
rescue Object => e
@exit_code = 1

Rubinius::Logger.log_exception "An exception occurred #{@stage}:", e
epilogue
handle_exception e
else
# We do this, run epilogue both in the rescue blocks and also here,
# so that at_exit{} hooks can read $!.
Expand Down
2 changes: 1 addition & 1 deletion library/rubygems.rb
Expand Up @@ -9,7 +9,7 @@
require 'thread'

module Gem
VERSION = '2.4.6'
VERSION = '2.4.8'
end

# Must be first since it unloads the prelude from 1.9.2
Expand Down
8 changes: 7 additions & 1 deletion library/rubygems/remote_fetcher.rb
Expand Up @@ -94,7 +94,13 @@ def api_endpoint(uri)
rescue Resolv::ResolvError
uri
else
URI.parse "#{uri.scheme}://#{res.target}#{uri.path}"
target = res.target.to_s.strip

if /\.#{Regexp.quote(host)}\z/ =~ target
return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
end

uri
end
end

Expand Down
13 changes: 13 additions & 0 deletions spec/core/module/thunk_method_spec.rb
Expand Up @@ -20,4 +20,17 @@
it "returns the coerced name" do
@class.thunk_method("a_reader", @value).should equal(:a_reader)
end

it "creates an executable that can be used to read the value" do
@class.thunk_method(:thunk, @value)
@class.instance_method(:thunk).executable.value.should equal(@value)
end

it "creates an executable that can be used to change the value" do
@class.thunk_method(:thunk, @value)
new_value = Object.new
@class.instance_method(:thunk).executable.value = new_value
@class.instance_method(:thunk).executable.value.should equal(new_value)
@class.new.thunk.should equal(new_value)
end
end
6 changes: 6 additions & 0 deletions spec/ruby/core/enumerator/size_spec.rb
Expand Up @@ -19,4 +19,10 @@
enum.size.should == 301
end
end

it "returns the result from size.call if the size respond to call " do
obj = mock('call')
obj.should_receive(:call).and_return(42)
Enumerator.new(obj) {}.size.should == 42
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/exception/signal_exception_spec.rb
Expand Up @@ -117,7 +117,7 @@

it "raises a SignalException when sent a signal" do
begin
Process.kill :TERM, Process.pid
raise SignalException.new(Signal.list["TERM"])
rescue SignalException => e
e.signo.should == Signal.list["TERM"]
end
Expand Down
18 changes: 18 additions & 0 deletions spec/ruby/core/marshal/shared/load.rb
Expand Up @@ -579,6 +579,24 @@
end
end

describe "for a Bignum" do
platform_is :wordsize => 64 do
context "that is Bignum on 32-bit platforms but Fixnum on 64-bit" do
it "dumps a Fixnum" do
val = Marshal.load("\004\bl+\ab:wU")
val.should == 1433877090
val.class.should == Fixnum
end

it "dumps an array containing multiple references to the Bignum as an array of Fixnum" do
arr = Marshal.load("\004\b[\al+\a\223BwU@\006")
arr.should == [1433879187, 1433879187]
arr.each { |v| v.class.should == Fixnum }
end
end
end
end

describe "for a Time" do
it "loads" do
Marshal.send(@method, Marshal.dump(Time.at(1))).should == Time.at(1)
Expand Down
20 changes: 20 additions & 0 deletions spec/ruby/optional/capi/ext/hash_spec.c
Expand Up @@ -11,6 +11,18 @@ VALUE hash_spec_rb_hash(VALUE self, VALUE hash) {
}
#endif

#ifdef HAVE_RB_HASH_DUP
VALUE hash_spec_rb_hash_dup(VALUE self, VALUE hash) {
return rb_hash_dup(hash);
}
#endif

#ifdef HAVE_RB_HASH_FREEZE
VALUE hash_spec_rb_hash_freeze(VALUE self, VALUE hash) {
return rb_hash_freeze(hash);
}
#endif

#ifdef HAVE_RB_HASH_AREF
VALUE hash_spec_rb_hash_aref(VALUE self, VALUE hash, VALUE key) {
return rb_hash_aref(hash, key);
Expand Down Expand Up @@ -107,6 +119,14 @@ void Init_hash_spec() {
rb_define_method(cls, "rb_hash", hash_spec_rb_hash, 1);
#endif

#ifdef HAVE_RB_HASH_DUP
rb_define_method(cls, "rb_hash_dup", hash_spec_rb_hash_dup, 1);
#endif

#ifdef HAVE_RB_HASH_FREEZE
rb_define_method(cls, "rb_hash_freeze", hash_spec_rb_hash_freeze, 1);
#endif

#ifdef HAVE_RB_HASH_AREF
rb_define_method(cls, "rb_hash_aref", hash_spec_rb_hash_aref, 2);
rb_define_method(cls, "rb_hash_aref_nil", hash_spec_rb_hash_aref_nil, 2);
Expand Down
2 changes: 2 additions & 0 deletions spec/ruby/optional/capi/ext/rubyspec.h
Expand Up @@ -303,6 +303,8 @@

/* Hash */
#define HAVE_RB_HASH 1
#define HAVE_RB_HASH_DUP 1
#define HAVE_RB_HASH_FREEZE 1
#define HAVE_RB_HASH_AREF 1
#define HAVE_RB_HASH_ASET 1
#define HAVE_RB_HASH_DELETE 1
Expand Down
15 changes: 15 additions & 0 deletions spec/ruby/optional/capi/hash_spec.rb
Expand Up @@ -49,6 +49,21 @@
end
end

describe "rb_hash_dup" do
it "returns a copy of the hash" do
hsh = {}
dup = @s.rb_hash_dup(hsh)
dup.should == hsh
dup.should_not equal(hsh)
end
end

describe "rb_hash_freeze" do
it "freezes the hash" do
@s.rb_hash_freeze({}).frozen?.should be_true
end
end

describe "rb_hash_aref" do
it "returns the value associated with the key" do
hsh = {:chunky => 'bacon'}
Expand Down
8 changes: 5 additions & 3 deletions vm/builtin/system.cpp
Expand Up @@ -923,13 +923,15 @@ namespace rubinius {
}

Object* System::vm_watch_signal(STATE, Fixnum* sig, Object* ignored) {
SignalThread* st = state->shared().signal_handler();
SignalThread* st = state->shared().signals();

if(st) {
native_int i = sig->to_native();
if(i < 0) {
st->add_signal(state, -i, SignalThread::eDefault);
st->add_signal_handler(state, -i, SignalThread::eDefault);
} else if(i > 0) {
st->add_signal(state, i, CBOOL(ignored) ? SignalThread::eIgnore : SignalThread::eCustom);
st->add_signal_handler(state, i,
CBOOL(ignored) ? SignalThread::eIgnore : SignalThread::eCustom);
}

return cTrue;
Expand Down
2 changes: 1 addition & 1 deletion vm/capi/array.cpp
Expand Up @@ -216,7 +216,7 @@ extern "C" {
}

/* @todo Check 64-bit? */
VALUE rb_ary_entry(VALUE self, int index) {
VALUE rb_ary_entry(VALUE self, long index) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();

Array* array = capi_get_array(env, self);
Expand Down
8 changes: 8 additions & 0 deletions vm/capi/hash.cpp
Expand Up @@ -10,6 +10,14 @@ extern "C" {
return capi_fast_call(rb_cHash, rb_intern("new"), 0);
}

VALUE rb_hash_dup(VALUE self) {
return capi_fast_call(self, rb_intern("dup"), 0);
}

VALUE rb_hash_freeze(VALUE self) {
return capi_fast_call(self, rb_intern("freeze"), 0);
}

VALUE rb_hash_aref(VALUE self, VALUE key) {
return capi_fast_call(self, rb_intern("[]"), 1, key);
}
Expand Down

0 comments on commit a97b41b

Please sign in to comment.