cvsuser 03/10/15 01:31:29
Modified: classes eval.pmc parrotinterpreter.pmc
config/gen/config_h config_h.in
. core.ops embed.c exceptions.c interpreter.c jit.c
include/parrot embed.h interpreter.h
languages/imcc main.c
Log:
separated interpreter flags and run core flags:
* interp->flags are indiviudal bits
* interp->run_core can only be one of the cores
So these are distinct now.
Revision Changes Path
1.20 +2 -2 parrot/classes/eval.pmc
Index: eval.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/eval.pmc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -r1.19 -r1.20
--- eval.pmc 28 Aug 2003 08:11:05 -0000 1.19
+++ eval.pmc 15 Oct 2003 08:31:15 -0000 1.20
@@ -1,7 +1,7 @@
/* Eval.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: eval.pmc,v 1.19 2003/08/28 08:11:05 leo Exp $
+ * $Id: eval.pmc,v 1.20 2003/10/15 08:31:15 leo Exp $
* Overview:
* These are the vtable functions for evaluating a code segment
* Data Structure and Algorithms:
@@ -31,7 +31,7 @@
SUPER(next); /* invoke on Sub returns the address */
#if EXEC_CAPABLE
extern int Parrot_exec_run;
- if (Interp_flags_TEST(interpreter, PARROT_EXEC_FLAG)) {
+ if (Interp_core_TEST(interpreter, PARROT_EXEC_CORE)) {
Parrot_exec_run = 2;
}
#endif
1.6 +6 -8 parrot/classes/parrotinterpreter.pmc
Index: parrotinterpreter.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotinterpreter.pmc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- parrotinterpreter.pmc 28 Aug 2003 13:17:01 -0000 1.5
+++ parrotinterpreter.pmc 15 Oct 2003 08:31:15 -0000 1.6
@@ -1,7 +1,7 @@
/* parrotinterpreter.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: parrotinterpreter.pmc,v 1.5 2003/08/28 13:17:01 leo Exp $
+ * $Id: parrotinterpreter.pmc,v 1.6 2003/10/15 08:31:15 leo Exp $
* Overview:
* These are the vtable functions for the ParrotInterpreter base class
* Data Structure and Algorithms:
@@ -12,10 +12,12 @@
* set I0, P0[x] # interpinfo I0, x
* set I0, P0[-1] # get interpreter flags
* set P0[-1], x # set flags on interpreter
+ * # NOTE: this doesn't restart
* References:
*/
#include "parrot/parrot.h"
+#include "parrot/embed.h"
pmclass ParrotInterpreter need_ext {
@@ -70,13 +72,9 @@
PARROT_TRACE_FLAG |
PARROT_BOUNDS_FLAG |
PARROT_PROFILE_FLAG |
- PARROT_PREDEREF_FLAG |
- PARROT_JIT_FLAG |
- PARROT_CGOTO_FLAG |
- PARROT_GC_DEBUG_FLAG |
- PARROT_SWITCH_FLAG;
- Interp_flags_CLEAR(new_interp, allowed);
- Interp_flags_SET(new_interp, val & allowed);
+ PARROT_GC_DEBUG_FLAG;
+ Parrot_clear_flag(new_interp, allowed);
+ Parrot_set_flag(new_interp, val & allowed);
break;
}
}
1.17 +1 -0 parrot/config/gen/config_h/config_h.in
Index: config_h.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/config_h/config_h.in,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -r1.16 -r1.17
--- config_h.in 14 Oct 2003 15:47:05 -0000 1.16
+++ config_h.in 15 Oct 2003 08:31:18 -0000 1.17
@@ -111,6 +111,7 @@
#define PARROT_CORE_OPLIB_NAME "core"
#define PARROT_CORE_OPLIB_INIT Parrot_DynOp_core_${MAJOR}_${MINOR}_${PATCH}
#define PARROT_CORE_PREDEREF_OPLIB_INIT
Parrot_DynOp_core_prederef_${MAJOR}_${MINOR}_${PATCH}
+#define PARROT_CORE_SWITCH_OPLIB_INIT
Parrot_DynOp_core_switch_${MAJOR}_${MINOR}_${PATCH}
#define PARROT_CORE_CG_OPLIB_INIT Parrot_DynOp_core_cg_${MAJOR}_${MINOR}_${PATCH}
#define PARROT_CORE_CGP_OPLIB_INIT Parrot_DynOp_core_cgp_${MAJOR}_${MINOR}_${PATCH}
1.330 +4 -3 parrot/core.ops
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.329
retrieving revision 1.330
diff -u -w -r1.329 -r1.330
--- core.ops 14 Oct 2003 15:47:07 -0000 1.329
+++ core.ops 15 Oct 2003 08:31:20 -0000 1.330
@@ -3,6 +3,7 @@
*/
#include "parrot/dynext.h"
+#include "parrot/embed.h"
#include "parrot/interp_guts.h"
VERSION = PARROT_VERSION;
@@ -594,7 +595,7 @@
=cut
inline op bounds(in INT) {
- if ($1 != 0) { Interp_flags_SET(interpreter, PARROT_BOUNDS_FLAG); }
+ if ($1 != 0) { Parrot_set_flag(interpreter, PARROT_BOUNDS_FLAG); }
else { Interp_flags_CLEAR(interpreter, PARROT_BOUNDS_FLAG); }
restart NEXT();
}
@@ -609,7 +610,7 @@
=cut
inline op profile(in INT) {
- if ($1 != 0) { Interp_flags_SET(interpreter, PARROT_PROFILE_FLAG); }
+ if ($1 != 0) { Parrot_set_flag(interpreter, PARROT_PROFILE_FLAG); }
else { Interp_flags_CLEAR(interpreter, PARROT_PROFILE_FLAG); }
restart NEXT();
}
@@ -624,7 +625,7 @@
=cut
inline op trace(in INT) {
- if ($1 != 0) { Interp_flags_SET(interpreter, PARROT_TRACE_FLAG); }
+ if ($1 != 0) { Parrot_set_flag(interpreter, PARROT_TRACE_FLAG); }
else { Interp_flags_CLEAR(interpreter, PARROT_TRACE_FLAG); }
restart NEXT();
}
1.90 +59 -46 parrot/embed.c
Index: embed.c
===================================================================
RCS file: /cvs/public/parrot/embed.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -w -r1.89 -r1.90
--- embed.c 27 Sep 2003 12:48:16 -0000 1.89
+++ embed.c 15 Oct 2003 08:31:20 -0000 1.90
@@ -1,7 +1,7 @@
/* embed.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: embed.c,v 1.89 2003/09/27 12:48:16 leo Exp $
+ * $Id: embed.c,v 1.90 2003/10/15 08:31:20 leo Exp $
* Overview:
* The Parrot embedding interface.
* Data Structure and Algorithms:
@@ -24,6 +24,7 @@
}
extern void Parrot_initialize_core_pmcs(Interp *interp);
+
void
Parrot_init(struct Parrot_Interp *interpreter)
{
@@ -39,17 +40,38 @@
}
void
-Parrot_setflag(struct Parrot_Interp *interpreter, Parrot_Interp_flag flag,
- Parrot_Interp_flag_val value)
+Parrot_set_flag(struct Parrot_Interp *interpreter, Parrot_Interp_flag flag)
{
/* These two macros (from interpreter.h) do exactly what they look like. */
- if (value) {
Interp_flags_SET(interpreter, flag);
+ switch (flag) {
+ case PARROT_BOUNDS_FLAG:
+ case PARROT_PROFILE_FLAG:
+ case PARROT_TRACE_FLAG:
+ Interp_core_SET(interpreter, PARROT_SLOW_CORE);
+ break;
+ default:
+ break;
}
- else {
+}
+
+void
+Parrot_clear_flag(Parrot_Interp interpreter, Parrot_Interp_flag flag)
+{
Interp_flags_CLEAR(interpreter, flag);
}
+
+Parrot_Int
+Parrot_test_flag(Parrot_Interp interpreter, Parrot_Interp_flag flag)
+{
+ return Interp_flags_TEST(interpreter, flag);
+}
+
+void
+Parrot_set_run_core(struct Parrot_Interp *interpreter, Parrot_Run_core_t core)
+{
+ Interp_core_SET(interpreter, core);
}
void
@@ -383,52 +405,43 @@
{
/* Debugging mode nonsense. */
if (Interp_flags_TEST(interpreter, PARROT_DEBUG_FLAG)) {
- PIO_eprintf(interpreter, "*** Parrot VM: Debugging enabled. ***\n");
-
if (Interp_flags_TEST(interpreter, PARROT_BOUNDS_FLAG)) {
PIO_eprintf(interpreter,
"*** Parrot VM: Bounds checking enabled. ***\n");
}
- if (Interp_flags_TEST(interpreter, PARROT_PREDEREF_FLAG)) {
- PIO_eprintf(interpreter,
- "*** Parrot VM: Predereferencing enabled. ***\n");
- }
- if (Interp_flags_TEST(interpreter, PARROT_SWITCH_FLAG)) {
- PIO_eprintf(interpreter,
- "*** Parrot VM: Switched core enabled. ***\n");
- }
- if (Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) {
- PIO_eprintf(interpreter, "*** Parrot VM: JIT enabled. ***\n");
- }
if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) {
PIO_eprintf(interpreter, "*** Parrot VM: Tracing enabled. ***\n");
}
+ PIO_eprintf(interpreter, "*** Parrot VM: ");
+ switch (interpreter->run_core) {
+ case PARROT_SLOW_CORE:
+ PIO_eprintf(interpreter, "Slow core");
+ break;
+ case PARROT_FAST_CORE:
+ PIO_eprintf(interpreter, "Fast core");
+ break;
+ case PARROT_PREDEREF_CORE:
+ PIO_eprintf(interpreter, "Predereferencing core");
+ break;
+ case PARROT_SWITCH_CORE:
+ PIO_eprintf(interpreter, "Switch core");
+ break;
+ case PARROT_CGP_CORE:
+ PIO_eprintf(interpreter, "CGP core");
+ break;
+ case PARROT_CGOTO_CORE:
+ PIO_eprintf(interpreter, "CGoto core");
+ break;
+ case PARROT_JIT_CORE:
+ PIO_eprintf(interpreter, "JIT core");
+ break;
+ case PARROT_EXEC_CORE:
+ PIO_eprintf(interpreter, "EXEC core");
+ break;
}
-
-#if !defined(PARROT_JIT_CAPABLE) || !PARROT_JIT_CAPABLE
-
- /* No JIT here--make sure they didn't ask for it. */
-
- if (Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) {
- PIO_eprintf(interpreter, "Parrot VM: Platform " PARROT_ARCHNAME
- " is not JIT-capable.\n");
- Parrot_exit(1);
- }
-
-#endif
-
-#if !PARROT_EXEC_CAPABLE
-
- /* No EXEC here--make sure they didn't ask for it. */
-
- if (Interp_flags_TEST(interpreter, PARROT_EXEC_FLAG)) {
- PIO_eprintf(interpreter, "Parrot VM: Platform " PARROT_ARCHNAME
- " is not EXEC-capable.\n");
- Parrot_exit(1);
+ PIO_eprintf(interpreter, " ***\n");
}
-#endif
-
/* Set up @ARGS (or whatever this language calls it).
XXX Should this be Array or PerlArray? */
@@ -437,7 +450,7 @@
#if EXEC_CAPABLE
/* s. runops_exec interpreter.c */
- if (Interp_flags_TEST(interpreter, PARROT_EXEC_FLAG)) {
+ if (Interp_core_TEST(interpreter, PARROT_EXEC_CORE)) {
extern int Parrot_exec_run;
Parrot_exec_run = 1;
}
1.37 +5 -3 parrot/exceptions.c
Index: exceptions.c
===================================================================
RCS file: /cvs/public/parrot/exceptions.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -w -r1.36 -r1.37
--- exceptions.c 29 Aug 2003 11:30:17 -0000 1.36
+++ exceptions.c 15 Oct 2003 08:31:20 -0000 1.37
@@ -1,7 +1,7 @@
/* exceptions.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: exceptions.c,v 1.36 2003/08/29 11:30:17 leo Exp $
+ * $Id: exceptions.c,v 1.37 2003/10/15 08:31:20 leo Exp $
* Overview:
* define the internal interpreter exceptions
* Data Structure and Algorithms:
@@ -215,8 +215,10 @@
/* translate an absolute location in byte_code to an offset
* used for resuming after an exception had occured
*/
- switch (interpreter->flags) {
- case PARROT_PREDEREF_FLAG:
+ switch (interpreter->run_core) {
+ case PARROT_PREDEREF_CORE:
+ case PARROT_SWITCH_CORE:
+ case PARROT_CGP_CORE:
offset = (void **)dest - interpreter->prederef_code;
default:
offset = dest - interpreter->code->byte_code;
1.214 +91 -78 parrot/interpreter.c
Index: interpreter.c
===================================================================
RCS file: /cvs/public/parrot/interpreter.c,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -w -r1.213 -r1.214
--- interpreter.c 14 Oct 2003 15:47:07 -0000 1.213
+++ interpreter.c 15 Oct 2003 08:31:20 -0000 1.214
@@ -1,7 +1,7 @@
/* interpreter.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: interpreter.c,v 1.213 2003/10/14 15:47:07 leo Exp $
+ * $Id: interpreter.c,v 1.214 2003/10/15 08:31:20 leo Exp $
* Overview:
* The interpreter api handles running the operations
* Data Structure and Algorithms:
@@ -29,8 +29,6 @@
#define ATEXIT_DESTROY
-#define PARROT_CGP_FLAG (PARROT_PREDEREF_FLAG | PARROT_CGOTO_FLAG)
-
#if EXEC_CAPABLE
struct Parrot_Interp interpre;
#endif
@@ -73,6 +71,7 @@
switch (opinfo->types[i]) {
case PARROT_ARG_OP:
+ if (prederef_op_func)
pc_prederef[i] = (void *)(ptrcast_t)prederef_op_func[arg];
break;
@@ -142,11 +141,14 @@
}
if (pc_prederef[i] == 0) {
+ if (prederef_op_func || i) {
+ /* switched core has no func_table, so a NULL op is ok */
internal_exception(INTERP_ERROR,
"Prederef generated a NULL pointer for arg of type %d!\n",
opinfo->types[i]);
}
}
+ }
return pc_prederef;
}
@@ -168,20 +170,20 @@
for (i = 0; i < N; ) {
is_ret = 0;
switch (which) {
- case PARROT_EXEC_FLAG:
+ case PARROT_EXEC_CORE:
if (*temp)
is_ret = 1;
break;
}
prederef(temp, interpreter);
switch (which) {
- case PARROT_SWITCH_FLAG:
+ case PARROT_SWITCH_CORE:
*temp = (void**) *pc;
break;
- case PARROT_CGP_FLAG:
+ case PARROT_CGP_CORE:
*temp = ((void**)(prederef_op_func)) [*pc];
break;
- case PARROT_EXEC_FLAG:
+ case PARROT_EXEC_CORE:
if (is_ret)
*temp = (void *)(ptrcast_t)prederef_op_func[2];
else
@@ -205,16 +207,22 @@
oplib_init_f init_func = (oplib_init_f)NULL;
if (core_op) {
switch (which) {
- case PARROT_SWITCH_FLAG:
- case PARROT_PREDEREF_FLAG:
+ case PARROT_SWITCH_CORE:
+ init_func = PARROT_CORE_SWITCH_OPLIB_INIT;
+ break;
+ case PARROT_PREDEREF_CORE:
init_func = PARROT_CORE_PREDEREF_OPLIB_INIT;
break;
#ifdef HAVE_COMPUTED_GOTO
- case PARROT_CGP_FLAG:
+ case PARROT_CGP_CORE:
init_func = PARROT_CORE_CGP_OPLIB_INIT;
break;
+ case PARROT_CGOTO_CORE:
+ init_func = PARROT_CORE_CG_OPLIB_INIT;
+ break;
#endif
- case NO_FLAGS: /* normal func core */
+ case PARROT_SLOW_CORE: /* normal func core */
+ case PARROT_FAST_CORE: /* normal func core */
init_func = PARROT_CORE_OPLIB_INIT;
break;
}
@@ -266,7 +274,7 @@
N * sizeof(void *));
#endif
- if (which == PARROT_PREDEREF_FLAG) {
+ if (which == PARROT_PREDEREF_CORE) {
for (i = 0; i < N; i++) {
temp[i] = (void *)(ptrcast_t)prederef;
}
@@ -275,7 +283,7 @@
interpreter->prederef_code = temp;
interpreter->code->cur_cs->prederef_code = temp;
- if (which != PARROT_PREDEREF_FLAG)
+ if (which != PARROT_PREDEREF_CORE)
fill_prederef(interpreter, which, N, temp);
}
}
@@ -303,10 +311,11 @@
void
exec_init_prederef(struct Parrot_Interp *interpreter, void *prederef_arena)
{
- int which = 0;
+ int which = PARROT_PREDEREF_CORE;
#if HAVE_COMPUTED_GOTO
- which = PARROT_CGOTO_FLAG | PARROT_PREDEREF_FLAG;
+ which = PARROT_CGP_CORE;
#endif
+ /* XXX do we need to prederef if no CGP is available */
load_prederef(interpreter, which);
if (!interpreter->prederef_code) {
@@ -318,7 +327,7 @@
interpreter->prederef_code = temp;
interpreter->code->cur_cs->prederef_code = temp;
- fill_prederef(interpreter, PARROT_EXEC_FLAG, N, temp);
+ fill_prederef(interpreter, PARROT_EXEC_CORE, N, temp);
}
}
#endif
@@ -341,7 +350,7 @@
# if defined HAVE_COMPUTED_GOTO && defined USE_CGP
# ifdef __GNUC__
# ifdef PARROT_I386
- init_prederef(interpreter, PARROT_CGP_FLAG);
+ init_prederef(interpreter, PARROT_CGP_CORE);
# endif
# endif
# endif
@@ -357,12 +366,18 @@
void
prepare_for_run(Parrot_Interp interpreter)
{
- if (Interp_flags_TEST(interpreter, PARROT_JIT_FLAG))
+ switch (interpreter->run_core) {
+ case PARROT_JIT_CORE:
(void) init_jit(interpreter, interpreter->code->byte_code);
- else if (Interp_flags_TEST(interpreter, PARROT_SWITCH_FLAG))
- init_prederef(interpreter, PARROT_SWITCH_FLAG);
- else if (Interp_flags_TEST(interpreter, PARROT_PREDEREF_FLAG))
- init_prederef(interpreter, interpreter->flags &PARROT_RUN_CORE_FLAGS);
+ break;
+ case PARROT_PREDEREF_CORE:
+ case PARROT_SWITCH_CORE:
+ case PARROT_CGP_CORE:
+ init_prederef(interpreter, interpreter->run_core);
+ break;
+ default:
+ break;
+ }
}
static opcode_t *
@@ -390,15 +405,15 @@
# if defined HAVE_COMPUTED_GOTO && defined USE_CGP
# ifdef __GNUC__
# ifdef PARROT_I386
- init_prederef(interpreter, PARROT_CGP_FLAG);
+ init_prederef(interpreter, PARROT_CGP_CORE);
# endif
# endif
# endif
if (Parrot_exec_run == 2) {
Parrot_exec_run = 0;
- Interp_flags_CLEAR(interpreter, PARROT_EXEC_FLAG);
+ Interp_core_SET(interpreter, PARROT_JIT_CORE);
runops_jit(interpreter, pc);
- Interp_flags_SET(interpreter, PARROT_EXEC_FLAG);
+ Interp_core_SET(interpreter, PARROT_EXEC_CORE);
}
else if (Parrot_exec_run == 1) {
Parrot_exec(interpreter, pc, code_start, code_end);
@@ -435,7 +450,7 @@
opcode_t *code_start = (opcode_t *)interpreter->code->byte_code;
void **pc_prederef;
- init_prederef(interpreter, PARROT_PREDEREF_FLAG);
+ init_prederef(interpreter, PARROT_PREDEREF_CORE);
pc_prederef = interpreter->prederef_code + (pc - code_start);
while (pc_prederef) {
@@ -454,7 +469,7 @@
#ifdef HAVE_COMPUTED_GOTO
opcode_t *code_start = (opcode_t *)interpreter->code->byte_code;
void **pc_prederef;
- init_prederef(interpreter, PARROT_CGP_FLAG);
+ init_prederef(interpreter, PARROT_CGP_CORE);
pc_prederef = interpreter->prederef_code + (pc - code_start);
pc = cgp_core((opcode_t*)pc_prederef, interpreter);
return pc;
@@ -471,7 +486,7 @@
{
opcode_t *code_start = (opcode_t *)interpreter->code->byte_code;
void **pc_prederef;
- init_prederef(interpreter, PARROT_SWITCH_FLAG);
+ init_prederef(interpreter, PARROT_SWITCH_CORE);
pc_prederef = interpreter->prederef_code + (pc - code_start);
pc = switch_core((opcode_t*)pc_prederef, interpreter);
return pc;
@@ -500,12 +515,9 @@
interpreter->lo_var_ptr = (void *)&lo_var_ptr;
interpreter->resume_offset = 0;
interpreter->resume_flag = 0;
+ switch (interpreter->run_core) {
+ case PARROT_SLOW_CORE:
- slow = Interp_flags_TEST(interpreter, (PARROT_BOUNDS_FLAG |
- PARROT_PROFILE_FLAG |
- PARROT_TRACE_FLAG));
-
- if (slow) {
core = runops_slow_core;
if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
@@ -517,45 +529,46 @@
PARROT_PROF_EXTRA) * sizeof(ProfData));
}
}
- }
- /* CGOTO is set per default, so test other cores first */
- else if (Interp_flags_TEST(interpreter, PARROT_SWITCH_FLAG)) {
- core = runops_switch;
- }
- else if (Interp_flags_TEST(interpreter, PARROT_PREDEREF_FLAG)) {
- if (Interp_flags_TEST(interpreter, PARROT_CGOTO_FLAG))
+ break;
+ case PARROT_FAST_CORE:
+ core = runops_fast_core;
+ break;
+ case PARROT_CGOTO_CORE:
+ core = runops_cgoto_core;
+ /* clear stacktop, it gets set in runops_cgoto_core beyond the
+ * opfunc table again, if the compiler supports nested funcs
+ */
+ /* #ifdef HAVE_NESTED_FUNC */
+#ifdef __GNUC__
+ interpreter->lo_var_ptr = 0;
+#endif
+ break;
+ case PARROT_CGP_CORE:
core = runops_cgp;
- else
+ break;
+ case PARROT_SWITCH_CORE:
+ core = runops_switch;
+ break;
+ case PARROT_PREDEREF_CORE:
core = runops_prederef;
- }
- else if (Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) {
+ break;
+ case PARROT_JIT_CORE:
#if !JIT_CAPABLE
internal_exception(JIT_UNAVAILABLE,
"Error: PARROT_JIT_FLAG is set, "
"but interpreter is not JIT_CAPABLE!\n");
#endif
core = runops_jit;
- }
- else if (Interp_flags_TEST(interpreter, PARROT_EXEC_FLAG)) {
+ break;
+ case PARROT_EXEC_CORE:
#if !EXEC_CAPABLE
internal_exception(EXEC_UNAVAILABLE,
"Error: PARROT_EXEC_FLAG is set, "
"but interpreter is not EXEC_CAPABLE!\n");
#endif
core = runops_exec;
+ break;
}
- else if (Interp_flags_TEST(interpreter, PARROT_CGOTO_FLAG)) {
- core = runops_cgoto_core;
- /* clear stacktop, it gets set in runops_cgoto_core beyond the
- * opfunc table again, if the compiler supports nested funcs
- */
-/* #ifdef HAVE_NESTED_FUNC */
-#ifdef __GNUC__
- interpreter->lo_var_ptr = 0;
-#endif
- }
- else
- core = runops_fast_core;
/* run it finally */
1.75 +2 -2 parrot/jit.c
Index: jit.c
===================================================================
RCS file: /cvs/public/parrot/jit.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -w -r1.74 -r1.75
--- jit.c 13 Oct 2003 13:36:02 -0000 1.74
+++ jit.c 15 Oct 2003 08:31:20 -0000 1.75
@@ -1,7 +1,7 @@
/*
* jit.c
*
- * $Id: jit.c,v 1.74 2003/10/13 13:36:02 dan Exp $
+ * $Id: jit.c,v 1.75 2003/10/15 08:31:20 leo Exp $
*/
#include <parrot/parrot.h>
@@ -788,7 +788,7 @@
reg_addr(struct Parrot_Interp * interpreter, int typ, int i)
{
#ifdef PARROT_I386
- if (Interp_flags_TEST(interpreter, PARROT_EXEC_FLAG))
+ if (Interp_core_TEST(interpreter, PARROT_EXEC_CORE))
switch (typ) {
case 0:
return (char*)
1.21 +6 -3 parrot/include/parrot/embed.h
Index: embed.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/embed.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- embed.h 26 Sep 2003 14:41:53 -0000 1.20
+++ embed.h 15 Oct 2003 08:31:23 -0000 1.21
@@ -1,7 +1,7 @@
/* embed.h
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: embed.h,v 1.20 2003/09/26 14:41:53 leo Exp $
+ * $Id: embed.h,v 1.21 2003/10/15 08:31:23 leo Exp $
* Overview:
* This is the Parrot embedding system--the only part of Parrot that
* the outside world should see.
@@ -20,13 +20,16 @@
#include "parrot/warnings.h" /* give us the warnings flags */
typedef int Parrot_warnclass;
-typedef void *Parrot_Interp_flag_val;
Parrot_Interp Parrot_new(void);
void Parrot_init(Parrot_Interp);
-void Parrot_setflag(Parrot_Interp, Parrot_Interp_flag, Parrot_Interp_flag_val);
+void Parrot_set_flag(Parrot_Interp, Parrot_Interp_flag);
+void Parrot_clear_flag(Parrot_Interp, Parrot_Interp_flag);
+Parrot_Int Parrot_test_flag(Parrot_Interp, Parrot_Interp_flag);
+
+void Parrot_set_run_core( Parrot_Interp, Parrot_Run_core_t core);
void Parrot_setwarnings(Parrot_Interp, Parrot_warnclass);
1.93 +22 -12 parrot/include/parrot/interpreter.h
Index: interpreter.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/interpreter.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -w -r1.92 -r1.93
--- interpreter.h 14 Oct 2003 12:29:15 -0000 1.92
+++ interpreter.h 15 Oct 2003 08:31:23 -0000 1.93
@@ -1,7 +1,7 @@
/* interpreter.h
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: interpreter.h,v 1.92 2003/10/14 12:29:15 leo Exp $
+ * $Id: interpreter.h,v 1.93 2003/10/15 08:31:23 leo Exp $
* Overview:
* The interpreter api handles running the operations
* Data Structure and Algorithms:
@@ -23,19 +23,26 @@
PARROT_TRACE_FLAG = 0x02, /* We're tracing execution */
PARROT_BOUNDS_FLAG = 0x04, /* We're tracking byte code bounds */
PARROT_PROFILE_FLAG = 0x08, /* We're gathering profile information */
- PARROT_PREDEREF_FLAG = 0x10, /* We're using the prederef runops */
- PARROT_JIT_FLAG = 0x20, /* We're using the jit runops */
- PARROT_CGOTO_FLAG = 0x40, /* We're using the computed goto runops */
- PARROT_GC_DEBUG_FLAG = 0x80, /* We're debugging memory management */
+ PARROT_GC_DEBUG_FLAG = 0x10, /* We're debugging memory management */
PARROT_EXTERN_CODE_FLAG = 0x100, /* reusing anothers interps code */
- PARROT_SWITCH_FLAG = 0x200, /* We're using the switched runops */
- PARROT_DESTROY_FLAG = 0x400, /* the last interpreter shall cleanup */
- PARROT_EXEC_FLAG = 0x800, /* We're emiting a native executable */
- PARROT_RUN_CORE_FLAGS= 0x270 /* flags denoting run core */
+ PARROT_DESTROY_FLAG = 0x200 /* the last interpreter shall cleanup */
} Parrot_Interp_flag;
/* &end_gen */
+/* &gen_from_enum(interpcores.pasm) */
+typedef enum {
+ PARROT_SLOW_CORE, /* slow bounds/trace/profile core */
+ PARROT_FAST_CORE, /* fast DO_OP core */
+ PARROT_PREDEREF_CORE, /* P = prederefed */
+ PARROT_SWITCH_CORE, /* P */
+ PARROT_CGP_CORE, /* CP */
+ PARROT_CGOTO_CORE, /* C = cgoto */
+ PARROT_JIT_CORE,
+ PARROT_EXEC_CORE /* TODO Parrot_exec_run variants */
+} Parrot_Run_core_t;
+
+/* &end_gen */
struct Parrot_Interp;
typedef struct Parrot_Interp *Parrot_Interp;
@@ -43,11 +50,15 @@
#if defined(PARROT_IN_CORE)
typedef Parrot_Interp_flag Interp_flags;
+typedef Parrot_Run_core_t Run_Cores;
#define Interp_flags_SET(interp, flag) (/[EMAIL PROTECTED]@*/ (interp)->flags |=
(flag))
#define Interp_flags_CLEAR(interp, flag) (/[EMAIL PROTECTED]@*/ (interp)->flags &=
~(flag))
#define Interp_flags_TEST(interp, flag) (/[EMAIL PROTECTED]@*/ (interp)->flags &
(flag))
+#define Interp_core_SET(interp, core) (/[EMAIL PROTECTED]@*/ (interp)->run_core =
(core))
+#define Interp_core_TEST(interp, core) (/[EMAIL PROTECTED]@*/ (interp)->run_core
== (core))
+
#include "parrot/register.h"
#include "parrot/parrot.h"
#include "parrot/warnings.h"
@@ -137,9 +148,8 @@
str_func_t *string_funcs;
#endif
- Interp_flags flags; /* Various interpreter flags that
- * signal that runops should do
- * something */
+ Interp_flags flags; /* Various interpreter flags that */
+ Run_Cores run_core; /* type of core to run the ops */
RunProfile *profile; /* The structure and array where we keep the
* profile counters */
1.55 +60 -41 parrot/languages/imcc/main.c
Index: main.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/main.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -w -r1.54 -r1.55
--- main.c 13 Oct 2003 07:54:46 -0000 1.54
+++ main.c 15 Oct 2003 08:31:29 -0000 1.55
@@ -29,7 +29,7 @@
static void usage(FILE* fp)
{
fprintf(fp,
- "parrot -[abcgGhjpPrStvVwy.] [-d [FLAGS]] [-O [level]] [-o FILE] <file>\n");
+ "parrot -[abcCEfgGhjpPrStvVwy.] [-d [FLAGS]] [-O [level]] [-o FILE] <file>\n");
}
static void help_debug(void)
@@ -56,14 +56,17 @@
" Options:\n"
" -h --help\n"
" -V --version\n"
- " <VM options>\n"
- " -b --bounds-checks\n"
- " -j --jit\n"
+ " <Run core options>\n"
+ " -b --bounds-checks|--slow-core\n"
+ " -C --CGP-core\n"
+ " -f --fast-core\n"
+ " -g --computed-goto-core\n"
+ " -j --jit-core\n"
" -p --profile\n"
" -P --predereferenced-core\n"
" -S --switched-core\n"
- " -g --no-computed-goto\n"
" -t --trace\n"
+ " <VM options>\n"
" -d --debug[=HEXFLAGS]\n"
" --help-debug\n"
" -w --warnings\n"
@@ -103,8 +106,8 @@
Parrot_exit(0);
}
-#define setopt(flag) Parrot_setflag(interp, flag, (*argv)[0]+2)
-#define unsetopt(flag) Parrot_setflag(interp, flag, 0)
+#define setopt(flag) Parrot_set_flag(interp, flag)
+#define setcore(core) Parrot_set_run_core(interp, core)
#define OPT_GC_DEBUG 128
#define OPT_DESTROY_FLAG 129
@@ -112,6 +115,7 @@
#define OPT_PBC_OUTPUT 131
static struct longopt_opt_decl options[] = {
{ '.', '.', 0, { "--wait" } },
+ { 'C', 'C', 0, { "--CGP-core" } },
{ 'E', 'E', 0, { "--pre-precess-only" } },
{ 'G', 'G', 0, { "--no-gc" } },
{ 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
@@ -121,13 +125,14 @@
{ '\0', OPT_DESTROY_FLAG, 0, { "--leak-test", "--destroy-at-end" } },
{ '\0', OPT_GC_DEBUG, 0, { "--gc-debug" } },
{ 'a', 'a', 0, { "--pasm" } },
- { 'b', 'b', 0, { "--bounds-checks" } },
+ { 'b', 'b', 0, { "--bounds-checks", "--slow-core" } },
{ 'c', 'c', 0, { "--pbc" } },
{ 'd', 'd', OPTION_optional_FLAG, { "--debug" } },
{ '\0', OPT_HELP_DEBUG, 0, { "--help-debug" } },
- { 'g', 'g', 0, { "--no-computed-goto" } },
+ { 'f', 'f', 0, { "--fast-core" } },
+ { 'g', 'g', 0, { "--computed-goto-core" } },
{ 'h', 'h', 0, { "--help" } },
- { 'j', 'j', 0, { "--jit" } },
+ { 'j', 'j', 0, { "--jit-core" } },
{ 'o', 'o', OPTION_required_FLAG, { "--output" } },
{ '\0', OPT_PBC_OUTPUT, 0, { "--output-pbc" } },
{ 'p', 'p', 0, { "--profile" } },
@@ -151,32 +156,34 @@
}
run_pbc = 1;
-#ifdef HAVE_COMPUTED_GOTO
- setopt(PARROT_CGOTO_FLAG);
-#endif
-
while ((status = longopt_get(interp, *argc, *argv, options, &opt)) > 0) {
switch (opt.opt_id) {
case 'b':
setopt(PARROT_BOUNDS_FLAG);
break;
- case 'j':
- setopt(PARROT_JIT_FLAG);
- break;
case 'p':
setopt(PARROT_PROFILE_FLAG);
break;
+ case 't':
+ setopt(PARROT_TRACE_FLAG);
+ break;
+ case 'j':
+ setcore(PARROT_JIT_CORE);
+ break;
case 'P':
- setopt(PARROT_PREDEREF_FLAG);
+ setcore(PARROT_PREDEREF_CORE);
break;
case 'S':
- setopt(PARROT_SWITCH_FLAG);
+ setcore(PARROT_SWITCH_CORE);
break;
- case 'g':
- unsetopt(PARROT_CGOTO_FLAG);
+ case 'C':
+ setcore(PARROT_CGP_CORE);
break;
- case 't':
- setopt(PARROT_TRACE_FLAG);
+ case 'f':
+ setcore(PARROT_FAST_CORE);
+ break;
+ case 'g':
+ setcore(PARROT_CGOTO_CORE);
break;
case 'd':
if (opt.opt_arg) {
@@ -247,12 +254,10 @@
else {
strcpy(optimizer_opt, "1");
}
- if (strchr(optimizer_opt, '1'))
- optimizer_level |= OPT_PRE;
+ if (strchr(optimizer_opt, 'p'))
+ optimizer_level |= OPT_PASM;
if (strchr(optimizer_opt, 'c'))
optimizer_level |= OPT_SUB;
- if (strchr(optimizer_opt, '2'))
- optimizer_level |= (OPT_CFG | OPT_PRE);
#if 0
/* currently not ok due to different register allocation */
if (strchr(optimizer_opt, 'j')) {
@@ -261,9 +266,21 @@
Parrot_setflag(interp, PARROT_JIT_FLAG, &one);
}
#endif
- if (strchr(optimizer_opt, 'p'))
- optimizer_level |= OPT_PASM;
-
+ if (strchr(optimizer_opt, '1')) {
+ optimizer_level |= OPT_PRE;
+ goto opt_t;
+ }
+ if (strchr(optimizer_opt, '2')) {
+ optimizer_level |= (OPT_CFG | OPT_PRE);
+ goto opt_t;
+ }
+ if (strchr(optimizer_opt, 't')) {
+opt_t:
+ setcore(PARROT_SWITCH_CORE);
+#ifdef HAVE_COMPUTED_GOTO
+ setcore(PARROT_CGP_CORE);
+#endif
+ }
break;
case OPT_GC_DEBUG:
@@ -280,7 +297,7 @@
default:
fatal(1, "main", "Invalid flag '%s' used."
- "\n\nhelp: imcc -h\n", (*argv)[0]);
+ "\n\nhelp: parrot -h\n", (*argv)[0]);
}
}
if (status == -1) {
@@ -429,16 +446,18 @@
if (ext && strcmp (ext, ".pbc") == 0) {
write_pbc = 1;
}
-#if EXEC_CAPABLE
else if (ext && strcmp (ext, ".o") == 0) {
+#if EXEC_CAPABLE
load_pbc = 1;
write_pbc = 0;
run_pbc = 1;
obj_file = 1;
Parrot_setup_opt(interpreter, 0, output);
- Parrot_setflag(interpreter, PARROT_EXEC_FLAG, ext);
- }
+ Parrot_set_run_core(interpreter, PARROT_EXEC_CORE);
+#else
+ fatal(1, "main", "can't produce object file");
#endif
+ }
if (!strcmp(sourcefile, output) && strcmp(sourcefile, "-"))
fatal(1, "main", "outputfile is sourcefile\n");
}