Permalink
Browse files

Merge from /branches/backtrace.

This makes the kernel support only loading from an archive, so be aware!
  • Loading branch information...
evanphx committed Jan 19, 2007
1 parent 4774788 commit dd4b5741b164bc481629aea996ce4d6b5a39e2f2
View
1 README
@@ -15,6 +15,7 @@ as gems or libraries:
* sydparse
* rspec (if you want to run specs, currently works with 0.7.5)
* ruby2ruby (also used in specs)
+ * zip (provided on pretty much all unix platforms these days)
Use the local sydparse by building locally using the 'rake syd' command. The
'rake build' task will fail until you install the correct version of sydparse.
View
@@ -110,8 +110,12 @@ end
task :build => 'build:all'
namespace :build do
- desc "Rebuild shotgun from scratch"
- task :all => ['build:clean', 'setup:syd', 'build:shotgun', 'build:kernel', 'build:compiler']
+
+ desc "Build shotgun only."
+ task :all => ['build:clean', 'setup:syd', 'build:shotgun']
+
+ desc "Rebuild all parts and archives from scratch."
+ task :dev => ['build:clean', 'setup:syd', 'build:shotgun', 'build:kernel', 'build:compiler']
desc "Cleanup build files."
task :clean do
@@ -140,7 +144,7 @@ namespace :build do
end
# Combine the separate .rb files in lib into a single kernel.rb
- task :kernel do
+ task :kernel_old do
fd = File.open("lib/kernel.rb", "w")
Dir["kernel/*.rb"].sort.each do |path|
next if File.basename(path) == "__loader.rb"
@@ -159,32 +163,41 @@ namespace :build do
fd << File.read("kernel/__loader.rb")
fd.close
- end
+ end
end
task :fields do
$:.unshift "lib"
require 'types'
fd = File.open("kernel/00auto_fields.rb", "w")
+ hints = {}
Rubinius::Types.each do |name, mod|
next if mod::TotalFields.size == 0
sname = mod.name.split("::").last
+ sub = {}
fd.puts "class #{sname}"
idx = 0
str = []
mod::TotalFields.each do |fel|
if fel == :instance_variables
fel = :__ivars__
end
+ 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
+ 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
end
desc "Build shotgun C components."
@@ -194,12 +207,41 @@ namespace :build do
end
desc "Build the kernel."
- task :kernel => 'build:setup:kernel' do
- puts "Compiling kernel.rb..."
- puts `bin/obsolete.rcompile lib/kernel.rb`
- raise 'Failed to compile kernel.rb' if $?.exitstatus != 0
- end
+ task :kernel do
+ files = nil
+ Dir.chdir("kernel") do
+ files = Dir["*.rb"].sort
+ files.delete "__loader.rb"
+
+ files += Dir["core/*.rb"]
+ files << "__loader.rb"
+
+ changed = []
+ files.each do |file|
+ cmp = "#{file}c"
+ unless File.exists?(cmp) and File.mtime(cmp) >= File.mtime(file)
+ changed << cmp
+ system "../bin/obsolete.rcompile #{file}"
+ raise "Failed to compile #{file}" if $?.exitstatus != 0
+ end
+ file << "c"
+ end
+ File.open(".load_order.txt","w") do |f|
+ f.puts files.join("\n")
+ end
+
+ kern = "../runtime/kernel.rba"
+
+ # File.unlink("../kernel.rba") if File.exists?("../kernel.rba")
+ if File.exists? kern
+ system "zip -u #{kern} .load_order.txt #{changed.join(' ')}"
+ else
+ system "zip #{kern} .load_order.txt #{files.join(' ')}"
+ end
+ end
+ end
+
desc "Build syd-parser."
task :syd do
puts "Building externals/syd-parser gem...\n"
@@ -224,17 +266,29 @@ namespace :build do
dest = File.join("native", file)
FileUtils.mkdir_p dest_dir
FileUtils.symlink path, dest rescue nil
- sh "bin/obsolete.rcompile #{dest}"
+ Dir.chdir "native" do
+ sh "../bin/obsolete.rcompile #{file}"
+ end
raise "Failed to compile #{dest}" if $?.exitstatus != 0
end
extra = %w!bytecode/rubinius!
extra.each do |name|
- sh "bin/obsolete.rcompile native/#{name}.rb"
+ Dir.chdir "native" do
+ sh "../bin/obsolete.rcompile #{name}.rb"
+ end
raise "Failed to compile native/#{name}" if $?.exitstatus != 0
end
end
+ desc "Package up the compiler"
+ task :packcompiler do
+ File.unlink "compiler.rba" rescue nil
+ Dir.chdir "native" do
+ sh "zip ../runtime/compiler.rba **/*.rbc"
+ end
+ end
+
desc "Builds shotgun, kernel, and bootstraps the compiler"
task :rubinius => ['build:shotgun', 'build:kernel', 'build:compiler']
View
@@ -1,4 +1,26 @@
-class Class
+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 bytecodes; Ruby.asm "push self\npush 3\nfetch_field"; end
+ def locals; Ruby.asm "push self\npush 4\nfetch_field"; end
+ def literals; Ruby.asm "push self\npush 5\nfetch_field"; end
+ def arguments; Ruby.asm "push self\npush 6\nfetch_field"; end
+ def scope; Ruby.asm "push self\npush 7\nfetch_field"; end
+ def exceptions; Ruby.asm "push self\npush 8\nfetch_field"; end
+ def lines; Ruby.asm "push self\npush 9\nfetch_field"; end
+ def file; Ruby.asm "push self\npush 10\nfetch_field"; end
+ def name; Ruby.asm "push self\npush 11\nfetch_field"; end
+ def path; Ruby.asm "push self\npush 12\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0, :primitive => 1, :required => 2, :bytecodes => 3, :locals => 4, :literals => 5, :arguments => 6, :scope => 7, :exceptions => 8, :lines => 9, :file => 10, :name => 11, :path => 12
+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
@@ -8,49 +30,10 @@ 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 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
-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 Object
- def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
- ivar_as_index :__ivars__ => 0
-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
- ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5
-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
+ 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 MetaClass
+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
@@ -60,43 +43,38 @@ 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
+ 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 Regexp
+class BlockEnvironment
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
+ 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 CompiledMethod
+class MethodContext
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 bytecodes; Ruby.asm "push self\npush 3\nfetch_field"; end
- def locals; Ruby.asm "push self\npush 4\nfetch_field"; end
- def literals; Ruby.asm "push self\npush 5\nfetch_field"; end
- def arguments; Ruby.asm "push self\npush 6\nfetch_field"; end
- def scope; Ruby.asm "push self\npush 7\nfetch_field"; end
- def exceptions; Ruby.asm "push self\npush 8\nfetch_field"; end
- def lines; Ruby.asm "push self\npush 9\nfetch_field"; end
- def file; Ruby.asm "push self\npush 10\nfetch_field"; end
- def name; Ruby.asm "push self\npush 11\nfetch_field"; end
- def path; Ruby.asm "push self\npush 12\nfetch_field"; end
- ivar_as_index :__ivars__ => 0, :primitive => 1, :required => 2, :bytecodes => 3, :locals => 4, :literals => 5, :arguments => 6, :scope => 7, :exceptions => 8, :lines => 9, :file => 10, :name => 11, :path => 12
+ 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 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 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 Hash
def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
def keys; Ruby.asm "push self\npush 1\nfetch_field"; end
@@ -106,13 +84,14 @@ def entries; Ruby.asm "push self\npush 4\nfetch_field"; end
def default; Ruby.asm "push self\npush 5\nfetch_field"; end
ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5
end
-class BlockEnvironment
+class Module
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 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
class String
def bytes; Ruby.asm "push self\npush 0\nfetch_field"; end
@@ -121,24 +100,45 @@ 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 MethodContext
+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 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 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 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
+ ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5
+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 IO
def descriptor; Ruby.asm "push self\npush 0\nfetch_field"; end
ivar_as_index :descriptor => 0
end
+class Object
+ def __ivars__; Ruby.asm "push self\npush 0\nfetch_field"; end
+ ivar_as_index :__ivars__ => 0
+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
View
@@ -0,0 +1,7 @@
+class IO
+ def write(str)
+ Ruby.primitive :io_write
+ exc = IOError.new("Unable to write '#{str}' via #{self}")
+ raise exc
+ end
+end
Oops, something went wrong.

0 comments on commit dd4b574

Please sign in to comment.