/**
* Function returns method name.
*
* @param method - method handle
*
* @return Method name bytes.
*
* @note Assertion is raised if method is equal to null.
*/
const char *
method_get_name(Method_Handle method);
/**
* Function returns method descriptor.
*
* @param method - method handle
*
* @return Method descriptor bytes.
*
* @note Assertion is raised if method is equal to null.
*/
const char *
method_get_descriptor(Method_Handle method);
/**
* Function returns a signature that can be used to iterate over method's arguments
* and query the type of the method result.
*
* @param method - method handle
*
* @return Return a method signature.
*
* @note Assertion is raised if method is equal to null.
*/
Method_Signature_Handle
method_get_signature(Method_Handle method);
/**
* Function returns a class in which the method is declared.
*
* @param method - method handle
*
* @return Return a class in which the method is declared.
*
* @note Assertion is raised if method is equal to null.
*/
Class_Handle
method_get_class(Method_Handle method);
/**
* Function returns a returned java type for the method.
*
* @param method - method handle
*
* @return Return a returned java type.
*
* @note Assertion is raised if method is equal to null.
*/
Java_Type
method_get_return_type(Method_Handle method);
/**
* Function returns access flags for a given method.
*
* @param method - method handle
*
* @return Return access flags.
*
* @note Assertion is raised if method is equal to null.
*/
unsigned short
method_get_flags(Method_Handle method);
/**
* Function checks if a given method is private.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is private.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_private(Method_Handle method);
/**
* Function checks if a given method is public.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is public.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_public(Method_Handle method);
/**
* Function checks if a given method is static.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is static.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_static(Method_Handle method);
/**
* Function checks if a given method is native.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is native.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_native(Method_Handle method);
/**
* Function checks if a given method is synchronized.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is synchronized.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_synchronized(Method_Handle method);
/**
* Function checks if a given method is final.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is final.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_final(Method_Handle method);
/**
* Function checks if a given method is abstract.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is abstract.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_abstract(Method_Handle method);
/**
* Function checks if a given method is strict.
* Java methods may have a flag set to indicate that floating point operations
* must be performed in the strict mode.
*
* @param method - method handle
*
* @return Return TRUE
the ACC_STRICT
flag is set for
* a Java method and FALSE
otherwise.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_strict(Method_Handle method);
/**
* Function checks if a given method is a fake method.
*
* @param method - method handle
*
* @return Return TRUE
if a given method is a fake method.
*
* @note Assertion is raised if method is equal to null.
*/
Boolean
method_is_fake(Method_Handle method);
/**
* Function checks if a given method is overridden.
*
* @param method - method handle
*
* @return Return TRUE
if the method has been overriden in
* a subclass and FALSE
otherwise.
*
* @note Assertion is raised if method is equal to null.
* @note If method_is_overridden returns FALSE
, loading
* of a subclass later in the execution of the program may change invalidate
* this condition. If a JIT uses method_is_overridden to implement
* unconditional inlining, it must be prepared to patch the code later
* (see vm_register_jit_overridden_method_callback).
*/
Boolean
method_is_overridden(Method_Handle method);
/**
* Function returns TRUE if the method should not be inlined.
* There may also be other reasons why a method shouldn't be inlined,
* e.g., native methods can't be inlined and in Java you can't inlined
* methods that are loaded by a different class loader than the caller.
*
* @param method - method handle
*
* @return Return TRUE
if the method should not be inlined.
*
* @note Assertion is raised if method is equal to null.
* @note Always FALSE
for Java.
*/
Boolean
method_is_no_inlining(Method_Handle method);
/**
* Function sets the number of exception handlers in the code generated by the JIT
* jit for a given method.
*
* @param method - method handle
* @param jit - jit handle
* @param num_handlers - the number of exception handlers
*
* @note The JIT must then call method_set_target_handler_info function
* for each of the num_handlers exception handlers.
*/
void
method_set_num_target_handlers(Method_Handle method, JIT_Handle jit,
unsigned short num_handlers);
/**
* Function checks if the local variable is pinned.
*
* @param method - method handle
* @param index - the local variable index
*
* @return Return TRUE if the local variable is pinned.
*/
Boolean
method_vars_is_pinned(Method_Handle method, unsigned short index);
/**
* Function returns a unique id associated with a method handle.
*
* @param method - method handle
*
* @return Return a unique id associated with a method handle.
*/
uint32
method_get_id(Method_Handle method);
/**
* The function returns a method handle for an accessible method overriding
* method in klass or in its closest superclass that overrides method.
*
* @param klass - class handle
* @param method - method handle
*
* @return Return a method handle for an accessible method overriding method.
*/
Method_Handle
method_find_overridden_method(Class_Handle klass, Method_Handle method);
/**
* Function returns the type info of the local variable.
*
* @param method - method handle
* @param index - the local variable number
*
* @return Return the type info of the local variable.
*
* @note Since local variables are not typed in Java, this function
* always returns NULL for Java methods.
*/
Type_Info_Handle
method_vars_get_type_info(Method_Handle method, unsigned short index);
/**
* Function returns the number of arguments defined for the method.
* This number automatically includes the this pointer (if present).
*
* @param method_signature - method signature handle
*
* @return Return the number of arguments defined for the method.
*/
unsigned char
method_args_get_number(Method_Signature_Handle method_signature);
/**
* Function initializes the ChaMethodIterator iterator, to iterate over all
* methods that match the method signature and descend from klass
* (including klass itself).
*
* @param iterator - class iterator
* @param method - method handle
* @param klass - class handle
*
* @return Return TRUE
if iteration is supported over klass,
* FALSE
if not.
*
* @note Reference to internal type ChaMethodIterator.
*/
Boolean
method_iterator_initialize(ChaMethodIterator *iterator, Method_Handle method,
Class_Handle klass);
/**
* Function advances the iterator.
*
* @param iterator - class iterator
*
* @note Reference to internal type ChaMethodIterator.
*/
void
method_iterator_advance(ChaMethodIterator *iterator);
/**
* Function returns the current method of the iterator.
* NULL is returned if there are no more methods.
*
* @param iterator - class iterator
*
* @return Return the current method of the iterator.
*
* @note Reference to internal type ChaMethodIterator.
*/
Method_Handle
method_iterator_get_current(ChaMethodIterator *iterator);
/**
* Function returns the number of exception a given method can throw.
*
* @param method - method handle
*
* @return Return the number of exception.
*
* @note Replaces method_number_throws function.
*/
unsigned short
method_get_num_throws(Method_Handle method);
/**
* Function returns the exception class a given method can throw.
*
* @param method - method handle
* @param index - the exception number
*
* @return Return the exception class a given method can throw.
*/
Class_Handle
method_get_throws(Method_Handle method, unsigned short index);
/**
* Function returns number of method exception handlers.
*
* @param method - method handle
*
* @return Number of method exception handlers.
*
* @note Assertion is raised if method is equal to null.
* @note Replaces method_get_exc_handler_number function.
*/
unsigned short
method_get_exc_handler_number(Method_Handle method);
/**
* Function obtains method exception handle info.
*
* @param method - method handle
* @param index - exception handle index number
* @param start_pc - resulting pointer to exception handle start program count
* @param end_pc - resulting pointer to exception handle end program count
* @param handler_pc - resulting pointer to exception handle program count
* @param catch_type - resulting pointer to constant pool entry index
*
* @note Assertion is raised if method is equal to null or
* exception handle index is out of range or
* any pointer is equal to null.
* @note Replaces method_get_exc_handler_info function.
*/
void
method_get_handler_info( method_handler method, unsigned short index,
unsigned short *start_pc, unsigned short *end_pc,
unsigned short *handler_pc, unsigned short *catch_type );
/**
* Function returns the type info for return value.
*
* @param method_signature - method signature handle
*
* @return Return the type info for return value.
*/
Type_Info_Handle
method_ret_type_get_type_info(Method_Signature_Handle method_signature);
/**
* Function returns the type info for argument.
*
* @param method_signature - method signature handle
* @param index - argument index
*
* @return Return the type info for argument.
*/
Type_Info_Handle
method_args_get_type_info(Method_Signature_Handle method_signature, unsigned index);
/**
* Function returns the method argument list.
*
* @param method - method handle
*
* @return Return the method argument list.
*/
Arg_List_Iterator
method_get_argument_list(Method_Handle method);
/**
* Function moves the iterator to the next argument in the list.
*
* @param iterator - argument list iterator
*
* @return Return the moved iterator.
*
* @note Replaces advance_arg_iterator function.
*/
Arg_List_Iterator
method_advance_arg_iterator(Arg_List_Iterator iterator);
/**
* Function returns Java type of the argument pointed by the iterator.
*
* @param iterator - argument list iterator
*
* @return Return Java type of the argument.
*
* @note Replaces curr_arg function.
*/
Java_Type
method_current_arg(Arg_List_Iterator iterator);
/**
* Function returns the method bytecode size.
*
* @param method - method handle
*
* @return Return the method bytecode size.
*
* @note Replaces method_get_code_length function.
*/
size_t
method_get_bytecode_size(Method_Handle method);
/*
* Function returns the method bytecode array.
*
* @param method - method handle
*
* @return Return the method bytecode array.
*
* @note Assertion is raised if method is equal to null.
* @note Reference to type Byte.
* @note Replaces method_get_bytecode function.
*/
const Byte *
method_get_bytecode_addr(Method_Handle method);
/**
* Function returns maximal local variables number of a given method.
*
* @param method - method handle
*
* @return Maximal local variables number of method.
*
* @note Assertion is raised if method is equal to null.
* @note Replaces method_get_max_local and method_vars_get_number functions.
*/
unsigned short
method_get_max_locals(Method_Handle method);
/**
* Function returns maximal stack deep of method.
*
* @param method - method handler
*
* @return Maximal stack deep of method.
*
* @note Assertion is raised if method is equal to null.
*/
unsigned short
method_get_max_stack(Method_Handle method);
/**
* Function returns the offset in bytes from the start of
* the vtable to the entry for a given method.
*
* @param method - method handler
*
* @return Return the offset in bytes from the start of the vtable
* to the entry for a given method.
*/
unsigned
method_get_offset(Method_Handle method);
/**
* Function return the address where the code pointer for a given method is.
* A simple JIT that doesn't support recompilation (see e.g.
* vm_register_jit_recompiled_method_callback) can only generate
* code with indirect branches through the address provided by
* method_get_indirect_address function.
*
* @param method - method handler
*
* @return Return the address where the code pointer for a given method is.
*/
void *
method_get_indirect_address(Method_Handle method);
/**
* This function allows allocation of multiple chunks of code with different
* heat values. The JIT is responsible for specifying ids that are unique
* within the same method.
* The first instruction of the chunk with id=0 is the entry point of the method.
* If the CAA_Allocate argument is specified, memory is allocated and a pointer
* to it is returned. If the CAA_Simulate argument is specified, no memory is
* actually allocated and the VM returns an address that would have been
* allocated if CAA_Allocate was specified and all the other arguments were
* the same. The VM may return NULL when CAA_Simulate is specified. This may
* for instance happen if multiple heat values were mapped to the same code
* pool or if the specified size would require a new code pool.
*
* @param method - method handle
* @param jit - jit handle
* @param size - allocated code block size
* @param alignment - memory block aligment
* @param heat - ?
* @param id - ?
* @param action - result return action
*
* @return Pointer to allocated code block.
*
* @note Reference to type Byte.
*/
Byte *
method_allocate_code_block(Method_Handle method, JIT_Handle jit, size_t size,
size_t alignment, unsigned heat, int id,
Code_Allocation_Action action);
/**
* Function allocates the "read-write" data block for this method.
* This memory block cannot be retrieved later. The intention is to
* use the data block for data that may be needed during the program
* execution (e.g. tables for switch statements).
*
* Separation of data allocated by method_allocate_data_block and
* method_allocate_info_block may help improve locality of references
* to data accessed during execution of compiled code and data accessed during
* stack unwinding.
*
* @param method - method handle
* @param jit - jit handle
* @param size - allocated code block size
* @param alignment - memory block aligment
*
* @return Pointer to allocated data block.
*
* @note Reference to type Byte.
*
* @see method_allocate_info_block
*/
Byte *
method_allocate_data_block(Method_Handle method, JIT_Handle jit, size_t size,
size_t alignment);
/**
* Function allocates an info block for this method.
* An info block can be later retrieved by the JIT. The JIT may
* for instance store GC maps for root set enumeration and stack
* unwinding in the onfo block.
*
* @param method - method handle
* @param jit - jit handle
* @param size - allocated code block size
*
* @return Pointer to allocated info block.
*
* @note Reference to type Byte.
*
* @see method_allocate_data_block
*/
Byte *
method_allocate_info_block(Method_Handle method, JIT_Handle jit, size_t size);
/**
* Function retrieves the memory block allocated earlier by
* method_allocate_data_block function.
* A pair uniquely identifies a JIT info block.
*
* @param method - method handle
* @param jit - jit handle
*
* @return Pointer to allocated data block.
*
* @note Reference to type Byte.
*/
Byte *
method_get_data_block_jit(Method_Handle method, JIT_Handle jit);
/**
* Function retrieves the memory block allocated earlier by
* method_allocate_info_block function.
* A pair uniquely identifies a JIT info block.
*
* @param method - method handle
* @param jit - jit handle
*
* @return Pointer to allocated info block.
*
* @note Reference to type Byte.
*/
Byte *
method_get_info_block_jit(Method_Handle method, JIT_Handle jit);