RPA Toolkit
work on defining this pointer usage
authorMartin Stoilov <martin@rpasearch.com>
Fri, 28 Jan 2011 06:06:38 +0000 (22:06 -0800)
committerMartin Stoilov <martin@rpasearch.com>
Fri, 28 Jan 2011 06:06:38 +0000 (22:06 -0800)
rvm/rvmcpu.c
rvm/rvmcpu.h
tests/rpagen-test.c

index 7e9a1dc..0369cf6 100644 (file)
@@ -149,6 +149,8 @@ static const char *stropcalls[] = {
        "RVM_OBJLKUP",
        "RVM_OBJADD",
        "RVM_OBJLKUPADD",
+       "RVM_PROPSET",
+       "RVM_PROPGET",
        "UNKNOWN",
        "UNKNOWN",
        "UNKNOWN",
@@ -399,6 +401,24 @@ static void rvm_op_strr(rvmcpu_t *cpu, rvm_asmins_t *ins)
 }
 
 
+static void rvm_op_propset(rvmcpu_t *cpu, rvm_asmins_t *ins)
+{
+       rvmreg_t *src = RVM_CPUREG_PTR(cpu, ins->op1);
+       rlong index = RVM_CPUREG_GETU(cpu, ins->op2);
+
+       r_carray_replace(cpu->prop, index, src);
+}
+
+
+static void rvm_op_propget(rvmcpu_t *cpu, rvm_asmins_t *ins)
+{
+       rvmreg_t *dest = RVM_CPUREG_PTR(cpu, ins->op1);
+       rlong index = RVM_CPUREG_GETU(cpu, ins->op2);
+
+       *dest = r_carray_index(cpu->prop, index, rvmreg_t);
+}
+
+
 static void rvm_op_adds(rvmcpu_t *cpu, rvm_asmins_t *ins)
 {
        rword res, op2 = RVM_CPUREG_GETU(cpu, ins->op2), op3 = RVM_CPUREG_GETU(cpu, ins->op3);
@@ -1773,6 +1793,8 @@ static rvm_cpu_op ops[] = {
        rvm_op_objlookup,       // RVM_OBJLKUP,
        rvm_op_objkeyadd,       // RVM_OBJADD,
        rvm_op_objkeylookupadd, // RVM_OBJLKUPADD,
+       rvm_op_propset,         // RVM_PROPSET
+       rvm_op_propget,         // RVM_PROPGET
        (void*) 0,
        (void*) 0,
        (void*) 0,
@@ -1797,6 +1819,7 @@ rvmcpu_t *rvm_cpu_create(rulong stacksize)
        cpu->switables = r_array_create(sizeof(rvm_switable_t*));
        cpu->stack = r_malloc(stacksize * sizeof(rvmreg_t));
        cpu->data = r_carray_create(sizeof(rvmreg_t));
+       cpu->prop = r_carray_create(sizeof(rvmreg_t));
        cpu->opmap = rvm_opmap_create();
        cpu->gc = rvm_gc_create();
        rvm_op_binary_init(cpu->opmap);
@@ -1821,6 +1844,7 @@ void rvm_cpu_destroy(rvmcpu_t *cpu)
        r_object_destroy((robject_t*)cpu->switables);
        r_free(cpu->stack);
        r_object_destroy((robject_t*)cpu->data);
+       r_object_destroy((robject_t*)cpu->prop);
        rvm_opmap_destroy(cpu->opmap);
        r_free(cpu);
 }
index 217e5c2..923ac56 100644 (file)
@@ -151,6 +151,8 @@ enum {
        RVM_OBJLKUP,
        RVM_OBJADD,
        RVM_OBJLKUPADD,
+       RVM_PROPSET,
+       RVM_PROPGET,
 };
 
 
@@ -301,6 +303,7 @@ struct rvmcpu_s {
        rulong stacksize;
        void *stack;
        rcarray_t *data;
+       rcarray_t *prop;
        struct rvm_opmap_s *opmap;
        void *userdata;
        rvm_gc_t *gc;
index 7a4b817..fd3bc31 100644 (file)
@@ -644,6 +644,10 @@ int codegen_program_callback(rpa_stat_handle stat, const char *name, void *userd
                rvm_costat_pushroot(co);
                rvm_codegen_addins(co->cg, rvm_asm(RVM_NOP, XX, XX, XX, 0));
                rvm_codegen_addins(co->cg, rvm_asm(RVM_NOP, XX, XX, XX, 0));
+               rvm_codegen_addins(co->cg, rvm_asm(RVM_ALLOCOBJ, R0, DA, XX, 0));
+               rvm_codegen_addins(co->cg, rvm_asm(RVM_PROPSET, R0, DA, XX, 0));
+               rvm_codegen_addins(co->cg, rvm_asm(RVM_PROPGET, TP, DA, XX, 0));
+
        } else {
                rvm_codegen_replaceins(co->cg, 0, rvm_asm(RVM_MOV, FP, SP, XX, 0));
                rvm_codegen_replaceins(co->cg, 1, rvm_asm(RVM_ADD, SP, SP, DA, r_array_pop(co->fp, rword)));
@@ -1083,6 +1087,7 @@ int codegen_funcallname_callback(rpa_stat_handle stat, const char *name, void *u
                rvm_codegen_addins(co->cg, rvm_asm(RVM_MOV, TP, R1, XX, 0));
        } else {
                rvm_codegen_addins(co->cg, rvm_asm(RVM_PUSHM, DA, XX, XX, BIT(TP)|BIT(FP)|BIT(SP)));
+               rvm_codegen_addins(co->cg, rvm_asm(RVM_PROPGET, TP, DA, XX, 0));
        }
        rvm_codegen_addins(co->cg, rvm_asm(RVM_PUSH, R0, XX, XX, 0));