Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (22 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/verify.cc

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11// defineclass.cc - defining a class from .class format.
    22
    3 /* Copyright (C) 2001, 2002  Free Software Foundation
     3/* Copyright (C) 2001, 2002  Free Software Foundation
    44
    55   This file is part of libgcj.
     
    127127
    128128    return r;
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
    129157  }
    130158
     
    406434      using namespace java::lang;
    407435      java::lang::ClassLoader *loader
    408         = verifier->current_class->getClassLoader();
     436        = verifier->current_class->getClassLoader();
    409437      // We might see either kind of name.  Sigh.
    410438      if (data.name->data[0] == 'L'
     
    459487        return key == k.key;
    460488
    461       // The `null' type is convertible to any reference type.
    462       // FIXME: is this correct for THIS?
     489      // The `null' type is convertible to any
     490      //
    463491      if (key == null_type || k.key == null_type)
    464492        return true;
     
    572600      if (key == reference_type)
    573601        return type (_Jv_GetArrayClass (data.klass,
    574                                         data.klass->getClassLoader ()));
     602                                        data.klass->getClassLoader()));
    575603      else
    576604        verifier->verify_fail ("internal error in type::to_array()");
     
    696724                        {
    697725                          java::lang::ClassLoader *loader
    698                             = verifier->current_class->getClassLoader();
     726                            = verifier->current_class->getClassLoader();
    699727                          k = _Jv_GetArrayClass (k, loader);
    700728                          --arraycount;
     
    794822    // without really initializing.
    795823    type this_type;
     824
     825
     826
     827
     828
     829
    796830
    797831    // INVALID marks a state which is not on the linked list of states
     
    812846      locals = NULL;
    813847      local_changed = NULL;
     848
    814849    }
    815850
     
    824859      locals = new type[max_locals];
    825860      local_changed = (bool *) _Jv_Malloc (sizeof (bool) * max_locals);
     861
    826862      for (int i = 0; i < max_locals; ++i)
    827863        {
     
    839875      locals = new type[max_locals];
    840876      local_changed = (bool *) _Jv_Malloc (sizeof (bool) * max_locals);
     877
    841878      copy (orig, max_stack, max_locals, ret_semantics);
    842879      next = INVALID;
     
    851888      if (local_changed)
    852889        _Jv_Free (local_changed);
     890
    853891    }
    854892
     
    871909    {
    872910      _Jv_Free (mem);
     911
     912
     913
     914
     915
     916
     917
     918
     919
     920
     921
    873922    }
    874923
     
    892941          local_changed[i] = copy->local_changed[i];
    893942        }
     943
     944
     945
     946
     947
     948
     949
     950
     951
     952
    894953      this_type = copy->this_type;
    895954      // Don't modify `next'.
     
    916975      for (int i = 0; i < max_locals; ++i)
    917976        local_changed[i] = false;
     977
     978
     979
     980
     981
     982
     983
     984
     985
    918986    }
    919987
     
    9451013      else
    9461014        {
    947           // If the subroutines differ, indicate that the state
    948           // changed.  This is needed to detect when subroutines have
    949           // merged.
    950           changed = true;
     1015          // If the subroutines differ, and we haven't seen this
     1016          // subroutine before, indicate that the state changed.  This
     1017          // is needed to detect when subroutines have merged.
     1018          bool found = false;
     1019          for (subr_info *info = seen_subrs; info != NULL; info = info->next)
     1020            {
     1021              if (info->pc == state_old->subroutine)
     1022                {
     1023                  found = true;
     1024                  break;
     1025                }
     1026            }
     1027          if (! found)
     1028            {
     1029              add_subr (state_old->subroutine);
     1030              changed = true;
     1031            }
    9511032        }
    9521033
     
    11221203  }
    11231204
    1124   type pop64 ()
    1125   {
    1126     type r = pop_raw ();
    1127     if (! r.iswide ())
    1128       verify_fail ("wide pop of narrow type");
    1129     return r;
    1130   }
    1131 
    11321205  type pop_type (type match)
    11331206  {
     
    11351208    type t = pop_raw ();
    11361209    if (! match.compatible (t, this))
     1210
     1211
     1212
     1213
     1214
     1215
     1216
     1217
     1218
     1219
     1220
     1221
     1222
    11371223      verify_fail ("incompatible type on stack");
    11381224    return t;
     
    13391425    int *prev_loc = &next_verify_pc;
    13401426    int npc = next_verify_pc;
    1341     bool skipped = false;
    13421427
    13431428    while (npc != state::NO_NEXT)
     
    13561441          }
    13571442
    1358         skipped = true;
    13591443        prev_loc = &states[npc]->next;
    13601444        npc = states[npc]->next;
     
    14351519    for (subr_info *subr = jsr_ptrs[csub]; subr != NULL; subr = subr->next)
    14361520      {
     1521
     1522
     1523
     1524
     1525
     1526
    14371527        // Temporarily modify the current state so it looks like we're
    14381528        // in the enclosing context.
     
    14841574    // might change the stack depth, so we can't make any assumptions
    14851575    // about it.  So we have yet another special case.  We know that
    1486     // at this point PC points to the instruction after the jsr.
    1487 
    1488     // FIXME: what if we have a jsr at the end of the code, but that
    1489     // jsr has no corresponding ret?  Is this verifiable, or is it
    1490     // not?  If it is then we need a special case here.
    1491     if (PC >= current_method->code_length)
    1492       verify_fail ("fell off end");
    1493 
    1494     current_state->stacktop = state::NO_STACK;
    1495     push_jump_merge (PC, current_state);
     1576    // at this point PC points to the instruction after the jsr.  Note
     1577    // that it is ok to have a `jsr' at the end of the bytecode,
     1578    // provided that the called subroutine never returns.  So, we have
     1579    // a special case here and another one when we handle the ret.
     1580    if (PC < current_method->code_length)
     1581      {
     1582        current_state->stacktop = state::NO_STACK;
     1583        push_jump_merge (PC, current_state);
     1584      }
    14961585    invalidate_pc ();
    14971586  }
     
    15261615        k = JvPrimClass (long);
    15271616        break;
     1617
     1618
     1619
     1620
     1621
     1622
     1623
     1624
     1625
     1626
     1627
     1628
     1629
    15281630      default:
    15291631        verify_fail ("unknown type in construct_primitive_array_type");
     
    18291931            break;
    18301932
     1933
     1934
     1935
     1936
     1937
     1938
     1939
     1940
     1941
     1942
     1943
     1944
     1945
     1946
     1947
     1948
     1949
     1950
     1951
     1952
     1953
     1954
     1955
     1956
    18311957          default:
    18321958            verify_fail ("unrecognized instruction in branch_prepass",
     
    18461972    for (int i = 0; i < current_method->exc_count; ++i)
    18471973      {
    1848         if (! (flags[exception[i].handler_pc] & FLAG_INSN_START))
     1974        if (! (flags[exception[i].handler_pc] & FLAG_INSN_START))
    18491975          verify_fail ("exception handler not at instruction start",
    1850                        exception[i].handler_pc);
    1851         if (! (flags[exception[i].start_pc] & FLAG_INSN_START))
     1976                       exception[i].handler_pc);
     1977        if (! (flags[exception[i].start_pc] & FLAG_INSN_START))
    18521978          verify_fail ("exception start not at instruction start",
    1853                        exception[i].start_pc);
    1854         if (exception[i].end_pc != current_method->code_length
    1855             && ! (flags[exception[i].end_pc] & FLAG_INSN_START))
     1979                       exception[i].start_pc);
     1980        if (exception[i].end_pc != current_method->code_length
     1981            && ! (flags[exception[i].end_pc] & FLAG_INSN_START))
    18561982          verify_fail ("exception end not at instruction start",
    1857                        exception[i].end_pc);
    1858 
    1859         flags[exception[i].handler_pc] |= FLAG_BRANCH_TARGET;
     1983                       exception[i].end_pc);
     1984
     1985        flags[exception[i].handler_pc] |= FLAG_BRANCH_TARGET;
    18601986      }
    18611987  }
     
    20272153  {
    20282154    int var = 0;
    2029     bool is_init = false;
     2155    bool is_init = _Jv_equalUtf8Consts (current_method->self->name,
     2156                                        gcj::init_name);
     2157    bool is_clinit = _Jv_equalUtf8Consts (current_method->self->name,
     2158                                          gcj::clinit_name);
    20302159
    20312160    using namespace java::lang::reflect;
     
    20332162      {
    20342163        type kurr (current_class);
    2035         if (_Jv_equalUtf8Consts (current_method->self->name, gcj::init_name))
     2164        if ()
    20362165          {
    20372166            kurr.set_uninitialized (type::SELF, this);
    20382167            is_init = true;
    20392168          }
     2169
     2170
    20402171        set_variable (0, kurr);
    20412172        current_state->set_this_type (kurr);
    20422173        ++var;
     2174
     2175
     2176
     2177
     2178
    20432179      }
    20442180
     
    21502286        for (int i = 0; i < current_method->exc_count; ++i)
    21512287          {
    2152             if (PC >= exception[i].start_pc && PC < exception[i].end_pc)
     2288            if (PC >= exception[i].start_pc)
    21532289              {
    21542290                type handler (&java::lang::Throwable::class$);
    2155                 if (exception[i].handler_type != 0)
    2156                   handler = check_class_constant (exception[i].handler_type);
    2157                 push_exception_jump (handler, exception[i].handler_pc);
     2291                if (exception[i].handler_type != 0)
     2292                  handler = check_class_constant (exception[i].handler_type);
     2293                push_exception_jump (handler, exception[i].handler_pc);
    21582294              }
    21592295          }
     
    22652401          case op_iaload:
    22662402            pop_type (int_type);
    2267             push_type (require_array_type (pop_type (reference_type),
     2403            push_type (require_array_type (pop_ (reference_type),
    22682404                                           int_type));
    22692405            break;
    22702406          case op_laload:
    22712407            pop_type (int_type);
    2272             push_type (require_array_type (pop_type (reference_type),
     2408            push_type (require_array_type (pop_ (reference_type),
    22732409                                           long_type));
    22742410            break;
    22752411          case op_faload:
    22762412            pop_type (int_type);
    2277             push_type (require_array_type (pop_type (reference_type),
     2413            push_type (require_array_type (pop_ (reference_type),
    22782414                                           float_type));
    22792415            break;
    22802416          case op_daload:
    22812417            pop_type (int_type);
    2282             push_type (require_array_type (pop_type (reference_type),
     2418            push_type (require_array_type (pop_ (reference_type),
    22832419                                           double_type));
    22842420            break;
    22852421          case op_aaload:
    22862422            pop_type (int_type);
    2287             push_type (require_array_type (pop_type (reference_type),
     2423            push_type (require_array_type (pop_ (reference_type),
    22882424                                           reference_type));
    22892425            break;
    22902426          case op_baload:
    22912427            pop_type (int_type);
    2292             require_array_type (pop_type (reference_type), byte_type);
     2428            require_array_type (pop_ (reference_type), byte_type);
    22932429            push_type (int_type);
    22942430            break;
    22952431          case op_caload:
    22962432            pop_type (int_type);
    2297             require_array_type (pop_type (reference_type), char_type);
     2433            require_array_type (pop_ (reference_type), char_type);
    22982434            push_type (int_type);
    22992435            break;
    23002436          case op_saload:
    23012437            pop_type (int_type);
    2302             require_array_type (pop_type (reference_type), short_type);
     2438            require_array_type (pop_ (reference_type), short_type);
    23032439            push_type (int_type);
    23042440            break;
     
    23512487            pop_type (int_type);
    23522488            pop_type (int_type);
    2353             require_array_type (pop_type (reference_type), int_type);
     2489            require_array_type (pop_ (reference_type), int_type);
    23542490            break;
    23552491          case op_lastore:
    23562492            pop_type (long_type);
    23572493            pop_type (int_type);
    2358             require_array_type (pop_type (reference_type), long_type);
     2494            require_array_type (pop_ (reference_type), long_type);
    23592495            break;
    23602496          case op_fastore:
    23612497            pop_type (float_type);
    23622498            pop_type (int_type);
    2363             require_array_type (pop_type (reference_type), float_type);
     2499            require_array_type (pop_ (reference_type), float_type);
    23642500            break;
    23652501          case op_dastore:
    23662502            pop_type (double_type);
    23672503            pop_type (int_type);
    2368             require_array_type (pop_type (reference_type), double_type);
     2504            require_array_type (pop_ (reference_type), double_type);
    23692505            break;
    23702506          case op_aastore:
    23712507            pop_type (reference_type);
    23722508            pop_type (int_type);
    2373             require_array_type (pop_type (reference_type), reference_type);
     2509            require_array_type (pop_ (reference_type), reference_type);
    23742510            break;
    23752511          case op_bastore:
    23762512            pop_type (int_type);
    23772513            pop_type (int_type);
    2378             require_array_type (pop_type (reference_type), byte_type);
     2514            require_array_type (pop_ (reference_type), byte_type);
    23792515            break;
    23802516          case op_castore:
    23812517            pop_type (int_type);
    23822518            pop_type (int_type);
    2383             require_array_type (pop_type (reference_type), char_type);
     2519            require_array_type (pop_ (reference_type), char_type);
    23842520            break;
    23852521          case op_sastore:
    23862522            pop_type (int_type);
    23872523            pop_type (int_type);
    2388             require_array_type (pop_type (reference_type), short_type);
     2524            require_array_type (pop_ (reference_type), short_type);
    23892525            break;
    23902526          case op_pop:
     
    23922528            break;
    23932529          case op_pop2:
    2394             pop64 ();
     2530            {
     2531              type t = pop_raw ();
     2532              if (! t.iswide ())
     2533                pop32 ();
     2534            }
    23952535            break;
    23962536          case op_dup:
     
    27242864            break;
    27252865          case op_areturn:
    2726             check_return_type (pop_type (reference_type));
     2866            check_return_type (pop_ (reference_type));
    27272867            invalidate_pc ();
    27282868            break;
     
    28062946                  // invokeinterface.
    28072947                  nargs -= arg_types[i].depth ();
    2808                   pop_type (arg_types[i]);
     2948                  pop_ (arg_types[i]);
    28092949                }
    28102950
     
    28232963                  type raw = pop_raw ();
    28242964                  bool ok = false;
    2825                   if (t.compatible (raw, this))
     2965                  if (! is_init && ! raw.isinitialized ())
     2966                    {
     2967                      // This is a failure.
     2968                    }
     2969                  else if (is_init && raw.isnull ())
     2970                    {
     2971                      // Another failure.
     2972                    }
     2973                  else if (t.compatible (raw, this))
    28262974                    {
    28272975                      ok = true;
     
    28793027          case op_arraylength:
    28803028            {
    2881               type t = pop_type (reference_type);
     3029              type t = pop_ (reference_type);
    28823030              if (! t.isarray () && ! t.isnull ())
    28833031                verify_fail ("array type expected");
     
    28903038            break;
    28913039          case op_checkcast:
    2892             pop_type (reference_type);
     3040            pop_ (reference_type);
    28933041            push_type (check_class_constant (get_ushort ()));
    28943042            break;
    28953043          case op_instanceof:
    2896             pop_type (reference_type);
     3044            pop_ (reference_type);
    28973045            check_class_constant (get_ushort ());
    28983046            push_type (int_type);
    28993047            break;
    29003048          case op_monitorenter:
    2901             pop_type (reference_type);
     3049            pop_ (reference_type);
    29023050            break;
    29033051          case op_monitorexit:
    2904             pop_type (reference_type);
     3052            pop_ (reference_type);
    29053053            break;
    29063054          case op_wide:
     
    29363084                  break;
    29373085                case op_astore:
    2938                   set_variable (get_ushort (), pop_type (reference_type));
     3086                  set_variable (get_ushort (), pop_ (reference_type));
    29393087                  break;
    29403088                case op_ret:
     
    29753123            break;
    29763124
     3125
     3126
     3127
     3128
     3129
     3130
     3131
     3132
     3133
     3134
     3135
     3136
     3137
     3138
     3139
     3140
     3141
     3142
     3143
     3144
     3145
     3146
     3147
     3148
    29773149          default:
    29783150            // Unrecognized opcode.
     
    29813153          }
    29823154      }
    2983   }
    2984 
    2985   __attribute__ ((__noreturn__)) void verify_fail (char *s, jint pc = -1)
    2986   {
    2987     using namespace java::lang;
    2988     StringBuffer *buf = new StringBuffer ();
    2989 
    2990     buf->append (JvNewStringLatin1 ("verification failed"));
    2991     if (pc == -1)
    2992       pc = start_PC;
    2993     if (pc != -1)
    2994       {
    2995         buf->append (JvNewStringLatin1 (" at PC "));
    2996         buf->append (pc);
    2997       }
    2998 
    2999     _Jv_InterpMethod *method = current_method;
    3000     buf->append (JvNewStringLatin1 (" in "));
    3001     buf->append (current_class->getName());
    3002     buf->append ((jchar) ':');
    3003     buf->append (JvNewStringUTF (method->get_method()->name->data));
    3004     buf->append ((jchar) '(');
    3005     buf->append (JvNewStringUTF (method->get_method()->signature->data));
    3006     buf->append ((jchar) ')');
    3007 
    3008     buf->append (JvNewStringLatin1 (": "));
    3009     buf->append (JvNewStringLatin1 (s));
    3010     throw new java::lang::VerifyError (buf->toString ());
    30113155  }
    30123156
Note: See TracChangeset for help on using the changeset viewer.