register access fixes
since the constants moved
This commit is contained in:
parent
6f0ae51dc5
commit
b58bba3fc4
@ -1,21 +1,21 @@
|
|||||||
Virtual::MessageSlot.class_eval do
|
Virtual::MessageSlot.class_eval do
|
||||||
def reg
|
def reg
|
||||||
Register::RegisterReference.new(Virtual::Message::MESSAGE_REG )
|
Register::RegisterReference.message_reg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::FrameSlot.class_eval do
|
Virtual::FrameSlot.class_eval do
|
||||||
def reg
|
def reg
|
||||||
Register::RegisterReference.new(Virtual::Message::FRAME_REG )
|
Register::RegisterReference.frame_reg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::SelfSlot.class_eval do
|
Virtual::SelfSlot.class_eval do
|
||||||
def reg
|
def reg
|
||||||
Register::RegisterReference.new(Virtual::Message::SELF_REG )
|
Register::RegisterReference.self_reg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::NewMessageSlot.class_eval do
|
Virtual::NewMessageSlot.class_eval do
|
||||||
def reg
|
def reg
|
||||||
Register::RegisterReference.new(Virtual::Message::NEW_MESSAGE_REG )
|
Register::RegisterReference.new_message_reg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ module Register
|
|||||||
# resolve the register and offset that we need to move to
|
# resolve the register and offset that we need to move to
|
||||||
to = code.to.reg
|
to = code.to.reg
|
||||||
# need a temporay place because of indexed load/store
|
# need a temporay place because of indexed load/store
|
||||||
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
|
tmp = RegisterReference.tmp_reg
|
||||||
# for constants we have to "move" the constants value
|
# for constants we have to "move" the constants value
|
||||||
if( code.from.is_a? Virtual::Constant)
|
if( code.from.is_a? Parfait::Value)
|
||||||
move1 = LoadConstant.new( tmp , code.from )
|
move1 = LoadConstant.new( tmp , code.from )
|
||||||
else # while otherwise we "load"
|
else # while otherwise we "load"
|
||||||
move1 = GetSlot.new( tmp , code.from.reg , code.from.index )
|
move1 = GetSlot.new( tmp , code.from.reg , code.from.index )
|
||||||
|
@ -6,7 +6,9 @@ module Register
|
|||||||
# In other words a simple level of indirection, or change from value to reference sematics.
|
# In other words a simple level of indirection, or change from value to reference sematics.
|
||||||
|
|
||||||
class RegisterReference
|
class RegisterReference
|
||||||
|
|
||||||
attr_accessor :symbol
|
attr_accessor :symbol
|
||||||
|
|
||||||
def initialize r
|
def initialize r
|
||||||
if( r.is_a? Fixnum)
|
if( r.is_a? Fixnum)
|
||||||
r = "r#{r}".to_sym
|
r = "r#{r}".to_sym
|
||||||
@ -39,13 +41,13 @@ module Register
|
|||||||
def self.self_reg
|
def self.self_reg
|
||||||
new SELF_REG
|
new SELF_REG
|
||||||
end
|
end
|
||||||
def self.messsage_reg
|
def self.message_reg
|
||||||
new MESSAGE_REG
|
new MESSAGE_REG
|
||||||
end
|
end
|
||||||
def self.frame_reg
|
def self.frame_reg
|
||||||
new FRAME_REG
|
new FRAME_REG
|
||||||
end
|
end
|
||||||
def self.new_messsage_reg
|
def self.new_message_reg
|
||||||
new NEW_MESSAGE_REG
|
new NEW_MESSAGE_REG
|
||||||
end
|
end
|
||||||
def self.tmp_reg
|
def self.tmp_reg
|
||||||
|
@ -17,27 +17,25 @@ module Virtual
|
|||||||
def run block
|
def run block
|
||||||
block.codes.dup.each do |code|
|
block.codes.dup.each do |code|
|
||||||
if code.is_a?(NewFrame)
|
if code.is_a?(NewFrame)
|
||||||
kind = :next_frame
|
kind = "next_frame"
|
||||||
elsif code.is_a?(NewMessage)
|
elsif code.is_a?(NewMessage)
|
||||||
kind = :next_message
|
kind = "next_message"
|
||||||
else
|
else
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
space = Parfait::Space.object_space
|
|
||||||
slot = Virtual::Slot
|
|
||||||
# a place to store a reference to the space, we grab the next_frame from the space
|
# a place to store a reference to the space, we grab the next_frame from the space
|
||||||
space_tmp = Register::RegisterReference.new(Virtual::Message::TMP_REG)
|
space_tmp = Register::RegisterReference.tmp_reg
|
||||||
# a temporary place to store the new frame
|
# a temporary place to store the new frame
|
||||||
frame_tmp = space_tmp.next_reg_use
|
frame_tmp = space_tmp.next_reg_use
|
||||||
# move the spave to it's register (mov instruction gets the address of the object)
|
# move the spave to it's register (mov instruction gets the address of the object)
|
||||||
new_codes = [ Register::LoadConstant.new( space_tmp , space )]
|
new_codes = [ Register::LoadConstant.new( space_tmp , Parfait::Space.object_space )]
|
||||||
# find index in the space wehre to grab frame/message
|
# find index in the space where to grab frame/message
|
||||||
ind = space.layout[:names].index(kind)
|
ind = Parfait::Space.object_space.get_layout().index_of( kind )
|
||||||
raise "index not found for :#{kind}" unless ind
|
raise "index not found for #{kind}.#{kind.class}" unless ind
|
||||||
# load the frame/message from space by index
|
# load the frame/message from space by index
|
||||||
new_codes << Register::GetSlot.new( frame_tmp , space_tmp , 5 )
|
new_codes << Register::GetSlot.new( frame_tmp , space_tmp , 5 )
|
||||||
# save the frame in real frame register
|
# save the frame in real frame register
|
||||||
new_codes << Register::RegisterTransfer.new( Virtual::Message::FRAME_REG , frame_tmp )
|
new_codes << Register::RegisterTransfer.new( Register::RegisterReference.frame_reg , frame_tmp )
|
||||||
# get the next_frame
|
# get the next_frame
|
||||||
new_codes << Register::GetSlot.new( frame_tmp , frame_tmp , 2 ) # 2 index of next_frame
|
new_codes << Register::GetSlot.new( frame_tmp , frame_tmp , 2 ) # 2 index of next_frame
|
||||||
# save next frame into space
|
# save next frame into space
|
||||||
|
Loading…
x
Reference in New Issue
Block a user