Skip to content

Commit

Permalink
Merge branch 'master', remote-tracking branch 'origin' into 2.0.testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Sep 13, 2012
2 parents e6bd17c + 2acbc7d commit a5a51aa
Show file tree
Hide file tree
Showing 37 changed files with 687 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -25,14 +25,14 @@ artifacts/
.depends.mf
/rubinius_tasks.dot
/nbproject
/coverage
.project
CI-specs
COMMIT
TAGS
\#*
autom4te.cache
code-cache
coverage
/config.rb
cscope.files
cscope.out
Expand Down
28 changes: 13 additions & 15 deletions kernel/bootstrap/thread.rb
Expand Up @@ -148,10 +148,9 @@ def thread_is_setup?
end

def alive?
@lock.receive
@alive
ensure
@lock.send nil
Rubinius.synchronize(self) do
@alive
end
end

def stop?
Expand All @@ -169,10 +168,9 @@ def kill
alias_method :terminate, :kill

def sleeping?
@lock.receive
@sleep
ensure
@lock.send nil
Rubinius.synchronize(self) do
@sleep
end
end

def status
Expand Down Expand Up @@ -205,12 +203,12 @@ def add_to_group(group)

def join_inner(timeout = undefined)
result = nil
@lock.receive
Rubinius.lock(self)
begin
if @alive
jc = Rubinius::Channel.new
@joins << jc
@lock.send nil
Rubinius.unlock(self)
begin
if timeout.equal? undefined
while true
Expand All @@ -231,23 +229,23 @@ def join_inner(timeout = undefined)
end
end
ensure
@lock.receive
Rubinius.lock(self)
end
end
Kernel.raise @exception if @exception
result = yield
ensure
@lock.send nil
Rubinius.unlock(self)
end
result
end
private :join_inner

def raise(exc=$!, msg=nil, trace=nil)
@lock.receive
Rubinius.lock(self)

unless @alive
@lock.send nil
Rubinius.unlock(self)
return self
end

Expand All @@ -268,7 +266,7 @@ def raise(exc=$!, msg=nil, trace=nil)

Kernel.raise exc if self == Thread.current
ensure
@lock.send nil
Rubinius.unlock(self)
end

raise_prim exc
Expand Down
10 changes: 4 additions & 6 deletions kernel/bootstrap/thread18.rb
Expand Up @@ -53,11 +53,10 @@ def self.critical=(value)
def __run__()
begin
begin
@lock.send nil
Rubinius.unlock(self)
@result = @block.call(*@args)
ensure
@lock.receive
unlock_locks
Rubinius.lock(self)
@joins.each { |join| join.send self }
end
rescue Die
Expand All @@ -68,7 +67,8 @@ def __run__()
@exception = e # unless @dying
ensure
@alive = false
@lock.send nil
Rubinius.unlock(self)
unlock_locks
end

if @exception
Expand All @@ -87,8 +87,6 @@ def setup(prime_lock)
@exception = nil
@critical = false
@dying = false
@lock = Rubinius::Channel.new
@lock.send nil if prime_lock
@joins = []
end

Expand Down
10 changes: 4 additions & 6 deletions kernel/bootstrap/thread19.rb
Expand Up @@ -38,11 +38,10 @@ def self.stop
def __run__()
begin
begin
@lock.send nil
Rubinius.unlock(self)
@result = @block.call(*@args)
ensure
@lock.receive
unlock_locks
Rubinius.lock(self)
@joins.each { |join| join.send self }
end
rescue Die
Expand All @@ -54,7 +53,8 @@ def __run__()
@exception = e # unless @dying
ensure
@alive = false
@lock.send nil
Rubinius.unlock(self)
unlock_locks
end

