Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/master' into 2.0.0pre

Conflicts:
	.gitignore
	Rakefile
	configure
	lib/timeout.rb
	spec/tags/18/ruby/core/argf/gets_tags.txt
	spec/tags/18/ruby/core/argf/readline_tags.txt
	spec/tags/18/ruby/library/openstruct/method_missing_tags.txt
	vm/agent_components.cpp
	vm/builtin/data.cpp
	vm/capi/include/ruby.h
	vm/configuration.hpp
	vm/gc/baker.cpp
	vm/gc/immix.cpp
	vm/gc/marksweep.cpp
	vm/gc/walker.cpp
	vm/inline_cache.cpp
	vm/objectmemory.cpp
  • Loading branch information...
commit f79f0c920b3982eca1190efd677a7ce3748ad73d 2 parents 7806103 + 0764ce3
@brixen brixen authored
Showing with 476 additions and 280 deletions.
  1. +2 −0  AUTHORS
  2. +1 −1  Rakefile
  3. +14 −8 configure
  4. +5 −3 kernel/common/argf.rb
  5. +1 −1  kernel/common/compiled_method.rb
  6. +8 −10 kernel/common/string.rb
  7. +6 −0 lib/expect.rb
  8. +1 −1  lib/ostruct.rb
  9. +6 −2 lib/socket.rb
  10. +5 −0 rakelib/install.rake
  11. +44 −0 spec/core/compiledmethod/locate_line_spec.rb
  12. +12 −0 spec/ruby/library/openstruct/element_reference_spec.rb
  13. +14 −0 spec/ruby/library/openstruct/element_set_spec.rb
  14. +0 −20 spec/ruby/library/openstruct/method_missing_spec.rb
  15. +0 −1  spec/tags/18/ruby/core/argf/gets_tags.txt
  16. +0 −1  spec/tags/18/ruby/core/argf/readline_tags.txt
  17. +0 −2  spec/tags/18/ruby/library/openstruct/method_missing_tags.txt
  18. +0 −2  spec/tags/19/ruby/core/argf/gets_tags.txt
  19. +0 −2  spec/tags/19/ruby/core/argf/readline_tags.txt
  20. +0 −2  spec/tags/20/ruby/core/argf/gets_tags.txt
  21. +0 −2  spec/tags/20/ruby/core/argf/readline_tags.txt
  22. +1 −1  vm/agent.cpp
  23. +1 −1  vm/agent_components.cpp
  24. +5 −1 vm/builtin/block_environment.cpp
  25. +1 −1  vm/builtin/compiledmethod.cpp
  26. +8 −6 vm/builtin/data.cpp
  27. +11 −4 vm/builtin/data.hpp
  28. +3 −3 vm/builtin/executable.cpp
  29. +1 −1  vm/builtin/find_object.cpp
  30. +6 −6 vm/builtin/heap_dump.cpp
  31. +11 −37 vm/builtin/nativemethod.cpp
  32. +1 −0  vm/builtin/string.cpp
  33. +1 −0  vm/builtin/tuple.cpp
  34. +10 −0 vm/capi/18/include/defines.h
  35. +8 −10 vm/capi/data.cpp
  36. +74 −0 vm/capi/handle.cpp
  37. +55 −2 vm/capi/handle.hpp
  38. +1 −24 vm/capi/tag.hpp
  39. +7 −7 vm/config_parser.cpp
  40. +4 −4 vm/config_parser.hpp
  41. +10 −3 vm/configuration.hpp
  42. +6 −6 vm/gc/baker.cpp
  43. +1 −1  vm/gc/gc.cpp
  44. +5 −5 vm/gc/immix.cpp
  45. +3 −3 vm/gc/inflated_headers.cpp
  46. +6 −6 vm/gc/marksweep.cpp
  47. +3 −3 vm/gc/walker.cpp
  48. +1 −1  vm/gc/write_barrier.cpp
  49. +6 −6 vm/inline_cache.cpp
  50. +1 −1  vm/linkedlist.cpp
  51. +1 −1  vm/linkedlist.hpp
  52. +1 −1  vm/llvm/cfg.hpp
  53. +1 −1  vm/llvm/jit_compiler.cpp
  54. +3 −3 vm/llvm/jit_runtime.cpp
  55. +1 −1  vm/llvm/jit_visit.hpp
  56. +8 −8 vm/llvm/passes.cpp
  57. +14 −12 vm/objectmemory.cpp
  58. +1 −0  vm/ontology.cpp
  59. +4 −4 vm/symboltable.cpp
  60. +0 −14 vm/test/capi/test_handles.hpp
  61. +6 −5 vm/test/test_objectmemory.hpp
  62. +14 −14 vm/util/bert.hpp
  63. +47 −10 vm/util/configuration.hpp
  64. +4 −4 vm/util/immix.hpp
  65. +1 −1  vm/vmmethod.cpp
