Permalink
Browse files

Complete reorganization of bootstrap. Addition of kernel/platform. FF…

…I fixed.

New restrictions for meta-programming in core bodies (not in methods).
kernel/platform is now where platform specific code, mainly related to FFI, lives.
A bunch of FFI bugs have been fixed and it should be working much better now.

FFI Note: you may now only specify :state as your first argument, and you must
leave it off when you call the method (rather than passing nil like before).
  • Loading branch information...
1 parent d9da6dc commit 541bcb521a8ee589c7d28c095ad7ee1489af42db @evanphx evanphx committed Aug 18, 2007
Showing with 2,804 additions and 2,564 deletions.
  1. +1 −1 .gitignore
  2. +13 −0 Rakefile
  3. +17 −8 compiler/bytecode/compiler.rb
  4. +16 −0 doc/point_of_bootstrap.txt
  5. +0 −12 kernel/bootstrap/00io.rb
  6. +0 −33 kernel/bootstrap/00object.rb
  7. +0 −45 kernel/bootstrap/01class.rb
  8. +0 −74 kernel/bootstrap/02module.rb
  9. +0 −132 kernel/bootstrap/03hash.rb
  10. +0 −53 kernel/bootstrap/04kernel.rb
  11. 0 kernel/{core → bootstrap}/archive.rb
  12. +3 −162 kernel/bootstrap/array.rb
  13. +1 −11 kernel/bootstrap/bytearray.rb
  14. +111 −108 kernel/bootstrap/class.rb
  15. +2 −310 kernel/bootstrap/context.rb
  16. +0 −201 kernel/bootstrap/core.rb
  17. +0 −64 kernel/bootstrap/exception.rb
  18. +18 −0 kernel/bootstrap/file.rb
  19. +64 −3 kernel/bootstrap/fixnum.rb
  20. +83 −3 kernel/bootstrap/float.rb
  21. +1 −6 kernel/bootstrap/gc.rb
  22. +23 −0 kernel/bootstrap/hash.rb
  23. +6 −0 kernel/bootstrap/io.rb
  24. +79 −0 kernel/bootstrap/literals.rb
  25. 0 kernel/{core → bootstrap}/marshal.rb
  26. 0 kernel/bootstrap/{meta_class.rb → metaclass.rb}
  27. +0 −16 kernel/bootstrap/method_missing.rb
  28. +32 −119 kernel/bootstrap/module.rb
  29. +0 −47 kernel/bootstrap/nil.rb
  30. +108 −0 kernel/bootstrap/object.rb
  31. +42 −0 kernel/bootstrap/primitives.rb
  32. +22 −0 kernel/bootstrap/process.rb
  33. +13 −0 kernel/bootstrap/readline.rb
  34. +5 −144 kernel/bootstrap/regexp.rb
  35. +0 −3 kernel/bootstrap/rubinius.rb
  36. +11 −0 kernel/bootstrap/sampler.rb
  37. +19 −302 kernel/bootstrap/string.rb
  38. +4 −21 kernel/bootstrap/symbol.rb
  39. +2 −130 kernel/bootstrap/thread.rb
  40. +18 −0 kernel/bootstrap/time.rb
  41. +4 −93 kernel/bootstrap/tuple.rb
  42. 0 kernel/{core → bootstrap}/vm.rb
  43. 0 kernel/{core → bootstrap}/weakref.rb
  44. +8 −15 kernel/core/00io.rb
  45. +0 −9 kernel/core/04numeric.rb
  46. +127 −3 kernel/core/09class.rb
  47. +7 −5 kernel/core/actor.rb
  48. +149 −8 kernel/core/array.rb
  49. +11 −0 kernel/core/bytearray.rb
  50. +2 −1 kernel/core/codearchive.rb
  51. +1 −55 kernel/{bootstrap → core}/compiled_method.rb
  52. +313 −0 kernel/core/context.rb
  53. +2 −1 kernel/core/debugger.rb
  54. +2 −16 kernel/core/env.rb
  55. +65 −1 kernel/core/exception.rb
  56. +22 −25 kernel/core/file.rb
  57. +0 −50 kernel/core/fixnum.rb
  58. +4 −72 kernel/core/float.rb
  59. +113 −0 kernel/core/hash.rb
  60. 0 kernel/{bootstrap → core}/immediate.rb
  61. +67 −7 kernel/core/kernel.rb
  62. +20 −2 kernel/core/list.rb
  63. +6 −3 kernel/core/math.rb
  64. 0 kernel/{bootstrap → core}/method_table.rb
  65. +20 −0 kernel/core/misc.rb
  66. +174 −0 kernel/core/module.rb
  67. +101 −3 kernel/core/object.rb
  68. +1 −17 kernel/core/process.rb
  69. +5 −11 kernel/core/readline.rb
  70. +130 −8 kernel/core/regexp.rb
  71. +1 −9 kernel/core/sampler.rb
  72. +2 −7 kernel/core/sprintf.rb
  73. +291 −19 kernel/core/string.rb
  74. +29 −0 kernel/core/symbol.rb
  75. +130 −0 kernel/core/thread.rb
  76. +0 −19 kernel/core/time.rb
  77. +92 −0 kernel/core/tuple.rb
  78. +16 −0 kernel/loader.rb
  79. +3 −4 kernel/{core → platform}/07ffi.rb
  80. +2 −2 kernel/{core → platform}/compression.rb
  81. +15 −0 kernel/platform/env.rb
  82. +4 −0 kernel/platform/rand.rb
  83. +3 −0 kernel/platform/vm.rb
  84. BIN runtime/bootstrap.rba
  85. BIN runtime/compiler.rba
  86. BIN runtime/core.rba
  87. BIN runtime/loader.rbc
  88. BIN runtime/platform.rba
  89. +3 −5 shotgun/Makefile
  90. +48 −0 shotgun/lib/class.c
  91. +1 −0 shotgun/lib/class.h
  92. +10 −45 shotgun/lib/cpu_instructions.c
  93. +3 −1 shotgun/lib/instructions.rb
  94. +4 −0 shotgun/lib/machine.c
  95. +4 −6 shotgun/lib/primitives.rb
  96. +52 −29 shotgun/lib/subtend/ffi.c
  97. +19 −4 shotgun/main.c
  98. +4 −1 spec/mini_rspec.rb
