Changing the call setup and return to be more efficient

Now we are using a statically linked list of messages. This will not work with procs, but that can be solved then.

Previous (wrong) thinking was that because of procs messages have to be allocated for every call. This was too slow, and not neccessary
This commit is contained in:
Torsten Rüger 2019-08-23 15:30:27 +03:00
parent 8ed013c2b9
commit 89f32ed74a
3 changed files with 2 additions and 32 deletions

View File

@ -59,25 +59,10 @@ module Mom
"method setup "
end
# get the next message from space and unlink it there
# also put it into next_message of current message (and reverse)
# set the method into the message
def build_message_data( builder )
builder.build do
factory? << Parfait.object_space.get_factory_for(:Message)
next_message? << factory[:next_object]
#FIXME in a multithreaded future this should be done using lock free compare and swap.
next_message_reg! << next_message[:next_message]
factory[:next_object] << next_message_reg
# FIXME: Also we relink used messages at the moment. This will have to stop
# when implementing continuations (or block passing/bindings)
# then we may run out and that means cheking and maybe getting more
message[:next_message] << next_message
next_message[:caller] << message
next_message[:method] << callable
next_message?[:method] << callable
end
end
end

View File

@ -26,19 +26,12 @@ module Mom
object! << message[:return_value]
caller_reg! << message[:caller]
caller_reg[:return_value] << object
factory? << Parfait.object_space.get_factory_for(:Message)
# here we return the current message to the list of messages
# which is only correct without blocks or real continuations
next_message! << factory[:next_object]
message[:next_message] << next_message
factory[:next_object] << message
end
compiler.reset_regs
builder.build do
return_address! << message[:return_address]
return_address << return_address[ Parfait::Integer.integer_index]
message << message[:caller]
return_address.function_return
add_code Risc.function_return("return", return_address)
end
end

View File

@ -171,14 +171,6 @@ module Risc
op
end
# generate a Function return instruction
# using the register as the parameter where the return address is passed
def function_return
ret = Risc.function_return("return", self)
builder.add_code(ret) if builder
ret
end
# create operator instruction for self and add
# doesn't read quite as smoothly as one would like, but better than the compiler version
def op( operator , right)