View
2  AUTHORS
@@ -141,10 +141,12 @@
- Patrick Hurley:
- Paul Meserve:
- Paul Thornthwaite:
+- Pavel Argentov: { irc: argent-smith, github: argent-smith }
- Pedro Del Gallego:
- Phil Hagelberg: { irc: technomancy }
- Philipp Bruschweiler:
- Pierre Yager:
+- Przemek Owczarek: { github: nazgob, twitter: powczarek }
- Ragnar Dahlen:
- Richard Heycock:
- Ruben Nine:
View
2  Rakefile
@@ -33,7 +33,7 @@ end
require config_rb
BUILD_CONFIG = Rubinius::BUILD_CONFIG
-unless BUILD_CONFIG[:config_version] == 134
+unless BUILD_CONFIG[:config_version] == 135
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
View
22 configure
@@ -91,6 +91,7 @@ class Configure
@include20dir = root + "/vm/capi/19/include"
@libdir = root
@runtime = @libdir + "/runtime"
+ @kernel_path = @libdir + "/kernel"
@lib_path = @libdir + "/lib"
@ext_path = @libdir + "/lib/ext"
@mandir = root + "/man"
@@ -110,7 +111,7 @@ class Configure
@libversion = "2.0"
@version = "#{@libversion}.0dev"
@release_date = "yyyy-mm-dd"
- @config_version = 134
+ @config_version = 135
# TODO: add conditionals for platforms
if RbConfig::CONFIG["build_os"] =~ /darwin/
@@ -252,6 +253,7 @@ class Configure
@include20dir = dir + "/19/include"
@libdir = dir
@runtime = @libdir + "/runtime"
+ @kernel_path = @libdir + "/kernel"
@lib_path = @libdir + "/lib"
@ext_path = @libdir + "/lib/ext"
@mandir = dir + "/man"
@@ -275,14 +277,15 @@ class Configure
end
o.on "-L", "--libdir", "PATH", "Install Ruby library in PATH" do |dir|
- @install = true
- @libdir = expand(dir) + "/rubinius/#{@libversion}"
- @runtime = @libdir + "/runtime"
- @lib_path = @libdir + "/lib"
- @ext_path = @libdir + "/lib/ext"
+ @install = true
+ @libdir = expand(dir) + "/rubinius/#{@libversion}"
+ @runtime = @libdir + "/runtime"
+ @kernel_path = @libdir + "/kernel"
+ @lib_path = @libdir + "/lib"
+ @ext_path = @libdir + "/lib/ext"
- @sitedir = @libdir + "/site"
- @vendordir = @libdir + "/vendor"
+ @sitedir = @libdir + "/site"
+ @vendordir = @libdir + "/vendor"
end
o.on "-M", "--mandir", "PATH", "Install man pages in PATH" do |dir|
@@ -948,6 +951,7 @@ module Rubinius
:bindir => "#{@bindir}",
:libdir => "#{@libdir}",
:runtime => "#{@runtime}",
+ :kernel_path => "#{@kernel_path}",
:lib_path => "#{@lib_path}",
:ext_path => "#{@ext_path}",
:include18dir => "#{@include18dir}",
@@ -988,6 +992,7 @@ end
#define RBX_BIN_PATH "#{@bindir}"
#define RBX_GEMS_PATH "#{@gemsdir}"
#define RBX_RUNTIME "#{@runtime}"
+#define RBX_KERNEL_PATH "#{@kernel_path}"
#define RBX_LIB_PATH "#{@lib_path}"
#define RBX_EXT_PATH "#{@ext_path}"
#define RBX_HDR18_PATH "#{@include18dir}"
@@ -1042,6 +1047,7 @@ end
#define RBX_BIN_PATH "#{@bindir}"
#define RBX_GEMS_PATH "#{@gemsdir}"
#define RBX_RUNTIME "#{@runtime}"
+#define RBX_KERNEL_PATH "#{@kernel_path}"
#define RBX_LIB_PATH "#{@lib_path}"
#define RBX_EXT_PATH "#{@ext_path}"
#define RBX_HDR18_PATH "#{@include18dir}"
View
8 kernel/common/argf.rb
@@ -489,6 +489,8 @@ def advance!
@init = true
end
+ File.unlink(@backup_filename) if @backup_filename && $-i == ""
+
return false if @use_stdin_only || ARGV.empty?
@advance = false
@@ -498,11 +500,11 @@ def advance!
@filename = file
if $-i && @stream != STDIN
- @original_stdout = $stdout
- @backup_filename = "#{@filename}#{$-i}"
+ backup_extension = $-i == "" ? ".bak" : $-i
+ @backup_filename = "#{@filename}#{backup_extension}"
File.rename(@filename, @backup_filename)
@stream = File.open(@backup_filename, "r")
- $stdout = @current_output = File.open(@filename, "w")
+ $stdout = File.open(@filename, "w")
end
return true
View
2  kernel/common/compiled_method.rb
@@ -363,7 +363,7 @@ def change_name(name)
# nil if nothing is found, else an array of size 2 containing the method
# the line was found in and the IP pointing there.
def locate_line(line)
- ip = 1
+ i = 1
total = @lines.size
while i < total
cur_line = @lines.at(i)
View
18 kernel/common/string.rb
@@ -1183,25 +1183,23 @@ def insert(index, other)
osize = other.size
size = @num_bytes + osize
- str = self.class.new("\0") * size
+ str = self.class.pattern size, "\0"
index = @num_bytes + 1 + index if index < 0
if index > @num_bytes or index < 0 then
raise IndexError, "index #{index} out of string"
end
- modify!
+ Ruby.check_frozen
+ hash_value = nil
- if index == 0
- str.copy_from other, 0, osize, 0
- str.copy_from self, 0, @num_bytes, osize
- elsif index < @num_bytes
- str.copy_from self, 0, index, 0
- str.copy_from other, 0, osize, index
- str.copy_from self, index, @num_bytes - index, index + osize
- else
+ if index == @num_bytes
str.copy_from self, 0, @num_bytes, 0
str.copy_from other, 0, osize, @num_bytes
+ else
+ str.copy_from self, 0, index, 0 if index > 0
+ str.copy_from other, 0, osize, index
+ str.copy_from self, index, @num_bytes - index, index + osize
end
@num_bytes = size
View
6 lib/expect.rb
@@ -4,6 +4,12 @@
$expect_verbose = false
class IO
+ # Reads ios until pattern matches or the timeout is over. It returns
+ # an array with the read buffer, followed by the matches. If a block is given,
+ # the result is yielded to the block and returns nil. The optional timeout parameter defines,
+ # in seconds, the total time to wait for pattern. If it is over of eof is found, it
+ # returns/yields nil. However, the buffer in a timeout session is kept for the next expect call.
+ # The default timeout is 9999999 seconds.
def expect(pat,timeout=9999999)
case pat
when String
View
2  lib/ostruct.rb
@@ -89,7 +89,7 @@ class << self; self; end.class_eval do
def method_missing(mid, *args) # :nodoc:
mname = mid.id2name
len = args.length
- if mname.chomp!('=')
+ if mname.chomp!('=') && mname != "[]"
if len != 1
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
end
View
8 lib/socket.rb
@@ -1068,8 +1068,12 @@ def tcp_setup(remote_host, remote_service, local_host = nil,
i[1] == family && i[2] == socket_type
end
- status = Socket::Foreign.bind sock, li[4]
- syscall = 'bind(2)'
+ if li
+ status = Socket::Foreign.bind sock, li[4]
+ syscall = 'bind(2)'
+ else
+ status = 1
+ end
else
status = 1
end
View
5 rakelib/install.rake
@@ -107,6 +107,11 @@ namespace :install do
install_file name, /^runtime/, BUILD_CONFIG[:runtime]
end
+ # Install the .rb files for the core library (kernel).
+ FileList['kernel/**/*.rb'].each do |name|
+ install_file name, /^kernel/, BUILD_CONFIG[:kernel_path]
+ end
+
# Install the .rb files for the standard library. This is a
# separate block from the .rbc files so that the .rb files
# have an older timestamp and do not trigger recompiling.
View
44 spec/core/compiledmethod/locate_line_spec.rb
@@ -0,0 +1,44 @@
+module CompiledMethodSpec
+ LineTest = def line_test
+ 1 + 1
+ 2 + 2
+ end
+
+ BlockLineTest = def block_line_test
+ 1 + 1
+ 1.times do
+ 2 + 2
+ end
+ end
+end
+
+# Line numbers are important! Thats why the above module is in
+# this file and not a fixture.
+
+describe "Rubinius::CompiledMethod#locate_line" do
+ it "finds the ip for a line" do
+ cm, ip = CompiledMethodSpec::LineTest.locate_line(4)
+ ip.should == 5
+ end
+
+ it "returns the CompiledMethod the ip is in" do
+ cm, ip = CompiledMethodSpec::LineTest.locate_line(3)
+ cm.should == CompiledMethodSpec::LineTest
+ end
+
+ it "returns nil if the line can't be found" do
+ CompiledMethodSpec::LineTest.locate_line(50).should be_nil
+ end
+
+ it "returns nil if the line is the definition line" do
+ CompiledMethodSpec::LineTest.locate_line(2).should be_nil
+ end
+
+ it "searches blocks for the line" do
+ cm, ip = CompiledMethodSpec::BlockLineTest.locate_line(10)
+ blk = CompiledMethodSpec::BlockLineTest.literals.to_a.grep(Rubinius::CompiledMethod).first
+
+ cm.should == blk
+ ip.should == 0
+ end
+end
View
12 spec/ruby/library/openstruct/element_reference_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require "ostruct"
+
+describe "OpenStruct#[]" do
+ before :each do
+ @os = OpenStruct.new
+ end
+
+ it "raises a NoMethodError" do
+ lambda { @os[1] }.should raise_error(NoMethodError)
+ end
+end
View
14 spec/ruby/library/openstruct/element_set_spec.rb
@@ -0,0 +1,14 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require "ostruct"
+
+describe "OpenStruct#[]=" do
+ before :each do
+ @os = OpenStruct.new
+ end
+
+ ruby_bug "redmine:4179", "1.9.2" do
+ it "raises a NoMethodError" do
+ lambda { @os[1] = 2 }.should raise_error(NoMethodError)
+ end
+ end
+end
View
20 spec/ruby/library/openstruct/method_missing_spec.rb
@@ -45,23 +45,3 @@
os.method_missing(:name).should be_nil
end
end
-
-ruby_bug "redmine:4179", "1.9.2" do
- describe "OpenStruct#method_missing when called with method name '[]'" do
- it "raises a NoMethodError" do
- os = OpenStruct.new
- lambda { os.method_missing(:[]) }.should raise_error(NoMethodError)
- lambda { os.method_missing(:[], 1) }.should raise_error(NoMethodError)
- lambda { os.method_missing(:[], 1, 2) }.should raise_error(NoMethodError)
- end
- end
-
- describe "OpenStruct#method_missing when called with method name '[]='" do
- it "raises a NoMethodError" do
- os = OpenStruct.new
- lambda { os.method_missing(:[]=, 1) }.should raise_error(NoMethodError)
- lambda { os.method_missing(:[]=, 1, 2) }.should raise_error(NoMethodError)
- lambda { os.method_missing(:[]=, 1, 2, 3) }.should raise_error(NoMethodError)
- end
- end
-end
View
1  spec/tags/18/ruby/core/argf/gets_tags.txt
@@ -1 +0,0 @@
-fails:ARGF.gets modifies the files when in place edit mode is on
View
1  spec/tags/18/ruby/core/argf/readline_tags.txt
@@ -1 +0,0 @@
-fails:ARGF.readline modifies the files when in place edit mode is on
View
2  spec/tags/18/ruby/library/openstruct/method_missing_tags.txt
@@ -1,2 +0,0 @@
-fails:OpenStruct#method_missing when called with method name '[]' raises a NoMethodError
-fails:OpenStruct#method_missing when called with method name '[]=' raises a NoMethodError
View
2  spec/tags/19/ruby/core/argf/gets_tags.txt
@@ -1,2 +0,0 @@
-fails:ARGF.gets modifies the files when in place edit mode is on
-fails:ARGF.gets modifies and backups two files when in place edit mode is on
View
2  spec/tags/19/ruby/core/argf/readline_tags.txt
@@ -1,2 +0,0 @@
-fails:ARGF.readline modifies the files when in place edit mode is on
-fails:ARGF.readline modifies and backups two files when in place edit mode is on
View
2  spec/tags/20/ruby/core/argf/gets_tags.txt
@@ -1,2 +0,0 @@
-fails:ARGF.gets modifies the files when in place edit mode is on
-fails:ARGF.gets modifies and backups two files when in place edit mode is on
View
2  spec/tags/20/ruby/core/argf/readline_tags.txt
@@ -1,2 +0,0 @@
-fails:ARGF.readline modifies the files when in place edit mode is on
-fails:ARGF.readline modifies and backups two files when in place edit mode is on
View
2  vm/agent.cpp
@@ -388,7 +388,7 @@ namespace rubinius {
continue;
}
}
- i++;
+ ++i;
}
if(!found) {
View
2  vm/agent_components.cpp
@@ -297,7 +297,7 @@ namespace agent {
for(std::list<ManagedThread*>::iterator i = threads->begin();
i != threads->end();
- i++) {
+ ++i) {
if(VM* vm = (*i)->as_vm()) {
std::ostringstream ss;
vm->saved_call_frame()->print_backtrace(state_, ss);
View
6 vm/builtin/block_environment.cpp
@@ -389,9 +389,13 @@ namespace rubinius {
// over again (ie Proc.new) so we mark the method as not
// inlinable so that this works even with the JIT on.
+ if(!target) {
+ return Qnil;
+ }
+
target->cm->backend_method()->set_no_inline();
- if(target && target->scope) {
+ if(target->scope) {
return target->scope->block();
}
View
2  vm/builtin/compiledmethod.cpp
@@ -302,7 +302,7 @@ namespace rubinius {
for(IndirectLiterals::iterator i = vmm->indirect_literals().begin();
i != vmm->indirect_literals().end();
- i++) {
+ ++i) {
Object** ptr = (*i);
if((tmp = mark.call(*ptr)) != NULL) {
*ptr = tmp;
View
14 vm/builtin/data.cpp
@@ -40,6 +40,8 @@ namespace rubinius {
rdata->dmark = mark;
rdata->dfree = free;
+ data->internal_ = rdata;
+
// If this Data requires a free function, register this object
// as needing finalization.
if(free) {
@@ -49,7 +51,7 @@ namespace rubinius {
return data;
}
- RDataShadow* Data::rdata(STATE) {
+ RDataShadow* Data::slow_rdata(STATE) {
InflatedHeader* ih = state->om->inflate_header(state, this);
capi::Handle* handle = ih->handle();
@@ -90,17 +92,17 @@ namespace rubinius {
}
void Data::Info::mark(Object* t, ObjectMark& mark) {
- auto_mark(t, mark);
+ // auto_mark(t, mark);
- STATE = mark.gc->state();
+ Data* data = force_as<Data>(t);
- Data* data = as<Data>(t);
+ RDataShadow* rdata = data->rdata();
- if(data->mark(state)) {
+ if(rdata->dmark) {
ObjectMark* cur = capi::current_mark();
capi::set_current_mark(&mark);
- (*data->mark(state))(data->data(state));
+ (*rdata->dmark)(rdata->data);
capi::set_current_mark(cur);
}
View
15 vm/builtin/data.hpp
@@ -25,9 +25,7 @@ namespace rubinius {
typedef void (*FreeFunctor)(void*);
private:
- void (*dmark_)(void*);
- void (*dfree_)(void*);
- void *data_;
+ RDataShadow* internal_;
public: /* Interface */
@@ -39,7 +37,16 @@ namespace rubinius {
static void finalize(STATE, Data* data);
- RDataShadow* rdata(STATE);
+ RDataShadow* rdata(STATE) {
+ return internal_;
+ }
+
+ RDataShadow* rdata() {
+ return internal_;
+ }
+
+ RDataShadow* slow_rdata(STATE);
+
void* data(STATE);
FreeFunctor free(STATE);
MarkFunctor mark(STATE);
View
6 vm/builtin/executable.cpp
@@ -78,7 +78,7 @@ namespace rubinius {
if(!inliners_ || inliners_ == (Inliners*)Qnil) return;
for(std::list<CompiledMethod*>::const_iterator i = inliners_->inliners().begin();
i != inliners_->inliners().end();
- i++) {
+ ++i) {
(*i)->backend_method()->deoptimize(state, *i);
}
@@ -101,7 +101,7 @@ namespace rubinius {
for(std::list<CompiledMethod*>::iterator i = inl->inliners().begin();
i != inl->inliners().end();
- i++) {
+ ++i) {
CompiledMethod* cm = *i;
Object* tmp = mark.call(cm);
@@ -126,7 +126,7 @@ namespace rubinius {
if(exc->inliners_) {
for(std::list<CompiledMethod*>::iterator i = exc->inliners_->inliners().begin();
i != exc->inliners_->inliners().end();
- i++) {
+ ++i) {
visit.call(*i);
}
}
View
2  vm/builtin/find_object.cpp
@@ -160,7 +160,7 @@ namespace rubinius {
TypeInfo* ti = state->om->type_info[obj->type_id()];
for(TypeInfo::Slots::iterator i = ti->slots.begin();
i != ti->slots.end();
- i++) {
+ ++i) {
Symbol* sym = Symbol::from_index(i->first);
if(obj->get_ivar(state, sym) == target_) return true;
}
View
12 vm/builtin/heap_dump.cpp
@@ -176,7 +176,7 @@ namespace rubinius {
~Layout() {
for(LayoutMapping::iterator i = subtrees_.begin();
i != subtrees_.end();
- i++) {
+ ++i) {
delete i->second;
}
}
@@ -209,7 +209,7 @@ namespace rubinius {
std::vector<int> sym_ids;
for(SymbolList::iterator i = syms.begin();
i != syms.end();
- i++) {
+ ++i) {
sym_ids.push_back(enc.initialize_symbol(state, *i));
}
@@ -218,7 +218,7 @@ namespace rubinius {
for(std::vector<int>::iterator i = sym_ids.begin();
i != sym_ids.end();
- i++) {
+ ++i) {
enc.write4(*i);
}
}
@@ -233,7 +233,7 @@ namespace rubinius {
TypeInfo* ti = state->om->type_info[obj->type_id()];
for(TypeInfo::Slots::iterator i = ti->slots.begin();
i != ti->slots.end();
- i++) {
+ ++i) {
syms.push_back(Symbol::from_index(i->first));
}
@@ -255,7 +255,7 @@ namespace rubinius {
// Look down the Layout tree to find the one we want.
for(SymbolList::iterator i = syms.begin();
i != syms.end();
- i++) {
+ ++i) {
current = current->find_subtree(*i);
}
@@ -369,7 +369,7 @@ namespace rubinius {
void dump_ivars(STATE, Object* obj, SymbolList& syms) {
for(SymbolList::iterator i = syms.begin();
i != syms.end();
- i++) {
+ ++i) {
dump_reference(state, obj->get_ivar(state, *i));
}
}
View
48 vm/builtin/nativemethod.cpp
@@ -43,12 +43,7 @@ namespace rubinius {
NativeMethodFrame::~NativeMethodFrame() {
flush_cached_data();
- for(capi::HandleSet::iterator i = handles_.begin();
- i != handles_.end();
- i++) {
- capi::Handle* handle = *i;
- handle->deref();
- }
+ handles_.deref_all();
}
void NativeMethodFrame::check_tracked_handle(capi::Handle* handle,
@@ -58,14 +53,9 @@ namespace rubinius {
check_handles_ = true;
}
- // ref() ONLY if it's not already in there!
- // otherwise the refcount is wrong and we leak handles.
- capi::HandleSet::iterator pos = handles_.find(handle);
- if(pos == handles_.end()) {
+ if(handles_.add_if_absent(handle)) {
// We're seeing this object for the first time in this function.
// Be sure that it's updated.
- handle->ref();
- handles_.insert(handle);
handle->update(NativeMethodEnvironment::get());
}
}
@@ -76,14 +66,9 @@ namespace rubinius {
capi::Handle* handle = ih->handle();
if(handle) {
- // ref() ONLY if it's not already in there!
- // otherwise the refcount is wrong and we leak handles.
- capi::HandleSet::iterator pos = handles_.find(handle);
- if(pos == handles_.end()) {
+ if(handles_.add_if_absent(handle)) {
// We're seeing this object for the first time in this function.
// Be sure that it's updated.
- handle->ref();
- handles_.insert(handle);
handle->update(NativeMethodEnvironment::get());
}
} else {
@@ -92,8 +77,7 @@ namespace rubinius {
state->shared.add_global_handle(state, handle);
- handle->ref();
- handles_.insert(handle);
+ handles_.add_if_absent(handle);
}
return handle->as_value();
@@ -107,12 +91,7 @@ namespace rubinius {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
if(check_handles_) {
- for(capi::HandleSet::iterator i = handles_.begin();
- i != handles_.end();
- i++) {
- capi::Handle* handle = *i;
- handle->flush(env);
- }
+ handles_.flush_all(env);
}
if(env->state()->shared.config.capi_global_flush) {
@@ -130,12 +109,7 @@ namespace rubinius {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
if(check_handles_) {
- for(capi::HandleSet::iterator i = handles_.begin();
- i != handles_.end();
- i++) {
- capi::Handle* handle = *i;
- handle->update(env);
- }
+ handles_.update_all(env);
}
if(env->state()->shared.config.capi_global_flush) {
@@ -242,7 +216,7 @@ namespace rubinius {
static Object* invoke(STATE, NativeMethod* nm, NativeMethodEnvironment* env,
Arguments& args)
{
- VALUE receiver = env->get_handle(args.recv());
+ VALUE receiver = env->current_native_frame()->receiver();
return env->get_object(nm->func()(receiver));
}
};
@@ -252,7 +226,7 @@ namespace rubinius {
static Object* invoke(STATE, NativeMethod* nm, NativeMethodEnvironment* env,
Arguments& args)
{
- VALUE receiver = env->get_handle(args.recv());
+ VALUE receiver = env->current_native_frame()->receiver();
VALUE a1 = env->get_handle(args.get_argument(0));
return env->get_object(nm->func()(receiver, a1));
@@ -264,7 +238,7 @@ namespace rubinius {
static Object* invoke(STATE, NativeMethod* nm, NativeMethodEnvironment* env,
Arguments& args)
{
- VALUE receiver = env->get_handle(args.recv());
+ VALUE receiver = env->current_native_frame()->receiver();
VALUE a1 = env->get_handle(args.get_argument(0));
VALUE a2 = env->get_handle(args.get_argument(1));
@@ -277,7 +251,7 @@ namespace rubinius {
static Object* invoke(STATE, NativeMethod* nm, NativeMethodEnvironment* env,
Arguments& args)
{
- VALUE receiver = env->get_handle(args.recv());
+ VALUE receiver = env->current_native_frame()->receiver();
VALUE a1 = env->get_handle(args.get_argument(0));
VALUE a2 = env->get_handle(args.get_argument(1));
VALUE a3 = env->get_handle(args.get_argument(2));
@@ -291,7 +265,7 @@ namespace rubinius {
static Object* invoke(STATE, NativeMethod* nm, NativeMethodEnvironment* env,
Arguments& args)
{
- VALUE receiver = env->get_handle(args.recv());
+ VALUE receiver = env->current_native_frame()->receiver();
switch(nm->arity()->to_int()) {
View
1  vm/builtin/string.cpp
@@ -22,6 +22,7 @@
#include <string.h>
#include <iostream>
#include <ctype.h>
+#include <stdint.h>
namespace rubinius {
View
1  vm/builtin/tuple.cpp
@@ -9,6 +9,7 @@
#include <stdarg.h>
#include <iostream>
+#include <stdint.h>
namespace rubinius {
Tuple* Tuple::bounds_exceeded_error(STATE, const char* method, int index) {
View
10 vm/capi/18/include/defines.h
@@ -18,3 +18,13 @@
#define HAVE_RB_HASH_FOREACH 1
#define HAVE_RB_HASH_ASET 1
+
+#define HAVE_TYPE_RB_BLOCKING_FUNCTION_T 1
+#define HAVE_RB_THREAD_BLOCKING_REGION 1
+
+#define HAVE_RB_IO_T 1
+#define HAVE_RB_IO_FD 1
+
+#define HAVE_RB_ERRINFO 1
+
+#define HAVE_RB_STR_PTR_READONLY 1
View
18 vm/capi/data.cpp
@@ -11,19 +11,17 @@ using namespace rubinius::capi;
namespace rubinius {
namespace capi {
- RData* Handle::as_rdata(NativeMethodEnvironment* env) {
- if(type_ != cRData) {
- type_ = cRData;
+ RData* Handle::create_rdata(NativeMethodEnvironment* env) {
+ type_ = cRData;
- RData* rdata = new RData;
- // Yes, we initialize it with garbage data. This is because when
- // Data creates this, it makes sure to initialize it before
- // anyone sees it.
+ RData* rdata = new RData;
+ // Yes, we initialize it with garbage data. This is because when
+ // Data creates this, it makes sure to initialize it before
+ // anyone sees it.
- as_.rdata = rdata;
- }
+ as_.rdata = rdata;
- return as_.rdata;
+ return rdata;
}
}
}
View
74 vm/capi/handle.cpp
@@ -77,5 +77,79 @@ namespace rubinius {
handle = next;
}
}
+
+ HandleSet::HandleSet()
+ : slow_(0)
+ {
+ for(int i = 0; i < cFastHashSize; i++) {
+ table_[i] = 0;
+ }
+ }
+
+ void HandleSet::deref_all() {
+ for(int i = 0; i < cFastHashSize; i++) {
+ if(table_[i]) table_[i]->deref();
+ }
+
+ if(slow_) {
+ for(SlowHandleSet::iterator i = slow_->begin();
+ i != slow_->end();
+ ++i) {
+ capi::Handle* handle = *i;
+ handle->deref();
+ }
+ }
+ }
+
+ void HandleSet::flush_all(NativeMethodEnvironment* env) {
+ for(int i = 0; i < cFastHashSize; i++) {
+ if(table_[i]) table_[i]->flush(env);
+ }
+
+ if(slow_) {
+ for(SlowHandleSet::iterator i = slow_->begin();
+ i != slow_->end();
+ ++i) {
+ capi::Handle* handle = *i;
+ handle->flush(env);
+ }
+ }
+ }
+
+ void HandleSet::update_all(NativeMethodEnvironment* env) {
+ for(int i = 0; i < cFastHashSize; i++) {
+ if(table_[i]) table_[i]->update(env);
+ }
+
+ if(slow_) {
+ for(SlowHandleSet::iterator i = slow_->begin();
+ i != slow_->end();
+ ++i) {
+ capi::Handle* handle = *i;
+ handle->update(env);
+ }
+ }
+ }
+
+ bool HandleSet::slow_add_if_absent(Handle* handle) {
+ for(int i = 0; i < cFastHashSize; i++) {
+ if(table_[i] == handle) return false;
+ }
+
+ SlowHandleSet::iterator pos = slow_->find(handle);
+ if(pos != slow_->end()) return false;
+
+ slow_->insert(handle);
+ handle->ref();
+
+ return true;
+ }
+
+ void HandleSet::make_slow_and_add(Handle* handle) {
+ // Inflate it to the slow set.
+ slow_ = new SlowHandleSet;
+ slow_->insert(handle);
+ handle->ref();
+ }
}
}
View
57 vm/capi/handle.hpp
@@ -151,8 +151,16 @@ namespace rubinius {
return as_.rstring;
}
+ RData* create_rdata(NativeMethodEnvironment* env);
+ RData* as_rdata(NativeMethodEnvironment* env) {
+ if(type_ == cRData) {
+ return as_.rdata;
+ } else {
+ return create_rdata(env);
+ }
+ }
+
RArray* as_rarray(NativeMethodEnvironment* env);
- RData* as_rdata(NativeMethodEnvironment* env);
RString* as_rstring(NativeMethodEnvironment* env, int cache_level);
RFloat* as_rfloat(NativeMethodEnvironment* env);
RIO* as_rio(NativeMethodEnvironment* env);
@@ -179,7 +187,52 @@ namespace rubinius {
};
- typedef std::tr1::unordered_set<Handle*> HandleSet;
+ typedef std::tr1::unordered_set<Handle*> SlowHandleSet;
+
+ class HandleSet {
+ public:
+ const static int cFastHashSize = 16;
+
+ private:
+ SlowHandleSet* slow_;
+ Handle* table_[cFastHashSize];
+
+ public:
+ HandleSet();
+ ~HandleSet() {
+ if(slow_) delete slow_;
+ }
+
+ void deref_all();
+ void flush_all(NativeMethodEnvironment* env);
+ void update_all(NativeMethodEnvironment* env);
+
+ bool add_if_absent(Handle* handle) {
+ // ref() ONLY if it's not already in there!
+ // otherwise the refcount is wrong and we leak handles.
+
+ if(unlikely(slow_)) {
+ return slow_add_if_absent(handle);
+ } else {
+ for(int i = 0; i < cFastHashSize; i++) {
+ if(!table_[i]) {
+ table_[i] = handle;
+ handle->ref();
+
+ return true;
+ }
+ if(table_[i] == handle) return false;
+ }
+
+ make_slow_and_add(handle);
+ return true;
+ }
+ }
+
+ private:
+ void make_slow_and_add(Handle* handle);
+ bool slow_add_if_absent(Handle* handle);
+ };
}
}
View
25 vm/capi/tag.hpp
@@ -27,10 +27,6 @@
* 4. "Booleans" (i.e. Qfalse, Qtrue, Qnil, Qundef)
*
* The handles are tagged to distinguish the categories of objects.
- * Further, the references are subdivided into "global" and "local"
- * handles. Global handles are used for constants like the class Array
- * (rb_cArray). Local handles are used for object references needed during
- * the execution of a single NativeMethod call.
*
* The tagging scheme allows passing Symbols and Fixnums straight through
* without changing their values. This ensures that if a C extension
@@ -49,12 +45,8 @@
* 10 0 0010 Qnil
* 11 0 0010 Qundef
*
- * xx 0 1010 global handle
- * xx 1 1010 local handle
- *
* In other words, any bit pattern ending in 1 is a Fixnum, ending in 110
- * is a Symbol, ending in 0010 is a C-API "boolean", ending in 1010 is a
- * C-API reference handle, and Qfalse is 0.
+ * is a Symbol, ending in 0010 is a C-API "boolean" and Qfalse is 0.
*/
#define CAPI_FALSE_P(v) ((VALUE)(v) == cCApiHandleQfalse)
@@ -64,22 +56,7 @@
#define CAPI_REFERENCE_TAG 0x00
#define CAPI_REFERENCE_MASK 0x03
-#define CAPI_HANDLE_MASK 0x1f
-#define CAPI_GLOBAL_HANDLE_TAG 0x0a
-#define CAPI_LOCAL_HANDLE_TAG 0x1a
-#define CAPI_REFERENCE_SHIFT 5
#define CAPI_REFERENCE_P(v) ({ VALUE __v = (VALUE)(v); __v && (__v & CAPI_REFERENCE_MASK) == CAPI_REFERENCE_TAG; })
-#define CAPI_GLOBAL_HANDLE_P(v) (((VALUE)(v) & CAPI_HANDLE_MASK) == CAPI_GLOBAL_HANDLE_TAG)
-#define CAPI_LOCAL_HANDLE_P(v) (((VALUE)(v) & CAPI_HANDLE_MASK) == CAPI_LOCAL_HANDLE_TAG)
-
-#define CAPI_APPLY_GLOBAL_TAG(v) \
- ((VALUE)(((VALUE)(v) << CAPI_REFERENCE_SHIFT) | CAPI_GLOBAL_HANDLE_TAG))
-#define CAPI_STRIP_GLOBAL_TAG(v) ((VALUE)((VALUE)(v) >> CAPI_REFERENCE_SHIFT))
-
-#define CAPI_APPLY_LOCAL_TAG(v) \
- ((VALUE)(((VALUE)(v) << CAPI_REFERENCE_SHIFT) | CAPI_LOCAL_HANDLE_TAG))
-#define CAPI_STRIP_LOCAL_TAG(v) ((VALUE)((VALUE)(v) >> CAPI_REFERENCE_SHIFT))
-
#endif
View
14 vm/config_parser.cpp
@@ -40,7 +40,7 @@ namespace rubinius {
ConfigParser::ConfigMap::iterator i = variables.begin();
while(i != variables.end()) {
delete i->second;
- i++;
+ ++i;
}
}
@@ -152,19 +152,19 @@ namespace rubinius {
variables[entry->variable] = entry;
}
- bool ConfigParser::Entry::is_number() {
+ bool ConfigParser::Entry::is_number() const {
return rubinius::is_number(value.c_str());
}
- bool ConfigParser::Entry::is_true() {
+ bool ConfigParser::Entry::is_true() const {
return value == "true";
}
- long ConfigParser::Entry::to_i() {
+ long ConfigParser::Entry::to_i() const {
return strtol(value.c_str(), NULL, 10);
}
- bool ConfigParser::Entry::in_section(std::string prefix) {
+ bool ConfigParser::Entry::in_section(std::string prefix) const {
return variable.find(prefix) == 0;
}
@@ -176,7 +176,7 @@ namespace rubinius {
if(i->second->in_section(prefix)) {
list->push_back(i->second);
}
- i++;
+ ++i;
}
return list;
@@ -185,7 +185,7 @@ namespace rubinius {
void ConfigParser::update_configuration(Configuration& config) {
for(ConfigParser::ConfigMap::iterator i = variables.begin();
i != variables.end();
- i++) {
+ ++i) {
if(!config.import(i->first.c_str(), i->second->value.c_str())) {
if(i->second->in_section("vm.") ||
i->second->in_section("jit.") ||
View
8 vm/config_parser.hpp
@@ -16,10 +16,10 @@ namespace rubinius {
std::string variable;
std::string value;
- bool is_number();
- bool is_true();
- bool in_section(std::string prefix);
- long to_i();
+ bool is_number() const;
+ bool is_true() const;
+ bool in_section(std::string prefix) const;
+ long to_i() const;
};
typedef std::map<std::string, Entry*> ConfigMap;
View
13 vm/configuration.hpp
@@ -8,15 +8,16 @@ namespace rubinius {
class Configuration : public config::Configuration {
public:
// GC
- config::Integer gc_bytes;
- config::Integer gc_large_object;
+ config::Bytes gc_bytes;
+ config::Bytes gc_large_object;
config::Integer gc_lifetime;
config::Bool gc_autotune;
config::Bool gc_show;
config::Bool gc_immix_debug;
config::Bool gc_honor_start;
config::Bool gc_autopack;
- config::Integer gc_marksweep_threshold;
+ config::Bytes gc_marksweep_threshold;
+ config::Bytes gc_malloc_threshold;
// Language
#ifdef RBX_ENABLED_18
@@ -89,6 +90,7 @@ namespace rubinius {
static const int default_jit_max_method_size = 2048;
static const bool default_jit_on = true;
static const bool default_gc_autotune = true;
+ static const int default_gc_malloc_threshold = 104857600;
Configuration()
: gc_bytes(this, "gc.bytes", default_gc_bytes)
@@ -114,6 +116,9 @@ namespace rubinius {
, version_20(this, "20", false)
#endif
+ , gc_malloc_threshold(this, "gc.malloc_threshold",
+ default_gc_malloc_threshold)
+
, dynamic_interpreter_enabled(this, "interpreter.dynamic")
, jit_dump_code(this, "jit.dump_code", default_jit_dump_code)
, jit_call_til_compile(this, "jit.call_til_compile",
@@ -168,6 +173,8 @@ namespace rubinius {
gc_marksweep_threshold.set_description(
"The number of bytes allocated before the marksweep GC region is collected");
+ gc_malloc_threshold.set_description(
+ "How many bytes allocated by C extensions til the GC is run");
#ifdef RBX_ENABLED_18
version_18.set_description(
View
12 vm/gc/baker.cpp
@@ -164,12 +164,12 @@ namespace rubinius {
for(std::list<gc::WriteBarrier*>::iterator wbi = object_memory_->aux_barriers().begin();
wbi != object_memory_->aux_barriers().end();
- wbi++) {
+ ++wbi) {
gc::WriteBarrier* wb = *wbi;
ObjectArray* rs = wb->swap_remember_set();
for(ObjectArray::iterator oi = rs->begin();
oi != rs->end();
- oi++) {
+ ++oi) {
tmp = *oi;
if(tmp) {
@@ -188,7 +188,7 @@ namespace rubinius {
if(data.threads()) {
for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
i != data.threads()->end();
- i++) {
+ ++i) {
scan(*i, true);
}
}
@@ -234,7 +234,7 @@ namespace rubinius {
if(gh) {
for(std::list<capi::Handle**>::iterator i = gh->begin();
i != gh->end();
- i++) {
+ ++i) {
capi::Handle** loc = *i;
if(capi::Handle* hdl = *loc) {
if(!CAPI_REFERENCE_P(hdl)) continue;
@@ -335,7 +335,7 @@ namespace rubinius {
if(object_memory_->running_finalizers()) {
for(std::list<FinalizeObject>::iterator i = object_memory_->finalize().begin();
i != object_memory_->finalize().end();
- i++) {
+ ++i) {
if(i->object) {
i->object = saw_object(i->object);
}
@@ -402,7 +402,7 @@ namespace rubinius {
if(remove) {
i = object_memory_->finalize().erase(i);
} else {
- i++;
+ ++i;
}
}
}
View
2  vm/gc/gc.cpp
@@ -275,7 +275,7 @@ namespace rubinius {
for(ObjectArray::iterator i = weak_refs_->begin();
i != weak_refs_->end();
- i++) {
+ ++i) {
WeakRef* ref = try_as<WeakRef>(*i);
if(!ref) continue; // WTF.
View
10 vm/gc/immix.cpp
@@ -161,7 +161,7 @@ namespace rubinius {
if(data.threads()) {
for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
i != data.threads()->end();
- i++) {
+ ++i) {
scan(*i, false);
}
}
@@ -185,7 +185,7 @@ namespace rubinius {
if(gh) {
for(std::list<capi::Handle**>::iterator i = gh->begin();
i != gh->end();
- i++) {
+ ++i) {
capi::Handle** loc = *i;
if(capi::Handle* hdl = *loc) {
if(!CAPI_REFERENCE_P(hdl)) continue;
@@ -225,7 +225,7 @@ namespace rubinius {
cleared = object_memory_->unremember_objects(mark);
for(std::list<gc::WriteBarrier*>::iterator wbi = object_memory_->aux_barriers().begin();
wbi != object_memory_->aux_barriers().end();
- wbi++) {
+ ++wbi) {
gc::WriteBarrier* wb = *wbi;
cleared += wb->unremember_objects(mark);
}
@@ -322,7 +322,7 @@ namespace rubinius {
if(object_memory_->running_finalizers()) {
for(std::list<FinalizeObject>::iterator i = object_memory_->finalize().begin();
i != object_memory_->finalize().end();
- i++) {
+ ++i) {
if(i->object) {
i->object = saw_object(i->object);
}
@@ -388,7 +388,7 @@ namespace rubinius {
if(remove) {
i = object_memory_->finalize().erase(i);
} else {
- i++;
+ ++i;
}
}
}
View
6 vm/gc/inflated_headers.cpp
@@ -7,7 +7,7 @@ namespace rubinius {
InflatedHeaders::~InflatedHeaders() {
for(Chunks::iterator i = chunks_.begin();
i != chunks_.end();
- i++) {
+ ++i) {
InflatedHeader* chunk = *i;
delete[] chunk;
}
@@ -76,7 +76,7 @@ namespace rubinius {
delete[] chunk;
i = chunks_.erase(i);
} else {
- i++;
+ ++i;
}
}
@@ -86,7 +86,7 @@ namespace rubinius {
for(Chunks::iterator i = chunks_.begin();
i != chunks_.end();
- i++) {
+ ++i) {
InflatedHeader* chunk = *i;
for(size_t j = 0; j < cChunkSize; j++) {
View
12 vm/gc/marksweep.cpp
@@ -34,7 +34,7 @@ namespace rubinius {
void MarkSweepGC::free_objects() {
std::list<Object*>::iterator i;
- for(i = entries.begin(); i != entries.end(); i++) {
+ for(i = entries.begin(); i != entries.end(); ++i) {
free_object(*i, true);
}
}
@@ -142,7 +142,7 @@ namespace rubinius {
// Walk all the call frames
for(CallFrameLocationList::const_iterator i = call_frames.begin();
i != call_frames.end();
- i++) {
+ ++i) {
CallFrame** loc = *i;
walk_call_frame(*loc);
}
@@ -173,7 +173,7 @@ namespace rubinius {
for(i = entries.begin(); i != entries.end();) {
Object* obj = *i;
if(obj->marked_p(object_memory_->mark())) {
- i++;
+ ++i;
} else {
free_object(obj);
i = entries.erase(i);
@@ -207,7 +207,7 @@ namespace rubinius {
for(std::list<Object*>::iterator i = entries.begin();
i != entries.end();
- i++) {
+ ++i) {
Object* obj = *i;
Class* cls = obj->class_object(object_memory_->state());
@@ -228,7 +228,7 @@ namespace rubinius {
for(std::map<Class*,PerClass>::iterator i = stats.begin();
i != stats.end();
- i++) {
+ ++i) {
std::cout << i->first->name()->c_str(object_memory_->state()) << "\n"
<< " objects: " << i->second.objects << "\n"
<< " bytes: " << i->second.bytes << "\n";
@@ -274,7 +274,7 @@ namespace rubinius {
ObjectPosition MarkSweepGC::validate_object(Object* obj) {
std::list<Object*>::iterator i;
- for(i = entries.begin(); i != entries.end(); i++) {
+ for(i = entries.begin(); i != entries.end(); ++i) {
if(*i == obj) return cMatureObject;
}
View
6 vm/gc/walker.cpp
@@ -34,12 +34,12 @@ namespace rubinius {
for(std::list<gc::WriteBarrier*>::iterator wbi = object_memory_->aux_barriers().begin();
wbi != object_memory_->aux_barriers().end();
- wbi++) {
+ ++wbi) {
gc::WriteBarrier* wb = *wbi;
ObjectArray* rs = wb->remember_set();
for(ObjectArray::iterator oi = rs->begin();
oi != rs->end();
- oi++) {
+ ++oi) {
tmp = *oi;
if(tmp) saw_object(tmp);
@@ -53,7 +53,7 @@ namespace rubinius {
if(data.threads()) {
for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
i != data.threads()->end();
- i++) {
+ ++i) {
scan(*i, false);
}
}
View
2  vm/gc/write_barrier.cpp
@@ -58,7 +58,7 @@ namespace gc {
for(ObjectArray::iterator oi = remember_set_->begin();
oi != remember_set_->end();
- oi++) {
+ ++oi) {
if(*oi == target) {
*oi = NULL;
target->clear_remember();
View
12 vm/inline_cache.cpp
@@ -667,7 +667,7 @@ namespace rubinius {
CacheVector& vec = caches_[sym->index()];
for(CacheVector::iterator i = vec.begin();
i != vec.end();
- i++) {
+ ++i) {
if(*i == cache) {
vec.erase(i);
return;
@@ -681,7 +681,7 @@ namespace rubinius {
for(CacheVector::iterator i = vec.begin();
i != vec.end();
- i++) {
+ ++i) {
(*i)->clear();
}
}
@@ -699,10 +699,10 @@ namespace rubinius {
for(CacheHash::iterator hi = caches_.begin();
hi != caches_.end();
- hi++) {
+ ++hi) {
for(CacheVector::iterator vi = hi->second.begin();
vi != hi->second.end();
- vi++) {
+ ++vi) {
InlineCache* ic = *vi;
int seen = ic->classes_seen();
if(ic->seen_classes_overflow() > 0) {
@@ -729,10 +729,10 @@ namespace rubinius {
for(CacheHash::iterator hi = caches_.begin();
hi != caches_.end();
- hi++) {
+ ++hi) {
for(CacheVector::iterator vi = hi->second.begin();
vi != hi->second.end();
- vi++) {
+ ++vi) {
InlineCache* ic = *vi;
if(ic->seen_classes_overflow() > 0) {
ic->print(state, std::cerr);
View
2  vm/linkedlist.cpp
@@ -5,7 +5,7 @@
LinkedList::LinkedList() : head_(NULL), count_(0) { }
LinkedList::Node::Node() : next_(NULL), prev_(NULL) { }
-size_t LinkedList::size() {
+size_t LinkedList::size() const {
return count_;
}
View
2  vm/linkedlist.hpp
@@ -57,7 +57,7 @@ class LinkedList {
return head_;
}
- size_t size();
+ size_t size() const;
void add(Node*);
void remove(Node*);
View
2  vm/llvm/cfg.hpp
@@ -99,7 +99,7 @@ namespace jit {
~CFGCalculator() {
for(Blocks::iterator i = blocks_.begin();
i != blocks_.end();
- i++) {
+ ++i) {
delete i->second;
}
}
View
2  vm/llvm/jit_compiler.cpp
@@ -160,7 +160,7 @@ namespace jit {
for(std::vector<BasicBlock*>::iterator i = to_remove.begin();
i != to_remove.end();
- i++) {
+ ++i) {
(*i)->eraseFromParent();
}
View
6 vm/llvm/jit_runtime.cpp
@@ -32,7 +32,7 @@ namespace jit {
for(std::list<jit::RuntimeData*>::iterator i = runtime_data_.begin();
i != runtime_data_.end();
- i++) {
+ ++i) {
jit::RuntimeData* rd = *i;
tmp = mark.call(rd->method());
@@ -58,7 +58,7 @@ namespace jit {
void RuntimeDataHolder::visit_all(ObjectVisitor& visit) {
for(std::list<jit::RuntimeData*>::iterator i = runtime_data_.begin();
i != runtime_data_.end();
- i++) {
+ ++i) {
jit::RuntimeData* rd = *i;
visit.call(rd->method());
@@ -71,7 +71,7 @@ namespace jit {
void RuntimeDataHolder::run_write_barrier(gc::WriteBarrier* wb, Object* obj) {
for(std::list<jit::RuntimeData*>::iterator i = runtime_data_.begin();
i != runtime_data_.end();
- i++) {
+ ++i) {
jit::RuntimeData* rd = *i;
obj->write_barrier(wb, rd->method());
View
2  vm/llvm/jit_visit.hpp
@@ -1543,7 +1543,7 @@ namespace rubinius {
for(std::list<JITMethodInfo*>::iterator i = in_scope.begin();
i != in_scope.end();
- i++ ) {
+ ++i) {
nfo = *i;
JITInlineBlock* ib = nfo->inline_block();
View
16 vm/llvm/passes.cpp
@@ -42,10 +42,10 @@ namespace {
for(Function::iterator bb = f.begin(), e = f.end();
bb != e;
- bb++) {
+ ++bb) {
for(BasicBlock::iterator inst = bb->begin();
inst != bb->end();
- inst++) {
+ ++inst) {
ICmpInst* icmp = dyn_cast<ICmpInst>(inst);
if(icmp == NULL) continue;
@@ -128,10 +128,10 @@ namespace {
for(Function::iterator bb = f.begin(), e = f.end();
bb != e;
- bb++) {
+ ++bb) {
for(BasicBlock::iterator inst = bb->begin();
inst != bb->end();
- inst++) {
+ ++inst) {
CallInst* call = dyn_cast<CallInst>(inst);
if(!call) continue;
@@ -166,7 +166,7 @@ namespace {
for(std::vector<CallInst*>::iterator i = to_remove.begin();
i != to_remove.end();
- i++) {
+ ++i) {
CallInst* call = *i;
for(Value::use_iterator u = call->use_begin();
u != call->use_end(); /* nothing */)
@@ -262,10 +262,10 @@ namespace {
for(Function::iterator bb = f.begin(), e = f.end();
bb != e;
- bb++) {
+ ++bb) {
for(BasicBlock::iterator inst = bb->begin();
inst != bb->end();
- inst++) {
+ ++inst) {
CallInst *call = dyn_cast<CallInst>(inst);
if(call == NULL) continue;
@@ -287,7 +287,7 @@ namespace {
for(std::vector<CallInst*>::iterator i = to_remove.begin();
i != to_remove.end();
- i++) {
+ ++i) {
(*i)->eraseFromParent();
}
View
26 vm/objectmemory.cpp
@@ -34,6 +34,10 @@
#include "instruments/tooling.hpp"
+// Used by XMALLOC at the bottom
+static long gc_malloc_threshold = 0;
+static long bytes_until_collection = 0;
+
namespace rubinius {
Object* object_watch = 0;
@@ -75,6 +79,9 @@ namespace rubinius {
}
TypeInfo::init(this);
+
+ gc_malloc_threshold = config.gc_malloc_threshold;
+ bytes_until_collection = gc_malloc_threshold;
}
ObjectMemory::~ObjectMemory() {
@@ -662,7 +669,7 @@ namespace rubinius {
if(data.threads()) {
for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
i != data.threads()->end();
- i++) {
+ ++i) {
gc::Slab& slab = (*i)->local_slab();
gc_stats.slab_allocated(slab.allocations(), slab.byte_used());
@@ -1057,7 +1064,7 @@ namespace rubinius {
// See if there already one.
for(std::list<FinalizeObject>::iterator i = finalize_.begin();
- i != finalize_.end(); i++)
+ i != finalize_.end(); ++i)
{
if(i->object == obj) {
if(fin->nil_p()) {
@@ -1275,7 +1282,7 @@ namespace rubinius {
{
FinalizeObject& fi = *i;
- if(!kind_of<IO>(fi.object)) { i++; continue; }
+ if(!kind_of<IO>(fi.object)) { ++i; continue; }
// Only finalize things that haven't been finalized.
if(fi.status != FinalizeObject::eFinalized) {
@@ -1502,7 +1509,7 @@ namespace rubinius {
std::cout << ary.size() << " total references:\n";
for(ObjectArray::iterator i = ary.begin();
i != ary.end();
- i++) {
+ ++i) {
std::cout << " " << (*i)->to_s(root_state_, true)->c_str(root_state_) << "\n";
if(++count == 100) break;
@@ -1529,7 +1536,6 @@ void x_print_snapshot() {
rubinius::VM::current()->om->print_new_since_snapshot();
}
-
// The following memory functions are defined in ruby.h for use by C-API
// extensions, and also used by library code lifted from MRI (e.g. Oniguruma).
// They provide some book-keeping around memory usage for non-VM code, so that
@@ -1541,15 +1547,12 @@ void x_print_snapshot() {
// a significant amount of memory has been malloc-ed should keep non-VM memory
// usage from growing uncontrollably.
-#define DEFAULT_MALLOC_THRESHOLD 10000000
-
-static long bytes_until_collection = DEFAULT_MALLOC_THRESHOLD;
void* XMALLOC(size_t bytes) {
bytes_until_collection -= bytes;
if(bytes_until_collection <= 0) {
rubinius::VM::current()->run_gc_soon();
- bytes_until_collection = DEFAULT_MALLOC_THRESHOLD;
+ bytes_until_collection = gc_malloc_threshold;
}
return malloc(bytes);
}
@@ -1562,7 +1565,7 @@ void* XREALLOC(void* ptr, size_t bytes) {
bytes_until_collection -= bytes;
if(bytes_until_collection <= 0) {
rubinius::VM::current()->run_gc_soon();
- bytes_until_collection = DEFAULT_MALLOC_THRESHOLD;
+ bytes_until_collection = gc_malloc_threshold;
}
return realloc(ptr, bytes);
@@ -1574,9 +1577,8 @@ void* XCALLOC(size_t items, size_t bytes_per) {
bytes_until_collection -= bytes;
if(bytes_until_collection <= 0) {
rubinius::VM::current()->run_gc_soon();
- bytes_until_collection = DEFAULT_MALLOC_THRESHOLD;
+ bytes_until_collection = gc_malloc_threshold;
}
return calloc(items, bytes_per);
}
-
View
1  vm/ontology.cpp
@@ -382,6 +382,7 @@ namespace rubinius {
* be uniform is simpler.
*/
G(rubinius)->set_const(state, "BIN_PATH", String::create(state, RBX_BIN_PATH));
+ G(rubinius)->set_const(state, "KERNEL_PATH", String::create(state, RBX_KERNEL_PATH));
G(rubinius)->set_const(state, "LIB_PATH", String::create(state, RBX_LIB_PATH));
G(rubinius)->set_const(state, "EXT_PATH", String::create(state, RBX_EXT_PATH));
G(rubinius)->set_const(state, "HDR18_PATH", String::create(state, RBX_HDR18_PATH));
View
8 vm/symboltable.cpp
@@ -116,7 +116,7 @@ namespace rubinius {
symbols[hash] = v;
} else {
SymbolIds& v = entry->second;
- for(SymbolIds::iterator i = v.begin(); i != v.end(); i++) {
+ for(SymbolIds::iterator i = v.begin(); i != v.end(); ++i) {
std::string& s = strings[*i];
if(!strcmp(s.c_str(), str)) return Symbol::from_index(*i);
@@ -186,7 +186,7 @@ namespace rubinius {
for(SymbolStrings::iterator i = strings.begin();
i != strings.end();
- i++) {
+ ++i) {
total += i->size();
total += sizeof(std::string);
}
@@ -198,8 +198,8 @@ namespace rubinius {
size_t idx = 0;
Array* ary = Array::create(state, this->size());
- for(SymbolMap::iterator s = symbols.begin(); s != symbols.end(); s++) {
- for(SymbolIds::iterator i = s->second.begin(); i != s->second.end(); i++) {
+ for(SymbolMap::iterator s = symbols.begin(); s != symbols.end(); ++s) {
+ for(SymbolIds::iterator i = s->second.begin(); i != s->second.end(); ++i) {
ary->set(state, idx++, (Object*)Symbol::from_index(state, *i));
}
}
View
14 vm/test/capi/test_handles.hpp
@@ -70,18 +70,4 @@ class TestCApiHandles : public CxxTest::TestSuite, public VMTest {
TS_ASSERT(!CAPI_UNDEF_P(cCApiQnil));
TS_ASSERT(CAPI_UNDEF_P(cCApiQundef));
}
-
- void test_CAPI_GLOBAL_HANDLE_P() {
- VALUE val = CAPI_APPLY_GLOBAL_TAG(3);
-
- TS_ASSERT(CAPI_GLOBAL_HANDLE_P(val));
- TS_ASSERT(!CAPI_LOCAL_HANDLE_P(val));
- }
-
- void test_CAPI_LOCAL_HANDLE_P() {
- VALUE val = CAPI_APPLY_LOCAL_TAG(4);
-
- TS_ASSERT(CAPI_LOCAL_HANDLE_P(val));
- TS_ASSERT(!CAPI_GLOBAL_HANDLE_P(val));
- }
};
View
11 vm/test/test_objectmemory.hpp
@@ -425,12 +425,13 @@ class TestObjectMemory : public CxxTest::TestSuite, public VMTest {
void test_xmalloc_causes_gc() {
// Knows that the threshold is 10M
state->interrupts.check = false;
- void* ptr = XMALLOC(1000000);
- XFREE(ptr);
- TS_ASSERT_EQUALS(state->interrupts.check, false);
- ptr = XMALLOC(9000001);
+ int bytes = 1024 * 1024;
+ int total = 110 * bytes;
+ while(total >= 0) {
+ XFREE(XMALLOC(bytes));
+ total -= bytes;
+ }
TS_ASSERT_EQUALS(state->interrupts.check, true);
- XFREE(ptr);
}
};
View
28 vm/util/bert.hpp
@@ -91,15 +91,15 @@ namespace bert {
if(string_) delete[] string_;
}
- TermType type() {
+ TermType type() const {
return type_;
}
- int integer() {
+ int integer() const {
return integer_;
}
- double float_number() {
+ double float_number() const {
return float_;
}
@@ -485,7 +485,7 @@ namespace bert {
, eof_(false)
{}
- bool eof_p() {
+ bool eof_p() const {
return eof_;
}
@@ -587,7 +587,7 @@ namespace bert {
if(elements_) {
for(ValueList::iterator i = elements_->begin();
i != elements_->end();
- i++) {
+ ++i) {
delete *i;
}
delete elements_;
@@ -598,7 +598,7 @@ namespace bert {
if(sub_value_) delete sub_value_;
}
- Type type() {
+ Type type() const {
return type_;
}
@@ -606,23 +606,23 @@ namespace bert {
return term_;
}
- bool integer_p() {
+ bool integer_p() const {
return type_ == Integer;
}
- int integer() {
+ int integer() const {
return term_->integer();
}
- bool float_p() {
+ bool float_p() const {
return type_ == Float;
}
- double float_number() {
+ double float_number() const {
return term_->float_number();
}
- bool string_p() {
+ bool string_p() const {
return type_ == Binary;
}
@@ -630,7 +630,7 @@ namespace bert {
return term_->string();
}
- bool boolean() {
+ bool boolean() const {
return boolean_;
}
@@ -646,7 +646,7 @@ namespace bert {
time_ = time;
}
- uint64_t time() {
+ uint64_t time() const {
return time_;
}
@@ -679,7 +679,7 @@ namespace bert {
for(ValueList::iterator i = elements_->begin();
i != elements_->end();
- i++, j++) {
+ ++i, ++j) {
(*i)->print(stream);
if(j != last) stream << ", ";
}
View
57 vm/util/configuration.hpp
@@ -62,15 +62,15 @@ namespace config {
return true;
}
- const char* name() {
+ const char* name() const {
return name_;
}
- bool set_p() {
+ bool set_p() const {
return set_;
}
- const char* description() {
+ const char* description() const {
return description_;
}
@@ -106,7 +106,44 @@ namespace config {
stream << value;
}
- operator long() {
+ operator long() const {
+ return value;
+ }
+ };
+
+ class Bytes : public ConfigItem {
+ public:
+ long value;
+
+ Bytes(Configuration* config, const char* name, int def = 0)
+ : ConfigItem(config, name)
+ , value(def)
+ {}
+
+ virtual void set(const char* str) {
+ char* end;
+ value = strtol(str, &end, 0);
+ switch(*end) {
+ case 'g':
+ case 'G':
+ value *= 1073741824;
+ break;
+ case 'm':
+ case 'M':
+ value *= 1048576;
+ break;
+ case 'k':
+ case 'K':
+ value *= 1024;
+ break;
+ }
+ }
+
+ virtual void print_value(std::ostream& stream) {
+ stream << value;
+ }
+
+ operator long() const {
return value;
}
};
@@ -133,7 +170,7 @@ namespace config {
}
}
- operator const char*() {
+ operator const char*() const {
return value.c_str();
}
};
@@ -166,7 +203,7 @@ namespace config {
stream << (value ? "true" : "false");
}
- operator bool() {
+ operator bool() const {
return value;
}
};
@@ -187,7 +224,7 @@ namespace config {
for(std::vector<Bool*>::iterator i = sub_bools_.begin();
i != sub_bools_.end();
- i++) {
+ ++i) {
(*i)->set(str);
}
}
@@ -200,7 +237,7 @@ namespace config {
inline bool Configuration::import(const char* key, const char* val) {
for(Items::iterator i = items_.begin();
i != items_.end();
- i++) {
+ ++i) {
ConfigItem* item = *i;
if(item->set_maybe(key, val)) return true;
}
@@ -211,7 +248,7 @@ namespace config {
inline ConfigItem* Configuration::find(const char* key) {
for(Items::iterator i = items_.begin();
i != items_.end();
- i++) {
+ ++i) {
ConfigItem* item = *i;
if(item->equal_p(key)) return item;
}
@@ -222,7 +259,7 @@ namespace config {
inline void Configuration::print(bool desc) {
for(Items::iterator i = items_.begin();
i != items_.end();
- i++) {
+ ++i) {
ConfigItem* item = *i;
std::cout << item->name() << ": ";
item->print_value(std::cout);
View
8 vm/util/immix.hpp
@@ -634,7 +634,7 @@ namespace immix {
~BlockAllocator() {
for(Chunks::iterator i = chunks_.begin();
i != chunks_.end();
- i++) {
+ ++i) {
Chunk* chunk = *i;
chunk->free();
}
@@ -728,7 +728,7 @@ namespace immix {
void reset() {
for(Chunks::iterator i = chunks_.begin();
i != chunks_.end();
- i++) {
+ ++i) {
Chunk* chunk = *i;
chunk->update_stats();
}
@@ -1037,7 +1037,7 @@ namespace immix {
void sweep_blocks() {
for(BlockList::const_iterator i = evacuate_.begin();
i != evacuate_.end();
- i++) {
+ ++i) {
Block* block = *i;
if(block->status() == cEvacuate) {
block->set_status(cFree);
@@ -1147,7 +1147,7 @@ namespace immix {
Chunks& chunks = block_allocator_.chunks();
for(Chunks::iterator i = chunks.begin();
i != chunks.end();
- i++) {
+ ++i) {
if((*i)->contains_address(addr)) return true;
}
View
2  vm/vmmethod.cpp
@@ -146,7 +146,7 @@ namespace rubinius {
for(IndirectLiterals::iterator i = indirect_literals_.begin();
i != indirect_literals_.end();
- i++) {
+ ++i) {
delete[] *i;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.