View
@@ -5,7 +5,7 @@ code-cache
.hg
COMMIT
.load_order.txt
-
+CI-specs
*.rbc
!runtime/loader.rbc
View
@@ -10,6 +10,7 @@ end
@pb = "runtime/pristine_bootstrap.rba"
@pc = "runtime/pristine_core.rba"
+@pl = "runtime/pristine_loader.rbc"
if File.exists?(@pb)
puts "Using #{@pb} for bootstrap."
@@ -21,6 +22,11 @@ if File.exists?(@pc)
ENV['CORE'] = @pc
end
+if File.exists?(@pl)
+ puts "Using #{@pl} for the loader."
+ ENV['LOADER'] = @pl
+end
+
@compiler = ENV['COMPILER']
def update_archive(files, archive, dir=nil)
@@ -227,6 +233,13 @@ namespace :build do
files = Dir["compiler/**/*.rb"].sort
update_archive files, 'runtime/compiler.rba', "compiler"
end
+
+ desc "Compiles the Rubinius platform archive"
+ task :platform do
+ files = Dir["kernel/platform/*.rb"].sort
+ update_archive files, 'runtime/platform.rba'
+ end
+
end
desc "Remove all .rbc files from the project"
@@ -1263,15 +1263,22 @@ def do_resbody(x, rr, fin)
one_cond = (cond.size == 1)
bl = unique_lbl('resbody_')
- while cur = cond.shift
- add "push_exception"
- process cur
- add "send === 1"
- if cond.empty?
- gif nxt
- else
- git bl
+
+ # If Object is your condition, we run it without checking
+ # since everything is an object.
+ unless cond == [[:const, :Object]]
+
+ while cur = cond.shift
+ add "push_exception"
+ process cur
+ add "send === 1"
+ if cond.empty?
+ gif nxt
+ else
+ git bl
+ end
end
+
end
if !one_cond
@@ -1718,8 +1725,10 @@ def detect_class_special(x)
return true
elsif recv = [:self] and meth == :private and args.empty?
@compiler.flags[:visibility] = :private
+ return true
elsif recv = [:self] and meth == :public and args.empty?
@compiler.flags[:visibility] = :public
+ return true
end
return false
end
View
@@ -0,0 +1,16 @@
+The point of the bootstrap step is to build up just enough functionality to:
+
+1) use alias
+2) run FFI (for platform code)
+3) provide basic error reporting (primary related to method_missing)
+
+It also serves ot attach all primitives. Primitives are ONLY allowed to be
+attached in bootstrap.
+
+All functionality provided by bootstrap may be redefined in core to provide
+a 'proper' implementation.
+
+Rules of bootstrap:
+
+1) limited to no metaprogramming. The bootstrap should be a container of code only.
+ if it runs code, then order starts to matter and things fall apart.
View
@@ -1,12 +0,0 @@
-class IO
- ivar_as_index :__ivars__ => 0, :descriptor => 1
- def descriptor; @descriptor ; end
- def __ivars__ ; @__ivars__ ; end
-
- def write(str)
- Ruby.primitive :io_write
- exc = IOError.new("Unable to write '#{str}' via #{self}")
- raise exc
- end
-end
-
@@ -1,33 +0,0 @@
-class Object
- ivar_as_index :__ivars__ => 0
- def __ivars__; @__ivars__ ; end
-
- def metaclass
- class << self;self;end
- end
-
- def extend(*mods)
- metaclass.include(*mods)
- end
-
- def at(idx)
- Ruby.primitive :at
- exc = InvalidIndex.new("Could not access index #{idx} of #{self}")
- raise exc
- end
-
- def put(idx, val)
- Ruby.primitive :put
- exc = InvalidIndex.new("Could not write to index #{idx} of #{self}")
- raise exc
- end
-
- def fields
- Ruby.primitive :fields
- end
-
- def become!(obj)
- Ruby.primitive :object_become
- end
-end
-
@@ -1,45 +0,0 @@
-class Class
- def instance_fields=(num)
- @instance_fields = num
- end
-
- ivar_as_index :superclass => 6, :instance_fields => 7, :instance_flags => 8
- def instance_fields; @instance_fields ; end
- def instance_flags ; @instance_flags ; end
-
- self.instance_fields = 9
-
- # 'superclass' method defined in class.rb,
- # because it is more complex than a mere accessor
- def superclass=(other)
- @superclass = other
- end
-
- def class_variable_set(name, val)
- raise NameError, "#{name} is not an allowed class variable name" unless name.to_s[0..1] == '@@'
-
- @variables ||= Hash.new
- @variables[name.to_sym] = val
- end
-
- def class_variable_get(name)
- raise NameError, "#{name} is not an allowed class variable name" unless name.to_s[0..1] == '@@'
-
- @variables ||= Hash.new
- @variables[name.to_sym]
- end
-
- def class_variables(symbols = false)
- @variables ||= Hash.new
- if symbols
- @variables.keys
- else
- @variables.keys.map {|k| k.to_s}
- end
- end
-
- def direct_superclass
- @superclass
- end
-end
-
@@ -1,74 +0,0 @@
-class Module
- ivar_as_index :__ivars__ => 0, :methods => 1, :method_cache => 2, :name => 3, :constants => 4, :parent => 5
- def __ivars__ ; @__ivars__ ; end
- # Do not define #methods as an accessor for @methods, use #method_table instead
- def method_cache ; @method_cache ; end
- def name ; @name ; end
- def constants_table; @constants ; end
- def parent ; @parent ; end
-
- def method_table
- @methods
- end
-
- def append_features(mod)
- im = IncludedModule.new(self)
- im.attach_to mod
- end
-
- def included(mod); end
-
- def include(mod)
- mod.append_features(self)
- mod.included(self)
- end
-
- def find_method_in_hierarchy(sym)
- [self, Functions].each do |mod|
- meth = mod.method_table[sym]
- return meth if meth
- end
- nil
- end
-
- def alias_method(new_name, current_name)
- meth = find_method_in_hierarchy(current_name)
- if meth
- method_table[new_name] = meth
- else
- raise NameError, "undefined method `#{current_name}' for module `#{self.name}'"
- end
- end
-end
-
-class IncludedModule < Module
- self.instance_fields = 8
-
- ivar_as_index :superclass => 6, :module => 7
- def superclass; @superclass ; end
- def module ; @module ; end
-
- def initialize(mod)
- @__ivars__ = mod.__ivars__
- @methods = mod.method_table
- @method_cache = nil
- @name = mod.name
- @constants = {}
- @parent = nil
- @module = mod
- end
-
- def old_to_s
- "#<IM>"
- end
-
- def attach_to(cls)
- @superclass = cls.direct_superclass
- cls.superclass = self
- end
-
- def direct_superclass
- @superclass
- end
-end
-
Oops, something went wrong.

0 comments on commit 541bcb5

Please sign in to comment.