Inline arguments into message

thus removing indirection for access
does affect rather much, several commits
This commit is contained in:
Torsten Rüger 2019-08-22 17:54:17 +03:00
parent c13d4fb017
commit 0a1b05b2ee
12 changed files with 36 additions and 28 deletions

View File

@ -54,7 +54,7 @@ module Mom
[ :div4, :<,:<= , :>=, :> , :div10 ].each do |f| #div4 is just a forward declaration [ :div4, :<,:<= , :>=, :> , :div10 ].each do |f| #div4 is just a forward declaration
compilers << compiler_for( int_type , Integer , f) compilers << compiler_for( int_type , Integer , f)
end end
compilers return compilers
end end
def self.compiler_for( type , mod , name) def self.compiler_for( type , mod , name)

View File

@ -12,8 +12,7 @@ module Mom
builder.build do builder.build do
integer! << message[:receiver] integer! << message[:receiver]
integer.reduce_int integer.reduce_int
integer_reg! << message[:arguments] integer_reg! << message[:arg1] #"other"
integer_reg << integer_reg[Parfait::NamedList.type_length + 0] #"other" is at index 0
integer_reg.reduce_int integer_reg.reduce_int
swap_names(:integer , :integer_reg) if(operator.to_s.start_with?('<') ) swap_names(:integer , :integer_reg) if(operator.to_s.start_with?('<') )
integer.op :- , integer_reg integer.op :- , integer_reg

View File

@ -6,8 +6,7 @@ module Mom
integer_tmp = builder.allocate_int integer_tmp = builder.allocate_int
builder.build do builder.build do
object! << message[:receiver] object! << message[:receiver]
integer! << message[:arguments] integer! << message[:arg1] #"at"
integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0
integer.reduce_int integer.reduce_int
object <= object[integer] object <= object[integer]
integer_tmp[Parfait::Integer.integer_index] << object integer_tmp[Parfait::Integer.integer_index] << object

View File

@ -4,8 +4,7 @@ module Mom
def to_risc(compiler) def to_risc(compiler)
compiler.builder(compiler.source).build do compiler.builder(compiler.source).build do
object! << message[:receiver] object! << message[:receiver]
integer! << message[:arguments] integer! << message[:arg1] #"at" is at index 0
integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0
integer.reduce_int integer.reduce_int
object << object[integer] object << object[integer]
message[:return_value] << object message[:return_value] << object

View File

@ -14,8 +14,7 @@ module Mom
builder.build do builder.build do
integer! << message[:receiver] integer! << message[:receiver]
integer.reduce_int integer.reduce_int
integer_reg! << message[:arguments] integer_reg! << message[:arg1] #"other"
integer_reg << integer_reg[Parfait::NamedList.type_length + 0] #"other" is at index 0
integer_reg.reduce_int integer_reg.reduce_int
integer.op operator , integer_reg integer.op operator , integer_reg
integer_tmp[Parfait::Integer.integer_index] << integer integer_tmp[Parfait::Integer.integer_index] << integer

View File

@ -4,10 +4,9 @@ module Mom
def to_risc(compiler) def to_risc(compiler)
compiler.builder(compiler.source).build do compiler.builder(compiler.source).build do
word! << message[:receiver] word! << message[:receiver]
integer! << message[:arguments] integer_reg! << message[:arg2] #VALUE
integer_reg! << integer[Parfait::NamedList.type_length + 1] #"value" is at index 1
message[:return_value] << integer_reg message[:return_value] << integer_reg
integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0 integer! << message[:arg1] #"index"
integer.reduce_int integer.reduce_int
integer_reg.reduce_int integer_reg.reduce_int
word[integer] <= integer_reg word[integer] <= integer_reg

View File

@ -4,9 +4,8 @@ module Mom
def to_risc(compiler) def to_risc(compiler)
compiler.builder(compiler.source).build do compiler.builder(compiler.source).build do
object! << message[:receiver] object! << message[:receiver]
integer! << message[:arguments] integer! << message[:arg1] # "index"
object_reg! << integer[Parfait::NamedList.type_length + 1] #"value" is at index 1 object_reg! << message[:arg2]#"value"
integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0
integer.reduce_int integer.reduce_int
object[integer] << object_reg object[integer] << object_reg
message[:return_value] << object_reg message[:return_value] << object_reg

View File

