LCOV - code coverage report
Current view: top level - vm/jit - patcher-common.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2015-06-10 18:10:59 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* src/vm/jit/patcher-common.hpp - architecture independent code patching stuff
       2             : 
       3             :    Copyright (C) 1996-2011
       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 _PATCHER_COMMON_HPP
      27             : #define _PATCHER_COMMON_HPP
      28             : 
      29             : /* forward typedefs ***********************************************************/
      30             : 
      31             : typedef struct patchref_t patchref_t;
      32             : 
      33             : #include "config.h"
      34             : #include "vm/types.hpp"
      35             : 
      36             : #include "toolbox/list.hpp"
      37             : 
      38             : #include "vm/global.hpp"
      39             : 
      40             : struct jitdata;
      41             : 
      42             : /* patchref_t ******************************************************************
      43             : 
      44             :    A patcher reference contains information about a code position
      45             :    which needs additional code patching during runtime.
      46             : 
      47             : *******************************************************************************/
      48             : 
      49           0 : struct patchref_t {
      50             :         uintptr_t    mpc;           /* absolute position in code segment          */
      51             :         uintptr_t    datap;         /* absolute position in data segment          */
      52             :         int32_t      disp;          /* displacement of ref in the data segment    */
      53             :         int16_t      disp_mb;       /* auxiliary code displacement (for membar)   */
      54             :         int16_t      patch_align;   /* auxiliary displacement for alignment       */
      55             :         functionptr  patcher;       /* patcher function to call                   */
      56             :         void*        ref;           /* reference passed                           */
      57             :         uint32_t     mcode;         /* machine code to be patched back in         */
      58             :         bool         done;          /* XXX preliminary: patch already applied?    */
      59             : };
      60             : 
      61             : 
      62             : /* macros *********************************************************************/
      63             : 
      64             : 
      65             : /* function prototypes ********************************************************/
      66             : 
      67             : void patcher_list_create(codeinfo *code);
      68             : void patcher_list_reset(codeinfo *code);
      69             : void patcher_list_free(codeinfo *code);
      70             : 
      71             : #if !defined(NDEBUG)
      72             : void patcher_list_show(codeinfo *code);
      73             : #endif
      74             : 
      75             : patchref_t *patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp);
      76             : 
      77             : void patcher_resolve(jitdata* jd);
      78             : 
      79             : bool patcher_is_patched(patchref_t* pr);
      80             : bool patcher_is_patched_at(void* pc);
      81             : 
      82             : // MD function.
      83             : bool patcher_is_valid_trap_instruction_at(void* pc);
      84             : 
      85             : bool patcher_handler(u1 *pc);
      86             : 
      87             : 
      88             : /* empty patcher (just patches back original mcode) ***************************/
      89             : 
      90             : void patcher_patch_code(patchref_t *pr);
      91             : 
      92             : 
      93             : /* patcher prototypes and macros **********************************************/
      94             : 
      95             : /* new patcher functions */
      96             : 
      97             : bool patcher_resolve_class(patchref_t *pr);
      98             : #define PATCHER_resolve_class (functionptr) patcher_resolve_class
      99             : 
     100             : bool patcher_initialize_class(patchref_t *pr);
     101             : #define PATCHER_initialize_class (functionptr) patcher_initialize_class
     102             : 
     103             : bool patcher_resolve_classref_to_classinfo(patchref_t *pr);
     104             : #define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
     105             : 
     106             : bool patcher_resolve_classref_to_vftbl(patchref_t *pr);
     107             : #define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
     108             : 
     109             : bool patcher_resolve_classref_to_index(patchref_t *pr);
     110             : #define PATCHER_resolve_classref_to_index (functionptr) patcher_resolve_classref_to_index
     111             : 
     112             : bool patcher_resolve_classref_to_flags(patchref_t *pr);
     113             : #define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
     114             : 
     115             : bool patcher_resolve_native_function(patchref_t *pr);
     116             : #define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
     117             : 
     118             : bool patcher_breakpoint(patchref_t *pr);
     119             : #define PATCHER_breakpoint (functionptr) patcher_breakpoint
     120             : 
     121             : /* old patcher functions */
     122             : 
     123             : bool patcher_get_putstatic(patchref_t *pr);
     124             : #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
     125             : 
     126             : #if defined(__I386__)
     127             : 
     128             : bool patcher_getfield(patchref_t *pr);
     129             : #define PATCHER_getfield (functionptr) patcher_getfield
     130             : 
     131             : bool patcher_putfield(patchref_t *pr);
     132             : #define PATCHER_putfield (functionptr) patcher_putfield
     133             : 
     134             : #else
     135             : 
     136             : bool patcher_get_putfield(patchref_t *pr);
     137             : #define PATCHER_get_putfield (functionptr) patcher_get_putfield
     138             : 
     139             : #endif /* defined(__I386__) */
     140             : 
     141             : #if defined(__I386__) || defined(__X86_64__)
     142             : 
     143             : bool patcher_putfieldconst(patchref_t *pr);
     144             : #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
     145             : 
     146             : #endif /* defined(__I386__) || defined(__X86_64__) */
     147             : 
     148             : bool patcher_invokestatic_special(patchref_t *pr);
     149             : #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
     150             : 
     151             : bool patcher_invokevirtual(patchref_t *pr);
     152             : #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
     153             : 
     154             : bool patcher_invokeinterface(patchref_t *pr);
     155             : #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
     156             : 
     157             : #if defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
     158             : 
     159             : bool patcher_checkcast_interface(patchref_t *pr);
     160             : #define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
     161             : 
     162             : bool patcher_instanceof_interface(patchref_t *pr);
     163             : #define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
     164             : 
     165             : #endif /* defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) */
     166             : 
     167             : #if defined(__S390__)
     168             : 
     169             : bool patcher_checkcast_instanceof_interface(patchref_t *pr);
     170             : #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
     171             : 
     172             : #endif /* defined(__S390__) */
     173             : 
     174             : #if defined(__I386__)
     175             : 
     176             : bool patcher_aconst(patchref_t *pr);
     177             : #define PATCHER_aconst (functionptr) patcher_aconst
     178             : 
     179             : bool patcher_builtin_multianewarray(patchref_t *pr);
     180             : #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
     181             : 
     182             : bool patcher_builtin_arraycheckcast(patchref_t *pr);
     183             : #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
     184             : 
     185             : bool patcher_checkcast_instanceof_flags(patchref_t *pr);
     186             : #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
     187             : 
     188             : bool patcher_checkcast_class(patchref_t *pr);
     189             : #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
     190             : 
     191             : bool patcher_instanceof_class(patchref_t *pr);
     192             : #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
     193             : 
     194             : #endif /* defined(__I386__) */
     195             : 
     196             : #endif // _PATCHER_COMMON_HPP
     197             : 
     198             : 
     199             : /*
     200             :  * These are local overrides for various environment variables in Emacs.
     201             :  * Please do not remove this and leave it at the end of the file, where
     202             :  * Emacs will automagically detect them.
     203             :  * ---------------------------------------------------------------------
     204             :  * Local variables:
     205             :  * mode: c++
     206             :  * indent-tabs-mode: t
     207             :  * c-basic-offset: 4
     208             :  * tab-width: 4
     209             :  * End:
     210             :  * vim:noexpandtab:sw=4:ts=4:
     211             :  */

Generated by: LCOV version 1.11