develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34492 - trunk/compilers/pirc/new

From:
kjs
Date:
December 28, 2008 07:03
Subject:
[svn:parrot] r34492 - trunk/compilers/pirc/new
Message ID:
20081228150336.D87A5CB9F9@x12.develooper.com
Author: kjs
Date: Sun Dec 28 07:03:35 2008
New Revision: 34492

Modified:
   trunk/compilers/pirc/new/bcgen.c
   trunk/compilers/pirc/new/pircompiler.c
   trunk/compilers/pirc/new/pircompunit.c
   trunk/compilers/pirc/new/piremit.c

Log:
[pirc] fix emission of bytecode for params. no :flags yet, only types and reg numbers.

Modified: trunk/compilers/pirc/new/bcgen.c
==============================================================================
--- trunk/compilers/pirc/new/bcgen.c	(original)
+++ trunk/compilers/pirc/new/bcgen.c	Sun Dec 28 07:03:35 2008
@@ -312,6 +312,8 @@
 void
 emit_opcode(bytecode * const bc, opcode_t op) {
     *bc->opcursor++ = op;
+/*    fprintf(stderr, "[%d]", op);
+*/
 }
 
 /*
@@ -329,6 +331,8 @@
 void
 emit_int_arg(bytecode * const bc, int intval) {
     *bc->opcursor++ = intval;
+/*    fprintf(stderr, "[%d]", intval);
+*/
 }
 
 /*

Modified: trunk/compilers/pirc/new/pircompiler.c
==============================================================================
--- trunk/compilers/pirc/new/pircompiler.c	(original)
+++ trunk/compilers/pirc/new/pircompiler.c	Sun Dec 28 07:03:35 2008
@@ -185,6 +185,7 @@
     if (TEST_FLAG(flags, LEXER_FLAG_REGALLOC))
         lexer->lsr = new_linear_scan_register_allocator(lexer);
 
+    /* create a bytecode object for bytecode generation */
     lexer->bc = new_bytecode(lexer->interp, filename);
 
     return lexer;

Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c	(original)
+++ trunk/compilers/pirc/new/pircompunit.c	Sun Dec 28 07:03:35 2008
@@ -1723,6 +1723,8 @@
 push_operand(lexer_state * const lexer, NOTNULL(expression * const operand)) {
     PARROT_ASSERT(lexer->subs->statements);
 
+    fprintf(stderr, "push_operand() current op: %s\n", CURRENT_INSTRUCTION(lexer)->opname);
+
     if (CURRENT_INSTRUCTION(lexer)->operands) {
         operand->next = CURRENT_INSTRUCTION(lexer)->operands->next;
         CURRENT_INSTRUCTION(lexer)->operands->next = operand;
@@ -1967,7 +1969,8 @@
     /* add the index (of the signature PMC) in the PBC constant table as operand */
     push_operand(lexer, expr_from_int(lexer, array_index));
 
-    fprintf(stderr, "args2ops: %u arguments\n", num_arguments);
+/*    fprintf(stderr, "args2ops: %u arguments\n", num_arguments);
+*/
 
     /* no need to continue if there's no arguments */
     if (num_arguments == 0)
@@ -1976,9 +1979,9 @@
     /* retrieve the signature array PMC */
     signature_array = get_pmc_const(lexer->bc, array_index);
 
-    fprintf(stderr, "signature array has size: %d\n",
+/*    fprintf(stderr, "signature array has size: %d\n",
             VTABLE_get_integer(lexer->interp, signature_array));
-
+*/
 
     /* initialize the argument iterator for the loop */
     argiter = args->next;
@@ -1988,7 +1991,7 @@
         /* calculate the right flags for the current argument */
         SET_FLAG(flag, get_expression_pirtype(argiter->value));
 
-        fprintf(stderr, "Setting flag %d on argument %u\n", flag, i);
+/*        fprintf(stderr, "Setting flag %d on argument %u\n", flag, i); */
 
         /* set the flags for this argument in the right position in the array */
         VTABLE_set_integer_keyed_int(lexer->interp, signature_array, i, flag);
@@ -1999,7 +2002,7 @@
         argiter = argiter->next;
     }
 
-    fprintf(stderr, "args2ops done\n");
+/*    fprintf(stderr, "args2ops done\n"); */
 
 }
 
@@ -2099,9 +2102,12 @@
      */
 
     /* count number of ints needed to store this instruction in bytecode */
-    lexer->codesize += CURRENT_INSTRUCTION(lexer)->opinfo->op_count + num_var_args;
+    lexer->codesize += CURRENT_INSTRUCTION(lexer)->opinfo->op_count;
+
+    fprintf(stderr, "opcount for '%s' is %d\n", opname, CURRENT_INSTRUCTION(lexer)->opinfo->op_count);
+    lexer->codesize += num_var_args;
 
-    fprintf(stderr, "new_sub_instr(): extra args for '%s': %u\n", opname, num_var_args);
+    fprintf(stderr, "new_sub_instr(): extra args for '%s': %u (codesize: %u)\n", opname, num_var_args, lexer->codesize);
 }
 
 /*
@@ -2123,6 +2129,8 @@
      */
     if (instr->opinfo)
         lexer->codesize -= instr->opinfo->op_count;
+
+    fprintf(stderr, "updateop(): %s\n", CURRENT_INSTRUCTION(lexer)->opname);
     /* else the instruction was already set; decrement the codesize, as it was added already */
 
     /* now get the opinfo structure, update the name, and update the opcode. */

Modified: trunk/compilers/pirc/new/piremit.c
==============================================================================
--- trunk/compilers/pirc/new/piremit.c	(original)
+++ trunk/compilers/pirc/new/piremit.c	Sun Dec 28 07:03:35 2008
@@ -446,6 +446,7 @@
             emit_int_arg(lexer->bc, index);
 
             */
+            fprintf(stderr, "emit_pbc_const_arg: pmc type\n");
             break;
         }
         default:
@@ -453,6 +454,7 @@
     }
 }
 
+/***
 int
 emit_pbc_const(lexer_state * const lexer, constant * const pirconst) {
     switch (pirconst->type) {
@@ -470,6 +472,7 @@
             break;
     }
 }
+***/
 
 /*
 
@@ -536,8 +539,7 @@
              */
             operand = instr->operands->next;
 
-            for (i = 0; i < instr->opinfo->op_count - 1; ++i) {
-
+            do {
                 switch (operand->type) {
                     case EXPR_CONSTANT:
                         emit_pbc_const_arg(lexer, operand->expr.c);
@@ -554,6 +556,7 @@
 
                 operand = operand->next;
             }
+            while (operand != instr->operands->next);
         }
     }
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About