fix all positioned uses as helper (not included anymore)
This commit is contained in:
parent
cd474f66f6
commit
0397d4064d
@ -48,7 +48,7 @@ module Arm
|
|||||||
# relative addressing for jumps/calls
|
# relative addressing for jumps/calls
|
||||||
# but because of the arm "theoretical" 3- stage pipeline,
|
# but because of the arm "theoretical" 3- stage pipeline,
|
||||||
# we have to subtract 2 words (fetch/decode)
|
# we have to subtract 2 words (fetch/decode)
|
||||||
arg = @first.position - self.position - 8
|
arg = Positioned.position(@first) - Positioned.position(self) - 8
|
||||||
when Parfait::TypedMethod
|
when Parfait::TypedMethod
|
||||||
# But, for methods, this happens to be the size of the object header,
|
# But, for methods, this happens to be the size of the object header,
|
||||||
# so there it balances out, but not blocks
|
# so there it balances out, but not blocks
|
||||||
|
@ -91,7 +91,7 @@ module Arm
|
|||||||
(@left.is_a?(Symbol) and !Register::RegisterValue.look_like_reg(@left)))
|
(@left.is_a?(Symbol) and !Register::RegisterValue.look_like_reg(@left)))
|
||||||
# do pc relative addressing with the difference to the instuction
|
# do pc relative addressing with the difference to the instuction
|
||||||
# 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute)
|
# 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute)
|
||||||
right = @left.position - self.position - 8
|
right = Positioned.position(@left) - Positioned.position(self) - 8
|
||||||
if( (right < 0) && ((opcode == :add) || (opcode == :sub)) )
|
if( (right < 0) && ((opcode == :add) || (opcode == :sub)) )
|
||||||
right *= -1 # this works as we never issue sub only add
|
right *= -1 # this works as we never issue sub only add
|
||||||
set_opcode :sub # so (as we can't change the sign permanently) we can change the opcode
|
set_opcode :sub # so (as we can't change the sign permanently) we can change the opcode
|
||||||
|
@ -27,7 +27,7 @@ module Elf
|
|||||||
Parfait.object_space.each_type do |type|
|
Parfait.object_space.each_type do |type|
|
||||||
type.methods.each do |f|
|
type.methods.each do |f|
|
||||||
f.instructions.each_label do |label|
|
f.instructions.each_label do |label|
|
||||||
add_symbol "#{type.name}::#{f.name}:#{label.name}" , label.position
|
add_symbol "#{type.name}::#{f.name}:#{label.name}" , Positioned.position(label)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -37,12 +37,12 @@ module Elf
|
|||||||
if( slot.respond_to? :sof_reference_name )
|
if( slot.respond_to? :sof_reference_name )
|
||||||
label = "#{slot.sof_reference_name}"
|
label = "#{slot.sof_reference_name}"
|
||||||
else
|
else
|
||||||
label = "#{slot.class.name}::#{slot.position.to_s(16)}"
|
label = "#{slot.class.name}::#{Positioned.position(slot).to_s(16)}"
|
||||||
end
|
end
|
||||||
label += "=#{slot}" if slot.is_a?(Symbol) or slot.is_a?(String)
|
label += "=#{slot}" if slot.is_a?(Symbol) or slot.is_a?(String)
|
||||||
add_symbol label , slot.position
|
add_symbol label , Positioned.position(slot)
|
||||||
if slot.is_a?(Parfait::TypedMethod)
|
if slot.is_a?(Parfait::TypedMethod)
|
||||||
add_symbol slot.name.to_s , slot.binary.position
|
add_symbol slot.name.to_s , Positioned.position(slot.binary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,10 +35,10 @@ module Register
|
|||||||
next unless objekt.is_a? Parfait::TypedMethod
|
next unless objekt.is_a? Parfait::TypedMethod
|
||||||
log.debug "CODE1 #{objekt.name}"
|
log.debug "CODE1 #{objekt.name}"
|
||||||
binary = objekt.binary
|
binary = objekt.binary
|
||||||
binary.set_position( at )
|
Positioned.set_position(binary,at)
|
||||||
objekt.instructions.set_position( at + 12) # BinaryCode header
|
objekt.instructions.set_position( at + 12) # BinaryCode header
|
||||||
len = objekt.instructions.total_byte_length
|
len = objekt.instructions.total_byte_length
|
||||||
log.debug "CODE2 #{objekt.name} at #{binary.position} len: #{len}"
|
log.debug "CODE2 #{objekt.name} at #{Positioned.position(binary)} len: #{len}"
|
||||||
binary.set_length(len , 0)
|
binary.set_length(len , 0)
|
||||||
at += binary.padded_length
|
at += binary.padded_length
|
||||||
end
|
end
|
||||||
@ -51,7 +51,7 @@ module Register
|
|||||||
@objects.each do | id , objekt|
|
@objects.each do | id , objekt|
|
||||||
next if objekt.is_a? Register::Label # will get assembled as method.instructions
|
next if objekt.is_a? Register::Label # will get assembled as method.instructions
|
||||||
next if objekt.is_a? Parfait::BinaryCode
|
next if objekt.is_a? Parfait::BinaryCode
|
||||||
objekt.set_position at
|
Positioned.set_position(objekt,at)
|
||||||
at += objekt.padded_length
|
at += objekt.padded_length
|
||||||
end
|
end
|
||||||
at
|
at
|
||||||
@ -81,11 +81,11 @@ module Register
|
|||||||
|
|
||||||
# debugging loop accesses all positions to force an error if it's not set
|
# debugging loop accesses all positions to force an error if it's not set
|
||||||
def try_write_debug
|
def try_write_debug
|
||||||
all = @objects.values.sort{|a,b| a.position <=> b.position}
|
all = @objects.values.sort{|a,b| Positioned.position(a) <=> Positioned.position(b)}
|
||||||
all.each do |objekt|
|
all.each do |objekt|
|
||||||
next if objekt.is_a?(Register::Label)
|
next if objekt.is_a?(Register::Label)
|
||||||
log.debug "Linked #{objekt.class}(#{objekt.object_id}) at #{objekt.position} / #{objekt.padded_length}"
|
log.debug "Linked #{objekt.class}(#{objekt.object_id}) at #{Positioned.position(objekt)} / #{objekt.padded_length}"
|
||||||
objekt.position
|
Positioned.position(objekt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ module Register
|
|||||||
@stream.write_unsigned_int_8(0)
|
@stream.write_unsigned_int_8(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_write_objects
|
def try_write_objects
|
||||||
# then the objects , not code yet
|
# then the objects , not code yet
|
||||||
@objects.each do | id, objekt|
|
@objects.each do | id, objekt|
|
||||||
@ -153,16 +154,16 @@ module Register
|
|||||||
|
|
||||||
def write_any obj
|
def write_any obj
|
||||||
write_any_log( obj , "Write")
|
write_any_log( obj , "Write")
|
||||||
if @stream.length != obj.position
|
if @stream.length != Positioned.position(obj)
|
||||||
raise "Write #{obj.class} #{obj.object_id} at #{stream_position} not #{obj.position}"
|
raise "Write #{obj.class} #{obj.object_id} at #{stream_position} not #{Positioned.position(obj)}"
|
||||||
end
|
end
|
||||||
write_any_out(obj)
|
write_any_out(obj)
|
||||||
write_any_log( obj , "Wrote")
|
write_any_log( obj , "Wrote")
|
||||||
obj.position
|
Positioned.position(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_any_log( obj , at)
|
def write_any_log( obj , at)
|
||||||
log.debug "#{at} #{obj.class}(#{obj.object_id}) at stream #{stream_position} pos:#{obj.position} , len:#{obj.padded_length}"
|
log.debug "#{at} #{obj.class}(#{obj.object_id}) at stream #{stream_position} pos:#{Positioned.position(obj)} , len:#{obj.padded_length}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_any_out(obj)
|
def write_any_out(obj)
|
||||||
@ -182,7 +183,7 @@ module Register
|
|||||||
log.debug "type #{obj_written} , total #{obj_written + indexed_written} (array #{indexed_written})"
|
log.debug "type #{obj_written} , total #{obj_written + indexed_written} (array #{indexed_written})"
|
||||||
log.debug "Len = #{object.get_length} , inst = #{object.get_type.instance_length}" if object.is_a? Parfait::Type
|
log.debug "Len = #{object.get_length} , inst = #{object.get_type.instance_length}" if object.is_a? Parfait::Type
|
||||||
pad_after( obj_written + indexed_written )
|
pad_after( obj_written + indexed_written )
|
||||||
object.position
|
Positioned.position(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_object_check(object)
|
def write_object_check(object)
|
||||||
@ -225,7 +226,7 @@ module Register
|
|||||||
raise "length mismatch #{str.length} != #{string.char_length}" if str.length != string.char_length
|
raise "length mismatch #{str.length} != #{string.char_length}" if str.length != string.char_length
|
||||||
end
|
end
|
||||||
str = string.to_s if string.is_a? Symbol
|
str = string.to_s if string.is_a? Symbol
|
||||||
log.debug "#{string.class} is #{string} at #{string.position} length #{string.length}"
|
log.debug "#{string.class} is #{string} at #{Positioned.position(string)} length #{string.length}"
|
||||||
write_checked_string(string , str)
|
write_checked_string(string , str)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -253,7 +254,7 @@ module Register
|
|||||||
when Fixnum
|
when Fixnum
|
||||||
@stream.write_signed_int_32(object)
|
@stream.write_signed_int_32(object)
|
||||||
else
|
else
|
||||||
@stream.write_signed_int_32(object.position + @load_at)
|
@stream.write_signed_int_32(Positioned.position(object) + @load_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user