LCOV - code coverage report
Current view: top level - vm/jit - parse.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 571 669 85.4 %
Date: 2017-07-14 10:03:36 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /* src/vm/jit/parse.cpp - parser for JavaVM to intermediate code translation
       2             : 
       3             :    Copyright (C) 1996-2014
       4             :    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
       5             : 
       6             :    This file is part of CACAO.
       7             : 
       8             :    This program is free software; you can redistribute it and/or
       9             :    modify it under the terms of the GNU General Public License as
      10             :    published by the Free Software Foundation; either version 2, or (at
      11             :    your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful, but
      14             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16             :    General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program; if not, write to the Free Software
      20             :    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
      21             :    02110-1301, USA.
      22             : 
      23             : */
      24             : 
      25             : #include "vm/jit/parse.hpp"
      26             : #include <assert.h>                     // for assert
      27             : #include <string.h>                     // for NULL
      28             : #include "config.h"                     // for ENABLE_VERIFIER, etc
      29             : #include "native/native.hpp"
      30             : #include "mm/dumpmemory.hpp"            // for DumpMemory
      31             : #include "threads/lock.hpp"
      32             : #include "toolbox/endianess.hpp"
      33             : #include "toolbox/logging.hpp"
      34             : #include "vm/breakpoint.hpp"            // for BreakpointTable
      35             : #include "vm/class.hpp"                 // for class_getconstant, etc
      36             : #include "vm/descriptor.hpp"            // for methoddesc
      37             : #include "vm/exceptions.hpp"
      38             : #include "vm/global.hpp"
      39             : #include "vm/jit/builtin.hpp"           // for builtintable_get_internal
      40             : #include "vm/jit/code.hpp"              // for code_unflag_leafmethod
      41             : #include "vm/jit/ir/bytecode.hpp"       // for ::BC_aload_0, ::BC_astore_0, etc
      42             : #include "vm/jit/ir/icmd.hpp"           // for ::ICMD_NOP, ::ICMD_BUILTIN, etc
      43             : #include "vm/jit/ir/instruction.hpp"    // for instruction, etc
      44             : #include "vm/jit/jit.hpp"               // for jitdata, basicblock, etc
      45             : #include "vm/jit/parse.hpp"
      46             : #include "vm/jit/reg.hpp"               // for varinfo
      47             : #include "vm/jit/stack.hpp"             // for stackelement_t
      48             : #include "vm/linker.hpp"
      49             : #include "vm/loader.hpp"                // for constant_double, etc
      50             : #include "vm/method.hpp"                // for methodinfo, etc
      51             : #include "vm/options.hpp"               // for checksync
      52             : #include "vm/references.hpp"            // for classref_or_classinfo, etc
      53             : #include "vm/resolve.hpp"               // for resolve_classref, etc
      54             : #include "vm/statistics.hpp"
      55             : #include "vm/string.hpp"                // for JavaString
      56             : #include "vm/suck.hpp"
      57             : #include "vm/types.hpp"                 // for s4, u1, u2, u4
      58             : #include "vm/utf8.hpp"                  // for Utf8String
      59             : 
      60             : struct parsedata_t;
      61             : struct utf;
      62             : 
      63             : using namespace cacao;
      64             : 
      65             : 
      66             : /* macros for verifier checks during parsing **********************************/
      67             : 
      68             : #if defined(ENABLE_VERIFIER)
      69             : 
      70             : /* We have to check local variables indices here because they are             */
      71             : /* used in stack.c to index the locals array.                                 */
      72             : 
      73             : #define INDEX_ONEWORD(num) \
      74             :         do { \
      75             :                 if (((num) < 0) || ((num) >= m->maxlocals)) \
      76             :                 goto throw_illegal_local_variable_number; \
      77             :         } while (0)
      78             : 
      79             : #define INDEX_TWOWORD(num) \
      80             :         do { \
      81             :                 if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
      82             :                         goto throw_illegal_local_variable_number; \
      83             :         } while (0)
      84             : 
      85             : /* CHECK_BYTECODE_INDEX(i) checks whether i is a valid bytecode index.        */
      86             : /* The end of the bytecode (i == m->jcodelength) is considered valid.         */
      87             : 
      88             : #define CHECK_BYTECODE_INDEX(i) \
      89             :     do { \
      90             :         if (((i) < 0) || ((i) >= m->jcodelength)) \
      91             :                         goto throw_invalid_bytecode_index; \
      92             :     } while (0)
      93             : 
      94             : /* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends               */
      95             : /* of exception handler ranges.                                                */
      96             : #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
      97             :     do { \
      98             :         if ((i) < 0 || (i) > m->jcodelength) \
      99             :                         goto throw_invalid_bytecode_index; \
     100             :     } while (0)
     101             : 
     102             : #else /* !defined(ENABLE_VERIFIER) */
     103             : 
     104             : #define INDEX_ONEWORD(num)
     105             : #define INDEX_TWOWORD(num)
     106             : #define CHECK_BYTECODE_INDEX(i)
     107             : #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
     108             : 
     109             : #endif /* defined(ENABLE_VERIFIER) */
     110             : 
     111             : 
     112             : /* basic block generating macro ***********************************************/
     113             : 
     114             : #define MARK_BASICBLOCK(pd, i)                                       \
     115             :     do {                                                             \
     116             :         (pd)->basicblockstart[(i)] = 1;                              \
     117             :     } while (0)
     118             : 
     119             : #define INSTRUCTIONS_CHECK(i)                                        \
     120             :     if ((ircount + (i)) > pd.instructionslength)                     \
     121             :         iptr = parse_realloc_instructions(&pd, ircount, (i))
     122             : 
     123             : 
     124             : /* intermediate code generating macros ****************************************/
     125             : 
     126             : /* These macros ALWAYS set the following fields of *iptr to valid values:     */
     127             : /*     iptr->opc                                                              */
     128             : /*     iptr->flags                                                            */
     129             : /*     iptr->line                                                             */
     130             : 
     131             : /* These macros do NOT touch the following fields of *iptr, unless a value is */
     132             : /* given for them:                                                            */
     133             : /*     iptr->s1                                                               */
     134             : /*     iptr->sx                                                               */
     135             : /*     iptr->dst                                                              */
     136             : 
     137             : /* The _PREPARE macros omit the PINC, so you can set additional fields        */
     138             : /* afterwards.                                                                */
     139             : 
     140             : #define PINC                                                         \
     141             :     iptr++; ircount++
     142             : 
     143             : #define OP_PREPARE_FLAGS(o, f)                                       \
     144             :     iptr->opc         = (ICMD) (o);                                  \
     145             :     iptr->line        = currentline;                                 \
     146             :     iptr->flags.bits |= (f) | (ircount << INS_FLAG_ID_SHIFT);
     147             : 
     148             : #define OP_PREPARE_ZEROFLAGS(o)                                      \
     149             :     OP_PREPARE_FLAGS(o, 0)
     150             : 
     151             : #define OP_PREPARE(o)                                                \
     152             :     OP_PREPARE_ZEROFLAGS(o)
     153             : 
     154             : #define OP(o)                                                        \
     155             :     OP_PREPARE_ZEROFLAGS(o);                                         \
     156             :     PINC
     157             : 
     158             : #define OP_CHECK_EXCEPTION(o)                                        \
     159             :     OP_PREPARE_FLAGS(o, INS_FLAG_CHECK);                             \
     160             :     PINC
     161             : 
     162             : #define OP_LOADCONST_I(v)                                            \
     163             :     OP_PREPARE_ZEROFLAGS(ICMD_ICONST);                               \
     164             :     iptr->sx.val.i           = (v);                                  \
     165             :     PINC
     166             : 
     167             : #define OP_LOADCONST_L(v)                                            \
     168             :     OP_PREPARE_ZEROFLAGS(ICMD_LCONST);                               \
     169             :     iptr->sx.val.l           = (v);                                  \
     170             :     PINC
     171             : 
     172             : #define OP_LOADCONST_F(v)                                            \
     173             :     OP_PREPARE_ZEROFLAGS(ICMD_FCONST);                               \
     174             :     iptr->sx.val.f           = (v);                                  \
     175             :     PINC
     176             : 
     177             : #define OP_LOADCONST_D(v)                                            \
     178             :     OP_PREPARE_ZEROFLAGS(ICMD_DCONST);                               \
     179             :     iptr->sx.val.d           = (v);                                  \
     180             :     PINC
     181             : 
     182             : #define OP_LOADCONST_NULL()                                          \
     183             :     OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK);                   \
     184             :     iptr->sx.val.anyptr      = NULL;                                 \
     185             :     PINC
     186             : 
     187             : #define OP_LOADCONST_STRING(v)                                       \
     188             :     OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK);                   \
     189             :     iptr->sx.val.stringconst = (v);                                  \
     190             :     PINC
     191             : 
     192             : #define OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS(cl, cr, extraflags) \
     193             :     OP_PREPARE(ICMD_ACONST);                                         \
     194             :     if (cl) {                                                        \
     195             :         iptr->sx.val.c.cls   = (cl);                                 \
     196             :         iptr->flags.bits     |= INS_FLAG_CLASS | (extraflags);       \
     197             :     }                                                                \
     198             :     else {                                                           \
     199             :         iptr->sx.val.c.ref   = (cr);                                 \
     200             :         iptr->flags.bits     |= INS_FLAG_CLASS | INS_FLAG_UNRESOLVED \
     201             :                              | (extraflags);                         \
     202             :     }                                                                \
     203             :     PINC
     204             : 
     205             : #define OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr)              \
     206             :     OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), INS_FLAG_CHECK)
     207             : 
     208             : #define OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr)            \
     209             :     OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), 0)
     210             : 
     211             : #define OP_S3_CLASSINFO_OR_CLASSREF(o, c, cr, extraflags)            \
     212             :     OP_PREPARE(o);                                                   \
     213             :     if (c) {                                                         \
     214             :         iptr->sx.s23.s3.c.cls= (c);                                  \
     215             :         iptr->flags.bits     |= (extraflags);                        \
     216             :     }                                                                \
     217             :     else {                                                           \
     218             :         iptr->sx.s23.s3.c.ref= (cr);                                 \
     219             :         iptr->flags.bits     |= INS_FLAG_UNRESOLVED | (extraflags);  \
     220             :     }                                                                \
     221             :     PINC
     222             : 
     223             : #define OP_INSINDEX(o, iindex)                                       \
     224             :     OP_PREPARE_ZEROFLAGS(o);                                         \
     225             :     iptr->dst.insindex       = (iindex);                             \
     226             :     PINC
     227             : 
     228             : # define OP_LOCALINDEX(o,index)                                      \
     229             :     OP_PREPARE_ZEROFLAGS(o);                                         \
     230             :     iptr->s1.varindex      = (index);                                \
     231             :     PINC
     232             : 
     233             : # define OP_LOCALINDEX_I(o,index,v)                                  \
     234             :     OP_PREPARE_ZEROFLAGS(o);                                         \
     235             :     iptr->s1.varindex      = (index);                                \
     236             :     iptr->sx.val.i           = (v);                                  \
     237             :     PINC
     238             : 
     239             : # define LOCALTYPE_USED(index,type)                                  \
     240             :     do {                                                             \
     241             :         local_map[(index) * 5 + (type)] = 1;                         \
     242             :     } while (0)
     243             : 
     244             : #define OP_LOAD_ONEWORD(o,index,type)                                \
     245             :     do {                                                             \
     246             :         INDEX_ONEWORD(index);                                        \
     247             :         OP_LOCALINDEX(o,index);                                      \
     248             :         LOCALTYPE_USED(index,type);                                  \
     249             :     } while (0)
     250             : 
     251             : #define OP_LOAD_TWOWORD(o,index,type)                                \
     252             :     do {                                                             \
     253             :         INDEX_TWOWORD(index);                                        \
     254             :         OP_LOCALINDEX(o,index);                                      \
     255             :         LOCALTYPE_USED(index,type);                                  \
     256             :     } while (0)
     257             : 
     258             : # define OP_STORE_ONEWORD(o,index,type)                              \
     259             :     do {                                                             \
     260             :         INDEX_ONEWORD(index);                                        \
     261             :         OP_PREPARE_ZEROFLAGS(o);                                     \
     262             :         iptr->dst.varindex = (index);                                \
     263             :         LOCALTYPE_USED(index,type);                                  \
     264             :         PINC;                                                        \
     265             :     } while (0)
     266             : 
     267             : # define OP_STORE_TWOWORD(o,index,type)                              \
     268             :     do {                                                             \
     269             :         INDEX_TWOWORD(index);                                        \
     270             :         OP_PREPARE_ZEROFLAGS(o);                                     \
     271             :         iptr->dst.varindex = (index);                                \
     272             :         LOCALTYPE_USED(index,type);                                  \
     273             :         PINC;                                                        \
     274             :     } while (0)
     275             : 
     276             : #define OP_BUILTIN_CHECK_EXCEPTION(BTE)                              \
     277             :     code_unflag_leafmethod(code);                                    \
     278             :     OP_PREPARE_FLAGS(ICMD_BUILTIN, INS_FLAG_CHECK);                  \
     279             :     iptr->sx.s23.s3.bte      = (BTE);                                \
     280             :     PINC
     281             : 
     282             : #define OP_BUILTIN_NO_EXCEPTION(BTE)                                 \
     283             :     code_unflag_leafmethod(code);                                    \
     284             :     OP_PREPARE_ZEROFLAGS(ICMD_BUILTIN);                              \
     285             :     iptr->sx.s23.s3.bte      = (BTE);                                \
     286             :     PINC
     287             : 
     288             : #define OP_BUILTIN_ARITHMETIC(opcode, BTE)                           \
     289             :     code_unflag_leafmethod(code);                                    \
     290             :     OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK);                        \
     291             :     iptr->sx.s23.s3.bte      = (BTE);                                \
     292             :     PINC
     293             : 
     294             : /* CAUTION: You must set iptr->flags yourself when using this!                */
     295             : #define OP_FMIREF_PREPARE(o, FMIREF)                                 \
     296             :     OP_PREPARE(o);                                                   \
     297             :     iptr->sx.s23.s3.fmiref   = (FMIREF);
     298             : 
     299             : 
     300             : #define INSTRUCTIONS_INCREMENT  5  /* number of additional instructions to    */
     301             :                                    /* allocate if space runs out              */
     302             : 
     303             : 
     304             : /* local macros ***************************************************************/
     305             : 
     306             : #define BYTECODEINDEX_TO_BASICBLOCK(dst) \
     307             :     do { \
     308             :         (dst).block = \
     309             :             parse_bytecodeindex_to_basicblock(jd, &pd, (dst).insindex); \
     310             :     } while (0)
     311             : 
     312             : 
     313             : /* parserdata_t ***************************************************************/
     314             : 
     315             : typedef struct parsedata_t parsedata_t;
     316             : 
     317             : struct parsedata_t {
     318             :         u1          *bytecodestart;         /* start of bytecode instructions     */
     319             :         u1          *basicblockstart;       /* start of bytecode basic-blocks     */
     320             : 
     321             :         s4          *bytecodemap;           /* bytecode to IR mapping             */
     322             : 
     323             :         instruction *instructions;          /* instruction array                  */
     324             :         s4           instructionslength;    /* length of the instruction array    */
     325             : 
     326             :         s4          *instructionmap;        /* IR to basic-block mapping          */
     327             : };
     328             : 
     329             : /* parse_setup *****************************************************************
     330             : 
     331             :    Fills the passed parsedata_t structure.
     332             : 
     333             : *******************************************************************************/
     334             : 
     335       86435 : static void parse_setup(jitdata *jd, parsedata_t *pd)
     336             : {
     337             :         methodinfo *m;
     338             : 
     339             :         /* get required compiler data */
     340             : 
     341       86435 :         m = jd->m;
     342             : 
     343             :         /* bytecode start array */
     344             : 
     345       86435 :         pd->bytecodestart = (u1*) DumpMemory::allocate(sizeof(u1) * (m->jcodelength + 1));
     346       86435 :         MZERO(pd->bytecodestart, u1, m->jcodelength + 1);
     347             : 
     348             :         /* bytecode basic-block start array */
     349             : 
     350       86435 :         pd->basicblockstart = (u1*) DumpMemory::allocate(sizeof(u1) *(m->jcodelength + 1));
     351       86435 :         MZERO(pd->basicblockstart, u1, m->jcodelength + 1);
     352             : 
     353             :         /* bytecode instruction index to IR instruction mapping */
     354             : 
     355       86435 :         pd->bytecodemap = (s4*) DumpMemory::allocate(sizeof(s4) * (m->jcodelength + 1));
     356       86435 :         MSET(pd->bytecodemap, -1, s4, m->jcodelength + 1);
     357             : 
     358             :         /* allocate the instruction array */
     359             : 
     360       86435 :         pd->instructionslength = m->jcodelength + 1;
     361       86435 :         pd->instructions = (instruction*) DumpMemory::allocate(sizeof(instruction) * pd->instructionslength);
     362             : 
     363             :         /* Zero the intermediate instructions array so we don't have any
     364             :            invalid pointers in it if we cannot finish stack_analyse(). */
     365             : 
     366       86435 :         MZERO(pd->instructions, instruction, pd->instructionslength);
     367             : 
     368             :         /* The instructionmap is allocated later when we know the count of
     369             :            instructions. */
     370             : 
     371       86435 :         pd->instructionmap = NULL;
     372       86435 : }
     373             : 
     374             : 
     375             : /* parse_realloc_instructions **************************************************
     376             : 
     377             :    Reallocate the instructions array so there is room for at least N
     378             :    additional instructions.
     379             : 
     380             :    RETURN VALUE:
     381             :        the new value for iptr
     382             : 
     383             : *******************************************************************************/
     384             : 
     385         151 : static instruction *parse_realloc_instructions(parsedata_t *pd, s4 icount, s4 n)
     386             : {
     387             :         /* increase the size of the instruction array */
     388             : 
     389         151 :         pd->instructionslength += (n + INSTRUCTIONS_INCREMENT);
     390             : 
     391             :         /* reallocate the array */
     392             : 
     393             :         pd->instructions = (instruction*) DumpMemory::reallocate(pd->instructions, sizeof(instruction) * icount,
     394         151 :                                                                  sizeof(instruction) * pd->instructionslength);
     395             :         MZERO(pd->instructions + icount, instruction,
     396         151 :                   (pd->instructionslength - icount));
     397             : 
     398             :         /* return the iptr */
     399             : 
     400         151 :         return pd->instructions + icount;
     401             : }
     402             : 
     403             : 
     404             : /* parse_bytecodeindex_to_basicblock *******************************************
     405             : 
     406             :    Resolves a bytecode index to the corresponding basic block.
     407             : 
     408             : *******************************************************************************/
     409             : 
     410      183609 : static basicblock *parse_bytecodeindex_to_basicblock(jitdata *jd,
     411             :                                                                                                          parsedata_t *pd,
     412             :                                                                                                          s4 bcindex)
     413             : {
     414             :         s4          irindex;
     415             :         basicblock *bb;
     416             : 
     417      183609 :         irindex = pd->bytecodemap[bcindex];
     418      183609 :         bb      = jd->basicblocks + pd->instructionmap[irindex];
     419             : 
     420      183609 :         return bb;
     421             : }
     422             : 
     423             : 
     424             : /* parse_mark_exception_boundaries *********************************************
     425             : 
     426             :    Mark exception handlers and the boundaries of the handled regions as
     427             :    basic block boundaries.
     428             : 
     429             :    IN:
     430             :        jd...............current jitdata
     431             : 
     432             :    RETURN VALUE:
     433             :        true.............everything ok
     434             :            false............an exception has been thrown
     435             : 
     436             : *******************************************************************************/
     437             : 
     438       86435 : static bool parse_mark_exception_boundaries(jitdata *jd, parsedata_t *pd)
     439             : {
     440             :         s4                   bcindex;
     441             :         s4                   len;
     442             :         raw_exception_entry *rex;
     443             :         methodinfo          *m;
     444             : 
     445       86435 :         m = jd->m;
     446             : 
     447       86435 :         len = m->rawexceptiontablelength;
     448             : 
     449       86435 :         if (len == 0)
     450       80880 :                 return true;
     451             : 
     452        5555 :         rex = m->rawexceptiontable;
     453             : 
     454       19248 :         for (s4 i = 0; i < len; ++i, ++rex) {
     455             : 
     456             :                 /* the start of the handled region becomes a basic block start */
     457             : 
     458       13693 :                 bcindex = rex->startpc;
     459       13693 :                 CHECK_BYTECODE_INDEX(bcindex);
     460       13693 :                 MARK_BASICBLOCK(pd, bcindex);
     461             : 
     462       13693 :                 bcindex = rex->endpc; /* see JVM Spec 4.7.3 */
     463       13693 :                 CHECK_BYTECODE_INDEX_EXCLUSIVE(bcindex);
     464             : 
     465             :                 /* check that the range is valid */
     466             : 
     467             : #if defined(ENABLE_VERIFIER)
     468       13693 :                 if (bcindex <= rex->startpc) {
     469           0 :                         exceptions_throw_verifyerror(m, "Invalid exception handler range");
     470           0 :                         return false;
     471             :                 }
     472             : #endif
     473             : 
     474             :                 /* End of handled region becomes a basic block boundary (if it
     475             :                    is the bytecode end, we'll use the special end block that
     476             :                    is created anyway). */
     477             : 
     478       13693 :                 if (bcindex < m->jcodelength)
     479       13693 :                         MARK_BASICBLOCK(pd, bcindex);
     480             :                 else
     481           0 :                         jd->branchtoend = true;
     482             : 
     483             :                 /* the start of the handler becomes a basic block start  */
     484             : 
     485       13693 :                 bcindex = rex->handlerpc;
     486       13693 :                 CHECK_BYTECODE_INDEX(bcindex);
     487       13693 :                 MARK_BASICBLOCK(pd, bcindex);
     488             :         }
     489             : 
     490             :         /* everything ok */
     491             : 
     492        5555 :         return true;
     493             : 
     494             : #if defined(ENABLE_VERIFIER)
     495             : throw_invalid_bytecode_index:
     496             :         exceptions_throw_verifyerror(m,
     497           0 :                                                                  "Illegal bytecode index in exception table");
     498           0 :         return false;
     499             : #endif
     500             : }
     501             : 
     502             : 
     503             : /* parse_resolve_exception_table ***********************************************
     504             : 
     505             :    Enter the exception handlers and their ranges, resolved to basicblock *s,
     506             :    in the jitdata.
     507             : 
     508             :    IN:
     509             :        jd...............current jitdata
     510             : 
     511             :    RETURN VALUE:
     512             :            true.............everything ok
     513             :            false............an exception has been thrown
     514             : 
     515             : *******************************************************************************/
     516             : 
     517       86432 : static bool parse_resolve_exception_table(jitdata *jd, parsedata_t *pd)
     518             : {
     519             :         methodinfo          *m;
     520             :         raw_exception_entry *rex;
     521             :         exception_entry     *ex;
     522             :         s4                   len;
     523             :         classinfo           *exclass;
     524             : 
     525       86432 :         m = jd->m;
     526             : 
     527       86432 :         len = m->rawexceptiontablelength;
     528             : 
     529             :         /* common case: no handler entries */
     530             : 
     531       86432 :         if (len == 0)
     532       80877 :                 return true;
     533             : 
     534             :         /* allocate the exception table */
     535             : 
     536        5555 :         jd->exceptiontablelength = len;
     537        5555 :         jd->exceptiontable = (exception_entry*) DumpMemory::allocate(sizeof(exception_entry) * (len + 1)); /* XXX why +1? */
     538             : 
     539             :         /* copy and resolve the entries */
     540             : 
     541        5555 :         ex = jd->exceptiontable;
     542        5555 :         rex = m->rawexceptiontable;
     543             : 
     544       19248 :         for (s4 i = 0; i < len; ++i, ++rex, ++ex) {
     545             :                 /* resolve instruction indices to basic blocks */
     546             : 
     547       13693 :                 ex->start   = parse_bytecodeindex_to_basicblock(jd, pd, rex->startpc);
     548       13693 :                 ex->end     = parse_bytecodeindex_to_basicblock(jd, pd, rex->endpc);
     549       13693 :                 ex->handler = parse_bytecodeindex_to_basicblock(jd, pd, rex->handlerpc);
     550             : 
     551             :                 /* lazily resolve the catchtype */
     552             : 
     553       13693 :                 if (rex->catchtype.any != NULL) {
     554        7621 :                         if (!resolve_classref_or_classinfo(m,
     555             :                                                                                            rex->catchtype,
     556             :                                                                                            resolveLazy, true, false,
     557             :                                                                                            &exclass))
     558           0 :                                 return false;
     559             : 
     560             :                         /* if resolved, enter the result of resolution in the table */
     561             : 
     562        7621 :                         if (exclass != NULL)
     563        1670 :                                 rex->catchtype.cls = exclass;
     564             :                 }
     565             : 
     566       13693 :                 ex->catchtype = rex->catchtype;
     567       13693 :                 ex->next = NULL;   /* set by loop analysis */
     568       13693 :                 ex->down = ex + 1; /* link to next exception entry */
     569             :         }
     570             : 
     571             :         /* terminate the ->down linked list */
     572             : 
     573        5555 :         assert(ex != jd->exceptiontable);
     574        5555 :         ex[-1].down = NULL;
     575             : 
     576        5555 :         return true;
     577             : }
     578             : 
     579             : 
     580             : /*******************************************************************************
     581             : 
     582             :         function 'parse' scans the JavaVM code and generates intermediate code
     583             : 
     584             :         During parsing the block index table is used to store at bit pos 0
     585             :         a flag which marks basic block starts and at position 1 to 31 the
     586             :         intermediate instruction index. After parsing the block index table
     587             :         is scanned, for marked positions a block is generated and the block
     588             :         number is stored in the block index table.
     589             : 
     590             : *******************************************************************************/
     591             : 
     592             : /*** macro for checking the length of the bytecode ***/
     593             : 
     594             : #if defined(ENABLE_VERIFIER)
     595             : #define CHECK_END_OF_BYTECODE(neededlength) \
     596             :         do { \
     597             :                 if ((neededlength) > m->jcodelength) \
     598             :                         goto throw_unexpected_end_of_bytecode; \
     599             :         } while (0)
     600             : #else /* !ENABLE_VERIFIER */
     601             : #define CHECK_END_OF_BYTECODE(neededlength)
     602             : #endif /* ENABLE_VERIFIER */
     603             : 
     604       86435 : bool parse(jitdata *jd)
     605             : {
     606             :         methodinfo  *m;                     /* method being parsed                */
     607             :         codeinfo    *code;
     608             :         parsedata_t  pd;
     609             :         instruction *iptr;                  /* current ptr into instruction array */
     610             : 
     611             :         s4           bcindex;               /* bytecode instruction index         */
     612             :         s4           nextbc;                /* start of next bytecode instruction */
     613             : 
     614             :         s4           irindex;               /* IR instruction index               */
     615             :         s4           ircount;               /* IR instruction count               */
     616             : 
     617             :         s4           bbcount;               /* basic block count                  */
     618             : 
     619       86435 :         int  s_count = 0;             /* stack element counter                    */
     620             :         bool blockend;                /* true if basic block end has been reached */
     621             :         bool iswide;                  /* true if last instruction was a wide      */
     622             : 
     623             :         constant_FMIref    *fmi;
     624             :         methoddesc         *md;
     625             : 
     626       86435 :         u2                  lineindex    = 0;
     627       86435 :         u2                  currentline  = 0;
     628       86435 :         u2                  linepcchange = 0;
     629             :         basicblock         *bptr;
     630             : 
     631             :         int                *local_map; /* local pointer to renaming map           */
     632             :                                        /* is assigned to rd->local_map at the end */
     633             :         branch_target_t *table;
     634             :         lookup_target_t *lookup;
     635             :         s4               i;
     636             : 
     637             :         /* get required compiler data */
     638             : 
     639       86435 :         m    = jd->m;
     640       86435 :         code = jd->code;
     641             : 
     642             :         /* allocate buffers for local variable renaming */
     643             : 
     644       86435 :         local_map = (int*) DumpMemory::allocate(sizeof(int) * m->maxlocals * 5);
     645             : 
     646      291157 :         for (s4 i = 0; i < m->maxlocals; i++) {
     647      204722 :                 local_map[i * 5 + 0] = 0;
     648      204722 :                 local_map[i * 5 + 1] = 0;
     649      204722 :                 local_map[i * 5 + 2] = 0;
     650      204722 :                 local_map[i * 5 + 3] = 0;
     651      204722 :                 local_map[i * 5 + 4] = 0;
     652             :         }
     653             : 
     654             :         /* initialize the parse data structures */
     655             : 
     656       86435 :         parse_setup(jd, &pd);
     657             : 
     658             :         /* initialize local variables */
     659             : 
     660       86435 :         iptr     = pd.instructions;
     661       86435 :         ircount  = 0;
     662       86435 :         bbcount  = 0;
     663       86435 :         blockend = false;
     664       86435 :         iswide   = false;
     665             : 
     666             :         /* mark basic block boundaries for exception table */
     667             : 
     668       86435 :         if (!parse_mark_exception_boundaries(jd, &pd))
     669           0 :                 return false;
     670             : 
     671             :         /* initialize stack element counter */
     672             : 
     673       86435 :         s_count = 1 + m->rawexceptiontablelength;
     674             : 
     675             :         /* setup line number info */
     676             : 
     677       86435 :         currentline = 0;
     678       86435 :         linepcchange = 0;
     679             : 
     680       86435 :         if (m->linenumbercount == 0) {
     681         245 :                 lineindex = 0;
     682             :         }
     683             :         else {
     684       86190 :                 linepcchange = m->linenumbers[0].start_pc;
     685             :         }
     686             : 
     687             :         /*** LOOP OVER ALL BYTECODE INSTRUCTIONS **********************************/
     688             : 
     689     4204026 :         for (bcindex = 0; bcindex < m->jcodelength; bcindex = nextbc) {
     690             : 
     691             :                 /* mark this position as a valid bytecode instruction start */
     692             : 
     693     4117594 :                 pd.bytecodestart[bcindex] = 1;
     694             : 
     695             :                 /* change the current line number, if necessary */
     696             : 
     697             :                 /* XXX rewrite this using pointer arithmetic */
     698             : 
     699     4117594 :                 if (linepcchange == bcindex) {
     700      597931 :                         if (m->linenumbercount > lineindex) {
     701             : next_linenumber:
     702      597686 :                                 currentline = m->linenumbers[lineindex].line_number;
     703      597686 :                                 lineindex++;
     704      597686 :                                 if (lineindex < m->linenumbercount) {
     705      511496 :                                         linepcchange = m->linenumbers[lineindex].start_pc;
     706      511496 :                                         if (linepcchange == bcindex)
     707           0 :                                                 goto next_linenumber;
     708             :                                 }
     709             :                         }
     710             :                 }
     711             : 
     712             : fetch_opcode:
     713             :                 /* fetch next opcode  */
     714             : 
     715     4122566 :                 ByteCode opcode = (ByteCode) read_u1_be(m->jcode + bcindex);
     716             : 
     717             :                 /* If the previous instruction was a block-end instruction,
     718             :                    mark the current bytecode instruction as basic-block
     719             :                    starting instruction. */
     720             : 
     721             :                 /* NOTE: Some compilers put a BC_nop after a blockend
     722             :                    instruction. */
     723             : 
     724     4122566 :                 if (blockend && (opcode != BC_nop)) {
     725      176297 :                         MARK_BASICBLOCK(&pd, bcindex);
     726      176297 :                         blockend = false;
     727             :                 }
     728             : 
     729             :                 /* If the current bytecode instruction was marked as
     730             :                    basic-block starting instruction before (e.g. blockend,
     731             :                    forward-branch target), mark the current IR instruction
     732             :                    too. */
     733             : 
     734     4122566 :                 if (pd.basicblockstart[bcindex] != 0) {
     735             :                         /* We need a NOP as last instruction in each basic block
     736             :                            for basic block reordering (may be replaced with a GOTO
     737             :                            later). */
     738             : 
     739      232479 :                         INSTRUCTIONS_CHECK(1);
     740      232479 :                         OP(ICMD_NOP);
     741             :                 }
     742             : 
     743             :                 /* store intermediate instruction count (bit 0 mark block starts) */
     744             : 
     745     4122566 :                 pd.bytecodemap[bcindex] = ircount;
     746             : 
     747             :                 /* compute next instruction start */
     748             : 
     749     4122566 :                 nextbc = bcindex + bytecode[opcode].length;
     750             : 
     751     4122566 :                 CHECK_END_OF_BYTECODE(nextbc);
     752             : 
     753             :                 /* add stack elements produced by this instruction */
     754             : 
     755     4122566 :                 s_count += bytecode[opcode].slots;
     756             : 
     757             :                 /* Generate a breakpoint instruction right before the actual
     758             :                    instruction, if the method contains a breakpoint at the
     759             :                    current bytecode index. */
     760             : 
     761     4122566 :                 if (m->breakpoints != NULL && m->breakpoints->contains(bcindex)) {
     762           0 :                         INSTRUCTIONS_CHECK(1);
     763           0 :                         OP_PREPARE_ZEROFLAGS(ICMD_BREAKPOINT);
     764           0 :                         iptr->sx.val.anyptr = m->breakpoints->get_breakpoint(bcindex);
     765           0 :                         PINC;
     766             :                 }
     767             : 
     768             :                 /* We check here for the space of 1 instruction in the
     769             :                    instruction array.  If an opcode is converted to more than
     770             :                    1 instruction, this is checked in the corresponding
     771             :                    case. */
     772             : 
     773     4122566 :                 INSTRUCTIONS_CHECK(1);
     774             : 
     775             :                 /* translate this bytecode instruction */
     776     4122566 :                 switch (opcode) {
     777             : 
     778             :                 case BC_nop:
     779           1 :                         break;
     780             : 
     781             :                 /* pushing constants onto the stack ***********************************/
     782             : 
     783             :                 case BC_bipush:
     784      564055 :                         OP_LOADCONST_I(read_s1_be(m->jcode + bcindex + 1));
     785      564055 :                         break;
     786             : 
     787             :                 case BC_sipush:
     788      502888 :                         OP_LOADCONST_I(read_s2_be(m->jcode + bcindex + 1));
     789      502888 :                         break;
     790             : 
     791             :                 case BC_ldc1:
     792       96839 :                         i = read_u1_be(m->jcode + bcindex + 1);
     793       96839 :                         goto pushconstantitem;
     794             : 
     795             :                 case BC_ldc2:
     796             :                 case BC_ldc2w:
     797        7991 :                         i = read_u2_be(m->jcode + bcindex + 1);
     798             :                         // fallthrough!
     799             : 
     800             :                 pushconstantitem:
     801             : 
     802             : #if defined(ENABLE_VERIFIER)
     803      104830 :                         if (i >= m->clazz->cpcount) {
     804             :                                 exceptions_throw_verifyerror(m,
     805           0 :                                         "Attempt to access constant outside range");
     806           0 :                                 return false;
     807             :                         }
     808             : #endif
     809             : 
     810      104830 :                         switch (m->clazz->cptags[i]) {
     811             :                         case CONSTANT_Integer:
     812        9332 :                                 OP_LOADCONST_I(*reinterpret_cast<int32_t*>(m->clazz->cpinfos[i]));
     813        9332 :                                 break;
     814             :                         case CONSTANT_Long:
     815         584 :                                 OP_LOADCONST_L(*reinterpret_cast<int64_t*>(m->clazz->cpinfos[i]));
     816         584 :                                 break;
     817             :                         case CONSTANT_Float:
     818        1987 :                                 OP_LOADCONST_F(*reinterpret_cast<float*>(m->clazz->cpinfos[i]));
     819        1987 :                                 break;
     820             :                         case CONSTANT_Double:
     821         131 :                                 OP_LOADCONST_D(*reinterpret_cast<double*>(m->clazz->cpinfos[i]));
     822         131 :                                 break;
     823             :                         case CONSTANT_String:
     824       91108 :                                 OP_LOADCONST_STRING(JavaString::literal((utf *) (m->clazz->cpinfos[i])));
     825       91108 :                                 break;
     826             :                         case CONSTANT_Class: {
     827        1688 :                                 constant_classref *cr = (constant_classref *) (m->clazz->cpinfos[i]);
     828             : 
     829             :                                 classinfo *c;
     830        1688 :                                 if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
     831           0 :                                         return false;
     832             : 
     833             :                                 /* if not resolved, c == NULL */
     834             : 
     835        1688 :                                 OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr);
     836             : 
     837        1688 :                                 break;
     838             :                         }
     839             : 
     840             : #if defined(ENABLE_VERIFIER)
     841             :                         default:
     842           0 :                                 exceptions_throw_verifyerror(m, "Invalid constant type to push: %u", m->clazz->cptags[i]);
     843           0 :                                 return false;
     844             : #endif
     845             :                         }
     846      104830 :                         break;
     847             : 
     848             :                 case BC_aconst_null:
     849       16156 :                         OP_LOADCONST_NULL();
     850       16156 :                         break;
     851             : 
     852             :                 case BC_iconst_m1:
     853             :                 case BC_iconst_0:
     854             :                 case BC_iconst_1:
     855             :                 case BC_iconst_2:
     856             :                 case BC_iconst_3:
     857             :                 case BC_iconst_4:
     858             :                 case BC_iconst_5:
     859      132378 :                         OP_LOADCONST_I(opcode - BC_iconst_0);
     860      132378 :                         break;
     861             : 
     862             :                 case BC_lconst_0:
     863             :                 case BC_lconst_1:
     864        5417 :                         OP_LOADCONST_L(opcode - BC_lconst_0);
     865        5417 :                         break;
     866             : 
     867             :                 case BC_fconst_0:
     868             :                 case BC_fconst_1:
     869             :                 case BC_fconst_2:
     870        2959 :                         OP_LOADCONST_F(opcode - BC_fconst_0);
     871        2959 :                         break;
     872             : 
     873             :                 case BC_dconst_0:
     874             :                 case BC_dconst_1:
     875         104 :                         OP_LOADCONST_D(opcode - BC_dconst_0);
     876         104 :                         break;
     877             : 
     878             :                 /* stack operations ***************************************************/
     879             : 
     880             :                 /* We need space for additional instruction so we can
     881             :                    translate these instructions to sequences of ICMD_COPY and
     882             :                    ICMD_MOVE instructions. */
     883             : 
     884             :                 case BC_dup_x1:
     885        2468 :                         INSTRUCTIONS_CHECK(4);
     886        2468 :                         OP(opcode);
     887        2468 :                         OP(ICMD_NOP);
     888        2468 :                         OP(ICMD_NOP);
     889        2468 :                         OP(ICMD_NOP);
     890        2468 :                         break;
     891             : 
     892             :                 case BC_dup_x2:
     893          76 :                         INSTRUCTIONS_CHECK(6);
     894          76 :                         OP(opcode);
     895          76 :                         OP(ICMD_NOP);
     896          76 :                         OP(ICMD_NOP);
     897          76 :                         OP(ICMD_NOP);
     898          76 :                         OP(ICMD_NOP);
     899          76 :                         OP(ICMD_NOP);
     900          76 :                         break;
     901             : 
     902             :                 case BC_dup2:
     903         247 :                         INSTRUCTIONS_CHECK(2);
     904         247 :                         OP(opcode);
     905         247 :                         OP(ICMD_NOP);
     906         247 :                         break;
     907             : 
     908             :                 case BC_dup2_x1:
     909          66 :                         INSTRUCTIONS_CHECK(7);
     910          66 :                         OP(opcode);
     911          66 :                         OP(ICMD_NOP);
     912          66 :                         OP(ICMD_NOP);
     913          66 :                         OP(ICMD_NOP);
     914          66 :                         OP(ICMD_NOP);
     915          66 :                         OP(ICMD_NOP);
     916          66 :                         OP(ICMD_NOP);
     917          66 :                         break;
     918             : 
     919             :                 case BC_dup2_x2:
     920          61 :                         INSTRUCTIONS_CHECK(9);
     921          61 :                         OP(opcode);
     922          61 :                         OP(ICMD_NOP);
     923          61 :                         OP(ICMD_NOP);
     924          61 :                         OP(ICMD_NOP);
     925          61 :                         OP(ICMD_NOP);
     926          61 :                         OP(ICMD_NOP);
     927          61 :                         OP(ICMD_NOP);
     928          61 :                         OP(ICMD_NOP);
     929          61 :                         OP(ICMD_NOP);
     930          61 :                         break;
     931             : 
     932             :                 case BC_swap:
     933         120 :                         INSTRUCTIONS_CHECK(3);
     934         120 :                         OP(opcode);
     935         120 :                         OP(ICMD_NOP);
     936         120 :                         OP(ICMD_NOP);
     937         120 :                         break;
     938             : 
     939             :                 /* local variable access instructions *********************************/
     940             : 
     941             :                 case BC_iload:
     942             :                 case BC_fload:
     943             :                 case BC_aload: {
     944             :                         int i; // must be signed because of OP_LOAD_ONEWORD
     945             : 
     946             : 
     947       88348 :                         if (iswide == false) {
     948       88343 :                                 i = read_u1_be(m->jcode + bcindex + 1);
     949             :                         }
     950             :                         else {
     951           5 :                                 i      = read_u2_be(m->jcode + bcindex + 1);
     952           5 :                                 nextbc = bcindex + 3;
     953           5 :                                 iswide = false;
     954             :                         }
     955       88348 :                         OP_LOAD_ONEWORD(opcode, i, opcode - BC_iload);
     956       88348 :                         break;
     957             :                 }
     958             : 
     959             :                 case BC_lload:
     960             :                 case BC_dload: {
     961             :                         int i; // must be signed because of OP_LOAD_ONEWORD
     962             : 
     963         369 :                         if (iswide == false) {
     964         367 :                                 i = read_u1_be(m->jcode + bcindex + 1);
     965             :                         }
     966             :                         else {
     967           2 :                                 i      = read_u2_be(m->jcode + bcindex + 1);
     968           2 :                                 nextbc = bcindex + 3;
     969           2 :                                 iswide = false;
     970             :                         }
     971         369 :                         OP_LOAD_TWOWORD(opcode, i, opcode - BC_iload);
     972         369 :                         break;
     973             :                 }
     974             : 
     975             :                 case BC_iload_0:
     976             :                 case BC_iload_1:
     977             :                 case BC_iload_2:
     978             :                 case BC_iload_3:
     979       72266 :                         OP_LOAD_ONEWORD(ICMD_ILOAD, opcode - BC_iload_0, TYPE_INT);
     980       72266 :                         break;
     981             : 
     982             :                 case BC_lload_0:
     983             :                 case BC_lload_1:
     984             :                 case BC_lload_2:
     985             :                 case BC_lload_3:
     986         961 :                         OP_LOAD_TWOWORD(ICMD_LLOAD, opcode - BC_lload_0, TYPE_LNG);
     987         961 :                         break;
     988             : 
     989             :                 case BC_fload_0:
     990             :                 case BC_fload_1:
     991             :                 case BC_fload_2:
     992             :                 case BC_fload_3:
     993        2520 :                         OP_LOAD_ONEWORD(ICMD_FLOAD, opcode - BC_fload_0, TYPE_FLT);
     994        2520 :                         break;
     995             : 
     996             :                 case BC_dload_0:
     997             :                 case BC_dload_1:
     998             :                 case BC_dload_2:
     999             :                 case BC_dload_3:
    1000         197 :                         OP_LOAD_TWOWORD(ICMD_DLOAD, opcode - BC_dload_0, TYPE_DBL);
    1001         197 :                         break;
    1002             : 
    1003             :                 case BC_aload_0:
    1004             :                 case BC_aload_1:
    1005             :                 case BC_aload_2:
    1006             :                 case BC_aload_3:
    1007      347523 :                         OP_LOAD_ONEWORD(ICMD_ALOAD, opcode - BC_aload_0, TYPE_ADR);
    1008      347523 :                         break;
    1009             : 
    1010             :                 case BC_istore:
    1011             :                 case BC_fstore:
    1012             :                 case BC_astore: {
    1013             :                         int i; // must be signed because of OP_LOAD_ONEWORD
    1014             : 
    1015             : 
    1016       41057 :                         if (iswide == false) {
    1017       41052 :                                 i = read_u1_be(m->jcode + bcindex + 1);
    1018             :                         }
    1019             :                         else {
    1020           5 :                                 i = read_u2_be(m->jcode + bcindex + 1);
    1021           5 :                                 nextbc = bcindex + 3;
    1022           5 :                                 iswide = false;
    1023             :                         }
    1024       41057 :                         OP_STORE_ONEWORD(opcode, i, opcode - BC_istore);
    1025       41056 :                         break;
    1026             :                 }
    1027             : 
    1028             :                 case BC_lstore:
    1029             :                 case BC_dstore:
    1030        5114 :                         if (iswide == false) {
    1031         208 :                                 i = read_u1_be(m->jcode + bcindex + 1);
    1032             :                         }
    1033             :                         else {
    1034        4906 :                                 i = read_u2_be(m->jcode + bcindex + 1);
    1035        4906 :                                 nextbc = bcindex + 3;
    1036        4906 :                                 iswide = false;
    1037             :                         }
    1038        5114 :                         OP_STORE_TWOWORD(opcode, i, opcode - BC_istore);
    1039        5112 :                         break;
    1040             : 
    1041             :                 case BC_istore_0:
    1042             :                 case BC_istore_1:
    1043             :                 case BC_istore_2:
    1044             :                 case BC_istore_3:
    1045       16301 :                         OP_STORE_ONEWORD(ICMD_ISTORE, opcode - BC_istore_0, TYPE_INT);
    1046       16301 :                         break;
    1047             : 
    1048             :                 case BC_lstore_0:
    1049             :                 case BC_lstore_1:
    1050             :                 case BC_lstore_2:
    1051             :                 case BC_lstore_3:
    1052         107 :                         OP_STORE_TWOWORD(ICMD_LSTORE, opcode - BC_lstore_0, TYPE_LNG);
    1053         107 :                         break;
    1054             : 
    1055             :                 case BC_fstore_0:
    1056             :                 case BC_fstore_1:
    1057             :                 case BC_fstore_2:
    1058             :                 case BC_fstore_3:
    1059          12 :                         OP_STORE_ONEWORD(ICMD_FSTORE, opcode - BC_fstore_0, TYPE_FLT);
    1060          12 :                         break;
    1061             : 
    1062             :                 case BC_dstore_0:
    1063             :                 case BC_dstore_1:
    1064             :                 case BC_dstore_2:
    1065             :                 case BC_dstore_3:
    1066          10 :                         OP_STORE_TWOWORD(ICMD_DSTORE, opcode - BC_dstore_0, TYPE_DBL);
    1067          10 :                         break;
    1068             : 
    1069             :                 case BC_astore_0:
    1070             :                 case BC_astore_1:
    1071             :                 case BC_astore_2:
    1072             :                 case BC_astore_3:
    1073       32826 :                         OP_STORE_ONEWORD(ICMD_ASTORE, opcode - BC_astore_0, TYPE_ADR);
    1074       32826 :                         break;
    1075             : 
    1076             :                 case BC_iinc: {
    1077             :                         int i; // must be signed because of INDEX_ONEWORD
    1078             :                         int v;
    1079             : 
    1080       11445 :                         if (iswide == false) {
    1081       11391 :                                 i = read_u1_be(m->jcode + bcindex + 1);
    1082       11391 :                                 v = read_s1_be(m->jcode + bcindex + 2);
    1083             :                         } else {
    1084          54 :                                 i = read_u2_be(m->jcode + bcindex + 1);
    1085          54 :                                 v = read_s2_be(m->jcode + bcindex + 3);
    1086          54 :                                 nextbc = bcindex + 5;
    1087          54 :                                 iswide = false;
    1088             :                         }
    1089       11445 :                         INDEX_ONEWORD(i);
    1090       11445 :                         LOCALTYPE_USED(i, TYPE_INT);
    1091       11445 :                         OP_LOCALINDEX_I(opcode, i, v);
    1092       11445 :                         break;
    1093             :                 }
    1094             : 
    1095             :                 /* wider index for loading, storing and incrementing ******************/
    1096             : 
    1097             :                 case BC_wide:
    1098        4972 :                         bcindex++;
    1099        4972 :                         iswide = true;
    1100        4972 :                         goto fetch_opcode;
    1101             : 
    1102             :                 /* managing arrays ****************************************************/
    1103             : 
    1104             :                 case BC_newarray: {
    1105             :                         builtintable_entry *bte;
    1106        5657 :                         switch (read_s1_be(m->jcode + bcindex + 1)) {
    1107             :                         case 4:
    1108           3 :                                 bte = builtintable_get_internal(BUILTIN_newarray_boolean);
    1109           3 :                                 break;
    1110             :                         case 5:
    1111        3715 :                                 bte = builtintable_get_internal(BUILTIN_newarray_char);
    1112        3715 :                                 break;
    1113             :                         case 6:
    1114           6 :                                 bte = builtintable_get_internal(BUILTIN_newarray_float);
    1115           6 :                                 break;
    1116             :                         case 7:
    1117           6 :                                 bte = builtintable_get_internal(BUILTIN_newarray_double);
    1118           6 :                                 break;
    1119             :                         case 8:
    1120        1461 :                                 bte = builtintable_get_internal(BUILTIN_newarray_byte);
    1121        1461 :                                 break;
    1122             :                         case 9:
    1123          27 :                                 bte = builtintable_get_internal(BUILTIN_newarray_short);
    1124          27 :                                 break;
    1125             :                         case 10:
    1126         419 :                                 bte = builtintable_get_internal(BUILTIN_newarray_int);
    1127         419 :                                 break;
    1128             :                         case 11:
    1129          20 :                                 bte = builtintable_get_internal(BUILTIN_newarray_long);
    1130          20 :                                 break;
    1131             : #if defined(ENABLE_VERIFIER)
    1132             :                         default:
    1133           0 :                                 exceptions_throw_verifyerror(m, "Invalid array-type to create");
    1134           0 :                                 return false;
    1135             : #endif
    1136             :                         }
    1137        5657 :                         OP_BUILTIN_CHECK_EXCEPTION(bte);
    1138        5657 :                         break;
    1139             :                 }
    1140             : 
    1141             :                 case BC_anewarray: {
    1142        9150 :                         u2                 i     = read_u2_be(m->jcode + bcindex + 1);
    1143        9150 :                         constant_classref *compr = (constant_classref *) class_getconstant(m->clazz, i, CONSTANT_Class);
    1144             : 
    1145        9150 :                         if (compr == NULL)
    1146           0 :                                 return false;
    1147             : 
    1148        9150 :                         constant_classref *cr = class_get_classref_multiarray_of(1, compr);
    1149             : 
    1150        9150 :                         if (cr == NULL)
    1151           0 :                                 return false;
    1152             : 
    1153             :                         classinfo *c;
    1154        9150 :                         if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
    1155           0 :                                 return false;
    1156             : 
    1157        9150 :                         INSTRUCTIONS_CHECK(2);
    1158        9150 :                         OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
    1159        9150 :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_newarray);
    1160        9150 :                         OP_BUILTIN_CHECK_EXCEPTION(bte);
    1161        9150 :                         s_count++;
    1162        9150 :                         break;
    1163             :                 }
    1164             : 
    1165             :                 case BC_multianewarray: {
    1166          15 :                         u2 i = read_u2_be(m->jcode + bcindex + 1);
    1167          15 :                         u1 j = read_u1_be(m->jcode + bcindex + 3);
    1168             : 
    1169          15 :                         constant_classref *cr = (constant_classref *) class_getconstant(m->clazz, i, CONSTANT_Class);
    1170          15 :                         if (cr == NULL)
    1171           0 :                                 return false;
    1172             : 
    1173             :                         classinfo *c;
    1174          15 :                         if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
    1175           0 :                                 return false;
    1176             : 
    1177             :                         /* if unresolved, c == NULL */
    1178             : 
    1179          15 :                         iptr->s1.argcount = j;
    1180          15 :                         OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, INS_FLAG_CHECK);
    1181          15 :                         code_unflag_leafmethod(code);
    1182          15 :                         break;
    1183             :                 }
    1184             : 
    1185             :                 /* control flow instructions ******************************************/
    1186             : 
    1187             :                 case BC_ifeq:
    1188             :                 case BC_iflt:
    1189             :                 case BC_ifle:
    1190             :                 case BC_ifne:
    1191             :                 case BC_ifgt:
    1192             :                 case BC_ifge:
    1193             :                 case BC_ifnull:
    1194             :                 case BC_ifnonnull:
    1195             :                 case BC_if_icmpeq:
    1196             :                 case BC_if_icmpne:
    1197             :                 case BC_if_icmplt:
    1198             :                 case BC_if_icmpgt:
    1199             :                 case BC_if_icmple:
    1200             :                 case BC_if_icmpge:
    1201             :                 case BC_if_acmpeq:
    1202             :                 case BC_if_acmpne:
    1203             :                 case BC_goto: {
    1204      140816 :                         s4 i = bcindex + read_s2_be(m->jcode + bcindex + 1);
    1205      140816 :                         CHECK_BYTECODE_INDEX(i);
    1206      140816 :                         MARK_BASICBLOCK(&pd, i);
    1207      140816 :                         blockend = true;
    1208      140816 :                         OP_INSINDEX(opcode, i);
    1209      140816 :                         break;
    1210             :                 }
    1211             : 
    1212             :                 case BC_goto_w: {
    1213           0 :                         s8 i = ((s8) bcindex) + read_s4_be(m->jcode + bcindex + 1);
    1214           0 :                         CHECK_BYTECODE_INDEX(i);
    1215           0 :                         MARK_BASICBLOCK(&pd, i);
    1216           0 :                         blockend = true;
    1217           0 :                         OP_INSINDEX(ICMD_GOTO, i);
    1218           0 :                         break;
    1219             :                 }
    1220             : 
    1221             :                 case BC_jsr: {
    1222          31 :                         s4 i = bcindex + read_s2_be(m->jcode + bcindex + 1);
    1223          31 :                         CHECK_BYTECODE_INDEX(i);
    1224          31 :                         MARK_BASICBLOCK(&pd, i);
    1225          31 :                         blockend = true;
    1226          31 :                         OP_PREPARE_ZEROFLAGS(ICMD_JSR);
    1227          31 :                         iptr->sx.s23.s3.jsrtarget.insindex = i;
    1228          31 :                         PINC;
    1229          31 :                         break;
    1230             :                 }
    1231             : 
    1232             :                 case BC_jsr_w: {
    1233           0 :                         s8 i = ((s8) bcindex) + read_s4_be(m->jcode + bcindex + 1);
    1234           0 :                         CHECK_BYTECODE_INDEX(i);
    1235           0 :                         MARK_BASICBLOCK(&pd, i);
    1236           0 :                         blockend = true;
    1237           0 :                         OP_PREPARE_ZEROFLAGS(ICMD_JSR);
    1238           0 :                         iptr->sx.s23.s3.jsrtarget.insindex = i;
    1239           0 :                         PINC;
    1240           0 :                         break;
    1241             :                 }
    1242             : 
    1243             :                 case BC_ret: {
    1244             :                         int i; // must be signed because of OP_LOAD_ONEWORD
    1245             : 
    1246          21 :                         if (iswide == false) {
    1247          21 :                                 i = read_u1_be(m->jcode + bcindex + 1);
    1248             :                         } else {
    1249           0 :                                 i      = read_u2_be(m->jcode + bcindex + 1);
    1250           0 :                                 nextbc = bcindex + 3;
    1251           0 :                                 iswide = false;
    1252             :                         }
    1253          21 :                         blockend = true;
    1254             : 
    1255          21 :                         OP_LOAD_ONEWORD(opcode, i, TYPE_ADR);
    1256          21 :                         break;
    1257             :                 }
    1258             : 
    1259             :                 case BC_ireturn:
    1260             :                 case BC_lreturn:
    1261             :                 case BC_freturn:
    1262             :                 case BC_dreturn:
    1263             :                 case BC_areturn:
    1264             :                 case BC_return:
    1265      103305 :                         blockend = true;
    1266             :                         /* XXX ARETURN will need a flag in the typechecker */
    1267      103305 :                         OP(opcode);
    1268      103305 :                         break;
    1269             : 
    1270             :                 case BC_athrow:
    1271       18424 :                         blockend = true;
    1272             :                         /* XXX ATHROW will need a flag in the typechecker */
    1273       18424 :                         OP(opcode);
    1274       18424 :                         break;
    1275             : 
    1276             : 
    1277             :                 /* table jumps ********************************************************/
    1278             : 
    1279             :                 case BC_lookupswitch: {
    1280             : #if defined(ENABLE_VERIFIER)
    1281          60 :                         s4 prevvalue = 0;
    1282             : #endif
    1283          60 :                         blockend = true;
    1284          60 :                         nextbc = MEMORY_ALIGN((bcindex + 1), 4);
    1285             : 
    1286          60 :                         CHECK_END_OF_BYTECODE(nextbc + 8);
    1287             : 
    1288          60 :                         OP_PREPARE_ZEROFLAGS(opcode);
    1289             : 
    1290             :                         /* default target */
    1291             : 
    1292          60 :                         s8 j = ((s8) bcindex) + read_s4_be(m->jcode + nextbc);
    1293          60 :                         CHECK_BYTECODE_INDEX(j);
    1294          60 :                         MARK_BASICBLOCK(&pd, j);
    1295          60 :                         iptr->sx.s23.s3.lookupdefault.insindex = j;
    1296          60 :                         nextbc += 4;
    1297             : 
    1298             :                         /* number of pairs */
    1299             : 
    1300          60 :                         s8 num = read_u4_be(m->jcode + nextbc);
    1301          60 :                         iptr->sx.s23.s2.lookupcount = num;
    1302          60 :                         nextbc += 4;
    1303             : 
    1304             :                         /* allocate the intermediate code table */
    1305             : 
    1306          60 :                         lookup_target_t *lookup = (lookup_target_t*) DumpMemory::allocate(sizeof(lookup_target_t) * num);
    1307          60 :                         iptr->dst.lookup = lookup;
    1308             : 
    1309             :                         /* iterate over the lookup table */
    1310             : 
    1311          60 :                         CHECK_END_OF_BYTECODE(nextbc + 8 * num);
    1312             : 
    1313         540 :                         for (u4 i = 0; i < num; i++) {
    1314             :                                 /* value */
    1315             : 
    1316         480 :                                 s4 value = read_s4_be(m->jcode + nextbc);
    1317         480 :                                 lookup->value = value;
    1318             : 
    1319         480 :                                 nextbc += 4;
    1320             : 
    1321             : #if defined(ENABLE_VERIFIER)
    1322             :                                 /* check if the lookup table is sorted correctly */
    1323             : 
    1324         480 :                                 if (i && (value <= prevvalue)) {
    1325           0 :                                         exceptions_throw_verifyerror(m, "Unsorted lookup switch");
    1326           0 :                                         return false;
    1327             :                                 }
    1328         480 :                                 prevvalue = value;
    1329             : #endif
    1330             :                                 /* target */
    1331             : 
    1332         480 :                                 s8 target = ((s8) bcindex) + read_s4_be(m->jcode + nextbc);
    1333         480 :                                 CHECK_BYTECODE_INDEX(target);
    1334         480 :                                 MARK_BASICBLOCK(&pd, target);
    1335         480 :                                 lookup->target.insindex = target;
    1336         480 :                                 lookup++;
    1337         480 :                                 nextbc += 4;
    1338             :                         }
    1339             : 
    1340          60 :                         PINC;
    1341          60 :                         break;
    1342             :                 }
    1343             : 
    1344             :                 case BC_tableswitch: {
    1345          72 :                         blockend = true;
    1346          72 :                         nextbc = MEMORY_ALIGN((bcindex + 1), 4);
    1347             : 
    1348          72 :                         CHECK_END_OF_BYTECODE(nextbc + 12);
    1349             : 
    1350          72 :                         OP_PREPARE_ZEROFLAGS(opcode);
    1351             : 
    1352             :                         /* default target */
    1353             : 
    1354          72 :                         s8 deftarget = ((s8) bcindex) + read_s4_be(m->jcode + nextbc);
    1355          72 :                         CHECK_BYTECODE_INDEX(deftarget);
    1356          72 :                         MARK_BASICBLOCK(&pd, deftarget);
    1357          72 :                         nextbc += 4;
    1358             : 
    1359             :                         /* lower bound */
    1360             : 
    1361          72 :                         s4 lo = read_s4_be(m->jcode + nextbc);
    1362          72 :                         iptr->sx.s23.s2.tablelow = lo;
    1363          72 :                         nextbc += 4;
    1364             : 
    1365             :                         /* upper bound */
    1366             : 
    1367          72 :                         s4 hi = read_s4_be(m->jcode + nextbc);
    1368          72 :                         iptr->sx.s23.s3.tablehigh = hi;
    1369          72 :                         nextbc += 4;
    1370             : 
    1371             :                         /* calculate the number of table entries */
    1372             : 
    1373          72 :                         s8 num = ((s8) hi) - ((s8) lo) + 1;
    1374             : 
    1375             : #if defined(ENABLE_VERIFIER)
    1376          72 :                         if (num < 1) {
    1377           0 :                                 exceptions_throw_verifyerror(m, "invalid TABLESWITCH: upper bound < lower bound");
    1378           0 :                                 return false;
    1379             :                         }
    1380             : #endif
    1381             :                         /* create the intermediate code table */
    1382             :                         /* the first entry is the default target */
    1383             : 
    1384          72 :                         branch_target_t *table = (branch_target_t*) DumpMemory::allocate(sizeof(branch_target_t) * (1 + num));
    1385          72 :                         iptr->dst.table = table;
    1386          72 :                         (table++)->insindex = deftarget;
    1387             : 
    1388             :                         /* iterate over the target table */
    1389             : 
    1390          72 :                         CHECK_END_OF_BYTECODE(nextbc + 4 * num);
    1391             : 
    1392        1146 :                         for (s4 i = 0; i < num; i++) {
    1393        1074 :                                 s8 j = ((s8) bcindex) + read_s4_be(m->jcode + nextbc);
    1394        1074 :                                 CHECK_BYTECODE_INDEX(j);
    1395        1074 :                                 MARK_BASICBLOCK(&pd, j);
    1396        1074 :                                 (table++)->insindex = j;
    1397        1074 :                                 nextbc += 4;
    1398             :                         }
    1399             : 
    1400          72 :                         PINC;
    1401          72 :                         break;
    1402             :                 }
    1403             : 
    1404             : 
    1405             :                 /* load and store of object fields ************************************/
    1406             : 
    1407             :                 case BC_aastore:
    1408       65152 :                         OP(opcode);
    1409       65152 :                         code_unflag_leafmethod(code);
    1410       65152 :                         break;
    1411             : 
    1412             :                 case BC_getstatic:
    1413             :                 case BC_putstatic:
    1414             :                 case BC_getfield:
    1415             :                 case BC_putfield: {
    1416      223575 :                         u2               i   = read_u2_be(m->jcode + bcindex + 1);
    1417      223575 :                         constant_FMIref *fmi = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Fieldref);
    1418             : 
    1419      223575 :                         if (fmi == NULL)
    1420           0 :                                 return false;
    1421             : 
    1422      223575 :                         OP_PREPARE_ZEROFLAGS(opcode);
    1423      223575 :                         iptr->sx.s23.s3.fmiref = fmi;
    1424             : 
    1425             :                         /* only with -noverify, otherwise the typechecker does this */
    1426             : 
    1427             : #if defined(ENABLE_VERIFIER)
    1428      223575 :                         if (!JITDATA_HAS_FLAG_VERIFY(jd)) {
    1429             : #endif
    1430           0 :                                 resolve_result_t result = resolve_field_lazy(m, fmi);
    1431             : 
    1432           0 :                                 if (result == resolveFailed)
    1433           0 :                                         return false;
    1434             : 
    1435           0 :                                 if (result != resolveSucceeded) {
    1436           0 :                                         unresolved_field *uf = resolve_create_unresolved_field(m->clazz, m, iptr);
    1437             : 
    1438           0 :                                         if (uf == NULL)
    1439           0 :                                                 return false;
    1440             : 
    1441             :                                         /* store the unresolved_field pointer */
    1442             : 
    1443           0 :                                         iptr->sx.s23.s3.uf = uf;
    1444           0 :                                         iptr->flags.bits  |= INS_FLAG_UNRESOLVED;
    1445             :                                 }
    1446             : #if defined(ENABLE_VERIFIER)
    1447             :                         }
    1448             : #endif
    1449      223575 :                         PINC;
    1450      223575 :                         break;
    1451             :                 }
    1452             : 
    1453             : 
    1454             :                 /* method invocation **************************************************/
    1455             : 
    1456             :                 case BC_invokestatic: {
    1457       57949 :                         OP_PREPARE_ZEROFLAGS(opcode);
    1458             : 
    1459       57949 :                         u2 i = read_u2_be(m->jcode + bcindex + 1);
    1460       57949 :                         fmi  = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Methodref);
    1461             : 
    1462       57949 :                         if (fmi == NULL)
    1463           0 :                                 return false;
    1464             : 
    1465       57949 :                         md = fmi->parseddesc.md;
    1466             : 
    1467       57949 :                         md->params_from_paramtypes(ACC_STATIC);
    1468             : 
    1469       57949 :                         goto invoke_method;
    1470             :                 }
    1471             : 
    1472             :                 case BC_invokespecial: {
    1473       89026 :                         OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK);
    1474             : 
    1475       89026 :                         u2 i = read_u2_be(m->jcode + bcindex + 1);
    1476       89026 :                         fmi  = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Methodref);
    1477             : 
    1478       89026 :                         goto invoke_nonstatic_method;
    1479             :                 }
    1480             : 
    1481             :                 case BC_invokeinterface: {
    1482        7503 :                         OP_PREPARE_ZEROFLAGS(opcode);
    1483             : 
    1484        7503 :                         u2 i = read_u2_be(m->jcode + bcindex + 1);
    1485        7503 :                         fmi  = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_InterfaceMethodref);
    1486             : 
    1487        7503 :                         goto invoke_nonstatic_method;
    1488             :                 }
    1489             : 
    1490             :                 case BC_invokevirtual: {
    1491      128743 :                         OP_PREPARE_ZEROFLAGS(opcode);
    1492             : 
    1493      128743 :                         u2 i = read_u2_be(m->jcode + bcindex + 1);
    1494      128743 :                         fmi  = (constant_FMIref*) class_getconstant(m->clazz, i, CONSTANT_Methodref);
    1495             :                         // fallthrough!
    1496             :                 }
    1497             : 
    1498             :                 invoke_nonstatic_method:
    1499      225272 :                         if (fmi == NULL)
    1500           0 :                                 return false;
    1501             : 
    1502      225272 :                         md = fmi->parseddesc.md;
    1503             : 
    1504      225272 :                         md->params_from_paramtypes(0);
    1505             : 
    1506             :                 invoke_method: {
    1507      283221 :                         code_unflag_leafmethod(code);
    1508             : 
    1509      283221 :                         iptr->sx.s23.s3.fmiref = fmi;
    1510             : 
    1511             :                         /* only with -noverify, otherwise the typechecker does this */
    1512             : 
    1513             : #if defined(ENABLE_VERIFIER)
    1514      283221 :                         if (!JITDATA_HAS_FLAG_VERIFY(jd)) {
    1515             : #endif
    1516           0 :                                 resolve_result_t result = resolve_method_lazy(m, fmi, opcode == BC_invokespecial);
    1517             : 
    1518           0 :                                 if (result == resolveFailed)
    1519           0 :                                         return false;
    1520             : 
    1521           0 :                                 if (result == resolveSucceeded) {
    1522           0 :                                         methodinfo *mi = iptr->sx.s23.s3.fmiref->p.method;
    1523             : 
    1524             :                                         /* if this call is monomorphic, turn it into an
    1525             :                                            INVOKESPECIAL */
    1526             : 
    1527           0 :                                         assert(iptr->sx.s23.s3.fmiref->is_resolved());
    1528             : 
    1529           0 :                                         if ((opcode == BC_invokevirtual) && (mi->flags & (ACC_FINAL | ACC_PRIVATE))) {
    1530           0 :                                                 iptr->opc         = ICMD_INVOKESPECIAL;
    1531           0 :                                                 iptr->flags.bits |= INS_FLAG_CHECK;
    1532             :                                         }
    1533             :                                 }
    1534             :                                 else {
    1535             :                                         unresolved_method *um = resolve_create_unresolved_method(m->clazz,
    1536             :                                                                                              m,
    1537             :                                                                                              fmi,
    1538             :                                                                                              opcode == BC_invokestatic,
    1539           0 :                                                                                              opcode == BC_invokespecial);
    1540             : 
    1541             :                                         /* store the unresolved_method pointer */
    1542             : 
    1543           0 :                                         iptr->sx.s23.s3.um = um;
    1544           0 :                                         iptr->flags.bits |= INS_FLAG_UNRESOLVED;
    1545             :                                 }
    1546             : #if defined(ENABLE_VERIFIER)
    1547             :                         }
    1548             : #endif
    1549      283221 :                         PINC;
    1550      283221 :                         break;
    1551             :                 }
    1552             : 
    1553             :                 /* instructions taking class arguments ********************************/
    1554             : 
    1555             :                 case BC_new: {
    1556       51587 :                         u2                 i  = read_u2_be(m->jcode + bcindex + 1);
    1557       51587 :                         constant_classref *cr = (constant_classref*) class_getconstant(m->clazz, i, CONSTANT_Class);
    1558             : 
    1559       51587 :                         if (cr == NULL)
    1560           0 :                                 return false;
    1561             : 
    1562             :                         classinfo *c;
    1563       51587 :                         if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
    1564           0 :                                 return false;
    1565             : 
    1566       51587 :                         INSTRUCTIONS_CHECK(2);
    1567       51587 :                         OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
    1568       51587 :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_new);
    1569       51587 :                         OP_BUILTIN_CHECK_EXCEPTION(bte);
    1570       51587 :                         s_count++;
    1571       51587 :                         break;
    1572             :                 }
    1573             : 
    1574             :                 case BC_checkcast: {
    1575        9191 :                         u2                 i  = read_u2_be(m->jcode + bcindex + 1);
    1576        9191 :                         constant_classref *cr = (constant_classref*) class_getconstant(m->clazz, i, CONSTANT_Class);
    1577             : 
    1578        9191 :                         if (cr == NULL)
    1579           0 :                                 return false;
    1580             : 
    1581             :                         classinfo *c;
    1582        9191 :                         if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
    1583           0 :                                 return false;
    1584             : 
    1585             :                         u4 flags;
    1586             : 
    1587        9191 :                         if (cr->name[0] == '[') {
    1588             :                                 /* array type cast-check */
    1589         959 :                                 flags = INS_FLAG_CHECK | INS_FLAG_ARRAY;
    1590         959 :                                 code_unflag_leafmethod(code);
    1591             :                         }
    1592             :                         else {
    1593             :                                 /* object type cast-check */
    1594        8232 :                                 flags = INS_FLAG_CHECK;
    1595             :                         }
    1596        9191 :                         OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, flags);
    1597        9191 :                         break;
    1598             :                 }
    1599             : 
    1600             :                 case BC_instanceof: {
    1601        1366 :                         u2                 i  = read_u2_be(m->jcode + bcindex + 1);
    1602        1366 :                         constant_classref *cr = (constant_classref*) class_getconstant(m->clazz, i, CONSTANT_Class);
    1603             : 
    1604        1366 :                         if (cr == NULL)
    1605           0 :                                 return false;
    1606             : 
    1607             :                         classinfo *c;
    1608        1366 :                         if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
    1609           0 :                                 return false;
    1610             : 
    1611        1366 :                         if (cr->name[0] == '[') {
    1612             :                                 /* array type cast-check */
    1613          99 :                                 INSTRUCTIONS_CHECK(2);
    1614          99 :                                 OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr);
    1615          99 :                                 builtintable_entry *bte = builtintable_get_internal(BUILTIN_arrayinstanceof);
    1616          99 :                                 OP_BUILTIN_NO_EXCEPTION(bte);
    1617          99 :                                 s_count++;
    1618             :                         }
    1619             :                         else {
    1620             :                                 /* object type cast-check */
    1621        1267 :                                 OP_S3_CLASSINFO_OR_CLASSREF(opcode, c, cr, 0 /* flags*/);
    1622             :                         }
    1623        1366 :                         break;
    1624             :                 }
    1625             : 
    1626             :                 /* synchronization instructions ***************************************/
    1627             : 
    1628             :                 case BC_monitorenter:
    1629        2549 :                         if (checksync) {
    1630        2549 :                                 builtintable_entry *bte = builtintable_get_internal(LOCK_monitor_enter);
    1631        2549 :                                 OP_BUILTIN_CHECK_EXCEPTION(bte);
    1632             :                         } else {
    1633           0 :                                 OP_CHECK_EXCEPTION(ICMD_CHECKNULL);
    1634           0 :                                 OP(ICMD_POP);
    1635             :                         }
    1636        2549 :                         break;
    1637             : 
    1638             :                 case BC_monitorexit:
    1639        5462 :                         if (checksync) {
    1640        5462 :                                 builtintable_entry *bte = builtintable_get_internal(LOCK_monitor_exit);
    1641        5462 :                                 OP_BUILTIN_CHECK_EXCEPTION(bte);
    1642             :                         } else {
    1643           0 :                                 OP_CHECK_EXCEPTION(ICMD_CHECKNULL);
    1644           0 :                                 OP(ICMD_POP);
    1645             :                         }
    1646        5462 :                         break;
    1647             : 
    1648             :                 /* arithmetic instructions that may become builtin functions **********/
    1649             : 
    1650             :                 case BC_idiv: {
    1651             : #if !SUPPORT_DIVISION
    1652             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_idiv);
    1653             :                         OP_BUILTIN_ARITHMETIC(opcode, bte);
    1654             : #else
    1655             : # if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
    1656         350 :                         OP(opcode);
    1657             : # else
    1658             :                         OP_CHECK_EXCEPTION(opcode);
    1659             : # endif
    1660             : #endif
    1661         350 :                         break;
    1662             :                 }
    1663             : 
    1664             :                 case BC_irem: {
    1665             : #if !SUPPORT_DIVISION
    1666             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_irem);
    1667             :                         OP_BUILTIN_ARITHMETIC(opcode, bte);
    1668             : #else
    1669             : # if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
    1670        1619 :                         OP(opcode);
    1671             : # else
    1672             :                         OP_CHECK_EXCEPTION(opcode);
    1673             : # endif
    1674             : #endif
    1675        1619 :                         break;
    1676             :                 }
    1677             : 
    1678             :                 case BC_ldiv: {
    1679             : #if !(SUPPORT_DIVISION && SUPPORT_LONG_DIV)
    1680             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_ldiv);
    1681             :                         OP_BUILTIN_ARITHMETIC(opcode, bte);
    1682             : #else
    1683             : # if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
    1684          61 :                         OP(opcode);
    1685             : # else
    1686             :                         OP_CHECK_EXCEPTION(opcode);
    1687             : # endif
    1688             : #endif
    1689          61 :                         break;
    1690             :                 }
    1691             : 
    1692             :                 case BC_lrem: {
    1693             : #if !(SUPPORT_DIVISION && SUPPORT_LONG_DIV)
    1694             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_lrem);
    1695             :                         OP_BUILTIN_ARITHMETIC(opcode, bte);
    1696             : #else
    1697             : # if SUPPORT_HARDWARE_DIVIDE_BY_ZERO
    1698          61 :                         OP(opcode);
    1699             : # else
    1700             :                         OP_CHECK_EXCEPTION(opcode);
    1701             : # endif
    1702             : #endif
    1703          61 :                         break;
    1704             :                 }
    1705             : 
    1706             :                 case BC_frem: {
    1707             : #if defined(__I386__)
    1708             :                         OP(opcode);
    1709             : #else
    1710        1004 :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_frem);
    1711        1004 :                         OP_BUILTIN_NO_EXCEPTION(bte);
    1712             : #endif
    1713        1004 :                         break;
    1714             :                 }
    1715             : 
    1716             :                 case BC_drem: {
    1717             : #if defined(__I386__)
    1718             :                         OP(opcode);
    1719             : #else
    1720           2 :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_drem);
    1721           2 :                         OP_BUILTIN_NO_EXCEPTION(bte);
    1722             : #endif
    1723           2 :                         break;
    1724             :                 }
    1725             : 
    1726             :                 case BC_f2i: {
    1727             : #if defined(__ALPHA__)
    1728             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_f2i);
    1729             :                         OP_BUILTIN_NO_EXCEPTION(bte);
    1730             : #else
    1731         714 :                         OP(opcode);
    1732             : #endif
    1733         714 :                         break;
    1734             :                 }
    1735             : 
    1736             :                 case BC_f2l: {
    1737             : #if defined(__ALPHA__)
    1738             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_f2l);
    1739             :                         OP_BUILTIN_NO_EXCEPTION(bte);
    1740             : #else
    1741           2 :                         OP(opcode);
    1742             : #endif
    1743           2 :                         break;
    1744             :                 }
    1745             : 
    1746             :                 case BC_d2i: {
    1747             : #if defined(__ALPHA__)
    1748             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_d2i);
    1749             :                         OP_BUILTIN_NO_EXCEPTION(bte);
    1750             : #else
    1751           8 :                         OP(opcode);
    1752             : #endif
    1753           8 :                         break;
    1754             :                 }
    1755             : 
    1756             :                 case BC_d2l: {
    1757             : #if defined(__ALPHA__)
    1758             :                         builtintable_entry *bte = builtintable_get_internal(BUILTIN_d2l);
    1759             :                         OP_BUILTIN_NO_EXCEPTION(bte);
    1760             : #else
    1761           2 :                         OP(opcode);
    1762             : #endif
    1763           2 :                         break;
    1764             :                 }
    1765             : 
    1766             : 
    1767             :                 /* invalid opcodes ****************************************************/
    1768             : 
    1769             :                         /* check for invalid opcodes if the verifier is enabled */
    1770             : #if defined(ENABLE_VERIFIER)
    1771             :                 case BC_breakpoint:
    1772           0 :                         exceptions_throw_verifyerror(m, "Quick instructions shouldn't appear, yet.");
    1773           0 :                         return false;
    1774             : 
    1775             : 
    1776             :                 /* Unused opcodes ************************************************** */
    1777             : 
    1778             :         default:
    1779             :                         exceptions_throw_verifyerror(m, "Illegal opcode %d at instr %d\n",
    1780           0 :                                                                                  opcode, ircount);
    1781           0 :                         return false;
    1782             :                         break;
    1783             : #else
    1784             :                 default: break;
    1785             : #endif /* defined(ENABLE_VERIFIER) */
    1786             : 
    1787             :         /* opcodes that don't require translation *****************************/
    1788             :         case BC_iaload:
    1789             :         case BC_laload:
    1790             :         case BC_faload:
    1791             :         case BC_daload:
    1792             :         case BC_aaload:
    1793             :         case BC_baload:
    1794             :         case BC_caload:
    1795             :         case BC_saload:
    1796             :         case BC_iastore:
    1797             :         case BC_lastore:
    1798             :         case BC_fastore:
    1799             :         case BC_dastore:
    1800             :         case BC_bastore:
    1801             :         case BC_castore:
    1802             :         case BC_sastore:
    1803             :         case BC_pop:
    1804             :         case BC_pop2:
    1805             :         case BC_dup:
    1806             :         case BC_iadd:
    1807             :         case BC_ladd:
    1808             :         case BC_fadd:
    1809             :         case BC_dadd:
    1810             :         case BC_isub:
    1811             :         case BC_lsub:
    1812             :         case BC_fsub:
    1813             :         case BC_dsub:
    1814             :         case BC_imul:
    1815             :         case BC_lmul:
    1816             :         case BC_fmul:
    1817             :         case BC_dmul:
    1818             :         case BC_fdiv:
    1819             :         case BC_ddiv:
    1820             :         case BC_ineg:
    1821             :         case BC_lneg:
    1822             :         case BC_fneg:
    1823             :         case BC_dneg:
    1824             :         case BC_ishl:
    1825             :         case BC_lshl:
    1826             :         case BC_ishr:
    1827             :         case BC_lshr:
    1828             :         case BC_iushr:
    1829             :         case BC_lushr:
    1830             :         case BC_iand:
    1831             :         case BC_land:
    1832             :         case BC_ior:
    1833             :         case BC_lor:
    1834             :         case BC_ixor:
    1835             :         case BC_lxor:
    1836             :         case BC_i2l:
    1837             :         case BC_i2f:
    1838             :         case BC_i2d:
    1839             :         case BC_l2i:
    1840             :         case BC_l2f:
    1841             :         case BC_l2d:
    1842             :         case BC_f2d:
    1843             :         case BC_d2f:
    1844             :         case BC_int2byte:
    1845             :         case BC_int2char:
    1846             :         case BC_int2short:
    1847             :         case BC_lcmp:
    1848             :         case BC_fcmpl:
    1849             :         case BC_fcmpg:
    1850             :         case BC_dcmpl:
    1851             :         case BC_dcmpg:
    1852             :         case BC_arraylength:
    1853             :         case BC_impdep1:
    1854             :         case BC_impdep2:
    1855             :             /* Straight-forward translation to HIR. */
    1856     1243235 :             OP(opcode);
    1857             :             break;
    1858             :                 } /* end switch */
    1859             : 
    1860             :                 /* verifier checks ****************************************************/
    1861             : 
    1862             : #if defined(ENABLE_VERIFIER)
    1863             :                 /* If WIDE was used correctly, iswide should have been reset by now. */
    1864     4117591 :                 if (iswide) {
    1865           0 :                         exceptions_throw_verifyerror(m, "Illegal instruction: WIDE before incompatible opcode");
    1866           0 :                         return false;
    1867             :                 }
    1868             : #endif /* defined(ENABLE_VERIFIER) */
    1869             : 
    1870             :         } /* end for */
    1871             : 
    1872       86432 :         if (JITDATA_HAS_FLAG_REORDER(jd)) {
    1873             :                 /* add a NOP to the last basic block */
    1874             : 
    1875           0 :                 INSTRUCTIONS_CHECK(1);
    1876           0 :                 OP(ICMD_NOP);
    1877             :         }
    1878             : 
    1879             :         /*** END OF LOOP **********************************************************/
    1880             : 
    1881             :         /* assert that we did not write more ICMDs than allocated */
    1882             : 
    1883       86432 :         assert(ircount <= pd.instructionslength);
    1884       86432 :         assert(ircount == (iptr - pd.instructions));
    1885             : 
    1886             :         /*** verifier checks ******************************************************/
    1887             : 
    1888             : #if defined(ENABLE_VERIFIER)
    1889       86432 :         if (bcindex != m->jcodelength) {
    1890             :                 exceptions_throw_verifyerror(m,
    1891           0 :                                 "Command-sequence crosses code-boundary");
    1892           0 :                 return false;
    1893             :         }
    1894             : 
    1895       86432 :         if (!blockend) {
    1896           0 :                 exceptions_throw_verifyerror(m, "Falling off the end of the code");
    1897           0 :                 return false;
    1898             :         }
    1899             : #endif /* defined(ENABLE_VERIFIER) */
    1900             : 
    1901             :         /*** setup the methodinfo, allocate stack and basic blocks ****************/
    1902             : 
    1903             :         /* identify basic blocks */
    1904             : 
    1905             :         /* check if first instruction is a branch target */
    1906             : 
    1907       86432 :         if (pd.basicblockstart[0] == 1) {
    1908        1077 :                 jd->branchtoentry = true;
    1909             :         }
    1910             :         else {
    1911             :                 /* first instruction always starts a basic block */
    1912             : 
    1913       85355 :                 iptr = pd.instructions;
    1914             : 
    1915       85355 :                 iptr->flags.bits |= INS_FLAG_BASICBLOCK;
    1916             :         }
    1917             : 
    1918             :         /* Iterate over all bytecode instructions and set missing
    1919             :            basic-block starts in IR instructions. */
    1920             : 
    1921     7522723 :         for (bcindex = 0; bcindex < m->jcodelength; bcindex++) {
    1922             :                 /* Does the current bytecode instruction start a basic
    1923             :                    block? */
    1924             : 
    1925     7436291 :                 if (pd.basicblockstart[bcindex] == 1) {
    1926             : #if defined(ENABLE_VERIFIER)
    1927             :                         /* Check if this bytecode basic-block start at the
    1928             :                            beginning of a bytecode instruction. */
    1929             : 
    1930      234018 :                         if (pd.bytecodestart[bcindex] == 0) {
    1931             :                                 exceptions_throw_verifyerror(m,
    1932           0 :                                                                                  "Branch into middle of instruction");
    1933           0 :                                 return false;
    1934             :                         }
    1935             : #endif
    1936             : 
    1937             :                         /* Get the IR instruction mapped to the bytecode
    1938             :                            instruction and set the basic block flag. */
    1939             : 
    1940      234018 :                         irindex = pd.bytecodemap[bcindex];
    1941      234018 :                         iptr    = pd.instructions + irindex;
    1942             : 
    1943      234018 :                         iptr->flags.bits |= INS_FLAG_BASICBLOCK;
    1944             :                 }
    1945             :         }
    1946             : 
    1947             :         /* IR instruction index to basic-block index mapping */
    1948             : 
    1949       86432 :         pd.instructionmap = (s4*) DumpMemory::allocate(sizeof(s4) * ircount);
    1950       86432 :         MZERO(pd.instructionmap, s4, ircount);
    1951             : 
    1952             :         /* Iterate over all IR instructions and count the basic blocks. */
    1953             : 
    1954       86432 :         iptr = pd.instructions;
    1955             : 
    1956       86432 :         bbcount = 0;
    1957             : 
    1958     4506474 :         for (s4 i = 0; i < ircount; i++, iptr++) {
    1959     4420042 :                 if (INSTRUCTION_STARTS_BASICBLOCK(iptr)) {
    1960             :                         /* store the basic-block number in the IR instruction
    1961             :                            map */
    1962             : 
    1963      319373 :                         pd.instructionmap[i] = bbcount;
    1964             : 
    1965             :                         /* post-increment the basic-block count */
    1966             : 
    1967      319373 :                         bbcount++;
    1968             :                 }
    1969             :         }
    1970             : 
    1971             :         /* Allocate basic block array (one more for end ipc). */
    1972             : 
    1973       86432 :         jd->basicblocks = (basicblock*) DumpMemory::allocate(sizeof(basicblock) * (bbcount + 1));
    1974       86432 :         MZERO(jd->basicblocks, basicblock, bbcount + 1);
    1975             : 
    1976             :         /* Now iterate again over all IR instructions and initialize the
    1977             :            basic block structures and, in the same loop, resolve the
    1978             :            branch-target instruction indices to basic blocks. */
    1979             : 
    1980       86432 :         iptr = pd.instructions;
    1981       86432 :         bptr = jd->basicblocks;
    1982             : 
    1983       86432 :         bbcount = 0;
    1984             : 
    1985     4506474 :         for (s4 i = 0; i < ircount; i++, iptr++) {
    1986             :                 /* check for basic block */
    1987             : 
    1988     4420042 :                 if (INSTRUCTION_STARTS_BASICBLOCK(iptr)) {
    1989             :                         /* intialize the basic block */
    1990             : 
    1991      319373 :                         BASICBLOCK_INIT(bptr, m);
    1992             : 
    1993      319373 :                         bptr->iinstr = iptr;
    1994             : 
    1995      319373 :                         if (bbcount > 0) {
    1996      232941 :                                 bptr[-1].icount = bptr->iinstr - bptr[-1].iinstr;
    1997             :                         }
    1998             : 
    1999             :                         /* bptr->icount is set when the next block is allocated */
    2000             : 
    2001      319373 :                         bptr->nr = bbcount++;
    2002      319373 :                         bptr++;
    2003      319373 :                         bptr[-1].next = bptr;
    2004             :                 }
    2005             : 
    2006             :                 /* resolve instruction indices to basic blocks */
    2007             : 
    2008     4420042 :                 switch (iptr->opc) {
    2009             :                 case ICMD_IFEQ:
    2010             :                 case ICMD_IFLT:
    2011             :                 case ICMD_IFLE:
    2012             :                 case ICMD_IFNE:
    2013             :                 case ICMD_IFGT:
    2014             :                 case ICMD_IFGE:
    2015             :                 case ICMD_IFNULL:
    2016             :                 case ICMD_IFNONNULL:
    2017             :                 case ICMD_IF_ICMPEQ:
    2018             :                 case ICMD_IF_ICMPNE:
    2019             :                 case ICMD_IF_ICMPLT:
    2020             :                 case ICMD_IF_ICMPGT:
    2021             :                 case ICMD_IF_ICMPLE:
    2022             :                 case ICMD_IF_ICMPGE:
    2023             :                 case ICMD_IF_ACMPEQ:
    2024             :                 case ICMD_IF_ACMPNE:
    2025             :                 case ICMD_GOTO:
    2026      140813 :                         BYTECODEINDEX_TO_BASICBLOCK(iptr->dst);
    2027      140813 :                         break;
    2028             : 
    2029             :                 case ICMD_JSR:
    2030          31 :                         BYTECODEINDEX_TO_BASICBLOCK(iptr->sx.s23.s3.jsrtarget);
    2031          31 :                         break;
    2032             : 
    2033             :                 case ICMD_TABLESWITCH: {
    2034          72 :                         table = iptr->dst.table;
    2035             : 
    2036          72 :                         BYTECODEINDEX_TO_BASICBLOCK(*table);
    2037          72 :                         table++;
    2038             : 
    2039          72 :                         s4 j = iptr->sx.s23.s3.tablehigh - iptr->sx.s23.s2.tablelow + 1;
    2040             : 
    2041        1218 :                         while (--j >= 0) {
    2042        1074 :                                 BYTECODEINDEX_TO_BASICBLOCK(*table);
    2043        1074 :                                 table++;
    2044             :                         }
    2045          72 :                         break;
    2046             :                 }
    2047             : 
    2048             :                 case ICMD_LOOKUPSWITCH: {
    2049          60 :                         BYTECODEINDEX_TO_BASICBLOCK(iptr->sx.s23.s3.lookupdefault);
    2050             : 
    2051          60 :                         lookup = iptr->dst.lookup;
    2052             : 
    2053          60 :                         s4 j = iptr->sx.s23.s2.lookupcount;
    2054             : 
    2055         600 :                         while (--j >= 0) {
    2056         480 :                                 BYTECODEINDEX_TO_BASICBLOCK(lookup->target);
    2057         480 :                                 lookup++;
    2058             :                         }
    2059             :                         break;
    2060             :                 }
    2061             :                 default:
    2062             :                         break;
    2063             :                 }
    2064             :         }
    2065             : 
    2066             :         /* set instruction count of last real block */
    2067             : 
    2068       86432 :         if (bbcount > 0) {
    2069       86432 :                 bptr[-1].icount = (pd.instructions + ircount) - bptr[-1].iinstr;
    2070             :         }
    2071             : 
    2072             :         /* allocate additional block at end */
    2073             : 
    2074       86432 :         BASICBLOCK_INIT(bptr, m);
    2075       86432 :         bptr->nr = bbcount;
    2076             : 
    2077             :         /* set basicblock pointers in exception table */
    2078             : 
    2079       86432 :         if (!parse_resolve_exception_table(jd, &pd))
    2080           0 :                 return false;
    2081             : 
    2082             :         /* store the local map */
    2083             : 
    2084       86432 :         jd->local_map = local_map;
    2085             : 
    2086             :         /* calculate local variable renaming */
    2087             : 
    2088             :         {
    2089       86432 :                 s4 nlocals = 0;
    2090             :                 s4 varindex;
    2091             :                 s4 *mapptr;
    2092             :                 s4 *reversemap;
    2093             : 
    2094       86432 :                 mapptr = local_map;
    2095             : 
    2096             :                 /* iterate over local_map[0..m->maxlocals*5-1] and allocate a unique */
    2097             :                 /* variable index for each _used_ (javaindex,type) pair.             */
    2098             :                 /* (local_map[javaindex*5+type] = cacaoindex)                        */
    2099             :                 /* Unused (javaindex,type) pairs are marked with UNUSED.             */
    2100             : 
    2101     1110012 :                 for (s4 i = 0; i < (m->maxlocals * 5); i++, mapptr++) {
    2102     1023580 :                         if (*mapptr)
    2103      195441 :                                 *mapptr = nlocals++;
    2104             :                         else
    2105      828139 :                                 *mapptr = jitdata::UNUSED;
    2106             :                 }
    2107             : 
    2108       86432 :                 jd->localcount = nlocals;
    2109             : 
    2110             :                 /* calculate the (maximum) number of variables needed */
    2111             : 
    2112             :                 jd->varcount =
    2113             :                           nlocals                                      /* local variables */
    2114             :                         + bbcount * m->maxstack                                 /* invars */
    2115       86432 :                         + s_count;         /* variables created within blocks (non-invar) */
    2116             : 
    2117             :                 /* reserve the first indices for local variables */
    2118             : 
    2119       86432 :                 jd->vartop = nlocals;
    2120             : 
    2121             :                 /* reserve extra variables needed by stack analyse */
    2122             : 
    2123       86432 :                 jd->varcount += STACK_EXTRA_VARS;
    2124       86432 :                 jd->vartop   += STACK_EXTRA_VARS;
    2125             : 
    2126             :                 /* The verifier needs space for saving invars in some cases and */
    2127             :                 /* extra variables.                                             */
    2128             : 
    2129             : #if defined(ENABLE_VERIFIER)
    2130       86432 :                 jd->varcount += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + m->maxstack;
    2131       86432 :                 jd->vartop   += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + m->maxstack;
    2132             : #endif
    2133             :                 /* allocate and initialize the variable array */
    2134             : 
    2135       86432 :                 jd->var = (varinfo*) DumpMemory::allocate(sizeof(varinfo) * jd->varcount);
    2136       86432 :                 MZERO(jd->var, varinfo, jd->varcount);
    2137             : 
    2138             :                 /* set types of all locals in jd->var */
    2139             :                 /* and fill the reverselocalmap       */
    2140             : 
    2141       86432 :                 reversemap = (s4*) DumpMemory::allocate(sizeof(s4) * nlocals);
    2142             : 
    2143      291148 :                 for (s4 i = 0; i < m->maxlocals; i++)
    2144     1228296 :                         for (s4 t=0; t<5; t++) {
    2145     1023580 :                                 varindex = local_map[5*i + t];
    2146     1023580 :                                 if (varindex != jitdata::UNUSED) {
    2147      195441 :                                         VAR(varindex)->type = (Type) t;
    2148      195441 :                                         reversemap[varindex] = i;
    2149             :                                 }
    2150             :                         }
    2151             : 
    2152       86432 :                 jd->reverselocalmap = reversemap;
    2153             :         }
    2154             : 
    2155             :         /* assign local variables to method variables */
    2156             : 
    2157       86432 :         jd->instructions     = pd.instructions;
    2158       86432 :         jd->instructioncount = ircount;
    2159       86432 :         jd->basicblockcount  = bbcount;
    2160       86432 :         jd->stackcount       = s_count + bbcount * m->maxstack; /* in-stacks */
    2161             : 
    2162             :         /* allocate stack table */
    2163             : 
    2164       86432 :         jd->stack = (stackelement_t*) DumpMemory::allocate(sizeof(stackelement_t) * jd->stackcount);
    2165             : 
    2166             :         /* everything's ok */
    2167             : 
    2168       86432 :         return true;
    2169             : 
    2170             :         /*** goto labels for throwing verifier exceptions *************************/
    2171             : 
    2172             : #if defined(ENABLE_VERIFIER)
    2173             : 
    2174             : throw_unexpected_end_of_bytecode:
    2175           0 :         exceptions_throw_verifyerror(m, "Unexpected end of bytecode");
    2176           0 :         return false;
    2177             : 
    2178             : throw_invalid_bytecode_index:
    2179           0 :         exceptions_throw_verifyerror(m, "Illegal target of branch instruction");
    2180           0 :         return false;
    2181             : 
    2182             : throw_illegal_local_variable_number:
    2183           3 :         exceptions_throw_verifyerror(m, "Illegal local variable number");
    2184           3 :         return false;
    2185             : 
    2186             : #endif /* ENABLE_VERIFIER */
    2187             : }
    2188             : 
    2189             : 
    2190             : /*
    2191             :  * These are local overrides for various environment variables in Emacs.
    2192             :  * Please do not remove this and leave it at the end of the file, where
    2193             :  * Emacs will automagically detect them.
    2194             :  * ---------------------------------------------------------------------
    2195             :  * Local variables:
    2196             :  * mode: c++
    2197             :  * indent-tabs-mode: t
    2198             :  * c-basic-offset: 4
    2199             :  * tab-width: 4
    2200             :  * End:
    2201             :  * vim:noexpandtab:sw=4:ts=4:
    2202             :  */

Generated by: LCOV version 1.11