Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Whitespace.

  • Loading branch information...
commit 7065007aa2b55220b19574155fcb9912bbddb413 1 parent b35d9eb
Evan Weaver authored
View
8 common.mk
@@ -18,7 +18,7 @@ RDOCOUT = $(EXTOUT)/rdoc
DMYEXT = dmyext.$(OBJEXT)
MAINOBJ = main.$(OBJEXT)
-EXTOBJS =
+EXTOBJS =
DLDOBJS = $(DMYEXT)
OBJS = array.$(OBJEXT) \
@@ -107,7 +107,7 @@ install-all: install-nodoc install-doc
install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
pre-install-nodoc:: pre-install-local pre-install-ext
-do-install-nodoc:
+do-install-nodoc:
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
post-install-nodoc:: post-install-local post-install-ext
@@ -181,7 +181,7 @@ no-install-all: no-install-nodoc
what-where-nodoc: no-install-nodoc
no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc
pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext
-dont-install-nodoc:
+dont-install-nodoc:
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
post-no-install-nodoc:: post-no-install-local post-no-install-ext
@@ -354,7 +354,7 @@ dl_os2.$(OBJEXT): {$(VPATH)}dl_os2.c
ia64.$(OBJEXT): {$(VPATH)}ia64.s
$(CC) $(CFLAGS) -c $<
-# when I use -I., there is confliction at "OpenFile"
+# when I use -I., there is confliction at "OpenFile"
# so, set . into environment varible "include"
win32.$(OBJEXT): {$(VPATH)}win32.c
View
22 configure.in
@@ -134,7 +134,7 @@ if test "$fat_binary" != no; then
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
ARCH_FLAG=
- for archs in $TARGET_ARCHS
+ for archs in $TARGET_ARCHS
do
ARCH_FLAG="$ARCH_FLAG -arch $archs"
done
@@ -152,12 +152,6 @@ AC_ARG_ENABLE(frame-address,
if test $frame_address = yes; then
AC_DEFINE(USE_BUILTIN_FRAME_ADDRESS)
fi
-AC_ARG_ENABLE(trace-newobj,
- [ --enable-trace-newobj enable rb_newobj tracer. ],
- [trace_newobj=$enableval])
-if test "$trace_newobj" = yes; then
- AC_DEFINE(TRACE_NEWOBJ)
-fi
AC_ARG_ENABLE(gc-debug,
[ --enable-gc-debug enable additional GC API methods, debugging, and statistics. ],
[gc_debug=$enableval])
@@ -386,7 +380,7 @@ AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
#include <errno.h>])
dnl whether link libc_r or not
-AC_ARG_WITH(libc_r,
+AC_ARG_WITH(libc_r,
[ --with-libc_r link libc_r if possible (FreeBSD only)], [
case $withval in
yes) with_libc_r=yes;;
@@ -635,7 +629,7 @@ AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp,
test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
AC_MSG_CHECKING(for setjmp type)
-AC_ARG_WITH(setjmp-type,
+AC_ARG_WITH(setjmp-type,
[ --with-setjmp-type select setjmp type], [
case $withval in
__builtin_setjmp) setjmp_prefix=__builtin_;;
@@ -813,7 +807,7 @@ main()
fi
AC_FUNC_GETPGRP
-AC_FUNC_SETPGRP
+AC_FUNC_SETPGRP
AC_C_BIGENDIAN
AC_C_CONST
@@ -1076,8 +1070,8 @@ fi
dnl default value for $KANJI
DEFAULT_KCODE="KCODE_NONE"
-AC_ARG_WITH(default-kcode,
- [ --with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
+AC_ARG_WITH(default-kcode,
+ [ --with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
[case $withval in
utf8) DEFAULT_KCODE="KCODE_UTF8";;
euc) DEFAULT_KCODE="KCODE_EUC";;
@@ -1088,7 +1082,7 @@ AC_ARG_WITH(default-kcode,
AC_DEFINE_UNQUOTED(DEFAULT_KCODE, $DEFAULT_KCODE)
dnl wheather use dln_a_out or not
-AC_ARG_WITH(dln-a-out,
+AC_ARG_WITH(dln-a-out,
[ --with-dln-a-out use dln_a_out if possible], [
case $withval in
yes) with_dln_a_out=yes;;
@@ -1313,7 +1307,7 @@ if test "$ac_cv_header_a_out_h" = yes; then
#define USE_DLN_A_OUT
#include "dln.c"
],
- [],
+ [],
rb_cv_dln_a_out=yes,
rb_cv_dln_a_out=no)])
if test "$rb_cv_dln_a_out" = yes; then
View
98 distro/installer.rb
@@ -18,7 +18,7 @@ class Installer
Dependencies::OpenSSL_Dev,
Dependencies::Readline_Dev
]
-
+
def start(options = {})
Dir.chdir(ROOT)
@version = File.read("version.txt")
@@ -30,15 +30,15 @@ def start(options = {})
if !options[:extra_configure_args].empty?
@extra_configure_args = options[:extra_configure_args].join(" ")
end
-
+
if RUBY_PLATFORM =~ /darwin/
ENV['PATH'] = "#{ENV['PATH']}:/usr/local/mysql/bin"
end
-
+
show_welcome_screen
check_dependencies || exit(1)
ask_installation_prefix
-
+
steps = []
if tcmalloc_supported?
steps += [
@@ -87,7 +87,7 @@ def show_welcome_screen
color_puts "<b>Press Enter to continue, or Ctrl-C to abort.</b>"
wait
end
-
+
def check_dependencies
missing_dependencies = []
color_puts "<banner>Checking for required software...</banner>"
@@ -106,7 +106,7 @@ def check_dependencies
missing_dependencies << dep
end
end
-
+
if missing_dependencies.empty?
return true
else
@@ -115,7 +115,7 @@ def check_dependencies
color_puts "But don't worry, this installer will tell you how to install them.\n"
color_puts "<b>Press Enter to continue, or Ctrl-C to abort.</b>"
wait
-
+
line
color_puts "<banner>Installation instructions for required software</banner>"
puts
@@ -126,7 +126,7 @@ def check_dependencies
return false
end
end
-
+
def print_dependency_installation_instructions(dep)
color_puts " * To install <yellow>#{dep.name}</yellow>:"
if !dep.install_command.nil?
@@ -142,7 +142,7 @@ def print_dependency_installation_instructions(dep)
color_puts " Search Google."
end
end
-
+
def strip_trailing_slashes(data)
if data.nil?
return nil
@@ -155,7 +155,7 @@ def strip_trailing_slashes(data)
end
end
end
-
+
def ask_installation_prefix
line
color_puts "<banner>Target directory</banner>"
@@ -175,28 +175,28 @@ def ask_installation_prefix
File.open("source/.prefix.txt", "w") do |f|
f.write(@prefix)
end
-
+
if @destdir && !@destdir =~ /\/$/
@destdir += "/"
end
-
+
ENV['CPATH'] = "#{@destdir}#{@prefix}/include:/usr/include:/usr/local/include:#{ENV['CPATH']}"
ENV['LD_LIBRARY_PATH'] = "#{@destdir}#{@prefix}/lib:#{ENV['LD_LIBRARY_PATH']}"
ENV['DYLD_LIBRARY_PATH'] = "#{@destdir}#{@prefix}/lib:#{ENV['DYLD_LIBRARY_PATH']}"
end
-
+
def configure_tcmalloc
return configure_autoconf_package('source/distro/google-perftools-1.7',
'the memory allocator for Ruby Enterprise Edition',
'--disable-dependency-tracking')
end
-
+
def compile_tcmalloc
Dir.chdir('source/distro/google-perftools-1.7') do
return sh("make libtcmalloc_minimal.la")
end
end
-
+
def install_tcmalloc
return install_autoconf_package('source/distro/google-perftools-1.7',
'the memory allocator for Ruby Enterprise Edition') do
@@ -209,13 +209,13 @@ def install_tcmalloc
sh("cp -Rpf .libs/libtcmalloc_minimal*.#{PlatformInfo::LIBEXT}* '#{@destdir}#{@prefix}/lib/'")
end
end
-
+
def configure_ruby
return configure_autoconf_package('source', 'Ruby Enterprise Edition',
"#{@extra_configure_args} " <<
"CFLAGS='-g -O2 #{ENV['CFLAGS']}'")
end
-
+
def compile_system_allocator
if platform_uses_two_level_namespace_for_dynamic_libraries?
Dir.chdir("source") do
@@ -231,7 +231,7 @@ def compile_system_allocator
return true
end
end
-
+
def compile_ruby
Dir.chdir("source") do
if fast_threading_patch_applied?
@@ -243,10 +243,10 @@ def compile_ruby
sh "patch -p1 < ../fast-threading.patch"
end
end
-
+
# No idea why, but sometimes 'make' fails unless we do this.
sh("mkdir -p .ext/common")
-
+
makefile = File.read('Makefile')
if makefile !~ /\$\(PRELIBS\)/
makefile.sub!(/^LIBS = (.*)$/, 'LIBS = $(PRELIBS) \1')
@@ -254,7 +254,7 @@ def compile_ruby
f.write(makefile)
end
end
-
+
prelibs = "-Wl,"
if PlatformInfo.solaris_ld?
prelibs << "-R#{@prefix}/lib"
@@ -282,7 +282,7 @@ def compile_ruby
return sh("make PRELIBS='#{prelibs}'")
end
end
-
+
def install_ruby
if install_autoconf_package('source', 'Ruby Enterprise Edition')
# Some installed files may have wrong permissions
@@ -301,7 +301,7 @@ def install_ruby
return false
end
end
-
+
def install_ree_specific_binaries
File.open("#{@destdir}#{@prefix}/bin/ree-version", 'w') do |f|
f.puts("#!/bin/sh")
@@ -309,7 +309,7 @@ def install_ree_specific_binaries
end
system("chmod +x '#{@destdir}#{@prefix}/bin/ree-version'")
end
-
+
def install_rubygems
# We might be installing into a fakeroot, so add the fakeroot's library
# search paths to RUBYLIB so that gem installation will work.
@@ -320,7 +320,7 @@ def install_rubygems
site_libdir = "#{basedir}/site_ruby/1.8"
site_extlibdir = "#{site_libdir}/#{archname}"
ENV['RUBYLIB'] = "#{libdir}:#{extlibdir}:#{site_libdir}:#{site_extlibdir}"
-
+
Dir.chdir("rubygems") do
line
color_puts "<banner>Installing RubyGems...</banner>"
@@ -331,7 +331,7 @@ def install_rubygems
end
return true
end
-
+
def install_iconv
# On some systems, most notably FreeBSD, the iconv extension isn't
# correctly installed. So here we do it manually.
@@ -345,7 +345,7 @@ def install_iconv
else
args = []
end
-
+
if !sh("#{@destdir}#{@prefix}/bin/ruby", "extconf.rb", *args) ||
# 'make clean' must be run, because sometimes 'make'
# thinks iconv.so is already compiled even though it
@@ -371,12 +371,12 @@ def install_dev_docs
end
return true
end
-
+
def install_useful_libraries
line
color_puts "<banner>Installing useful libraries...</banner>"
gem = "#{@destdir}#{@prefix}/bin/ruby #{@destdir}#{@prefix}/bin/gem"
-
+
mysql_config = PlatformInfo.find_command('mysql_config')
if mysql_config
mysql_gem = "mysql -- --with-mysql-config='#{mysql_config}'"
@@ -390,7 +390,7 @@ def install_useful_libraries
"rack", mysql_gem, "sqlite3-ruby", "pg"]
end
failed_gems = []
-
+
if sh("#{gem} sources --update")
gem_names.each do |gem_name|
color_puts "\n<b>Installing #{gem_name}...</b>"
@@ -401,7 +401,7 @@ def install_useful_libraries
else
failed_gems = gem_names
end
-
+
if !failed_gems.empty?
line
color_puts "<banner>Warning: some libraries could not be installed</banner>"
@@ -422,7 +422,7 @@ def install_useful_libraries
color_puts "<b>Press ENTER to show the next screen.</b>"
wait
end
-
+
# Fix the shebang lines of scripts in 'bin' folder.
fix_shebang_lines("#{@destdir}#{@prefix}/bin", "#{@prefix}/bin/ruby")
Dir.chdir("#{@destdir}#{@prefix}/lib/ruby/gems/1.8/gems") do
@@ -433,7 +433,7 @@ def install_useful_libraries
end
end
end
-
+
def show_finalization_screen
line
color_puts "<banner>Ruby Enterprise Edition is successfully installed!</banner>"
@@ -465,7 +465,7 @@ def show_finalization_screen
def color_puts(message)
puts substitute_color_tags(message)
end
-
+
def color_print(message)
print substitute_color_tags(message)
end
@@ -478,16 +478,16 @@ def substitute_color_tags(data)
data.gsub!(%r{<banner>(.*?)</banner>}m, "\e[33m\e[44m\e[1m\\1#{DEFAULT_TERMINAL_COLORS}")
return data
end
-
+
def reset_terminal_colors
STDOUT.write("\e[0m")
STDOUT.flush
end
-
+
def line
puts "--------------------------------------------"
end
-
+
def wait
if !@auto_install_prefix
STDIN.readline
@@ -495,7 +495,7 @@ def wait
rescue Interrupt
exit 2
end
-
+
def query_directory(default = "")
while true
STDOUT.write("[#{default}] : ")
@@ -514,7 +514,7 @@ def query_directory(default = "")
rescue Interrupt, EOFError
exit 2
end
-
+
def tcmalloc_supported?
return @use_tcmalloc &&
RUBY_PLATFORM !~ /solaris/ &&
@@ -523,22 +523,22 @@ def tcmalloc_supported?
# tcmalloc has issues on Snow Leopard, but works fine on Leopard.
(RUBY_PLATFORM !~ /darwin/ || osx_kernel_major_release_version <= 9)
end
-
+
def osx_kernel_major_release_version
release = `uname -r`.strip
release.gsub!(/\..*/, '')
return release.to_i
end
-
+
def platform_uses_two_level_namespace_for_dynamic_libraries?
return RUBY_PLATFORM =~ /darwin/
end
-
+
def sh(*command)
puts command.join(' ')
return system(*command)
end
-
+
def configure_autoconf_package(dir, name, configure_options = nil)
line
color_puts "<banner>Compiling and optimizing #{name}</banner>"
@@ -557,7 +557,7 @@ def configure_autoconf_package(dir, name, configure_options = nil)
system("touch -r / m4/*")
end
end
-
+
if @prefix_changed || !File.exist?("Makefile")
if !sh("./configure --prefix=#{@prefix} #{configure_options}")
return false
@@ -569,7 +569,7 @@ def configure_autoconf_package(dir, name, configure_options = nil)
return true
end
end
-
+
def install_autoconf_package(dir, name)
Dir.chdir(dir) do
if block_given?
@@ -601,7 +601,7 @@ def install_autoconf_package(dir, name)
end
end
end
-
+
# Fix the shebang lines of Ruby scripts.
def fix_shebang_lines(dir, new_shebang_line)
Dir.foreach(dir) do |basename|
@@ -632,7 +632,7 @@ def fix_shebang_lines(dir, new_shebang_line)
end
end
end
-
+
def fast_threading_patch_applied?
File.read("eval.c") =~ /PROT_EMPTY/
end
@@ -641,10 +641,10 @@ def fast_threading_patch_applied?
options = { :tcmalloc => true, :install_dev_docs => true, :install_useful_gems => true, :extra_configure_args => [] }
parser = OptionParser.new do |opts|
newline = "\n#{' ' * 37}"
-
+
opts.banner = "Usage: installer [options]"
opts.separator("")
-
+
opts.on("-a", "--auto PREFIX", String,
"Configure Ruby with prefix PREFIX and#{newline}" <<
"install it without any user interaction.") do |dir|
View
38 error.c
@@ -340,7 +340,7 @@ rb_exc_new3(etype, str)
* call-seq:
* Exception.new(msg = nil) => exception
*
- * Construct a new Exception object, optionally passing in
+ * Construct a new Exception object, optionally passing in
* a message.
*/
@@ -364,12 +364,12 @@ exc_initialize(argc, argv, exc)
*
* call-seq:
* exc.exception(string) -> an_exception or exc
- *
+ *
* With no argument, or if the argument is the same as the receiver,
* return the receiver. Otherwise, create a new
* exception object of the same class as the receiver, but with a
* message equal to <code>string.to_str</code>.
- *
+ *
*/
static VALUE
@@ -457,27 +457,27 @@ exc_inspect(exc)
/*
* call-seq:
* exception.backtrace => array
- *
+ *
* Returns any backtrace associated with the exception. The backtrace
* is an array of strings, each containing either ``filename:lineNo: in
* `method''' or ``filename:lineNo.''
- *
+ *
* def a
* raise "boom"
* end
- *
+ *
* def b
* a()
* end
- *
+ *
* begin
* b()
* rescue => detail
* print detail.backtrace.join("\n")
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* prog.rb:2:in `a'
* prog.rb:6:in `b'
* prog.rb:10
@@ -519,11 +519,11 @@ rb_check_backtrace(bt)
/*
* call-seq:
* exc.set_backtrace(array) => array
- *
+ *
* Sets the backtrace information associated with <i>exc</i>. The
* argument must be an array of <code>String</code> objects in the
* format described in <code>Exception#backtrace</code>.
- *
+ *
*/
static VALUE
@@ -795,7 +795,7 @@ rb_invalid_str(str, type)
rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING(s)->ptr);
}
-/*
+/*
* Document-module: Errno
*
* Ruby exception objects are subclasses of <code>Exception</code>.
@@ -805,21 +805,21 @@ rb_invalid_str(str, type)
* number generating its own subclass of <code>SystemCallError</code>.
* As the subclass is created in module <code>Errno</code>, its name
* will start <code>Errno::</code>.
- *
+ *
* The names of the <code>Errno::</code> classes depend on
* the environment in which Ruby runs. On a typical Unix or Windows
* platform, there are <code>Errno</code> classes such as
* <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
* <code>Errno::EINTR</code>, and so on.
- *
+ *
* The integer operating system error number corresponding to a
* particular error is available as the class constant
* <code>Errno::</code><em>error</em><code>::Errno</code>.
- *
+ *
* Errno::EACCES::Errno #=> 13
* Errno::EAGAIN::Errno #=> 11
* Errno::EINTR::Errno #=> 4
- *
+ *
* The full list of operating system errors on your particular platform
* are available as the constants of <code>Errno</code>.
*
@@ -974,7 +974,7 @@ syserr_eqq(self, exc)
* statements in <code>begin/end</code> blocks. <code>Exception</code>
* objects carry information about the exception---its type (the
* exception's class name), an optional descriptive string, and
- * optional traceback information. Programs may subclass
+ * optional traceback information. Programs may subclass
* <code>Exception</code> to add additional information.
*/
@@ -1132,14 +1132,14 @@ rb_sys_warning(fmt, va_alist)
char buf[BUFSIZ];
va_list args;
int errno_save;
-
+
errno_save = errno;
if (!RTEST(ruby_verbose)) return;
snprintf(buf, BUFSIZ, "warning: %s", fmt);
snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
-
+
va_init_list(args, fmt);
warn_print(buf, args);
va_end(args);
View
6,764 eval.c
3,382 additions, 3,382 deletions not shown
View
1,630 gc.c
@@ -204,12 +204,12 @@ rb_memerror()
rb_thread_t th = rb_curr_thread;
during_gc = 0;
if (!nomem_error ||
- (rb_thread_raised_p(th, RAISED_NOMEMORY) && rb_safe_level() < 4)) {
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
- exit(EXIT_FAILURE);
+ (rb_thread_raised_p(th, RAISED_NOMEMORY) && rb_safe_level() < 4)) {
+ fprintf(stderr, "[FATAL] failed to allocate memory\n");
+ exit(EXIT_FAILURE);
}
if (rb_thread_raised_p(th, RAISED_NOMEMORY)) {
- rb_exc_jump(nomem_error);
+ rb_exc_jump(nomem_error);
}
rb_thread_raised_set(th, RAISED_NOMEMORY);
rb_exc_raise(nomem_error);
@@ -222,7 +222,7 @@ ruby_xmalloc(size)
void *mem;
if (size < 0) {
- rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
+ rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
}
if (size == 0) {
size = 1;
@@ -230,12 +230,12 @@ ruby_xmalloc(size)
RUBY_CRITICAL(mem = malloc(size));
if (!mem) {
- longlife_collection = Qtrue;
+ longlife_collection = Qtrue;
garbage_collect("OOM in malloc");
- RUBY_CRITICAL(mem = malloc(size));
- if (!mem) {
- rb_memerror();
- }
+ RUBY_CRITICAL(mem = malloc(size));
+ if (!mem) {
+ rb_memerror();
+ }
}
#if STACK_WIPE_SITES & 0x100
@@ -264,7 +264,7 @@ ruby_xrealloc(ptr, size)
void *mem;
if (size < 0) {
- rb_raise(rb_eArgError, "negative re-allocation size");
+ rb_raise(rb_eArgError, "negative re-allocation size");
}
if (!ptr) {
return xmalloc(size);
@@ -275,11 +275,11 @@ ruby_xrealloc(ptr, size)
RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
- longlife_collection = Qtrue;
+ longlife_collection = Qtrue;
garbage_collect("OOM in realloc()");
- RUBY_CRITICAL(mem = realloc(ptr, size));
- if (!mem) {
- rb_memerror();
+ RUBY_CRITICAL(mem = realloc(ptr, size));
+ if (!mem) {
+ rb_memerror();
}
}
#if STACK_WIPE_SITES & 0x200
@@ -293,8 +293,8 @@ ruby_xfree(x)
void *x;
{
if (x) {
- RUBY_CRITICAL(free(x));
-}
+ RUBY_CRITICAL(free(x));
+ }
}
static int dont_gc;
@@ -372,19 +372,19 @@ rb_gc_unregister_address(addr)
struct gc_list *tmp = global_List;
if (tmp->varptr == addr) {
- global_List = tmp->next;
- RUBY_CRITICAL(free(tmp));
- return;
+ global_List = tmp->next;
+ RUBY_CRITICAL(free(tmp));
+ return;
}
while (tmp->next) {
- if (tmp->next->varptr == addr) {
- struct gc_list *t = tmp->next;
+ if (tmp->next->varptr == addr) {
+ struct gc_list *t = tmp->next;
- tmp->next = tmp->next->next;
- RUBY_CRITICAL(free(t));
- break;
- }
- tmp = tmp->next;
+ tmp->next = tmp->next->next;
+ RUBY_CRITICAL(free(t));
+ break;
+ }
+ tmp = tmp->next;
}
}
@@ -403,26 +403,26 @@ static FILE* gc_data_file = NULL;
typedef struct RVALUE {
union {
- struct {
- unsigned long flags; /* always 0 for freed obj */
- struct RVALUE *next;
- } free;
- struct RBasic basic;
- struct RObject object;
- struct RClass klass;
- struct RFloat flonum;
- struct RString string;
- struct RArray array;
- struct RRegexp regexp;
- struct RHash hash;
- struct RData data;
- struct RStruct rstruct;
- struct RBignum bignum;
- struct RFile file;
- struct RNode node;
- struct RMatch match;
- struct RVarmap varmap;
- struct SCOPE scope;
+ struct {
+ unsigned long flags; /* always 0 for freed obj */
+ struct RVALUE *next;
+ } free;
+ struct RBasic basic;
+ struct RObject object;
+ struct RClass klass;
+ struct RFloat flonum;
+ struct RString string;
+ struct RArray array;
+ struct RRegexp regexp;
+ struct RHash hash;
+ struct RData data;
+ struct RStruct rstruct;
+ struct RBignum bignum;
+ struct RFile file;
+ struct RNode node;
+ struct RMatch match;
+ struct RVarmap varmap;
+ struct SCOPE scope;
} as;
#ifdef GC_DEBUG
source_position_t *source_pos;
@@ -766,7 +766,7 @@ static void set_gc_parameters()
gc_data_file_name = getenv("RUBY_GC_DATA_FILE");
if (gc_data_file_name == NULL) {
gc_data_file_name = "/dev/stderr";
- }
+ }
FILE* data_file = fopen(gc_data_file_name, "w");
if (data_file != NULL) {
gc_data_file = data_file;
@@ -774,8 +774,8 @@ static void set_gc_parameters()
fprintf(stderr, "Can't open RUBY_GC_DATA_FILE for writing\n");
gc_data_file_name = "/dev/stderr";
gc_data_file = fopen(gc_data_file_name, "w");
+ }
}
-}
#endif
SET_INT_ENV_VAR("RUBY_GC_HEAP_SIZE", heap_size)
@@ -784,7 +784,7 @@ static void set_gc_parameters()
WITH_FLOAT_ENV_VAR("RUBY_GC_LONGLIFE_LAZINESS", longlife_laziness)
if (val >= 1) {
val = DEFAULT_LONGLIFE_LAZINESS;
- }
+ }
longlife_laziness = val;
END_WITH_ENV_VAR
@@ -842,22 +842,22 @@ add_heap(heaps_space_t *heaps_space)
int new_heap_size = heap_size;
if (heaps_used == heaps_length) {
- /* Realloc heaps */
- struct heaps_slot *p;
- int length;
-
- heaps_length += heaps_increment;
- length = heaps_length*sizeof(struct heaps_slot);
- RUBY_CRITICAL(
- if (heaps_used > 0) {
- p = (struct heaps_slot *)realloc(heaps, length);
+ /* Realloc heaps */
+ struct heaps_slot *p;
+ int length;
+
+ heaps_length += heaps_increment;
+ length = heaps_length*sizeof(struct heaps_slot);
+ RUBY_CRITICAL(
+ if (heaps_used > 0) {
+ p = (struct heaps_slot *)realloc(heaps, length);
if (p) {
heaps = p;
}
- }
- else {
- p = heaps = (struct heaps_slot *)malloc(length);
- });
+ }
+ else {
+ p = heaps = (struct heaps_slot *)malloc(length);
+ });
if (p == 0) {
rb_memerror();
}
@@ -865,9 +865,9 @@ add_heap(heaps_space_t *heaps_space)
for (;;) {
RUBY_CRITICAL(p = (RVALUE*)malloc(sizeof(RVALUE)*(new_heap_size)));
- if (p == 0) {
- rb_memerror();
- }
+ if (p == 0) {
+ rb_memerror();
+ }
heaps[heaps_used].membase = p;
// Align heap pointer to RVALUE size, if necessary
@@ -882,7 +882,7 @@ add_heap(heaps_space_t *heaps_space)
heaps[heaps_used].marks_size = (int) (ceil(new_heap_size / (sizeof(int) * 8.0)));
heaps[heaps_used].marks = (int *) calloc(heaps[heaps_used].marks_size, sizeof(int));
heaps[heaps_used].lifetime = heaps_space->lifetime;
- break;
+ break;
}
pend = p + new_heap_size;
if (lomem == 0 || lomem > p) {
@@ -931,7 +931,7 @@ static inline void
add_heap_if_needed(heaps_space_t* heaps_space)
{
int new_heap_size;
- if(!heaps_space->freelist) {
+ if (!heaps_space->freelist) {
new_heap_size = add_heap(heaps_space);
GC_DEBUG_PRINTF("*** %s heap added (out of space) (size %d) ***\n",
lifetime_name[heaps_space->lifetime], new_heap_size)
@@ -980,7 +980,7 @@ rb_newobj_longlife(int type)
return rb_newobj_eden(type);
}
if (during_gc) {
- rb_bug("object allocation during garbage collection phase");
+ rb_bug("object allocation during garbage collection phase");
}
if (gc_debug_stress) {
longlife_collection = Qtrue;
@@ -1090,9 +1090,9 @@ ruby_stack_length(base)
SET_STACK_END;
VALUE *start;
if (rb_curr_thread == rb_main_thread) {
- start = rb_gc_stack_start;
+ start = rb_gc_stack_start;
} else {
- start = rb_curr_thread->stk_base;
+ start = rb_curr_thread->stk_base;
}
if (base) {
*base = STACK_UPPER(start, STACK_END);
@@ -1105,15 +1105,15 @@ ruby_stack_check()
{
SET_STACK_END;
if (!rb_main_thread || rb_curr_thread == rb_main_thread) {
- return __stack_past(stack_limit, STACK_END);
+ return __stack_past(stack_limit, STACK_END);
} else {
- /* ruby_stack_check() is only called periodically, but we want to
- * detect a stack overflow before the thread's guard area is accessed.
- * So we append a '+ getpagesize()' to the address check.
- *
- * TODO: support architectures on which the stack grows upwards.
- */
- return __stack_past(rb_curr_thread->guard + getpagesize(), STACK_END);
+ /* ruby_stack_check() is only called periodically, but we want to
+ * detect a stack overflow before the thread's guard area is accessed.
+ * So we append a '+ getpagesize()' to the address check.
+ *
+ * TODO: support architectures on which the stack grows upwards.
+ */
+ return __stack_past(rb_curr_thread->guard + getpagesize(), STACK_END);
}
}
@@ -1168,12 +1168,12 @@ push_mark_stack(VALUE ptr)
{
if (!mark_stack_overflow) {
if (mark_stack_ptr - mark_stack < MARK_STACK_MAX) {
- *mark_stack_ptr++ = ptr;
+ *mark_stack_ptr++ = ptr;
} else {
- mark_stack_overflow = 1;
+ mark_stack_overflow = 1;
+ }
}
}
-}
static st_table *source_filenames;
@@ -1190,13 +1190,13 @@ rb_source_filename(f)
st_data_t name;
if (!st_lookup(source_filenames, (st_data_t)f, &name)) {
- long len = strlen(f) + 1;
- char *ptr = ALLOC_N(char, len + 1);
- name = (st_data_t)ptr;
- *ptr++ = 0;
- MEMCPY(ptr, f, char, len);
- st_add_direct(source_filenames, (st_data_t)ptr, name);
- return ptr;
+ long len = strlen(f) + 1;
+ char *ptr = ALLOC_N(char, len + 1);
+ name = (st_data_t)ptr;
+ *ptr++ = 0;
+ MEMCPY(ptr, f, char, len);
+ st_add_direct(source_filenames, (st_data_t)ptr, name);
+ return ptr;
}
return (char *)name + 1;
}
@@ -1206,7 +1206,7 @@ mark_source_filename(f)
char *f;
{
if (f) {
- rb_mark_table_add_filename(f);
+ rb_mark_table_add_filename(f);
}
}
@@ -1215,13 +1215,13 @@ sweep_source_filename(key, value)
char *key, *value;
{
if (rb_mark_table_contains_filename(value + 1)) {
- rb_mark_table_remove_filename(value + 1);
- return ST_CONTINUE;
+ rb_mark_table_remove_filename(value + 1);
+ return ST_CONTINUE;
}
else {
- rb_mark_table_remove_filename(value + 1);
- free(value);
- return ST_DELETE;
+ rb_mark_table_remove_filename(value + 1);
+ free(value);
+ return ST_DELETE;
}
}
@@ -1273,14 +1273,14 @@ gc_mark_all()
init_mark_stack();
while (--heap >= heaps) {
- p = heap->slot; pend = p + heap->limit;
- while (p < pend) {
- if (rb_mark_table_heap_contains(heap, p) &&
- BUILTIN_TYPE(p) != T_DEFERRED) {
- gc_mark_children((VALUE)p);
- }
- p++;
- }
+ p = heap->slot; pend = p + heap->limit;
+ while (p < pend) {
+ if (rb_mark_table_heap_contains(heap, p) &&
+ BUILTIN_TYPE(p) != T_DEFERRED) {
+ gc_mark_children((VALUE)p);
+ }
+ p++;
+ }
}
}
@@ -1316,7 +1316,7 @@ is_pointer_to_heap(ptr)
heap = heaps+heaps_used;
while (--heap >= heaps) {
if (p >= heap->slot && p < heap->slot + heap->limit) {
- return Qtrue;
+ return Qtrue;
}
}
return Qfalse;
@@ -1337,7 +1337,7 @@ is_pointer_to_longlife_heap(ptr)
heap = heaps+heaps_used;
while (--heap >= heaps) {
if (p >= heap->slot && p < heap->slot + heap->limit && heap->lifetime == lifetime_longlife) {
- return Qtrue;
+ return Qtrue;
}
}
return Qfalse;
@@ -1374,7 +1374,7 @@ rb_gc_write_barrier(VALUE ptr)
RVALUE *obj = RANY(ptr);
if (ptr && !SPECIAL_CONST_P(ptr) && obj->as.basic.flags && !(RBASIC(ptr)->flags & (FL_REMEMBERED_SET|FL_LONGLIFE))) {
- remembered_set_t *tmp;
+ remembered_set_t *tmp;
if (remembered_set_freed) {
tmp = remembered_set_freed;
remembered_set_freed = remembered_set_freed->next;
@@ -1398,10 +1398,10 @@ mark_locations_array(x, n)
VALUE v;
while (n--) {
v = *x;
- if (is_pointer_to_heap((void *)v)) {
+ if (is_pointer_to_heap((void *)v)) {
rb_gc_mark(v);
- }
- x++;
+ }
+ x++;
}
}
@@ -1504,7 +1504,7 @@ gc_mark_children(ptr)
{
RVALUE *obj = RANY(ptr);
- goto marking; /* skip */
+ goto marking; /* skip */
again:
obj = RANY(ptr);
@@ -1520,151 +1520,151 @@ gc_mark_children(ptr)
marking:
if (FL_TEST(obj, FL_EXIVAR)) {
- rb_mark_generic_ivar(ptr);
+ rb_mark_generic_ivar(ptr);
}
switch (obj->as.basic.flags & T_MASK) {
case T_NIL:
case T_FIXNUM:
- rb_bug("rb_gc_mark() called for broken object");
- break;
+ rb_bug("rb_gc_mark() called for broken object");
+ break;
case T_NODE:
if (longlife_collection) {
- mark_source_filename(obj->as.node.nd_file);
- }
- switch (nd_type(obj)) {
- case NODE_IF: /* 1,2,3 */
- case NODE_FOR:
- case NODE_ITER:
- case NODE_CREF:
- case NODE_WHEN:
- case NODE_MASGN:
- case NODE_RESCUE:
- case NODE_RESBODY:
- case NODE_CLASS:
+ mark_source_filename(obj->as.node.nd_file);
+ }
+ switch (nd_type(obj)) {
+ case NODE_IF: /* 1,2,3 */
+ case NODE_FOR:
+ case NODE_ITER:
+ case NODE_CREF:
+ case NODE_WHEN:
+ case NODE_MASGN:
+ case NODE_RESCUE:
+ case NODE_RESBODY:
+ case NODE_CLASS:
rb_gc_mark((VALUE)obj->as.node.u2.node);
- /* fall through */
- case NODE_BLOCK: /* 1,3 */
- case NODE_ARRAY:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DREGX_ONCE:
- case NODE_FBODY:
- case NODE_ENSURE:
- case NODE_CALL:
- case NODE_DEFS:
- case NODE_OP_ASGN1:
+ /* fall through */
+ case NODE_BLOCK: /* 1,3 */
+ case NODE_ARRAY:
+ case NODE_DSTR:
+ case NODE_DXSTR:
+ case NODE_DREGX:
+ case NODE_DREGX_ONCE:
+ case NODE_FBODY:
+ case NODE_ENSURE:
+ case NODE_CALL:
+ case NODE_DEFS:
+ case NODE_OP_ASGN1:
rb_gc_mark((VALUE)obj->as.node.u1.node);
- /* fall through */
- case NODE_SUPER: /* 3 */
- case NODE_FCALL:
- case NODE_DEFN:
- case NODE_NEWLINE:
- ptr = (VALUE)obj->as.node.u3.node;
- goto again;
-
- case NODE_WHILE: /* 1,2 */
- case NODE_UNTIL:
- case NODE_AND:
- case NODE_OR:
- case NODE_CASE:
- case NODE_SCLASS:
- case NODE_DOT2:
- case NODE_DOT3:
- case NODE_FLIP2:
- case NODE_FLIP3:
- case NODE_MATCH2:
- case NODE_MATCH3:
- case NODE_OP_ASGN_OR:
- case NODE_OP_ASGN_AND:
- case NODE_MODULE:
- case NODE_ALIAS:
- case NODE_VALIAS:
- case NODE_ARGS:
+ /* fall through */
+ case NODE_SUPER: /* 3 */
+ case NODE_FCALL:
+ case NODE_DEFN:
+ case NODE_NEWLINE:
+ ptr = (VALUE)obj->as.node.u3.node;
+ goto again;
+
+ case NODE_WHILE: /* 1,2 */
+ case NODE_UNTIL:
+ case NODE_AND:
+ case NODE_OR:
+ case NODE_CASE:
+ case NODE_SCLASS:
+ case NODE_DOT2:
+ case NODE_DOT3:
+ case NODE_FLIP2:
+ case NODE_FLIP3:
+ case NODE_MATCH2:
+ case NODE_MATCH3:
+ case NODE_OP_ASGN_OR:
+ case NODE_OP_ASGN_AND:
+ case NODE_MODULE:
+ case NODE_ALIAS:
+ case NODE_VALIAS:
+ case NODE_ARGS:
rb_gc_mark((VALUE)obj->as.node.u1.node);
- /* fall through */
- case NODE_METHOD: /* 2 */
- case NODE_NOT:
- case NODE_GASGN:
- case NODE_LASGN:
- case NODE_DASGN:
- case NODE_DASGN_CURR:
- case NODE_IASGN:
- case NODE_CVDECL:
- case NODE_CVASGN:
- case NODE_COLON3:
- case NODE_OPT_N:
- case NODE_EVSTR:
- case NODE_UNDEF:
- ptr = (VALUE)obj->as.node.u2.node;
- goto again;
-
- case NODE_HASH: /* 1 */
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DEFINED:
- case NODE_MATCH:
- case NODE_RETURN:
- case NODE_BREAK:
- case NODE_NEXT:
- case NODE_YIELD:
- case NODE_COLON2:
- case NODE_SPLAT:
- case NODE_TO_ARY:
- case NODE_SVALUE:
- ptr = (VALUE)obj->as.node.u1.node;
- goto again;
-
- case NODE_SCOPE: /* 2,3 */
- case NODE_BLOCK_PASS:
- case NODE_CDECL:
+ /* fall through */
+ case NODE_METHOD: /* 2 */
+ case NODE_NOT:
+ case NODE_GASGN:
+ case NODE_LASGN:
+ case NODE_DASGN:
+ case NODE_DASGN_CURR:
+ case NODE_IASGN:
+ case NODE_CVDECL:
+ case NODE_CVASGN:
+ case NODE_COLON3:
+ case NODE_OPT_N:
+ case NODE_EVSTR:
+ case NODE_UNDEF:
+ ptr = (VALUE)obj->as.node.u2.node;
+ goto again;
+
+ case NODE_HASH: /* 1 */
+ case NODE_LIT:
+ case NODE_STR:
+ case NODE_XSTR:
+ case NODE_DEFINED:
+ case NODE_MATCH:
+ case NODE_RETURN:
+ case NODE_BREAK:
+ case NODE_NEXT:
+ case NODE_YIELD:
+ case NODE_COLON2:
+ case NODE_SPLAT:
+ case NODE_TO_ARY:
+ case NODE_SVALUE:
+ ptr = (VALUE)obj->as.node.u1.node;
+ goto again;
+
+ case NODE_SCOPE: /* 2,3 */
+ case NODE_BLOCK_PASS:
+ case NODE_CDECL:
rb_gc_mark((VALUE)obj->as.node.u3.node);
- ptr = (VALUE)obj->as.node.u2.node;
- goto again;
-
- case NODE_ZARRAY: /* - */
- case NODE_ZSUPER:
- case NODE_CFUNC:
- case NODE_VCALL:
- case NODE_GVAR:
- case NODE_LVAR:
- case NODE_DVAR:
- case NODE_IVAR:
- case NODE_CVAR:
- case NODE_NTH_REF:
- case NODE_BACK_REF:
- case NODE_REDO:
- case NODE_RETRY:
- case NODE_SELF:
- case NODE_NIL:
- case NODE_TRUE:
- case NODE_FALSE:
- case NODE_ATTRSET:
- case NODE_BLOCK_ARG:
- case NODE_POSTEXE:
- break;
- case NODE_ALLOCA:
- mark_locations_array((VALUE*)obj->as.node.u1.value,
- obj->as.node.u3.cnt);
- ptr = (VALUE)obj->as.node.u2.node;
- goto again;
-
- default: /* unlisted NODE */
- if (is_pointer_to_heap(obj->as.node.u1.node)) {
+ ptr = (VALUE)obj->as.node.u2.node;
+ goto again;
+
+ case NODE_ZARRAY: /* - */
+ case NODE_ZSUPER:
+ case NODE_CFUNC:
+ case NODE_VCALL:
+ case NODE_GVAR:
+ case NODE_LVAR:
+ case NODE_DVAR:
+ case NODE_IVAR:
+ case NODE_CVAR:
+ case NODE_NTH_REF:
+ case NODE_BACK_REF:
+ case NODE_REDO:
+ case NODE_RETRY:
+ case NODE_SELF:
+ case NODE_NIL:
+ case NODE_TRUE:
+ case NODE_FALSE:
+ case NODE_ATTRSET:
+ case NODE_BLOCK_ARG:
+ case NODE_POSTEXE:
+ break;
+ case NODE_ALLOCA:
+ mark_locations_array((VALUE*)obj->as.node.u1.value,
+ obj->as.node.u3.cnt);
+ ptr = (VALUE)obj->as.node.u2.node;
+ goto again;
+
+ default: /* unlisted NODE */
+ if (is_pointer_to_heap(obj->as.node.u1.node)) {
rb_gc_mark((VALUE)obj->as.node.u1.node);
- }
- if (is_pointer_to_heap(obj->as.node.u2.node)) {
+ }
+ if (is_pointer_to_heap(obj->as.node.u2.node)) {
rb_gc_mark((VALUE)obj->as.node.u2.node);
- }
- if (is_pointer_to_heap(obj->as.node.u3.node)) {
+ }
+ if (is_pointer_to_heap(obj->as.node.u3.node)) {
ptr = (VALUE)obj->as.node.u3.node;
goto again;
- }
- }
- return; /* no need to mark class. */
+ }
+ }
+ return; /* no need to mark class. */
}
rb_gc_mark(obj->as.basic.klass);
@@ -1672,89 +1672,89 @@ gc_mark_children(ptr)
case T_ICLASS:
case T_CLASS:
case T_MODULE:
- mark_tbl(obj->as.klass.m_tbl);
- mark_tbl(obj->as.klass.iv_tbl);
- ptr = obj->as.klass.super;
- goto again;
+ mark_tbl(obj->as.klass.m_tbl);
+ mark_tbl(obj->as.klass.iv_tbl);
+ ptr = obj->as.klass.super;
+ goto again;
case T_ARRAY:
- if (FL_TEST(obj, ELTS_SHARED)) {
- ptr = obj->as.array.aux.shared;
- goto again;
- }
- else {
- VALUE *ptr = obj->as.array.ptr;
+ if (FL_TEST(obj, ELTS_SHARED)) {
+ ptr = obj->as.array.aux.shared;
+ goto again;
+ }
+ else {
+ VALUE *ptr = obj->as.array.ptr;
VALUE *pend = ptr + obj->as.array.len;
- while (ptr < pend) {
+ while (ptr < pend) {
rb_gc_mark(*ptr++);
- }
- }
- break;
+ }
+ }
+ break;
case T_HASH:
- mark_hash(obj->as.hash.tbl);
- ptr = obj->as.hash.ifnone;
- goto again;
+ mark_hash(obj->as.hash.tbl);
+ ptr = obj->as.hash.ifnone;
+ goto again;
case T_STRING:
#define STR_ASSOC FL_USER3 /* copied from string.c */
- if (FL_TEST(obj, ELTS_SHARED|STR_ASSOC)) {
- ptr = obj->as.string.aux.shared;
- goto again;
- }
- break;
+ if (FL_TEST(obj, ELTS_SHARED|STR_ASSOC)) {
+ ptr = obj->as.string.aux.shared;
+ goto again;
+ }
+ break;
case T_DATA:
- if (obj->as.data.dmark) (*obj->as.data.dmark)(DATA_PTR(obj));
- break;
+ if (obj->as.data.dmark) (*obj->as.data.dmark)(DATA_PTR(obj));
+ break;
case T_OBJECT:
- mark_tbl(obj->as.object.iv_tbl);
- break;
+ mark_tbl(obj->as.object.iv_tbl);
+ break;
case T_FILE:
case T_REGEXP:
case T_FLOAT:
case T_BIGNUM:
case T_BLKTAG:
- break;
+ break;
case T_MATCH:
- if (obj->as.match.str) {
- ptr = obj->as.match.str;
- goto again;
- }
- break;
+ if (obj->as.match.str) {
+ ptr = obj->as.match.str;
+ goto again;
+ }
+ break;
case T_VARMAP:
rb_gc_mark(obj->as.varmap.val);
- ptr = (VALUE)obj->as.varmap.next;
- goto again;
+ ptr = (VALUE)obj->as.varmap.next;
+ goto again;
case T_SCOPE:
- if (obj->as.scope.local_vars && (obj->as.scope.flags & SCOPE_MALLOC)) {
- int n = obj->as.scope.local_tbl[0]+1;
- VALUE *vars = &obj->as.scope.local_vars[-1];
+ if (obj->as.scope.local_vars && (obj->as.scope.flags & SCOPE_MALLOC)) {
+ int n = obj->as.scope.local_tbl[0]+1;
+ VALUE *vars = &obj->as.scope.local_vars[-1];
- while (n--) {
+ while (n--) {
rb_gc_mark(*vars++);
- }
- }
- break;
+ }
+ }
+ break;
case T_STRUCT:
- {
- VALUE *ptr = obj->as.rstruct.ptr;
+ {
+ VALUE *ptr = obj->as.rstruct.ptr;
VALUE *pend = ptr + obj->as.rstruct.len;
while (ptr < pend)
rb_gc_mark(*ptr++);
- }
- break;
+ }
+ break;
default:
- rb_bug("rb_gc_mark(): unknown data type 0x%lx(0x%lx) %s",
- obj->as.basic.flags & T_MASK, obj,
- is_pointer_to_heap(obj) ? "corrupted object" : "non object");
+ rb_bug("rb_gc_mark(): unknown data type 0x%lx(0x%lx) %s",
+ obj->as.basic.flags & T_MASK, obj,
+ is_pointer_to_heap(obj) ? "corrupted object" : "non object");
}
}
@@ -1782,17 +1782,17 @@ finalize_list(p)
RVALUE *p;
{
while (p) {
- RVALUE *tmp = p->as.free.next;
- run_final((VALUE)p);
- /* Don't free objects that are singletons, or objects that are already freed.
- * The latter is to prevent the unnecessary marking of memory pages as dirty,
- * which can destroy copy-on-write semantics.
- */
- if (!FL_TEST(p, FL_SINGLETON)) {
- rb_mark_table_remove(p);
- add_to_correct_freelist(p);
- }
- p = tmp;
+ RVALUE *tmp = p->as.free.next;
+ run_final((VALUE)p);
+ /* Don't free objects that are singletons, or objects that are already freed.
+ * The latter is to prevent the unnecessary marking of memory pages as dirty,
+ * which can destroy copy-on-write semantics.
+ */
+ if (!FL_TEST(p, FL_SINGLETON)) {
+ rb_mark_table_remove(p);
+ add_to_correct_freelist(p);
+ }
+ p = tmp;
}
}
@@ -1939,7 +1939,7 @@ char* node_type(int tp)
CONST_TO_NAME(NODE_DSYM)
CONST_TO_NAME(NODE_ATTRASGN)
CONST_TO_NAME(NODE_LAST)
- default: return "____";
+ default: return "____";
}
}
@@ -1949,17 +1949,17 @@ free_unused_heaps()
int i, j;
for (i = j = 1; j < heaps_used; i++) {
- if (heaps[i].limit == 0) {
+ if (heaps[i].limit == 0) {
free(heaps[i].membase);
- free(heaps[i].marks);
- heaps_used--;
- }
- else {
- if (i != j) {
- heaps[j] = heaps[i];
- }
- j++;
- }
+ free(heaps[i].marks);
+ heaps_used--;
+ }
+ else {
+ if (i != j) {
+ heaps[j] = heaps[i];
+ }
+ j++;
+ }
}
}
@@ -1978,11 +1978,11 @@ remembered_set_recycle()
if (rb_mark_table_contains((RVALUE *)rem->obj)) {
top = rem;
++kept;
- }
+ }
else {
if (top) {
top->next = next;
- }
+ }
else {
remembered_set_ptr = next;
}
@@ -1990,7 +1990,7 @@ remembered_set_recycle()
rem->next = remembered_set_freed;
remembered_set_freed = rem;
++recycled;
- }
+ }
rem = next;
}
GC_DEBUG_PRINTF(" Remembered set kept: %8d\n", kept)
@@ -2031,7 +2031,7 @@ gc_sweep(heaps_space_t *heaps_space)
longlife_moved_objs_count = 0;
} else {
fprintf(gc_data_file, " %s collection\n", heaps_space_name);
- }
+ }
MEMZERO(&free_counts, int, OBJ_TYPE_COUNT);
MEMZERO(&live_counts, int, OBJ_TYPE_COUNT);
}
@@ -2050,7 +2050,7 @@ gc_sweep(heaps_space_t *heaps_space)
#endif
for (i = heaps_used - 1; i >= 0; i--) {
- heap = &heaps[i];
+ heap = &heaps[i];
if (heap->lifetime != lt) continue;
RVALUE *free = heaps_space->freelist;
@@ -2067,51 +2067,51 @@ gc_sweep(heaps_space_t *heaps_space)
p = pstart + heap->limit;
while (p-- > pstart) {
type = BUILTIN_TYPE(p);
- if (!rb_mark_table_heap_contains(heap, p)) {
- if (p->as.basic.flags) {
+ if (!rb_mark_table_heap_contains(heap, p)) {
+ if (p->as.basic.flags) {
#ifdef GC_DEBUG
if (GC_DEBUG_ON && gc_debug_dump) {
gc_debug_add_to_source_pos_table(freed_objects_table, p, type);
- }
+ }
#endif
deferred = obj_free((VALUE)p);
if (deferred || ((FL_TEST(p, FL_FINALIZE)) && need_call_final)) {
- /* This object has a finalizer, so don't free it right now, but do it later. */
+ /* This object has a finalizer, so don't free it right now, but do it later. */
finalized_slots++;
- if (!deferred) {
- p->as.free.flags = T_DEFERRED;
- RDATA(p)->dfree = 0;
- }
- rb_mark_table_heap_add(heap, p); /* remain marked */
- p->as.free.next = final_list;
- final_list = p;
+ if (!deferred) {
+ p->as.free.flags = T_DEFERRED;
+ RDATA(p)->dfree = 0;
+ }
+ rb_mark_table_heap_add(heap, p); /* remain marked */
+ p->as.free.next = final_list;
+ final_list = p;
} else {
newly_freed_slots++;
#ifdef GC_DEBUG
if (GC_DEBUG_ON && type) free_counts[type]++;
#endif
push_freelist(heaps_space, p);
- }
+ }
} else {
already_freed_slots++;
push_freelist(heaps_space, p);
- }
+ }
#ifdef GC_DEBUG
} else if (type == T_DEFERRED) {
live_slots++;
- /* objects to be finalized */
- /* do nothing remain marked */
+ /* objects to be finalized */
+ /* do nothing remain marked */
} else {
live_slots++;
if (GC_DEBUG_ON) {
live_counts[type]++;
if (gc_debug_dump) {
gc_debug_add_to_source_pos_table(live_objects_table, p, type);
- }
- }
+ }
+ }
#endif
- }
- }
+ }
+ }
free_slots = already_freed_slots + newly_freed_slots + finalized_slots;
total_free_slots += free_slots;
@@ -2133,17 +2133,17 @@ gc_sweep(heaps_space_t *heaps_space)
/* Shrink eden if there is a freeable heap and we are over our target size */
(lt == lifetime_eden && (heaps_space->num_heaps > eden_heaps))) {
GC_DEBUG_PRINTF(" %s heap freed (size %d)\n", heaps_space_name, heap->limit)
- RVALUE *pp;
+ RVALUE *pp;
heaps_space->heap_slots_total -= heap->limit;
heaps_space->num_heaps--;
heap->limit = 0;
heap->slotlimit = heap->slot;
- for (pp = final_list; pp != final; pp = pp->as.free.next) {
- pp->as.free.flags |= FL_SINGLETON; /* freeing page mark */
- }
+ for (pp = final_list; pp != final; pp = pp->as.free.next) {
+ pp->as.free.flags |= FL_SINGLETON; /* freeing page mark */
+ }
heaps_space->freelist = free; /* cancel this page from freelist */
- }
- }
+ }
+ }
}
if ((lt == lifetime_longlife &&
@@ -2169,17 +2169,17 @@ gc_sweep(heaps_space_t *heaps_space)
remembered_set_recycle();
} else { /* lt == lifetime_eden */
during_gc = 0;
- /* clear finalization list */
- if (final_list) {
- deferred_final_list = final_list;
+ /* clear finalization list */
+ if (final_list) {
+ deferred_final_list = final_list;
if (!rb_thread_critical) {
- rb_gc_finalize_deferred();
+ rb_gc_finalize_deferred();
} else {
- rb_thread_pending = 1;
- }
+ rb_thread_pending = 1;
+ }
+ }
+ free_unused_heaps();
}
- free_unused_heaps();
-}
#ifdef GC_DEBUG
if (GC_DEBUG_ON) {
@@ -2197,17 +2197,17 @@ gc_sweep(heaps_space_t *heaps_space)
for(i = 0; i < OBJ_TYPE_COUNT; i++) {
if (free_counts[i] > 0 || live_counts[i] > 0) {
fprintf(gc_data_file, " %-8s %8d %8d\n", obj_type(i), live_counts[i], free_counts[i]);
- }
-}
- }
+ }
+ }
+ }
if (gc_debug_dump) {
gc_debug_dump_source_pos_table(live_objects_table, lt, "live");
gc_debug_dump_source_pos_table(freed_objects_table, lt, "freed");
st_free_table(live_objects_table);
st_free_table(freed_objects_table);
- }
- }
+ }
+ }
#endif
if (lt == lifetime_eden) {
@@ -2218,12 +2218,12 @@ gc_sweep(heaps_space_t *heaps_space)
if (longlife_collection) {
st_foreach(source_positions, sweep_source_pos, 0);
GC_DEBUG_PRINTF(" Source position freed structs: %8d\n", prev_source_positions_count - source_positions->num_entries)
- }
+ }
GC_DEBUG_PRINTF(" Source position live structs: %8d\n", source_positions->num_entries)
- }
+ }
#endif
if (longlife_collection) {
- st_foreach(source_filenames, sweep_source_filename, 0);
+ st_foreach(source_filenames, sweep_source_filename, 0);
GC_DEBUG_PRINTF(" Source filename freed strings: %8d\n", prev_sourcefiles_count - source_filenames->num_entries)
}
GC_DEBUG_PRINTF(" Source filename live strings: %8d\n", source_filenames->num_entries)
@@ -2254,124 +2254,124 @@ obj_free(obj)
case T_FIXNUM:
case T_TRUE:
case T_FALSE:
- rb_bug("obj_free() called for broken object");
- break;
+ rb_bug("obj_free() called for broken object");
+ break;
}
if (FL_TEST(obj, FL_EXIVAR)) {
- rb_free_generic_ivar((VALUE)obj);
+ rb_free_generic_ivar((VALUE)obj);
}
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
- if (RANY(obj)->as.object.iv_tbl) {
- st_free_table(RANY(obj)->as.object.iv_tbl);
- }
- break;
+ if (RANY(obj)->as.object.iv_tbl) {
+ st_free_table(RANY(obj)->as.object.iv_tbl);
+ }
+ break;
case T_MODULE:
case T_CLASS:
- rb_clear_cache_by_class((VALUE)obj);
- st_free_table(RANY(obj)->as.klass.m_tbl);
- if (RANY(obj)->as.object.iv_tbl) {
- st_free_table(RANY(obj)->as.object.iv_tbl);
- }
- break;
+ rb_clear_cache_by_class((VALUE)obj);
+ st_free_table(RANY(obj)->as.klass.m_tbl);
+ if (RANY(obj)->as.object.iv_tbl) {
+ st_free_table(RANY(obj)->as.object.iv_tbl);
+ }
+ break;
case T_STRING:
- if (RANY(obj)->as.string.ptr && !FL_TEST(obj, ELTS_SHARED)) {
- RUBY_CRITICAL(free(RANY(obj)->as.string.ptr));
- }
- break;
+ if (RANY(obj)->as.string.ptr && !FL_TEST(obj, ELTS_SHARED)) {
+ RUBY_CRITICAL(free(RANY(obj)->as.string.ptr));
+ }
+ break;
case T_ARRAY:
- if (RANY(obj)->as.array.ptr && !FL_TEST(obj, ELTS_SHARED)) {
- RUBY_CRITICAL(free(RANY(obj)->as.array.ptr));
- }
- break;
+ if (RANY(obj)->as.array.ptr && !FL_TEST(obj, ELTS_SHARED)) {
+ RUBY_CRITICAL(free(RANY(obj)->as.array.ptr));
+ }
+ break;
case T_HASH:
- if (RANY(obj)->as.hash.tbl) {
- st_free_table(RANY(obj)->as.hash.tbl);
- }
- break;
+ if (RANY(obj)->as.hash.tbl) {
+ st_free_table(RANY(obj)->as.hash.tbl);
+ }
+ break;
case T_REGEXP:
- if (RANY(obj)->as.regexp.ptr) {
- re_free_pattern(RANY(obj)->as.regexp.ptr);
- }
- if (RANY(obj)->as.regexp.str) {
- RUBY_CRITICAL(free(RANY(obj)->as.regexp.str));
- }
- break;
+ if (RANY(obj)->as.regexp.ptr) {
+ re_free_pattern(RANY(obj)->as.regexp.ptr);
+ }
+ if (RANY(obj)->as.regexp.str) {
+ RUBY_CRITICAL(free(RANY(obj)->as.regexp.str));
+ }
+ break;
case T_DATA:
- if (DATA_PTR(obj)) {
- if ((long)RANY(obj)->as.data.dfree == -1) {
- RUBY_CRITICAL(free(DATA_PTR(obj)));
- }
- else if (RANY(obj)->as.data.dfree) {
- make_deferred(RANY(obj));
- return 1;
- }
- }
- break;
+ if (DATA_PTR(obj)) {
+ if ((long)RANY(obj)->as.data.dfree == -1) {
+ RUBY_CRITICAL(free(DATA_PTR(obj)));
+ }
+ else if (RANY(obj)->as.data.dfree) {
+ make_deferred(RANY(obj));
+ return 1;
+ }
+ }
+ break;
case T_MATCH:
- if (RANY(obj)->as.match.regs) {
- re_free_registers(RANY(obj)->as.match.regs);
- RUBY_CRITICAL(free(RANY(obj)->as.match.regs));
- }
- break;
+ if (RANY(obj)->as.match.regs) {
+ re_free_registers(RANY(obj)->as.match.regs);
+ RUBY_CRITICAL(free(RANY(obj)->as.match.regs));
+ }
+ break;
case T_FILE:
- if (RANY(obj)->as.file.fptr) {
- struct rb_io_t *fptr = RANY(obj)->as.file.fptr;
- make_deferred(RANY(obj));
- RDATA(obj)->dfree = (void (*)(void*))rb_io_fptr_finalize;
- RDATA(obj)->data = fptr;
- return 1;
- }
- break;
+ if (RANY(obj)->as.file.fptr) {
+ struct rb_io_t *fptr = RANY(obj)->as.file.fptr;
+ make_deferred(RANY(obj));
+ RDATA(obj)->dfree = (void (*)(void*))rb_io_fptr_finalize;
+ RDATA(obj)->data = fptr;
+ return 1;
+ }
+ break;
case T_ICLASS:
- /* iClass shares table with the module */
- break;
+ /* iClass shares table with the module */
+ break;
case T_FLOAT:
case T_VARMAP:
case T_BLKTAG:
- break;
+ break;
case T_BIGNUM:
- if (RANY(obj)->as.bignum.digits) {
- RUBY_CRITICAL(free(RANY(obj)->as.bignum.digits));
- }
- break;
+ if (RANY(obj)->as.bignum.digits) {
+ RUBY_CRITICAL(free(RANY(obj)->as.bignum.digits));
+ }
+ break;