github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/jit-interp.h (about)

     1  /*
     2   * jit-interp.h - Bytecode interpreter for platforms without native support.
     3   *
     4   * Copyright (C) 2004  Southern Storm Software, Pty Ltd.
     5   *
     6   * This file is part of the libjit library.
     7   *
     8   * The libjit library is free software: you can redistribute it and/or
     9   * modify it under the terms of the GNU Lesser General Public License
    10   * as published by the Free Software Foundation, either version 2.1 of
    11   * the License, or (at your option) any later version.
    12   *
    13   * The libjit library is distributed in the hope that it will be useful,
    14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    16   * Lesser General Public License for more details.
    17   *
    18   * You should have received a copy of the GNU Lesser General Public
    19   * License along with the libjit library.  If not, see
    20   * <http://www.gnu.org/licenses/>.
    21   */
    22  
    23  #ifndef	_JIT_INTERP_H
    24  #define	_JIT_INTERP_H
    25  
    26  #include "jit-internal.h"
    27  #include "jit-apply-rules.h"
    28  #include "jit-interp-opcode.h"
    29  
    30  #ifdef	__cplusplus
    31  extern	"C" {
    32  #endif
    33  
    34  /*
    35   * Structure of a stack item.
    36   */
    37  typedef union
    38  {
    39  	jit_int		int_value;
    40  	jit_uint	uint_value;
    41  	jit_long	long_value;
    42  	jit_ulong	ulong_value;
    43  	jit_float32	float32_value;
    44  	jit_float64	float64_value;
    45  	jit_nfloat	nfloat_value;
    46  	void	   *ptr_value;
    47  #if JIT_APPLY_MAX_STRUCT_IN_REG != 0
    48  	char		struct_value[JIT_APPLY_MAX_STRUCT_IN_REG];
    49  #endif
    50  
    51  } jit_item;
    52  
    53  /*
    54   * Number of items that make up a struct or union value on the stack.
    55   */
    56  #define	JIT_NUM_ITEMS_IN_STRUCT(size)		\
    57  	(((size) + (sizeof(jit_item) - 1)) / sizeof(jit_item))
    58  
    59  /*
    60   * Information that is prefixed to a function that describes
    61   * its interpretation context.  The code starts just after this.
    62   */
    63  typedef struct jit_function_interp *jit_function_interp_t;
    64  struct jit_function_interp
    65  {
    66  	/* The function that this structure is associated with */
    67  	jit_function_t	func;
    68  
    69  	/* Size of the argument area to allocate, in bytes */
    70  	unsigned int	args_size;
    71  
    72  	/* Size of the local stack frame to allocate, in bytes */
    73  	unsigned int	frame_size;
    74  
    75  	/* Size of the working stack area of the frame, in items */
    76  	unsigned int	working_area;
    77  };
    78  
    79  /*
    80   * Get the size of the "jit_function_interp" structure, rounded
    81   * up to a multiple of "void *".
    82   */
    83  #define	jit_function_interp_size	\
    84  			((sizeof(struct jit_function_interp) + sizeof(void *) - 1) & \
    85  			 ~(sizeof(void *) - 1))
    86  
    87  /*
    88   * Get the entry point for a function, from its "jit_function_interp_t" block.
    89   */
    90  #define	jit_function_interp_entry_pc(info)	\
    91  			((void **)(((unsigned char *)(info)) + jit_function_interp_size))
    92  
    93  #ifdef	__cplusplus
    94  };
    95  #endif
    96  
    97  #endif /* _JIT_INTERP_H */