From 7dbb98494fd4815873f244cbc1538d8ce9c28f0d Mon Sep 17 00:00:00 2001 From: Ilya Berezhniuk Date: Sun, 16 Mar 2008 02:43:01 +0300 Subject: [PATCH] Make Port shared --- make/vm/em.xml | 3 +- make/vm/hythr.xml | 3 +- make/vm/jitrino.xml | 3 +- make/vm/port.xml | 15 +++- make/vm/vmcore.xml | 4 +- vm/port/build/port.exp | 120 +++++++++++++++++++++++++++ vm/port/include/platform_core_natives.h | 12 +++- vm/port/include/port_atomic.h | 15 ++-- vm/port/include/port_barriers.h | 4 +- vm/port/include/port_crash_handler.h | 16 ++-- vm/port/include/port_general.h | 1 + vm/port/include/port_memaccess.h | 5 +- vm/port/include/port_modules.h | 9 +- vm/port/include/port_sysencoding.h | 6 +- vm/port/include/port_thread.h | 24 +++--- vm/port/include/port_unwind.h | 7 +- vm/port/src/thread/linux/thread_asm_em64t.s | 10 +- vm/port/src/thread/linux/thread_em64t.c | 8 ++ vm/vmcore/build/vmcore.exp | 34 -------- 19 files changed, 209 insertions(+), 90 deletions(-) create mode 100644 vm/port/build/port.exp diff --git a/make/vm/em.xml b/make/vm/em.xml index 757c794..4b0b971 100644 --- a/make/vm/em.xml +++ b/make/vm/em.xml @@ -43,8 +43,7 @@ - - + diff --git a/make/vm/hythr.xml b/make/vm/hythr.xml index 1f83c90..f387934 100644 --- a/make/vm/hythr.xml +++ b/make/vm/hythr.xml @@ -42,8 +42,9 @@ - + diff --git a/make/vm/jitrino.xml b/make/vm/jitrino.xml index 9457119..2caa58f 100644 --- a/make/vm/jitrino.xml +++ b/make/vm/jitrino.xml @@ -85,8 +85,9 @@ - + + diff --git a/make/vm/port.xml b/make/vm/port.xml index 4571fe5..e90678a 100644 --- a/make/vm/port.xml +++ b/make/vm/port.xml @@ -63,6 +63,8 @@ + + @@ -87,7 +89,7 @@ - + @@ -127,9 +129,16 @@ - + - + + + + + + + + diff --git a/make/vm/vmcore.xml b/make/vm/vmcore.xml index 52a33b1..c43d79a 100644 --- a/make/vm/vmcore.xml +++ b/make/vm/vmcore.xml @@ -212,8 +212,8 @@ - + + diff --git a/vm/port/build/port.exp b/vm/port/build/port.exp new file mode 100644 index 0000000..1e53ad9 --- /dev/null +++ b/vm/port/build/port.exp @@ -0,0 +1,120 @@ +PORT_0.1 { + global : + + init_log_system; + shutdown_log_system; + set_logging_level_from_file; + log4cxx_from_c; + set_threshold; + is_enabled; + is_warn_enabled; + is_info_enabled; + is_log_enabled; + is_trace_enabled; + set_out; + set_header_format; + set_thread_specific_out; + log_printf; + + get_current_time; + port_rw_barrier; + port_write_barrier; + port_init_crash_handler; + port_shutdown_crash_handler; + port_crash_handler_*; + port_set_breakpoint; + port_clear_breakpoint; + port_is_breakpoint_set; + port_read_memory; + port_write_memory; + port_get_all_modules; + port_dump_modules; + port_clear_modules; + port_find_module; + port_get_utf8_converted_system_message_length; + port_convert_system_error_message_to_utf8; + port_thread_*; + port_transfer_to_regs; + port_set_longjump_regs; + port_transfer_to_function; + port_init_unwind_context; + port_clean_unwind_context; + port_unwind_frame; + port_atomic_*; + port_disas*; + port_dso_*; + port_filepath_*; + port_executable_name; + port_CPUs_number; + port_CPU_architecture; + port_OS_name_version; + port_user_*; + port_nanotimer; + port_vmem_*; + +# APR functions used by VM core and other components + apr_initialize; + apr_atomic_cas32; + apr_atomic_casptr; + apr_atomic_dec32; + apr_atomic_inc32; + apr_dso_error; + apr_dso_load; + apr_dso_sym; + apr_dso_unload; + apr_file_*; + apr_filepath_get; + apr_gethostname; + apr_hash_*; + apr_itoa; + apr_mmap_create; + apr_mmap_delete; + apr_os_thread_current; + apr_palloc; + apr_pool_clear; + apr_pool_create_ex; + apr_pool_destroy; + apr_pstrcat; + apr_pstrdup; + apr_snprintf; + apr_stat; + apr_strerror; + apr_temp_dir_get; + apr_thread_*; + apr_thread_rwlock_*; + apr_time_now; +# Some of these APR functions are not used in Port itself, but they +# should be exported, so there are dummy calls to these functions +# in port/src/wrapper/apr_stubs.c file to ensure they are linked +# apr_stubs_dummy; +# apr_initialize; +# apr_allocator_*; +# apr_atomic_*; +# apr_dso_*; +# apr_file_*; +# apr_filepath_*; +# apr_gethostname; +# apr_hash_*; +# apr_mmap_*; +# apr_os_thread_current; +# apr_palloc; +# apr_palloc_debug; +# apr_pool_*; +# apr_pstrcat; +# apr_pstrdup; +# apr_snprintf; +# apr_stat; +# apr_strerror; +# apr_temp_dir_get; +# apr_thread_mutex_*; +# apr_thread_rwlock_*; +# apr_time_now; + +# Workaround for LogParams::release C++ function used by EM + *LogParams*; +# Workaround for API used by GC_CC + *MemoryPool*; +# + local : *; +}; + diff --git a/vm/port/include/platform_core_natives.h b/vm/port/include/platform_core_natives.h index fca2ddc..1e16b96 100644 --- a/vm/port/include/platform_core_natives.h +++ b/vm/port/include/platform_core_natives.h @@ -24,9 +24,19 @@ #include "jni.h" +#include "port_general.h" + +#ifdef __cplusplus +extern "C" { +#endif // TIME -jlong get_current_time(); +VMEXPORT jlong get_current_time(); + + +#ifdef __cplusplus +} +#endif #endif // _PLATFORM_CORE_NATIVES_H_ diff --git a/vm/port/include/port_atomic.h b/vm/port/include/port_atomic.h index 17a4fb7..c765abd 100644 --- a/vm/port/include/port_atomic.h +++ b/vm/port/include/port_atomic.h @@ -27,7 +27,6 @@ * Atomic operations */ -#include "open/types.h" #include "port_general.h" /** @@ -56,7 +55,7 @@ extern "C" { * @param[in] comp - the value to compare with * @return The old value. */ -APR_DECLARE(uint8) port_atomic_cas8(volatile uint8 * data, +APR_DECLARE(uint8) port_atomic_cas8(volatile uint8 * data, uint8 value, uint8 comp); /** @@ -69,7 +68,7 @@ APR_DECLARE(uint8) port_atomic_cas8(volatile uint8 * data, * @param[in] comp - the value to compare with * @return The old value. */ -APR_DECLARE(uint16) port_atomic_cas16(volatile uint16 * data, +APR_DECLARE(uint16) port_atomic_cas16(volatile uint16 * data, uint16 value, uint16 comp); /** @@ -82,7 +81,7 @@ APR_DECLARE(uint16) port_atomic_cas16(volatile uint16 * data, * @param[in] comp - the value to compare with * @return The old value. */ -APR_DECLARE(uint64) port_atomic_cas64(volatile uint64 * data, +APR_DECLARE(uint64) port_atomic_cas64(volatile uint64 * data, uint64 value, uint64 comp); /** @} */ @@ -136,23 +135,23 @@ PORT_INLINE uint64 port_atomic_cas64(volatile uint64 * data , uint64 value, uint #pragma intrinsic(_InterlockedCompareExchange16) #pragma intrinsic(_InterlockedCompareExchange64) -PORT_INLINE uint8 port_atomic_cas8(volatile uint8 * data, +APR_DECLARE(uint8) port_atomic_cas8(volatile uint8 * data, uint8 value, uint8 comp); -PORT_INLINE uint16 port_atomic_cas16(volatile uint16 * data, +PORT_INLINE uint16 port_atomic_cas16(volatile uint16 * data, uint16 value, uint16 comp) { return _InterlockedCompareExchange16((volatile SHORT *)data, value, comp); } -PORT_INLINE uint64 port_atomic_cas64(volatile uint64 * data, +PORT_INLINE uint64 port_atomic_cas64(volatile uint64 * data, uint64 value, uint64 comp) { return _InterlockedCompareExchange64((volatile LONG64 *)data, value, comp); } -#elif defined (PLATFORM_POSIX) +#elif defined (PLATFORM_POSIX) PORT_INLINE uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) { #if defined(_IA32_) || defined(_EM64T_) diff --git a/vm/port/include/port_barriers.h b/vm/port/include/port_barriers.h index c263a8b..61460c6 100644 --- a/vm/port/include/port_barriers.h +++ b/vm/port/include/port_barriers.h @@ -38,8 +38,8 @@ extern "C" { #if defined(_IPF_) #if defined (PLATFORM_POSIX) -void port_rw_barrier(void); -void port_write_barrier(void); +VMEXPORT void port_rw_barrier(void); +VMEXPORT void port_write_barrier(void); #else /* POSIX */ #error "Windows/IPF is not supported!" diff --git a/vm/port/include/port_crash_handler.h b/vm/port/include/port_crash_handler.h index deca7f1..1692bf9 100644 --- a/vm/port/include/port_crash_handler.h +++ b/vm/port/include/port_crash_handler.h @@ -135,7 +135,7 @@ typedef struct * @return TRUE if initalization is successful. * FALSE if initialization failed. */ -Boolean port_init_crash_handler( +VMEXPORT Boolean port_init_crash_handler( port_signal_handler_registration *registrations, unsigned count, port_unwind_compiled_frame unwind_callback); @@ -201,7 +201,7 @@ typedef enum * * @returns supported crash handler features. */ -unsigned port_crash_handler_get_capabilities(); +VMEXPORT unsigned port_crash_handler_get_capabilities(); /** * Set crash handler output flags. Default mode is @@ -212,7 +212,7 @@ unsigned port_crash_handler_get_capabilities(); * * @param flags - crash handler output flags. */ -void port_crash_handler_set_flags(unsigned flags); +VMEXPORT void port_crash_handler_set_flags(unsigned flags); /** * Callback function that is called at the end of shutdown sequence. @@ -243,7 +243,7 @@ typedef void (*port_crash_handler_action)( * FALSE if action was not added because no memory could * be allocated. */ -Boolean port_crash_handler_add_action(port_crash_handler_action action); +VMEXPORT Boolean port_crash_handler_add_action(port_crash_handler_action action); /** * Shutdown signals and crash handler. All signals are assigned their @@ -255,7 +255,7 @@ Boolean port_crash_handler_add_action(port_crash_handler_action action); * @return TRUE if shutdown is * successful. FALSE if shutdown failed. */ -Boolean port_shutdown_crash_handler(); +VMEXPORT Boolean port_shutdown_crash_handler(); /** @@ -267,7 +267,7 @@ Boolean port_shutdown_crash_handler(); * @note Caller should keep store previous byte to restore * the location in future. */ -int port_set_breakpoint(void* addr, unsigned char* prev); +VMEXPORT int port_set_breakpoint(void* addr, unsigned char* prev); /** * Restores original byte in the location previously instrumented @@ -277,14 +277,14 @@ int port_set_breakpoint(void* addr, unsigned char* prev); * @return 0 if OK; nonzero if the location was not * instrumented yet or if an error occured. */ -int port_clear_breakpoint(void* addr, unsigned char prev); +VMEXPORT int port_clear_breakpoint(void* addr, unsigned char prev); /** * Checks if the location is instrumented. * @param [in] addr - memory location to deinstrument. * @return TRUE if instrumented; FALSE otherwise. */ -Boolean port_is_breakpoint_set(void* addr); +VMEXPORT Boolean port_is_breakpoint_set(void* addr); diff --git a/vm/port/include/port_general.h b/vm/port/include/port_general.h index 754dd4c..135625d 100644 --- a/vm/port/include/port_general.h +++ b/vm/port/include/port_general.h @@ -24,6 +24,7 @@ #include #include +#include "open/platform_types.h" #ifndef NULL #ifdef __cplusplus diff --git a/vm/port/include/port_memaccess.h b/vm/port/include/port_memaccess.h index 3122cae..dfc3577 100644 --- a/vm/port/include/port_memaccess.h +++ b/vm/port/include/port_memaccess.h @@ -20,6 +20,7 @@ #include #include "open/platform_types.h" +#include "port_general.h" #ifdef __cplusplus @@ -34,7 +35,7 @@ extern "C" { * @param buf - buffer to read to. * @return 0 if OK; nonzero if an error occured. */ -int port_read_memory(void* addr, size_t size, void* buf); +VMEXPORT int port_read_memory(void* addr, size_t size, void* buf); /** * Tries to write specified number of bytes from buffer to given address. @@ -43,7 +44,7 @@ int port_read_memory(void* addr, size_t size, void* buf); * @param buf - buffer to write from. * @return 0 if OK; nonzero if an error occured. */ -int port_write_memory(void* addr, size_t size, void* buf); +VMEXPORT int port_write_memory(void* addr, size_t size, void* buf); #ifdef __cplusplus diff --git a/vm/port/include/port_modules.h b/vm/port/include/port_modules.h index 3bd59bd..2abf289 100644 --- a/vm/port/include/port_modules.h +++ b/vm/port/include/port_modules.h @@ -25,6 +25,7 @@ #include #include #include "open/platform_types.h" +#include "port_general.h" typedef enum { @@ -61,20 +62,20 @@ extern "C" { * @param count_ptr - count of modules in the returned list * @return TRUE if OK; FALSE if error occured. */ -Boolean port_get_all_modules(native_module_t** list_ptr, int* count_ptr); +VMEXPORT Boolean port_get_all_modules(native_module_t** list_ptr, int* count_ptr); /** * Dumps the list of modules loaded to the current process.. * @param modules - pointer to the list of modules to dump. * @param out - stream for printing the dump. */ -void port_dump_modules(native_module_t* modules, FILE *out); +VMEXPORT void port_dump_modules(native_module_t* modules, FILE *out); /** * Clears the list of modules passed, writes NULL to the poiner. * @param modules - pointer to the list of modules to clear. */ -void port_clear_modules(native_module_t** list_ptr); +VMEXPORT void port_clear_modules(native_module_t** list_ptr); /** * Searches for the specific address in the list of modules. @@ -82,7 +83,7 @@ void port_clear_modules(native_module_t** list_ptr); * @param code_ptr - the address to look for. * @return native_module_t pointer if OK; otherwise, NULL. */ -native_module_t* port_find_module(native_module_t* modules, void* code_ptr); +VMEXPORT native_module_t* port_find_module(native_module_t* modules, void* code_ptr); #ifdef __cplusplus diff --git a/vm/port/include/port_sysencoding.h b/vm/port/include/port_sysencoding.h index 60e114f..20d3ffc 100644 --- a/vm/port/include/port_sysencoding.h +++ b/vm/port/include/port_sysencoding.h @@ -18,6 +18,8 @@ #ifndef _PORT_SYSENCODING_H_ #define _PORT_SYSENCODING_H_ +#include "port_general.h" + /** * @defgroup port_sysencoding Convert system messages to UTF8 * @ingroup port_apr @@ -36,7 +38,7 @@ extern "C" { * @return - number of bytes needed to hold the converted string including final * zero byte */ -int port_get_utf8_converted_system_message_length(char *system_message); +VMEXPORT int port_get_utf8_converted_system_message_length(char *system_message); /** * Converts system message from system encoding to UTF8 @@ -45,7 +47,7 @@ int port_get_utf8_converted_system_message_length(char *system_message); * @param buffer_size - number of bytes in the converted_message buffer * @param system_message - pointer to NULL terminated string in system encoding */ -void port_convert_system_error_message_to_utf8(char *converted_message, +VMEXPORT void port_convert_system_error_message_to_utf8(char *converted_message, int buffer_size, char *system_message); diff --git a/vm/port/include/port_thread.h b/vm/port/include/port_thread.h index 85014ba..3f3b6dc 100644 --- a/vm/port/include/port_thread.h +++ b/vm/port/include/port_thread.h @@ -71,22 +71,22 @@ PORT_INLINE int port_gettid() #endif } -void port_thread_yield_other(osthread_t thread); -int port_thread_cancel(osthread_t os_thread); +VMEXPORT void port_thread_yield_other(osthread_t thread); +VMEXPORT int port_thread_cancel(osthread_t os_thread); -int port_thread_suspend(osthread_t thread); -int port_thread_resume(osthread_t thread); -int port_thread_get_suspend_count(osthread_t thread); +VMEXPORT int port_thread_suspend(osthread_t thread); +VMEXPORT int port_thread_resume(osthread_t thread); +VMEXPORT int port_thread_get_suspend_count(osthread_t thread); -int port_thread_get_context(osthread_t thread, thread_context_t* pcontext); -int port_thread_set_context(osthread_t thread, thread_context_t* pcontext); +VMEXPORT int port_thread_get_context(osthread_t thread, thread_context_t* pcontext); +VMEXPORT int port_thread_set_context(osthread_t thread, thread_context_t* pcontext); -void port_thread_context_to_regs(Registers* regs, thread_context_t* context); -void port_thread_regs_to_context(thread_context_t* context, Registers* regs); +VMEXPORT void port_thread_context_to_regs(Registers* regs, thread_context_t* context); +VMEXPORT void port_thread_regs_to_context(thread_context_t* context, Registers* regs); /* Transfer control to specified register context */ -void port_transfer_to_regs(Registers* regs); +VMEXPORT void port_transfer_to_regs(Registers* regs); /** * Prepares 'Registers' structure and stack area pointed in for calling @@ -115,7 +115,7 @@ void port_transfer_to_regs(Registers* regs); * @param [in] ... - the parameters for 'fn'; should all be void* or of * the same size (pointer-sized) */ -void port_set_longjump_regs(void* fn, Registers* regs, int num, ...); +VMEXPORT void port_set_longjump_regs(void* fn, Registers* regs, int num, ...); /** * The same as 'port_set_longjump_regs', but transfers a control to the @@ -130,7 +130,7 @@ void port_set_longjump_regs(void* fn, Registers* regs, int num, ...); * @param [in] ... - the parameters for 'fn'; should all be void* or of * the same size (pointer-sized) */ -void port_transfer_to_function(void* fn, Registers* regs, int num, ...); +VMEXPORT void port_transfer_to_function(void* fn, Registers* regs, int num, ...); diff --git a/vm/port/include/port_unwind.h b/vm/port/include/port_unwind.h index 8067073..c7e8bd1 100644 --- a/vm/port/include/port_unwind.h +++ b/vm/port/include/port_unwind.h @@ -18,6 +18,7 @@ #ifndef __PORT_UNWIND_H__ #define __PORT_UNWIND_H__ +#include "port_general.h" #include "port_modules.h" typedef struct UnwindContext { @@ -31,10 +32,10 @@ extern "C" { #endif -bool port_init_unwind_context(UnwindContext* context, native_module_t* modules, Registers* regs); -void port_clean_unwind_context(UnwindContext* context); +VMEXPORT bool port_init_unwind_context(UnwindContext* context, native_module_t* modules, Registers* regs); +VMEXPORT void port_clean_unwind_context(UnwindContext* context); -bool port_unwind_frame(UnwindContext* context, Registers* regs); +VMEXPORT bool port_unwind_frame(UnwindContext* context, Registers* regs); #ifdef __cplusplus diff --git a/vm/port/src/thread/linux/thread_asm_em64t.s b/vm/port/src/thread/linux/thread_asm_em64t.s index 5468020..1d3ee4c 100644 --- a/vm/port/src/thread/linux/thread_asm_em64t.s +++ b/vm/port/src/thread/linux/thread_asm_em64t.s @@ -41,11 +41,11 @@ // uint32 eflags;; 88h // }; // -// void port_transfer_to_regs(Registers* regs) +// void port_transfer_to_regs_asm(Registers* regs) -.globl port_transfer_to_regs - .type port_transfer_to_regs, @function -port_transfer_to_regs: +.globl port_transfer_to_regs_asm + .type port_transfer_to_regs_asm, @function +port_transfer_to_regs_asm: movq %rdi, %rdx // regs pointer (1st param - RDI) -> RDX movq 0x08(%rdx), %rbp // RBP field @@ -116,5 +116,5 @@ __skipefl__: port_longjump_stub: // movq 128(%rsp), %rdi // load RDI with the address of saved Registers movq (%rsp), %rdi // load RDI with the address of saved Registers - callq port_transfer_to_regs // restore context + callq port_transfer_to_regs_asm // restore context ret // dummy RET - unreachable diff --git a/vm/port/src/thread/linux/thread_em64t.c b/vm/port/src/thread/linux/thread_em64t.c index a07057d..6bf776f 100644 --- a/vm/port/src/thread/linux/thread_em64t.c +++ b/vm/port/src/thread/linux/thread_em64t.c @@ -185,3 +185,11 @@ void port_transfer_to_function(void* fn, Registers* pregs, int num, ...) port_transfer_to_regs(®s); } + +// Workaround for improper -fPIC processing for assembler files +void port_transfer_to_regs_asm(Registers* regs); + +void port_transfer_to_regs(Registers* regs) +{ + port_transfer_to_regs_asm(regs); +} diff --git a/vm/vmcore/build/vmcore.exp b/vm/vmcore/build/vmcore.exp index ead2902..2cca907 100644 --- a/vm/vmcore/build/vmcore.exp +++ b/vm/vmcore/build/vmcore.exp @@ -140,14 +140,8 @@ VMCORE_0.1 { get_thread_ptr; get_vm_interface; initialize_arg_list_iterator; - init_log_system; - is_enabled; - is_info_enabled; is_it_finalize_thread; - is_log_enabled; is_property_set; - is_trace_enabled; - is_warn_enabled; Java_java_lang_ClassLoader_defineClass0; Java_java_lang_ClassLoader_findLoadedClass; Java_java_lang_ClassLoader_registerInitiatedClass; @@ -477,7 +471,6 @@ VMCORE_0.1 { jvmti_send_thread_start_end_event; jvmti_send_waited_monitor_event; jvmti_send_wait_monitor_event; - log4cxx_from_c; method_allocate_code_block; method_allocate_data_block; method_allocate_info_block; @@ -549,9 +542,6 @@ VMCORE_0.1 { method_vars_is_managed_pointer; method_vars_is_pinned; object_get_vtable_offset; - port_atomic_cas64; - port_vmem_page_sizes; - port_CPUs_number; resolve_class; resolve_class_new; resolve_field; @@ -562,15 +552,9 @@ VMCORE_0.1 { resolve_static_field; resolve_static_method; resolve_virtual_method; - set_header_format; - set_logging_level_from_file; set_native_finalizer_thread_flag; set_native_ref_enqueue_thread_flag; - set_out; set_property; - set_thread_specific_out; - set_threshold; - shutdown_log_system; st_alloc_frames; type_info_create_from_java_descriptor; type_info_get_class; @@ -654,26 +638,8 @@ VMCORE_0.1 { vtable_get_class; vtable_get_super_array_offset; -# Workaround for LogParams::release C++ function used by EM - *LogParams*; -# Workaround for EncoderBase used by JIT - *EncoderBase*; -# Workaround for encoder API used by JIT - *getOpndKindString*; - *getOpndSize*; - *getRegName*; - *getOpndKind*; # Workaround for VM_Global_State used by GC_GEN *VM_Global_State*; -# Workaround for apr API used by GC_GEN - apr_atomic_dec32; - apr_atomic_inc32; - apr_atomic_cas32; - apr_time_now; - apr_atomic_casptr; -# Workaround for API used by GC_CC - apr_atomic_xchg32; - *MemoryPool*; # Workaround for ManagedObject::_tag_pointer used in interpreter *ManagedObject*; # Workaround for C++ functions unspecified in interface used by interpreter -- 1.5.4