removing passes (before arm)

collector becomes a function
minimizer unused
This commit is contained in:
Torsten Ruger
2015-10-18 19:27:02 +03:00
parent fa4949fc80
commit 15b570f5cf
9 changed files with 19 additions and 24 deletions

View File

@ -74,6 +74,7 @@ module Interpreter
def tick
return unless @instruction
@clock += 1
#puts @instruction
name = @instruction.class.name.split("::").last
fetch = send "execute_#{name}"
return unless fetch

View File

@ -6,11 +6,7 @@ require "virtual/padding"
require "virtual/parfait_adapter"
require "phisol/compiler"
require "virtual/instruction"
require "virtual/method_source"
# the passes _are_ order dependant
require "virtual/passes/minimizer"
require "virtual/passes/collector"
class Fixnum

View File

@ -1,10 +1,10 @@
module Virtual
# collect anything that is in the space but and reachable from init
class Collector
def run
module Collector
def collect
# init= Parfait::Space.object_space.get_class_by_name("Kernel").get_instance_method "__init__"
Virtual.machine.objects.clear
self.objects.clear
keep Parfait::Space.object_space , 0
end
@ -12,7 +12,7 @@ module Virtual
return if object.nil?
#puts "adding #{' ' * depth}:#{object.class}"
#puts "ADD #{object.first.class}, #{object.last.class}" if object.is_a? Array
return unless Virtual.machine.add_object object
return unless self.add_object object
return unless object.respond_to? :has_layout?
if( object.is_a? Parfait::Method)
object.source.constants.each{|c|

View File

@ -1,5 +1,5 @@
require 'parslet/convenience'
require_relative "collector"
module Virtual
# The Virtual Machine is a object based virtual machine in which ruby is implemented.
#
@ -35,12 +35,11 @@ module Virtual
# The "machine" is not part of the run-time (Parfait)
class Machine
FIRST_PASS = "Register::CallImplementation"
include Collector
def initialize
@parser = Parser::Salama.new
@passes = [ FIRST_PASS ]
@passes = [ ]
@objects = {}
@booted = false
end
@ -51,8 +50,6 @@ module Virtual
# runs housekeeping Minimizer and Collector
# Has to be called before run_after
def run_before stop_at
Minimizer.new.run
Collector.new.run
@blocks = [@init]
@space.classes.values.each do |c|
c.instance_methods.each do |f|
@ -85,8 +82,9 @@ module Virtual
# as before, run all passes that are registered
# (but now finer control with before/after versions)
def run_passes
run_before FIRST_PASS
run_after FIRST_PASS
return if @passes.empty?
run_before @passes.first
run_after @passes.first
end
# Objects are data and get assembled after functions

View File

@ -25,7 +25,7 @@ module Virtual
@gonners.delete function
function.source.blocks.each do |block|
block.codes.each do |code|
keep code.method if code.is_a? Virtual::MethodCall
keep code.method if code.is_a? Register::FunctionCall
end
end
end