Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into 1.8.7
Browse files Browse the repository at this point in the history
Conflicts:
	kernel/common/proc.rb
	spec/ruby/core/array/shared/inspect.rb
	spec/ruby/core/dir/shared/exists.rb
	spec/ruby/core/marshal/shared/load.rb
	vm/include/capi/ruby/ruby.h
  • Loading branch information
brixen committed Jun 16, 2015
2 parents a97b41b + 4b5b02d commit 2dc04f1
Show file tree
Hide file tree
Showing 28 changed files with 165 additions and 130 deletions.
4 changes: 2 additions & 2 deletions spec/ruby/core/array/shared/slice.rb
Expand Up @@ -277,8 +277,8 @@ def to.to_int() -2 end
range_incl = ArraySpecs::MyRange.new(1, 2)
range_excl = ArraySpecs::MyRange.new(-3, -1, true)

a[range_incl].should == [2, 3]
a[range_excl].should == [2, 3]
a.send(@method, range_incl).should == [2, 3]
a.send(@method, range_excl).should == [2, 3]
end

it "returns nil for a requested index not in the array with [index]" do
Expand Down
9 changes: 3 additions & 6 deletions spec/ruby/core/dir/shared/exists.rb
Expand Up @@ -43,11 +43,8 @@
Dir.send(@method, __FILE__).should be_false
end

ruby_version_is "1.9" do
it "calls #to_path on non String arguments" do
p = mock('path')
p.should_receive(:to_path).and_return(File.dirname(__FILE__))
Dir.send(@method, p)
end
it "doesn't set $! when file doesn't exist" do
Dir.send(@method, "/path/to/non/existent/dir")
$!.should be_nil
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/shared/collect_concat.rb
Expand Up @@ -39,7 +39,7 @@
obj = mock("to_ary defined")
obj.should_receive(:to_ary).and_return("array")

lambda { [1, obj, 3].flat_map { |i| i } }.should raise_error(TypeError)
lambda { [1, obj, 3].send(@method) { |i| i } }.should raise_error(TypeError)
end

it "returns an enumerator when no block given" do
Expand Down
6 changes: 3 additions & 3 deletions spec/ruby/core/hash/shared/store.rb
Expand Up @@ -22,15 +22,15 @@ def key.reverse() "bar" end
k1.should_receive(:hash).and_return(0)
k2.should_receive(:hash).and_return(0)

h[k1] = 1
h[k2] = 2
h.send(@method, k1, 1)
h.send(@method, k2, 2)
h.size.should == 2
end

it "accepts keys with private #hash method" do
key = HashSpecs::KeyWithPrivateHash.new
h = new_hash
h[key] = "foo"
h.send(@method, key, "foo")
h[key].should == "foo"
end

Expand Down
3 changes: 2 additions & 1 deletion spec/ruby/core/kernel/__send___spec.rb
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/send', __FILE__)

describe "Kernel#__send__" do
it "needs to be reviewed for spec completeness"
it_behaves_like(:kernel_send, :__send__)
end
8 changes: 4 additions & 4 deletions spec/ruby/core/kernel/shared/send.rb
Expand Up @@ -36,15 +36,15 @@ def self.bar
end

it "raises an ArgumentError if no arguments are given" do
lambda { KernelSpecs::Foo.new.send }.should raise_error(ArgumentError)
lambda { KernelSpecs::Foo.new.send @method }.should raise_error(ArgumentError)
end

it "raises an ArgumentError if called with more arguments than available parameters" do
class KernelSpecs::Foo
def bar; end
end

lambda { KernelSpecs::Foo.new.send(:bar, :arg) }.should raise_error(ArgumentError)
lambda { KernelSpecs::Foo.new.send(@method, :bar, :arg) }.should raise_error(ArgumentError)
end

it "raises an ArgumentError if called with fewer arguments than required parameters" do
Expand Down Expand Up @@ -98,13 +98,13 @@ def foo(first = true) first end
not_compliant_on :rubinius do
# Confirm commit r24306
it "has an arity of -1" do
method(:__send__).arity.should == -1
method(@method).arity.should == -1
end
end

deviates_on :rubinius do
it "has an arity of -2" do
method(:__send__).arity.should == -2
method(@method).arity.should == -2
end
end
end
28 changes: 21 additions & 7 deletions spec/ruby/core/marshal/shared/load.rb
Expand Up @@ -289,31 +289,31 @@
it "loads a US-ASCII String" do
str = "abc".force_encoding("us-ascii")
data = "\x04\bI\"\babc\x06:\x06EF"
result = Marshal.load(data)
result = Marshal.send(@method, data)
result.should == str
result.encoding.should equal(Encoding::US_ASCII)
end

