Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

borrow Regs struct from parrot, break M0 test now

  • Loading branch information...
commit 3c62ec93858f9708018d35ff5f19cb7be034c401 1 parent 076d7e6
Jimmy Zhuo authored
2  docs/pdds/draft/pdd32_m0.pod
View
@@ -175,7 +175,7 @@ of M0 ops.
In descriptions, C<$1> refers to the value of the first argument to an op,
C<$2> to the second and C<$3> to the third. Any op can operate on any
-register; types are only by convention. As far as an M0 VM is conerned, the
+register; types are only by convention. As far as an M0 VM is concerned, the
256 ops are nothing more than an array of 256 int32-sized chunks of data.
Note that this documentation uses a C-like syntax to differentiate between a
14 src/m0/c/include/m0_interp_structures.h
View
@@ -13,8 +13,20 @@ typedef struct {
M0_Chunk *last_chunk;
} M0_Interp;
+typedef union {
+ void *p[128];
+ char *s[128];
+} Regs_ps;
+
+typedef union {
+ double n[128];
+ long i[128];
+} Regs_ni;
+
typedef struct {
- uint64_t registers[256];
+ uint64_t registers[12];
+ Regs_ni regs_ni;
+ Regs_ps regs_ps;
} M0_CallFrame;
enum CF_NAMED_REGS {
35 src/m0/c/m0_ops.c
View
@@ -14,7 +14,7 @@ Copyright (C) 2011-2012, Parrot Foundation.
static void
m0_op_set_imm( M0_CallFrame *frame, const unsigned char *ops )
{
- frame->registers[ops[1]] = ops[2] * 256 + ops[3];
+ frame->regs_ni.i[ops[1]] = ops[2] * 256 + ops[3];
}
static void
@@ -23,15 +23,16 @@ m0_op_deref( M0_CallFrame *frame, const unsigned char *ops )
unsigned char ref = ops[2];
switch (ref) {
- case CONSTS:
+ case CONST:
{
M0_Constants_Segment *consts =
(M0_Constants_Segment *)frame->registers[ ref ];
unsigned long offset = frame->registers[ ops[3] ];
- frame->registers[ ops[1] ] = (uint64_t)consts->consts[ offset ];
+ frame->regs_ni.n[ ops[1] ] = (uint64_t)consts->consts[ offset ];
break;
}
+
default:
/* XXX: the rest of the system has non-uniform array handling */
break;
@@ -49,50 +50,42 @@ static void
m0_op_print_i( M0_CallFrame *frame, const unsigned char *ops )
{
/* note the lack of filehandle selection (ops[1]) for output */
- fprintf( stdout, "%d", *(int *)frame->registers[ ops[2] ] );
+ fprintf( stdout, "%d", frame->regs_ni.i[ ops[2] ] );
}
static void
m0_op_print_n( M0_CallFrame *frame, const unsigned char *ops )
{
/* note the lack of filehandle selection (ops[1]) for output */
- fprintf( stdout, "%.15g", *(double *)frame->registers[ ops[2] ] );
+ fprintf( stdout, "%.15g", frame->regs_ni.n[ ops[2] ] );
}
static void
m0_op_add_i( M0_CallFrame *frame, const unsigned char *ops )
{
- const uint64_t result = *(uint64_t *) frame->registers[ops[2]] +
- *(uint64_t *)frame->registers[ops[3]];
-
- frame->registers[ops[1]] = &result;
+ frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] +
+ frame->regs_ni.i[ops[3]];
}
static void
m0_op_add_n( M0_CallFrame *frame, const unsigned char *ops )
{
- const double result = *(double *) frame->registers[ops[2]] +
- *(double *)frame->registers[ops[3]];
-
- frame->registers[ops[1]] = &result;
+ frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] +
+ frame->regs_ni.n[ops[3]];
}
static void
m0_op_sub_i( M0_CallFrame *frame, const unsigned char *ops )
{
- const uint64_t result = *(uint64_t *) frame->registers[ops[2]] +
- *(uint64_t *)frame->registers[ops[3]];
-
- frame->registers[ops[1]] = &result;
+ frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] -
+ frame->regs_ni.i[ops[3]];
}
static void
m0_op_sub_n( M0_CallFrame *frame, const unsigned char *ops )
{
- const double result = *(double *) frame->registers[ops[2]] -
- *(double *)frame->registers[ops[3]];
-
- frame->registers[ops[1]] = &result;
+ frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] -
+ frame->regs_ni.n[ops[3]];
}
static void
Please sign in to comment.
Something went wrong with that request. Please try again.