[svn:parrot] r45125 - in trunk: include/parrot lib/Parrot/Pmc2c src src/call src/ops src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Mar 23 12:00:08 UTC 2010
Author: bacek
Date: Tue Mar 23 12:00:05 2010
New Revision: 45125
URL: https://trac.parrot.org/parrot/changeset/45125
Log:
Get rid of Interp.current_object and all perverted logick to propogate it into CallContext. Just set it directly when required. This also fixes latest failures in examples/benchmarks/oo*.pir
Modified:
trunk/include/parrot/interpreter.h
trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm
trunk/src/call/args.c
trunk/src/call/pcc.c
trunk/src/ops/core.ops
trunk/src/ops/object.ops
trunk/src/pmc/class.pmc
trunk/src/pmc/coroutine.pmc
trunk/src/pmc/object.pmc
trunk/src/pmc/sub.pmc
trunk/src/thread.c
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/include/parrot/interpreter.h Tue Mar 23 12:00:05 2010 (r45125)
@@ -296,7 +296,6 @@
/* during a call sequencer the caller fills these objects
* inside the invoke these get moved to the context structure */
PMC *current_cont; /* the return continuation PMC */
- PMC *current_object; /* invocant, if a method call */
};
/* typedef struct parrot_interp_t Interp; done in parrot.h so that
Modified: trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm Tue Mar 23 12:00:05 2010 (r45125)
@@ -258,7 +258,6 @@
/*BEGIN RETURN $returns */
END
$e->emit( <<"END", __FILE__, __LINE__ + 1 );
- interp->current_object = PMCNULL;
Parrot_pcc_build_call_from_c_args(interp, _call_object, "$returns_signature",
$returns_varargs);
return;
Modified: trunk/src/call/args.c
==============================================================================
--- trunk/src/call/args.c Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/call/args.c Tue Mar 23 12:00:05 2010 (r45125)
@@ -491,6 +491,8 @@
VTABLE_push_pmc(interp, call_object, PMC_IS_NULL(pmc_value)
? PMCNULL
: clone_key_arg(interp, pmc_value));
+ if (arg_flags & PARROT_ARG_INVOCANT)
+ Parrot_pcc_set_object(interp, call_object, pmc_value);
}
break;
@@ -718,6 +720,7 @@
else {
VTABLE_push_pmc(interp, call_object, pmc_arg);
i++; /* skip 'i' */
+ Parrot_pcc_set_object(interp, call_object, pmc_arg);
}
}
else
Modified: trunk/src/call/pcc.c
==============================================================================
--- trunk/src/call/pcc.c Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/call/pcc.c Tue Mar 23 12:00:05 2010 (r45125)
@@ -175,7 +175,6 @@
"Method '%Ss' not found", method_name);
/* Invoke the subroutine object with the given CallSignature object */
- interp->current_object = pmc;
Parrot_pcc_invoke_from_sig_object(interp, sub_obj, sig_obj);
}
@@ -291,8 +290,6 @@
do_run_ops(PARROT_INTERP, ARGIN(PMC *sub_obj))
{
ASSERT_ARGS(do_run_ops)
- if (!PMC_IS_NULL(interp->current_object))
- return 0;
if (sub_obj->vtable->base_type < enum_class_core_max)
return sub_obj->vtable->base_type == enum_class_Sub
Modified: trunk/src/ops/core.ops
==============================================================================
--- trunk/src/ops/core.ops Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/ops/core.ops Tue Mar 23 12:00:05 2010 (r45125)
@@ -376,8 +376,11 @@
inline op invokecc(invar PMC) :flow {
PMC * const p = $1;
opcode_t *dest = expr NEXT();
+ PMC *signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
- interp->current_object = NULL;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, NULL);
interp->current_cont = NEED_CONTINUATION;
dest = VTABLE_invoke(interp, p, dest);
@@ -387,8 +390,11 @@
inline op invoke(invar PMC, invar PMC) :flow {
opcode_t *dest = expr NEXT();
PMC * const p = $1;
+ PMC *signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
- interp->current_object = NULL;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, NULL);
interp->current_cont = $2;
dest = VTABLE_invoke(interp, p, dest);
Modified: trunk/src/ops/object.ops
==============================================================================
--- trunk/src/ops/object.ops Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/ops/object.ops Tue Mar 23 12:00:05 2010 (r45125)
@@ -53,6 +53,8 @@
PMC * const method_pmc = VTABLE_find_method(interp, object, meth);
opcode_t *dest = NULL;
+ PMC * signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
if (PMC_IS_NULL(method_pmc)) {
PMC * const _class = VTABLE_get_class(interp, object);
@@ -69,7 +71,8 @@
}
}
else {
- interp->current_object = object;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, object);
interp->current_cont = NEED_CONTINUATION;
dest = VTABLE_invoke(interp, method_pmc, next);
}
@@ -79,8 +82,11 @@
op callmethodcc(invar PMC, invar PMC) :object_base :flow {
opcode_t *dest;
opcode_t * const next = expr NEXT();
+ PMC * signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
- interp->current_object = $1;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, $1);
interp->current_cont = NEED_CONTINUATION;
dest = VTABLE_invoke(interp, $2, next);
@@ -94,6 +100,8 @@
PMC * const method_pmc = VTABLE_find_method(interp, object, meth);
opcode_t *dest = NULL;
+ PMC * signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
if (PMC_IS_NULL(method_pmc)) {
@@ -102,7 +110,8 @@
VTABLE_get_string(interp, VTABLE_get_class(interp, object)));
}
else {
- interp->current_object = object;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, object);
interp->current_cont = $3;
dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
}
@@ -115,8 +124,11 @@
opcode_t * const next = expr NEXT();
opcode_t *dest;
+ PMC * signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
- interp->current_object = object;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, object);
interp->current_cont = $3;
dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
goto ADDRESS(dest);
@@ -129,6 +141,8 @@
PMC * const method_pmc = VTABLE_find_method(interp, object, meth);
opcode_t *dest;
+ PMC * signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
if (PMC_IS_NULL(method_pmc)) {
dest = Parrot_ex_throw_from_op_args(interp, next, EXCEPTION_METHOD_NOT_FOUND,
@@ -138,7 +152,8 @@
else {
interp->current_cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
PObj_get_FLAGS(interp->current_cont) |= SUB_FLAG_TAILCALL;
- interp->current_object = object;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, object);
dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
}
goto ADDRESS(dest);
@@ -150,11 +165,14 @@
PMC * const method_pmc = $2;
opcode_t *dest;
+ PMC * signature = Parrot_pcc_get_signature(interp,
+ CURRENT_CONTEXT(interp));
interp->current_cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
PObj_get_FLAGS(interp->current_cont) |= SUB_FLAG_TAILCALL;
- interp->current_object = object;
+ if (!PMC_IS_NULL(signature))
+ Parrot_pcc_set_object(interp, signature, object);
dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
goto ADDRESS(dest);
}
Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/pmc/class.pmc Tue Mar 23 12:00:05 2010 (r45125)
@@ -344,9 +344,7 @@
if (!PMC_IS_NULL(meth)) {
/* preserve current_object */
- PMC * const old_object = interp->current_object;
Parrot_pcc_invoke_sub_from_c_args(interp, meth, "Pi->", object);
- interp->current_object = old_object;
}
}
}
Modified: trunk/src/pmc/coroutine.pmc
==============================================================================
--- trunk/src/pmc/coroutine.pmc Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/pmc/coroutine.pmc Tue Mar 23 12:00:05 2010 (r45125)
@@ -183,7 +183,6 @@
Parrot_pcc_set_continuation(INTERP, ctx, ccont);
Parrot_pcc_set_object(INTERP, ctx, PMCNULL);
- INTERP->current_object = PMCNULL;
INTERP->current_cont = PMCNULL;
GET_ATTR_lex_info(INTERP, SELF, lex_info);
Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/pmc/object.pmc Tue Mar 23 12:00:05 2010 (r45125)
@@ -660,8 +660,7 @@
if (!PMC_IS_NULL(meth)) {
/* Experimental code. See DEPRECATED.pod */
PMC *call_sig = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
- if (PMC_IS_NULL(interp->current_object) &&
- (VTABLE_elements(interp, call_sig) == 0 ||
+ if ((VTABLE_elements(interp, call_sig) == 0 ||
VTABLE_get_pmc_keyed_int(interp, call_sig, 0) != SELF))
VTABLE_unshift_pmc(interp, call_sig, SELF);
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/pmc/sub.pmc Tue Mar 23 12:00:05 2010 (r45125)
@@ -345,8 +345,9 @@
*/
VTABLE opcode_t *invoke(void *next) {
- PMC *caller_ctx = CURRENT_CONTEXT(interp);
+ PMC *caller_ctx = CURRENT_CONTEXT(INTERP);
PMC *ccont = INTERP->current_cont;
+ PMC *object;
/* plain subroutine call
* create new context, place it in interpreter */
@@ -395,7 +396,10 @@
CURRENT_CONTEXT(INTERP) = context;
Parrot_pcc_set_caller_ctx(INTERP, context, caller_ctx);
Parrot_pcc_allocate_registers(INTERP, context, sub->n_regs_used);
+ /* Preserve object */
+ object = Parrot_pcc_get_object(INTERP, context);
Parrot_pcc_init_context(INTERP, context, caller_ctx);
+ Parrot_pcc_set_object(INTERP, context, object);
Parrot_pcc_set_sub(interp, context, SELF);
Parrot_pcc_set_continuation(interp, context, ccont);
@@ -418,11 +422,6 @@
ccont->vtable = interp->vtables[enum_class_Continuation];
}
- if (!PMC_IS_NULL(INTERP->current_object)) {
- Parrot_pcc_set_object(interp, context, INTERP->current_object);
- INTERP->current_object = NULL;
- }
-
/* create pad if needed
* TODO move this up in front of argument passing
* and factor out common code with coroutine pmc
Modified: trunk/src/thread.c
==============================================================================
--- trunk/src/thread.c Tue Mar 23 11:59:22 2010 (r45124)
+++ trunk/src/thread.c Tue Mar 23 12:00:05 2010 (r45125)
@@ -777,10 +777,6 @@
make_local_args_copy(interpreter, interp, arg));
/*
- * set regs according to pdd03
- */
- interpreter->current_object = dest_interp;
- /*
* create a joinable thread
*/
interpreter->thread_data->state = THREAD_STATE_JOINABLE;
More information about the parrot-commits
mailing list