Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ff2c3ec6715a
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2f8dac4b36da
Choose a head ref
  • 13 commits
  • 33 files changed
  • 1 contributor

Commits on May 28, 2015

  1. Copy the full SHA
    3b869bf View commit details

Commits on May 29, 2015

  1. Added CodeDB::open and ::load.

    brixen committed May 29, 2015
    Copy the full SHA
    d90ca6d View commit details
  2. Copy the full SHA
    7a2494b View commit details
  3. Added signature to CodeDB.

    brixen committed May 29, 2015
    Copy the full SHA
    9c0eb68 View commit details
  4. Copy the full SHA
    7ea55f2 View commit details
  5. Added m_id to CodeDB contents.

    brixen committed May 29, 2015
    Copy the full SHA
    82bdff7 View commit details

Commits on May 30, 2015

  1. Copy the full SHA
    7d32e21 View commit details

Commits on May 31, 2015

  1. Copy the full SHA
    8b9d42a View commit details
  2. Copy the full SHA
    5db6078 View commit details
  3. Copy the full SHA
    6ee2440 View commit details

Commits on Jun 1, 2015

  1. Boot kernel from CodeDB.

    brixen committed Jun 1, 2015
    Copy the full SHA
    4cf95e2 View commit details
  2. Copy the full SHA
    a5c5ee0 View commit details
  3. Fixed String#replace.

    The store_my_field bug hid this bug.
    brixen committed Jun 1, 2015
    Copy the full SHA
    2f8dac4 View commit details
32 changes: 23 additions & 9 deletions kernel/alpha.rb
Original file line number Diff line number Diff line change
@@ -354,7 +354,7 @@ def lookup(name)

# Store Executable under name, with given visibility.
#
def store(name, exec, visibility)
def store(name, method_id, exec, scope, serial, visibility)
Rubinius.primitive :methodtable_store
raise PrimitiveFailure, "MethodTable#store primitive failed"
end
@@ -469,9 +469,7 @@ def self.allocate
# Redefined in kernel/common/module.rb
#
def const_missing(name)
Rubinius::VM.write_error "Missing or uninitialized constant: \n"
Rubinius::VM.write_error name.to_s
Rubinius::VM.write_error "\n"
Rubinius::VM.write_error "Missing or uninitialized constant: #{name.to_s}"
end

# Set Module's direct superclass.
@@ -532,14 +530,14 @@ def include(mod)
#
def attr_reader(name)
meth = Rubinius::AccessVariable.get_ivar name
@method_table.store name, meth, :public
@method_table.store name, nil, meth, nil, 0, :public
Rubinius::VM.reset_method_cache self, name
nil
end

def attr_reader_specific(name, method_name)
meth = Rubinius::AccessVariable.get_ivar name
@method_table.store method_name, meth, :public
@method_table.store method_name, nil, meth, nil, 0, :public
Rubinius::VM.reset_method_cache self, method_name
nil
end
@@ -553,7 +551,7 @@ def attr_reader_specific(name, method_name)
def attr_writer(name)
meth = Rubinius::AccessVariable.set_ivar name
writer_name = "#{name}=".to_sym
@method_table.store writer_name, meth, :public
@method_table.store writer_name, nil, meth, nil, 0, :public
Rubinius::VM.reset_method_cache self, writer_name
nil
end
@@ -624,7 +622,8 @@ def alias_method(new_name, current_name)
# If we're aliasing a method we contain, just reference it directly, no
# need for the alias wrapper
if entry = @method_table.lookup(current_name)
@method_table.store new_name, entry.method, entry.visibility
@method_table.store new_name, entry.method_id, entry.method,
entry.scope, entry.serial, entry.visibility
else
mod = direct_superclass()
while mod
@@ -654,7 +653,8 @@ def alias_method(new_name, current_name)
def module_function(name)
if entry = @method_table.lookup(name)
sc = class << self; self; end
sc.method_table.store name, entry.method, :public
sc.method_table.store name, entry.method_id, entry.method,
entry.scope, entry.serial, :public
Rubinius::VM.reset_method_cache self, name
private name
end
@@ -664,6 +664,12 @@ def track_subclass(cls)
Rubinius.primitive :module_track_subclass
raise PrimitiveFailure, "Module.track_subclass primitive failed"
end

