Change Locals in calling convention

Just like the args, locals are now inlined into the Message.
Message is off course bigger, but as they are created at compile time, that hardly matters
Some programs did get somewhat smaller, especially with both changes, but not super much
This commit is contained in:
Torsten Rüger 2019-08-23 10:23:01 +03:00
parent 5e44e9caaf
commit 8ed013c2b9
4 changed files with 22 additions and 11 deletions

View File

@ -28,17 +28,17 @@ module Mom
# or then the methods arg or frame
def slot_type_for(name)
if index = @callable.arguments_type.variable_index(name)
return ["arg#{index}".to_sym]
elsif @callable.frame_type.variable_index(name)
slot_def = [:frame]
slot_def = ["arg#{index}".to_sym]
elsif index = @callable.frame_type.variable_index(name)
slot_def = ["local#{index}".to_sym]
elsif index = @method.arguments_type.variable_index(name)
return [:caller , :caller , "arg#{index}".to_sym]
elsif @method.frame_type.variable_index(name)
slot_def = [:caller ,:caller , :frame ]
slot_def = [:caller , :caller , "arg#{index}".to_sym]
elsif index = @method.frame_type.variable_index(name)
slot_def = [:caller ,:caller , "local#{index}".to_sym ]
elsif
raise "no variable #{name} , need to resolve at runtime"
end
slot_def << name
return slot_def
end

View File

@ -71,7 +71,9 @@ module Mom
if index = @callable.arguments_type.variable_index(name)
return ["arg#{index}".to_sym]
end
[:frame , name]
index = @callable.frame_type.variable_index(name)
raise "no such local or argument #{name}" unless index
return ["local#{index}".to_sym]
end
def add_block_compiler(compiler)

View File

@ -16,14 +16,17 @@ module Parfait
# :caller => :Message , :name => :Word , :arguments => :NamedList
attr :type, :next_message
attr :receiver , :frame
attr :receiver
attr :return_address, :return_value
attr :caller , :method
attr :arguments_given
attr :arg1 , :arg2, :arg3, :arg4, :arg5, :arg6
attr :locals_used
attr :local1 , :local2, :local3, :local4, :local5, :local6 ,:local7,:local8
attr :local9 ,:local10, :local11 , :local12, :local13, :local14
def self.type_length
16
31
end
def self.memory_size
32
@ -31,10 +34,13 @@ module Parfait
def self.args_start_at
Parfait.object_space.get_type_by_class_name(:Message).variable_index(:arguments_given)
end
def self.locals_start_at
Parfait.object_space.get_type_by_class_name(:Message).variable_index(:locals_used)
end
def initialize( )
super()
self.frame = NamedList.new()
self.locals_used = Parfait::Integer.new(0)
self.arguments_given = Parfait::Integer.new(0)
end
public :initialize

View File

@ -58,8 +58,11 @@ module Parfait
end
def init_message_chain( message )
prev = nil
while(message)
message.initialize
message.caller = prev if prev
prev = message
message = message.next_message
end
end