Mon, 29 Oct 2012 11:08:48 -0700
8000780: make Zero build and run with JDK8
Reviewed-by: coleenp, dholmes, twisti
Contributed-by: Roman Kennke <rkennke@redhat.com>
1.1 --- a/make/Makefile Fri Oct 26 14:18:57 2012 -0700 1.2 +++ b/make/Makefile Mon Oct 29 11:08:48 2012 -0700 1.3 @@ -453,14 +453,30 @@ 1.4 ifeq ($(JVM_VARIANT_ZEROSHARK), true) 1.5 $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX) 1.6 $(install-file) 1.7 + $(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo): $(SHARK_DIR)/%.debuginfo 1.8 + $(install-file) 1.9 + $(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(SHARK_DIR)/%.diz 1.10 + $(install-file) 1.11 $(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX) 1.12 $(install-file) 1.13 + $(EXPORT_SERVER_DIR)/%.debuginfo: $(SHARK_DIR)/%.debuginfo 1.14 + $(install-file) 1.15 + $(EXPORT_SERVER_DIR)/%.diz: $(SHARK_DIR)/%.diz 1.16 + $(install-file) 1.17 endif 1.18 ifeq ($(JVM_VARIANT_ZERO), true) 1.19 $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX) 1.20 $(install-file) 1.21 + $(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(ZERO_DIR)/%.debuginfo 1.22 + $(install-file) 1.23 + $(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(ZERO_DIR)/%.diz 1.24 + $(install-file) 1.25 $(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX) 1.26 $(install-file) 1.27 + $(EXPORT_SERVER_DIR)/%.debuginfo: $(ZERO_DIR)/%.debuginfo 1.28 + $(install-file) 1.29 + $(EXPORT_SERVER_DIR)/%.diz: $(ZERO_DIR)/%.diz 1.30 + $(install-file) 1.31 endif 1.32 ifeq ($(JVM_VARIANT_MINIMAL1), true) 1.33 $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
2.1 --- a/src/cpu/zero/vm/cppInterpreterGenerator_zero.hpp Fri Oct 26 14:18:57 2012 -0700 2.2 +++ b/src/cpu/zero/vm/cppInterpreterGenerator_zero.hpp Mon Oct 29 11:08:48 2012 -0700 2.3 @@ -31,12 +31,17 @@ 2.4 return _masm; 2.5 } 2.6 2.7 - protected: 2.8 - address generate_entry(address entry_point) { 2.9 - ZeroEntry *entry = (ZeroEntry *) assembler()->pc(); 2.10 - assembler()->advance(sizeof(ZeroEntry)); 2.11 + public: 2.12 + static address generate_entry_impl(MacroAssembler* masm, address entry_point) { 2.13 + ZeroEntry *entry = (ZeroEntry *) masm->pc(); 2.14 + masm->advance(sizeof(ZeroEntry)); 2.15 entry->set_entry_point(entry_point); 2.16 return (address) entry; 2.17 } 2.18 2.19 + protected: 2.20 + address generate_entry(address entry_point) { 2.21 + return generate_entry_impl(assembler(), entry_point); 2.22 + } 2.23 + 2.24 #endif // CPU_ZERO_VM_CPPINTERPRETERGENERATOR_ZERO_HPP
3.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp Fri Oct 26 14:18:57 2012 -0700 3.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp Mon Oct 29 11:08:48 2012 -0700 3.3 @@ -180,25 +180,6 @@ 3.4 method, istate->osr_entry(), istate->osr_buf(), THREAD); 3.5 return; 3.6 } 3.7 - else if (istate->msg() == BytecodeInterpreter::call_method_handle) { 3.8 - oop method_handle = istate->callee(); 3.9 - 3.10 - // Trim back the stack to put the parameters at the top 3.11 - stack->set_sp(istate->stack() + 1); 3.12 - 3.13 - // Make the call 3.14 - process_method_handle(method_handle, THREAD); 3.15 - fixup_after_potential_safepoint(); 3.16 - 3.17 - // Convert the result 3.18 - istate->set_stack(stack->sp() - 1); 3.19 - 3.20 - // Restore the stack 3.21 - stack->set_sp(istate->stack_limit() + 1); 3.22 - 3.23 - // Resume the interpreter 3.24 - istate->set_msg(BytecodeInterpreter::method_resume); 3.25 - } 3.26 else { 3.27 ShouldNotReachHere(); 3.28 } 3.29 @@ -535,35 +516,35 @@ 3.30 if (entry->is_volatile()) { 3.31 switch (entry->flag_state()) { 3.32 case ctos: 3.33 - SET_LOCALS_INT(object->char_field_acquire(entry->f2()), 0); 3.34 + SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0); 3.35 break; 3.36 3.37 case btos: 3.38 - SET_LOCALS_INT(object->byte_field_acquire(entry->f2()), 0); 3.39 + SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0); 3.40 break; 3.41 3.42 case stos: 3.43 - SET_LOCALS_INT(object->short_field_acquire(entry->f2()), 0); 3.44 + SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0); 3.45 break; 3.46 3.47 case itos: 3.48 - SET_LOCALS_INT(object->int_field_acquire(entry->f2()), 0); 3.49 + SET_LOCALS_INT(object->int_field_acquire(entry->f2_as_index()), 0); 3.50 break; 3.51 3.52 case ltos: 3.53 - SET_LOCALS_LONG(object->long_field_acquire(entry->f2()), 0); 3.54 + SET_LOCALS_LONG(object->long_field_acquire(entry->f2_as_index()), 0); 3.55 break; 3.56 3.57 case ftos: 3.58 - SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2()), 0); 3.59 + SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2_as_index()), 0); 3.60 break; 3.61 3.62 case dtos: 3.63 - SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2()), 0); 3.64 + SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2_as_index()), 0); 3.65 break; 3.66 3.67 case atos: 3.68 - SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2()), 0); 3.69 + SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2_as_index()), 0); 3.70 break; 3.71 3.72 default: 3.73 @@ -573,35 +554,35 @@ 3.74 else { 3.75 switch (entry->flag_state()) { 3.76 case ctos: 3.77 - SET_LOCALS_INT(object->char_field(entry->f2()), 0); 3.78 + SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0); 3.79 break; 3.80 3.81 case btos: 3.82 - SET_LOCALS_INT(object->byte_field(entry->f2()), 0); 3.83 + SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0); 3.84 break; 3.85 3.86 case stos: 3.87 - SET_LOCALS_INT(object->short_field(entry->f2()), 0); 3.88 + SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0); 3.89 break; 3.90 3.91 case itos: 3.92 - SET_LOCALS_INT(object->int_field(entry->f2()), 0); 3.93 + SET_LOCALS_INT(object->int_field(entry->f2_as_index()), 0); 3.94 break; 3.95 3.96 case ltos: 3.97 - SET_LOCALS_LONG(object->long_field(entry->f2()), 0); 3.98 + SET_LOCALS_LONG(object->long_field(entry->f2_as_index()), 0); 3.99 break; 3.100 3.101 case ftos: 3.102 - SET_LOCALS_FLOAT(object->float_field(entry->f2()), 0); 3.103 + SET_LOCALS_FLOAT(object->float_field(entry->f2_as_index()), 0); 3.104 break; 3.105 3.106 case dtos: 3.107 - SET_LOCALS_DOUBLE(object->double_field(entry->f2()), 0); 3.108 + SET_LOCALS_DOUBLE(object->double_field(entry->f2_as_index()), 0); 3.109 break; 3.110 3.111 case atos: 3.112 - SET_LOCALS_OBJECT(object->obj_field(entry->f2()), 0); 3.113 + SET_LOCALS_OBJECT(object->obj_field(entry->f2_as_index()), 0); 3.114 break; 3.115 3.116 default: 3.117 @@ -629,516 +610,6 @@ 3.118 return 0; 3.119 } 3.120 3.121 -int CppInterpreter::method_handle_entry(Method* method, 3.122 - intptr_t UNUSED, TRAPS) { 3.123 - JavaThread *thread = (JavaThread *) THREAD; 3.124 - ZeroStack *stack = thread->zero_stack(); 3.125 - int argument_slots = method->size_of_parameters(); 3.126 - int result_slots = type2size[result_type_of(method)]; 3.127 - intptr_t *vmslots = stack->sp(); 3.128 - intptr_t *unwind_sp = vmslots + argument_slots; 3.129 - 3.130 - // Find the MethodType 3.131 - address p = (address) method; 3.132 - for (jint* pc = method->method_type_offsets_chain(); (*pc) != -1; pc++) { 3.133 - p = *(address*)(p + (*pc)); 3.134 - } 3.135 - oop method_type = (oop) p; 3.136 - 3.137 - // The MethodHandle is in the slot after the arguments 3.138 - int num_vmslots = argument_slots - 1; 3.139 - oop method_handle = VMSLOTS_OBJECT(num_vmslots); 3.140 - 3.141 - // InvokeGeneric requires some extra shuffling 3.142 - oop mhtype = java_lang_invoke_MethodHandle::type(method_handle); 3.143 - bool is_exact = mhtype == method_type; 3.144 - if (!is_exact) { 3.145 - if (true || // FIXME 3.146 - method->intrinsic_id() == vmIntrinsics::_invokeExact) { 3.147 - CALL_VM_NOCHECK_NOFIX( 3.148 - SharedRuntime::throw_WrongMethodTypeException( 3.149 - thread, method_type, mhtype)); 3.150 - // NB all oops trashed! 3.151 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.152 - stack->set_sp(unwind_sp); 3.153 - return 0; 3.154 - } 3.155 - assert(method->intrinsic_id() == vmIntrinsics::_invokeGeneric, "should be"); 3.156 - 3.157 - // Load up an adapter from the calling type 3.158 - // NB the x86 code for this (in methodHandles_x86.cpp, search for 3.159 - // "genericInvoker") is really really odd. I'm hoping it's trying 3.160 - // to accomodate odd VM/class library combinations I can ignore. 3.161 - oop adapter = NULL; //FIXME: load the adapter from the CP cache 3.162 - IF (adapter == NULL) { 3.163 - CALL_VM_NOCHECK_NOFIX( 3.164 - SharedRuntime::throw_WrongMethodTypeException( 3.165 - thread, method_type, mhtype)); 3.166 - // NB all oops trashed! 3.167 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.168 - stack->set_sp(unwind_sp); 3.169 - return 0; 3.170 - } 3.171 - 3.172 - // Adapters are shared among form-families of method-type. The 3.173 - // type being called is passed as a trusted first argument so that 3.174 - // the adapter knows the actual types of its arguments and return 3.175 - // values. 3.176 - insert_vmslots(num_vmslots + 1, 1, THREAD); 3.177 - if (HAS_PENDING_EXCEPTION) { 3.178 - // NB all oops trashed! 3.179 - stack->set_sp(unwind_sp); 3.180 - return 0; 3.181 - } 3.182 - 3.183 - vmslots = stack->sp(); 3.184 - num_vmslots++; 3.185 - SET_VMSLOTS_OBJECT(method_type, num_vmslots); 3.186 - 3.187 - method_handle = adapter; 3.188 - } 3.189 - 3.190 - // Start processing 3.191 - process_method_handle(method_handle, THREAD); 3.192 - if (HAS_PENDING_EXCEPTION) 3.193 - result_slots = 0; 3.194 - 3.195 - // If this is an invokeExact then the eventual callee will not 3.196 - // have unwound the method handle argument so we have to do it. 3.197 - // If a result is being returned the it will be above the method 3.198 - // handle argument we're unwinding. 3.199 - if (is_exact) { 3.200 - intptr_t result[2]; 3.201 - for (int i = 0; i < result_slots; i++) 3.202 - result[i] = stack->pop(); 3.203 - stack->pop(); 3.204 - for (int i = result_slots - 1; i >= 0; i--) 3.205 - stack->push(result[i]); 3.206 - } 3.207 - 3.208 - // Check 3.209 - assert(stack->sp() == unwind_sp - result_slots, "should be"); 3.210 - 3.211 - // No deoptimized frames on the stack 3.212 - return 0; 3.213 -} 3.214 - 3.215 -void CppInterpreter::process_method_handle(oop method_handle, TRAPS) { 3.216 - JavaThread *thread = (JavaThread *) THREAD; 3.217 - ZeroStack *stack = thread->zero_stack(); 3.218 - intptr_t *vmslots = stack->sp(); 3.219 - 3.220 - bool direct_to_method = false; 3.221 - BasicType src_rtype = T_ILLEGAL; 3.222 - BasicType dst_rtype = T_ILLEGAL; 3.223 - 3.224 - MethodHandleEntry *entry = 3.225 - java_lang_invoke_MethodHandle::vmentry(method_handle); 3.226 - MethodHandles::EntryKind entry_kind = 3.227 - (MethodHandles::EntryKind) (((intptr_t) entry) & 0xffffffff); 3.228 - 3.229 - Method* method = NULL; 3.230 - switch (entry_kind) { 3.231 - case MethodHandles::_invokestatic_mh: 3.232 - direct_to_method = true; 3.233 - break; 3.234 - 3.235 - case MethodHandles::_invokespecial_mh: 3.236 - case MethodHandles::_invokevirtual_mh: 3.237 - case MethodHandles::_invokeinterface_mh: 3.238 - { 3.239 - oop receiver = 3.240 - VMSLOTS_OBJECT( 3.241 - java_lang_invoke_MethodHandle::vmslots(method_handle) - 1); 3.242 - if (receiver == NULL) { 3.243 - stack->set_sp(calculate_unwind_sp(stack, method_handle)); 3.244 - CALL_VM_NOCHECK_NOFIX( 3.245 - throw_exception( 3.246 - thread, vmSymbols::java_lang_NullPointerException())); 3.247 - // NB all oops trashed! 3.248 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.249 - return; 3.250 - } 3.251 - if (entry_kind != MethodHandles::_invokespecial_mh) { 3.252 - intptr_t index = java_lang_invoke_DirectMethodHandle::vmindex(method_handle); 3.253 - InstanceKlass* rcvrKlass = 3.254 - (InstanceKlass *) receiver->klass(); 3.255 - if (entry_kind == MethodHandles::_invokevirtual_mh) { 3.256 - method = (Method*) rcvrKlass->start_of_vtable()[index]; 3.257 - } 3.258 - else { 3.259 - oop iclass = java_lang_invoke_MethodHandle::next_target(method_handle); 3.260 - itableOffsetEntry* ki = 3.261 - (itableOffsetEntry *) rcvrKlass->start_of_itable(); 3.262 - int i, length = rcvrKlass->itable_length(); 3.263 - for (i = 0; i < length; i++, ki++ ) { 3.264 - if (ki->interface_klass() == iclass) 3.265 - break; 3.266 - } 3.267 - if (i == length) { 3.268 - stack->set_sp(calculate_unwind_sp(stack, method_handle)); 3.269 - CALL_VM_NOCHECK_NOFIX( 3.270 - throw_exception( 3.271 - thread, vmSymbols::java_lang_IncompatibleClassChangeError())); 3.272 - // NB all oops trashed! 3.273 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.274 - return; 3.275 - } 3.276 - itableMethodEntry* im = ki->first_method_entry(receiver->klass()); 3.277 - method = im[index].method(); 3.278 - if (method == NULL) { 3.279 - stack->set_sp(calculate_unwind_sp(stack, method_handle)); 3.280 - CALL_VM_NOCHECK_NOFIX( 3.281 - throw_exception( 3.282 - thread, vmSymbols::java_lang_AbstractMethodError())); 3.283 - // NB all oops trashed! 3.284 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.285 - return; 3.286 - } 3.287 - } 3.288 - } 3.289 - } 3.290 - direct_to_method = true; 3.291 - break; 3.292 - 3.293 - case MethodHandles::_bound_ref_direct_mh: 3.294 - case MethodHandles::_bound_int_direct_mh: 3.295 - case MethodHandles::_bound_long_direct_mh: 3.296 - direct_to_method = true; 3.297 - // fall through 3.298 - case MethodHandles::_bound_ref_mh: 3.299 - case MethodHandles::_bound_int_mh: 3.300 - case MethodHandles::_bound_long_mh: 3.301 - { 3.302 - BasicType arg_type = T_ILLEGAL; 3.303 - int arg_mask = -1; 3.304 - int arg_slots = -1; 3.305 - MethodHandles::get_ek_bound_mh_info( 3.306 - entry_kind, arg_type, arg_mask, arg_slots); 3.307 - int arg_slot = 3.308 - java_lang_invoke_BoundMethodHandle::vmargslot(method_handle); 3.309 - 3.310 - // Create the new slot(s) 3.311 - intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle); 3.312 - insert_vmslots(arg_slot, arg_slots, THREAD); 3.313 - if (HAS_PENDING_EXCEPTION) { 3.314 - // all oops trashed 3.315 - stack->set_sp(unwind_sp); 3.316 - return; 3.317 - } 3.318 - vmslots = stack->sp(); 3.319 - 3.320 - // Store bound argument into new stack slot 3.321 - oop arg = java_lang_invoke_BoundMethodHandle::argument(method_handle); 3.322 - if (arg_type == T_OBJECT) { 3.323 - assert(arg_slots == 1, "should be"); 3.324 - SET_VMSLOTS_OBJECT(arg, arg_slot); 3.325 - } 3.326 - else { 3.327 - jvalue arg_value; 3.328 - arg_type = java_lang_boxing_object::get_value(arg, &arg_value); 3.329 - switch (arg_type) { 3.330 - case T_BOOLEAN: 3.331 - SET_VMSLOTS_INT(arg_value.z, arg_slot); 3.332 - break; 3.333 - case T_CHAR: 3.334 - SET_VMSLOTS_INT(arg_value.c, arg_slot); 3.335 - break; 3.336 - case T_BYTE: 3.337 - SET_VMSLOTS_INT(arg_value.b, arg_slot); 3.338 - break; 3.339 - case T_SHORT: 3.340 - SET_VMSLOTS_INT(arg_value.s, arg_slot); 3.341 - break; 3.342 - case T_INT: 3.343 - SET_VMSLOTS_INT(arg_value.i, arg_slot); 3.344 - break; 3.345 - case T_FLOAT: 3.346 - SET_VMSLOTS_FLOAT(arg_value.f, arg_slot); 3.347 - break; 3.348 - case T_LONG: 3.349 - SET_VMSLOTS_LONG(arg_value.j, arg_slot + 1); 3.350 - break; 3.351 - case T_DOUBLE: 3.352 - SET_VMSLOTS_DOUBLE(arg_value.d, arg_slot + 1); 3.353 - break; 3.354 - default: 3.355 - tty->print_cr("unhandled type %s", type2name(arg_type)); 3.356 - ShouldNotReachHere(); 3.357 - } 3.358 - } 3.359 - } 3.360 - break; 3.361 - 3.362 - case MethodHandles::_adapter_retype_only: 3.363 - case MethodHandles::_adapter_retype_raw: 3.364 - src_rtype = result_type_of_handle( 3.365 - java_lang_invoke_MethodHandle::next_target(method_handle)); 3.366 - dst_rtype = result_type_of_handle(method_handle); 3.367 - break; 3.368 - 3.369 - case MethodHandles::_adapter_check_cast: 3.370 - { 3.371 - int arg_slot = 3.372 - java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); 3.373 - oop arg = VMSLOTS_OBJECT(arg_slot); 3.374 - if (arg != NULL) { 3.375 - Klass* objKlassOop = arg->klass(); 3.376 - Klass* klassOf = java_lang_Class::as_Klass( 3.377 - java_lang_invoke_AdapterMethodHandle::argument(method_handle)); 3.378 - 3.379 - if (objKlassOop != klassOf && 3.380 - !objKlassOop->is_subtype_of(klassOf)) { 3.381 - ResourceMark rm(THREAD); 3.382 - const char* objName = Klass::cast(objKlassOop)->external_name(); 3.383 - const char* klassName = Klass::cast(klassOf)->external_name(); 3.384 - char* message = SharedRuntime::generate_class_cast_message( 3.385 - objName, klassName); 3.386 - 3.387 - stack->set_sp(calculate_unwind_sp(stack, method_handle)); 3.388 - CALL_VM_NOCHECK_NOFIX( 3.389 - throw_exception( 3.390 - thread, vmSymbols::java_lang_ClassCastException(), message)); 3.391 - // NB all oops trashed! 3.392 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.393 - return; 3.394 - } 3.395 - } 3.396 - } 3.397 - break; 3.398 - 3.399 - case MethodHandles::_adapter_dup_args: 3.400 - { 3.401 - int arg_slot = 3.402 - java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); 3.403 - int conv = 3.404 - java_lang_invoke_AdapterMethodHandle::conversion(method_handle); 3.405 - int num_slots = -MethodHandles::adapter_conversion_stack_move(conv); 3.406 - assert(num_slots > 0, "should be"); 3.407 - 3.408 - // Create the new slot(s) 3.409 - intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle); 3.410 - stack->overflow_check(num_slots, THREAD); 3.411 - if (HAS_PENDING_EXCEPTION) { 3.412 - // all oops trashed 3.413 - stack->set_sp(unwind_sp); 3.414 - return; 3.415 - } 3.416 - 3.417 - // Duplicate the arguments 3.418 - for (int i = num_slots - 1; i >= 0; i--) 3.419 - stack->push(*VMSLOTS_SLOT(arg_slot + i)); 3.420 - 3.421 - vmslots = stack->sp(); // unused, but let the compiler figure that out 3.422 - } 3.423 - break; 3.424 - 3.425 - case MethodHandles::_adapter_drop_args: 3.426 - { 3.427 - int arg_slot = 3.428 - java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); 3.429 - int conv = 3.430 - java_lang_invoke_AdapterMethodHandle::conversion(method_handle); 3.431 - int num_slots = MethodHandles::adapter_conversion_stack_move(conv); 3.432 - assert(num_slots > 0, "should be"); 3.433 - 3.434 - remove_vmslots(arg_slot, num_slots, THREAD); // doesn't trap 3.435 - vmslots = stack->sp(); // unused, but let the compiler figure that out 3.436 - } 3.437 - break; 3.438 - 3.439 - case MethodHandles::_adapter_opt_swap_1: 3.440 - case MethodHandles::_adapter_opt_swap_2: 3.441 - case MethodHandles::_adapter_opt_rot_1_up: 3.442 - case MethodHandles::_adapter_opt_rot_1_down: 3.443 - case MethodHandles::_adapter_opt_rot_2_up: 3.444 - case MethodHandles::_adapter_opt_rot_2_down: 3.445 - { 3.446 - int arg1 = 3.447 - java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); 3.448 - int conv = 3.449 - java_lang_invoke_AdapterMethodHandle::conversion(method_handle); 3.450 - int arg2 = MethodHandles::adapter_conversion_vminfo(conv); 3.451 - 3.452 - int swap_bytes = 0, rotate = 0; 3.453 - MethodHandles::get_ek_adapter_opt_swap_rot_info( 3.454 - entry_kind, swap_bytes, rotate); 3.455 - int swap_slots = swap_bytes >> LogBytesPerWord; 3.456 - 3.457 - intptr_t tmp; 3.458 - switch (rotate) { 3.459 - case 0: // swap 3.460 - for (int i = 0; i < swap_slots; i++) { 3.461 - tmp = *VMSLOTS_SLOT(arg1 + i); 3.462 - SET_VMSLOTS_SLOT(VMSLOTS_SLOT(arg2 + i), arg1 + i); 3.463 - SET_VMSLOTS_SLOT(&tmp, arg2 + i); 3.464 - } 3.465 - break; 3.466 - 3.467 - case 1: // up 3.468 - assert(arg1 - swap_slots > arg2, "should be"); 3.469 - 3.470 - tmp = *VMSLOTS_SLOT(arg1); 3.471 - for (int i = arg1 - swap_slots; i >= arg2; i--) 3.472 - SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + swap_slots); 3.473 - SET_VMSLOTS_SLOT(&tmp, arg2); 3.474 - 3.475 - break; 3.476 - 3.477 - case -1: // down 3.478 - assert(arg2 - swap_slots > arg1, "should be"); 3.479 - 3.480 - tmp = *VMSLOTS_SLOT(arg1); 3.481 - for (int i = arg1 + swap_slots; i <= arg2; i++) 3.482 - SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i - swap_slots); 3.483 - SET_VMSLOTS_SLOT(&tmp, arg2); 3.484 - break; 3.485 - 3.486 - default: 3.487 - ShouldNotReachHere(); 3.488 - } 3.489 - } 3.490 - break; 3.491 - 3.492 - case MethodHandles::_adapter_opt_i2l: 3.493 - { 3.494 - int arg_slot = 3.495 - java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); 3.496 - int arg = VMSLOTS_INT(arg_slot); 3.497 - intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle); 3.498 - insert_vmslots(arg_slot, 1, THREAD); 3.499 - if (HAS_PENDING_EXCEPTION) { 3.500 - // all oops trashed 3.501 - stack->set_sp(unwind_sp); 3.502 - return; 3.503 - } 3.504 - vmslots = stack->sp(); 3.505 - arg_slot++; 3.506 - SET_VMSLOTS_LONG(arg, arg_slot); 3.507 - } 3.508 - break; 3.509 - 3.510 - case MethodHandles::_adapter_opt_unboxi: 3.511 - case MethodHandles::_adapter_opt_unboxl: 3.512 - { 3.513 - int arg_slot = 3.514 - java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); 3.515 - oop arg = VMSLOTS_OBJECT(arg_slot); 3.516 - jvalue arg_value; 3.517 - if (arg == NULL) { 3.518 - // queue a nullpointer exception for the caller 3.519 - stack->set_sp(calculate_unwind_sp(stack, method_handle)); 3.520 - CALL_VM_NOCHECK_NOFIX( 3.521 - throw_exception( 3.522 - thread, vmSymbols::java_lang_NullPointerException())); 3.523 - // NB all oops trashed! 3.524 - assert(HAS_PENDING_EXCEPTION, "should do"); 3.525 - return; 3.526 - } 3.527 - BasicType arg_type = java_lang_boxing_object::get_value(arg, &arg_value); 3.528 - if (arg_type == T_LONG || arg_type == T_DOUBLE) { 3.529 - intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle); 3.530 - insert_vmslots(arg_slot, 1, THREAD); 3.531 - if (HAS_PENDING_EXCEPTION) { 3.532 - // all oops trashed 3.533 - stack->set_sp(unwind_sp); 3.534 - return; 3.535 - } 3.536 - vmslots = stack->sp(); 3.537 - arg_slot++; 3.538 - } 3.539 - switch (arg_type) { 3.540 - case T_BOOLEAN: 3.541 - SET_VMSLOTS_INT(arg_value.z, arg_slot); 3.542 - break; 3.543 - case T_CHAR: 3.544 - SET_VMSLOTS_INT(arg_value.c, arg_slot); 3.545 - break; 3.546 - case T_BYTE: 3.547 - SET_VMSLOTS_INT(arg_value.b, arg_slot); 3.548 - break; 3.549 - case T_SHORT: 3.550 - SET_VMSLOTS_INT(arg_value.s, arg_slot); 3.551 - break; 3.552 - case T_INT: 3.553 - SET_VMSLOTS_INT(arg_value.i, arg_slot); 3.554 - break; 3.555 - case T_FLOAT: 3.556 - SET_VMSLOTS_FLOAT(arg_value.f, arg_slot); 3.557 - break; 3.558 - case T_LONG: 3.559 - SET_VMSLOTS_LONG(arg_value.j, arg_slot); 3.560 - break; 3.561 - case T_DOUBLE: 3.562 - SET_VMSLOTS_DOUBLE(arg_value.d, arg_slot); 3.563 - break; 3.564 - default: 3.565 - tty->print_cr("unhandled type %s", type2name(arg_type)); 3.566 - ShouldNotReachHere(); 3.567 - } 3.568 - } 3.569 - break; 3.570 - 3.571 - default: 3.572 - tty->print_cr("unhandled entry_kind %s", 3.573 - MethodHandles::entry_name(entry_kind)); 3.574 - ShouldNotReachHere(); 3.575 - } 3.576 - 3.577 - // Continue along the chain 3.578 - if (direct_to_method) { 3.579 - if (method == NULL) { 3.580 - method = 3.581 - (Method*) java_lang_invoke_MethodHandle::vmtarget(method_handle); 3.582 - } 3.583 - address entry_point = method->from_interpreted_entry(); 3.584 - Interpreter::invoke_method(method, entry_point, THREAD); 3.585 - } 3.586 - else { 3.587 - process_method_handle( 3.588 - java_lang_invoke_MethodHandle::next_target(method_handle), THREAD); 3.589 - } 3.590 - // NB all oops now trashed 3.591 - 3.592 - // Adapt the result type, if necessary 3.593 - if (src_rtype != dst_rtype && !HAS_PENDING_EXCEPTION) { 3.594 - switch (dst_rtype) { 3.595 - case T_VOID: 3.596 - for (int i = 0; i < type2size[src_rtype]; i++) 3.597 - stack->pop(); 3.598 - return; 3.599 - 3.600 - case T_INT: 3.601 - switch (src_rtype) { 3.602 - case T_VOID: 3.603 - stack->overflow_check(1, CHECK); 3.604 - stack->push(0); 3.605 - return; 3.606 - 3.607 - case T_BOOLEAN: 3.608 - case T_CHAR: 3.609 - case T_BYTE: 3.610 - case T_SHORT: 3.611 - return; 3.612 - } 3.613 - // INT results sometimes need narrowing 3.614 - case T_BOOLEAN: 3.615 - case T_CHAR: 3.616 - case T_BYTE: 3.617 - case T_SHORT: 3.618 - switch (src_rtype) { 3.619 - case T_INT: 3.620 - return; 3.621 - } 3.622 - } 3.623 - 3.624 - tty->print_cr("unhandled conversion:"); 3.625 - tty->print_cr("src_rtype = %s", type2name(src_rtype)); 3.626 - tty->print_cr("dst_rtype = %s", type2name(dst_rtype)); 3.627 - ShouldNotReachHere(); 3.628 - } 3.629 -} 3.630 - 3.631 // The new slots will be inserted before slot insert_before. 3.632 // Slots < insert_before will have the same slot number after the insert. 3.633 // Slots >= insert_before will become old_slot + num_slots. 3.634 @@ -1380,10 +851,6 @@ 3.635 entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry(); 3.636 break; 3.637 3.638 - case Interpreter::method_handle: 3.639 - entry_point = ((InterpreterGenerator*) this)->generate_method_handle_entry(); 3.640 - break; 3.641 - 3.642 case Interpreter::java_lang_math_sin: 3.643 case Interpreter::java_lang_math_cos: 3.644 case Interpreter::java_lang_math_tan: 3.645 @@ -1391,6 +858,8 @@ 3.646 case Interpreter::java_lang_math_log: 3.647 case Interpreter::java_lang_math_log10: 3.648 case Interpreter::java_lang_math_sqrt: 3.649 + case Interpreter::java_lang_math_pow: 3.650 + case Interpreter::java_lang_math_exp: 3.651 entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind); 3.652 break; 3.653
4.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.hpp Fri Oct 26 14:18:57 2012 -0700 4.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.hpp Mon Oct 29 11:08:48 2012 -0700 4.3 @@ -36,7 +36,6 @@ 4.4 static int native_entry(Method* method, intptr_t UNUSED, TRAPS); 4.5 static int accessor_entry(Method* method, intptr_t UNUSED, TRAPS); 4.6 static int empty_entry(Method* method, intptr_t UNUSED, TRAPS); 4.7 - static int method_handle_entry(Method* method, intptr_t UNUSED, TRAPS); 4.8 4.9 public: 4.10 // Main loop of normal_entry 4.11 @@ -44,7 +43,6 @@ 4.12 4.13 private: 4.14 // Helpers for method_handle_entry 4.15 - static void process_method_handle(oop method_handle, TRAPS); 4.16 static void insert_vmslots(int insert_before, int num_slots, TRAPS); 4.17 static void remove_vmslots(int first_slot, int num_slots, TRAPS); 4.18 static BasicType result_type_of_handle(oop method_handle);
5.1 --- a/src/cpu/zero/vm/frame_zero.cpp Fri Oct 26 14:18:57 2012 -0700 5.2 +++ b/src/cpu/zero/vm/frame_zero.cpp Mon Oct 29 11:08:48 2012 -0700 5.3 @@ -351,7 +351,7 @@ 5.4 switch (offset) { 5.5 case pc_off: 5.6 strncpy(fieldbuf, "pc", buflen); 5.7 - if (method()->is_oop()) { 5.8 + if (method()->is_method()) { 5.9 nmethod *code = method()->code(); 5.10 if (code && code->pc_desc_at(pc())) { 5.11 SimpleScopeDesc ssd(code, pc()); 5.12 @@ -367,7 +367,7 @@ 5.13 5.14 case method_off: 5.15 strncpy(fieldbuf, "method", buflen); 5.16 - if (method()->is_oop()) { 5.17 + if (method()->is_method()) { 5.18 method()->name_and_sig_as_C_string(valuebuf, buflen); 5.19 } 5.20 return; 5.21 @@ -378,7 +378,7 @@ 5.22 } 5.23 5.24 // Variable part 5.25 - if (method()->is_oop()) { 5.26 + if (method()->is_method()) { 5.27 identify_vp_word(frame_index, addr_of_word(offset), 5.28 addr_of_word(header_words + 1), 5.29 unextended_sp() + method()->max_stack(), 5.30 @@ -430,4 +430,3 @@ 5.31 // unused... but returns fp() to minimize changes introduced by 7087445 5.32 return fp(); 5.33 } 5.34 -
6.1 --- a/src/cpu/zero/vm/frame_zero.inline.hpp Fri Oct 26 14:18:57 2012 -0700 6.2 +++ b/src/cpu/zero/vm/frame_zero.inline.hpp Mon Oct 29 11:08:48 2012 -0700 6.3 @@ -36,6 +36,8 @@ 6.4 _deopt_state = unknown; 6.5 } 6.6 6.7 +inline address frame::sender_pc() const { ShouldNotCallThis(); } 6.8 + 6.9 inline frame::frame(ZeroFrame* zf, intptr_t* sp) { 6.10 _zeroframe = zf; 6.11 _sp = sp;
7.1 --- a/src/cpu/zero/vm/icBuffer_zero.cpp Fri Oct 26 14:18:57 2012 -0700 7.2 +++ b/src/cpu/zero/vm/icBuffer_zero.cpp Mon Oct 29 11:08:48 2012 -0700 7.3 @@ -40,7 +40,7 @@ 7.4 } 7.5 7.6 void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, 7.7 - Metadata* cached_oop, 7.8 + void* cached_oop, 7.9 address entry_point) { 7.10 // NB ic_stub_code_size() must return the size of the code we generate 7.11 ShouldNotCallThis(); 7.12 @@ -51,7 +51,6 @@ 7.13 ShouldNotCallThis(); 7.14 } 7.15 7.16 -Metadata* InlineCacheBuffer::ic_buffer_cached_oop(address code_begin) { 7.17 - // NB ic_stub_code_size() must return the size of the code we generate 7.18 +void* InlineCacheBuffer::ic_buffer_cached_value(address code_begin) { 7.19 ShouldNotCallThis(); 7.20 }
8.1 --- a/src/cpu/zero/vm/methodHandles_zero.cpp Fri Oct 26 14:18:57 2012 -0700 8.2 +++ b/src/cpu/zero/vm/methodHandles_zero.cpp Mon Oct 29 11:08:48 2012 -0700 8.3 @@ -24,26 +24,159 @@ 8.4 */ 8.5 8.6 #include "precompiled.hpp" 8.7 +#include "interpreter/interpreterGenerator.hpp" 8.8 #include "interpreter/interpreter.hpp" 8.9 #include "memory/allocation.inline.hpp" 8.10 #include "prims/methodHandles.hpp" 8.11 8.12 -int MethodHandles::adapter_conversion_ops_supported_mask() { 8.13 - return ((1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY) 8.14 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW) 8.15 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST) 8.16 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM) 8.17 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM) 8.18 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS) 8.19 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS) 8.20 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS) 8.21 - |(1<<java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS) 8.22 - //|(1<<java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG! 8.23 - ); 8.24 - // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS. 8.25 +void MethodHandles::invoke_target(Method* method, TRAPS) { 8.26 + 8.27 + JavaThread *thread = (JavaThread *) THREAD; 8.28 + ZeroStack *stack = thread->zero_stack(); 8.29 + InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame(); 8.30 + interpreterState istate = frame->interpreter_state(); 8.31 + 8.32 + // Trim back the stack to put the parameters at the top 8.33 + stack->set_sp(istate->stack() + 1); 8.34 + 8.35 + Interpreter::invoke_method(method, method->from_interpreted_entry(), THREAD); 8.36 + 8.37 + // Convert the result 8.38 + istate->set_stack(stack->sp() - 1); 8.39 + 8.40 } 8.41 8.42 -void MethodHandles::generate_method_handle_stub(MacroAssembler* masm, 8.43 - MethodHandles::EntryKind ek) { 8.44 - init_entry(ek, (MethodHandleEntry *) ek); 8.45 +oop MethodHandles::popFromStack(TRAPS) { 8.46 + 8.47 + JavaThread *thread = (JavaThread *) THREAD; 8.48 + InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame(); 8.49 + interpreterState istate = frame->interpreter_state(); 8.50 + intptr_t* topOfStack = istate->stack(); 8.51 + 8.52 + oop top = STACK_OBJECT(-1); 8.53 + MORE_STACK(-1); 8.54 + istate->set_stack(topOfStack); 8.55 + 8.56 + return top; 8.57 + 8.58 } 8.59 + 8.60 +int MethodHandles::method_handle_entry_invokeBasic(Method* method, intptr_t UNUSED, TRAPS) { 8.61 + 8.62 + JavaThread *thread = (JavaThread *) THREAD; 8.63 + InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame(); 8.64 + interpreterState istate = frame->interpreter_state(); 8.65 + intptr_t* topOfStack = istate->stack(); 8.66 + 8.67 + // 'this' is a MethodHandle. We resolve the target method by accessing this.form.vmentry.vmtarget. 8.68 + int numArgs = method->size_of_parameters(); 8.69 + oop lform1 = java_lang_invoke_MethodHandle::form(STACK_OBJECT(-numArgs)); // this.form 8.70 + oop vmEntry1 = java_lang_invoke_LambdaForm::vmentry(lform1); 8.71 + Method* vmtarget = (Method*) java_lang_invoke_MemberName::vmtarget(vmEntry1); 8.72 + 8.73 + invoke_target(vmtarget, THREAD); 8.74 + 8.75 + // No deoptimized frames on the stack 8.76 + return 0; 8.77 +} 8.78 + 8.79 +int MethodHandles::method_handle_entry_linkToStaticOrSpecial(Method* method, intptr_t UNUSED, TRAPS) { 8.80 + 8.81 + // Pop appendix argument from stack. This is a MemberName which we resolve to the 8.82 + // target method. 8.83 + oop vmentry = popFromStack(THREAD); 8.84 + 8.85 + Method* vmtarget = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry); 8.86 + 8.87 + invoke_target(vmtarget, THREAD); 8.88 + 8.89 + return 0; 8.90 +} 8.91 + 8.92 +int MethodHandles::method_handle_entry_linkToInterface(Method* method, intptr_t UNUSED, TRAPS) { 8.93 + JavaThread *thread = (JavaThread *) THREAD; 8.94 + InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame(); 8.95 + interpreterState istate = frame->interpreter_state(); 8.96 + 8.97 + // Pop appendix argument from stack. This is a MemberName which we resolve to the 8.98 + // target method. 8.99 + oop vmentry = popFromStack(THREAD); 8.100 + intptr_t* topOfStack = istate->stack(); 8.101 + 8.102 + // Resolve target method by looking up in the receiver object's itable. 8.103 + Klass* clazz = java_lang_Class::as_Klass(java_lang_invoke_MemberName::clazz(vmentry)); 8.104 + intptr_t vmindex = java_lang_invoke_MemberName::vmindex(vmentry); 8.105 + Method* target = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry); 8.106 + 8.107 + int numArgs = target->size_of_parameters(); 8.108 + oop recv = STACK_OBJECT(-numArgs); 8.109 + 8.110 + InstanceKlass* klass_part = InstanceKlass::cast(recv->klass()); 8.111 + itableOffsetEntry* ki = (itableOffsetEntry*) klass_part->start_of_itable(); 8.112 + int i; 8.113 + for ( i = 0 ; i < klass_part->itable_length() ; i++, ki++ ) { 8.114 + if (ki->interface_klass() == clazz) break; 8.115 + } 8.116 + 8.117 + itableMethodEntry* im = ki->first_method_entry(recv->klass()); 8.118 + Method* vmtarget = im[vmindex].method(); 8.119 + 8.120 + invoke_target(vmtarget, THREAD); 8.121 + 8.122 + return 0; 8.123 +} 8.124 + 8.125 +int MethodHandles::method_handle_entry_linkToVirtual(Method* method, intptr_t UNUSED, TRAPS) { 8.126 + JavaThread *thread = (JavaThread *) THREAD; 8.127 + 8.128 + InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame(); 8.129 + interpreterState istate = frame->interpreter_state(); 8.130 + 8.131 + // Pop appendix argument from stack. This is a MemberName which we resolve to the 8.132 + // target method. 8.133 + oop vmentry = popFromStack(THREAD); 8.134 + intptr_t* topOfStack = istate->stack(); 8.135 + 8.136 + // Resolve target method by looking up in the receiver object's vtable. 8.137 + intptr_t vmindex = java_lang_invoke_MemberName::vmindex(vmentry); 8.138 + Method* target = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry); 8.139 + int numArgs = target->size_of_parameters(); 8.140 + oop recv = STACK_OBJECT(-numArgs); 8.141 + Klass* clazz = recv->klass(); 8.142 + Klass* klass_part = InstanceKlass::cast(clazz); 8.143 + klassVtable* vtable = klass_part->vtable(); 8.144 + Method* vmtarget = vtable->method_at(vmindex); 8.145 + 8.146 + invoke_target(vmtarget, THREAD); 8.147 + 8.148 + return 0; 8.149 +} 8.150 + 8.151 +int MethodHandles::method_handle_entry_invalid(Method* method, intptr_t UNUSED, TRAPS) { 8.152 + ShouldNotReachHere(); 8.153 + return 0; 8.154 +} 8.155 + 8.156 +address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* masm, 8.157 + vmIntrinsics::ID iid) { 8.158 + switch (iid) { 8.159 + case vmIntrinsics::_invokeGeneric: 8.160 + case vmIntrinsics::_compiledLambdaForm: 8.161 + // Perhaps surprisingly, the symbolic references visible to Java are not directly used. 8.162 + // They are linked to Java-generated adapters via MethodHandleNatives.linkMethod. 8.163 + // They all allow an appendix argument. 8.164 + return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invalid); 8.165 + case vmIntrinsics::_invokeBasic: 8.166 + return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invokeBasic); 8.167 + case vmIntrinsics::_linkToStatic: 8.168 + case vmIntrinsics::_linkToSpecial: 8.169 + return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToStaticOrSpecial); 8.170 + case vmIntrinsics::_linkToInterface: 8.171 + return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToInterface); 8.172 + case vmIntrinsics::_linkToVirtual: 8.173 + return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToVirtual); 8.174 + default: 8.175 + ShouldNotReachHere(); 8.176 + return NULL; 8.177 + } 8.178 +}
9.1 --- a/src/cpu/zero/vm/methodHandles_zero.hpp Fri Oct 26 14:18:57 2012 -0700 9.2 +++ b/src/cpu/zero/vm/methodHandles_zero.hpp Mon Oct 29 11:08:48 2012 -0700 9.3 @@ -26,6 +26,14 @@ 9.4 9.5 // Adapters 9.6 enum /* platform_dependent_constants */ { 9.7 - adapter_code_size = 0 9.8 + adapter_code_size = sizeof(ZeroEntry) * (Interpreter::method_handle_invoke_LAST - Interpreter::method_handle_invoke_FIRST + 1) 9.9 }; 9.10 9.11 +private: 9.12 + static oop popFromStack(TRAPS); 9.13 + static void invoke_target(Method* method, TRAPS); 9.14 + static int method_handle_entry_invokeBasic(Method* method, intptr_t UNUSED, TRAPS); 9.15 + static int method_handle_entry_linkToStaticOrSpecial(Method* method, intptr_t UNUSED, TRAPS); 9.16 + static int method_handle_entry_linkToVirtual(Method* method, intptr_t UNUSED, TRAPS); 9.17 + static int method_handle_entry_linkToInterface(Method* method, intptr_t UNUSED, TRAPS); 9.18 + static int method_handle_entry_invalid(Method* method, intptr_t UNUSED, TRAPS);
10.1 --- a/src/cpu/zero/vm/register_zero.hpp Fri Oct 26 14:18:57 2012 -0700 10.2 +++ b/src/cpu/zero/vm/register_zero.hpp Mon Oct 29 11:08:48 2012 -0700 10.3 @@ -114,5 +114,8 @@ 10.4 }; 10.5 10.6 CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1)); 10.7 +#ifndef DONT_USE_REGISTER_DEFINES 10.8 +#define noreg ((Register)(noreg_RegisterEnumValue)) 10.9 +#endif 10.10 10.11 #endif // CPU_ZERO_VM_REGISTER_ZERO_HPP
11.1 --- a/src/cpu/zero/vm/relocInfo_zero.cpp Fri Oct 26 14:18:57 2012 -0700 11.2 +++ b/src/cpu/zero/vm/relocInfo_zero.cpp Mon Oct 29 11:08:48 2012 -0700 11.3 @@ -77,3 +77,7 @@ 11.4 CodeBuffer* dst) { 11.5 ShouldNotCallThis(); 11.6 } 11.7 + 11.8 +void metadata_Relocation::pd_fix_value(address x) { 11.9 + ShouldNotCallThis(); 11.10 +}
12.1 --- a/src/cpu/zero/vm/sharedRuntime_zero.cpp Fri Oct 26 14:18:57 2012 -0700 12.2 +++ b/src/cpu/zero/vm/sharedRuntime_zero.cpp Mon Oct 29 11:08:48 2012 -0700 12.3 @@ -35,6 +35,7 @@ 12.4 #include "runtime/sharedRuntime.hpp" 12.5 #include "runtime/vframeArray.hpp" 12.6 #include "vmreg_zero.inline.hpp" 12.7 + 12.8 #ifdef COMPILER1 12.9 #include "c1/c1_Runtime1.hpp" 12.10 #endif 12.11 @@ -47,6 +48,12 @@ 12.12 #endif 12.13 12.14 12.15 + 12.16 +static address zero_null_code_stub() { 12.17 + address start = ShouldNotCallThisStub(); 12.18 + return start; 12.19 +} 12.20 + 12.21 int SharedRuntime::java_calling_convention(const BasicType *sig_bt, 12.22 VMRegPair *regs, 12.23 int total_args_passed, 12.24 @@ -63,16 +70,14 @@ 12.25 AdapterFingerPrint *fingerprint) { 12.26 return AdapterHandlerLibrary::new_entry( 12.27 fingerprint, 12.28 - ShouldNotCallThisStub(), 12.29 - ShouldNotCallThisStub(), 12.30 - ShouldNotCallThisStub()); 12.31 + CAST_FROM_FN_PTR(address,zero_null_code_stub), 12.32 + CAST_FROM_FN_PTR(address,zero_null_code_stub), 12.33 + CAST_FROM_FN_PTR(address,zero_null_code_stub)); 12.34 } 12.35 12.36 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, 12.37 methodHandle method, 12.38 int compile_id, 12.39 - int total_args_passed, 12.40 - int max_arg, 12.41 BasicType *sig_bt, 12.42 VMRegPair *regs, 12.43 BasicType ret_type) { 12.44 @@ -96,19 +101,20 @@ 12.45 ShouldNotCallThis(); 12.46 } 12.47 12.48 +JRT_LEAF(void, zero_stub()) 12.49 + ShouldNotCallThis(); 12.50 +JRT_END 12.51 + 12.52 static RuntimeStub* generate_empty_runtime_stub(const char* name) { 12.53 - CodeBuffer buffer(name, 0, 0); 12.54 - return RuntimeStub::new_runtime_stub(name, &buffer, 0, 0, NULL, false); 12.55 + return CAST_FROM_FN_PTR(RuntimeStub*,zero_stub); 12.56 } 12.57 12.58 static SafepointBlob* generate_empty_safepoint_blob() { 12.59 - CodeBuffer buffer("handler_blob", 0, 0); 12.60 - return SafepointBlob::create(&buffer, NULL, 0); 12.61 + return CAST_FROM_FN_PTR(SafepointBlob*,zero_stub); 12.62 } 12.63 12.64 static DeoptimizationBlob* generate_empty_deopt_blob() { 12.65 - CodeBuffer buffer("handler_blob", 0, 0); 12.66 - return DeoptimizationBlob::create(&buffer, NULL, 0, 0, 0, 0); 12.67 + return CAST_FROM_FN_PTR(DeoptimizationBlob*,zero_stub); 12.68 } 12.69 12.70 12.71 @@ -116,7 +122,7 @@ 12.72 _deopt_blob = generate_empty_deopt_blob(); 12.73 } 12.74 12.75 -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, bool cause_return) { 12.76 +SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { 12.77 return generate_empty_safepoint_blob(); 12.78 } 12.79 12.80 @@ -124,6 +130,7 @@ 12.81 return generate_empty_runtime_stub("resolve_blob"); 12.82 } 12.83 12.84 + 12.85 int SharedRuntime::c_calling_convention(const BasicType *sig_bt, 12.86 VMRegPair *regs, 12.87 int total_args_passed) {
13.1 --- a/src/share/vm/asm/codeBuffer.cpp Fri Oct 26 14:18:57 2012 -0700 13.2 +++ b/src/share/vm/asm/codeBuffer.cpp Mon Oct 29 11:08:48 2012 -0700 13.3 @@ -758,7 +758,7 @@ 13.4 } 13.5 } 13.6 13.7 - if (dest->blob() == NULL) { 13.8 + if (dest->blob() == NULL && dest_filled != NULL) { 13.9 // Destination is a final resting place, not just another buffer. 13.10 // Normalize uninitialized bytes in the final padding. 13.11 Copy::fill_to_bytes(dest_filled, dest_end - dest_filled,
14.1 --- a/src/share/vm/interpreter/abstractInterpreter.hpp Fri Oct 26 14:18:57 2012 -0700 14.2 +++ b/src/share/vm/interpreter/abstractInterpreter.hpp Mon Oct 29 11:08:48 2012 -0700 14.3 @@ -320,6 +320,7 @@ 14.4 void bang_stack_shadow_pages(bool native_call); 14.5 14.6 void generate_all(); 14.7 + void initialize_method_handle_entries(); 14.8 14.9 public: 14.10 AbstractInterpreterGenerator(StubQueue* _code);
15.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.cpp Fri Oct 26 14:18:57 2012 -0700 15.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp Mon Oct 29 11:08:48 2012 -0700 15.3 @@ -235,10 +235,6 @@ 15.4 #endif 15.5 #endif 15.6 15.7 -// JavaStack Implementation 15.8 -#define MORE_STACK(count) \ 15.9 - (topOfStack -= ((count) * Interpreter::stackElementWords)) 15.10 - 15.11 15.12 #define UPDATE_PC(opsize) {pc += opsize; } 15.13 /* 15.14 @@ -575,7 +571,7 @@ 15.15 15.16 /* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, 15.17 /* 0xE4 */ &&opc_default, &&opc_fast_aldc, &&opc_fast_aldc_w, &&opc_return_register_finalizer, 15.18 -/* 0xE8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, 15.19 +/* 0xE8 */ &&opc_invokehandle,&&opc_default, &&opc_default, &&opc_default, 15.20 /* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, 15.21 15.22 /* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, 15.23 @@ -1773,7 +1769,7 @@ 15.24 15.25 oop obj; 15.26 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { 15.27 - Klass* k = (Klass*) cache->f1(); 15.28 + Klass* k = cache->f1_as_klass(); 15.29 obj = k->java_mirror(); 15.30 MORE_STACK(1); // Assume single slot push 15.31 } else { 15.32 @@ -1885,7 +1881,7 @@ 15.33 --count; 15.34 } 15.35 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { 15.36 - Klass* k = (Klass*) cache->f1(); 15.37 + Klass* k = cache->f1_as_klass(); 15.38 obj = k->java_mirror(); 15.39 } else { 15.40 --count; 15.41 @@ -2190,6 +2186,7 @@ 15.42 } 15.43 15.44 CASE(_invokedynamic): { 15.45 + 15.46 if (!EnableInvokeDynamic) { 15.47 // We should not encounter this bytecode if !EnableInvokeDynamic. 15.48 // The verifier will stop it. However, if we get past the verifier, 15.49 @@ -2199,30 +2196,68 @@ 15.50 ShouldNotReachHere(); 15.51 } 15.52 15.53 - int index = Bytes::get_native_u4(pc+1); 15.54 + u4 index = Bytes::get_native_u4(pc+1); 15.55 + ConstantPoolCacheEntry* cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index); 15.56 15.57 // We are resolved if the resolved_references field contains a non-null object (CallSite, etc.) 15.58 // This kind of CP cache entry does not need to match the flags byte, because 15.59 // there is a 1-1 relation between bytecode type and CP entry type. 15.60 - ConstantPool* constants = METHOD->constants(); 15.61 - oop result = constants->resolved_references()->obj_at(index); 15.62 - if (result == NULL) { 15.63 + if (! cache->is_resolved((Bytecodes::Code) opcode)) { 15.64 CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD), 15.65 handle_exception); 15.66 - result = THREAD->vm_result(); 15.67 + cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index); 15.68 } 15.69 15.70 - VERIFY_OOP(result); 15.71 - oop method_handle = java_lang_invoke_CallSite::target(result); 15.72 - CHECK_NULL(method_handle); 15.73 - 15.74 - istate->set_msg(call_method_handle); 15.75 - istate->set_callee((Method*) method_handle); 15.76 + Method* method = cache->f1_as_method(); 15.77 + VERIFY_OOP(method); 15.78 + 15.79 + if (cache->has_appendix()) { 15.80 + ConstantPool* constants = METHOD->constants(); 15.81 + SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0); 15.82 + MORE_STACK(1); 15.83 + } 15.84 + 15.85 + istate->set_msg(call_method); 15.86 + istate->set_callee(method); 15.87 + istate->set_callee_entry_point(method->from_interpreted_entry()); 15.88 istate->set_bcp_advance(5); 15.89 15.90 UPDATE_PC_AND_RETURN(0); // I'll be back... 15.91 } 15.92 15.93 + CASE(_invokehandle): { 15.94 + 15.95 + if (!EnableInvokeDynamic) { 15.96 + ShouldNotReachHere(); 15.97 + } 15.98 + 15.99 + u2 index = Bytes::get_native_u2(pc+1); 15.100 + ConstantPoolCacheEntry* cache = cp->entry_at(index); 15.101 + 15.102 + if (! cache->is_resolved((Bytecodes::Code) opcode)) { 15.103 + CALL_VM(InterpreterRuntime::resolve_invokehandle(THREAD), 15.104 + handle_exception); 15.105 + cache = cp->entry_at(index); 15.106 + } 15.107 + 15.108 + Method* method = cache->f1_as_method(); 15.109 + 15.110 + VERIFY_OOP(method); 15.111 + 15.112 + if (cache->has_appendix()) { 15.113 + ConstantPool* constants = METHOD->constants(); 15.114 + SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0); 15.115 + MORE_STACK(1); 15.116 + } 15.117 + 15.118 + istate->set_msg(call_method); 15.119 + istate->set_callee(method); 15.120 + istate->set_callee_entry_point(method->from_interpreted_entry()); 15.121 + istate->set_bcp_advance(3); 15.122 + 15.123 + UPDATE_PC_AND_RETURN(0); // I'll be back... 15.124 + } 15.125 + 15.126 CASE(_invokeinterface): { 15.127 u2 index = Bytes::get_native_u2(pc+1); 15.128
16.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.hpp Fri Oct 26 14:18:57 2012 -0700 16.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.hpp Mon Oct 29 11:08:48 2012 -0700 16.3 @@ -50,6 +50,10 @@ 16.4 16.5 #ifdef CC_INTERP 16.6 16.7 +// JavaStack Implementation 16.8 +#define MORE_STACK(count) \ 16.9 + (topOfStack -= ((count) * Interpreter::stackElementWords)) 16.10 + 16.11 // CVM definitions find hotspot equivalents... 16.12 16.13 union VMJavaVal64 { 16.14 @@ -107,7 +111,6 @@ 16.15 rethrow_exception, // unwinding and throwing exception 16.16 // requests to frame manager from C++ interpreter 16.17 call_method, // request for new frame from interpreter, manager responds with method_entry 16.18 - call_method_handle, // like the above, except the callee is a method handle 16.19 return_from_method, // request from interpreter to unwind, manager responds with method_continue 16.20 more_monitors, // need a new monitor 16.21 throwing_exception, // unwind stack and rethrow
17.1 --- a/src/share/vm/interpreter/cppInterpreter.cpp Fri Oct 26 14:18:57 2012 -0700 17.2 +++ b/src/share/vm/interpreter/cppInterpreter.cpp Mon Oct 29 11:08:48 2012 -0700 17.3 @@ -117,7 +117,6 @@ 17.4 method_entry(empty); 17.5 method_entry(accessor); 17.6 method_entry(abstract); 17.7 - method_entry(method_handle); 17.8 method_entry(java_lang_math_sin ); 17.9 method_entry(java_lang_math_cos ); 17.10 method_entry(java_lang_math_tan ); 17.11 @@ -125,7 +124,12 @@ 17.12 method_entry(java_lang_math_sqrt ); 17.13 method_entry(java_lang_math_log ); 17.14 method_entry(java_lang_math_log10 ); 17.15 + method_entry(java_lang_math_pow ); 17.16 + method_entry(java_lang_math_exp ); 17.17 method_entry(java_lang_ref_reference_get); 17.18 + 17.19 + initialize_method_handle_entries(); 17.20 + 17.21 Interpreter::_native_entry_begin = Interpreter::code()->code_end(); 17.22 method_entry(native); 17.23 method_entry(native_synchronized);
18.1 --- a/src/share/vm/interpreter/interpreter.cpp Fri Oct 26 14:18:57 2012 -0700 18.2 +++ b/src/share/vm/interpreter/interpreter.cpp Mon Oct 29 11:08:48 2012 -0700 18.3 @@ -464,3 +464,11 @@ 18.4 } 18.5 } 18.6 } 18.7 + 18.8 +void AbstractInterpreterGenerator::initialize_method_handle_entries() { 18.9 + // method handle entry kinds are generated later in MethodHandlesAdapterGenerator::generate: 18.10 + for (int i = Interpreter::method_handle_invoke_FIRST; i <= Interpreter::method_handle_invoke_LAST; i++) { 18.11 + Interpreter::MethodKind kind = (Interpreter::MethodKind) i; 18.12 + Interpreter::_entry_table[kind] = Interpreter::_entry_table[Interpreter::abstract]; 18.13 + } 18.14 +}
19.1 --- a/src/share/vm/interpreter/templateInterpreter.cpp Fri Oct 26 14:18:57 2012 -0700 19.2 +++ b/src/share/vm/interpreter/templateInterpreter.cpp Mon Oct 29 11:08:48 2012 -0700 19.3 @@ -373,11 +373,7 @@ 19.4 method_entry(java_lang_math_pow ) 19.5 method_entry(java_lang_ref_reference_get) 19.6 19.7 - // method handle entry kinds are generated later in MethodHandlesAdapterGenerator::generate: 19.8 - for (int i = Interpreter::method_handle_invoke_FIRST; i <= Interpreter::method_handle_invoke_LAST; i++) { 19.9 - Interpreter::MethodKind kind = (Interpreter::MethodKind) i; 19.10 - Interpreter::_entry_table[kind] = Interpreter::_entry_table[Interpreter::abstract]; 19.11 - } 19.12 + initialize_method_handle_entries(); 19.13 19.14 // all native method kinds (must be one contiguous block) 19.15 Interpreter::_native_entry_begin = Interpreter::code()->code_end();
20.1 --- a/src/share/vm/runtime/vmStructs.cpp Fri Oct 26 14:18:57 2012 -0700 20.2 +++ b/src/share/vm/runtime/vmStructs.cpp Mon Oct 29 11:08:48 2012 -0700 20.3 @@ -2474,7 +2474,7 @@ 20.4 /* frame */ \ 20.5 /**********************/ \ 20.6 \ 20.7 - X86_ONLY(declare_constant(frame::entry_frame_call_wrapper_offset)) \ 20.8 + NOT_ZERO(X86_ONLY(declare_constant(frame::entry_frame_call_wrapper_offset))) \ 20.9 declare_constant(frame::pc_return_offset) \ 20.10 \ 20.11 /*************/ \
21.1 --- a/src/share/vm/utilities/macros.hpp Fri Oct 26 14:18:57 2012 -0700 21.2 +++ b/src/share/vm/utilities/macros.hpp Mon Oct 29 11:08:48 2012 -0700 21.3 @@ -282,6 +282,22 @@ 21.4 #define NOT_WIN64(code) code 21.5 #endif 21.6 21.7 +#if defined(ZERO) 21.8 +#define ZERO_ONLY(code) code 21.9 +#define NOT_ZERO(code) 21.10 +#else 21.11 +#define ZERO_ONLY(code) 21.12 +#define NOT_ZERO(code) code 21.13 +#endif 21.14 + 21.15 +#if defined(SHARK) 21.16 +#define SHARK_ONLY(code) code 21.17 +#define NOT_SHARK(code) 21.18 +#else 21.19 +#define SHARK_ONLY(code) 21.20 +#define NOT_SHARK(code) code 21.21 +#endif 21.22 + 21.23 #if defined(IA32) || defined(AMD64) 21.24 #define X86 21.25 #define X86_ONLY(code) code