Skip to content
Browse files

Add a simple placeholder implementation for the gc_alloc op

This op is required for the poke_caller test.
  • Loading branch information...
1 parent 092a2c0 commit c1973c061fa76b53d78d5e46d9eb76d615e8c2fd @nbrown nbrown committed Apr 5, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/m0/c/m0_ops.c
View
12 src/m0/c/m0_ops.c
@@ -287,6 +287,13 @@ m0_op_get_word( M0_CallFrame *frame, const unsigned char *ops )
memcpy(target, &src[offset * 4], 4*sizeof(char));
}
+static void
+m0_op_gc_alloc( M0_CallFrame *frame, const unsigned char *ops )
+{
+ const int bytes = frame->registers[ops[2]];
+ void *ptr = malloc( sizeof(char) * bytes );
+ frame->registers[ops[1]] = (uint64_t) ptr;
+}
int
run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
@@ -420,6 +427,7 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
case (M0_GET_WORD):
m0_op_get_word( cf, &ops[pc] );
break;
+
case (M0_ITON):
m0_op_convert_i_n( cf, &ops[pc] );
break;
@@ -428,6 +436,10 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
m0_op_convert_n_i( cf, &ops[pc] );
break;
+ case (M0_GC_ALLOC):
+ m0_op_gc_alloc( cf, &ops[pc]);
+ break;
+
case (M0_EXIT):
m0_op_exit( interp, cf, &ops[pc]);
break;

0 comments on commit c1973c0

Please sign in to comment.
Something went wrong with that request. Please try again.