Skip to content

Commit c1f479d

Browse files
committedOct 10, 2015
Merge branch 'master' into 2.2
* master: Fixes to assist building Rubinius under Alpine Linux (with musl). Changed "of the issue" to "if the issue" Contributing notes on version managers/releases Expand $PID in Metrics filename. Clean up log output of serial_debug/ic_debug Specify `superclass` in respect to `prepend` Fix correction to documentation for OnStack class. Fixed typ in the OnStack class Log class names for invalid ivars_ references Add a C-API "rb_hash_clear" Fix Range#bsearch for matching end value in find-minimum mode Fix String#split with 0 limit. Fixes #3474 Add a String#split spec with 0 limit
2 parents f56eacf + 2920c9e commit c1f479d

File tree

18 files changed

+115
-38
lines changed

18 files changed

+115
-38
lines changed
 

‎CONTRIBUTING.md

+21
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ Gist:
2727
These two files contain the output of the compilation process and the various
2828
configuration options used (e.g. compiler options).
2929

30+
### Version Managers
31+
32+
We can *not* help you with any issues that might be caused by a Ruby version
33+
manager. In the event of any issues please try building from source instead to
34+
see if the issue is caused by Rubinius itself or your version manager of choice.
35+
36+
Issues involving version managers will be closed if they can either not be
37+
reproduced when building from source, or when the original report makes no
38+
mention about the author having tried building from source.
39+
40+
Note that this only applies to the installation procedure. Problems with the
41+
runtime can of course still be reported, even when using a version manager.
42+
43+
### Rubinius Versions
44+
45+
Rubinius releases quite often, at least more often than most other
46+
implementations. As such we ask users to try out the latest version prior to
47+
reporting an issue. This ensures we don't have to start digging through the
48+
code, only to find out the problem has already been resolved in a more recent
49+
release.
50+
3051
### Running Specs
3152

3253
MSpec provides several different scripts to run the specs under different

‎kernel/common/range.rb

+22-22
Original file line numberDiff line numberDiff line change
@@ -51,47 +51,47 @@ def bsearch
5151

5252
last_true = nil
5353

54-
if max < 0 and min < 0
55-
value = min + (max - min) / 2
56-
elsif min < -max
57-
value = -((-1 - min - max) / 2 + 1)
58-
else
59-
value = (min + max) / 2
60-
end
61-
62-
while min < max
63-
x = yield value
54+
seeker = Proc.new do |current|
55+
x = yield current
6456

65-
return value if x == 0
57+
return current if x == 0
6658

6759
case x
6860
when Numeric
6961
if x > 0
70-
min = value + 1
62+
min = current + 1
7163
else
72-
max = value
64+
max = current
7365
end
7466
when true
75-
last_true = value
76-
max = value
67+
last_true = current
68+
max = current
7769
when false, nil
78-
min = value + 1
70+
min = current + 1
7971
else
8072
raise TypeError, "Range#bsearch block must return Numeric or boolean"
8173
end
74+
end
8275

76+
while min < max
8377
if max < 0 and min < 0
84-
value = min + (max - min) / 2
78+
mid = min + (max - min) / 2
8579
elsif min < -max
86-
value = -((-1 - min - max) / 2 + 1)
80+
mid = -((-1 - min - max) / 2 + 1)
8781
else
88-
value = (min + max) / 2
89-
end
82+
mid = (min + max) / 2
83+
end
84+
85+
seeker.call mid
86+
end
87+
88+
if min == max
89+
seeker.call min
9090
end
9191

9292
if min < max
93-
return @begin if value == start
94-
return @begin.kind_of?(Float) ? value.to_f : value
93+
return @begin if mid == start
94+
return @begin.kind_of?(Float) ? mid.to_f : mid
9595
end
9696

9797
if last_true

‎kernel/common/splitter.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def self.split(string, pattern, limit)
3232
return [string.dup] if limit == 1
3333
limited = true
3434
else
35-
tail_empty = true
35+
if limit < 0
36+
tail_empty = true
37+
end
3638
limited = false
3739
end
3840
end

‎rakelib/platform.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ file 'runtime/platform.conf' => deps do |task|
752752

753753
Rubinius::FFI::Generators::Constants.new 'rbx.platform.signal' do |cg|
754754
cg.include 'signal.h'
755-
unless BUILD_CONFIG[:windows]
755+
unless BUILD_CONFIG[:windows] or RUBY_PLATFORM.match(/linux-musl$/)
756756
cg.include 'sys/signal.h'
757757
end
758758

