cvsuser 03/11/01 08:33:29
Modified: classes compiler.pmc sub.pmc
docs/pmc subs.pod
imcc/t/syn bsr.t
ops core.ops ops.num
t/pmc coroutine.t sub.t
Log:
use pointer vtables for passing Sub address
* new get_addr opcode
* update tests and pod
Revision Changes Path
1.15 +2 -3 parrot/classes/compiler.pmc
Index: compiler.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/compiler.pmc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -r1.14 -r1.15
--- compiler.pmc 22 Sep 2003 19:27:37 -0000 1.14
+++ compiler.pmc 1 Nov 2003 16:33:20 -0000 1.15
@@ -1,7 +1,7 @@
/* Compiler.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: compiler.pmc,v 1.14 2003/09/22 19:27:37 dan Exp $
+ * $Id: compiler.pmc,v 1.15 2003/11/01 16:33:20 leo Exp $
* Overview:
* The vtable functions for implementing assembler/compilers
* Data Structure and Algorithms:
@@ -47,8 +47,7 @@
/* morph the Byte_cointer *pointer in code_seg to an invokable sub */
code_seg->vtable = Parrot_base_vtables[enum_class_Eval];
VTABLE_init(interpreter, code_seg);
- VTABLE_set_integer_native(interpreter, code_seg,
- (INTVAL) eval_pf);
+ VTABLE_set_pointer(interpreter, code_seg, (void*) eval_pf);
return code_seg;
}
}
1.29 +5 -9 parrot/classes/sub.pmc
Index: sub.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/sub.pmc,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -w -r1.28 -r1.29
--- sub.pmc 25 Oct 2003 07:43:54 -0000 1.28
+++ sub.pmc 1 Nov 2003 16:33:20 -0000 1.29
@@ -1,7 +1,7 @@
/* Sub.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: sub.pmc,v 1.28 2003/10/25 07:43:54 leo Exp $
+ * $Id: sub.pmc,v 1.29 2003/11/01 16:33:20 leo Exp $
* Overview:
* These are the vtable functions for the Sub (subroutine) base class
* Data Structure and Algorithms:
@@ -34,16 +34,12 @@
pobject_lives(INTERP, sub->ctx.warns);
}
- void set_integer (PMC * value) {
- SELF->cache.struct_val = (void *)VTABLE_get_integer(INTERP, value);
+ void set_pointer (void* value) {
+ SELF->cache.struct_val = value;
}
- void set_integer_native (INTVAL value) {
- SELF->cache.struct_val = (void *)value;
- }
-
- INTVAL get_integer () {
- return (INTVAL) SELF->cache.struct_val;
+ void* get_pointer () {
+ return SELF->cache.struct_val;
}
/* This just unconditionally returns the start of bytecode. It's
1.9 +2 -3 parrot/docs/pmc/subs.pod
Index: subs.pod
===================================================================
RCS file: /cvs/public/parrot/docs/pmc/subs.pod,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- subs.pod 23 Oct 2003 02:06:28 -0000 1.8
+++ subs.pod 1 Nov 2003 16:33:23 -0000 1.9
@@ -42,8 +42,7 @@
Create a subroutine of class C<Sub> and assign the subroutine address to it:
new P0, .Sub
- set_addr I0, _sub_label
- set P0, I0
+ set_addr P0, _sub_label
This can be done with one opcode:
@@ -132,7 +131,7 @@
.pcc_sub _the::sub:
print "in sub\n" # must preserve P1
find_global P0, "_next::sub"
- set I0, P0 # get the absolute address
+ get_addr I0, P0 # get the absolute address
jump I0 # jump to absolute address
.pcc_sub _next::sub: # must preserve P1
1.16 +2 -4 parrot/imcc/t/syn/bsr.t
Index: bsr.t
===================================================================
RCS file: /cvs/public/parrot/imcc/t/syn/bsr.t,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- bsr.t 23 Oct 2003 17:03:01 -0000 1.15
+++ bsr.t 1 Nov 2003 16:33:24 -0000 1.16
@@ -234,8 +234,7 @@
I6 = 5 # count
I5 = 1 # product
P0 = new Sub
- $I0 = addr _fact
- set P0, $I0
+ P0 = addr _fact
saveall
invokecc
save I5
@@ -266,8 +265,7 @@
.sub _main
.local Coroutine co
co = new Coroutine
- $I0 = addr _routine
- co = $I0
+ co = addr _routine
print "Hello"
invoke co
print "perl6"
1.338 +17 -9 parrot/ops/core.ops
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/ops/core.ops,v
retrieving revision 1.337
retrieving revision 1.338
diff -u -w -r1.337 -r1.338
--- core.ops 28 Oct 2003 11:00:36 -0000 1.337
+++ core.ops 1 Nov 2003 16:33:26 -0000 1.338
@@ -451,14 +451,18 @@
########################################
-=item B<set_addr>(out INT, in INT)
+=item B<set_addr>(out INT, inconst INT)
Sets register $1 to the current address plus the offset $2.
-=item B<set_addr>(in PMC, in INT)
+=item B<set_addr>(in PMC, inconst INT)
Sets PMC in register $1 to the current address plus the offset $2.
+=item B<get_addr>(out INT, in PMC)
+
+Sets $1 to the absolute address of the Sub-PMC $2.
+
=cut
inline op set_addr(out INT, inconst INT) {
@@ -467,7 +471,12 @@
}
inline op set_addr(in PMC, inconst INT) {
- $1->vtable->set_integer_native(interpreter, $1, PTR2OPCODE_T(CUR_OPCODE + $2));
+ $1->vtable->set_pointer(interpreter, $1, (CUR_OPCODE + $2));
+ goto NEXT();
+}
+
+inline op get_addr(out INT, in PMC) {
+ $1 = (INTVAL)$2->vtable->get_pointer(interpreter, $2);
goto NEXT();
}
@@ -489,8 +498,7 @@
}
$1 = pmc_new_noinit(interpreter, $2);
$1->vtable->init(interpreter, $1);
- VTABLE_set_integer_native(interpreter, $1,
- PTR2OPCODE_T(CUR_OPCODE + $3));
+ VTABLE_set_pointer(interpreter, $1, (CUR_OPCODE + $3));
goto NEXT();
}
@@ -505,12 +513,12 @@
}
interpreter->pmc_reg.registers[0] = pmc_new_noinit(interpreter, $1);
VTABLE_init(interpreter, interpreter->pmc_reg.registers[0]);
- VTABLE_set_integer_native(interpreter, interpreter->pmc_reg.registers[0],
- PTR2OPCODE_T(CUR_OPCODE + $3));
+ VTABLE_set_pointer(interpreter, interpreter->pmc_reg.registers[0],
+ (CUR_OPCODE + $3));
interpreter->pmc_reg.registers[1] = pmc_new_noinit(interpreter, $2);
VTABLE_init(interpreter, interpreter->pmc_reg.registers[1]);
- VTABLE_set_integer_native(interpreter, interpreter->pmc_reg.registers[1],
- PTR2OPCODE_T(CUR_OPCODE + $4));
+ VTABLE_set_pointer(interpreter, interpreter->pmc_reg.registers[1],
+ (CUR_OPCODE + $4));
goto NEXT();
}
1.11 +1 -0 parrot/ops/ops.num
Index: ops.num
===================================================================
RCS file: /cvs/public/parrot/ops/ops.num,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- ops.num 31 Oct 2003 15:16:41 -0000 1.10
+++ ops.num 1 Nov 2003 16:33:26 -0000 1.11
@@ -1274,3 +1274,4 @@
seti_ind_ic_i 1247
seti_ind_i_ic 1248
seti_ind_ic_ic 1249
+get_addr_i_p 1250
1.3 +8 -15 parrot/t/pmc/coroutine.t
Index: coroutine.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/coroutine.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- coroutine.t 26 Oct 2003 18:22:13 -0000 1.2
+++ coroutine.t 1 Nov 2003 16:33:28 -0000 1.3
@@ -5,8 +5,7 @@
output_is(<<'CODE', <<'OUTPUT', "Coroutines");
new P0, .Coroutine
- set_addr I0, co2
- set P0, I0
+ set_addr P0, co2
co1:
set I1, 4
print "start 1\n"
@@ -21,8 +20,7 @@
co2:
print "start 2\n"
new P5, .Coroutine
- set_addr I0, co3
- set P5, I0
+ set_addr P5, co3
set P6, P0
co2_loop:
invoke
@@ -36,8 +34,7 @@
co3:
print "start 3\n"
new P7, .Coroutine
- set_addr I0, co2_loop
- set P7, I0
+ set_addr P7, co2_loop
set P8, P0
co3_loop:
invoke
@@ -82,12 +79,10 @@
store_lex -2, "b", P21
new P1, .Coroutine
- set_addr I0, co1
- set P1, I0
+ set_addr P1, co1
new P2, .Coroutine
- set_addr I0, co2
- set P2, I0
+ set_addr P2, co2
set P0, P1
invoke
@@ -176,12 +171,10 @@
output_is(<<'CODE', <<'OUTPUT', "Coroutines and registers");
new P1, .Coroutine
- set_addr I0, co1
- set P1, I0
+ set_addr P1, co1
new P2, .Coroutine
- set_addr I0, co2
- set P2, I0
+ set_addr P2, co2
set P0, P1
1.30 +3 -3 parrot/t/pmc/sub.t
Index: sub.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/sub.t,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -w -r1.29 -r1.30
--- sub.t 27 Oct 2003 06:49:08 -0000 1.29
+++ sub.t 1 Nov 2003 16:33:28 -0000 1.30
@@ -465,7 +465,7 @@
.pcc_sub _the_sub:
print "in sub\n"
find_global P0, "_next_sub"
- set I0, P0
+ get_addr I0, P0
jump I0
print "never here\n"