Skip to content
Permalink
Browse files
Reorganized kernel to improve loading order.
These are the desired phases for booting Rubinius:

1. boot the VM itself with the ability to load and execute bytecode;
2. create the bootstrap methods and functions to be able to define
   class/module and methods;
3. load the kernel code, only defining class/module and methods;
4. run all 'init' / setup code for the kernel, defining initial runtime data
   structures and constant values;
5. create the Loader instance and parse command line options;
6. run user code.
  • Loading branch information
brixen committed Jan 31, 2016
1 parent 3a683eb commit fb59e4de2832240535166a33c171c4f8166f2e37
Showing with 1,431 additions and 1,563 deletions.
  1. +1 −0 .gitignore
  2. +4 −10 kernel/alpha.rb
  3. +1 −8 kernel/argf.rb
  4. +2 −9 kernel/array.rb
  5. +0 −1 kernel/array_mirror.rb
  6. +5 −6 kernel/autoload.rb
  7. +1 −2 kernel/basic_object.rb
  8. +0 −3 kernel/bignum.rb
  9. +14 −17 kernel/block_environment.rb
  10. +7 −10 kernel/byte_array.rb
  11. +0 −1 kernel/call_custom_cache.rb
  12. +0 −2 kernel/call_site.rb
  13. +0 −1 kernel/capi.rb
  14. +0 −12 kernel/channel.rb
  15. +0 −1 kernel/character.rb
  16. +0 −11 kernel/class.rb
  17. +10 −14 kernel/code_loader.rb
  18. +4 −10 kernel/compiled_code.rb
  19. +0 −2 kernel/complex.rb
  20. +0 −9 kernel/complexifier.rb
  21. +0 −2 kernel/configuration.rb
  22. +0 −2 kernel/constant_cache.rb
  23. +10 −14 kernel/constant_scope.rb
  24. +0 −1 kernel/continuation.rb
  25. +1 −2 kernel/ctype.rb
  26. +3 −1 kernel/deprecations.rb
  27. +2 −3 kernel/dir.rb
  28. +21 −22 kernel/encoding.rb
  29. +0 −55 kernel/enum.rb
  30. +445 −206 kernel/ffi.rb
  31. +147 −150 kernel/io.rb
  32. +10 −90 kernel/kernel.rb
  33. +83 −84 kernel/load_order.txt
  34. +9 −13 kernel/lookup_table.rb
  35. +0 −146 kernel/rubinius.rb
  36. +161 −191 kernel/stat.rb
  37. +0 −1 kernel/stats.rb
  38. +19 −24 kernel/string.rb
  39. +0 −315 kernel/struct.rb
  40. +2 −3 kernel/symbol.rb
  41. +8 −18 kernel/thread.rb
  42. +0 −20 kernel/throw_catch.rb
  43. +0 −1 kernel/thunk.rb
  44. +2 −8 kernel/time.rb
  45. +0 −4 kernel/true.rb
  46. +1 −13 kernel/tuple.rb
  47. +0 −7 kernel/type.rb
  48. +0 −9 kernel/union.rb
  49. +12 −15 kernel/variable_scope.rb
  50. +0 −1 kernel/vm.rb
  51. +0 −1 kernel/weakref.rb
  52. +445 −0 kernel/zed.rb
  53. +0 −1 library/rubinius/.gitignore
  54. +1 −1 rakelib/configure.rb
  55. +0 −10 rakelib/kernel.rake
@@ -83,6 +83,7 @@ Gemfile.installed.lock
vm/include/capi/ruby/digest.h

/kernel/signature.rb
/kernel/build_config.rb

# Generated documentation
doc/generated/vm
@@ -104,7 +104,6 @@ def new(*args)
end
end


module Kernel

# Return the Class object this object is an instance of.
@@ -244,7 +243,6 @@ def clone
# See kernel/bootstrap/rubinius.rb
#
module Rubinius

module Runtime
def self.dup_as_array(obj)
Rubinius.primitive :array_dup_as_array
@@ -322,7 +320,6 @@ def []=(key, val)
# kernel/common/constant_table.rb
#
class ConstantTable

