[perl #42156] [PATCH] Make invoke() return opcode_t*

0 views
Skip to first unread message

Steve Peters

unread,
Mar 28, 2007, 1:41:51 PM3/28/07
to bugs-bi...@rt.perl.org
# New Ticket Created by Steve Peters
# Please include the string: [perl #42156]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42156 >


In this next round of cleanups, I switched over the invoke() methods
to return opcode_t* as Andy Dougherty suggested. Also, I added
a change to the NEED_CONTINUATION based on Kevin Tewks suggestions.
Finally, I also included a couple of additional changes to back out some
of my changes yesterday that are now irrelevant due to the first two
changes.

Steve Peters
st...@fisharerojo.org

opcode.diff

Paul Cochrane

unread,
Mar 29, 2007, 1:28:52 PM3/29/07
to perl6-i...@perl.org, bugs-bi...@rt.perl.org

Thanks for the patch, however, applying it generates the warning: (on
linux x86; gcc)

src/sub.c: In function `mark_context':
src/sub.c:55: warning: comparison of distinct pointer types lacks a cast

I'm not sure how to proceed from here, and I hoped you would. How
should the patch be altered so that the warning doesn't appear?

Paul

Steve Peters

unread,
Mar 30, 2007, 10:34:45 AM3/30/07
to Paul Cochrane, perl6-i...@perl.org, bugs-bi...@netlabs.develooper.com

Below is an additional change for src/sub.c.

I had been looking at this function for additional changes, but
I'd rather get this patch taken care of first, since the rest remaining
changes are made easier by this patch going in first.

I also noticed a warning with src/debug.c. There are certainly, however,
some rather severe existing problems with the Parrot debugger that I don't
know I am qualified to handle. It's pretty obvious that the previous
expectation that VTABLE_invoke() would return something that could be
turned into a PackFile was incorrect since everywhere else it's expected to
return an opcode_t*. I'm certain that I do not have the right answers, but
getting the Parrot Debugger to work may be a great exercize for a future
microgrant winner (hint hint).

Steve Peters
st...@fisharerojo.org

Index: src/sub.c
===================================================================
--- src/sub.c (revision 17850)
+++ src/sub.c (working copy)
@@ -52,7 +52,7 @@
* and GC the continuation
*/
obj = (PObj*)interp->current_cont;
- if (obj && obj != NEED_CONTINUATION)
+ if (obj && obj != (PObj*)NEED_CONTINUATION)
pobject_lives(interp, obj);
obj = (PObj*)ctx->current_cont;
if (obj && !PObj_live_TEST(obj))

Index: src/debug.c
===================================================================
--- src/debug.c (revision 17850)
+++ src/debug.c (working copy)
@@ -1973,15 +1973,27 @@
struct PackFile *eval_pf;
struct PackFile_ByteCode *old_cs;

- eval_pf = PDB_compile(interp, command);
+/*
+ The replacement code is almost certainly wrong. The previous
+ code is almost certainly wrong as well. Obviously, the
+ Parrot debugger needs some love.
+*/

+#if 0
+ /* eval_pf = PDB_compile(interp, command);
+
if (eval_pf) {
old_cs = Parrot_switch_to_cs(interp, eval_pf->cur_cs, 1);
run = eval_pf->cur_cs->base.data;
DO_OP(run,interp);
Parrot_switch_to_cs(interp, old_cs, 1);
- /* TODO destroy packfile */
+ TODO destroy packfile
}
+#endif
+ run = PDB_compile(interp, command);
+ if(run) {
+ DO_OP(run,interp);
+ }
}

/*
@@ -2000,25 +2012,22 @@

*/

-struct PackFile *
+opcode_t *
PDB_compile(Interp *interp, const char *command)
{
STRING *buf;
const char *end = "\nend\n";
- PMC * compiler, *code;
+ PMC * compiler;
STRING *key = const_string(interp, "PASM");
PMC *compreg_hash = VTABLE_get_pmc_keyed_int(interp,
interp->iglobals, IGLOBALS_COMPREG_HASH);
-
compiler = VTABLE_get_pmc_keyed_str(interp, compreg_hash, key);
if (!VTABLE_defined(interp, compiler)) {
fprintf(stderr, "Couldn't find PASM compiler");
return NULL;
}
buf = Parrot_sprintf_c(interp, "%s%s", command, end);
-
- code = VTABLE_invoke(interp, compiler, buf);
- return PMC_struct_val(code);
+ return VTABLE_invoke(interp, compiler, buf);
}

/*

Paul Cochrane via RT

unread,
Mar 30, 2007, 3:21:23 PM3/30/07
to perl6-i...@perl.org
Thanks! Applied in r17859.

Note: I had to update include/parrot/debug.h to make sure that src/
debug.c

Reply all
Reply to author
Forward
0 new messages