if @exception
Expand All @@ -73,8 +73,6 @@ def setup(prime_lock)
@exception = nil
@critical = false
@dying = false
@lock = Rubinius::Channel.new
@lock.send nil if prime_lock
@joins = []
@killed = false
end
Expand Down
2 changes: 1 addition & 1 deletion kernel/delta/rubinius.rb
Expand Up @@ -295,7 +295,7 @@ def self.terminal_width
end
end
end
@terminal_width = 80 if @terminal_width.zero?
@terminal_width = 80 if @terminal_width.nil? || @terminal_width.zero?
@terminal_width
end

Expand Down
2 changes: 1 addition & 1 deletion kernel/platform/posix.rb
Expand Up @@ -44,7 +44,7 @@ module FFI::Platform::POSIX

# File/IO
attach_function :fcntl, [:int, :int, :long], :int
attach_function :ioctl, [:int, :int, :long], :int
attach_function :ioctl, [:int, :ulong, :long], :int
attach_function :fsync, [:int], :int
attach_function :dup, [:int], :int

Expand Down
53 changes: 53 additions & 0 deletions lib/19/coverage.rb
@@ -0,0 +1,53 @@
module Coverage
@coverage_tool = nil

def self.start
require 'tooling/coverage'

@coverage_tool = Rubinius::Coverage.new
@coverage_tool.start
end

def self.result
return unless @coverage_tool

map = @coverage_tool.stop.results

kernel = File.dirname Rubinius::KERNEL_PATH

coverage = Hash.new { |h, k| h[k] = [] }

map.each do |id, attr|
counts = attr[:counts]
code = attr[:code]
next unless code

file = code.file.to_s
next if file[0] == ?(
file = File.join kernel, file unless file[0] == ?/

code.lines.to_a.drop(1).each_slice(2) do |line, _|
next unless line > 0
next if coverage[file][line - 1]

coverage[file][line - 1] = 0
end

counts.each do |ip, count|
line = code.line_from_ip(ip)
next unless line > 0

coverage[file][line - 1] = count
end
end

coverage.each do |file, counts|
lines = File.open(file, "r") { |f| f.lines.count }
next unless lines > 0

counts[lines - 1] = nil unless counts.size == lines
end

coverage
end
end
18 changes: 13 additions & 5 deletions lib/iconv.rb
Expand Up @@ -4,14 +4,22 @@
class Iconv
extend FFI::Library

def self.iconv_attach(libsymbol, libname, par_array, return_type)
begin
attach_function libsymbol, libname, par_array, return_type
rescue
attach_function libsymbol, "lib"+libname, par_array, return_type
end
end
private_class_method :iconv_attach

# Use libiconv if it exists, otherwise get the symbols from the current
# process.
ffi_lib ["libiconv.2.dylib", "libiconv.so.2", "libiconv", FFI::CURRENT_PROCESS]

attach_function :create, "iconv_open", [:string, :string], :pointer
attach_function :close, "iconv_close", [:pointer], :int
attach_function :convert, "iconv",
[:pointer, :pointer, :pointer, :pointer, :pointer], :long
iconv_attach :create, "iconv_open", [:string, :string], :pointer
iconv_attach :close, "iconv_close", [:pointer], :int
iconv_attach :convert, "iconv",
[:pointer, :pointer, :pointer, :pointer, :pointer], :long

module Failure
attr_reader :success
Expand Down
1 change: 1 addition & 0 deletions lib/tooling/coverage.rb
@@ -0,0 +1 @@
require 'tooling/coverage/coverage'
38 changes: 38 additions & 0 deletions lib/tooling/coverage/coverage.rb
@@ -0,0 +1,38 @@
module Rubinius
class Coverage
def self.loaded(flag)
@loaded = flag
end

def self.loaded?
@loaded == true
end

def self.load
return if loaded?

Tooling.load File.expand_path("../ext/coverage", __FILE__)
loaded true

self
end

attr_reader :results

def initialize
self.class.load
end

def start
Rubinius::Tooling.enable

self
end

def stop
@results = Rubinius::Tooling.disable

self
end
end
end

0 comments on commit a5a51aa

Please sign in to comment.