def custom_call_site(name)
if entry = @method_table.lookup(name)
entry.get_method.custom_call_site
end
end
end


@@ -680,7 +686,15 @@ class AccessVariable
#
class MethodTable::Bucket
attr_accessor :visibility
attr_accessor :method_id
attr_accessor :method
attr_accessor :scope
attr_accessor :serial

def get_method
Rubinius.primitive :methodtable_bucket_get_method
raise PrimitiveFailure, "MethodTable::Bucket#get_method primitive failed"
end

def public?
@visibility == :public
4 changes: 3 additions & 1 deletion kernel/bootstrap/kernel.rb
Original file line number Diff line number Diff line change
@@ -92,7 +92,9 @@ def untrusted?
# methods.
def respond_to?(meth, include_private=false)
respond_to_prim?(meth, include_private)
end.custom_call_site
end

custom_call_site :respond_to?

def respond_to_missing?(meth, include_private)
false
8 changes: 6 additions & 2 deletions kernel/bootstrap/rubinius.rb
Original file line number Diff line number Diff line change
@@ -70,8 +70,12 @@ def self.mri_backtrace(skip)
raise PrimitiveFailure, "Rubinius.mri_backtrace primitive failed"
end

def self.add_method(name, executable, mod, vis)
mod.method_table.store name, executable, :public
def self.add_method(name, executable, mod, serial, vis)
if executable.kind_of? String
mod.method_table.store name, executable, nil, serial, :public
else
mod.method_table.store name, nil, executable, serial, :public
end
Rubinius::VM.reset_method_cache mod, name
end

2 changes: 1 addition & 1 deletion kernel/common/compiled_code.rb
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ def create_script(wrap=false)
end

sc = Rubinius::Type.object_singleton_class(MAIN)
sc.method_table.store :__script__, self, :public
sc.method_table.store :__script__, nil, self, @scope, 0, :public
VM.reset_method_cache sc, :__script__

script
26 changes: 16 additions & 10 deletions kernel/common/module.rb
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ def instance_method(name)
if mod == mod.origin && entry = mod.method_table.lookup(name)
break if entry.visibility == :undef

if meth = entry.method
if meth = entry.get_method
if meth.kind_of? Rubinius::Alias
meth = meth.original_exec
end
@@ -333,7 +333,7 @@ def undef_method(*names)
def undef_method!(name)
Rubinius.check_frozen
name = Rubinius::Type.coerce_to_symbol(name)
@method_table.store name, nil, :undef
@method_table.store name, nil, nil, nil, 0, :undef
Rubinius::VM.reset_method_cache self, name
if obj = Rubinius::Type.singleton_class_object(self)
Rubinius.privately do
@@ -479,6 +479,8 @@ def define_method(name, meth = undefined, &prc)
meth = meth.dup
meth.lambda_style!
end

scope = meth.block.scope
when Method
Rubinius::Type.bindable_method? meth.defined_in, self.class

@@ -492,6 +494,8 @@ def define_method(name, meth = undefined, &prc)
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth.unbind, true)
end

scope = exec.scope
when UnboundMethod
Rubinius::Type.bindable_method? meth.defined_in, self.class

@@ -502,11 +506,13 @@ def define_method(name, meth = undefined, &prc)
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)
end

scope = exec.scope
else
raise TypeError, "wrong argument type #{meth.class} (expected Proc/Method)"
end

Rubinius.add_method name, code, self, :public
Rubinius.add_method name, code, self, scope, 0, :public

name
end
@@ -516,7 +522,7 @@ def define_method(name, meth = undefined, &prc)
def thunk_method(name, value)
thunk = Rubinius::Thunk.new(value)
name = Rubinius::Type.coerce_to_symbol name
Rubinius.add_method name, thunk, self, :public
Rubinius.add_method name, thunk, self, nil, 0, :public

