Permalink
Browse files

* Phase 1 of 'hints' refactoring

* Remove dependency on 00auto_fields bootstrap file. The methods defined there are now in their respective bootstrap files.
* hints file is now written in alphabetical order
* Minor changes to array.rb and continuation.rb to remove warnings during 'rake build:core'
  • Loading branch information...
1 parent ea0f819 commit 440dfac38f5047e766ac68fccec54646dfa83d11 @wilson wilson committed May 16, 2007
View
@@ -197,7 +197,7 @@ namespace :build do
task :syd do
require 'rubygems'
begin
- require_gem 'sydparse', '>= 1.2.1'
+ gem 'sydparse', '>= 1.2.1'
rescue Gem::LoadError
puts "\nYour system does not have the required sysparse gem installed...\n"
Rake::Task['syd'].invoke
@@ -206,44 +206,29 @@ namespace :build do
end
end
+ desc "Build the kernel/hints file that is used to generate auto.c and auto.h"
task :fields => ['setup:syd'] do
$:.unshift "lib"
require 'types'
- fd = File.open("kernel/bootstrap/00auto_fields.rb", "w")
hfd = File.open("kernel/hints", "w")
- hints = {}
- Rubinius::Types.each do |name, mod|
+ # Process types in alphabetical order to avoid file modifications
+ types = Rubinius::Types.keys.sort_by {|k| k.to_s}
+ types.each do |name|
+ mod = Rubinius::Types[name]
next if mod::TotalFields.size == 0
sname = mod.name.split("::").last
- sub = {}
hfd.puts sname
- fd.puts "class #{sname}"
- idx = 0
- str = []
mod::TotalFields.each do |fel|
if fel == :instance_variables
fel = :__ivars__
end
hfd.puts fel
- sub["@#{fel}".to_sym] = idx
- str << [":#{fel} => #{idx}"]
- # fd.puts "index_accessor :#{fel}, #{idx}"
- fd.puts " def #{fel}; Ruby.asm \"push self\\npush #{idx}\\nfetch_field\"; end"
- idx += 1
end
hfd.puts "!"
- hints[sname] = sub
- fd.puts " ivar_as_index #{str.join(", ")}"
- fd.puts "end"
end
- fd.close
-
- #require 'yaml'
- #File.open("kernel/hints", "w") do |f|
- # f << hints.to_yaml
- #end
+ hfd.close
end
-
+
desc "Build shotgun C components."
task :shotgun => ['build:setup', 'spec:setup:code_cache', 'build:configure'] do
system("make -e -C shotgun rubinius")
@@ -1,152 +0,0 @@
-class Class
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def methods; Ruby.asm "push self\npush 1\nfetch_field"; end
- def method_cache; Ruby.asm "push self\npush 2\nfetch_field"; end
- def name; Ruby.asm "push self\npush 3\nfetch_field"; end
- def constants; Ruby.asm "push self\npush 4\nfetch_field"; end
- def parent; Ruby.asm "push self\npush 5\nfetch_field"; end
- def superclass; Ruby.asm "push self\npush 6\nfetch_field"; end
- def instance_fields; Ruby.asm "push self\npush 7\nfetch_field"; end
- def instance_flags; Ruby.asm "push self\npush 8\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :methods => 1, :method_cache => 2, :name => 3, :constants => 4, :parent => 5, :superclass => 6, :instance_fields => 7, :instance_flags => 8
-end
-class BlockContext
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def sender; Ruby.asm "push self\npush 1\nfetch_field"; end
- def ip; Ruby.asm "push self\npush 2\nfetch_field"; end
- def sp; Ruby.asm "push self\npush 3\nfetch_field"; end
- def block; Ruby.asm "push self\npush 4\nfetch_field"; end
- def raiseable; Ruby.asm "push self\npush 5\nfetch_field"; end
- def env; Ruby.asm "push self\npush 6\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :sender => 1, :ip => 2, :sp => 3, :block => 4, :raiseable => 5, :env => 6
-end
-class Regexp
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def source; Ruby.asm "push self\npush 1\nfetch_field"; end
- def data; Ruby.asm "push self\npush 2\nfetch_field"; end
- def names; Ruby.asm "push self\npush 3\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :source => 1, :data => 2, :names => 3
-end
-class MatchData
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def source; Ruby.asm "push self\npush 1\nfetch_field"; end
- def regexp; Ruby.asm "push self\npush 2\nfetch_field"; end
- def full; Ruby.asm "push self\npush 3\nfetch_field"; end
- def region; Ruby.asm "push self\npush 4\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :source => 1, :regexp => 2, :full => 3, :region => 4
-end
-class Array
- def total; Ruby.asm "push self\npush 0\nfetch_field"; end
- def tuple; Ruby.asm "push self\npush 1\nfetch_field"; end
- ivar_as_index :total => 0, :tuple => 1
-end
-class MethodTable
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def keys; Ruby.asm "push self\npush 1\nfetch_field"; end
- def values; Ruby.asm "push self\npush 2\nfetch_field"; end
- def bins; Ruby.asm "push self\npush 3\nfetch_field"; end
- def entries; Ruby.asm "push self\npush 4\nfetch_field"; end
- def default; Ruby.asm "push self\npush 5\nfetch_field"; end
- def default_proc; Ruby.asm "push self\npush 6\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5, :default_proc => 6
-end
-class Hash
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def keys; Ruby.asm "push self\npush 1\nfetch_field"; end
- def values; Ruby.asm "push self\npush 2\nfetch_field"; end
- def bins; Ruby.asm "push self\npush 3\nfetch_field"; end
- def entries; Ruby.asm "push self\npush 4\nfetch_field"; end
- def default; Ruby.asm "push self\npush 5\nfetch_field"; end
- def default_proc; Ruby.asm "push self\npush 6\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5, :default_proc => 6
-end
-class SymbolTable
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def symbols; Ruby.asm "push self\npush 1\nfetch_field"; end
- def strings; Ruby.asm "push self\npush 2\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :symbols => 1, :strings => 2
-end
-class MetaClass
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def methods; Ruby.asm "push self\npush 1\nfetch_field"; end
- def method_cache; Ruby.asm "push self\npush 2\nfetch_field"; end
- def name; Ruby.asm "push self\npush 3\nfetch_field"; end
- def constants; Ruby.asm "push self\npush 4\nfetch_field"; end
- def parent; Ruby.asm "push self\npush 5\nfetch_field"; end
- def superclass; Ruby.asm "push self\npush 6\nfetch_field"; end
- def instance_fields; Ruby.asm "push self\npush 7\nfetch_field"; end
- def instance_flags; Ruby.asm "push self\npush 8\nfetch_field"; end
- def attached_instance; Ruby.asm "push self\npush 9\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :methods => 1, :method_cache => 2, :name => 3, :constants => 4, :parent => 5, :superclass => 6, :instance_fields => 7, :instance_flags => 8, :attached_instance => 9
-end
-class Object
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- ivar_as_index :__ivars__ => 0
-end
-class Float
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- ivar_as_index :__ivars__ => 0
-end
-class String
- def bytes; Ruby.asm "push self\npush 0\nfetch_field"; end
- def characters; Ruby.asm "push self\npush 1\nfetch_field"; end
- def encoding; Ruby.asm "push self\npush 2\nfetch_field"; end
- def data; Ruby.asm "push self\npush 3\nfetch_field"; end
- ivar_as_index :bytes => 0, :characters => 1, :encoding => 2, :data => 3
-end
-class BlockEnvironment
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def home; Ruby.asm "push self\npush 1\nfetch_field"; end
- def initial_ip; Ruby.asm "push self\npush 2\nfetch_field"; end
- def last_ip; Ruby.asm "push self\npush 3\nfetch_field"; end
- def post_send; Ruby.asm "push self\npush 4\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :home => 1, :initial_ip => 2, :last_ip => 3, :post_send => 4
-end
-class IO
- def descriptor; Ruby.asm "push self\npush 0\nfetch_field"; end
- ivar_as_index :descriptor => 0
-end
-class MethodContext
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def sender; Ruby.asm "push self\npush 1\nfetch_field"; end
- def ip; Ruby.asm "push self\npush 2\nfetch_field"; end
- def sp; Ruby.asm "push self\npush 3\nfetch_field"; end
- def block; Ruby.asm "push self\npush 4\nfetch_field"; end
- def raiseable; Ruby.asm "push self\npush 5\nfetch_field"; end
- def method; Ruby.asm "push self\npush 6\nfetch_field"; end
- def bytecodes; Ruby.asm "push self\npush 7\nfetch_field"; end
- def literals; Ruby.asm "push self\npush 8\nfetch_field"; end
- def receiver; Ruby.asm "push self\npush 9\nfetch_field"; end
- def locals; Ruby.asm "push self\npush 10\nfetch_field"; end
- def argcount; Ruby.asm "push self\npush 11\nfetch_field"; end
- def name; Ruby.asm "push self\npush 12\nfetch_field"; end
- def module; Ruby.asm "push self\npush 13\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :sender => 1, :ip => 2, :sp => 3, :block => 4, :raiseable => 5, :method => 6, :bytecodes => 7, :literals => 8, :receiver => 9, :locals => 10, :argcount => 11, :name => 12, :module => 13
-end
-class CompiledMethod
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def primitive; Ruby.asm "push self\npush 1\nfetch_field"; end
- def required; Ruby.asm "push self\npush 2\nfetch_field"; end
- def serial; Ruby.asm "push self\npush 3\nfetch_field"; end
- def bytecodes; Ruby.asm "push self\npush 4\nfetch_field"; end
- def name; Ruby.asm "push self\npush 5\nfetch_field"; end
- def file; Ruby.asm "push self\npush 6\nfetch_field"; end
- def locals; Ruby.asm "push self\npush 7\nfetch_field"; end
- def literals; Ruby.asm "push self\npush 8\nfetch_field"; end
- def arguments; Ruby.asm "push self\npush 9\nfetch_field"; end
- def scope; Ruby.asm "push self\npush 10\nfetch_field"; end
- def exceptions; Ruby.asm "push self\npush 11\nfetch_field"; end
- def lines; Ruby.asm "push self\npush 12\nfetch_field"; end
- def path; Ruby.asm "push self\npush 13\nfetch_field"; end
- def cache; Ruby.asm "push self\npush 14\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :primitive => 1, :required => 2, :serial => 3, :bytecodes => 4, :name => 5, :file => 6, :locals => 7, :literals => 8, :arguments => 9, :scope => 10, :exceptions => 11, :lines => 12, :path => 13, :cache => 14
-end
-class Module
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- def methods; Ruby.asm "push self\npush 1\nfetch_field"; end
- def method_cache; Ruby.asm "push self\npush 2\nfetch_field"; end
- def name; Ruby.asm "push self\npush 3\nfetch_field"; end
- def constants; Ruby.asm "push self\npush 4\nfetch_field"; end
- def parent; Ruby.asm "push self\npush 5\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :methods => 1, :method_cache => 2, :name => 3, :constants => 4, :parent => 5
-end
View
@@ -1,5 +1,7 @@
class IO
+ def descriptor; Ruby.asm "push self\npush 0\nfetch_field"; end
def __ivars__; nil; end
+ ivar_as_index :descriptor => 0
def write(str)
Ruby.primitive :io_write
@@ -1,4 +1,7 @@
class Object
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0
+
def extend(*mods)
(class << self; self; end).include(*mods)
end
@@ -1,4 +1,14 @@
class Class
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def methods; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def method_cache; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def name; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def constants; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def parent; Ruby.asm "push self\npush 5\nfetch_field"; end
+ def superclass; Ruby.asm "push self\npush 6\nfetch_field"; end
+ def instance_fields; Ruby.asm "push self\npush 7\nfetch_field"; end
+ def instance_flags; Ruby.asm "push self\npush 8\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :methods => 1, :method_cache => 2, :name => 3, :constants => 4, :parent => 5, :superclass => 6, :instance_fields => 7, :instance_flags => 8
def instance_fields=(num)
@instance_fields = num
@@ -18,4 +28,7 @@ def class_variable_get(name)
@variables[name.to_sym]
end
+ def superclass=(other)
+ @superclass = other
+ end
end
@@ -1,4 +1,12 @@
class Module
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def methods; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def method_cache; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def name; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def constants; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def parent; Ruby.asm "push self\npush 5\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :methods => 1, :method_cache => 2, :name => 3, :constants => 4, :parent => 5
+
def name
@name
end
@@ -51,7 +59,7 @@ def module
def attach_to(cls)
@superclass = cls.superclass
- cls.put 6, self
+ cls.superclass = self
end
def superclass
View
@@ -1,10 +1,17 @@
class Hash
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def keys; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def values; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def bins; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def entries; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def default_proc; Ruby.asm "push self\npush 6\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5, :default_proc => 6
- def self.new(default=nil,&block)
+ def self.new(default_value=nil,&block)
hsh = {}
- raise ArgumentError, 'wrong number of arguments' if default && block
- hsh.put 5, (default or block)
- hsh.put 6, (block != nil)
+ raise ArgumentError, 'wrong number of arguments' if default_value && block
+ hsh.put(5, (default_value || block))
+ hsh.put(6, (block != nil))
return hsh
end
@@ -10,7 +10,10 @@
# uniq, uniq!, unshift, values_at, yaml_initialize, zip, |
class Array
+ def total; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def tuple; Ruby.asm "push self\npush 1\nfetch_field"; end
def __ivars__; nil; end
+ ivar_as_index :total => 0, :tuple => 1
def to_s
"#<Array:0x#{object_id.to_s(16)} #{@total} elements>"
@@ -17,6 +17,23 @@ def line_from_ip(i)
end
class CompiledMethod
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def primitive; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def required; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def serial; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def bytecodes; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def name; Ruby.asm "push self\npush 5\nfetch_field"; end
+ def file; Ruby.asm "push self\npush 6\nfetch_field"; end
+ def locals; Ruby.asm "push self\npush 7\nfetch_field"; end
+ def literals; Ruby.asm "push self\npush 8\nfetch_field"; end
+ def arguments; Ruby.asm "push self\npush 9\nfetch_field"; end
+ def scope; Ruby.asm "push self\npush 10\nfetch_field"; end
+ def exceptions; Ruby.asm "push self\npush 11\nfetch_field"; end
+ def lines; Ruby.asm "push self\npush 12\nfetch_field"; end
+ def path; Ruby.asm "push self\npush 13\nfetch_field"; end
+ def cache; Ruby.asm "push self\npush 14\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :primitive => 1, :required => 2, :serial => 3, :bytecodes => 4, :name => 5, :file => 6, :locals => 7, :literals => 8, :arguments => 9, :scope => 10, :exceptions => 11, :lines => 12, :path => 13, :cache => 14
+
def inspect
"#<#{self.class.name}:0x#{self.object_id.to_s(16)} name=#{@name} file=#{@file}>"
end
@@ -1,7 +1,23 @@
# Hey! Be careful with this! This is used by backtrace and if it doesn't work,
-# you can get recursive exceptions being raise (THATS BAD, BTW).
+# you can get recursive exceptions being raised (THATS BAD, BTW).
class MethodContext
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def sender; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def ip; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def sp; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def block; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def raiseable; Ruby.asm "push self\npush 5\nfetch_field"; end
+ def method; Ruby.asm "push self\npush 6\nfetch_field"; end
+ def bytecodes; Ruby.asm "push self\npush 7\nfetch_field"; end
+ def literals; Ruby.asm "push self\npush 8\nfetch_field"; end
+ def receiver; Ruby.asm "push self\npush 9\nfetch_field"; end
+ def locals; Ruby.asm "push self\npush 10\nfetch_field"; end
+ def argcount; Ruby.asm "push self\npush 11\nfetch_field"; end
+ def name; Ruby.asm "push self\npush 12\nfetch_field"; end
+ def module; Ruby.asm "push self\npush 13\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :sender => 1, :ip => 2, :sp => 3, :block => 4, :raiseable => 5, :method => 6, :bytecodes => 7, :literals => 8, :receiver => 9, :locals => 10, :argcount => 11, :name => 12, :module => 13
+
def self.current
cur = nil
Ruby.asm "push_context\nset cur\n"
@@ -111,6 +127,15 @@ def dup
end
class BlockContext
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def sender; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def ip; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def sp; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def block; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def raiseable; Ruby.asm "push self\npush 5\nfetch_field"; end
+ def env; Ruby.asm "push self\npush 6\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :sender => 1, :ip => 2, :sp => 3, :block => 4, :raiseable => 5, :env => 6
+
def activate(val)
Ruby.primitive :activate_context
end
@@ -144,6 +169,13 @@ def method_module
end
class BlockEnvironment
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ def home; Ruby.asm "push self\npush 1\nfetch_field"; end
+ def initial_ip; Ruby.asm "push self\npush 2\nfetch_field"; end
+ def last_ip; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def post_send; Ruby.asm "push self\npush 4\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :home => 1, :initial_ip => 2, :last_ip => 3, :post_send => 4
+
def call(*args)
execute args.tuple
end
Oops, something went wrong.

0 comments on commit 440dfac

Please sign in to comment.