it "loads a UTF-8 String" do
str = "\x6d\xc3\xb6\x68\x72\x65".force_encoding("utf-8")
data = "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET"
result = Marshal.load(data)
result = Marshal.send(@method, data)
result.should == str
result.encoding.should equal(Encoding::UTF_8)
end

it "loads a String in another encoding" do
str = "\x6d\x00\xf6\x00\x68\x00\x72\x00\x65\x00".force_encoding("utf-16le")
data = "\x04\bI\"\x0Fm\x00\xF6\x00h\x00r\x00e\x00\x06:\rencoding\"\rUTF-16LE"
result = Marshal.load(data)
result = Marshal.send(@method, data)
result.should == str
result.encoding.should equal(Encoding::UTF_16LE)
end

it "loads a String as ASCII-8BIT if no encoding is specified at the end" do
str = "\xC3\xB8"
data = "\x04\b\"\a\xC3\xB8".force_encoding("UTF-8")
result = Marshal.load(data)
result = Marshal.send(@method, data)
result.encoding.should == Encoding::ASCII_8BIT
result.should == str
end
Expand Down Expand Up @@ -583,13 +583,13 @@
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 = Marshal.send(@method, "\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 = Marshal.send(@method, "\004\b[\al+\a\223BwU@\006")
arr.should == [1433879187, 1433879187]
arr.each { |v| v.class.should == Fixnum }
end
Expand All @@ -606,7 +606,21 @@
t = Time.new
t.instance_variable_set(:@foo, 'bar')

Marshal.load(Marshal.dump(t)).instance_variable_get(:@foo).should == 'bar'
Marshal.send(@method, Marshal.dump(t)).instance_variable_get(:@foo).should == 'bar'
end

it "loads Time objects stored as links" do
t = Time.new

t1, t2 = Marshal.send(@method, Marshal.dump([t, t]))
t1.should equal t2
end

it "loads the zone" do
with_timezone 'AST', 3 do
t = Time.local(2012, 1, 1)
Marshal.send(@method, Marshal.dump(t)).zone.should == t.zone
end
end
end

Expand Down
17 changes: 5 additions & 12 deletions vm/builtin/thread.cpp
Expand Up @@ -269,17 +269,10 @@ namespace rubinius {
SharedState& shared = vm->shared;
State state_obj(vm), *state = &state_obj;

std::string thread_name;
vm->set_current_thread();

{
std::ostringstream tn;
tn << "rbx.ruby." << vm->thread_id();
VM::set_current(vm, tn.str());
thread_name = tn.str();
}

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name.c_str()),
vm->thread_id(), 0);
RUBINIUS_THREAD_START(
const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 0);

if(cDebugThreading) {
utilities::logger::debug("Thread: start thread: id: %d, pthread: %d",
Expand Down Expand Up @@ -341,8 +334,8 @@ namespace rubinius {

vm->set_zombie();

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name.c_str()),
vm->thread_id(), 0);
RUBINIUS_THREAD_STOP(
const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 0);

return 0;
}
Expand Down
7 changes: 3 additions & 4 deletions vm/console.hpp
@@ -1,7 +1,6 @@
#ifndef RBX_CONSOLE_HPP
#define RBX_CONSOLE_HPP

#include "lock.hpp"
#include "internal_threads.hpp"

#include "gc/root.hpp"
Expand Down Expand Up @@ -66,7 +65,7 @@ namespace rubinius {
Class* server_class(STATE);
};

class Listener : public InternalThread, public Lockable {
class Listener : public InternalThread {
Console* console_;

TypedRoot<FSEvent*> fsevent_;
Expand All @@ -88,7 +87,7 @@ namespace rubinius {

typedef std::list<char*> RequestList;

class Response : public InternalThread, public Lockable {
class Response : public InternalThread {
Console* console_;

TypedRoot<Channel*> inbox_;
Expand Down Expand Up @@ -122,7 +121,7 @@ namespace rubinius {
void write_response(STATE, const char* response, native_int size);
};

class Request : public InternalThread, public Lockable {
class Request : public InternalThread {
Console* console_;
Response* response_;

Expand Down
2 changes: 1 addition & 1 deletion vm/environment.cpp
Expand Up @@ -103,7 +103,7 @@ namespace rubinius {

check_io_descriptors();

root_vm = shared->new_vm();
root_vm = shared->new_vm("rbx.ruby.main");
root_vm->metrics().init(metrics::eRubyMetrics);
state = new State(root_vm);

Expand Down
3 changes: 1 addition & 2 deletions vm/gc/finalize.hpp
@@ -1,7 +1,6 @@
#ifndef RBX_GC_FINALIZE_HPP
#define RBX_GC_FINALIZE_HPP

#include "lock.hpp"
#include "internal_threads.hpp"

#include "gc/finalize.hpp"
Expand Down Expand Up @@ -59,7 +58,7 @@ namespace rubinius {
typedef std::list<FinalizeObject> FinalizeObjects;
typedef std::list<FinalizeObjects*> FinalizeObjectsList;

class FinalizerThread : public InternalThread, public Lockable {
class FinalizerThread : public InternalThread {
public:
class iterator {
FinalizerThread* handler_;
Expand Down
3 changes: 1 addition & 2 deletions vm/gc/immix_marker.hpp
@@ -1,7 +1,6 @@
#ifndef RBX_GC_IMMIX_MARKER_HPP
#define RBX_GC_IMMIX_MARKER_HPP

#include "lock.hpp"
#include "internal_threads.hpp"

#include "gc/root.hpp"
Expand All @@ -13,7 +12,7 @@ namespace rubinius {
class ImmixGC;
class GCData;

class ImmixMarker : public InternalThread, public Lockable {
class ImmixMarker : public InternalThread {
ImmixGC* immix_;
GCData* data_;

Expand Down
22 changes: 17 additions & 5 deletions vm/gc/managed.cpp
Expand Up @@ -5,16 +5,28 @@
#include "shared_state.hpp"
#include "metrics.hpp"

#include <sstream>

namespace rubinius {
utilities::thread::ThreadData<ManagedThread*> _current_thread;

ManagedThread::ManagedThread(uint32_t id, SharedState& ss, ManagedThread::Kind kind)
: shared_(ss)
, name_(kind == eRuby ? "<ruby>" : "<system>")
ManagedThread::ManagedThread(uint32_t id, SharedState& ss,
ManagedThread::Kind kind, const char* name)
: Lockable(true)
, shared_(ss)
, run_state_(eIndependent)
, kind_(kind)
, os_thread_(pthread_self())
, id_(id)
{
if(name) {
name_ = std::string(name);
} else {
std::ostringstream thread_name;
thread_name << "rbx.ruby." << id_;
name_ = thread_name.str();
}

metrics_.init(metrics::eNone);
}

Expand All @@ -28,9 +40,9 @@ namespace rubinius {
return _current_thread.get();
}

void ManagedThread::set_current(ManagedThread* th, std::string name) {
void ManagedThread::set_current_thread(ManagedThread* th) {
utilities::thread::Thread::set_os_name(th->name().c_str());
th->os_thread_ = pthread_self();
th->set_name(name);
_current_thread.set(th);
}
}
21 changes: 8 additions & 13 deletions vm/gc/managed.hpp
Expand Up @@ -10,6 +10,7 @@

#include <algorithm>
#include <vector>
#include <string>

namespace rubinius {
class SharedState;
Expand All @@ -24,7 +25,8 @@ namespace rubinius {
friend class WorldState;

enum Kind {
eRuby, eSystem
eRuby,
eSystem
};

enum RunState {
Expand All @@ -51,9 +53,12 @@ namespace rubinius {
uint32_t id_;

public:
ManagedThread(uint32_t id, SharedState& ss, Kind kind);
ManagedThread(uint32_t id, SharedState& ss, Kind kind, const char* name);
~ManagedThread();

static void set_current_thread(ManagedThread* vm);
static ManagedThread* current();

Roots& roots() {
return roots_;
}
Expand Down Expand Up @@ -99,19 +104,13 @@ namespace rubinius {
}

VM* as_vm() {
if(kind_ == eRuby) return reinterpret_cast<VM*>(this);
return 0;
return reinterpret_cast<VM*>(this);
}

std::string name() const {
return name_;
}

void set_name(std::string name) {
name_ = name;
utilities::thread::Thread::set_os_name(name.c_str());
}

uint32_t thread_id() const {
return id_;
}
Expand All @@ -131,10 +130,6 @@ namespace rubinius {
metrics::MetricsData& metrics() {
return metrics_;
}

public:
static ManagedThread* current();
static void set_current(ManagedThread* vm, std::string name);
};
}

Expand Down

0 comments on commit 2dc04f1

Please sign in to comment.