name
end
@@ -559,7 +565,7 @@ def set_visibility(meth, vis, where=nil)
if entry = @method_table.lookup(name)
entry.visibility = vis
elsif lookup_method(name)
@method_table.store name, nil, vis
@method_table.store name, nil, nil, nil, 0, vis
else
raise NameError.new("Unknown #{where}method '#{name}' to make #{vis.to_s} (#{self})", name)
end
@@ -828,10 +834,10 @@ def dynamic_method(name, file="(dynamic)", line=1)

code = g.package Rubinius::CompiledCode

code.scope =
Rubinius::ConstantScope.new(self, Rubinius::ConstantScope.new(Object))
scope = Rubinius::ConstantScope.new(self, Rubinius::ConstantScope.new(Object))
code.scope = scope

Rubinius.add_method name, code, self, :public
Rubinius.add_method name, code, self, scope, 0, :public

return code
end
@@ -844,7 +850,7 @@ def freeze

def attr_reader(name)
meth = Rubinius::AccessVariable.get_ivar name
@method_table.store name, meth, :public
@method_table.store name, nil, meth, nil, 0, :public
Rubinius::VM.reset_method_cache self, name
ivar_name = "@#{name}".to_sym
if @seen_ivars
@@ -861,7 +867,7 @@ def attr_reader(name)
def attr_writer(name)
meth = Rubinius::AccessVariable.set_ivar name
writer_name = "#{name}=".to_sym
@method_table.store writer_name, meth, :public
@method_table.store writer_name, nil, meth, nil, 0, :public
Rubinius::VM.reset_method_cache self, writer_name
ivar_name = "@#{name}".to_sym
if @seen_ivars
8 changes: 6 additions & 2 deletions kernel/common/string.rb
Original file line number Diff line number Diff line change
@@ -1544,8 +1544,12 @@ def replace(other)
other = StringValue(other)

@shared = true
other.shared!
@data = other.__data__
if other.frozen?
@data = other.__data__.dup
else
other.shared!
@data = other.__data__
end
self.num_bytes = other.num_bytes
@hash_value = nil
force_encoding(other.encoding)
2 changes: 1 addition & 1 deletion kernel/delta/class.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
code = Class.method_table.lookup(:new).method
code = Class.method_table.lookup(:new).get_method
code.serial = Rubinius::CompiledCode::KernelMethodSerial

class Class
12 changes: 7 additions & 5 deletions kernel/delta/module.rb
Original file line number Diff line number Diff line change
@@ -13,11 +13,12 @@ def alias_method(new_name, current_name)
# The 'and entry.method' is there to force us to use the alias code
# when the original method exists only to change the visibility of
# a parent method.
if mod == self and entry.method
@method_table.store new_name, entry.method, method_visibility
if mod == self and entry.get_method
@method_table.store new_name, entry.method_id, entry.method,
entry.scope, entry.serial, method_visibility
else
@method_table.alias new_name, method_visibility, current_name,
entry.method, mod
entry.get_method, mod
end

Rubinius::VM.reset_method_cache self, new_name
@@ -53,8 +54,9 @@ def module_function(*args)
sc = Rubinius::Type.object_singleton_class(self)
args.each do |meth|
method_name = Rubinius::Type.coerce_to_symbol meth
mod, method = lookup_method(method_name)
sc.method_table.store method_name, method.method, :public
mod, entry = lookup_method(method_name)
sc.method_table.store method_name, entry.method_id, entry.method,
entry.scope, entry.serial, :public
Rubinius::VM.reset_method_cache self, method_name
set_visibility method_name, :private
end
22 changes: 16 additions & 6 deletions kernel/delta/rubinius.rb
Original file line number Diff line number Diff line change
@@ -87,6 +87,8 @@ def self.open_module(name, scope)
end

