home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / Jikes / Source / src / op.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-24  |  26.8 KB  |  798 lines

  1. // $Id: op.cpp,v 1.11 2001/01/10 16:49:45 mdejong Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10.  
  11. #include "op.h"
  12.  
  13. /*
  14. //FIXME: include stuff
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <iostream.h>
  18. #include <string.h>
  19. */
  20.  
  21. #ifdef    HAVE_JIKES_NAMESPACE
  22. namespace Jikes {    // Open namespace Jikes block
  23. #endif
  24.  
  25.  
  26. void Operators::opdesc(int opc, char **name, char **desc)
  27. {
  28.     struct op_entry
  29.     {
  30.         char *op_name,
  31.              *op_desc;
  32.     };
  33.  
  34.     struct op_entry table[] =
  35.     {
  36.         {"nop",  "do nothing"},
  37.         {"aconst_null",  "push null"},
  38.         {"iconst_m1",  "push int constant -1"},
  39.         {"iconst_0",  "push int constant 0"},
  40.         {"iconst_1",  "push int constant 1"},
  41.         {"iconst_2",  "push int constant 2"},
  42.         {"iconst_3",  "push int constant 3"},
  43.         {"iconst_4",  "push int constant 4"},
  44.         {"iconst_5",  "push int constant 5"},
  45.         {"lconst_0",  "push long constant 0"},
  46.         {"lconst_1",  "push long constant 1"},
  47.         {"fconst_0",  "push float 0.0"},
  48.         {"fconst_1",  "push float 1.0"},
  49.         {"fconst_2",  "push float 2.0"},
  50.         {"dconst_0",  "push double 0.0 onto stack"},
  51.         {"dconst_1",  "push double 1.0 onto stack"},
  52.         {"bipush",  "push byte"},
  53.         {"sipush",  "push short"},
  54.         {"ldc",  "push item from constant pool"},
  55.         {"ldc_w",  "push item from constant pool (wide index)"},
  56.         {"ldc2_w",  "push long or double from constant pool (wide index)"},
  57.         {"iload",  "load int from local variable"},
  58.         {"lload",  "load long from local variable"},
  59.         {"fload",  "load float from local variable"},
  60.         {"dload",  "load double from local variable"},
  61.         {"aload",  "load reference from local variable"},
  62.         {"iload_0",  "load int from local variable 0"},
  63.         {"iload_1",  "load int from local variable 1"},
  64.         {"iload_2",  "load int from local variable 2"},
  65.         {"iload_3",  "load int from local variable 3"},
  66.         {"lload_0",  "load long from local variable 0"},
  67.         {"lload_1",  "load long from local variable 1"},
  68.         {"lload_2",  "load long from local variable 2"},
  69.         {"lload_3",  "load long from local variable 3"},
  70.         {"fload_0",  "load float from local variable 0"},
  71.         {"fload_1",  "load float from local variable 1"},
  72.         {"fload_2",  "load float from local variable 2"},
  73.         {"fload_3",  "load float from local variable 3"},
  74.         {"dload_0",  "load double from local variable 0"},
  75.         {"dload_1",  "load double from local variable 1"},
  76.         {"dload_2",  "load double from local variable 2"},
  77.         {"dload_3",  "load double from local variable 3"},
  78.         {"aload_0",  "load reference from local variable 0"},
  79.         {"aload_1",  "load reference from local variable 1"},
  80.         {"aload_2",  "load reference from local variable 2"},
  81.         {"aload_3",  "load reference from local variable 3"},
  82.         {"iaload",  "load int from array"},
  83.         {"laload",  "load long from array"},
  84.         {"faload",  "load float from array"},
  85.         {"daload",  "load double from array"},
  86.         {"aaload",  "load reference from array"},
  87.         {"baload",  "load byte from array"},
  88.         {"caload",  "load char from array"},
  89.         {"saload",  "load short from array"},
  90.         {"istore",  "store int into local variable"},
  91.         {"lstore",  "store long into local variable"},
  92.         {"fstore",  "store float into local variable"},
  93.         {"dstore",  "store double into local variable"},
  94.         {"astore",  "store reference into local variable"},
  95.         {"istore_0",  "store int into local variable 0"},
  96.         {"istore_1",  "store int into local variable 1"},
  97.         {"istore_2",  "store int into local variable 2"},
  98.         {"istore_3",  "store int into local variable 3"},
  99.         {"lstore_0",  "store long into local variable 0"},
  100.         {"lstore_1",  "store long into local variable 1"},
  101.         {"lstore_2",  "store long into local variable 2"},
  102.         {"lstore_3",  "store long into local variable 3"},
  103.         {"fstore_0",  "store float into local variable 0"},
  104.         {"fstore_1",  "store float into local variable 1"},
  105.         {"fstore_2",  "store float into local variable 2"},
  106.         {"fstore_3",  "store float into local variable 3"},
  107.         {"dstore_0",  "store double into local variable 0"},
  108.         {"dstore_1",  "store double into local variable 1"},
  109.         {"dstore_2",  "store double into local variable 2"},
  110.         {"dstore_3",  "store double into local variable 3"},
  111.         {"astore_0",  "store reference into local variable 0"},
  112.         {"astore_1",  "store reference into local variable 1"},
  113.         {"astore_2",  "store reference into local variable 2"},
  114.         {"astore_3",  "store reference into local variable 3"},
  115.         {"iastore",  "store into int array"},
  116.         {"lastore",  "store into long array"},
  117.         {"fastore",  "store into float array"},
  118.         {"dastore",  "store into double array"},
  119.         {"aastore",  "store into reference array"},
  120.         {"bastore",  "store into byte array"},
  121.         {"castore",  "store into char array"},
  122.         {"sastore",  "store into short array"},
  123.         {"pop",  "pop top operand stack word"},
  124.         {"pop2",  "pop two two operand stack words"},
  125.         {"dup",  "duplicate top operand stack word"},
  126.         {"dup_x1",  "duplicate top operand stack word and put two down"},
  127.         {"dup_x2",  "duplicate top operand stack word and put three down"},
  128.         {"dup2",  "duplicate top two operand stack words"},
  129.         {"dup2_x1",  "duplicate top two operand stack words and put three down"},
  130.         {"dup2_x2",  "duplicate top two operand stack words and put four down"},
  131.         {"swap",  "swap top two operand stack words"},
  132.         {"iadd",  "add int"},
  133.         {"ladd",  "add long"},
  134.         {"fadd",  "add float"},
  135.         {"dadd",  "add double"},
  136.         {"isub",  "subtract int"},
  137.         {"lsub",  "subtract long"},
  138.         {"fsub",  "substract float"},
  139.         {"dsub",  "subtract double"},
  140.         {"imul",  "multiply int"},
  141.         {"lmul",  "multiply long"},
  142.         {"fmul",  "multiply float"},
  143.         {"dmul",  "multiply double"},
  144.         {"idiv",  "divide int"},
  145.         {"ldiv",  "divide long"},
  146.         {"fdiv",  "divide float"},
  147.         {"ddiv",  "divide double"},
  148.         {"irem",  "remainder int"},
  149.         {"lrem",  "remainder long"},
  150.         {"frem",  "remainder float"},
  151.         {"drem",  "remainder double"},
  152.         {"ineg",  "negate int"},
  153.         {"lneg",  "negate long"},
  154.         {"fneg",  "negate float"},
  155.         {"dneg",  "negate double"},
  156.         {"ishl",  "shift left int"},
  157.         {"lshl",  "shift left long"},
  158.         {"ishr",  "shift right int"},
  159.         {"lshr",  "shift right long"},
  160.         {"iushr",  "logical shift right int"},
  161.         {"lushr",  "logical shift right long"},
  162.         {"iand",  "boolean and int"},
  163.         {"land",  "boolean and long"},
  164.         {"ior",  "boolean or int"},
  165.         {"lor",  "boolean or long"},
  166.         {"ixor",  "boolean xor int"},
  167.         {"lxor",  "boolean xor long"},
  168.         {"iinc",  "increment local variable by constant"},
  169.         {"i2l",  "convert int to long"},
  170.         {"i2f",  "convert int to float"},
  171.         {"i2d",  "convert int to double"},
  172.         {"l2i",  "convert long to int"},
  173.         {"l2f",  "convert long to float"},
  174.         {"l2d",  "convert long to double"},
  175.         {"f2i",  "convert float to int"},
  176.         {"f2l",  "convert float to long"},
  177.         {"f2d",  "convert float to double"},
  178.         {"d2i",  "convert double to int"},
  179.         {"d2l",  "convert double to long"},
  180.         {"d2f",  "convert double to float"},
  181.         {"i2b",  "convert int to byte"},
  182.         {"i2c",  "convert int to char"},
  183.         {"i2s",  "convert int to short"},
  184.         {"lcmp",  "compare long"},
  185.         {"fcmpl",  "compare float less"},
  186.         {"fcmpg",  "compare float greater"},
  187.         {"dcmpl",  "compare double less"},
  188.         {"dcmpg",  "compare double greater"},
  189.         {"ifeq",  "branch if int eq zero"},
  190.         {"ifne",  "branch if int ne zero"},
  191.         {"iflt",  "branch if int lt zero"},
  192.         {"ifge",  "branch if int ge zero"},
  193.         {"ifgt",  "branch if int gt zero"},
  194.         {"ifle",  "branch if int le zero"},
  195.         {"if_icmpeq",  "branch if int comparison eq"},
  196.         {"if_icmpne",  "branch if int comparison ne"},
  197.         {"if_icmplt",  "branch if int comparison lt"},
  198.         {"if_icmpge",  "branch if int comparison ge"},
  199.         {"if_icmpgt",  "branch if int comparison gt"},
  200.         {"if_icmple",  "branch if int comparison le"},
  201.         {"if_acmpeq",  "branch if reference comparison eq"},
  202.         {"if_acmpne",  "branch if reference comparison ne"},
  203.         {"goto",  "branch always"},
  204.         {"jsr",  "jump subroutine"},
  205.         {"ret",  "return from subroutine"},
  206.         {"tableswitch",  "access jump table by index and jump"},
  207.         {"lookupswitch",  "access jump table by key match and jump"},
  208.         {"ireturn",  "return int from method"},
  209.         {"lreturn",  "return long from method"},
  210.         {"freturn",  "return float from method"},
  211.         {"dreturn",  "return double from method"},
  212.         {"areturn",  "return reference from method"},
  213.         {"return",  "return void from method"},
  214.         {"getstatic",  "get static field from class"},
  215.         {"putstatic",  "set static field in class"},
  216.         {"getfield",  "fetch field from object"},
  217.         {"putfield",  "set field in object"},
  218.         {"invokevirtual",  "invoke instance method; dispatch based on runtime type"},
  219.         {"invokenonvirtual",  "invoke instance method; dispatch based on compile-time type"},
  220.         {"invokestatic",  "invoke a class (static) method"},
  221.         {"invokeinterface",  "invoke interface method"},
  222.         {"xxxunusedxxx",  "xxxunusedxxx"},
  223.         {"new",  "create new object"},
  224.         {"newarray",  "create new array"},
  225.         {"anewarray",  "create new array of references"},
  226.         {"arraylength",  "get length of array"},
  227.         {"athrow",  "throw exception or error"},
  228.         {"checkcast",  "check whether object is of given type"},
  229.         {"instanceof",  "determine if object is of given type"},
  230.         {"monitorenter",  "enter monitor for object"},
  231.         {"monitorexit",  "exit monitor for object"},
  232.         {"wide",  "extend local variable index by additional bytes"},
  233.         {"multianewarray",  "create new multidimensional array"},
  234.         {"ifnull",  "branch if reference is null"},
  235.         {"ifnonnuull",  "branch if reference not null"},
  236.         {"goto_w",  "branch always (wide index) ?"},
  237.         {"jsr_w",  "jump subroutine (wide index)"}
  238.     };
  239.  
  240.     if (opc == OP_SOFTWARE)                 // software
  241.          *name = *desc = "software";
  242.     else if (opc == OP_HARDWARE)           // hardware
  243.          *name = *desc = "hardware";
  244.     else if (opc >=0 && opc <= 0xc9)
  245.     {
  246.          *name = table[opc].op_name;
  247.          *desc = table[opc].op_desc;
  248.     }
  249.     else *name = *desc = "illegal";
  250.  
  251.      return;
  252. }
  253.  
  254. void Operators::opline(Tuple<cp_info *> &constant_pool, char *hdr, int pc, int opc, char *name,
  255.                        char *args, char *desc, int info_kind, int info_index)
  256. {
  257.     // generate line of opcode dump, info is extra info
  258.  
  259.     Coutput << *hdr;
  260.     Coutput.width(4);
  261.     Coutput << pc;
  262.     Coutput << "\t" << name;
  263.     int len = strlen(name);
  264.     if (strlen(args))
  265.     {
  266.         Coutput << " " << args;
  267.         len += (strlen(args) + 1);
  268.     }
  269.     if (len < 8)
  270.          Coutput << "\t\t\t";
  271.     else if (len < 16)
  272.          Coutput << "\t\t";
  273.     else Coutput << "\t";
  274.  
  275.     switch (info_kind)
  276.     {
  277.         case INFO_CONST:
  278.              Coutput << " ";
  279.              if (info_index <= 0 || info_index > constant_pool.Length())
  280.                 Coutput << "OUT-OF_BOUNDS CONSTANT_POOL-INDEX " << info_index;
  281.             else {
  282. //              constant_pool[info_index] -> describe(constant_pool);
  283.             }
  284.             break;
  285.         case INFO_LOCAL:
  286.             Coutput << " local#" << info_index;
  287.             break;
  288.     }
  289. //
  290. // DS (17 jun) - skip desc for now: it's too long and shoud only
  291. // be written at user request.
  292. //  Coutput << " " << desc;
  293. //
  294.     Coutput << "\n";
  295.  
  296.     return;
  297. }
  298.  
  299. void Operators::opdmp(Tuple<cp_info *> &constant_pool, Tuple<u1> &code)
  300. {
  301.     int pc = 0;
  302.     while (pc < code.Length())
  303.     {
  304.         int info_kind = INFO_NONE; // assume no extra info
  305.         int info_index = 0;
  306.         int pc_start = pc;
  307.         unsigned opc = get_u1(code, pc);
  308.         char *name, *desc; // set to name (mnemonic) and description of opcode.
  309.         opdesc(code[pc_start], &name, &desc);
  310.         pc++;
  311.  
  312.         char argdesc[100];
  313.         argdesc[0] = U_NULL; // assume no argument description needed
  314.  
  315.         unsigned au1;
  316.         int ai1,
  317.             ai2,
  318.             ai4;
  319.         switch (opc)
  320.         {
  321.             case OP_BIPUSH:
  322.                  ai1 = get_i1(code, pc); pc++;
  323.                  sprintf(argdesc, "%d", ai1);
  324.                  break;
  325.             case OP_SIPUSH:
  326.                  ai2 = get_i2(code, pc); pc +=2;
  327.                  sprintf(argdesc, "%d", ai2);
  328.                  break;
  329.             case OP_LDC:
  330.                  info_index = get_u1(code, pc); pc++;
  331.                  sprintf(argdesc,"%d", info_index);
  332.                  info_kind = INFO_CONST;
  333.                  break;
  334.             case OP_LDC_W:
  335.             case OP_LDC2_W:
  336.                  info_index = get_u2(code, pc);pc +=2;
  337.                  sprintf(argdesc, "%u", info_index);
  338.                  info_kind = INFO_CONST;
  339.                  break;
  340.             case OP_ILOAD:
  341.             case OP_LLOAD:
  342.             case OP_FLOAD:
  343.             case OP_DLOAD:
  344.             case OP_ALOAD:
  345.             case OP_ISTORE:
  346.             case OP_LSTORE:
  347.             case OP_FSTORE:
  348.             case OP_DSTORE:
  349.             case OP_ASTORE:
  350.                  info_index = get_u1(code, pc);pc++;
  351.                  sprintf(argdesc, "%u", info_index);
  352.                  info_kind = INFO_LOCAL;
  353.                  break;
  354.             case OP_ILOAD_0:
  355.             case OP_LLOAD_0:
  356.             case OP_FLOAD_0:
  357.             case OP_DLOAD_0:
  358.             case OP_ALOAD_0:
  359.             case OP_ISTORE_0:
  360.             case OP_LSTORE_0:
  361.             case OP_FSTORE_0:
  362.             case OP_DSTORE_0:
  363.             case OP_ASTORE_0:
  364.                  info_kind = INFO_LOCAL;
  365.                  info_index = 0;
  366.                  break;
  367.             case OP_ILOAD_1:
  368.             case OP_LLOAD_1:
  369.             case OP_FLOAD_1:
  370.             case OP_DLOAD_1:
  371.             case OP_ALOAD_1:
  372.             case OP_ISTORE_1:
  373.             case OP_LSTORE_1:
  374.             case OP_FSTORE_1:
  375.             case OP_DSTORE_1:
  376.             case OP_ASTORE_1:
  377.                  info_kind = INFO_LOCAL;
  378.                  info_index = 1;
  379.                  break;
  380.             case OP_ILOAD_2:
  381.             case OP_LLOAD_2:
  382.             case OP_FLOAD_2:
  383.             case OP_DLOAD_2:
  384.             case OP_ALOAD_2:
  385.             case OP_ISTORE_2:
  386.             case OP_LSTORE_2:
  387.             case OP_DSTORE_2:
  388.             case OP_FSTORE_2:
  389.             case OP_ASTORE_2:
  390.                  info_kind = INFO_LOCAL;
  391.                  info_index = 2;
  392.                  break;
  393.             case OP_ILOAD_3:
  394.             case OP_LLOAD_3:
  395.             case OP_FLOAD_3:
  396.             case OP_DLOAD_3:
  397.             case OP_ALOAD_3:
  398.             case OP_ISTORE_3:
  399.             case OP_LSTORE_3:
  400.             case OP_FSTORE_3:
  401.             case OP_DSTORE_3:
  402.             case OP_ASTORE_3:
  403.                  info_kind= INFO_LOCAL;
  404.                  info_index = 3;
  405.                  break;
  406.             case OP_IINC:
  407.                  info_index = get_u1(code, pc); pc++;
  408.                  au1 = get_u1(code, pc); pc++;
  409.                  ai1 = get_i1(code, pc); pc++;
  410.                  info_kind = INFO_LOCAL;
  411.                  sprintf(argdesc, "%d %d", au1, ai1);
  412.                  break;
  413.             case OP_IFEQ:
  414.             case OP_IFNE:
  415.             case OP_IFLT:
  416.             case OP_IFGE:
  417.             case OP_IFGT:
  418.             case OP_IFLE:
  419.             case OP_IF_ICMPEQ:
  420.             case OP_IF_ICMPNE:
  421.             case OP_IF_ICMPLT:
  422.             case OP_IF_ICMPGE:
  423.             case OP_IF_ICMPGT:
  424.             case OP_IF_ICMPLE:
  425.             case OP_IF_ACMPEQ:
  426.             case OP_IF_ACMPNE:
  427.             case OP_GOTO:
  428.             case OP_JSR:
  429.             case OP_IFNULL:
  430.             case OP_IFNONNULL:
  431.                  ai2 = get_i2(code, pc);
  432.                  sprintf(argdesc, "%d", (int) ( ai2+pc_start)); // compute branch target
  433.                  pc +=2;
  434.                  break;
  435.             case OP_RET:
  436.                  au1 = get_u1(code, pc);
  437.                  pc++;
  438.                  sprintf(argdesc, "%d", (int) au1);
  439.                  break;
  440.             case OP_TABLESWITCH:
  441.                  {
  442.                      int def,
  443.                          low,
  444.                          high,
  445.                          len,
  446.                          val,
  447.                          pc_this,
  448.                          op_this;
  449.                      unsigned iu1;
  450.                      op_this = OP_TABLESWITCH;
  451.                      // account for padding
  452.                      while (pc % 4)
  453.                      {
  454.                          iu1 = get_u1(code, pc);
  455.                          pc++;
  456.                      }
  457.                      def = get_i4(code, pc); pc += 4;
  458.                      low = get_i4(code, pc); pc +=4;
  459.                      high = get_i4(code, pc); pc += 4;
  460.                      sprintf(argdesc, "default:%d low:%d high:%d", def + pc_start, low, high);
  461.                      opline(constant_pool, " ", pc_start, opc, name, argdesc, desc, info_kind, info_index);
  462.                      len =  high - low + 1;
  463.                      while (len)
  464.                      {
  465.                          pc_this = pc;
  466.                          val = get_i4(code, pc);
  467.                          sprintf(argdesc, "match:%d offset:%d", low++, val + pc_start);
  468.                          opline(constant_pool,"*",pc_this, op_this,name,argdesc,desc,INFO_NONE,0);
  469.                          pc += 4;
  470.                          len--;
  471.                      }
  472.                      info_kind = INFO_DONE;
  473.                  }
  474.                  break;
  475.             case OP_LOOKUPSWITCH:
  476.                  {
  477.                      int def,
  478.                          npairs,
  479.                          len,
  480.                          match,
  481.                          offset,
  482.                          op_this;
  483.  
  484.                      // account for padding
  485.                      unsigned iu1;
  486.                      op_this = OP_LOOKUPSWITCH;
  487.                      while (pc % 4)
  488.                      {
  489.                          iu1 = get_u1(code, pc);
  490.                          pc++;
  491.                      }
  492.                      def = get_i4(code, pc); pc += 4;
  493.                      npairs = get_i4(code, pc); pc +=4;
  494.                      sprintf(argdesc, "default:%d npairs:%d", (def + pc_start), npairs);
  495.                      opline(constant_pool, " ", pc_start, op_this, name, argdesc, desc, info_kind, info_index);
  496.                      len = npairs;
  497.                      while (npairs)
  498.                      {
  499.                          int pcb = pc;
  500.                          match = get_i4(code, pc); pc +=4 ;
  501.                          offset = get_i4(code, pc); pc +=4;
  502.                          sprintf(argdesc, "match:%d offset:%d ", match,offset + pc_start);
  503.                          opline(constant_pool, "*", pcb, op_this, name, argdesc, desc, INFO_NONE, 0);
  504.                          npairs--;
  505.                      }
  506.                      info_kind = INFO_DONE;
  507.                  }
  508.                  break;
  509.             case OP_GETSTATIC:
  510.             case OP_PUTSTATIC:
  511.             case OP_GETFIELD:
  512.             case OP_PUTFIELD:
  513.             case OP_INVOKEVIRTUAL:
  514.             case OP_INVOKENONVIRTUAL:
  515.             case OP_INVOKESTATIC:
  516.             case OP_NEW:
  517.             case OP_ANEWARRAY:
  518.             case OP_CHECKCAST:
  519.             case OP_INSTANCEOF:
  520.                  info_index = get_u2(code, pc); pc += 2;
  521.                  sprintf(argdesc, "%d", info_index);
  522.                  info_kind = INFO_CONST;
  523.                  break;
  524.             case OP_INVOKEINTERFACE:
  525.                  {
  526.                      int nargs;
  527.                      info_index = get_u2(code, pc); pc += 2;
  528.                      au1 = get_u1(code, pc); pc++;
  529.                      nargs = au1;
  530.                      au1 = get_u1(code, pc); pc++;
  531.  
  532.                      assert((! au1) && "...zero byte required in this position");
  533.  
  534.                      sprintf(argdesc, "%d %d", nargs,info_index);
  535.                      info_kind=INFO_CONST;
  536.                  }
  537.                  break;
  538.             case OP_NEWARRAY:
  539.                  au1 = get_u1(code, pc); pc++;
  540.                  switch(au1)
  541.                  {
  542.                      case 4: sprintf(argdesc, "%s", "BOOLEAN");break;
  543.                      case 5: sprintf(argdesc, "%s", "CHAR");break;
  544.                      case 6: sprintf(argdesc, "%s", "FLOAT");break;
  545.                      case 7: sprintf(argdesc, "%s", "DOUBLE");break;
  546.                      case 8: sprintf(argdesc, "%s", "BYTE");break;
  547.                      case 9: sprintf(argdesc, "%s", "SHORT");break;
  548.                      case 10: sprintf(argdesc, "%s", "INT");break;
  549.                      case 11: sprintf(argdesc, "%s", "LONG");break;
  550.                      default:
  551.                          sprintf(argdesc, "%s", "<UNKNOWN>");break;
  552.                  }
  553.                  break;
  554.             case OP_WIDE:
  555.                  assert(false && "dmp for op_wide not supported yet");
  556.                  break;
  557.             case OP_MULTIANEWARRAY:
  558.                  info_index = get_u2(code, pc); pc += 2;
  559.                  au1 = get_u1(code, pc); pc++;
  560.                  info_kind = INFO_CONST;
  561.                  // au1 gives dimensions
  562.                  sprintf(argdesc, "%u", au1);
  563.                  break;
  564.             case OP_GOTO_W:
  565.             case OP_JSR_W:
  566.                  ai4 = get_i4(code, pc); pc += 4;
  567.                  // ai4 gives offset (wide) of branch target
  568.                  sprintf(argdesc, "%d", pc_start + ai4);
  569.                  break;
  570.             default:
  571.                  break;
  572.         }
  573.  
  574.         // output first part of description
  575.         if (info_kind != INFO_DONE)
  576.             opline(constant_pool, " ", pc_start, opc, name, argdesc, desc, info_kind, info_index);
  577.     }
  578.  
  579.     return;
  580. }
  581.  
  582.  
  583. //
  584. // stack_effect gives effect on stack of executing an opcode
  585. //
  586. int Operators::stack_effect[] =
  587. {
  588.     0,  // OP_NOP
  589.     1,  // OP_ACONST_NULL
  590.     1,  // OP_ICONST_M1
  591.     1,  // OP_ICONST_0
  592.     1,  // OP_ICONST_1
  593.     1,  // OP_ICONST_2
  594.     1,  // OP_ICONST_3
  595.     1,  // OP_ICONST_4
  596.     1,  // OP_ICONST_5
  597.     2,  // OP_LCONST_0
  598.     2,  // OP_LCONST_1
  599.     1,  // OP_FCONST_0
  600.     1,  // OP_FCONST_1
  601.     1,  // OP_FCONST_2
  602.     2,  // OP_DCONST_0
  603.     2,  // OP_DCONST_1
  604.     1,  // OP_BIPUSH
  605.     1,  // OP_SIPUSH
  606.     1,  // OP_LDC
  607.     1,  // OP_LDC_W
  608.     2,  // OP_LDC2_W
  609.     1,  // OP_ILOAD
  610.     2,  // OP_LLOAD
  611.     1,  // OP_FLOAD
  612.     2,  // OP_DLOAD
  613.     1,  // OP_ALOAD
  614.     1,  // OP_ILOAD_0
  615.     1,  // OP_ILOAD_1
  616.     1,  // OP_ILOAD_2
  617.     1,  // OP_ILOAD_3
  618.     2,  // OP_LLOAD_0
  619.     2,  // OP_LLOAD_1
  620.     2,  // OP_LLOAD_2
  621.     2,  // OP_LLOAD_3
  622.     1,  // OP_FLOAD_0
  623.     1,  // OP_FLOAD_1
  624.     1,  // OP_FLOAD_2
  625.     1,  // OP_FLOAD_3
  626.     2,  // OP_DLOAD_0
  627.     2,  // OP_DLOAD_1
  628.     2,  // OP_DLOAD_2
  629.     2,  // OP_DLOAD_3
  630.     1,  // OP_ALOAD_0
  631.     1,  // OP_ALOAD_1
  632.     1,  // OP_ALOAD_2
  633.     1,  // OP_ALOAD_3
  634.    -1,  // OP_IALOAD
  635.     0,  // OP_LALOAD
  636.    -1,  // OP_FALOAD
  637.     0,  // OP_DALOAD
  638.    -1,  // OP_AALOAD
  639.    -1,  // OP_BALOAD
  640.    -1,  // OP_CALOAD
  641.    -1,  // OP_SALOAD
  642.    -1,  // OP_ISTORE
  643.    -2,  // OP_LSTORE
  644.    -1,  // OP_FSTORE
  645.    -2,  // OP_DSTORE
  646.    -1,  // OP_ASTORE
  647.    -1,  // OP_ISTORE_0
  648.    -1,  // OP_ISTORE_1
  649.    -1,  // OP_ISTORE_2
  650.    -1,  // OP_ISTORE_3
  651.    -2,  // OP_LSTORE_0
  652.    -2,  // OP_LSTORE_1
  653.    -2,  // OP_LSTORE_2
  654.    -2,  // OP_LSTORE_3
  655.    -1,  // OP_FSTORE_0
  656.    -1,  // OP_FSTORE_1
  657.    -1,  // OP_FSTORE_2
  658.    -1,  // OP_FSTORE_3
  659.    -2,  // OP_DSTORE_0
  660.    -2,  // OP_DSTORE_1
  661.    -2,  // OP_DSTORE_2
  662.    -2,  // OP_DSTORE_3
  663.    -1,  // OP_ASTORE_0
  664.    -1,  // OP_ASTORE_1
  665.    -1,  // OP_ASTORE_2
  666.    -1,  // OP_ASTORE_3
  667.    -3,  // OP_IASTORE
  668.    -4,  // OP_LASTORE
  669.    -3,  // OP_FASTORE
  670.    -4,  // OP_DASTORE
  671.    -3,  // OP_AASTORE
  672.    -3,  // OP_BASTORE
  673.    -3,  // OP_CASTORE
  674.    -3,  // OP_SASTORE
  675.    -1,  // OP_POP
  676.    -2,  // OP_POP2
  677.     1,  // OP_DUP
  678.     1,  // OP_DUP_X1
  679.     1,  // OP_DUP_X2
  680.     2,  // OP_DUP2
  681.     2,  // OP_DUP2_X1
  682.     2,  // OP_DUP2_X2
  683.     0,  // OP_SWAP
  684.    -1,  // OP_IADD
  685.    -2,  // OP_LADD
  686.    -1,  // OP_FADD
  687.    -2,  // OP_DADD
  688.    -1,  // OP_ISUB
  689.    -2,  // OP_LSUB
  690.    -1,  // OP_FSUB
  691.    -2,  // OP_DSUB
  692.    -1,  // OP_IMUL
  693.    -2,  // OP_LMUL
  694.    -1,  // OP_FMUL
  695.    -2,  // OP_DMUL
  696.    -1,  // OP_IDIV
  697.    -2,  // OP_LDIV
  698.    -1,  // OP_FDIV
  699.    -2,  // OP_DDIV
  700.    -1,  // OP_IREM
  701.    -2,  // OP_LREM
  702.    -1,  // OP_FREM
  703.    -2,  // OP_DREM
  704.     0,  // OP_INEG
  705.     0,  // OP_LNEG
  706.     0,  // OP_FNEG
  707.     0,  // OP_DNEG
  708.    -1,  // OP_ISHL
  709.    -1,  // OP_LSHL
  710.    -1,  // OP_ISHR
  711.    -1,  // OP_LSHR
  712.    -1,  // OP_IUSHR
  713.    -1,  // OP_LUSHR
  714.    -1,  // OP_IAND
  715.    -2,  // OP_LAND
  716.    -1,  // OP_IOR
  717.    -2,  // OP_LOR
  718.    -1,  // OP_IXOR
  719.    -2,  // OP_LXOR
  720.     0,  // OP_IINC
  721.     1,  // OP_I2L
  722.     0,  // OP_I2F
  723.     1,  // OP_I2D
  724.    -1,  // OP_L2I
  725.    -1,  // OP_L2F
  726.     0,  // OP_L2D
  727.     0,  // OP_F2I
  728.     1,  // OP_F2L
  729.     1,  // OP_F2D
  730.    -1,  // OP_D2I
  731.     0,  // OP_D2L
  732.    -1,  // OP_D2F
  733.     0,  // OP_I2B
  734.     0,  // OP_I2C
  735.     0,  // OP_I2S
  736.    -3,  // OP_LCMP
  737.    -1,  // OP_FCMPL
  738.    -1,  // OP_FCMPG
  739.    -3,  // OP_DCMPL
  740.    -3,  // OP_DCMPG
  741.    -1,  // OP_IFEQ
  742.    -1,  // OP_IFNE
  743.    -1,  // OP_IFLT
  744.    -1,  // OP_IFGE
  745.    -1,  // OP_IFGT
  746.    -1,  // OP_IFLE
  747.    -2,  // OP_IF_ICMPEQ
  748.    -2,  // OP_IF_ICMPNE
  749.    -2,  // OP_IF_ICMPLT
  750.    -2,  // OP_IF_ICMPGE
  751.    -2,  // OP_IF_ICMPGT
  752.    -2,  // OP_IF_ICMPLE
  753.    -2,  // OP_IF_ACMPEQ
  754.    -2,  // OP_IF_ACMPNE
  755.     0,  // OP_GOTO
  756.     1,  // OP_JSR
  757.     0,  // OP_RET
  758.    -1,  // OP_TABLESWITCH
  759.    -1,  // OP_LOOKUPSWITCH
  760.    -1,  // OP_IRETURN
  761.    -2,  // OP_LRETURN
  762.    -1,  // OP_FRETURN
  763.    -2,  // OP_DRETURN
  764.    -1,  // OP_ARETURN
  765.     0,  // OP_RETURN
  766.     0,  // OP_GETSTATIC, caller must adjust if long or double
  767.     0,  // OP_PUTSTATIC, caller must adjust if long or double
  768.     0,  // OP_GETFIELD, caller must adjust if long or double
  769.     0,  // OP_PUTFIELD, caller must adjust if long or double
  770.    -1,  // OP_INVOKEVIRTUAL,   actually  -1-args_length
  771.    -1,  // OP_INVOKENONVIRTUAL,    actually  -1-args_length
  772.     0,  // OP_INVOKESTATIC, actually -args_length
  773.    -1,  // OP_INVOKEINTERFACE, actually -1 -args_length
  774.     0,  // OP_XXXUNUSEDXXX
  775.     1,  // OP_NEW
  776.     0,  // OP_NEWARRAY
  777.     0,  // OP_ANEWARRAY
  778.     0,  // OP_ARRAYLENGTH
  779.     0,  // OP_ATHROW
  780.     0,  // OP_CHECKCAST
  781.     0,  // OP_INSTANCEOF
  782.    -1,  // OP_MONITORENTER
  783.    -1,  // OP_MONITOREXIT
  784.     0,  // OP_WIDE
  785.     0,  // OP_MULTIANEWARRAY, actually dims-1
  786.    -1,  // OP_IFNULL
  787.    -1,  // OP_IFNONNULL
  788.     0,  // OP_GOTO_W
  789.     1,  // OP_JSR_W
  790.     0,  // OP_SOFTWARE
  791.     0   // OP_HARDWARE
  792. };
  793.  
  794. #ifdef    HAVE_JIKES_NAMESPACE
  795. }            // Close namespace Jikes block
  796. #endif
  797.  
  798.