# Perform lookup for constant name.
#
def lookup(name)
@@ -344,7 +341,6 @@ def store(name, constant, visibility)
# kernel/common/method_table.rb
#
class MethodTable

# Perform lookup for method name.
#
def lookup(name)
@@ -368,7 +364,6 @@ def alias(name, visibility, original_name, original_exec, original_mod)
end
end


class Symbol
# Produce String representation of this Symbol.
#
@@ -384,7 +379,6 @@ def to_sym
end
end


class String
# Returns the <code>Symbol</code> corresponding to <i>self</i>, creating the
# symbol if it did not previously exist. See <code>Symbol#id2name</code>.
@@ -414,7 +408,6 @@ def to_s
end
end


module Process
# Terminate with given status code.
#
@@ -445,7 +438,6 @@ def self.exit!(code=1)
end
end


class Module
def method_table ; @method_table ; end
def constant_table ; @constant_table ; end
@@ -672,9 +664,7 @@ def custom_call_site(name)
end
end


module Rubinius

class AccessVariable
attr_reader :name
end
@@ -795,3 +785,7 @@ class Object
include Kernel
end

module Enumerable; end
class Integer; end
class Numeric; end
class String; end
@@ -530,7 +530,7 @@ def advance!
@advance = false

file = ARGV.shift
@stream = stream(file)
@stream = stream(file)
@filename = file

if $-i && @stream != STDIN
@@ -546,10 +546,3 @@ def advance!
private :advance!
end
end

#
# The virtual concatenation file of the files given on command line (or
# from $stdin if no files were given.) Usable like an IO.
#
ARGF = Rubinius::ARGFClass.new

@@ -1,4 +1,6 @@
class Array
include Enumerable

def self.allocate
Rubinius.primitive :array_allocate
raise PrimitiveFailure, "Array.allocate primitive failed"
@@ -20,12 +22,6 @@ def new_reserved(count)
raise PrimitiveFailure, "Array.new_reserved primitive failed"
end

# THIS MUST NOT BE REMOVED. the kernel requires a simple
# Array#[] to work while parts of the kernel boot.
def [](idx)
at(idx)
end

def []=(idx, ent)
Rubinius.check_frozen

@@ -126,9 +122,6 @@ def to_tuple
tuple.copy_from @tuple, @start, @total, 0
tuple
end
end
class Array
include Enumerable

# The flow control for many of these methods is
# pretty evil due to how MRI works. There is
@@ -91,7 +91,6 @@ def repeated_permutation_size(combination_size)
return 0 if combination_size < 0
@object.size ** combination_size
end

end
end
end
@@ -2,17 +2,17 @@
# Used to implement Module#autoload.

class Autoload
def self.allocate
Rubinius.primitive :autoload_allocate
raise PrimtiveFailure, "Autoload.allocate primitive failed"
end

attr_reader :name
attr_reader :scope
attr_reader :path
attr_reader :constant
attr_reader :thread

def self.allocate
Rubinius.primitive :autoload_allocate
raise PrimtiveFailure, "Autoload.allocate primitive failed"
end

def initialize(name, scope, path)
@name = name
@scope = scope
@@ -98,5 +98,4 @@ def find_const(under)

under.const_missing(name)
end

end
@@ -37,8 +37,7 @@ def __id__
Rubinius.primitive :object_id
raise ::PrimitiveFailure, "BasicObject#__id__ primitive failed"
end
end
class BasicObject

def method_missing(meth, *args)
::Kernel.raise ::NoMethodError, "Unable to send '#{meth}' on instance of BasicObject"
end
@@ -1,5 +1,4 @@
class Bignum < Integer

# unary operators

def ~
@@ -167,8 +166,6 @@ def size
Rubinius.primitive :bignum_size
raise PrimitiveFailure, "Bignum#size primitive failed"
end
end
class Bignum < Integer

# see README-DEVELOPERS regarding safe math compiler plugin
alias_method :/, :divide
@@ -1,5 +1,19 @@
##
# Describes the environment a block was created in. BlockEnvironment is used
# to create a BlockContext.

module Rubinius
class BlockEnvironment
attr_reader :scope
attr_reader :top_scope
attr_reader :module