def self.add_defn_method(name, executable, constant_scope, vis)
# TODO: puts serial on MethodTable entry
unless Type.object_kind_of? executable, String
executable.serial = 1
if executable.respond_to? :scope=
# If we're adding a method inside ane eval, dup it so that
@@ -99,6 +101,7 @@ def self.add_defn_method(name, executable, constant_scope, vis)
end
executable.scope = constant_scope
end
end

mod = constant_scope.for_method_definition

@@ -113,11 +116,11 @@ def self.add_defn_method(name, executable, constant_scope, vis)
end
end

add_method name, executable, mod, vis
add_method name, executable, mod, constant_scope, 1, vis
name
end

def self.add_method(name, executable, mod, vis)
def self.add_method(name, executable, mod, scope, serial, vis)
vis ||= :public

# Don't change the visibility for methods added to singleton
@@ -130,7 +133,11 @@ def self.add_method(name, executable, mod, vis)
visibility = vis
end

mod.method_table.store name, executable, visibility
if Type.object_kind_of? executable, String
mod.method_table.store name, executable, nil, scope, serial, visibility
else
mod.method_table.store name, nil, executable, scope, serial, visibility
end
Rubinius::VM.reset_method_cache mod, name

Rubinius.privately do
@@ -180,6 +187,8 @@ def self.privatized_method?(name)
# Must be AFTER add_method, because otherwise we'll run this attach_method to add
# add_method itself and fail.
def self.attach_method(name, executable, constant_scope, recv)
# TODO: puts serial on MethodTable entry
unless Type.object_kind_of? executable, String
executable.serial = 1
if executable.respond_to? :scope=
# If we're adding a method inside ane eval, dup it so that
@@ -192,23 +201,24 @@ def self.attach_method(name, executable, constant_scope, recv)
end
executable.scope = constant_scope
end
end

mod = Rubinius::Type.object_singleton_class recv

add_method name, executable, mod, :public
add_method name, executable, mod, constant_scope, 1, :public
name
end


def self.add_reader(name, mod, vis)
normalized = Rubinius::Type.coerce_to_symbol(name)
add_method normalized, AccessVariable.get_ivar(normalized), mod, vis
add_method normalized, AccessVariable.get_ivar(normalized), mod, nil, 0, vis
end

def self.add_writer(name, mod, vis)
normalized = Rubinius::Type.coerce_to_symbol(name)
writer_name = "#{normalized}=".to_sym
add_method writer_name, AccessVariable.set_ivar(normalized), mod, vis
add_method writer_name, AccessVariable.set_ivar(normalized), mod, nil, 0, vis
end

def self.received_signal(sig)
4 changes: 2 additions & 2 deletions kernel/platform/library.rb
Original file line number Diff line number Diff line change
@@ -201,11 +201,11 @@ def ffi_function_missing(cname, mname, args, ret)
def add_function(name, func)
# Make it available as a method callable directly..
sc = Rubinius::Type.object_singleton_class(self)
sc.method_table.store name, func, :public
sc.method_table.store name, nil, func, nil, 0, :public

# and expose it as a private method for people who
# want to include this module.
method_table.store name, func, :private
method_table.store name, nil, func, nil, 0, :private
end
private :add_function

6 changes: 3 additions & 3 deletions kernel/platform/pointer.rb
Original file line number Diff line number Diff line change
@@ -426,7 +426,7 @@ def initialize(ret_type, arg_types, val=nil, options=nil, &block)
# Hook the created function into the method_table so that #call goes
# straight to it.
sc = Rubinius::Type.object_singleton_class(self)
sc.method_table.store :call, @function, :public
sc.method_table.store :call, nil, @function, nil, 0, :public
end

attr_reader :function
@@ -441,11 +441,11 @@ def attach(mod, name)

# Make it available as a method callable directly..
sc = Rubinius::Type.object_singleton_class(mod)
sc.method_table.store name, @function, :public
sc.method_table.store name, nil, @function, nil, 0, :public

# and expose it as a private method for people who
# want to include this module.
mod.method_table.store name, @function, :public
mod.method_table.store name, nil, @function, nil, 0, :public
end
end
end
Loading