Permalink
Browse files

[pcc_branch] Committing uncommitted changes so others can take a look

(some may be reverted later).


git-svn-id: https://svn.parrot.org/parrot/branches/pcc_rewiring@39370 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent c856261 commit 7abbbef10dffeed0ee837ab15ac48d31cf89832f allison committed Jun 3, 2009
Showing with 92 additions and 27 deletions.
  1. +17 −0 include/parrot/call.h
  2. +43 −3 src/call/pcc.c
  3. +4 −4 src/events.c
  4. +1 −1 src/exceptions.c
  5. +11 −10 src/inter_cb.c
  6. +4 −0 src/ops/pic.ops
  7. +1 −1 src/packfile.c
  8. +2 −1 src/pmc/class.pmc
  9. +4 −4 src/scheduler.c
  10. +1 −1 src/stacks.c
  11. +1 −1 src/thread.c
  12. +3 −1 src/utils.c
View
@@ -269,6 +269,17 @@ void Parrot_pcc_invoke_method_from_c_args(PARROT_INTERP,
FUNC_MODIFIES(*method_name);
PARROT_EXPORT
+void Parrot_pcc_invoke_method_object_from_c_args(PARROT_INTERP,
+ ARGIN(PMC* pmc),
+ ARGIN(PMC *method_obj),
+ ARGIN(const char *signature),
+ ...)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ __attribute__nonnull__(4);
+
+PARROT_EXPORT
void Parrot_pcc_invoke_sub_from_c_args(PARROT_INTERP,
ARGIN(PMC *sub_obj),
ARGIN(const char *sig),
@@ -424,6 +435,12 @@ STRING* set_retval_s(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
|| PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(method_name) \
|| PARROT_ASSERT_ARG(signature)
+#define ASSERT_ARGS_Parrot_pcc_invoke_method_object_from_c_args \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(pmc) \
+ || PARROT_ASSERT_ARG(method_obj) \
+ || PARROT_ASSERT_ARG(signature)
#define ASSERT_ARGS_Parrot_pcc_invoke_sub_from_c_args \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
View
@@ -3842,6 +3842,43 @@ Parrot_PCCINVOKE(PARROT_INTERP, ARGIN(PMC* pmc), ARGMOD(STRING *method_name),
/*
+=item C<void Parrot_pcc_invoke_method_object_from_c_args(PARROT_INTERP, PMC* pmc,
+PMC *method_obj, const char *signature, ...)>
+
+Makes a method call given the name of the method and the arguments as a
+C variadic argument list. C<pmc> is the invocant, C<method_obj> is the
+invocable method object, C<signature> is a C string describing the
+signature of the invocation, according to the Parrot calling
+conventions. The variadic argument list contains the input arguments
+followed by the output results in the same order that they appear in the
+function signature.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_pcc_invoke_method_object_from_c_args(PARROT_INTERP, ARGIN(PMC* pmc),
+ ARGIN(PMC *method_obj),
+ ARGIN(const char *signature), ...)
+{
+ ASSERT_ARGS(Parrot_pcc_invoke_method_object_from_c_args)
+ PMC *sig_obj;
+ va_list args;
+ va_start(args, signature);
+ sig_obj = Parrot_pcc_build_sig_object_from_varargs(interp, pmc, signature, args);
+ va_end(args);
+
+ /* Invoke the subroutine object with the given CallSignature object */
+ interp->current_object = pmc;
+ Parrot_pcc_invoke_from_sig_object(interp, method_obj, sig_obj);
+ gc_unregister_pmc(interp, sig_obj);
+
+}
+
+/*
+
=item C<void Parrot_pcc_invoke_method_from_c_args(PARROT_INTERP, PMC* pmc,
STRING *method_name, const char *signature, ...)>
@@ -3916,6 +3953,9 @@ Parrot_pcc_invoke_from_sig_object(PARROT_INTERP, ARGIN(PMC *sub_obj),
/* Invoke the function */
dest = VTABLE_invoke(interp, sub_obj, NULL);
+ if (!dest)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PARROT_USAGE_ERROR,
+ "Subroutine returned a NULL address");
/* PIR Subs need runops to run their opcodes. Methods and NCI subs
* don't. */
@@ -3925,12 +3965,12 @@ Parrot_pcc_invoke_from_sig_object(PARROT_INTERP, ARGIN(PMC *sub_obj),
const opcode_t offset = dest - interp->code->base.data;
/* can't re-enter the runloop from here with PIC cores: RT #60048 */
- if (interp->run_core == PARROT_CGP_CORE
+/* if (interp->run_core == PARROT_CGP_CORE
|| interp->run_core == PARROT_SWITCH_CORE)
- interp->run_core = PARROT_SLOW_CORE;
+ interp->run_core = PARROT_SLOW_CORE;*/
runops(interp, offset);
- interp->run_core = old_core;
+/* interp->run_core = old_core; */
}
}
View
@@ -1471,8 +1471,8 @@ do_event(PARROT_INTERP, ARGIN(parrot_event* event), ARGIN_NULLOK(opcode_t *next)
break;
case EVENT_TYPE_TIMER:
/* run ops, save registers */
- Parrot_runops_fromc_args_event(interp,
- event->u.timer_event.sub, "v");
+ Parrot_pcc_invoke_sub_from_c_args(interp,
+ event->u.timer_event.sub, "->");
break;
case EVENT_TYPE_CALL_BACK:
edebug((stderr, "starting user cb\n"));
@@ -1481,9 +1481,9 @@ do_event(PARROT_INTERP, ARGIN(parrot_event* event), ARGIN_NULLOK(opcode_t *next)
break;
case EVENT_TYPE_IO:
edebug((stderr, "starting io handler\n"));
- Parrot_runops_fromc_args_event(interp,
+ Parrot_pcc_invoke_sub_from_c_args(interp,
event->u.io_event.handler,
- "vPP",
+ "PP->",
event->u.io_event.pio,
event->u.io_event.user_data);
break;
View
@@ -351,7 +351,7 @@ Parrot_ex_throw_from_c(PARROT_INTERP, ARGIN(PMC *exception))
}
/* Run the handler. */
- Parrot_runops_fromc_args(interp, handler, "vP", exception);
+ Parrot_pcc_invoke_sub_from_c_args(interp, handler, "P->", exception);
/* After handling a C exception, you don't want to resume at the point
* where the C exception was thrown, you want to resume the next outer
View
@@ -294,7 +294,7 @@ Parrot_run_callback(PARROT_INTERP,
PMC *sub;
STRING *sig_str;
char *p;
- char pasm_sig[4];
+ char pasm_sig[5];
INTVAL i_param;
PMC *p_param;
void *param = NULL; /* avoid -Ox warning */
@@ -309,13 +309,12 @@ Parrot_run_callback(PARROT_INTERP,
p = sig_str->strstart;
++p; /* Skip return type */
- pasm_sig[0] = 'v'; /* no return value supported yet */
- pasm_sig[1] = 'P';
+ pasm_sig[0] = 'P';
if (*p == 'U') /* user_data Z in pdd16 */
++p; /* p is now type of external data */
switch (*p) {
case 'v':
- pasm_sig[2] = 'v';
+ pasm_sig[1] = 'v';
break;
#if 0
case '2':
@@ -334,7 +333,7 @@ Parrot_run_callback(PARROT_INTERP,
case 'c':
i_param = (INTVAL)(char)(long)external_data;
case_I:
- pasm_sig[2] = 'I';
+ pasm_sig[1] = 'I';
param = (void*) i_param;
break;
#if 0
@@ -349,24 +348,26 @@ Parrot_run_callback(PARROT_INTERP,
/* created a UnManagedStruct */
p_param = pmc_new(interp, enum_class_UnManagedStruct);
VTABLE_set_pointer(interp, p_param, external_data);
- pasm_sig[2] = 'P';
+ pasm_sig[1] = 'P';
param = (void*) p_param;
break;
#if 0
case 'P':
- pasm_sig[2] = 'P';
+ pasm_sig[1] = 'P';
break;
#endif
case 't':
- pasm_sig[2] = 'S';
+ pasm_sig[1] = 'S';
param = Parrot_str_new(interp, external_data, 0);
break;
default:
Parrot_ex_throw_from_c_args(interp, NULL, 1,
"unhandled signature char '%c' in run_cb", *p);
}
- pasm_sig[3] = '\0';
- Parrot_runops_fromc_args_event(interp, sub, pasm_sig,
+ pasm_sig[2] = '-';
+ pasm_sig[3] = '>'; /* no return value supported yet */
+ pasm_sig[4] = '\0';
+ Parrot_pcc_invoke_sub_from_c_args(interp, sub, pasm_sig,
user_data, param);
}
/*
View
@@ -244,6 +244,10 @@ inline op pic_callr__(inconst PMC) :pic :flow {
void **pred_pc;
INTVAL i, n_args, *sig_bits;
PMC *sig;
+ opcode_t *handler = Parrot_ex_throw_from_op_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
+ "Impossible call, poking into low-level args");
+ goto ADDRESS(handler);
ctx = CONTEXT(interp);
mic = (Parrot_MIC *) cur_opcode[1];
View
@@ -678,7 +678,7 @@ run_sub(PARROT_INTERP, ARGIN(PMC *sub_pmc))
CONTEXT(interp)->constants = interp->code->const_table->constants;
- retval = (PMC *)Parrot_runops_fromc_args(interp, sub_pmc, "P");
+ Parrot_pcc_invoke_sub_from_c_args(interp, sub_pmc, "->P", &retval);
interp->run_core = old;
return retval;
View
@@ -364,7 +364,8 @@ initialize_parents_pmc(PARROT_INTERP, PMC *object, PMC *all_parents, PMC *init)
meth = Parrot_oo_find_vtable_override_for_class(interp, parent, name);
if (!PMC_IS_NULL(meth))
- Parrot_run_meth_fromc_args(interp, meth, object, name, "vP", init);
+ Parrot_pcc_invoke_sub_from_c_args(interp, meth,
+ "PiP->", object, init);
}
}
View
@@ -140,8 +140,8 @@ Parrot_cx_handle_tasks(PARROT_INTERP, ARGMOD(PMC *scheduler))
PMC * const handler = Parrot_cx_find_handler_for_task(interp, task);
if (!PMC_IS_NULL(handler)) {
PMC * handler_sub = VTABLE_get_attr_str(interp, handler, CONST_STRING(interp, "code"));
- Parrot_runops_fromc_args_event(interp, handler_sub,
- "vPP", handler, task);
+ Parrot_pcc_invoke_sub_from_c_args(interp, handler_sub,
+ "PP->", handler, task);
}
}
else {
@@ -950,8 +950,8 @@ Parrot_cx_timer_invoke(PARROT_INTERP, ARGIN(PMC *timer))
Parrot_floatval_time());
#endif
if (!PMC_IS_NULL(timer_struct->codeblock)) {
- Parrot_runops_fromc_args_event(interp,
- timer_struct->codeblock, "v");
+ Parrot_pcc_invoke_sub_from_c_args(interp,
+ timer_struct->codeblock, "->");
}
}
View
@@ -544,7 +544,7 @@ run_cleanup_action(PARROT_INTERP, ARGIN(Stack_Entry_t *e))
* stack - run the action subroutine with an INTVAL arg of 0
*/
PMC * const sub = UVal_pmc(e->entry);
- Parrot_runops_fromc_args(interp, sub, "vI", 0);
+ Parrot_pcc_invoke_sub_from_c_args(interp, sub, "I->", 0);
}
/*
View
@@ -532,7 +532,7 @@ thread_func(ARGIN_NULLOK(void *arg))
Parrot_ex_add_c_handler(interp, &jump_point);
Parrot_unblock_GC_mark(interp);
Parrot_unblock_GC_sweep(interp);
- ret_val = Parrot_runops_fromc_args(interp, sub_pmc, "PF", sub_arg);
+ Parrot_pcc_invoke_sub_from_c_args(interp, sub_pmc, "P->P", sub_arg, &ret_val);
}
/* thread is finito */
View
@@ -902,6 +902,7 @@ static INTVAL
COMPARE(PARROT_INTERP, ARGIN(void *a), ARGIN(void *b), ARGIN(PMC *cmp))
{
ASSERT_ARGS(COMPARE)
+ INTVAL result;
if (PMC_IS_NULL(cmp))
return VTABLE_cmp(interp, (PMC *)a, (PMC *)b);
@@ -910,7 +911,8 @@ COMPARE(PARROT_INTERP, ARGIN(void *a), ARGIN(void *b), ARGIN(PMC *cmp))
return f(interp, a, b);
}
- return Parrot_runops_fromc_args_reti(interp, cmp, "IPP", a, b);
+ Parrot_pcc_invoke_sub_from_c_args(interp, cmp, "PP->I", a, b, &result);
+ return result;
}
/*

0 comments on commit 7abbbef

Please sign in to comment.