‎spec/ruby/core/module/prepend_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
Module.should have_public_instance_method(:prepend, true)
77
end
88

9+
it "does not affect the superclass" do
10+
Class.new { prepend Module.new }.superclass.should == Object
11+
end
12+
913
it "calls #prepend_features(self) in reversed order on each module" do
1014
ScratchPad.record []
1115

‎spec/ruby/core/string/split_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
"a\x00a b".split(' ').should == ["a\x00a", "b"]
104104
end
105105

106+
describe "when limit is zero" do
107+
it "ignores leading and continuous whitespace when string is a single space" do
108+
" now's the time ".split(' ', 0).should == ["now's", "the", "time"]
109+
end
110+
end
111+
106112
it "splits between characters when its argument is an empty string" do
107113
"hi!".split("").should == ["h", "i", "!"]
108114
"hi!".split("", -1).should == ["h", "i", "!", ""]

‎spec/ruby/optional/capi/ext/hash_spec.c

+10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ VALUE hash_spec_rb_hash_aset(VALUE self, VALUE hash, VALUE key, VALUE val) {
4040
}
4141
#endif
4242

43+
#ifdef HAVE_RB_HASH_CLEAR
44+
VALUE hash_spec_rb_hash_clear(VALUE self, VALUE hash) {
45+
return rb_hash_clear(hash);
46+
}
47+
#endif
48+
4349
#ifdef HAVE_RB_HASH_DELETE
4450
VALUE hash_spec_rb_hash_delete(VALUE self, VALUE hash, VALUE key) {
4551
return rb_hash_delete(hash, key);
@@ -148,6 +154,10 @@ void Init_hash_spec() {
148154
rb_define_method(cls, "rb_hash_aset", hash_spec_rb_hash_aset, 3);
149155
#endif
150156

157+
#ifdef HAVE_RB_HASH_CLEAR
158+
rb_define_method(cls, "rb_hash_clear", hash_spec_rb_hash_clear, 1);
159+
#endif
160+
151161
#ifdef HAVE_RB_HASH_DELETE
152162
rb_define_method(cls, "rb_hash_delete", hash_spec_rb_hash_delete, 2);
153163
#endif

‎spec/ruby/optional/capi/ext/rubyspec.h

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
#define HAVE_RB_HASH_FREEZE 1
323323
#define HAVE_RB_HASH_AREF 1
324324
#define HAVE_RB_HASH_ASET 1
325+
#define HAVE_RB_HASH_CLEAR 1
325326
#define HAVE_RB_HASH_DELETE 1
326327
#define HAVE_RB_HASH_DELETE_IF 1
327328
#define HAVE_RB_HASH_FOREACH 1

‎spec/ruby/optional/capi/hash_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@
9191
end
9292
end
9393

94+
describe "rb_hash_clear" do
95+
it "returns self that cleared keys and values" do
96+
hsh = { :key => 'value' }
97+
@s.rb_hash_clear(hsh).should equal(hsh)
98+
hsh.should == {}
99+
end
100+
end
101+
94102
describe "rb_hash_delete" do
95103
it "removes the key and returns the value" do
96104
hsh = {:chunky => 'bacon'}

‎spec/tags/ruby/core/range/bsearch_tags.txt

-1
This file was deleted.

‎vm/builtin/object.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ namespace rubinius {
137137
} else if(CompactLookupTable* clt = try_as<CompactLookupTable>(other->ivars())) {
138138
ivars(state, clt->duplicate(state));
139139
} else {
140-
utilities::logger::warn("Object::copy_object: invalid ivars_ reference");
140+
utilities::logger::warn(
141+
"Object::copy_object: invalid ivars_ reference for %s",
142+
other->class_object(state)->to_string(state, true).c_str()
143+
);
141144
};
142145
}
143146

‎vm/builtin/system.cpp

+18-7
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,21 @@ namespace rubinius {
905905

906906
if(state->shared().config.ic_debug) {
907907
String* mod_name = mod->get_name(state);
908+
908909
if(mod_name->nil_p()) {
909-
mod_name = String::create(state, "");
910+
mod_name = String::create(state, "<unknown>");
910911
}
911-
std::cout << "[IC Increase serial for " << mod_name->c_str(state) << "]" << std::endl;
912912

913-
std::cout << "[IC Reset method cache for " << mod_name->c_str(state)
914-
<< "#" << name->debug_str(state).c_str() << "]" << std::endl;
913+
std::cerr << std::endl
914+
<< "reset global/method cache for "
915+
<< mod_name->c_str(state)
916+
<< "#"
917+
<< name->debug_str(state).c_str()
918+
<< std::endl;
919+
915920
CallFrame* call_frame = calling_environment->previous;
916-
call_frame->print_backtrace(state, 6, true);
921+
922+
call_frame->print_backtrace(state, std::cerr, 6, true);
917923
}
918924

919925
return cTrue;
@@ -1338,9 +1344,14 @@ namespace rubinius {
13381344

13391345
Object* System::vm_inc_global_serial(STATE, CallFrame* calling_environment) {
13401346
if(state->shared().config.serial_debug) {
1341-
std::cout << "[Global serial increased from " << state->shared().global_serial() << "]" << std::endl;
1342-
calling_environment->print_backtrace(state, 6, true);
1347+
std::cerr << std::endl
1348+
<< "global serial increased from "
1349+
<< state->shared().global_serial()
1350+
<< std::endl;
1351+
1352+
calling_environment->print_backtrace(state, std::cerr, 6, true);
13431353
}
1354+
13441355
return Fixnum::from(state->shared().inc_global_serial(state));
13451356
}
13461357

‎vm/capi/hash.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ extern "C" {
2626
return capi_fast_call(self, rb_intern("[]="), 2, key, value);
2727
}
2828

29+
VALUE rb_hash_clear(VALUE self) {
30+
return capi_fast_call(self, rb_intern("clear"), 0);
31+
}
32+
2933
VALUE rb_hash_delete(VALUE self, VALUE key) {
3034
return capi_fast_call(self, rb_intern("delete"), 1, key);
3135
}

‎vm/include/capi/ruby/ruby.h

+3
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,9 @@ struct RTypedData {
14531453
/** Set the value associated with the key. */
14541454
VALUE rb_hash_aset(VALUE self, VALUE key, VALUE value);
14551455

1456+
/** Clear the Hash object */
1457+
VALUE rb_hash_clear(VALUE self);
1458+
14561459
/** Remove the key and return the associated value. */
14571460
VALUE rb_hash_delete(VALUE self, VALUE key);
14581461

‎vm/metrics.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ namespace rubinius {
3939
using namespace utilities;
4040

4141
namespace metrics {
42-
FileEmitter::FileEmitter(MetricsMap& map, std::string path)
42+
FileEmitter::FileEmitter(STATE, MetricsMap& map, std::string path)
4343
: MetricsEmitter()
4444
, metrics_map_(map)
4545
, path_(path)
4646
, fd_(-1)
4747
{
48+
// TODO: Make this a proper feature of the config facility.
49+
state->shared().env()->expand_config_value(
50+
path_, "$PID", state->shared().pid.c_str());
51+
4852
initialize();
4953
}
5054

@@ -254,7 +258,7 @@ namespace rubinius {
254258
state->shared().config.system_metrics_statsd_server.value,
255259
state->shared().config.system_metrics_statsd_prefix.value);
256260
} else if(state->shared().config.system_metrics_target.value.compare("none")) {
257-
emitter_ = new FileEmitter(metrics_map_,
261+
emitter_ = new FileEmitter(state, metrics_map_,
258262
state->shared().config.system_metrics_target.value);
259263
}
260264
}

‎vm/metrics.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ namespace rubinius {
299299
int fd_;
300300

301301
public:
302-
FileEmitter(MetricsMap& map, std::string path);
302+
FileEmitter(STATE, MetricsMap& map, std::string path);
303303
virtual ~FileEmitter();
304304

305305
void send_metrics();

‎vm/on_stack.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace rubinius {
3131
// what we do is validate the type of o1, as expanded by the template,
3232
// is an Object* or subclass.
3333
//
34-
// Thats what the static_cast<> here does. It will only compiled iff the
35-
// type of o1 is Object* or a subclass.
34+
// That's what the static_cast<> here does. It will be compiled if and
35+
// only if the type of o1 is Object* or a subclass.
3636
//
3737
// When compiled though, because it's completely unused, it disappears, thus
3838
// we've added a compile time type check.

‎vm/util/logger.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <time.h>
1111
#include <sys/param.h>
1212
#include <sys/stat.h>
13+
#include <sys/file.h>
1314

1415
#include <zlib.h>
1516

0 commit comments

Comments
 (0)
Please sign in to comment.