As we mentioned yesterday at #ps, we're going to have a hackathon on
Saturday to get the args/returns refactor started. Information about
the refactor is located on the wiki:

http://trac.parrot.org/parrot/wiki/CallingConventionsTasklist

For people who aren't familiar with the task at hand, here's a
nutshell version: In current function calls in PIR, we call the
get_results opcode BEFORE we invoke the Sub PMC. This means two
things: (1) we have to pack pointers to the return results into the
CallContext PMC, and (2) we need to use different functions for
passing arguments and passing returns, even though the two should use
the same mechanism. After the refactor, both function call and
function return will use the same mechanism: Pass "arguments"
("returns") into a CallContext, invoke the function (invoke the
return), and unpack the "parameters" ("results").

To make this work, there are a few tasks to complete. I'm listing them
in a general order that I think things could go in, but this isn't a
firm timeline:

1) We need to modify IMCC to output the correct opcode sequence for a
function call. I'm sure it's not so simple, but it looks to me like
the primary place to make this change is going to be in
compilers/imcc/pcc.c:expand_pcc_sub_call(), and related functions.

2) We need to remove return_flags, current_returns, returns_values,
returns_sizes and returns_size_threshold attributes, and supporting
code from CallContext PMC.

3) Modify the set_returns opcode to create a new CallContext to pass
the returns. set_returns is going to act almost identically to the
set_args opcode. We need to build the CallContext, passing the returns
like how set_args passes arguments. The relevant ops are in
src/ops/core.ops. We're probably also going to need to look at
src/call/args.c:Parrot_pcc_build_sig_object_from_op(), mostly for
inspiration. We should probably delete
src/call/args.c:Parrot_pcc_build_sig_object_returns_from_op(),
replacing with the former function.

4) We need to unify the argument passing code. Specifically, we need
to unify the functions src/call/args.c:Parrot_pcc_fill_params_from_op
with src/call/args.c:Parrot_pcc_fill_returns_from_op, and unify
src/call/args.c:Parrot_pcc_fill_params_from_varargs with
src/call/args.c:Parrot_pcc_fill_returns_from_varargs. We're also going
to need to take a close look at
src/call/args.c:Parrot_pcc_fill_returns_from_continuation. At the very
least we should rename it to
"Parrot_pcc_fill_params_from_continuation".

5) Unify supporting functions, src/call/args.c:fill_params with
src/call/args.c:fill_results. These functions are large and ugly, so
this could be the hardest part of the refactor. Also, merge
src/call/args.c:assign_default_result_value ->
src/call/args.c:assign_default_param_value.

6) Find and kill any dead code that is no longer used.

I think that's a pretty comprehensive list of the tasks that need to
be completed for this hackathon. I'm sure I'm missing something, so
please post a follow-up email if you can point other items out. There
is a branch for this already, but it's several days old. If there are
no commits to the branch, we'll delete it and create a new more
up-to-date branch on Friday to support the work.

Comments/questions can come to the list or go to IRC if people are
around. Send me a message and I'll make sure you get the answers you
need, or I'll make sure to get you in touch with whoever has answers.
Clarifications for various subtasks can go to the wiki. I look forward
to seeing a bunch of hackers on Saturday!

--Andrew Whitworth
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to