LCOV - code coverage report
Current view: top level - vm/jit - code.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 23 78.3 %
Date: 2015-06-10 18:10:59 Functions: 7 9 77.8 %

          Line data    Source code
       1             : /* src/vm/jit/code.hpp - codeinfo struct for representing compiled code
       2             : 
       3             :    Copyright (C) 1996-2013
       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             : 
      26             : #ifndef CODE_HPP_
      27             : #define CODE_HPP_ 1
      28             : 
      29             : #include "config.h"                     // for ENABLE_REPLACEMENT, ENABLE_PROFILING
      30             : #include <assert.h>                     // for assert
      31             : #include <stdint.h>                     // for int32_t, uint8_t, uint32_t, etc
      32             : #include <stdlib.h>                     // for NULL
      33             : #include "vm/jit/methodheader.hpp"      // for CodeInfoPointer
      34             : #include "vm/types.hpp"                 // for u1, s4
      35             : 
      36             : class LinenumberTable;
      37             : struct exceptiontable_t;
      38             : struct methodinfo;
      39             : struct patchref_t;
      40             : struct rplalloc;
      41             : struct rplpoint;
      42      105324 : template <class T> class LockedList;
      43             : 
      44             : 
      45             : /* constants ******************************************************************/
      46             : 
      47             : enum CodeFlag {
      48             :         CODE_FLAG_INVALID      = 0x0001,
      49             :         CODE_FLAG_LEAFMETHOD   = 0x0002,
      50             :         CODE_FLAG_SYNCHRONIZED = 0x0004,
      51             :         CODE_FLAG_TLH          = 0x0008
      52             : };
      53             : 
      54             : 
      55             : /* codeinfo *******************************************************************
      56             : 
      57             :    A codeinfo represents a particular realization of a method in
      58             :    machine code.
      59             : 
      60             :    ATTENTION: The methodinfo entry in the code-structure MUST have the
      61             :    offset 0, otherwise we have a problem in our compiler stub. This is
      62             :    checked with an assert in code_init().
      63             : 
      64             : *******************************************************************************/
      65             : 
      66             : struct codeinfo {
      67             :         methodinfo   *m;                    /* method this is a realization of    */
      68             :         codeinfo     *prev;                 /* previous codeinfo of this method   */
      69             : 
      70             :         uint32_t      flags;                /* OR of CODE_FLAG_ constants         */
      71             : 
      72             :         u1            optlevel;             /* optimization level of this code    */
      73             : 
      74             :         /* machine code */
      75             :         u1           *mcode;                /* pointer to machine code            */
      76             :         u1           *entrypoint;           /* machine code entry point           */
      77             :         s4            mcodelength;          /* length of generated machine code   */
      78             : 
      79             :         /* runtime information */
      80             :         int32_t       stackframesize;       /* size of the stackframe in slots    */
      81             :         int32_t       synchronizedoffset;   /* stack offset of synchronized obj.  */
      82             :         uint8_t       savedintcount;        /* number of callee saved int regs    */
      83             :         uint8_t       savedfltcount;        /* number of callee saved flt regs    */
      84             : 
      85             :         exceptiontable_t  *exceptiontable;
      86             :         LinenumberTable* linenumbertable;
      87             : 
      88             :         /* patcher list */
      89             :         LockedList<patchref_t>* patchers;
      90             : 
      91             :         /* replacement */
      92             : #if defined(ENABLE_REPLACEMENT)
      93             :         rplpoint     *rplpoints;            /* replacement points                 */
      94             :         rplalloc     *regalloc;             /* register allocation info           */
      95             :         s4            rplpointcount;        /* number of replacement points       */
      96             :         s4            globalcount;          /* number of global allocations       */
      97             :         s4            regalloccount;        /* number of total allocations        */
      98             :         s4            memuse;               /* number of arg + local slots        */
      99             :         u1           *savedmcode;           /* saved code under patches           */
     100             : #endif
     101             : 
     102             :         /* profiling information */
     103             : #if defined(ENABLE_PROFILING)
     104             :         u4            frequency;            /* number of method invocations       */
     105             :         s4            basicblockcount;      /* number of basic blocks             */
     106             :         u4           *bbfrequency;          /* basic block profiling information  */
     107             :         s8            cycles;               /* number of cpu cycles               */
     108             : #endif
     109             : };
     110             : 
     111             : 
     112             : /* inline functions ***********************************************************/
     113             : 
     114             : /* code_xxx_invalid ************************************************************
     115             : 
     116             :    Functions for CODE_FLAG_INVALID.
     117             : 
     118             : *******************************************************************************/
     119             : 
     120           0 : inline static int code_is_invalid(codeinfo *code)
     121             : {
     122           0 :         return (code->flags & CODE_FLAG_INVALID);
     123             : }
     124             : 
     125           0 : inline static void code_flag_invalid(codeinfo *code)
     126             : {
     127           0 :         code->flags |= CODE_FLAG_INVALID;
     128           0 : }
     129             : 
     130             : inline static void code_unflag_invalid(codeinfo *code)
     131             : {
     132             :         code->flags &= ~CODE_FLAG_INVALID;
     133             : }
     134             : 
     135             : 
     136             : /* code_xxx_leafmethod *********************************************************
     137             : 
     138             :    Functions for CODE_FLAG_LEAFMETHOD.
     139             : 
     140             : *******************************************************************************/
     141             : 
     142     2271289 : inline static int code_is_leafmethod(codeinfo *code)
     143             : {
     144     2271289 :         return (code->flags & CODE_FLAG_LEAFMETHOD);
     145             : }
     146             : 
     147      102093 : inline static void code_flag_leafmethod(codeinfo *code)
     148             : {
     149      102093 :         code->flags |= CODE_FLAG_LEAFMETHOD;
     150      102093 : }
     151             : 
     152      441872 : inline static void code_unflag_leafmethod(codeinfo *code)
     153             : {
     154      441872 :         code->flags &= ~CODE_FLAG_LEAFMETHOD;
     155      441872 : }
     156             : 
     157             : 
     158             : /* code_xxx_synchronized *******************************************************
     159             : 
     160             :    Functions for CODE_FLAG_SYNCHRONIZED.
     161             : 
     162             : *******************************************************************************/
     163             : 
     164      296586 : inline static int code_is_synchronized(codeinfo *code)
     165             : {
     166      296586 :         return (code->flags & CODE_FLAG_SYNCHRONIZED);
     167             : }
     168             : 
     169        3231 : inline static void code_flag_synchronized(codeinfo *code)
     170             : {
     171        3231 :         code->flags |= CODE_FLAG_SYNCHRONIZED;
     172        3231 : }
     173             : 
     174             : inline static void code_unflag_synchronized(codeinfo *code)
     175             : {
     176             :         code->flags &= ~CODE_FLAG_SYNCHRONIZED;
     177             : }
     178             : 
     179             : 
     180             : /* code_get_codeinfo_for_pv ****************************************************
     181             : 
     182             :    Return the codeinfo for the given PV.
     183             : 
     184             :    IN:
     185             :        pv...............PV
     186             : 
     187             :    RETURN VALUE:
     188             :        the codeinfo *
     189             : 
     190             : *******************************************************************************/
     191             : 
     192    15466010 : inline static codeinfo *code_get_codeinfo_for_pv(void *pv)
     193             : {
     194             :         codeinfo *code;
     195             : 
     196    15466010 :         assert(pv != NULL);
     197             : 
     198    15466010 :         code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer));
     199             : 
     200    15466010 :         return code;
     201             : }
     202             : 
     203             : 
     204             : /* function prototypes ********************************************************/
     205             : 
     206             : void code_init(void);
     207             : 
     208             : codeinfo *code_codeinfo_new(methodinfo *m);
     209             : void code_codeinfo_free(codeinfo *code);
     210             : 
     211             : codeinfo *code_find_codeinfo_for_pc(void *pc);
     212             : codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc);
     213             : 
     214             : methodinfo *code_get_methodinfo_for_pv(void *pv);
     215             : 
     216             : #if defined(ENABLE_REPLACEMENT)
     217             : int code_get_sync_slot_count(codeinfo *code);
     218             : #endif /* defined(ENABLE_REPLACEMENT) */
     219             : 
     220             : void code_free_code_of_method(methodinfo *m);
     221             : 
     222             : #endif // CODE_HPP_
     223             : 
     224             : 
     225             : /*
     226             :  * These are local overrides for various environment variables in Emacs.
     227             :  * Please do not remove this and leave it at the end of the file, where
     228             :  * Emacs will automagically detect them.
     229             :  * ---------------------------------------------------------------------
     230             :  * Local variables:
     231             :  * mode: c++
     232             :  * indent-tabs-mode: t
     233             :  * c-basic-offset: 4
     234             :  * tab-width: 4
     235             :  * End:
     236             :  * vim:noexpandtab:sw=4:ts=4:
     237             :  */

Generated by: LCOV version 1.11