@ -18,19 +18,24 @@ module Parfait
attr :type, :next_message attr :type, :next_message
attr :receiver , :frame attr :receiver , :frame
attr :return_address, :return_value attr :return_address, :return_value
attr :caller , :method , :arguments attr :caller , :method
attr :arguments_given
attr :arg1 , :arg2, :arg3, :arg4, :arg5, :arg6
def self.type_length def self.type_length
9 16
end end
def self.memory_size def self.memory_size
16 32
end
def self.args_start_at
Parfait.object_space.get_type_by_class_name(:Message).variable_index(:arguments_given)
end end
def initialize( ) def initialize( )
super() super()
self.frame = NamedList.new() self.frame = NamedList.new()
self.arguments = NamedList.new() self.arguments_given = Parfait::Integer.new(0)
end end
public :initialize public :initialize

View File

@ -151,6 +151,7 @@ module Parfait
Data4: {}, Data4: {},
Data8: {}, Data8: {},
Data16: {}, Data16: {},
Data32: {},
Dictionary: {i_keys: :List , i_values: :List } , Dictionary: {i_keys: :List , i_values: :List } ,
FalseClass: {}, FalseClass: {},
Factory: { for_type: :Type , next_object: :Object , Factory: { for_type: :Type , next_object: :Object ,
@ -159,7 +160,10 @@ module Parfait
List: {indexed_length: :Integer , next_list: :List} , List: {indexed_length: :Integer , next_list: :List} ,
Message: { next_message: :Message, receiver: :Object, frame: :NamedList , Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
return_address: :Integer, return_value: :Object, return_address: :Integer, return_value: :Object,
caller: :Message , method: :TypedMethod , arguments: :NamedList }, caller: :Message , method: :TypedMethod ,
arguments_given: :Integer ,
arg1: :Integer , arg2: :Integer, arg3: :Integer,
arg4: :Integer, arg5: :Integer, arg6: :Integer},
MetaClass: {instance_methods: :List, instance_type: :Type, clazz: :Class }, MetaClass: {instance_methods: :List, instance_type: :Type, clazz: :Class },
NamedList: {}, NamedList: {},
NilClass: {}, NilClass: {},

View File

@ -15,7 +15,7 @@ module Parfait
def test_message_name_nil def test_message_name_nil
last = @type.names.last last = @type.names.last
assert_equal :arguments , last , @type.names.inspect assert_equal :arg6 , last , @type.names.inspect
assert_nil @mess.method assert_nil @mess.method
end end
def test_message_next_set def test_message_next_set

View File

@ -7,15 +7,20 @@ module Parfait
super super
@mess = @space.get_next_for(:Message) @mess = @space.get_next_for(:Message)
end end
def test_args_start
assert_equal 8 , Message.args_start_at
end
def test_length def test_length
assert_equal 9 , @mess.get_type.instance_length , @mess.get_type.inspect assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect
end end
def test_attribute_set def test_attribute_set
@mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed @mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed
assert_equal 55 , @mess.receiver assert_equal 55 , @mess.receiver
end end
def test_indexed def test_indexed
assert_equal 8 , @mess.get_type.variable_index(:arguments) assert_equal 8 , @mess.get_type.variable_index(:arguments_given)
assert_equal 9 , @mess.get_type.variable_index(:arg1)
assert_equal 13 , @mess.get_type.variable_index(:arg5)
end end
def test_next_message def test_next_message
assert_equal Message , @mess.next_message.class assert_equal Message , @mess.next_message.class
@ -24,7 +29,7 @@ module Parfait
assert_equal NamedList , @mess.frame.class assert_equal NamedList , @mess.frame.class
end end
def test_arguments def test_arguments
assert_equal NamedList , @mess.arguments.class assert_equal Integer , @mess.arguments_given.class
end end
def test_return_address def test_return_address
assert_nil @mess.return_address assert_nil @mess.return_address

View File

@ -5,7 +5,7 @@ module Parfait
def classes def classes
[:BinaryCode,:Block,:CacheEntry,:Callable,:CallableMethod,:Class, [:BinaryCode,:Block,:CacheEntry,:Callable,:CallableMethod,:Class,
:DataObject,:Data4,:Data8,:Data16,:Dictionary,:Factory, :Integer,:FalseClass, :DataObject,:Data4,:Data8,:Data16,:Data32,:Dictionary,:Factory, :Integer,:FalseClass,
:List,:Message, :MetaClass, :NamedList,:NilClass,:Object,:ReturnAddress, :List,:Message, :MetaClass, :NamedList,:NilClass,:Object,:ReturnAddress,
:Space,:TrueClass,:Type,:VoolMethod,:Word] :Space,:TrueClass,:Type,:VoolMethod,:Word]
end end