cvsuser 03/10/14 08:47:09
Modified: config/gen/config_h config_h.in
. core.ops interpreter.c ops2c.pl
dynoplibs test.pasm
Log:
dynamic oplibs - cgoto core
Revision Changes Path
1.16 +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.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- config_h.in 13 Aug 2003 12:52:49 -0000 1.15
+++ config_h.in 14 Oct 2003 15:47:05 -0000 1.16
@@ -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_CG_OPLIB_INIT Parrot_DynOp_core_cg_${MAJOR}_${MINOR}_${PATCH}
#define PARROT_CORE_CGP_OPLIB_INIT Parrot_DynOp_core_cgp_${MAJOR}_${MINOR}_${PATCH}
#define INTVAL_FMT "${intvalfmt}"
1.329 +10 -4 parrot/core.ops
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.328
retrieving revision 1.329
diff -u -w -r1.328 -r1.329
--- core.ops 10 Oct 2003 07:18:29 -0000 1.328
+++ core.ops 14 Oct 2003 15:47:07 -0000 1.329
@@ -3,6 +3,8 @@
*/
#include "parrot/dynext.h"
+#include "parrot/interp_guts.h"
+
VERSION = PARROT_VERSION;
=head1 NAME
@@ -72,9 +74,11 @@
Note: Do B<not> use this opcode. It is for internal use only.
(Must be op #4).
-=item B<load_opcode_lib>(in STR)
+=item B<wrapper__>()
-TODO: Load the opcode library $1.
+Internal opcode to wrap unknown ops from loaded opcode libs.
+Don't use.
+(Must be op #5).
=item B<load_bytecode>(in STR)
@@ -108,8 +112,10 @@
goto ADDRESS(this); /* force this being a branch op */
}
-inline op load_opcode_lib(in STR) {
- goto NEXT();
+inline op wrapper__() {
+ opcode_t *pc = CUR_OPCODE;
+ DO_OP(pc, interpreter);
+ goto ADDRESS(pc);
}
inline op reserved(in INT) {
1.213 +40 -1 parrot/interpreter.c
Index: interpreter.c
===================================================================
RCS file: /cvs/public/parrot/interpreter.c,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -w -r1.212 -r1.213
--- interpreter.c 14 Oct 2003 12:29:09 -0000 1.212
+++ interpreter.c 14 Oct 2003 15:47:07 -0000 1.213
@@ -1,7 +1,7 @@
/* interpreter.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: interpreter.c,v 1.212 2003/10/14 12:29:09 leo Exp $
+ * $Id: interpreter.c,v 1.213 2003/10/14 15:47:07 leo Exp $
* Overview:
* The interpreter api handles running the operations
* Data Structure and Algorithms:
@@ -1057,6 +1057,9 @@
/*
* dynamic loading stuff
*/
+#if defined HAVE_COMPUTED_GOTO
+static void dynop_register_cg(Parrot_Interp, PMC*, op_lib_t *, op_lib_t *);
+#endif
/*=for api interpreter dynop_register
*
@@ -1107,7 +1110,43 @@
core->op_info_table = interpreter->op_info_table = new_info_table;
core->op_count = interpreter->op_count = n_old + n_new;
/* done for plain core */
+#if defined HAVE_COMPUTED_GOTO
+ dynop_register_cg(interpreter, lib_pmc, lib, core);
+#endif
+}
+
+#if defined HAVE_COMPUTED_GOTO
+/*
+ * register op_lib with CGOTO core
+ */
+static void
+dynop_register_cg(Parrot_Interp interpreter, PMC* lib_pmc,
+ op_lib_t *lib, op_lib_t *core)
+{
+ op_lib_t *cg_lib;
+ void **ops_addr;
+ size_t i, n_old, n_new;
+
+ n_new = lib->op_count;
+ n_old = core->op_count;
+
+ cg_lib = PARROT_CORE_CG_OPLIB_INIT(1);
+ /* TODO check if the lib_pmc exists with a _cg flavor */
+
+ /* if not install wrappers */
+ ops_addr = mem_sys_allocate(n_old * sizeof(void *));
+ n_old -= n_new;
+ for (i = 0; i < n_old; ++i)
+ ops_addr[i] = ((void **)cg_lib->op_func_table)[i];
+ /* fill new entries with the wrapper op */
+ for (i = n_old; i < n_old + n_new; ++i)
+ ops_addr[i] = ((void **)cg_lib->op_func_table)[5];
+ /*
+ * tell the cg_core about the new jump table
+ */
+ PARROT_CORE_CG_OPLIB_INIT((int) ops_addr);
}
+#endif
/*
* Local variables:
1.52 +17 -6 parrot/ops2c.pl
Index: ops2c.pl
===================================================================
RCS file: /cvs/public/parrot/ops2c.pl,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -w -r1.51 -r1.52
--- ops2c.pl 14 Oct 2003 12:29:09 -0000 1.51
+++ ops2c.pl 14 Oct 2003 15:47:07 -0000 1.52
@@ -5,7 +5,7 @@
# Generate a C header and source file from the operation definitions in
# an .ops file, using a supplied transform.
#
-# $Id: ops2c.pl,v 1.51 2003/10/14 12:29:09 leo Exp $
+# $Id: ops2c.pl,v 1.52 2003/10/14 15:47:07 leo Exp $
#
use strict;
@@ -166,6 +166,8 @@
if ($suffix =~ /cg/) {
print SOURCE <<END_C;
+static void **ops_addr;
+
opcode_t *
$cg_func$base(opcode_t *cur_op, struct Parrot_Interp *interpreter)
{
@@ -175,7 +177,7 @@
opcode_t *cur_opcode = cur_op;
#endif
- static void *ops_addr[] = {
+ static void *l_ops_addr[] = {
END_C
} elsif ($suffix =~ /switch/) {
@@ -294,13 +296,17 @@
}
#endif
/* #endif */
+
+ if (!ops_addr)
+ ops_addr = l_ops_addr;
+ if (cur_opcode == 0) {
+ return (opcode_t *)ops_addr ;
+ }
END_C
}
if ($suffix =~ /cgp/) {
print SOURCE <<END_C;
- if (cur_opcode == 0)
- return (opcode_t *)ops_addr;
#ifdef __GNUC__
# ifdef I386
else if (cur_opcode == (opcode_t *) 1)
@@ -586,9 +592,14 @@
if (init) {
END_C
-if ($suffix =~ /cgp/) {
+if ($suffix =~ /cg/) {
print SOURCE <<END_C;
- op_lib.op_func_table = (op_func_t *) cgp_$base(0, 0);
+ if (init == 1) {
+ if (!op_lib.op_func_table)
+ op_lib.op_func_table = (op_func_t *) $cg_func$base(0, 0);
+ }
+ else
+ ops_addr = (void**) init;
END_C
}
1.3 +1 -1 parrot/dynoplibs/test.pasm
Index: test.pasm
===================================================================
RCS file: /cvs/public/parrot/dynoplibs/test.pasm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- test.pasm 14 Oct 2003 12:29:13 -0000 1.2
+++ test.pasm 14 Oct 2003 15:47:09 -0000 1.3
@@ -1,4 +1,4 @@
- bounds 1 # be sure we run with plain func core
+ #bounds 1 # be sure we run with plain func core
.include "iglobals.pasm"
print "in test\n"
loadlib P1, "myops_ops"