You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2008/03/07 06:59:52 UTC
svn commit: r634547 [2/2] - in /harmony/enhanced/drlvm/trunk/vm: em/src/
include/open/ interpreter/src/ jitrino/src/codegenerator/ia32/
jitrino/src/codegenerator/ipf/ jitrino/src/jet/ jitrino/src/shared/
jitrino/src/vm/ vmcore/build/ vmcore/src/class_s...
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.cpp?rev=634547&r1=634546&r2=634547&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.cpp Thu Mar 6 21:59:46 2008
@@ -15,18 +15,11 @@
* limitations under the License.
*/
-/**
- * @author Intel, Mikhail Y. Fursov
- * @version $Revision: 1.36.8.4.4.4 $
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <assert.h>
-#include "open/hythread_ext.h"
-
#include "Type.h"
#include "VMInterface.h"
#include "CompilationContext.h"
@@ -38,6 +31,395 @@
namespace Jitrino {
+vm_adaptor_t VMInterface::vm = 0;
+
+
+static allocation_handle_get_class_t allocation_handle_get_class = 0;
+
+//Class
+static class_get_array_element_class_t class_get_array_element_class = 0;
+static class_get_array_element_size_t class_get_array_element_size = 0;
+static class_get_array_of_class_t class_get_array_of_class = 0;
+static class_get_element_type_info_t class_get_element_type_info = 0;
+static class_get_name_t class_get_name = 0;
+static class_get_super_class_t class_get_super_class = 0;
+static class_get_depth_t class_get_depth = 0;
+static class_get_vtable_t class_get_vtable = 0;
+static class_get_allocation_handle_t class_get_allocation_handle = 0;
+static class_get_boxed_data_size_t class_get_boxed_data_size = 0;
+static class_get_num_array_dimensions_t class_get_num_array_dimensions = 0;
+static class_get_class_of_primitive_type_t class_get_class_of_primitive_type = 0;
+static class_get_const_string_intern_addr_t class_get_const_string_intern_addr = 0;
+static class_get_const_type_t class_get_const_type = 0;
+static class_get_const_addr_t class_get_const_addr = 0;
+static class_get_method_by_name_t class_get_method_by_name = 0;
+static class_get_field_by_name_t class_get_field_by_name = 0;
+static class_get_class_loader_t class_get_class_loader = 0;
+
+static class_is_array_t class_is_array = 0;
+static class_is_enum_t class_is_enum = 0;
+static class_is_final_t class_is_final = 0; //class_property_is_final
+static class_is_throwable_t class_is_throwable = 0; //class_hint_is_exceptiontype
+static class_is_interface_t class_is_interface = 0; //class_property_is_interface2
+static class_is_abstract_t class_is_abstract = 0; //class_property_is_abstract
+static class_is_initialized_t class_is_initialized = 0; //class_needs_initialization && class_is_initialized()
+static class_is_finalizable_t class_is_finalizable = 0;
+static class_is_instanceof_t class_is_instanceof = 0;
+static class_is_support_fast_instanceof_t class_is_support_fast_instanceof = 0;// class_get_fast_instanceof_flag
+static class_is_primitive_t class_is_primitive = 0;
+
+static class_lookup_class_by_name_using_bootstrap_class_loader_t class_lookup_class_by_name_using_bootstrap_class_loader = 0;
+static class_lookup_method_recursively_t class_lookup_method_recursively = 0;
+
+// Const Pool
+static class_cp_get_field_type_t class_cp_get_field_type = 0;// VM_Data_Type class_get_cp_field_type(Class_Handle src_class, unsigned short cp_index);
+static class_cp_get_entry_signature_t class_cp_get_entry_signature = 0;//const char* class_get_cp_entry_signature(Class_Handle src_class, unsigned short index); ? const char* const_pool_get_field_descriptor(Class_Handle cl, unsigned index);
+static class_cp_is_entry_resolved_t class_cp_is_entry_resolved = 0;//bool class_is_cp_entry_resolved(Compile_Handle ch, Class_Handle clazz, unsigned cp_index);
+static class_cp_get_class_name_t class_cp_get_class_name =0;//const char* const_pool_get_class_name(Class_Handle cl, unsigned index);
+static class_cp_get_method_class_name_t class_cp_get_method_class_name = 0;//const char *const_pool_get_method_class_name(Class_Handle cl, unsigned index);
+static class_cp_get_method_name_t class_cp_get_method_name = 0;//const char* const_pool_get_method_name(Class_Handle cl, unsigned index);
+
+
+//Field
+
+static field_get_address_t field_get_address = 0;
+static field_get_class_t field_get_class = 0;
+static field_get_descriptor_t field_get_descriptor = 0;
+static field_get_name_t field_get_name = 0;
+static field_get_offset_t field_get_offset = 0;
+static field_get_type_info_t field_get_type_info = 0; //field_get_type_info_of_field_value
+static field_is_final_t field_is_final = 0;
+static field_is_magic_t field_is_magic = 0; //Boolean field_is_magic(Field_Handle fh);
+static field_is_private_t field_is_private = 0;
+static field_is_static_t field_is_static = 0;
+static field_is_volatile_t field_is_volatile = 0;
+
+//Method
+
+static method_get_overridden_method_t method_get_overridden_method = 0;//method_find_overridden_method
+static method_get_info_block_jit_t method_get_info_block_jit = 0;
+static method_get_info_block_size_jit_t method_get_info_block_size_jit = 0;
+static method_get_name_t method_get_name = 0;
+static method_get_descriptor_t method_get_descriptor = 0;
+static method_get_byte_code_addr_t method_get_byte_code_addr = 0;
+static method_get_byte_code_size_t method_get_byte_code_size = 0;
+static method_get_max_stack_t method_get_max_stack = 0;
+static method_get_num_handlers_t method_get_num_handlers = 0;
+static method_get_offset_t method_get_offset = 0;
+static method_get_indirect_address_t method_get_indirect_address = 0;
+static method_get_native_func_addr_t method_get_native_func_addr = 0;
+static method_vars_get_number_t method_vars_get_number = 0;
+static method_args_get_number_t method_args_get_number = 0;
+static method_args_get_type_info_t method_args_get_type_info = 0;
+static method_ret_type_get_type_info_t method_ret_type_get_type_info = 0;
+static method_get_signature_t method_get_signature = 0;
+static method_get_class_t method_get_class = 0;
+static method_get_handler_info_t method_get_handler_info = 0;
+static method_get_code_block_addr_jit_new_t method_get_code_block_addr_jit_new = 0;
+static method_get_code_block_size_jit_new_t method_get_code_block_size_jit_new = 0;
+static method_get_side_effects_t method_get_side_effects = 0;
+
+static method_has_annotation_t method_has_annotation = 0;
+static method_is_private_t method_is_private = 0;
+static method_is_static_t method_is_static = 0;
+static method_is_native_t method_is_native = 0;
+static method_is_synchronized_t method_is_synchronized = 0;
+static method_is_final_t method_is_final = 0;
+static method_is_abstract_t method_is_abstract = 0;
+static method_is_strict_t method_is_strict = 0;
+static method_is_overridden_t method_is_overridden = 0;
+static method_is_no_inlining_t method_is_no_inlining = 0;
+
+
+static method_set_side_effects_t method_set_side_effects = 0;
+static method_set_num_target_handlers_t method_set_num_target_handlers = 0;
+static method_set_target_handler_info_t method_set_target_handler_info = 0;
+
+static method_lock_t method_lock = 0;
+static method_unlock_t method_unlock = 0;
+
+static method_allocate_code_block_t method_allocate_code_block = 0;
+static method_allocate_data_block_t method_allocate_data_block = 0;
+static method_allocate_info_block_t method_allocate_info_block = 0;
+static method_allocate_jit_data_block_t method_allocate_jit_data_block = 0;
+
+
+//Object
+static object_get_vtable_offset_t object_get_vtable_offset = 0;
+
+
+//Resolve
+static resolve_class_t resolve_class = 0;
+static resolve_class_new_t resolve_class_new = 0;
+static resolve_special_method_t resolve_special_method = 0;
+static resolve_interface_method_t resolve_interface_method = 0;
+static resolve_static_method_t resolve_static_method = 0;
+static resolve_virtual_method_t resolve_virtual_method = 0;
+static resolve_nonstatic_field_t resolve_nonstatic_field = 0;
+static resolve_static_field_t resolve_static_field = 0;
+
+//Type Info
+
+static type_info_create_from_java_descriptor_t type_info_create_from_java_descriptor = 0;
+static type_info_get_type_name_t type_info_get_type_name = 0;
+static type_info_get_class_t type_info_get_class = 0;
+static type_info_get_class_no_exn_t type_info_get_class_no_exn = 0;
+static type_info_get_num_array_dimensions_t type_info_get_num_array_dimensions = 0;
+static type_info_get_type_info_t type_info_get_type_info = 0;
+
+static type_info_is_void_t type_info_is_void = 0;
+static type_info_is_reference_t type_info_is_reference = 0;
+static type_info_is_resolved_t type_info_is_resolved = 0;
+static type_info_is_primitive_t type_info_is_primitive = 0;
+static type_info_is_vector_t type_info_is_vector = 0;
+
+//Vector
+static vector_get_first_element_offset_t vector_get_first_element_offset = 0; //vector_first_element_offset_class_handle
+static vector_get_length_offset_t vector_get_length_offset = 0; //vector_length_offset
+
+//Vm
+static vm_tls_alloc_t vm_tls_alloc = 0; //IDATA VMCALL hythread_tls_alloc(hythread_tls_key_t *handle)
+static vm_tls_get_offset_t vm_tls_get_offset = 0; //UDATA VMCALL hythread_tls_get_offset(hythread_tls_key_t key)
+static vm_tls_get_request_offset_t vm_tls_get_request_offset = 0; //DATA VMCALL hythread_tls_get_request_offset
+static vm_tls_is_fast_t vm_tls_is_fast = 0;//UDATA VMCALL hythread_uses_fast_tls
+static vm_get_tls_offset_in_segment_t vm_get_tls_offset_in_segment = 0;//IDATA VMCALL hythread_get_hythread_offset_in_tls(void)
+
+static vm_properties_destroy_keys_t vm_properties_destroy_keys = 0;//void destroy_properties_keys(char** keys)
+static vm_properties_destroy_value_t vm_properties_destroy_value = 0;//void destroy_property_value(char* value)
+static vm_properties_get_keys_t vm_properties_get_keys = 0;//char** get_properties_keys(PropertyTable table_number);
+static vm_properties_get_keys_starting_with_t vm_properties_get_keys_starting_with = 0;
+static vm_properties_get_value_t vm_properties_get_value = 0;//char* get_property(const char* key, PropertyTable table_number)
+
+
+static vm_get_system_object_class_t vm_get_system_object_class = 0; // get_system_object_class
+static vm_get_system_class_class_t vm_get_system_class_class = 0; // get_system_class_class
+static vm_get_system_string_class_t vm_get_system_string_class = 0; // get_system_string_class
+static vm_get_vtable_base_t vm_get_vtable_base = 0; //POINTER_SIZE_INT vm_get_vtable_base()
+static vm_get_heap_base_address_t vm_get_heap_base_address = 0; //vm_heap_base_address
+static vm_get_heap_ceiling_address_t vm_get_heap_ceiling_address = 0; //vm_heap_ceiling_address
+static vm_is_heap_compressed_t vm_is_heap_compressed = 0;//vm_references_are_compressed();
+static vm_is_vtable_compressed_t vm_is_vtable_compressed = 0;//vm_vtable_pointers_are_compressed();
+static vm_patch_code_block_t vm_patch_code_block = 0;
+static vm_compile_method_t vm_compile_method = 0;
+static vm_register_jit_extended_class_callback_t vm_register_jit_extended_class_callback = 0;
+static vm_register_jit_overridden_method_callback_t vm_register_jit_overridden_method_callback = 0;
+static vm_register_jit_recompiled_method_callback_t vm_register_jit_recompiled_method_callback = 0;
+static vm_compiled_method_load_t vm_compiled_method_load = 0;
+static vm_helper_get_addr_t vm_helper_get_addr = 0;
+static vm_helper_get_addr_optimized_t vm_helper_get_addr_optimized = 0;
+static vm_helper_get_by_name_t vm_helper_get_by_name = 0;
+static vm_helper_get_calling_convention_t vm_helper_get_calling_convention = 0;
+static vm_helper_get_interruptibility_kind_t vm_helper_get_interruptibility_kind = 0;
+static vm_helper_get_magic_helper_t vm_helper_get_magic_helper = 0;
+static vm_helper_get_name_t vm_helper_get_name = 0;
+
+//VTable
+static vtable_get_class_t vtable_get_class = 0;
+
+static vm_enumerate_root_reference_t vm_enumerate_root_reference = 0;
+static vm_enumerate_compressed_root_reference_t vm_enumerate_compressed_root_reference = 0;
+static vm_enumerate_root_interior_pointer_t vm_enumerate_root_interior_pointer = 0;
+
+#undef GET_INTERFACE
+
+#define GET_INTERFACE(get_adapter, func_name) \
+ (func_name##_t)get_adapter(#func_name); assert(func_name)
+
+
+ bool VMInterface::setVmAdapter(vm_adaptor_t a) {
+ vm = a;
+ allocation_handle_get_class = GET_INTERFACE(vm, allocation_handle_get_class);
+
+ //Class
+ class_get_array_element_class = GET_INTERFACE(vm, class_get_array_element_class);
+ class_get_array_element_size = GET_INTERFACE(vm, class_get_array_element_size);
+ class_get_array_of_class = GET_INTERFACE(vm, class_get_array_of_class);
+ class_get_element_type_info = GET_INTERFACE(vm, class_get_element_type_info);
+ class_get_name = GET_INTERFACE(vm, class_get_name);
+ class_get_super_class = GET_INTERFACE(vm, class_get_super_class);
+ class_get_depth = GET_INTERFACE(vm, class_get_depth);
+ class_get_vtable = GET_INTERFACE(vm, class_get_vtable);
+ class_get_allocation_handle = GET_INTERFACE(vm, class_get_allocation_handle);
+ class_get_boxed_data_size = GET_INTERFACE(vm, class_get_boxed_data_size);
+ class_get_num_array_dimensions = GET_INTERFACE(vm, class_get_num_array_dimensions);
+ class_get_class_of_primitive_type = GET_INTERFACE(vm, class_get_class_of_primitive_type);
+ class_get_const_string_intern_addr = GET_INTERFACE(vm, class_get_const_string_intern_addr);
+ class_get_const_type = GET_INTERFACE(vm, class_get_const_type);
+ class_get_const_addr = GET_INTERFACE(vm, class_get_const_addr);
+ class_get_method_by_name = GET_INTERFACE(vm, class_get_method_by_name);
+ class_get_field_by_name = GET_INTERFACE(vm, class_get_field_by_name);
+ class_get_class_loader = GET_INTERFACE(vm, class_get_class_loader);
+
+ class_is_array = GET_INTERFACE(vm, class_is_array);
+ class_is_enum = GET_INTERFACE(vm, class_is_enum);
+ class_is_final = GET_INTERFACE(vm, class_is_final);
+ class_is_throwable = GET_INTERFACE(vm, class_is_throwable);
+ class_is_interface = GET_INTERFACE(vm, class_is_interface);
+ class_is_abstract = GET_INTERFACE(vm, class_is_abstract);
+ class_is_initialized = GET_INTERFACE(vm, class_is_initialized);
+ class_is_finalizable = GET_INTERFACE(vm, class_is_finalizable);
+ class_is_instanceof = GET_INTERFACE(vm, class_is_instanceof);
+ class_is_support_fast_instanceof = GET_INTERFACE(vm, class_is_support_fast_instanceof);
+ class_is_primitive = GET_INTERFACE(vm, class_is_primitive);
+
+ class_lookup_class_by_name_using_bootstrap_class_loader = GET_INTERFACE(vm, class_lookup_class_by_name_using_bootstrap_class_loader);
+ class_lookup_method_recursively = GET_INTERFACE(vm, class_lookup_method_recursively);
+
+ // Const Pool
+ class_cp_get_field_type = GET_INTERFACE(vm, class_cp_get_field_type);
+ class_cp_get_entry_signature = GET_INTERFACE(vm, class_cp_get_entry_signature);
+ class_cp_is_entry_resolved = GET_INTERFACE(vm, class_cp_is_entry_resolved);
+ class_cp_get_class_name = GET_INTERFACE(vm, class_cp_get_class_name);
+ class_cp_get_method_class_name = GET_INTERFACE(vm, class_cp_get_method_class_name);
+ class_cp_get_method_name = GET_INTERFACE(vm, class_cp_get_method_name);
+
+
+ //Field
+
+ field_get_address = GET_INTERFACE(vm, field_get_address);
+ field_get_class = GET_INTERFACE(vm, field_get_class);
+ field_get_descriptor = GET_INTERFACE(vm, field_get_descriptor);
+ field_get_name = GET_INTERFACE(vm, field_get_name);
+ field_get_offset = GET_INTERFACE(vm, field_get_offset);
+ field_get_type_info = GET_INTERFACE(vm, field_get_type_info);
+ field_is_final = GET_INTERFACE(vm, field_is_final);
+ field_is_magic = GET_INTERFACE(vm, field_is_magic);
+ field_is_private = GET_INTERFACE(vm, field_is_private);
+ field_is_static = GET_INTERFACE(vm, field_is_static);
+ field_is_volatile = GET_INTERFACE(vm, field_is_volatile);
+
+ //Method
+
+ method_get_overridden_method = GET_INTERFACE(vm, method_get_overridden_method);
+ method_get_info_block_jit = GET_INTERFACE(vm, method_get_info_block_jit);
+ method_get_info_block_size_jit = GET_INTERFACE(vm, method_get_info_block_size_jit);
+ method_get_name = GET_INTERFACE(vm, method_get_name);
+ method_get_descriptor = GET_INTERFACE(vm, method_get_descriptor);
+ method_get_byte_code_addr = GET_INTERFACE(vm, method_get_byte_code_addr);
+ method_get_byte_code_size = GET_INTERFACE(vm, method_get_byte_code_size);
+ method_get_max_stack = GET_INTERFACE(vm, method_get_max_stack);
+ method_get_num_handlers = GET_INTERFACE(vm, method_get_num_handlers);
+ method_get_offset = GET_INTERFACE(vm, method_get_offset);
+ method_get_indirect_address = GET_INTERFACE(vm, method_get_indirect_address);
+ method_get_native_func_addr = GET_INTERFACE(vm, method_get_native_func_addr);
+ method_vars_get_number = GET_INTERFACE(vm, method_vars_get_number);
+ method_args_get_number = GET_INTERFACE(vm, method_args_get_number);
+ method_args_get_type_info = GET_INTERFACE(vm, method_args_get_type_info);
+ method_ret_type_get_type_info = GET_INTERFACE(vm, method_ret_type_get_type_info);
+ method_get_signature = GET_INTERFACE(vm, method_get_signature);
+ method_get_class = GET_INTERFACE(vm, method_get_class);
+ method_get_handler_info = GET_INTERFACE(vm, method_get_handler_info);
+ method_get_code_block_addr_jit_new = GET_INTERFACE(vm, method_get_code_block_addr_jit_new);
+ method_get_code_block_size_jit_new = GET_INTERFACE(vm, method_get_code_block_size_jit_new);
+ method_get_side_effects = GET_INTERFACE(vm, method_get_side_effects);
+
+ method_has_annotation = GET_INTERFACE(vm, method_has_annotation);
+ method_is_private = GET_INTERFACE(vm, method_is_private);
+ method_is_static = GET_INTERFACE(vm, method_is_static);
+ method_is_native = GET_INTERFACE(vm, method_is_native);
+ method_is_synchronized = GET_INTERFACE(vm, method_is_synchronized);
+ method_is_final = GET_INTERFACE(vm, method_is_final);
+ method_is_abstract = GET_INTERFACE(vm, method_is_abstract);
+ method_is_strict = GET_INTERFACE(vm, method_is_strict);
+ method_is_overridden = GET_INTERFACE(vm, method_is_overridden);
+ method_is_no_inlining = GET_INTERFACE(vm, method_is_no_inlining);
+
+
+ method_set_side_effects = GET_INTERFACE(vm, method_set_side_effects);
+ method_set_num_target_handlers = GET_INTERFACE(vm, method_set_num_target_handlers);
+ method_set_target_handler_info = GET_INTERFACE(vm, method_set_target_handler_info);
+
+ method_lock = GET_INTERFACE(vm, method_lock);
+ method_unlock = GET_INTERFACE(vm, method_unlock);
+
+ method_allocate_code_block = GET_INTERFACE(vm, method_allocate_code_block);
+ method_allocate_data_block = GET_INTERFACE(vm, method_allocate_data_block);
+ method_allocate_info_block = GET_INTERFACE(vm, method_allocate_info_block);
+ method_allocate_jit_data_block = GET_INTERFACE(vm, method_allocate_jit_data_block);
+
+
+ //Object
+ object_get_vtable_offset = GET_INTERFACE(vm, object_get_vtable_offset);
+
+
+ //Resolve
+ resolve_class = GET_INTERFACE(vm, resolve_class);
+ resolve_class_new = GET_INTERFACE(vm, resolve_class_new);
+ resolve_special_method = GET_INTERFACE(vm, resolve_special_method);
+ resolve_interface_method = GET_INTERFACE(vm, resolve_interface_method);
+ resolve_static_method = GET_INTERFACE(vm, resolve_static_method);
+ resolve_virtual_method = GET_INTERFACE(vm, resolve_virtual_method);
+ resolve_nonstatic_field = GET_INTERFACE(vm, resolve_nonstatic_field);
+ resolve_static_field = GET_INTERFACE(vm, resolve_static_field);
+
+ //Type Info
+
+ type_info_create_from_java_descriptor = GET_INTERFACE(vm, type_info_create_from_java_descriptor);
+ type_info_get_type_name = GET_INTERFACE(vm, type_info_get_type_name);
+ type_info_get_class = GET_INTERFACE(vm, type_info_get_class);
+ type_info_get_class_no_exn = GET_INTERFACE(vm, type_info_get_class_no_exn);
+ type_info_get_num_array_dimensions = GET_INTERFACE(vm, type_info_get_num_array_dimensions);
+ type_info_get_type_info = GET_INTERFACE(vm, type_info_get_type_info);
+
+ type_info_is_void = GET_INTERFACE(vm, type_info_is_void);
+ type_info_is_reference = GET_INTERFACE(vm, type_info_is_reference);
+ type_info_is_resolved = GET_INTERFACE(vm, type_info_is_resolved);
+ type_info_is_primitive = GET_INTERFACE(vm, type_info_is_primitive);
+ type_info_is_vector = GET_INTERFACE(vm, type_info_is_vector);
+
+ //Vector
+ vector_get_first_element_offset = GET_INTERFACE(vm, vector_get_first_element_offset);
+ vector_get_length_offset = GET_INTERFACE(vm, vector_get_length_offset);
+
+ //Vm
+ vm_tls_alloc = GET_INTERFACE(vm, vm_tls_alloc);
+ vm_tls_get_offset = GET_INTERFACE(vm, vm_tls_get_offset);
+ vm_tls_get_request_offset = GET_INTERFACE(vm, vm_tls_get_request_offset);
+ vm_tls_is_fast = GET_INTERFACE(vm, vm_tls_is_fast);
+ vm_get_tls_offset_in_segment = GET_INTERFACE(vm, vm_get_tls_offset_in_segment);
+
+ vm_properties_destroy_keys = GET_INTERFACE(vm, vm_properties_destroy_keys);
+ vm_properties_destroy_value = GET_INTERFACE(vm, vm_properties_destroy_value);
+ vm_properties_get_keys = GET_INTERFACE(vm, vm_properties_get_keys);
+ vm_properties_get_keys_starting_with = GET_INTERFACE(vm, vm_properties_get_keys_starting_with);
+ vm_properties_get_value = GET_INTERFACE(vm, vm_properties_get_value);
+
+
+ vm_get_system_object_class = GET_INTERFACE(vm, vm_get_system_object_class);
+ vm_get_system_class_class = GET_INTERFACE(vm, vm_get_system_class_class);
+ vm_get_system_string_class = GET_INTERFACE(vm, vm_get_system_string_class);
+ vm_get_vtable_base = GET_INTERFACE(vm, vm_get_vtable_base);
+ vm_get_heap_base_address = GET_INTERFACE(vm, vm_get_heap_base_address);
+ vm_get_heap_ceiling_address = GET_INTERFACE(vm, vm_get_heap_ceiling_address);
+ vm_is_heap_compressed = GET_INTERFACE(vm, vm_is_heap_compressed);
+ vm_is_vtable_compressed = GET_INTERFACE(vm, vm_is_vtable_compressed);
+ vm_patch_code_block = GET_INTERFACE(vm, vm_patch_code_block);
+ vm_compile_method = GET_INTERFACE(vm, vm_compile_method);
+ vm_register_jit_extended_class_callback = GET_INTERFACE(vm, vm_register_jit_extended_class_callback);
+ vm_register_jit_overridden_method_callback = GET_INTERFACE(vm, vm_register_jit_overridden_method_callback);
+ vm_register_jit_recompiled_method_callback = GET_INTERFACE(vm, vm_register_jit_recompiled_method_callback);
+ vm_compiled_method_load = GET_INTERFACE(vm, vm_compiled_method_load);
+ vm_helper_get_addr = GET_INTERFACE(vm, vm_helper_get_addr);
+ vm_helper_get_addr_optimized = GET_INTERFACE(vm, vm_helper_get_addr_optimized);
+ vm_helper_get_by_name = GET_INTERFACE(vm, vm_helper_get_by_name);
+ vm_helper_get_calling_convention = GET_INTERFACE(vm, vm_helper_get_calling_convention);
+ vm_helper_get_interruptibility_kind = GET_INTERFACE(vm, vm_helper_get_interruptibility_kind);
+ vm_helper_get_magic_helper = GET_INTERFACE(vm, vm_helper_get_magic_helper);
+ vm_helper_get_name = GET_INTERFACE(vm, vm_helper_get_name);
+
+ //VTable
+ vtable_get_class = GET_INTERFACE(vm, vtable_get_class);
+
+ vm_enumerate_root_reference = GET_INTERFACE(vm, vm_enumerate_root_reference);
+ vm_enumerate_compressed_root_reference = GET_INTERFACE(vm, vm_enumerate_compressed_root_reference);
+ vm_enumerate_root_interior_pointer = GET_INTERFACE(vm, vm_enumerate_root_interior_pointer);
+
+ return true;
+ }
+
+ bool VMInterface::isValidFeature(const char* id) {
+ return NULL != vm(id);
+ }
@@ -71,16 +453,16 @@
// TODO: free TLS key on JIT deinitilization
uint32
VMInterface::flagTLSSuspendRequestOffset(){
- return (uint32)hythread_tls_get_request_offset();
+ return (uint32)vm_tls_get_request_offset();
}
uint32
VMInterface::flagTLSThreadStateOffset() {
- static hythread_tls_key_t key = 0;
+ static UDATA key = 0;
static size_t offset = 0;
if (key == 0) {
- hythread_tls_alloc(&key);
- offset = hythread_tls_get_offset(key);
+ vm_tls_alloc(&key);
+ offset = vm_tls_get_offset(key);
}
assert(fit32(offset));
return (uint32)offset;
@@ -88,14 +470,23 @@
int32
VMInterface::getTLSBaseOffset() {
- return (int32) hythread_get_hythread_offset_in_tls();
+ return (int32) vm_get_tls_offset_in_segment();
}
bool
VMInterface::useFastTLSAccess() {
- return 0 != hythread_uses_fast_tls();
+ return 0 != vm_tls_is_fast();
}
+bool
+VMInterface::isVTableCompressed() {
+ return vm_is_vtable_compressed();
+}
+
+bool
+VMInterface::areReferencesCompressed() {
+ return vm_is_heap_compressed();
+}
//////////////////////////////////////////////////////////////////////////////
///////////////////////// VMTypeManager /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -134,31 +525,26 @@
void*
VMInterface::getSystemObjectVMTypeHandle() {
- return get_system_object_class();
+ return vm_get_system_object_class();
}
void*
VMInterface::getSystemClassVMTypeHandle() {
- return get_system_class_class();
+ return vm_get_system_class_class();
}
void*
VMInterface::getSystemStringVMTypeHandle() {
- return get_system_string_class();
+ return vm_get_system_string_class();
}
void*
VMInterface::getArrayVMTypeHandle(void* elemVMTypeHandle,bool isUnboxed) {
- if (isUnboxed)
- return class_get_array_of_unboxed((Class_Handle) elemVMTypeHandle);
+ //if (isUnboxed)
+ // return class_get_array_of_unboxed((Class_Handle) elemVMTypeHandle);
return class_get_array_of_class((Class_Handle) elemVMTypeHandle);
}
-const char*
-VMInterface::getTypeNameQualifier(void* vmTypeHandle) {
- return class_get_package_name((Class_Handle) vmTypeHandle);
-}
-
void*
VMInterface::getArrayElemVMTypeHandle(void* vmTypeHandle) {
return class_get_array_element_class((Class_Handle) vmTypeHandle);
@@ -185,17 +571,12 @@
bool
VMInterface::isLikelyExceptionType(void* vmTypeHandle) {
- return class_hint_is_exceptiontype((Class_Handle) vmTypeHandle)?true:false;
-}
-
-bool
-VMInterface::isBeforeFieldInit(void* vmTypeHandle) {
- return class_is_before_field_init((Class_Handle) vmTypeHandle)?true:false;
+ return class_is_throwable((Class_Handle) vmTypeHandle)?true:false;
}
bool
VMInterface::getClassFastInstanceOfFlag(void* vmTypeHandle) {
- return class_get_fast_instanceof_flag((Class_Handle) vmTypeHandle)?true:false;
+ return class_is_support_fast_instanceof((Class_Handle) vmTypeHandle)?true:false;
}
int
@@ -205,14 +586,14 @@
uint32
VMInterface::getArrayLengthOffset() {
- return vector_length_offset();
+ return vector_get_length_offset();
}
uint32
VMInterface::getArrayElemOffset(void* vmElemTypeHandle,bool isUnboxed) {
- if (isUnboxed)
- return vector_first_element_offset_unboxed((Class_Handle) vmElemTypeHandle);
- return vector_first_element_offset_class_handle((Class_Handle) vmElemTypeHandle);
+ //if (isUnboxed)
+ // return vector_first_element_offset_unboxed((Class_Handle) vmElemTypeHandle);
+ return vector_get_first_element_offset((Class_Handle) vmElemTypeHandle);
}
bool
@@ -241,16 +622,16 @@
return class_is_array((Class_Handle)vmTypeHandle)?true:false;
}
bool VMInterface::isFinalType(void* vmTypeHandle) {
- return class_property_is_final((Class_Handle)vmTypeHandle)?true:false;
+ return class_is_final((Class_Handle)vmTypeHandle)?true:false;
}
bool VMInterface::isInterfaceType(void* vmTypeHandle) {
- return class_property_is_interface2((Class_Handle)vmTypeHandle)?true:false;
+ return class_is_interface((Class_Handle)vmTypeHandle)?true:false;
}
bool VMInterface::isAbstractType(void* vmTypeHandle) {
- return class_property_is_abstract((Class_Handle)vmTypeHandle)?true:false;
+ return class_is_abstract((Class_Handle)vmTypeHandle)?true:false;
}
bool VMInterface::needsInitialization(void* vmTypeHandle) {
- return class_needs_initialization((Class_Handle)vmTypeHandle)?true:false;
+ return class_is_initialized((Class_Handle)vmTypeHandle)?false:true;
}
bool VMInterface::isFinalizable(void* vmTypeHandle) {
return class_is_finalizable((Class_Handle)vmTypeHandle)?true:false;
@@ -275,6 +656,11 @@
return object_get_vtable_offset();
}
+uint64
+VMInterface::getVTableBase() {
+ return (uint64)vm_get_vtable_base();
+}
+
void* VMInterface::getTypeHandleFromAllocationHandle(void* vmAllocationHandle)
{
return allocation_handle_get_class((Allocation_Handle)vmAllocationHandle);
@@ -286,6 +672,43 @@
///////////////////////// MethodDesc //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
+MethodDesc::MethodDesc(Method_Handle m, JIT_Handle jit, CompilationInterface* ci, uint32 id)
+: TypeMemberDesc(id, ci), drlMethod(m),
+methodSig(method_get_signature(m)),
+handleMap(NULL),
+jitHandle(jit){}
+
+const char* MethodDesc::getName() const {return method_get_name(drlMethod);}
+const char* MethodDesc::getSignatureString() const {return method_get_descriptor(drlMethod); }
+
+bool MethodDesc::isPrivate() const {return method_is_private(drlMethod)?true:false;}
+bool MethodDesc::isStatic() const {return method_is_static(drlMethod)?true:false;}
+bool MethodDesc::isInstance() const {return method_is_static(drlMethod)?false:true;}
+bool MethodDesc::isNative() const {return method_is_native(drlMethod)?true:false;}
+bool MethodDesc::isSynchronized() const {return method_is_synchronized(drlMethod)?true:false;}
+bool MethodDesc::isFinal() const {return method_is_final(drlMethod)?true:false;}
+bool MethodDesc::isVirtual() const {return isInstance() && !isPrivate();}
+bool MethodDesc::isAbstract() const {return method_is_abstract(drlMethod)?true:false;}
+// FP strict
+bool MethodDesc::isStrict() const {return method_is_strict(drlMethod)?true:false;}
+bool MethodDesc::isClassInitializer() const {return strcmp(getName(), "<clinit>") == 0; }
+bool MethodDesc::isInstanceInitializer() const {return strcmp(getName(), "<init>") == 0; }
+
+//
+// Method info
+//
+
+const Byte* MethodDesc::getByteCodes() const {return method_get_byte_code_addr(drlMethod);}
+uint32 MethodDesc::getByteCodeSize() const {return (uint32) method_get_byte_code_size(drlMethod);}
+uint16 MethodDesc::getMaxStack() const {return (uint16) method_get_max_stack(drlMethod);}
+uint32 MethodDesc::getNumHandlers() const {return method_get_num_handlers(drlMethod);}
+bool MethodDesc::isOverridden() const {return method_is_overridden(drlMethod)?true:false;}
+uint32 MethodDesc::getOffset() const {return method_get_offset(drlMethod);}
+void* MethodDesc::getIndirectAddress() const {return method_get_indirect_address(drlMethod);}
+void* MethodDesc::getNativeAddress() const {return method_get_native_func_addr(drlMethod);}
+
+uint32 MethodDesc::getNumVars() const {return method_vars_get_number(drlMethod);}
+
uint32
MethodDesc::getNumParams() const {
return method_args_get_number(methodSig);
@@ -334,20 +757,15 @@
}
bool
-MethodDesc::isRequireSecObject() {
- return method_is_require_security_object(drlMethod)?true:false;
-}
-
-bool
TypeMemberDesc::isParentClassIsLikelyExceptionType() const {
Class_Handle ch = getParentHandle();
- return class_hint_is_exceptiontype(ch);
+ return class_is_throwable(ch);
}
const char*
CompilationInterface::getSignatureString(MethodDesc* enclosingMethodDesc, uint32 methodToken) {
Class_Handle enclosingDrlVMClass = enclosingMethodDesc->getParentHandle();
- return class_get_cp_entry_signature(enclosingDrlVMClass, (unsigned short)methodToken);
+ return class_cp_get_entry_signature(enclosingDrlVMClass, (unsigned short)methodToken);
}
Method_Side_Effects
@@ -395,6 +813,21 @@
///////////////////////// FieldDesc ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
+const char* FieldDesc::getName() const {return field_get_name(drlField);}
+const char* FieldDesc::getSignatureString() const {return field_get_descriptor(drlField); }
+bool FieldDesc::isPrivate() const {return field_is_private(drlField)?true:false;}
+bool FieldDesc::isStatic() const {return field_is_static(drlField)?true:false;}
+//
+// this field is constant after it is initialized
+// can only be mutated by constructor (instance fields) or
+// type initializer (static fields)
+//
+bool FieldDesc::isInitOnly() const {return field_is_final(drlField)?true:false;}
+// accesses to field cannot be reordered or CSEed
+bool FieldDesc::isVolatile() const {return field_is_volatile(drlField)?true:false;}
+bool FieldDesc::isMagic() const {return field_is_magic(drlField)?true:false;}
+void* FieldDesc::getAddress() const {return field_get_address(drlField);} // for static fields
+
Class_Handle FieldDesc::getParentHandle() const {
return field_get_class(drlField);
@@ -413,7 +846,7 @@
Type*
FieldDesc::getFieldType() {
- Type_Info_Handle typeHandle = field_get_type_info_of_field_value(drlField);
+ Type_Info_Handle typeHandle = field_get_type_info(drlField);
return compilationInterface->getTypeFromDrlVMTypeHandle(typeHandle);
}
@@ -422,31 +855,6 @@
return field_get_offset(drlField);
}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////// ClassHierachyMethodIterator //////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-ClassHierarchyMethodIterator::ClassHierarchyMethodIterator(
- CompilationInterface& compilationInterface, ObjectType* objType, MethodDesc* methodDesc)
- : compilationInterface(compilationInterface)
-{
- valid = method_iterator_initialize(&iterator, methodDesc->getMethodHandle(),
- (Class_Handle) objType->getVMTypeHandle());
-}
-
-bool ClassHierarchyMethodIterator::hasNext() const {
- Method_Handle handle = method_iterator_get_current(&iterator);
- return handle != NULL;
-}
-
-MethodDesc*
-ClassHierarchyMethodIterator::getNext() {
- MethodDesc* desc = compilationInterface.getMethodDesc(method_iterator_get_current(&iterator));
- method_iterator_advance(&iterator);
- return desc;
-}
-
//////////////////////////////////////////////////////////////////////////////
//////////////////////////// CompilationInterface /////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -524,7 +932,7 @@
void*
CompilationInterface::getRuntimeHelperAddress(VM_RT_SUPPORT id) {
- return vm_get_rt_support_addr(id);
+ return vm_helper_get_addr(id);
}
void*
@@ -532,7 +940,7 @@
Class_Handle handle = NULL;
if (type != NULL && type->isNamedType())
handle = (Class_Handle) ((NamedType *)type)->getVMTypeHandle();
- void* addr = vm_get_rt_support_addr_optimized(id, handle);
+ void* addr = vm_helper_get_addr_optimized(id, handle);
assert(addr != NULL);
return addr;
}
@@ -602,18 +1010,13 @@
if (type->isUnresolvedType()) {
return NULL;
}
- Method_Handle m = method_find_overridden_method((Class_Handle) type->getVMTypeHandle(),
+ Method_Handle m = method_get_overridden_method((Class_Handle) type->getVMTypeHandle(),
methodDesc->getMethodHandle());
if (!m)
return NULL;
return getMethodDesc(m);
}
-ClassHierarchyMethodIterator*
-CompilationInterface::getClassHierarchyMethodIterator(ObjectType* baseType, MethodDesc* methodDesc) {
- return new (getMemManager()) ClassHierarchyMethodIterator(*this, baseType, methodDesc);
-}
-
void CompilationInterface::setNotifyWhenClassIsExtended(ObjectType * type,
void * callbackData) {
void * typeHandle = type->getVMTypeHandle();
@@ -639,15 +1042,15 @@
Method_Handle method = methodDesc->getMethodHandle();
Method_Handle outer = outerDesc->getMethodHandle();
- compiled_method_load(method, codeSize, codeAddr, mapLength, addrLocationMap, compileInfo, outer);
+ vm_compiled_method_load(method, codeSize, codeAddr, mapLength, addrLocationMap, compileInfo, outer);
}
void * VMInterface::getHeapBase() {
- return vm_heap_base_address();
+ return vm_get_heap_base_address();
}
void * VMInterface::getHeapCeiling() {
- return vm_heap_ceiling_address();
+ return vm_get_heap_ceiling_address();
}
ObjectType * CompilationInterface::findClassUsingBootstrapClassloader( const char * klassName ) {
@@ -675,16 +1078,6 @@
}
-
-
-NamedType* MethodDesc::getThrowType(uint32 i) {
- assert(i<=method_number_throws(drlMethod));
- Class_Handle ch = method_get_throws(drlMethod, i);
- assert(ch);
- NamedType* res = compilationInterface->getTypeManager().getObjectType(ch);
- return res;
-}
-
bool MethodDesc::hasAnnotation(NamedType* type) const {
return method_has_annotation(drlMethod, (Class_Handle)type->getVMTypeHandle());
}
@@ -794,8 +1187,8 @@
NamedType* CompilationInterface::getNamedType(Class_Handle enclClass, uint32 cpIndex, ResolveNewCheck checkNew) {
Class_Handle ch = NULL;
- if (typeManager.isLazyResolutionMode() && !class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
- const char* className = const_pool_get_class_name(enclClass, cpIndex);
+ if (typeManager.isLazyResolutionMode() && !class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ const char* className = class_cp_get_class_name(enclClass, cpIndex);
bool forceResolve = VMMagicUtils::isVMMagicClass(className);
if (!forceResolve) {
return getUnresolvedType(typeManager, enclClass, cpIndex);
@@ -825,7 +1218,7 @@
CompilationInterface::getSpecialMethod(Class_Handle enclClass, uint32 cpIndex) {
Method_Handle res = NULL;
bool lazy = typeManager.isLazyResolutionMode();
- if (!lazy || class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ if (!lazy || class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
res = resolve_special_method(compileHandle,enclClass, cpIndex);
}
if (!res) return NULL;
@@ -836,7 +1229,7 @@
CompilationInterface::getInterfaceMethod(Class_Handle enclClass, uint32 cpIndex) {
Method_Handle res = NULL;
bool lazy = typeManager.isLazyResolutionMode();
- if (!lazy || class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ if (!lazy || class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
res = resolve_interface_method(compileHandle,enclClass, cpIndex);
}
if (!res) return NULL;
@@ -847,7 +1240,7 @@
CompilationInterface::getStaticMethod(Class_Handle enclClass, uint32 cpIndex) {
Method_Handle res = NULL;
bool lazy = typeManager.isLazyResolutionMode();
- if (!lazy || class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ if (!lazy || class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
res = resolve_static_method(compileHandle,enclClass, cpIndex);
}
if (!res) return NULL;
@@ -858,7 +1251,7 @@
CompilationInterface::getVirtualMethod(Class_Handle enclClass, uint32 cpIndex) {
Method_Handle res = NULL;
bool lazy = typeManager.isLazyResolutionMode();
- if (!lazy || class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ if (!lazy || class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
res = resolve_virtual_method(compileHandle,enclClass, cpIndex);
}
if (!res) return NULL;
@@ -870,7 +1263,7 @@
CompilationInterface::getNonStaticField(Class_Handle enclClass, uint32 cpIndex, bool putfield) {
Field_Handle res = NULL;
bool lazy = typeManager.isLazyResolutionMode();
- if (!lazy || class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ if (!lazy || class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
res = resolve_nonstatic_field(compileHandle, enclClass, cpIndex, putfield);
}
if (!res) {
@@ -884,7 +1277,7 @@
CompilationInterface::getStaticField(Class_Handle enclClass, uint32 cpIndex, bool putfield) {
Field_Handle res = NULL;
bool lazy = typeManager.isLazyResolutionMode();
- if (!lazy || class_is_cp_entry_resolved(compileHandle, enclClass, cpIndex)) {
+ if (!lazy || class_cp_is_entry_resolved(compileHandle, enclClass, cpIndex)) {
res = resolve_static_field(compileHandle, enclClass, cpIndex, putfield);
}
if (!res) {
@@ -908,7 +1301,7 @@
Type*
CompilationInterface::getFieldType(Class_Handle enclClass, uint32 cpIndex) {
- Java_Type drlType = (Java_Type)class_get_cp_field_type(enclClass, (unsigned short)cpIndex);
+ Java_Type drlType = (Java_Type)class_cp_get_field_type(enclClass, (unsigned short)cpIndex);
bool lazy = typeManager.isLazyResolutionMode();
switch (drlType) {
case JAVA_TYPE_BOOLEAN: return typeManager.getBooleanType();
@@ -923,7 +1316,7 @@
case JAVA_TYPE_CLASS:
if (lazy) {
- const char* fieldTypeName = const_pool_get_field_descriptor(enclClass, cpIndex);
+ const char* fieldTypeName = class_cp_get_entry_signature(enclClass, cpIndex);
assert(fieldTypeName);
return getTypeFromDescriptor(enclClass, fieldTypeName);
}
@@ -939,17 +1332,17 @@
const char*
CompilationInterface::getMethodName(Class_Handle enclClass, uint32 cpIndex) {
- return const_pool_get_method_name(enclClass, cpIndex);
+ return class_cp_get_method_name(enclClass, cpIndex);
}
const char*
CompilationInterface::getMethodClassName(Class_Handle enclClass, uint32 cpIndex) {
- return const_pool_get_method_class_name(enclClass, cpIndex);
+ return class_cp_get_method_class_name(enclClass, cpIndex);
}
const char*
CompilationInterface::getFieldSignature(Class_Handle enclClass, uint32 cpIndex) {
- return const_pool_get_field_descriptor(enclClass, cpIndex);
+ return class_cp_get_entry_signature(enclClass, cpIndex);
}
::std::ostream& operator<<(::std::ostream& os, Method_Handle method) {
@@ -961,11 +1354,11 @@
VMPropertyIterator::VMPropertyIterator(
MemoryManager& mm, const char* prefix): mm(mm), key(NULL), value(NULL), iterator(0)
{
- keys = get_properties_keys_staring_with(prefix, VM_PROPERTIES);
+ keys = vm_properties_get_keys_starting_with(prefix, VM_PROPERTIES);
}
VMPropertyIterator::~VMPropertyIterator() {
- destroy_properties_keys(keys);
+ vm_properties_destroy_keys(keys);
}
bool
@@ -974,10 +1367,34 @@
return false;
}
key = mm.copy(keys[iterator]);
- char* nval = get_property(keys[iterator++], VM_PROPERTIES);
+ char* nval = vm_properties_get_value(keys[iterator++], VM_PROPERTIES);
value = mm.copy(nval);
- destroy_property_value(nval);
+ vm_properties_destroy_value(nval);
return true;
+}
+
+void GCInterface::enumerateRootReference(void** reference) {
+ vm_enumerate_root_reference(reference, FALSE);
+}
+
+void GCInterface::enumerateCompressedRootReference(uint32* reference) {
+ vm_enumerate_compressed_root_reference(reference, FALSE);
+}
+
+void GCInterface::enumerateRootManagedReference(void** slotReference, int slotOffset) {
+ vm_enumerate_root_interior_pointer(slotReference, slotOffset, FALSE);
+}
+
+void ThreadDumpEnumerator::enumerateRootReference(void** reference) {
+ //vm_check_if_monitor(reference, 0, 0, 0, FALSE, 1);
+}
+
+void ThreadDumpEnumerator::enumerateCompressedRootReference(uint32* reference) {
+ //vm_check_if_monitor(0, 0, reference, 0, FALSE, 2);
+}
+
+void ThreadDumpEnumerator::enumerateRootManagedReference(void** slotReference, int slotOffset) {
+ //vm_check_if_monitor(slotReference, 0, 0, slotOffset, FALSE, 3);
}
} //namespace Jitrino
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h?rev=634547&r1=634546&r2=634547&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h Thu Mar 6 21:59:46 2008
@@ -19,10 +19,9 @@
#define _VMINTERFACE_H_
#include <ostream>
-#include "open/em.h"
#include "open/types.h"
-#include "jit_runtime_support.h"
-#include "jit_intf.h"
+#include "open/ee_em_intf.h"
+#include "open/vm_interface.h"
namespace Jitrino {
@@ -48,7 +47,6 @@
static void* getSystemStringVMTypeHandle();
static void* getArrayVMTypeHandle(void* elemVMTypeHandle,bool isUnboxed);
static const char* getTypeName(void* vmTypeHandle);
- static const char* getTypeNameQualifier(void* vmTypeHandle);
static void* getSuperTypeVMTypeHandle(void* vmTypeHandle);
static void* getArrayElemVMTypeHandle(void* vmTypeHandle);
static bool isArrayType(void* vmTypeHandle);
@@ -61,7 +59,6 @@
static bool isAbstractType(void* vmTypeHandle);
static bool needsInitialization(void* vmTypeHandle);
static bool isFinalizable(void* vmTypeHandle);
- static bool isBeforeFieldInit(void* vmTypeHandle);
static bool getClassFastInstanceOfFlag(void* vmTypeHandle);
static int getClassDepth(void* vmTypeHandle);
static bool isInitialized(void* vmTypeHandle);
@@ -84,7 +81,7 @@
// returns true if vtable pointers are compressed
- static bool areVTablePtrsCompressed() {return vm_vtable_pointers_are_compressed();}
+ static bool isVTableCompressed();
// returns size of vtable pointer (currently 4 if compressed and 8 otherwise)
//static uint32 getVTablePtrSize() {return vm_get_vtable_ptr_size();}
@@ -92,10 +89,10 @@
// returns the offset of an object's virtual table
static uint32 getVTableOffset();
// returns the base for all vtables (addend to compressed vtable pointer)
- static uint64 getVTableBase() {return vm_get_vtable_base();}
+ static uint64 getVTableBase();
// returns true if instance fields that are references are compressed
- static bool areReferencesCompressed() {return vm_references_are_compressed();}
+ static bool areReferencesCompressed();
//
// returns the base for the heap (addend to compressed heap references)
@@ -105,6 +102,12 @@
static void rewriteCodeBlock(Byte* codeBlock, Byte* newCode, size_t size);
+
+ static bool setVmAdapter(vm_adaptor_t vm);
+ static bool isValidFeature(const char* id);
+
+protected:
+ static vm_adaptor_t vm;
};
@@ -145,24 +148,24 @@
FieldDesc(Field_Handle field, CompilationInterface* ci, uint32 id)
: TypeMemberDesc(id, ci), drlField(field) {}
- const char* getName() const {return field_get_name(drlField);}
- const char* getSignatureString() const {return field_get_descriptor(drlField); }
+ const char* getName() const;
+ const char* getSignatureString() const;
void printFullName(::std::ostream &os);
Class_Handle getParentHandle() const;
- bool isPrivate() const {return field_is_private(drlField)?true:false;}
- bool isStatic() const {return field_is_static(drlField)?true:false;}
+ bool isPrivate() const;
+ bool isStatic() const;
//
// this field is constant after it is initialized
// can only be mutated by constructor (instance fields) or
// type initializer (static fields)
//
- bool isInitOnly() const {return field_is_final(drlField)?true:false;}
+ bool isInitOnly() const;
// accesses to field cannot be reordered or CSEed
- bool isVolatile() const {return field_is_volatile(drlField)?true:false;}
- bool isMagic() const {return field_is_magic(drlField)?true:false;}
+ bool isVolatile() const;
+ bool isMagic() const;
Type* getFieldType();
uint32 getOffset() const; // for non-static fields
- void* getAddress() const {return field_get_address(drlField);} // for static fields
+ void* getAddress() const; // for static fields
Field_Handle getFieldHandle() const {return drlField; }
private:
@@ -172,44 +175,37 @@
///Method representation for resolved methods
class MethodDesc : public TypeMemberDesc {
public:
- MethodDesc(Method_Handle m, JIT_Handle jit, CompilationInterface* ci = NULL, uint32 id = 0)
- : TypeMemberDesc(id, ci), drlMethod(m),
- methodSig(method_get_signature(m)),
- handleMap(NULL),
- jitHandle(jit){}
+ MethodDesc(Method_Handle m, JIT_Handle jit, CompilationInterface* ci = NULL, uint32 id = 0);
- const char* getName() const {return method_get_name(drlMethod);}
- const char* getSignatureString() const {return method_get_descriptor(drlMethod); }
+ const char* getName() const;
+ const char* getSignatureString() const;
void printFullName(::std::ostream& os);
Class_Handle getParentHandle() const;
- bool isPrivate() const {return method_is_private(drlMethod)?true:false;}
- bool isStatic() const {return method_is_static(drlMethod)?true:false;}
- bool isInstance() const {return method_is_static(drlMethod)?false:true;}
- bool isNative() const {return method_is_native(drlMethod)?true:false;}
- bool isSynchronized() const {return method_is_synchronized(drlMethod)?true:false;}
+ bool isPrivate() const;
+ bool isStatic() const;
+ bool isInstance() const;
+ bool isNative() const;
+ bool isSynchronized() const;
bool isNoInlining() const;
- bool isFinal() const {return method_is_final(drlMethod)?true:false;}
- bool isVirtual() const {return isInstance() && !isPrivate();}
- bool isAbstract() const {return method_is_abstract(drlMethod)?true:false;}
+ bool isFinal() const;
+ bool isVirtual() const;
+ bool isAbstract() const;
// FP strict
- bool isStrict() const {return method_is_strict(drlMethod)?true:false;}
- bool isRequireSecObject(); //FIXME drop???
- bool isClassInitializer() const {return strcmp(getName(), "<clinit>") == 0; }
- bool isInstanceInitializer() const {return strcmp(getName(), "<init>") == 0; }
+ bool isStrict() const;
+ bool isClassInitializer() const;
+ bool isInstanceInitializer() const;
//
// Method info
//
- const Byte* getByteCodes() const {return method_get_byte_code_addr(drlMethod);}
- uint32 getByteCodeSize() const {return (uint32) method_get_byte_code_size(drlMethod);}
- uint16 getMaxStack() const {return (uint16) method_get_max_stack(drlMethod);}
- uint32 getNumHandlers() const {return method_get_num_handlers(drlMethod);}
+ const Byte* getByteCodes() const;
+ uint32 getByteCodeSize() const;
+ uint16 getMaxStack() const;
+ uint32 getNumHandlers() const;
void getHandlerInfo(unsigned index, unsigned* beginOffset,
unsigned* endOffset, unsigned* handlerOffset, unsigned* handlerClassIndex) const;
- uint32 getNumThrows() const {return method_number_throws(drlMethod);}
- NamedType* getThrowType(uint32 i);
bool hasAnnotation(NamedType* type) const;
//
@@ -239,11 +235,12 @@
//
// DRL kernel
//
- bool isOverridden() const {return method_is_overridden(drlMethod)?true:false;}
- uint32 getOffset() const {return method_get_offset(drlMethod);}
- void* getIndirectAddress() const {return method_get_indirect_address(drlMethod);}
+ bool isOverridden() const;
+ uint32 getOffset() const;
+ void* getIndirectAddress() const;
+ void* getNativeAddress() const;
- uint32 getNumVars() const {return method_vars_get_number(drlMethod);}
+ uint32 getNumVars() const;
Method_Handle getMethodHandle() const {return drlMethod;}
@@ -264,19 +261,6 @@
JIT_Handle jitHandle;
};
-class ClassHierarchyMethodIterator {
-public:
- ClassHierarchyMethodIterator(CompilationInterface& compilationInterface, ObjectType* objType, MethodDesc* methodDesc);
- bool isValid() const { return valid; }
- bool hasNext() const;
- MethodDesc* getNext();
-
-private:
- CompilationInterface& compilationInterface;
- bool valid;
- ChaMethodIterator iterator;
-};
-
enum ResolveNewCheck{ResolveNewCheck_NoCheck, ResolveNewCheck_DoCheck};
class CompilationInterface {
@@ -357,7 +341,6 @@
// superclass of ch that overrides mh.
MethodDesc* getOverriddenMethod(NamedType *type, MethodDesc * methodDesc);
- ClassHierarchyMethodIterator* getClassHierarchyMethodIterator(ObjectType* baseType, MethodDesc* methodDesc);
void* getStringInternAddr(MethodDesc* enclosingMethodDesc, uint32 stringToken);
Type* getConstantType(MethodDesc* enclosingMethodDesc, uint32 constantToken);
@@ -479,17 +462,11 @@
GCInterface(GC_Enumeration_Handle gcHandle) : gcHandle(gcHandle) {}
virtual ~GCInterface() {}
- virtual void enumerateRootReference(void** reference) {
- vm_enumerate_root_reference(reference, FALSE);
- }
+ virtual void enumerateRootReference(void** reference);
- virtual void enumerateCompressedRootReference(uint32* reference) {
- vm_enumerate_compressed_root_reference(reference, FALSE);
- }
+ virtual void enumerateCompressedRootReference(uint32* reference);
- virtual void enumerateRootManagedReference(void** slotReference, int slotOffset) {
- vm_enumerate_root_interior_pointer(slotReference, slotOffset, FALSE);
- }
+ virtual void enumerateRootManagedReference(void** slotReference, int slotOffset);
private:
GC_Enumeration_Handle gcHandle;
@@ -500,17 +477,11 @@
public:
ThreadDumpEnumerator() : GCInterface(NULL) {}
- virtual void enumerateRootReference(void** reference) {
- vm_check_if_monitor(reference, 0, 0, 0, FALSE, 1);
- }
+ virtual void enumerateRootReference(void** reference);
- virtual void enumerateCompressedRootReference(uint32* reference) {
- vm_check_if_monitor(0, 0, reference, 0, FALSE, 2);
- }
+ virtual void enumerateCompressedRootReference(uint32* reference);
- virtual void enumerateRootManagedReference(void** slotReference, int slotOffset) {
- vm_check_if_monitor(slotReference, 0, 0, slotOffset, FALSE, 3);
- }
+ virtual void enumerateRootManagedReference(void** slotReference, int slotOffset);
};
//
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp?rev=634547&r1=634546&r2=634547&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp Thu Mar 6 21:59:46 2008
@@ -142,6 +142,7 @@
get_system_object_class;
get_system_string_class;
get_thread_ptr;
+ get_vm_interface;
initialize_arg_list_iterator;
init_log_system;
is_enabled;
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?rev=634547&r1=634546&r2=634547&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Thu Mar 6 21:59:46 2008
@@ -1464,16 +1464,11 @@
-int vector_first_element_offset_class_handle(Class_Handle UNREF element_type)
+int vector_first_element_offset_class_handle(Class_Handle element_type)
{
- return VM_VECTOR_FIRST_ELEM_OFFSET_REF;
-} //vector_first_element_offset_class_handle
-
-int vector_first_element_offset_vtable_handle(VTable_Handle UNREF element_type)
-{
- return VM_VECTOR_FIRST_ELEM_OFFSET_REF;
-} //vector_first_element_offset_class_handle
-
+ return vector_first_element_offset_unboxed(element_type);
+ //return VM_VECTOR_FIRST_ELEM_OFFSET_REF;
+}
Boolean method_is_java(Method_Handle mh)
{
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=634547&r1=634546&r2=634547&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Thu Mar 6 21:59:46 2008
@@ -120,6 +120,104 @@
}
} //create_instance_for_class
+// VM adapter part
+
+static apr_dso_handle_t* get_harmonyvm_handle(){
+ apr_dso_handle_t* descriptor;
+ apr_pool_t* pool;
+ int ret = apr_pool_create(&pool, NULL);
+ assert(APR_SUCCESS == ret);
+ ret = apr_dso_load(&descriptor, PORT_DSO_NAME("harmonyvm"), pool);
+ assert(APR_SUCCESS == ret);
+ return descriptor;
+}
+
+extern "C" VMEXPORT
+void* get_vm_interface(const char* func_name){
+ static apr_dso_handle_t* descriptor = get_harmonyvm_handle();
+ void* p_func = NULL;
+ int ret = apr_dso_sym((apr_dso_handle_sym_t*) &p_func, descriptor, func_name);
+
+ //assert(APR_SUCCESS == ret);
+
+ //FIXME: temporary solution, should be fixed in next patch
+ if (p_func) {
+ return p_func;
+
+ } else if (strcmp(func_name,"class_is_support_fast_instanceof") == 0) {
+ return (void*)class_get_fast_instanceof_flag;
+ } else if (strcmp(func_name,"class_is_final") == 0) {
+ return (void*)class_property_is_final;
+ } else if (strcmp(func_name,"class_is_throwable") == 0) {
+ return (void*)class_hint_is_exceptiontype;
+ } else if (strcmp(func_name,"class_is_interface") == 0) {
+ return (void*)class_property_is_interface2;
+ } else if (strcmp(func_name,"class_is_abstract") == 0) {
+ return (void*)class_property_is_abstract;
+ } else if (strcmp(func_name,"class_cp_get_field_type") == 0) {
+ return (void*)class_get_cp_field_type;
+ } else if (strcmp(func_name,"class_cp_get_entry_signature") == 0) {
+ return (void*)class_get_cp_entry_signature;
+ } else if (strcmp(func_name,"class_cp_get_method_class_name") == 0) {
+ return (void*)const_pool_get_method_class_name;
+ } else if (strcmp(func_name,"class_cp_get_method_name") == 0) {
+ return (void*)const_pool_get_method_name;
+ } else if (strcmp(func_name,"class_cp_is_entry_resolved") == 0) {
+ return (void*)class_is_cp_entry_resolved;
+ } else if (strcmp(func_name,"class_cp_get_class_name") == 0) {
+ return (void*)const_pool_get_class_name;
+ } else if (strcmp(func_name,"field_get_type_info") == 0) {
+ return (void*)field_get_type_info_of_field_value;
+ } else if (strcmp(func_name,"method_get_overridden_method") == 0) {
+ return (void*)method_find_overridden_method;
+ } else if (strcmp(func_name,"vector_get_first_element_offset") == 0) {
+ return (void*)vector_first_element_offset_class_handle;
+ } else if (strcmp(func_name,"vector_get_length_offset") == 0) {
+ return (void*)vector_length_offset;
+ } else if (strcmp(func_name,"vm_tls_alloc") == 0) {
+ return (void*)hythread_tls_alloc;
+ } else if (strcmp(func_name,"vm_tls_get_offset") == 0) {
+ return (void*)hythread_tls_get_offset;
+ } else if (strcmp(func_name,"vm_tls_get_request_offset") == 0) {
+ return (void*)hythread_tls_get_request_offset;
+ } else if (strcmp(func_name,"vm_tls_is_fast") == 0) {
+ return (void*)hythread_uses_fast_tls;
+ } else if (strcmp(func_name,"vm_get_tls_offset_in_segment") == 0) {
+ return (void*)hythread_get_hythread_offset_in_tls;
+ } else if (strcmp(func_name,"vm_get_system_object_class") == 0) {
+ return (void*)get_system_object_class;
+ } else if (strcmp(func_name,"vm_get_system_class_class") == 0) {
+ return (void*)get_system_class_class;
+ } else if (strcmp(func_name,"vm_get_system_string_class") == 0) {
+ return (void*)get_system_string_class;
+ } else if (strcmp(func_name,"vm_get_heap_base_address") == 0) {
+ return (void*)vm_heap_base_address;
+ } else if (strcmp(func_name,"vm_get_heap_ceiling_address") == 0) {
+ return (void*)vm_heap_ceiling_address;
+ } else if (strcmp(func_name,"vm_is_heap_compressed") == 0) {
+ return (void*)vm_references_are_compressed;
+ } else if (strcmp(func_name,"vm_is_vtable_compressed") == 0) {
+ return (void*)vm_vtable_pointers_are_compressed;
+ } else if (strcmp(func_name,"vm_compiled_method_load") == 0) {
+ return (void*)compiled_method_load;
+ } else if (strcmp(func_name,"vm_properties_destroy_keys") == 0) {
+ return (void*)destroy_properties_keys;
+ } else if (strcmp(func_name,"vm_properties_destroy_value") == 0) {
+ return (void*)destroy_property_value;
+ } else if (strcmp(func_name,"vm_properties_get_keys") == 0) {
+ return (void*)get_properties_keys;
+ } else if (strcmp(func_name,"vm_properties_get_keys_starting_with") == 0) {
+ return (void*)get_properties_keys_staring_with;
+ } else if (strcmp(func_name,"vm_properties_get_value") == 0) {
+ return (void*)get_property;
+ } else if (strcmp(func_name,"vm_helper_get_addr") == 0) {
+ return (void*)vm_get_rt_support_addr;
+ } else if (strcmp(func_name,"vm_helper_get_addr_optimized") == 0) {
+ return (void*)vm_get_rt_support_addr_optimized;
+ } else {
+ return NULL;
+ }
+}
#define GC_DLL_COMP PORT_DSO_NAME("gc_gen")
#define GC_DLL_UNCOMP PORT_DSO_NAME("gc_gen_uncomp")
@@ -151,7 +249,7 @@
LWARN(13, "Cannot load EM component from {0}" << dll);
return status;
}
-
+
status = vm_env->cm->CreateInstance(&(vm_env->em_instance), "em");
if (status != JNI_OK) {
LWARN(14, "Cannot instantiate EM");