# The CompiledCode that implements the code for the block
attr_reader :compiled_code
attr_reader :constant_scope

attr_accessor :proc_environment

def self.allocate
Rubinius.primitive :blockenvironment_allocate
raise PrimitiveFailure, "BlockEnvironment.allocate primitive failed"
@@ -62,23 +76,6 @@ def defined_line
@block_env.line
end
end
end
end
##
# Describes the environment a block was created in. BlockEnvironment is used
# to create a BlockContext.

module Rubinius
class BlockEnvironment
attr_reader :scope
attr_reader :top_scope
attr_reader :module

# The CompiledCode that implements the code for the block
attr_reader :compiled_code
attr_reader :constant_scope

attr_accessor :proc_environment

def from_proc?
@proc_environment
@@ -1,3 +1,6 @@
##
# An array of bytes, used as a low-level data store for implementing various
# other classes.
module Rubinius
class ByteArray
def self.allocate
@@ -34,11 +37,15 @@ def get_byte(index)
raise PrimitiveFailure, "ByteArray#get_byte primitive failed"
end

alias_method :[], :get_byte

def set_byte(index, value)
Rubinius.primitive :bytearray_set_byte
raise PrimitiveFailure, "ByteArray#set_byte primitive failed"
end

alias_method :[]=, :set_byte

def compare_bytes(other, a, b)
Rubinius.primitive :bytearray_compare_bytes
raise PrimitiveFailure, "ByteArray#compare_bytes primitive failed"
@@ -87,16 +94,6 @@ def reverse(start, total)
Rubinius.primitive :bytearray_reverse
raise PrimitiveFailure, "ByteArray#reverse primitive failed"
end
end
end
##
# An array of bytes, used as a low-level data store for implementing various
# other classes.

module Rubinius
class ByteArray
alias_method :[], :get_byte
alias_method :[]=, :set_byte

# TODO: encoding
def character_at_index(index)
@@ -11,4 +11,3 @@ def inspect

end
end

@@ -1,6 +1,5 @@
module Rubinius
class CallSite

attr_reader :name
attr_reader :executable

@@ -20,6 +19,5 @@ def location
def inspect
"#<#{self.class.name}:0x#{self.object_id.to_s(16)} #{location}##{@name}(#{hits})>"
end

end
end
@@ -1,5 +1,4 @@
module Rubinius

# CAPI contains utility methods used by capi.
module CAPI
def self.coerce(x, y, error=false)
@@ -8,13 +8,8 @@
# that same thread, the VM wakes up t1 and the value passed to #send is
# returned. This allows us to implement all manner of Thread semantics, such
# as Mutex.
#
# Channel is used heavily by Scheduler, to allow ruby code to interact with
# the outside world in a thread aware manner.

module Rubinius
class Channel

##
# Returns nil if nothing is waiting, or a List object which contains all
# Thread objects waiting on this Channel.
@@ -71,14 +66,7 @@ def try_receive
Rubinius.primitive :channel_try_receive
raise PrimitiveFailure, "Channel#try_receive primitive failed"
end
end
end
##
# A communication mechanism based on pi-calculus channels used primarily to
# communicate between ruby and the VM about events.

module Rubinius
class Channel
def inspect
"#<Rubinius::Channel:0x#{object_id.to_s(16)}>"
end
@@ -1,6 +1,5 @@
module Rubinius
class Character < ::String

def self.__allocate__
Rubinius.primitive :character_allocate
raise PrimitiveFailure, "Rubinius::Character.allocate primitive failed"
@@ -11,8 +11,6 @@ def set_superclass(sup)
end

private :set_superclass
end
class Class

def initialize(sclass=Object, name=nil, under=nil)
raise TypeError, "already initialized class" if @instance_type
@@ -65,12 +63,3 @@ def superclass
return cls
end
end
code = Class.method_table.lookup(:new).get_method
code.serial = Rubinius::CompiledCode::KernelMethodSerial

class Class
undef_method :append_features
undef_method :extend_object
undef_method :module_function
undef_method :prepend_features
end
Loading

0 comments on commit fb59e4d

Please sign in to comment.