# HG changeset patch # User twisti # Date 1300437855 25200 # Node ID fc5ebbb2d1a8d4c75480995e289ac8ee45e89e68 # Parent d2134498fd3f54a856e1e0ad09699e058fa5259b# Parent 2074c95f707e645d231c27097b7845dc6b122104 Merge diff -r 2074c95f707e -r fc5ebbb2d1a8 src/cpu/sparc/vm/assembler_sparc.cpp --- a/src/cpu/sparc/vm/assembler_sparc.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/cpu/sparc/vm/assembler_sparc.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -3179,7 +3179,7 @@ Label& wrong_method_type) { assert_different_registers(mtype_reg, mh_reg, temp_reg); // compare method type against that of the receiver - RegisterOrConstant mhtype_offset = delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg); + RegisterOrConstant mhtype_offset = delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg); load_heap_oop(mh_reg, mhtype_offset, temp_reg); cmp(temp_reg, mtype_reg); br(Assembler::notEqual, false, Assembler::pn, wrong_method_type); @@ -3195,14 +3195,14 @@ Register temp_reg) { assert_different_registers(vmslots_reg, mh_reg, temp_reg); // load mh.type.form.vmslots - if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) { + if (java_lang_invoke_MethodHandle::vmslots_offset_in_bytes() != 0) { // hoist vmslots into every mh to avoid dependent load chain - ld( Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); + ld( Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); } else { Register temp2_reg = vmslots_reg; - load_heap_oop(Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)), temp2_reg); - load_heap_oop(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)), temp2_reg); - ld( Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); + load_heap_oop(Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)), temp2_reg); + load_heap_oop(Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)), temp2_reg); + ld( Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); } } @@ -3213,7 +3213,7 @@ // pick out the interpreted side of the handler // NOTE: vmentry is not an oop! - ld_ptr(mh_reg, delayed_value(java_dyn_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg); + ld_ptr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg); // off we go... ld_ptr(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes(), temp_reg); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/cpu/sparc/vm/cppInterpreter_sparc.cpp --- a/src/cpu/sparc/vm/cppInterpreter_sparc.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/cpu/sparc/vm/cppInterpreter_sparc.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1188,7 +1188,7 @@ __ st_ptr(O2, XXX_STATE(_stack)); // PREPUSH __ lduh(max_stack, O3); // Full size expression stack - guarantee(!EnableMethodHandles, "no support yet for java.dyn.MethodHandle"); //6815692 + guarantee(!EnableMethodHandles, "no support yet for java.lang.invoke.MethodHandle"); //6815692 //6815692//if (EnableMethodHandles) //6815692// __ inc(O3, methodOopDesc::extra_stack_entries()); __ sll(O3, LogBytesPerWord, O3); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/cpu/sparc/vm/interpreter_sparc.cpp --- a/src/cpu/sparc/vm/interpreter_sparc.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/cpu/sparc/vm/interpreter_sparc.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -260,7 +260,7 @@ // Method handle invoker -// Dispatch a method of the form java.dyn.MethodHandles::invoke(...) +// Dispatch a method of the form java.lang.invoke.MethodHandles::invoke(...) address InterpreterGenerator::generate_method_handle_entry(void) { if (!EnableMethodHandles) { return generate_abstract_entry(); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/cpu/sparc/vm/methodHandles_sparc.cpp --- a/src/cpu/sparc/vm/methodHandles_sparc.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/cpu/sparc/vm/methodHandles_sparc.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -112,8 +112,8 @@ } // given the MethodType, find out where the MH argument is buried - __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)), O4_argslot); - __ ldsw( Address(O4_argslot, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O4_argslot); + __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, O1_scratch)), O4_argslot); + __ ldsw( Address(O4_argslot, __ delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O4_argslot); __ add(Gargs, __ argument_offset(O4_argslot, 1), O4_argbase); // Note: argument_address uses its input as a scratch register! __ ld_ptr(Address(O4_argbase, -Interpreter::stackElementSize), G3_method_handle); @@ -141,10 +141,10 @@ // load up an adapter from the calling type (Java weaves this) Register O2_form = O2_scratch; Register O3_adapter = O3_scratch; - __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)), O2_form); - // load_heap_oop(Address(O2_form, __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter); + __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, O1_scratch)), O2_form); + // load_heap_oop(Address(O2_form, __ delayed_value(java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter); // deal with old JDK versions: - __ add( Address(O2_form, __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter); + __ add( Address(O2_form, __ delayed_value(java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter); __ cmp(O3_adapter, O2_form); Label sorry_no_invoke_generic; __ brx(Assembler::lessUnsigned, false, Assembler::pn, sorry_no_invoke_generic); @@ -376,16 +376,16 @@ // which conversion op types are implemented here? int MethodHandles::adapter_conversion_ops_supported_mask() { - return ((1<obj(), x->offset(), x->field(), value, x->is_static(), - x->state_before(), x->is_loaded(), x->is_initialized())); + x->state_before(), x->needs_patching())); return; } } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/c1/c1_GraphBuilder.cpp --- a/src/share/vm/c1/c1_GraphBuilder.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1456,12 +1456,12 @@ BasicType field_type = field->type()->basic_type(); ValueType* type = as_ValueType(field_type); // call will_link again to determine if the field is valid. - const bool is_loaded = holder->is_loaded() && - field->will_link(method()->holder(), code); - const bool is_initialized = is_loaded && holder->is_initialized(); + const bool needs_patching = !holder->is_loaded() || + !field->will_link(method()->holder(), code) || + PatchALot; ValueStack* state_before = NULL; - if (!is_initialized || PatchALot) { + if (!holder->is_initialized() || needs_patching) { // save state before instruction for debug info when // deoptimization happens during patching state_before = copy_state_before(); @@ -1469,10 +1469,6 @@ Value obj = NULL; if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) { - // commoning of class constants should only occur if the class is - // fully initialized and resolved in this constant pool. The will_link test - // above essentially checks if this class is resolved in this constant pool - // so, the is_initialized flag should be suffiect. if (state_before != NULL) { // build a patching constant obj = new Constant(new ClassConstant(holder), state_before); @@ -1482,7 +1478,7 @@ } - const int offset = is_loaded ? field->offset() : -1; + const int offset = !needs_patching ? field->offset() : -1; switch (code) { case Bytecodes::_getstatic: { // check for compile-time constants, i.e., initialized static final fields @@ -1509,7 +1505,7 @@ state_before = copy_state_for_exception(); } push(type, append(new LoadField(append(obj), offset, field, true, - state_before, is_loaded, is_initialized))); + state_before, needs_patching))); } break; } @@ -1518,7 +1514,7 @@ if (state_before == NULL) { state_before = copy_state_for_exception(); } - append(new StoreField(append(obj), offset, field, val, true, state_before, is_loaded, is_initialized)); + append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching)); } break; case Bytecodes::_getfield : @@ -1526,8 +1522,8 @@ if (state_before == NULL) { state_before = copy_state_for_exception(); } - LoadField* load = new LoadField(apop(), offset, field, false, state_before, is_loaded, true); - Value replacement = is_loaded ? _memory->load(load) : load; + LoadField* load = new LoadField(apop(), offset, field, false, state_before, needs_patching); + Value replacement = !needs_patching ? _memory->load(load) : load; if (replacement != load) { assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked"); push(type, replacement); @@ -1542,8 +1538,8 @@ if (state_before == NULL) { state_before = copy_state_for_exception(); } - StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, is_loaded, true); - if (is_loaded) store = _memory->store(store); + StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, needs_patching); + if (!needs_patching) store = _memory->store(store); if (store != NULL) { append(store); } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/c1/c1_Instruction.hpp --- a/src/share/vm/c1/c1_Instruction.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/c1/c1_Instruction.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -323,8 +323,6 @@ CanTrapFlag, DirectCompareFlag, IsEliminatedFlag, - IsInitializedFlag, - IsLoadedFlag, IsSafepointFlag, IsStaticFlag, IsStrictfpFlag, @@ -693,7 +691,7 @@ public: // creation AccessField(Value obj, int offset, ciField* field, bool is_static, - ValueStack* state_before, bool is_loaded, bool is_initialized) + ValueStack* state_before, bool needs_patching) : Instruction(as_ValueType(field->type()->basic_type()), state_before) , _obj(obj) , _offset(offset) @@ -701,16 +699,9 @@ , _explicit_null_check(NULL) { set_needs_null_check(!is_static); - set_flag(IsLoadedFlag, is_loaded); - set_flag(IsInitializedFlag, is_initialized); set_flag(IsStaticFlag, is_static); + set_flag(NeedsPatchingFlag, needs_patching); ASSERT_VALUES - if (!is_loaded || (PatchALot && !field->is_volatile())) { - // need to patch if the holder wasn't loaded or we're testing - // using PatchALot. Don't allow PatchALot for fields which are - // known to be volatile they aren't patchable. - set_flag(NeedsPatchingFlag, true); - } // pin of all instructions with memory access pin(); } @@ -721,11 +712,14 @@ ciField* field() const { return _field; } BasicType field_type() const { return _field->type()->basic_type(); } bool is_static() const { return check_flag(IsStaticFlag); } - bool is_loaded() const { return check_flag(IsLoadedFlag); } - bool is_initialized() const { return check_flag(IsInitializedFlag); } NullCheck* explicit_null_check() const { return _explicit_null_check; } bool needs_patching() const { return check_flag(NeedsPatchingFlag); } + // Unresolved getstatic and putstatic can cause initialization. + // Technically it occurs at the Constant that materializes the base + // of the static fields but it's simpler to model it here. + bool is_init_point() const { return is_static() && (needs_patching() || !_field->holder()->is_initialized()); } + // manipulation // Under certain circumstances, if a previous NullCheck instruction @@ -745,15 +739,15 @@ public: // creation LoadField(Value obj, int offset, ciField* field, bool is_static, - ValueStack* state_before, bool is_loaded, bool is_initialized) - : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized) + ValueStack* state_before, bool needs_patching) + : AccessField(obj, offset, field, is_static, state_before, needs_patching) {} ciType* declared_type() const; ciType* exact_type() const; // generic - HASHING2(LoadField, is_loaded() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if not yet loaded or if volatile + HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if needs patching or if volatile }; @@ -764,8 +758,8 @@ public: // creation StoreField(Value obj, int offset, ciField* field, Value value, bool is_static, - ValueStack* state_before, bool is_loaded, bool is_initialized) - : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized) + ValueStack* state_before, bool needs_patching) + : AccessField(obj, offset, field, is_static, state_before, needs_patching) , _value(value) { set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object()); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/c1/c1_LIR.hpp --- a/src/share/vm/c1/c1_LIR.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/c1/c1_LIR.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1156,7 +1156,7 @@ return is_invokedynamic() // An invokedynamic is always a MethodHandle call site. || - (method()->holder()->name() == ciSymbol::java_dyn_MethodHandle() && + (method()->holder()->name() == ciSymbol::java_lang_invoke_MethodHandle() && methodOopDesc::is_method_handle_invoke_name(method()->name()->sid())); } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/c1/c1_LIRGenerator.cpp --- a/src/share/vm/c1/c1_LIRGenerator.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1559,9 +1559,7 @@ (info ? new CodeEmitInfo(info) : NULL)); } - if (is_volatile) { - assert(!needs_patching && x->is_loaded(), - "how do we know it's volatile if it's not loaded"); + if (is_volatile && !needs_patching) { volatile_field_store(value.result(), address, info); } else { LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none; @@ -1627,9 +1625,7 @@ address = generate_address(object.result(), x->offset(), field_type); } - if (is_volatile) { - assert(!needs_patching && x->is_loaded(), - "how do we know it's volatile if it's not loaded"); + if (is_volatile && !needs_patching) { volatile_field_load(address, reg, info); } else { LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none; @@ -2516,7 +2512,7 @@ __ load(new LIR_Address(tmp, call_site_offset, T_OBJECT), tmp); // Load target MethodHandle from CallSite object. - __ load(new LIR_Address(tmp, java_dyn_CallSite::target_offset_in_bytes(), T_OBJECT), receiver); + __ load(new LIR_Address(tmp, java_lang_invoke_CallSite::target_offset_in_bytes(), T_OBJECT), receiver); __ call_dynamic(target, receiver, result_register, SharedRuntime::get_resolve_opt_virtual_call_stub(), diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/c1/c1_ValueMap.hpp --- a/src/share/vm/c1/c1_ValueMap.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/c1/c1_ValueMap.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -141,7 +141,8 @@ // visitor functions void do_StoreField (StoreField* x) { - if (!x->is_initialized()) { + if (x->is_init_point()) { + // putstatic is an initialization point so treat it as a wide kill kill_memory(); } else { kill_field(x->field()); @@ -159,7 +160,8 @@ void do_Local (Local* x) { /* nothing to do */ } void do_Constant (Constant* x) { /* nothing to do */ } void do_LoadField (LoadField* x) { - if (!x->is_initialized()) { + if (x->is_init_point()) { + // getstatic is an initialization point so treat it as a wide kill kill_memory(); } } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciCallSite.cpp --- a/src/share/vm/ci/ciCallSite.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciCallSite.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ // Return the target MethodHandle of this CallSite. ciMethodHandle* ciCallSite::get_target() const { VM_ENTRY_MARK; - oop method_handle_oop = java_dyn_CallSite::target(get_oop()); + oop method_handle_oop = java_lang_invoke_CallSite::target(get_oop()); return CURRENT_ENV->get_object(method_handle_oop)->as_method_handle(); } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciCallSite.hpp --- a/src/share/vm/ci/ciCallSite.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciCallSite.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ // ciCallSite // -// The class represents a java.dyn.CallSite object. +// The class represents a java.lang.invoke.CallSite object. class ciCallSite : public ciInstance { public: ciCallSite(instanceHandle h_i) : ciInstance(h_i) {} diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciField.cpp --- a/src/share/vm/ci/ciField.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciField.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -177,7 +177,7 @@ // Never trust strangely unstable finals: System.out, etc. return false; // Even if general trusting is disabled, trust system-built closures in these packages. - if (holder->is_in_package("java/dyn") || holder->is_in_package("sun/dyn")) + if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) return true; return TrustFinalNonStaticFields; } @@ -191,8 +191,9 @@ // Check to see if the field is constant. if (_holder->is_initialized() && this->is_final()) { if (!this->is_static()) { - // A field can be constant if it's a final static field or if it's - // a final non-static field of a trusted class ({java,sun}.dyn). + // A field can be constant if it's a final static field or if + // it's a final non-static field of a trusted class (classes in + // java.lang.invoke and sun.invoke packages and subpackages). if (trust_final_non_static_fields(_holder)) { _is_constant = true; return; diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciMethod.cpp --- a/src/share/vm/ci/ciMethod.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciMethod.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -769,7 +769,7 @@ // signature-polymorphic MethodHandle methods, invokeExact or invokeGeneric. bool ciMethod::is_method_handle_invoke() const { if (!is_loaded()) { - bool flag = (holder()->name() == ciSymbol::java_dyn_MethodHandle() && + bool flag = (holder()->name() == ciSymbol::java_lang_invoke_MethodHandle() && methodOopDesc::is_method_handle_invoke_name(name()->sid())); return flag; } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciMethodHandle.hpp --- a/src/share/vm/ci/ciMethodHandle.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciMethodHandle.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ // ciMethodHandle // -// The class represents a java.dyn.MethodHandle object. +// The class represents a java.lang.invoke.MethodHandle object. class ciMethodHandle : public ciInstance { private: ciMethod* _callee; diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciObjectFactory.cpp --- a/src/share/vm/ci/ciObjectFactory.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciObjectFactory.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -342,9 +342,9 @@ return new (arena()) ciMethodData(h_md); } else if (o->is_instance()) { instanceHandle h_i(THREAD, (instanceOop)o); - if (java_dyn_CallSite::is_instance(o)) + if (java_lang_invoke_CallSite::is_instance(o)) return new (arena()) ciCallSite(h_i); - else if (java_dyn_MethodHandle::is_instance(o)) + else if (java_lang_invoke_MethodHandle::is_instance(o)) return new (arena()) ciMethodHandle(h_i); else return new (arena()) ciInstance(h_i); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/ci/ciStreams.cpp --- a/src/share/vm/ci/ciStreams.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/ci/ciStreams.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -380,7 +380,7 @@ bool ignore; // report as InvokeDynamic for invokedynamic, which is syntactically classless if (cur_bc() == Bytecodes::_invokedynamic) - return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_dyn_InvokeDynamic(), false); + return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_lang_invoke_InvokeDynamic(), false); return CURRENT_ENV->get_klass_by_index(cpool, get_method_holder_index(), ignore, _holder); } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/classFileParser.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,12 +146,14 @@ break; case JVM_CONSTANT_MethodHandle : case JVM_CONSTANT_MethodType : - if (!EnableMethodHandles || - _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { + if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { classfile_parse_error( - (!EnableMethodHandles ? - "This JVM does not support constant tag %u in class file %s" : - "Class file version does not support constant tag %u in class file %s"), + "Class file version does not support constant tag %u in class file %s", + tag, CHECK); + } + if (!EnableMethodHandles) { + classfile_parse_error( + "This JVM does not support constant tag %u in class file %s", tag, CHECK); } if (tag == JVM_CONSTANT_MethodHandle) { @@ -170,12 +172,14 @@ case JVM_CONSTANT_InvokeDynamicTrans : // this tag appears only in old classfiles case JVM_CONSTANT_InvokeDynamic : { - if (!EnableInvokeDynamic || - _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { + if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { classfile_parse_error( - (!EnableInvokeDynamic ? - "This JVM does not support constant tag %u in class file %s" : - "Class file version does not support constant tag %u in class file %s"), + "Class file version does not support constant tag %u in class file %s", + tag, CHECK); + } + if (!EnableInvokeDynamic) { + classfile_parse_error( + "This JVM does not support constant tag %u in class file %s", tag, CHECK); } cfs->guarantee_more(5, CHECK); // bsm_index, nt, tag/access_flags @@ -2802,11 +2806,11 @@ // Force MethodHandle.vmentry to be an unmanaged pointer. // There is no way for a classfile to express this, so we must help it. -void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp, +void ClassFileParser::java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp, typeArrayHandle fields, FieldAllocationCount *fac_ptr, TRAPS) { - // Add fake fields for java.dyn.MethodHandle instances + // Add fake fields for java.lang.invoke.MethodHandle instances // // This is not particularly nice, but since there is no way to express // a native wordSize field in Java, we must do it at this level. @@ -2823,9 +2827,10 @@ } } + if (AllowTransitionalJSR292 && word_sig_index == 0) return; if (word_sig_index == 0) THROW_MSG(vmSymbols::java_lang_VirtualMachineError(), - "missing I or J signature (for vmentry) in java.dyn.MethodHandle"); + "missing I or J signature (for vmentry) in java.lang.invoke.MethodHandle"); // Find vmentry field and change the signature. bool found_vmentry = false; @@ -2862,9 +2867,10 @@ } } + if (AllowTransitionalJSR292 && !found_vmentry) return; if (!found_vmentry) THROW_MSG(vmSymbols::java_lang_VirtualMachineError(), - "missing vmentry byte field in java.dyn.MethodHandle"); + "missing vmentry byte field in java.lang.invoke.MethodHandle"); } @@ -3229,9 +3235,18 @@ java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle)); } - // adjust the vmentry field declaration in java.dyn.MethodHandle - if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) { - java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); + // adjust the vmentry field declaration in java.lang.invoke.MethodHandle + if (EnableMethodHandles && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) { + java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); + } + if (AllowTransitionalJSR292 && + EnableMethodHandles && class_name == vmSymbols::java_dyn_MethodHandle() && class_loader.is_null()) { + java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); + } + if (AllowTransitionalJSR292 && + EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) { + // allow vmentry field in MethodHandleImpl also + java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); } // Add a fake "discovered" field if it is not present diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/classFileParser.hpp --- a/src/share/vm/classfile/classFileParser.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/classFileParser.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -162,9 +162,9 @@ // Adjust the next_nonstatic_oop_offset to place the fake fields // before any Java fields. void java_lang_Class_fix_post(int* next_nonstatic_oop_offset); - // Adjust the field allocation counts for java.dyn.MethodHandle to add + // Adjust the field allocation counts for java.lang.invoke.MethodHandle to add // a fake address (void*) field. - void java_dyn_MethodHandle_fix_pre(constantPoolHandle cp, + void java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp, typeArrayHandle fields, FieldAllocationCount *fac_ptr, TRAPS); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/javaClasses.cpp --- a/src/share/vm/classfile/javaClasses.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/javaClasses.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,6 +66,28 @@ return ik->find_local_field(name_symbol, signature_symbol, fd); } +static bool find_hacked_field(instanceKlass* ik, + Symbol* name_symbol, Symbol* signature_symbol, + fieldDescriptor* fd, + bool allow_super = false) { + bool found = find_field(ik, name_symbol, signature_symbol, fd, allow_super); + if (!found && AllowTransitionalJSR292) { + Symbol* backup_sig = SystemDictionary::find_backup_signature(signature_symbol); + if (backup_sig != NULL) { + found = find_field(ik, name_symbol, backup_sig, fd, allow_super); + if (TraceMethodHandles) { + ResourceMark rm; + tty->print_cr("MethodHandles: %s.%s: backup for %s => %s%s", + ik->name()->as_C_string(), name_symbol->as_C_string(), + signature_symbol->as_C_string(), backup_sig->as_C_string(), + (found ? "" : " (NOT FOUND)")); + } + } + } + return found; +} +#define find_field find_hacked_field /* remove after AllowTransitionalJSR292 */ + // Helpful routine for computing field offsets at run time rather than hardcoding them static void compute_offset(int &dest_offset, @@ -2176,41 +2198,43 @@ } -// Support for java_dyn_MethodHandle - -int java_dyn_MethodHandle::_type_offset; -int java_dyn_MethodHandle::_vmtarget_offset; -int java_dyn_MethodHandle::_vmentry_offset; -int java_dyn_MethodHandle::_vmslots_offset; - -int sun_dyn_MemberName::_clazz_offset; -int sun_dyn_MemberName::_name_offset; -int sun_dyn_MemberName::_type_offset; -int sun_dyn_MemberName::_flags_offset; -int sun_dyn_MemberName::_vmtarget_offset; -int sun_dyn_MemberName::_vmindex_offset; - -int sun_dyn_DirectMethodHandle::_vmindex_offset; - -int sun_dyn_BoundMethodHandle::_argument_offset; -int sun_dyn_BoundMethodHandle::_vmargslot_offset; - -int sun_dyn_AdapterMethodHandle::_conversion_offset; - -void java_dyn_MethodHandle::compute_offsets() { +// Support for java_lang_invoke_MethodHandle + +int java_lang_invoke_MethodHandle::_type_offset; +int java_lang_invoke_MethodHandle::_vmtarget_offset; +int java_lang_invoke_MethodHandle::_vmentry_offset; +int java_lang_invoke_MethodHandle::_vmslots_offset; + +int java_lang_invoke_MemberName::_clazz_offset; +int java_lang_invoke_MemberName::_name_offset; +int java_lang_invoke_MemberName::_type_offset; +int java_lang_invoke_MemberName::_flags_offset; +int java_lang_invoke_MemberName::_vmtarget_offset; +int java_lang_invoke_MemberName::_vmindex_offset; + +int java_lang_invoke_DirectMethodHandle::_vmindex_offset; + +int java_lang_invoke_BoundMethodHandle::_argument_offset; +int java_lang_invoke_BoundMethodHandle::_vmargslot_offset; + +int java_lang_invoke_AdapterMethodHandle::_conversion_offset; + +void java_lang_invoke_MethodHandle::compute_offsets() { klassOop k = SystemDictionary::MethodHandle_klass(); if (k != NULL && EnableMethodHandles) { - compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::java_dyn_MethodType_signature(), true); - compute_offset(_vmtarget_offset, k, vmSymbols::vmtarget_name(), vmSymbols::object_signature(), true); - compute_offset(_vmentry_offset, k, vmSymbols::vmentry_name(), vmSymbols::machine_word_signature(), true); + bool allow_super = false; + if (AllowTransitionalJSR292) allow_super = true; // temporary, to access java.dyn.MethodHandleImpl + compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::java_lang_invoke_MethodType_signature(), allow_super); + compute_offset(_vmtarget_offset, k, vmSymbols::vmtarget_name(), vmSymbols::object_signature(), allow_super); + compute_offset(_vmentry_offset, k, vmSymbols::vmentry_name(), vmSymbols::machine_word_signature(), allow_super); // Note: MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots. // It is optional pending experiments to keep or toss. - compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true); + compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), allow_super); } } -void sun_dyn_MemberName::compute_offsets() { +void java_lang_invoke_MemberName::compute_offsets() { klassOop k = SystemDictionary::MemberName_klass(); if (k != NULL && EnableMethodHandles) { compute_offset(_clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); @@ -2222,14 +2246,14 @@ } } -void sun_dyn_DirectMethodHandle::compute_offsets() { +void java_lang_invoke_DirectMethodHandle::compute_offsets() { klassOop k = SystemDictionary::DirectMethodHandle_klass(); if (k != NULL && EnableMethodHandles) { compute_offset(_vmindex_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature(), true); } } -void sun_dyn_BoundMethodHandle::compute_offsets() { +void java_lang_invoke_BoundMethodHandle::compute_offsets() { klassOop k = SystemDictionary::BoundMethodHandle_klass(); if (k != NULL && EnableMethodHandles) { compute_offset(_vmargslot_offset, k, vmSymbols::vmargslot_name(), vmSymbols::int_signature(), true); @@ -2237,22 +2261,22 @@ } } -void sun_dyn_AdapterMethodHandle::compute_offsets() { +void java_lang_invoke_AdapterMethodHandle::compute_offsets() { klassOop k = SystemDictionary::AdapterMethodHandle_klass(); if (k != NULL && EnableMethodHandles) { compute_offset(_conversion_offset, k, vmSymbols::conversion_name(), vmSymbols::int_signature(), true); } } -oop java_dyn_MethodHandle::type(oop mh) { +oop java_lang_invoke_MethodHandle::type(oop mh) { return mh->obj_field(_type_offset); } -void java_dyn_MethodHandle::set_type(oop mh, oop mtype) { +void java_lang_invoke_MethodHandle::set_type(oop mh, oop mtype) { mh->obj_field_put(_type_offset, mtype); } -int java_dyn_MethodHandle::vmslots(oop mh) { +int java_lang_invoke_MethodHandle::vmslots(oop mh) { int vmslots_offset = _vmslots_offset; if (vmslots_offset != 0) { #ifdef ASSERT @@ -2267,7 +2291,7 @@ } // if MH.vmslots exists, hoist into it the value of type.form.vmslots -void java_dyn_MethodHandle::init_vmslots(oop mh) { +void java_lang_invoke_MethodHandle::init_vmslots(oop mh) { int vmslots_offset = _vmslots_offset; if (vmslots_offset != 0) { mh->int_field_put(vmslots_offset, compute_vmslots(mh)); @@ -2276,20 +2300,20 @@ // fetch type.form.vmslots, which is the number of JVM stack slots // required to carry the arguments of this MH -int java_dyn_MethodHandle::compute_vmslots(oop mh) { +int java_lang_invoke_MethodHandle::compute_vmslots(oop mh) { oop mtype = type(mh); if (mtype == NULL) return 0; // Java code would get NPE - oop form = java_dyn_MethodType::form(mtype); + oop form = java_lang_invoke_MethodType::form(mtype); if (form == NULL) return 0; // Java code would get NPE - return java_dyn_MethodTypeForm::vmslots(form); + return java_lang_invoke_MethodTypeForm::vmslots(form); } // fetch the low-level entry point for this mh -MethodHandleEntry* java_dyn_MethodHandle::vmentry(oop mh) { +MethodHandleEntry* java_lang_invoke_MethodHandle::vmentry(oop mh) { return (MethodHandleEntry*) mh->address_field(_vmentry_offset); } -void java_dyn_MethodHandle::set_vmentry(oop mh, MethodHandleEntry* me) { +void java_lang_invoke_MethodHandle::set_vmentry(oop mh, MethodHandleEntry* me) { assert(_vmentry_offset != 0, "must be present"); // This is always the final step that initializes a valid method handle: @@ -2303,123 +2327,123 @@ /// MemberName accessors -oop sun_dyn_MemberName::clazz(oop mname) { +oop java_lang_invoke_MemberName::clazz(oop mname) { assert(is_instance(mname), "wrong type"); return mname->obj_field(_clazz_offset); } -void sun_dyn_MemberName::set_clazz(oop mname, oop clazz) { +void java_lang_invoke_MemberName::set_clazz(oop mname, oop clazz) { assert(is_instance(mname), "wrong type"); mname->obj_field_put(_clazz_offset, clazz); } -oop sun_dyn_MemberName::name(oop mname) { +oop java_lang_invoke_MemberName::name(oop mname) { assert(is_instance(mname), "wrong type"); return mname->obj_field(_name_offset); } -void sun_dyn_MemberName::set_name(oop mname, oop name) { +void java_lang_invoke_MemberName::set_name(oop mname, oop name) { assert(is_instance(mname), "wrong type"); mname->obj_field_put(_name_offset, name); } -oop sun_dyn_MemberName::type(oop mname) { +oop java_lang_invoke_MemberName::type(oop mname) { assert(is_instance(mname), "wrong type"); return mname->obj_field(_type_offset); } -void sun_dyn_MemberName::set_type(oop mname, oop type) { +void java_lang_invoke_MemberName::set_type(oop mname, oop type) { assert(is_instance(mname), "wrong type"); mname->obj_field_put(_type_offset, type); } -int sun_dyn_MemberName::flags(oop mname) { +int java_lang_invoke_MemberName::flags(oop mname) { assert(is_instance(mname), "wrong type"); return mname->int_field(_flags_offset); } -void sun_dyn_MemberName::set_flags(oop mname, int flags) { +void java_lang_invoke_MemberName::set_flags(oop mname, int flags) { assert(is_instance(mname), "wrong type"); mname->int_field_put(_flags_offset, flags); } -oop sun_dyn_MemberName::vmtarget(oop mname) { +oop java_lang_invoke_MemberName::vmtarget(oop mname) { assert(is_instance(mname), "wrong type"); return mname->obj_field(_vmtarget_offset); } -void sun_dyn_MemberName::set_vmtarget(oop mname, oop ref) { +void java_lang_invoke_MemberName::set_vmtarget(oop mname, oop ref) { assert(is_instance(mname), "wrong type"); mname->obj_field_put(_vmtarget_offset, ref); } -int sun_dyn_MemberName::vmindex(oop mname) { +int java_lang_invoke_MemberName::vmindex(oop mname) { assert(is_instance(mname), "wrong type"); return mname->int_field(_vmindex_offset); } -void sun_dyn_MemberName::set_vmindex(oop mname, int index) { +void java_lang_invoke_MemberName::set_vmindex(oop mname, int index) { assert(is_instance(mname), "wrong type"); mname->int_field_put(_vmindex_offset, index); } -oop java_dyn_MethodHandle::vmtarget(oop mh) { +oop java_lang_invoke_MethodHandle::vmtarget(oop mh) { assert(is_instance(mh), "MH only"); return mh->obj_field(_vmtarget_offset); } -void java_dyn_MethodHandle::set_vmtarget(oop mh, oop ref) { +void java_lang_invoke_MethodHandle::set_vmtarget(oop mh, oop ref) { assert(is_instance(mh), "MH only"); mh->obj_field_put(_vmtarget_offset, ref); } -int sun_dyn_DirectMethodHandle::vmindex(oop mh) { +int java_lang_invoke_DirectMethodHandle::vmindex(oop mh) { assert(is_instance(mh), "DMH only"); return mh->int_field(_vmindex_offset); } -void sun_dyn_DirectMethodHandle::set_vmindex(oop mh, int index) { +void java_lang_invoke_DirectMethodHandle::set_vmindex(oop mh, int index) { assert(is_instance(mh), "DMH only"); mh->int_field_put(_vmindex_offset, index); } -int sun_dyn_BoundMethodHandle::vmargslot(oop mh) { +int java_lang_invoke_BoundMethodHandle::vmargslot(oop mh) { assert(is_instance(mh), "BMH only"); return mh->int_field(_vmargslot_offset); } -oop sun_dyn_BoundMethodHandle::argument(oop mh) { +oop java_lang_invoke_BoundMethodHandle::argument(oop mh) { assert(is_instance(mh), "BMH only"); return mh->obj_field(_argument_offset); } -int sun_dyn_AdapterMethodHandle::conversion(oop mh) { +int java_lang_invoke_AdapterMethodHandle::conversion(oop mh) { assert(is_instance(mh), "AMH only"); return mh->int_field(_conversion_offset); } -void sun_dyn_AdapterMethodHandle::set_conversion(oop mh, int conv) { +void java_lang_invoke_AdapterMethodHandle::set_conversion(oop mh, int conv) { assert(is_instance(mh), "AMH only"); mh->int_field_put(_conversion_offset, conv); } -// Support for java_dyn_MethodType - -int java_dyn_MethodType::_rtype_offset; -int java_dyn_MethodType::_ptypes_offset; -int java_dyn_MethodType::_form_offset; - -void java_dyn_MethodType::compute_offsets() { +// Support for java_lang_invoke_MethodType + +int java_lang_invoke_MethodType::_rtype_offset; +int java_lang_invoke_MethodType::_ptypes_offset; +int java_lang_invoke_MethodType::_form_offset; + +void java_lang_invoke_MethodType::compute_offsets() { klassOop k = SystemDictionary::MethodType_klass(); if (k != NULL) { compute_offset(_rtype_offset, k, vmSymbols::rtype_name(), vmSymbols::class_signature()); compute_offset(_ptypes_offset, k, vmSymbols::ptypes_name(), vmSymbols::class_array_signature()); - compute_offset(_form_offset, k, vmSymbols::form_name(), vmSymbols::java_dyn_MethodTypeForm_signature()); + compute_offset(_form_offset, k, vmSymbols::form_name(), vmSymbols::java_lang_invoke_MethodTypeForm_signature()); } } -void java_dyn_MethodType::print_signature(oop mt, outputStream* st) { +void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) { st->print("("); objArrayOop pts = ptypes(mt); for (int i = 0, limit = pts->length(); i < limit; i++) { @@ -2429,7 +2453,7 @@ java_lang_Class::print_signature(rtype(mt), st); } -Symbol* java_dyn_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) { +Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) { ResourceMark rm; stringStream buffer(128); print_signature(mt, &buffer); @@ -2444,103 +2468,83 @@ return name; } -oop java_dyn_MethodType::rtype(oop mt) { +oop java_lang_invoke_MethodType::rtype(oop mt) { assert(is_instance(mt), "must be a MethodType"); return mt->obj_field(_rtype_offset); } -objArrayOop java_dyn_MethodType::ptypes(oop mt) { +objArrayOop java_lang_invoke_MethodType::ptypes(oop mt) { assert(is_instance(mt), "must be a MethodType"); return (objArrayOop) mt->obj_field(_ptypes_offset); } -oop java_dyn_MethodType::form(oop mt) { +oop java_lang_invoke_MethodType::form(oop mt) { assert(is_instance(mt), "must be a MethodType"); return mt->obj_field(_form_offset); } -oop java_dyn_MethodType::ptype(oop mt, int idx) { +oop java_lang_invoke_MethodType::ptype(oop mt, int idx) { return ptypes(mt)->obj_at(idx); } -int java_dyn_MethodType::ptype_count(oop mt) { +int java_lang_invoke_MethodType::ptype_count(oop mt) { return ptypes(mt)->length(); } -// Support for java_dyn_MethodTypeForm - -int java_dyn_MethodTypeForm::_vmslots_offset; -int java_dyn_MethodTypeForm::_erasedType_offset; -int java_dyn_MethodTypeForm::_genericInvoker_offset; - -void java_dyn_MethodTypeForm::compute_offsets() { +// Support for java_lang_invoke_MethodTypeForm + +int java_lang_invoke_MethodTypeForm::_vmslots_offset; +int java_lang_invoke_MethodTypeForm::_erasedType_offset; +int java_lang_invoke_MethodTypeForm::_genericInvoker_offset; + +void java_lang_invoke_MethodTypeForm::compute_offsets() { klassOop k = SystemDictionary::MethodTypeForm_klass(); if (k != NULL) { compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true); - compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_dyn_MethodType_signature(), true); - compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_dyn_MethodHandle_signature(), true); + compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_lang_invoke_MethodType_signature(), true); + compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_lang_invoke_MethodHandle_signature(), true); if (_genericInvoker_offset == 0) _genericInvoker_offset = -1; // set to explicit "empty" value } } -int java_dyn_MethodTypeForm::vmslots(oop mtform) { +int java_lang_invoke_MethodTypeForm::vmslots(oop mtform) { assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only"); return mtform->int_field(_vmslots_offset); } -oop java_dyn_MethodTypeForm::erasedType(oop mtform) { +oop java_lang_invoke_MethodTypeForm::erasedType(oop mtform) { assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only"); return mtform->obj_field(_erasedType_offset); } -oop java_dyn_MethodTypeForm::genericInvoker(oop mtform) { +oop java_lang_invoke_MethodTypeForm::genericInvoker(oop mtform) { assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only"); return mtform->obj_field(_genericInvoker_offset); } -// Support for java_dyn_CallSite - -int java_dyn_CallSite::_target_offset; -int java_dyn_CallSite::_caller_method_offset; -int java_dyn_CallSite::_caller_bci_offset; - -void java_dyn_CallSite::compute_offsets() { +// Support for java_lang_invoke_CallSite + +int java_lang_invoke_CallSite::_target_offset; + +void java_lang_invoke_CallSite::compute_offsets() { if (!EnableInvokeDynamic) return; klassOop k = SystemDictionary::CallSite_klass(); if (k != NULL) { - compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_dyn_MethodHandle_signature()); - compute_offset(_caller_method_offset, k, vmSymbols::vmmethod_name(), vmSymbols::sun_dyn_MemberName_signature()); - compute_offset(_caller_bci_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature()); + compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature()); } } -oop java_dyn_CallSite::target(oop site) { +oop java_lang_invoke_CallSite::target(oop site) { return site->obj_field(_target_offset); } -void java_dyn_CallSite::set_target(oop site, oop target) { +void java_lang_invoke_CallSite::set_target(oop site, oop target) { site->obj_field_put(_target_offset, target); } -oop java_dyn_CallSite::caller_method(oop site) { - return site->obj_field(_caller_method_offset); -} - -void java_dyn_CallSite::set_caller_method(oop site, oop ref) { - site->obj_field_put(_caller_method_offset, ref); -} - -jint java_dyn_CallSite::caller_bci(oop site) { - return site->int_field(_caller_bci_offset); -} - -void java_dyn_CallSite::set_caller_bci(oop site, jint bci) { - site->int_field_put(_caller_bci_offset, bci); -} - // Support for java_security_AccessControlContext @@ -2877,16 +2881,16 @@ java_lang_Thread::compute_offsets(); java_lang_ThreadGroup::compute_offsets(); if (EnableMethodHandles) { - java_dyn_MethodHandle::compute_offsets(); - sun_dyn_MemberName::compute_offsets(); - sun_dyn_DirectMethodHandle::compute_offsets(); - sun_dyn_BoundMethodHandle::compute_offsets(); - sun_dyn_AdapterMethodHandle::compute_offsets(); - java_dyn_MethodType::compute_offsets(); - java_dyn_MethodTypeForm::compute_offsets(); + java_lang_invoke_MethodHandle::compute_offsets(); + java_lang_invoke_MemberName::compute_offsets(); + java_lang_invoke_DirectMethodHandle::compute_offsets(); + java_lang_invoke_BoundMethodHandle::compute_offsets(); + java_lang_invoke_AdapterMethodHandle::compute_offsets(); + java_lang_invoke_MethodType::compute_offsets(); + java_lang_invoke_MethodTypeForm::compute_offsets(); } if (EnableInvokeDynamic) { - java_dyn_CallSite::compute_offsets(); + java_lang_invoke_CallSite::compute_offsets(); } java_security_AccessControlContext::compute_offsets(); // Initialize reflection classes. The layouts of these classes diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/javaClasses.hpp --- a/src/share/vm/classfile/javaClasses.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/javaClasses.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -794,11 +794,11 @@ }; -// Interface to java.dyn.MethodHandle objects +// Interface to java.lang.invoke.MethodHandle objects class MethodHandleEntry; -class java_dyn_MethodHandle: AllStatic { +class java_lang_invoke_MethodHandle: AllStatic { friend class JavaClasses; private: @@ -839,7 +839,7 @@ static int vmslots_offset_in_bytes() { return _vmslots_offset; } }; -class sun_dyn_DirectMethodHandle: public java_dyn_MethodHandle { +class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle { friend class JavaClasses; private: @@ -864,7 +864,7 @@ static int vmindex_offset_in_bytes() { return _vmindex_offset; } }; -class sun_dyn_BoundMethodHandle: public java_dyn_MethodHandle { +class java_lang_invoke_BoundMethodHandle: public java_lang_invoke_MethodHandle { friend class JavaClasses; private: @@ -891,7 +891,7 @@ static int vmargslot_offset_in_bytes() { return _vmargslot_offset; } }; -class sun_dyn_AdapterMethodHandle: public sun_dyn_BoundMethodHandle { +class java_lang_invoke_AdapterMethodHandle: public java_lang_invoke_BoundMethodHandle { friend class JavaClasses; private: @@ -942,14 +942,14 @@ }; -// Interface to sun.dyn.MemberName objects +// Interface to java.lang.invoke.MemberName objects // (These are a private interface for Java code to query the class hierarchy.) -class sun_dyn_MemberName: AllStatic { +class java_lang_invoke_MemberName: AllStatic { friend class JavaClasses; private: - // From java.dyn.MemberName: + // From java.lang.invoke.MemberName: // private Class clazz; // class in which the method is defined // private String name; // may be null if not yet materialized // private Object type; // may be null if not yet materialized @@ -1018,9 +1018,9 @@ }; -// Interface to java.dyn.MethodType objects +// Interface to java.lang.invoke.MethodType objects -class java_dyn_MethodType: AllStatic { +class java_lang_invoke_MethodType: AllStatic { friend class JavaClasses; private: @@ -1052,7 +1052,7 @@ static int form_offset_in_bytes() { return _form_offset; } }; -class java_dyn_MethodTypeForm: AllStatic { +class java_lang_invoke_MethodTypeForm: AllStatic { friend class JavaClasses; private: @@ -1075,9 +1075,9 @@ }; -// Interface to java.dyn.CallSite objects +// Interface to java.lang.invoke.CallSite objects -class java_dyn_CallSite: AllStatic { +class java_lang_invoke_CallSite: AllStatic { friend class JavaClasses; private: diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/systemDictionary.cpp --- a/src/share/vm/classfile/systemDictionary.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/systemDictionary.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1887,27 +1887,99 @@ 0 }; +Symbol* SystemDictionary::find_backup_symbol(Symbol* symbol, + const char* from_prefix, + const char* to_prefix) { + assert(AllowTransitionalJSR292, ""); // delete this subroutine + Symbol* backup_symbol = NULL; + size_t from_len = strlen(from_prefix); + if (strncmp((const char*) symbol->base(), from_prefix, from_len) != 0) + return NULL; + char buf[100]; + size_t to_len = strlen(to_prefix); + size_t tail_len = symbol->utf8_length() - from_len; + size_t new_len = to_len + tail_len; + guarantee(new_len < sizeof(buf), "buf too small"); + memcpy(buf, to_prefix, to_len); + memcpy(buf + to_len, symbol->base() + from_len, tail_len); + buf[new_len] = '\0'; + vmSymbols::SID backup_sid = vmSymbols::find_sid(buf); + if (backup_sid != vmSymbols::NO_SID) { + backup_symbol = vmSymbols::symbol_at(backup_sid); + } + return backup_symbol; +} + +Symbol* SystemDictionary::find_backup_class_name(Symbol* symbol) { + assert(AllowTransitionalJSR292, ""); // delete this subroutine + if (symbol == NULL) return NULL; + Symbol* backup_symbol = find_backup_symbol(symbol, "java/lang/invoke/", "java/dyn/"); // AllowTransitionalJSR292 ONLY + if (backup_symbol == NULL) + backup_symbol = find_backup_symbol(symbol, "java/dyn/", "sun/dyn/"); // AllowTransitionalJSR292 ONLY + return backup_symbol; +} + +Symbol* SystemDictionary::find_backup_signature(Symbol* symbol) { + assert(AllowTransitionalJSR292, ""); // delete this subroutine + if (symbol == NULL) return NULL; + return find_backup_symbol(symbol, "Ljava/lang/invoke/", "Ljava/dyn/"); +} + bool SystemDictionary::initialize_wk_klass(WKID id, int init_opt, TRAPS) { assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob"); int info = wk_init_info[id - FIRST_WKID]; int sid = (info >> CEIL_LG_OPTION_LIMIT); Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid); klassOop* klassp = &_well_known_klasses[id]; - bool must_load = (init_opt < SystemDictionary::Opt); - bool try_load = true; + bool pre_load = (init_opt < SystemDictionary::Opt); + bool try_load = true; if (init_opt == SystemDictionary::Opt_Kernel) { #ifndef KERNEL try_load = false; #endif //KERNEL } - if ((*klassp) == NULL && try_load) { + Symbol* backup_symbol = NULL; // symbol to try if the current symbol fails + if (init_opt == SystemDictionary::Pre_JSR292) { + if (!EnableMethodHandles) try_load = false; // do not bother to load such classes + if (AllowTransitionalJSR292) { + backup_symbol = find_backup_class_name(symbol); + if (try_load && PreferTransitionalJSR292) { + while (backup_symbol != NULL) { + (*klassp) = resolve_or_null(backup_symbol, CHECK_0); // try backup early + if (TraceMethodHandles) { + ResourceMark rm; + tty->print_cr("MethodHandles: try backup first for %s => %s (%s)", + symbol->as_C_string(), backup_symbol->as_C_string(), + ((*klassp) == NULL) ? "no such class" : "backup load succeeded"); + } + if ((*klassp) != NULL) return true; + backup_symbol = find_backup_class_name(backup_symbol); // find next backup + } + } + } + } + if ((*klassp) != NULL) return true; + if (!try_load) return false; + while (symbol != NULL) { + bool must_load = (pre_load && (backup_symbol == NULL)); if (must_load) { (*klassp) = resolve_or_fail(symbol, true, CHECK_0); // load required class } else { (*klassp) = resolve_or_null(symbol, CHECK_0); // load optional klass } + if ((*klassp) != NULL) return true; + // Go around again. Example of long backup sequence: + // java.lang.invoke.MemberName, java.dyn.MemberName, sun.dyn.MemberName, ONLY if AllowTransitionalJSR292 + if (TraceMethodHandles && (backup_symbol != NULL)) { + ResourceMark rm; + tty->print_cr("MethodHandles: backup for %s => %s", + symbol->as_C_string(), backup_symbol->as_C_string()); + } + symbol = backup_symbol; + if (AllowTransitionalJSR292) + backup_symbol = find_backup_class_name(symbol); } - return ((*klassp) != NULL); + return false; } void SystemDictionary::initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) { @@ -2348,6 +2420,8 @@ if (THREAD->is_Compiler_thread()) return NULL; // do not attempt from within compiler bool for_invokeGeneric = (name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name)); + if (AllowInvokeForInvokeGeneric && name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name)) + for_invokeGeneric = true; bool found_on_bcp = false; Handle mt = find_method_handle_type(signature, accessing_klass, for_invokeGeneric, @@ -2376,7 +2450,7 @@ } } -// Ask Java code to find or construct a java.dyn.MethodType for the given +// Ask Java code to find or construct a java.lang.invoke.MethodType for the given // signature, as interpreted relative to the given class loader. // Because of class loader constraints, all method handle usage must be // consistent with this loader. @@ -2430,25 +2504,33 @@ } assert(arg == npts, ""); - // call sun.dyn.MethodHandleNatives::findMethodType(Class rt, Class[] pts) -> MethodType + // call java.lang.invoke.MethodHandleNatives::findMethodType(Class rt, Class[] pts) -> MethodType JavaCallArguments args(Handle(THREAD, rt())); args.push_oop(pts()); JavaValue result(T_OBJECT); + Symbol* findMethodHandleType_signature = vmSymbols::findMethodHandleType_signature(); + if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodType_klass()->name() == vmSymbols::java_dyn_MethodType()) { + findMethodHandleType_signature = vmSymbols::findMethodHandleType_TRANS_signature(); + } JavaCalls::call_static(&result, SystemDictionary::MethodHandleNatives_klass(), vmSymbols::findMethodHandleType_name(), - vmSymbols::findMethodHandleType_signature(), + findMethodHandleType_signature, &args, CHECK_(empty)); Handle method_type(THREAD, (oop) result.get_jobject()); if (for_invokeGeneric) { - // call sun.dyn.MethodHandleNatives::notifyGenericMethodType(MethodType) -> void + // call java.lang.invoke.MethodHandleNatives::notifyGenericMethodType(MethodType) -> void JavaCallArguments args(Handle(THREAD, method_type())); JavaValue no_result(T_VOID); + Symbol* notifyGenericMethodType_signature = vmSymbols::notifyGenericMethodType_signature(); + if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodType_klass()->name() == vmSymbols::java_dyn_MethodType()) { + notifyGenericMethodType_signature = vmSymbols::notifyGenericMethodType_TRANS_signature(); + } JavaCalls::call_static(&no_result, SystemDictionary::MethodHandleNatives_klass(), vmSymbols::notifyGenericMethodType_name(), - vmSymbols::notifyGenericMethodType_signature(), + notifyGenericMethodType_signature, &args, THREAD); if (HAS_PENDING_EXCEPTION) { // If the notification fails, just kill it. @@ -2489,7 +2571,7 @@ THROW_MSG_(vmSymbols::java_lang_LinkageError(), "bad signature", empty); } - // call sun.dyn.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle + // call java.lang.invoke.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle JavaCallArguments args; args.push_oop(caller->java_mirror()); // the referring class args.push_int(ref_kind); @@ -2497,15 +2579,19 @@ args.push_oop(name()); args.push_oop(type()); JavaValue result(T_OBJECT); + Symbol* linkMethodHandleConstant_signature = vmSymbols::linkMethodHandleConstant_signature(); + if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandle_klass()->name() == vmSymbols::java_dyn_MethodHandle()) { + linkMethodHandleConstant_signature = vmSymbols::linkMethodHandleConstant_TRANS_signature(); + } JavaCalls::call_static(&result, SystemDictionary::MethodHandleNatives_klass(), vmSymbols::linkMethodHandleConstant_name(), - vmSymbols::linkMethodHandleConstant_signature(), + linkMethodHandleConstant_signature, &args, CHECK_(empty)); return Handle(THREAD, (oop) result.get_jobject()); } -// Ask Java code to find or construct a java.dyn.CallSite for the given +// Ask Java code to find or construct a java.lang.invoke.CallSite for the given // name and signature, as interpreted relative to the given class loader. Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method, Symbol* name, @@ -2516,13 +2602,13 @@ TRAPS) { Handle empty; guarantee(bootstrap_method.not_null() && - java_dyn_MethodHandle::is_instance(bootstrap_method()), + java_lang_invoke_MethodHandle::is_instance(bootstrap_method()), "caller must supply a valid BSM"); Handle caller_mname = MethodHandles::new_MemberName(CHECK_(empty)); MethodHandles::init_MemberName(caller_mname(), caller_method()); - // call sun.dyn.MethodHandleNatives::makeDynamicCallSite(bootm, name, mtype, info, caller_mname, caller_pos) + // call java.lang.invoke.MethodHandleNatives::makeDynamicCallSite(bootm, name, mtype, info, caller_mname, caller_pos) oop name_str_oop = StringTable::intern(name, CHECK_(empty)); // not a handle! JavaCallArguments args(Handle(THREAD, bootstrap_method())); args.push_oop(name_str_oop); @@ -2531,14 +2617,21 @@ args.push_oop(caller_mname()); args.push_int(caller_bci); JavaValue result(T_OBJECT); + Symbol* makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_signature(); + if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandleNatives_klass()->name() == vmSymbols::sun_dyn_MethodHandleNatives()) { + makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_TRANS_signature(); + } + if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandleNatives_klass()->name() == vmSymbols::java_dyn_MethodHandleNatives()) { + makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_TRANS2_signature(); + } JavaCalls::call_static(&result, SystemDictionary::MethodHandleNatives_klass(), vmSymbols::makeDynamicCallSite_name(), - vmSymbols::makeDynamicCallSite_signature(), + makeDynamicCallSite_signature, &args, CHECK_(empty)); oop call_site_oop = (oop) result.get_jobject(); assert(call_site_oop->is_oop() - /*&& java_dyn_CallSite::is_instance(call_site_oop)*/, "must be sane"); + /*&& java_lang_invoke_CallSite::is_instance(call_site_oop)*/, "must be sane"); if (TraceMethodHandles) { #ifndef PRODUCT tty->print_cr("Linked invokedynamic bci=%d site="INTPTR_FORMAT":", caller_bci, call_site_oop); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/systemDictionary.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -144,18 +144,18 @@ template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \ \ /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \ - template(MethodHandle_klass, java_dyn_MethodHandle, Opt) \ - template(MemberName_klass, sun_dyn_MemberName, Opt) \ - template(MethodHandleImpl_klass, sun_dyn_MethodHandleImpl, Opt) \ - template(MethodHandleNatives_klass, sun_dyn_MethodHandleNatives, Opt) \ - template(AdapterMethodHandle_klass, sun_dyn_AdapterMethodHandle, Opt) \ - template(BoundMethodHandle_klass, sun_dyn_BoundMethodHandle, Opt) \ - template(DirectMethodHandle_klass, sun_dyn_DirectMethodHandle, Opt) \ - template(MethodType_klass, java_dyn_MethodType, Opt) \ - template(MethodTypeForm_klass, java_dyn_MethodTypeForm, Opt) \ - template(WrongMethodTypeException_klass, java_dyn_WrongMethodTypeException, Opt) \ - template(Linkage_klass, java_dyn_Linkage, Opt) \ - template(CallSite_klass, java_dyn_CallSite, Opt) \ + template(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292) \ + template(MemberName_klass, java_lang_invoke_MemberName, Pre_JSR292) \ + template(MethodHandleImpl_klass, sun_dyn_MethodHandleImpl, Opt) /* AllowTransitionalJSR292 ONLY */ \ + template(MethodHandleNatives_klass, java_lang_invoke_MethodHandleNatives, Pre_JSR292) \ + template(AdapterMethodHandle_klass, java_lang_invoke_AdapterMethodHandle, Pre_JSR292) \ + template(BoundMethodHandle_klass, java_lang_invoke_BoundMethodHandle, Pre_JSR292) \ + template(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle, Pre_JSR292) \ + template(MethodType_klass, java_lang_invoke_MethodType, Pre_JSR292) \ + template(MethodTypeForm_klass, java_lang_invoke_MethodTypeForm, Pre_JSR292) \ + template(WrongMethodTypeException_klass, java_lang_invoke_WrongMethodTypeException, Pre_JSR292) \ + template(Linkage_klass, java_lang_invoke_Linkage, Opt) /* AllowTransitionalJSR292 ONLY */ \ + template(CallSite_klass, java_lang_invoke_CallSite, Pre_JSR292) \ /* Note: MethodHandle must be first, and CallSite last in group */ \ \ template(StringBuffer_klass, java_lang_StringBuffer, Pre) \ @@ -207,6 +207,7 @@ enum InitOption { Pre, // preloaded; error if not present + Pre_JSR292, // preloaded if EnableMethodHandles // Order is significant. Options before this point require resolve_or_fail. // Options after this point will use resolve_or_null instead. @@ -401,6 +402,7 @@ } static klassOop check_klass_Pre(klassOop k) { return check_klass(k); } + static klassOop check_klass_Pre_JSR292(klassOop k) { return EnableInvokeDynamic ? check_klass(k) : k; } static klassOop check_klass_Opt(klassOop k) { return k; } static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt static klassOop check_klass_Opt_Only_JDK15(klassOop k) { @@ -420,6 +422,8 @@ initialize_wk_klasses_until((WKID) limit, start_id, THREAD); } + static Symbol* find_backup_symbol(Symbol* symbol, const char* from_prefix, const char* to_prefix); + public: #define WK_KLASS_DECLARE(name, ignore_symbol, option) \ static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } @@ -441,6 +445,9 @@ static void load_abstract_ownable_synchronizer_klass(TRAPS); + static Symbol* find_backup_class_name(Symbol* class_name_symbol); + static Symbol* find_backup_signature(Symbol* signature_symbol); + private: // Tells whether ClassLoader.loadClassInternal is present static bool has_loadClassInternal() { return _has_loadClassInternal; } @@ -475,18 +482,18 @@ Handle loader2, bool is_method, TRAPS); // JSR 292 - // find the java.dyn.MethodHandles::invoke method for a given signature + // find the java.lang.invoke.MethodHandles::invoke method for a given signature static methodOop find_method_handle_invoke(Symbol* name, Symbol* signature, KlassHandle accessing_klass, TRAPS); - // ask Java to compute a java.dyn.MethodType object for a given signature + // ask Java to compute a java.lang.invoke.MethodType object for a given signature static Handle find_method_handle_type(Symbol* signature, KlassHandle accessing_klass, bool for_invokeGeneric, bool& return_bcp_flag, TRAPS); - // ask Java to compute a java.dyn.MethodHandle object for a given CP entry + // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry static Handle link_method_handle_constant(KlassHandle caller, int ref_kind, //e.g., JVM_REF_invokeVirtual KlassHandle callee, diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/verifier.cpp --- a/src/share/vm/classfile/verifier.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/verifier.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1671,13 +1671,19 @@ VerificationType::long_type(), VerificationType::long2_type(), CHECK_VERIFY(this)); } else if (tag.is_method_handle()) { + Symbol* methodHandle_name = vmSymbols::java_lang_invoke_MethodHandle(); + if (AllowTransitionalJSR292 && !Universe::is_bootstrapping()) + methodHandle_name = SystemDictionaryHandles::MethodHandle_klass()->name(); current_frame->push_stack( VerificationType::reference_type( - vmSymbols::java_dyn_MethodHandle()), CHECK_VERIFY(this)); + methodHandle_name), CHECK_VERIFY(this)); } else if (tag.is_method_type()) { + Symbol* methodType_name = vmSymbols::java_lang_invoke_MethodType(); + if (AllowTransitionalJSR292 && !Universe::is_bootstrapping()) + methodType_name = SystemDictionaryHandles::MethodType_klass()->name(); current_frame->push_stack( VerificationType::reference_type( - vmSymbols::java_dyn_MethodType()), CHECK_VERIFY(this)); + methodType_name), CHECK_VERIFY(this)); } else { verify_error(bci, "Invalid index in ldc"); return; diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/vmSymbols.cpp --- a/src/share/vm/classfile/vmSymbols.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/vmSymbols.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -277,6 +277,12 @@ return sid; } +vmSymbols::SID vmSymbols::find_sid(const char* symbol_name) { + Symbol* symbol = SymbolTable::probe(symbol_name, (int) strlen(symbol_name)); + if (symbol == NULL) return NO_SID; + return find_sid(symbol); +} + static vmIntrinsics::ID wrapper_intrinsic(BasicType type, bool unboxing) { #define TYPE2(type, unboxing) ((int)(type)*2 + ((unboxing) ? 1 : 0)) switch (TYPE2(type, unboxing)) { diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -229,33 +229,60 @@ template(base_name, "base") \ \ /* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \ - template(java_dyn_InvokeDynamic, "java/dyn/InvokeDynamic") \ - template(java_dyn_Linkage, "java/dyn/Linkage") \ - template(java_dyn_CallSite, "java/dyn/CallSite") \ - template(java_dyn_MethodHandle, "java/dyn/MethodHandle") \ - template(java_dyn_MethodType, "java/dyn/MethodType") \ - template(java_dyn_WrongMethodTypeException, "java/dyn/WrongMethodTypeException") \ - template(java_dyn_MethodType_signature, "Ljava/dyn/MethodType;") \ - template(java_dyn_MethodHandle_signature, "Ljava/dyn/MethodHandle;") \ + template(java_lang_invoke_InvokeDynamic, "java/lang/invoke/InvokeDynamic") \ + template(java_lang_invoke_Linkage, "java/lang/invoke/Linkage") \ + template(java_lang_invoke_CallSite, "java/lang/invoke/CallSite") \ + template(java_lang_invoke_MethodHandle, "java/lang/invoke/MethodHandle") \ + template(java_lang_invoke_MethodType, "java/lang/invoke/MethodType") \ + template(java_lang_invoke_WrongMethodTypeException, "java/lang/invoke/WrongMethodTypeException") \ + template(java_lang_invoke_MethodType_signature, "Ljava/lang/invoke/MethodType;") \ + template(java_lang_invoke_MethodHandle_signature, "Ljava/lang/invoke/MethodHandle;") \ /* internal classes known only to the JVM: */ \ - template(java_dyn_MethodTypeForm, "java/dyn/MethodTypeForm") \ - template(java_dyn_MethodTypeForm_signature, "Ljava/dyn/MethodTypeForm;") \ - template(sun_dyn_MemberName, "sun/dyn/MemberName") \ - template(sun_dyn_MemberName_signature, "Lsun/dyn/MemberName;") \ - template(sun_dyn_MethodHandleImpl, "sun/dyn/MethodHandleImpl") \ - template(sun_dyn_MethodHandleNatives, "sun/dyn/MethodHandleNatives") \ - template(sun_dyn_AdapterMethodHandle, "sun/dyn/AdapterMethodHandle") \ - template(sun_dyn_BoundMethodHandle, "sun/dyn/BoundMethodHandle") \ - template(sun_dyn_DirectMethodHandle, "sun/dyn/DirectMethodHandle") \ - /* internal up-calls made only by the JVM, via class sun.dyn.MethodHandleNatives: */ \ + template(java_lang_invoke_MethodTypeForm, "java/lang/invoke/MethodTypeForm") \ + template(java_lang_invoke_MethodTypeForm_signature, "Ljava/lang/invoke/MethodTypeForm;") \ + template(java_lang_invoke_MemberName, "java/lang/invoke/MemberName") \ + template(java_lang_invoke_MethodHandleNatives, "java/lang/invoke/MethodHandleNatives") \ + template(java_lang_invoke_AdapterMethodHandle, "java/lang/invoke/AdapterMethodHandle") \ + template(java_lang_invoke_BoundMethodHandle, "java/lang/invoke/BoundMethodHandle") \ + template(java_lang_invoke_DirectMethodHandle, "java/lang/invoke/DirectMethodHandle") \ + /* temporary transitional public names from 6839872: */ \ + template(java_dyn_InvokeDynamic, "java/dyn/InvokeDynamic") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_Linkage, "java/dyn/Linkage") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_CallSite, "java/dyn/CallSite") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MethodHandle, "java/dyn/MethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MethodType, "java/dyn/MethodType") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_WrongMethodTypeException, "java/dyn/WrongMethodTypeException") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MethodType_signature, "Ljava/dyn/MethodType;") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MethodHandle_signature, "Ljava/dyn/MethodHandle;") /* AllowTransitionalJSR292 ONLY */ \ + /* temporary transitional internal names from 6839872: */ \ + template(java_dyn_MethodTypeForm, "java/dyn/MethodTypeForm") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MethodTypeForm_signature, "Ljava/dyn/MethodTypeForm;") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MemberName, "java/dyn/MemberName") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_MethodHandleNatives, "java/dyn/MethodHandleNatives") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_AdapterMethodHandle, "java/dyn/AdapterMethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_BoundMethodHandle, "java/dyn/BoundMethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + template(java_dyn_DirectMethodHandle, "java/dyn/DirectMethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + /* temporary transitional internal names from EDR: */ \ + template(sun_dyn_MemberName, "sun/dyn/MemberName") /* AllowTransitionalJSR292 ONLY */ \ + template(sun_dyn_MethodHandleImpl, "sun/dyn/MethodHandleImpl") /* AllowTransitionalJSR292 ONLY */ \ + template(sun_dyn_MethodHandleNatives, "sun/dyn/MethodHandleNatives") /* AllowTransitionalJSR292 ONLY */ \ + template(sun_dyn_AdapterMethodHandle, "sun/dyn/AdapterMethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + template(sun_dyn_BoundMethodHandle, "sun/dyn/BoundMethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + template(sun_dyn_DirectMethodHandle, "sun/dyn/DirectMethodHandle") /* AllowTransitionalJSR292 ONLY */ \ + /* internal up-calls made only by the JVM, via class sun.invoke.MethodHandleNatives: */ \ template(findMethodHandleType_name, "findMethodHandleType") \ - template(findMethodHandleType_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/dyn/MethodType;") \ + template(findMethodHandleType_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;") \ + template(findMethodHandleType_TRANS_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/dyn/MethodType;") /* AllowTransitionalJSR292 ONLY */ \ template(notifyGenericMethodType_name, "notifyGenericMethodType") \ - template(notifyGenericMethodType_signature, "(Ljava/dyn/MethodType;)V") \ + template(notifyGenericMethodType_signature, "(Ljava/lang/invoke/MethodType;)V") \ + template(notifyGenericMethodType_TRANS_signature, "(Ljava/dyn/MethodType;)V") /* AllowTransitionalJSR292 ONLY */ \ template(linkMethodHandleConstant_name, "linkMethodHandleConstant") \ - template(linkMethodHandleConstant_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/dyn/MethodHandle;") \ + template(linkMethodHandleConstant_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;") \ + template(linkMethodHandleConstant_TRANS_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/dyn/MethodHandle;") /* AllowTransitionalJSR292 ONLY */ \ template(makeDynamicCallSite_name, "makeDynamicCallSite") \ - template(makeDynamicCallSite_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Lsun/dyn/MemberName;I)Ljava/dyn/CallSite;") \ + template(makeDynamicCallSite_signature, "(Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;Ljava/lang/invoke/MemberName;I)Ljava/lang/invoke/CallSite;") \ + template(makeDynamicCallSite_TRANS_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Lsun/dyn/MemberName;I)Ljava/dyn/CallSite;") /* AllowTransitionalJSR292 ONLY */ \ + template(makeDynamicCallSite_TRANS2_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Ljava/dyn/MemberName;I)Ljava/dyn/CallSite;") /* AllowTransitionalJSR292 ONLY */ \ NOT_LP64( do_alias(machine_word_signature, int_signature) ) \ LP64_ONLY( do_alias(machine_word_signature, long_signature) ) \ \ @@ -882,13 +909,15 @@ \ do_intrinsic(_invoke, java_lang_reflect_Method, invoke_name, object_object_array_object_signature, F_R) \ /* (symbols invoke_name and invoke_signature defined above) */ \ - do_intrinsic(_checkSpreadArgument, sun_dyn_MethodHandleImpl, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) \ + do_intrinsic(_checkSpreadArgument, java_lang_invoke_MethodHandleNatives, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) \ + do_intrinsic(_checkSpreadArgument_TRANS,sun_dyn_MethodHandleImpl, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) /* AllowTransitionalJSR292 ONLY */ \ + do_intrinsic(_checkSpreadArgument_TRANS2,java_dyn_MethodHandleNatives, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) /* AllowTransitionalJSR292 ONLY */ \ do_name( checkSpreadArgument_name, "checkSpreadArgument") \ do_name( checkSpreadArgument_signature, "(Ljava/lang/Object;I)V") \ - do_intrinsic(_invokeExact, java_dyn_MethodHandle, invokeExact_name, object_array_object_signature, F_RN) \ - do_intrinsic(_invokeGeneric, java_dyn_MethodHandle, invokeGeneric_name, object_array_object_signature, F_RN) \ - do_intrinsic(_invokeVarargs, java_dyn_MethodHandle, invokeVarargs_name, object_array_object_signature, F_R) \ - do_intrinsic(_invokeDynamic, java_dyn_InvokeDynamic, star_name, object_array_object_signature, F_SN) \ + do_intrinsic(_invokeExact, java_lang_invoke_MethodHandle, invokeExact_name, object_array_object_signature, F_RN) \ + do_intrinsic(_invokeGeneric, java_lang_invoke_MethodHandle, invokeGeneric_name, object_array_object_signature, F_RN) \ + do_intrinsic(_invokeVarargs, java_lang_invoke_MethodHandle, invokeVarargs_name, object_array_object_signature, F_R) \ + do_intrinsic(_invokeDynamic, java_lang_invoke_InvokeDynamic, star_name, object_array_object_signature, F_SN) \ \ /* unboxing methods: */ \ do_intrinsic(_booleanValue, java_lang_Boolean, booleanValue_name, void_boolean_signature, F_R) \ @@ -995,6 +1024,7 @@ // Returns symbol's SID if one is assigned, else NO_SID. static SID find_sid(Symbol* symbol); + static SID find_sid(const char* symbol_name); #ifndef PRODUCT // No need for this in the product: diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/code/codeCache.cpp --- a/src/share/vm/code/codeCache.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/code/codeCache.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -939,9 +939,16 @@ _heap->high(), _heap->high_boundary()); st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT - " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT + " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT "Kb" " largest_free_block=" SIZE_FORMAT, - CodeCache::nof_blobs(), CodeCache::nof_nmethods(), - CodeCache::nof_adapters(), CodeCache::unallocated_capacity(), - CodeCache::largest_free_block()); + nof_blobs(), nof_nmethods(), nof_adapters(), + unallocated_capacity()/K, largest_free_block()); } + +void CodeCache::log_state(outputStream* st) { + st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" + " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'" + " largest_free_block='" SIZE_FORMAT "'", + nof_blobs(), nof_nmethods(), nof_adapters(), + unallocated_capacity(), largest_free_block()); +} diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/code/codeCache.hpp --- a/src/share/vm/code/codeCache.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/code/codeCache.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -147,6 +147,7 @@ static void verify(); // verifies the code cache static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN; static void print_bounds(outputStream* st); // Prints a summary of the bounds of the code cache + static void log_state(outputStream* st); // The full limits of the codeCache static address low_bound() { return (address) _heap->low_boundary(); } @@ -159,7 +160,7 @@ static size_t max_capacity() { return _heap->max_capacity(); } static size_t unallocated_capacity() { return _heap->unallocated_capacity(); } static size_t largest_free_block() { return _heap->largest_free_block(); } - static bool needs_flushing() { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; } + static bool needs_flushing() { return largest_free_block() < CodeCacheFlushingMinimumFreeSpace; } static bool needs_cache_clean() { return _needs_cache_clean; } static void set_needs_cache_clean(bool v) { _needs_cache_clean = v; } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/code/nmethod.cpp --- a/src/share/vm/code/nmethod.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/code/nmethod.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -765,7 +765,7 @@ void* nmethod::operator new(size_t size, int nmethod_size) { // Always leave some room in the CodeCache for I2C/C2I adapters - if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) return NULL; + if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) return NULL; return CodeCache::allocate(nmethod_size); } @@ -1882,7 +1882,7 @@ oop nmethod::embeddedOop_at(u_char* p) { - RelocIterator iter(this, p, p + oopSize); + RelocIterator iter(this, p, p + 1); while (iter.next()) if (iter.type() == relocInfo::oop_type) { return iter.oop_reloc()->oop_value(); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/compiler/compileBroker.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1364,7 +1364,7 @@ // We need this HandleMark to avoid leaking VM handles. HandleMark hm(thread); - if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { + if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) { // the code cache is really full handle_full_code_cache(); } else if (UseCodeCacheFlushing && CodeCache::needs_flushing()) { @@ -1645,11 +1645,13 @@ if (UseCompiler || AlwaysCompileLoopMethods ) { if (xtty != NULL) { xtty->begin_elem("code_cache_full"); + CodeCache::log_state(xtty); xtty->stamp(); xtty->end_elem(); } warning("CodeCache is full. Compiler has been disabled."); warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); + CodeCache::print_bounds(tty); #ifndef PRODUCT if (CompileTheWorld || ExitOnFullCodeCache) { before_exit(JavaThread::current()); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/interpreter/abstractInterpreter.hpp --- a/src/share/vm/interpreter/abstractInterpreter.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/interpreter/abstractInterpreter.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,7 +96,7 @@ empty, // empty method (code: _return) accessor, // accessor method (code: _aload_0, _getfield, _(a|i)return) abstract, // abstract method (throws an AbstractMethodException) - method_handle, // java.dyn.MethodHandles::invoke + method_handle, // java.lang.invoke.MethodHandles::invoke java_lang_math_sin, // implementation of java.lang.Math.sin (x) java_lang_math_cos, // implementation of java.lang.Math.cos (x) java_lang_math_tan, // implementation of java.lang.Math.tan (x) diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/interpreter/interpreterRuntime.cpp --- a/src/share/vm/interpreter/interpreterRuntime.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -369,7 +369,10 @@ } // create exception - THROW_MSG(vmSymbols::java_dyn_WrongMethodTypeException(), message); + Symbol* java_lang_invoke_WrongMethodTypeException = vmSymbols::java_lang_invoke_WrongMethodTypeException(); + if (AllowTransitionalJSR292) + java_lang_invoke_WrongMethodTypeException = SystemDictionaryHandles::WrongMethodTypeException_klass()->name(); + THROW_MSG(java_lang_invoke_WrongMethodTypeException, message); } IRT_END @@ -794,7 +797,7 @@ Handle info; // optional argument(s) in JVM_CONSTANT_InvokeDynamic Handle bootm = SystemDictionary::find_bootstrap_method(caller_method, caller_bci, main_index, info, CHECK); - if (!java_dyn_MethodHandle::is_instance(bootm())) { + if (!java_lang_invoke_MethodHandle::is_instance(bootm())) { THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "no bootstrap method found for invokedynamic"); } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/interpreter/linkResolver.cpp --- a/src/share/vm/interpreter/linkResolver.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/interpreter/linkResolver.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -217,11 +217,13 @@ if (EnableMethodHandles && klass() == SystemDictionary::MethodHandle_klass() && methodOopDesc::is_method_handle_invoke_name(name)) { - if (!MethodHandles::enabled()) { + if (!THREAD->is_Compiler_thread() && !MethodHandles::enabled()) { // Make sure the Java part of the runtime has been booted up. klassOop natives = SystemDictionary::MethodHandleNatives_klass(); if (natives == NULL || instanceKlass::cast(natives)->is_not_initialized()) { - SystemDictionary::resolve_or_fail(vmSymbols::sun_dyn_MethodHandleNatives(), + Symbol* natives_name = vmSymbols::java_lang_invoke_MethodHandleNatives(); + if (natives != NULL && AllowTransitionalJSR292) natives_name = Klass::cast(natives)->name(); + SystemDictionary::resolve_or_fail(natives_name, Handle(), Handle(), true, @@ -298,7 +300,7 @@ } void LinkResolver::resolve_dynamic_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) { - // The class is java.dyn.MethodHandle + // The class is java.lang.invoke.MethodHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); Symbol* method_name = vmSymbols::invokeExact_name(); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/memory/heap.cpp --- a/src/share/vm/memory/heap.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/memory/heap.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -316,12 +316,19 @@ } size_t CodeHeap::largest_free_block() const { + // First check unused space excluding free blocks. + size_t free_sz = size(_free_segments); + size_t unused = max_capacity() - allocated_capacity() - free_sz; + if (unused >= free_sz) + return unused; + + // Now check largest free block. size_t len = 0; for (FreeBlock* b = _freelist; b != NULL; b = b->link()) { if (b->length() > len) len = b->length(); } - return size(len); + return MAX2(unused, size(len)); } // Free list management diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/oops/cpCacheOop.hpp --- a/src/share/vm/oops/cpCacheOop.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/oops/cpCacheOop.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -190,7 +190,7 @@ ); void set_dynamic_call( - Handle call_site, // Resolved java.dyn.CallSite (f1) + Handle call_site, // Resolved java.lang.invoke.CallSite (f1) methodHandle signature_invoker // determines signature information ); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/oops/instanceKlass.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -2420,7 +2420,7 @@ st->cr(); } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { st->print(BULLET"signature: "); - java_dyn_MethodType::print_signature(obj, st); + java_lang_invoke_MethodType::print_signature(obj, st); st->cr(); } } @@ -2451,7 +2451,7 @@ } } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { st->print(" = "); - java_dyn_MethodType::print_signature(obj, st); + java_lang_invoke_MethodType::print_signature(obj, st); } else if (java_lang_boxing_object::is_instance(obj)) { st->print(" = "); java_lang_boxing_object::print(obj, st); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/oops/instanceKlass.hpp --- a/src/share/vm/oops/instanceKlass.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/oops/instanceKlass.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -193,8 +193,8 @@ typeArrayOop _inner_classes; // Implementors of this interface (not valid if it overflows) klassOop _implementors[implementors_limit]; - // invokedynamic bootstrap method (a java.dyn.MethodHandle) - oop _bootstrap_method; + // invokedynamic bootstrap method (a java.lang.invoke.MethodHandle) + oop _bootstrap_method; // AllowTransitionalJSR292 ONLY // Annotations for this class, or null if none. typeArrayOop _class_annotations; // Annotation objects (byte arrays) for fields, or null if no annotations. @@ -529,7 +529,7 @@ _enclosing_method_method_index = method_index; } // JSR 292 support - oop bootstrap_method() const { return _bootstrap_method; } + oop bootstrap_method() const { return _bootstrap_method; } // AllowTransitionalJSR292 ONLY void set_bootstrap_method(oop mh) { oop_store(&_bootstrap_method, mh); } // jmethodID support @@ -817,7 +817,7 @@ oop* adr_signers() const { return (oop*)&this->_signers;} oop* adr_inner_classes() const { return (oop*)&this->_inner_classes;} oop* adr_implementors() const { return (oop*)&this->_implementors[0];} - oop* adr_bootstrap_method() const { return (oop*)&this->_bootstrap_method;} + oop* adr_bootstrap_method() const { return (oop*)&this->_bootstrap_method;} // AllowTransitionalJSR292 ONLY oop* adr_methods_jmethod_ids() const { return (oop*)&this->_methods_jmethod_ids;} oop* adr_methods_cached_itable_indices() const { return (oop*)&this->_methods_cached_itable_indices;} oop* adr_class_annotations() const { return (oop*)&this->_class_annotations;} diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/oops/methodKlass.cpp --- a/src/share/vm/oops/methodKlass.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/oops/methodKlass.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -103,6 +103,12 @@ m->backedge_counter()->init(); m->clear_number_of_breakpoints(); +#ifdef TIERED + m->set_rate(0); + m->set_prev_event_count(0); + m->set_prev_time(0); +#endif + assert(m->is_parsable(), "must be parsable here."); assert(m->size() == size, "wrong size for object"); // We should not publish an uprasable object's reference diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/oops/methodOop.cpp --- a/src/share/vm/oops/methodOop.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/oops/methodOop.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -855,7 +855,7 @@ case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name): return true; } - if (AllowTransitionalJSR292 + if ((AllowTransitionalJSR292 || AllowInvokeForInvokeGeneric) && name_sid == vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name)) return true; return false; @@ -865,7 +865,7 @@ enum { _imcp_invoke_name = 1, // utf8: 'invokeExact' or 'invokeGeneric' _imcp_invoke_signature, // utf8: (variable Symbol*) - _imcp_method_type_value, // string: (variable java/dyn/MethodType, sic) + _imcp_method_type_value, // string: (variable java/lang/invoke/MethodType, sic) _imcp_limit }; @@ -1091,7 +1091,8 @@ vmSymbols::SID name_id = vmSymbols::find_sid(name()); if (name_id == vmSymbols::NO_SID) return; vmSymbols::SID sig_id = vmSymbols::find_sid(signature()); - if (klass_id != vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle) + if (klass_id != vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle) + && !(klass_id == vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle) && AllowTransitionalJSR292) && sig_id == vmSymbols::NO_SID) return; jshort flags = access_flags().as_short(); @@ -1117,7 +1118,8 @@ break; // Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*. - case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle): + case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle): // AllowTransitionalJSR292 ONLY + case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle): if (is_static() || !is_native()) break; switch (name_id) { case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name): @@ -1127,11 +1129,12 @@ id = vmIntrinsics::_invokeExact; break; case vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name): - if (AllowTransitionalJSR292) id = vmIntrinsics::_invokeExact; + if (AllowInvokeForInvokeGeneric) id = vmIntrinsics::_invokeGeneric; + else if (AllowTransitionalJSR292) id = vmIntrinsics::_invokeExact; break; } break; - case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_InvokeDynamic): + case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_InvokeDynamic): if (!is_static() || !is_native()) break; id = vmIntrinsics::_invokeDynamic; break; diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/oops/methodOop.hpp --- a/src/share/vm/oops/methodOop.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/oops/methodOop.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -84,6 +84,11 @@ // | invocation_counter | // | backedge_counter | // |------------------------------------------------------| +// | prev_time (tiered only, 64 bit wide) | +// | | +// |------------------------------------------------------| +// | rate (tiered) | +// |------------------------------------------------------| // | code (pointer) | // | i2i (pointer) | // | adapter (pointer) | @@ -124,6 +129,11 @@ InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations +#ifdef TIERED + jlong _prev_time; // Previous time the rate was acquired + float _rate; // Events (invocation and backedge counter increments) per millisecond +#endif + #ifndef PRODUCT int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging) #endif @@ -304,6 +314,17 @@ InvocationCounter* invocation_counter() { return &_invocation_counter; } InvocationCounter* backedge_counter() { return &_backedge_counter; } +#ifdef TIERED + // We are reusing interpreter_invocation_count as a holder for the previous event count! + // We can do that since interpreter_invocation_count is not used in tiered. + int prev_event_count() const { return _interpreter_invocation_count; } + void set_prev_event_count(int count) { _interpreter_invocation_count = count; } + jlong prev_time() const { return _prev_time; } + void set_prev_time(jlong time) { _prev_time = time; } + float rate() const { return _rate; } + void set_rate(float rate) { _rate = rate; } +#endif + int invocation_count(); int backedge_count(); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/opto/bytecodeInfo.cpp --- a/src/share/vm/opto/bytecodeInfo.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/opto/bytecodeInfo.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -487,7 +487,7 @@ if (caller_jvms->method()->is_method_handle_adapter()) new_depth_adjust -= 1; // don't count actions in MH or indy adapter frames else if (callee_method->is_method_handle_invoke()) { - new_depth_adjust -= 1; // don't count method handle calls from java.dyn implem + new_depth_adjust -= 1; // don't count method handle calls from java.lang.invoke implem } if (new_depth_adjust != 0 && PrintInlining) { stringStream nm1; caller_jvms->method()->print_name(&nm1); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/opto/callGenerator.cpp --- a/src/share/vm/opto/callGenerator.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/opto/callGenerator.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -199,7 +199,7 @@ Node* call_site = kit.make_load(kit.control(), call_site_adr, TypeInstPtr::BOTTOM, T_OBJECT, Compile::AliasIdxRaw); // Load the target MethodHandle from the CallSite object. - Node* target_mh_adr = kit.basic_plus_adr(call_site, call_site, java_dyn_CallSite::target_offset_in_bytes()); + Node* target_mh_adr = kit.basic_plus_adr(call_site, call_site, java_lang_invoke_CallSite::target_offset_in_bytes()); Node* target_mh = kit.make_load(kit.control(), target_mh_adr, TypeInstPtr::BOTTOM, T_OBJECT); address resolve_stub = SharedRuntime::get_resolve_opt_virtual_call_stub(); @@ -725,7 +725,7 @@ Node* call_site = kit.make_load(kit.control(), call_site_adr, TypeInstPtr::BOTTOM, T_OBJECT, Compile::AliasIdxRaw); // Load the target MethodHandle from the CallSite object. - Node* target_adr = kit.basic_plus_adr(call_site, call_site, java_dyn_CallSite::target_offset_in_bytes()); + Node* target_adr = kit.basic_plus_adr(call_site, call_site, java_lang_invoke_CallSite::target_offset_in_bytes()); Node* target_mh = kit.make_load(kit.control(), target_adr, TypeInstPtr::BOTTOM, T_OBJECT); // Check if the MethodHandle is still the same. diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/opto/output.cpp --- a/src/share/vm/opto/output.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/opto/output.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1028,7 +1028,7 @@ // helper for Fill_buffer bailout logic static void turn_off_compiler(Compile* C) { - if (CodeCache::unallocated_capacity() >= CodeCacheMinimumFreeSpace*10) { + if (CodeCache::largest_free_block() >= CodeCacheMinimumFreeSpace*10) { // Do not turn off compilation if a single giant method has // blown the code cache size. C->record_failure("excessive request to CodeCache"); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/opto/parse3.cpp --- a/src/share/vm/opto/parse3.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/opto/parse3.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,8 +143,8 @@ return; } else { - // final non-static field of a trusted class ({java,sun}.dyn - // classes). + // final non-static field of a trusted class (classes in + // java.lang.invoke and sun.invoke packages and subpackages). if (obj->is_Con()) { const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr(); ciObject* constant_oop = oop_ptr->const_oop(); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/opto/type.cpp --- a/src/share/vm/opto/type.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/opto/type.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -3386,7 +3386,22 @@ instance_id = InstanceBot; tary = TypeAry::make(Type::BOTTOM, tary->_size); } + } else // Non integral arrays. + // Must fall to bottom if exact klasses in upper lattice + // are not equal or super klass is exact. + if ( above_centerline(ptr) && klass() != tap->klass() && + // meet with top[] and bottom[] are processed further down: + tap ->_klass != NULL && this->_klass != NULL && + // both are exact and not equal: + ((tap ->_klass_is_exact && this->_klass_is_exact) || + // 'tap' is exact and super or unrelated: + (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || + // 'this' is exact and super or unrelated: + (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { + tary = TypeAry::make(Type::BOTTOM, tary->_size); + return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot ); } + bool xk = false; switch (tap->ptr()) { case AnyNull: @@ -3766,7 +3781,7 @@ // Oops, need to compute _klass and cache it ciKlass* k_ary = compute_klass(); - if( this != TypeAryPtr::OOPS ) { + if( this != TypeAryPtr::OOPS && this->dual() != TypeAryPtr::OOPS ) { // The _klass field acts as a cache of the underlying // ciKlass for this array type. In order to set the field, // we need to cast away const-ness. diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/prims/methodHandleWalk.cpp --- a/src/share/vm/prims/methodHandleWalk.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/prims/methodHandleWalk.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -36,7 +36,7 @@ // MethodHandleChain void MethodHandleChain::set_method_handle(Handle mh, TRAPS) { - if (!java_dyn_MethodHandle::is_instance(mh())) lose("bad method handle", CHECK); + if (!java_lang_invoke_MethodHandle::is_instance(mh())) lose("bad method handle", CHECK); // set current method handle and unpack partially _method_handle = mh; @@ -47,21 +47,21 @@ _conversion = -1; _last_invoke = Bytecodes::_nop; //arbitrary non-garbage - if (sun_dyn_DirectMethodHandle::is_instance(mh())) { + if (java_lang_invoke_DirectMethodHandle::is_instance(mh())) { set_last_method(mh(), THREAD); return; } - if (sun_dyn_AdapterMethodHandle::is_instance(mh())) { + if (java_lang_invoke_AdapterMethodHandle::is_instance(mh())) { _conversion = AdapterMethodHandle_conversion(); assert(_conversion != -1, "bad conv value"); - assert(sun_dyn_BoundMethodHandle::is_instance(mh()), "also BMH"); + assert(java_lang_invoke_BoundMethodHandle::is_instance(mh()), "also BMH"); } - if (sun_dyn_BoundMethodHandle::is_instance(mh())) { + if (java_lang_invoke_BoundMethodHandle::is_instance(mh())) { if (!is_adapter()) // keep AMH and BMH separate in this model _is_bound = true; _arg_slot = BoundMethodHandle_vmargslot(); oop target = MethodHandle_vmtarget_oop(); - if (!is_bound() || java_dyn_MethodHandle::is_instance(target)) { + if (!is_bound() || java_lang_invoke_MethodHandle::is_instance(target)) { _arg_type = compute_bound_arg_type(target, NULL, _arg_slot, CHECK); } else if (target != NULL && target->is_method()) { methodOop m = (methodOop) target; @@ -100,13 +100,12 @@ BasicType MethodHandleChain::compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS) { // There is no direct indication of whether the argument is primitive or not. // It is implied by the _vmentry code, and by the MethodType of the target. - // FIXME: Make it explicit MethodHandleImpl refactors out from MethodHandle BasicType arg_type = T_VOID; if (target != NULL) { - oop mtype = java_dyn_MethodHandle::type(target); + oop mtype = java_lang_invoke_MethodHandle::type(target); int arg_num = MethodHandles::argument_slot_to_argnum(mtype, arg_slot); if (arg_num >= 0) { - oop ptype = java_dyn_MethodType::ptype(mtype, arg_num); + oop ptype = java_lang_invoke_MethodType::ptype(mtype, arg_num); arg_type = java_lang_Class::as_BasicType(ptype); } } else if (m != NULL) { @@ -205,28 +204,28 @@ int arg_slot = chain().adapter_arg_slot(); SlotState* arg_state = slot_state(arg_slot); if (arg_state == NULL - && conv_op > sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW) { + && conv_op > java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW) { lose("bad argument index", CHECK_(empty)); } // perform the adapter action switch (chain().adapter_conversion_op()) { - case sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY: + case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY: // No changes to arguments; pass the bits through. break; - case sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW: { + case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW: { // To keep the verifier happy, emit bitwise ("raw") conversions as needed. // See MethodHandles::same_basic_type_for_arguments for allowed conversions. Handle incoming_mtype(THREAD, chain().method_type_oop()); oop outgoing_mh_oop = chain().vmtarget_oop(); - if (!java_dyn_MethodHandle::is_instance(outgoing_mh_oop)) + if (!java_lang_invoke_MethodHandle::is_instance(outgoing_mh_oop)) lose("outgoing target not a MethodHandle", CHECK_(empty)); - Handle outgoing_mtype(THREAD, java_dyn_MethodHandle::type(outgoing_mh_oop)); + Handle outgoing_mtype(THREAD, java_lang_invoke_MethodHandle::type(outgoing_mh_oop)); outgoing_mh_oop = NULL; // GC safety - int nptypes = java_dyn_MethodType::ptype_count(outgoing_mtype()); - if (nptypes != java_dyn_MethodType::ptype_count(incoming_mtype())) + int nptypes = java_lang_invoke_MethodType::ptype_count(outgoing_mtype()); + if (nptypes != java_lang_invoke_MethodType::ptype_count(incoming_mtype())) lose("incoming and outgoing parameter count do not agree", CHECK_(empty)); for (int i = 0, slot = _outgoing.length() - 1; slot >= 0; slot--) { @@ -236,8 +235,8 @@ klassOop in_klass = NULL; klassOop out_klass = NULL; - BasicType inpbt = java_lang_Class::as_BasicType(java_dyn_MethodType::ptype(incoming_mtype(), i), &in_klass); - BasicType outpbt = java_lang_Class::as_BasicType(java_dyn_MethodType::ptype(outgoing_mtype(), i), &out_klass); + BasicType inpbt = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(incoming_mtype(), i), &in_klass); + BasicType outpbt = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(outgoing_mtype(), i), &out_klass); assert(inpbt == arg.basic_type(), "sanity"); if (inpbt != outpbt) { @@ -255,8 +254,8 @@ i++; // We need to skip void slots at the top of the loop. } - BasicType inrbt = java_lang_Class::as_BasicType(java_dyn_MethodType::rtype(incoming_mtype())); - BasicType outrbt = java_lang_Class::as_BasicType(java_dyn_MethodType::rtype(outgoing_mtype())); + BasicType inrbt = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(incoming_mtype())); + BasicType outrbt = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(outgoing_mtype())); if (inrbt != outrbt) { if (inrbt == T_INT && outrbt == T_VOID) { // See comments in MethodHandles::same_basic_type_for_arguments. @@ -268,7 +267,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_CHECK_CAST: { + case java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST: { // checkcast the Nth outgoing argument in place klassOop dest_klass = NULL; BasicType dest = java_lang_Class::as_BasicType(chain().adapter_arg_oop(), &dest_klass); @@ -281,7 +280,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM: { + case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM: { // i2l, etc., on the Nth outgoing argument in place BasicType src = chain().adapter_conversion_src_type(), dest = chain().adapter_conversion_dest_type(); @@ -306,7 +305,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM: { + case java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM: { // checkcast to wrapper type & call intValue, etc. BasicType dest = chain().adapter_conversion_dest_type(); ArgToken arg = arg_state->_arg; @@ -324,7 +323,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_PRIM_TO_REF: { + case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF: { // call wrapper type.valueOf BasicType src = chain().adapter_conversion_src_type(); ArgToken arg = arg_state->_arg; @@ -340,7 +339,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS: { + case java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS: { int dest_arg_slot = chain().adapter_conversion_vminfo(); if (!slot_has_argument(dest_arg_slot)) { lose("bad swap index", CHECK_(empty)); @@ -353,7 +352,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_ROT_ARGS: { + case java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS: { int dest_arg_slot = chain().adapter_conversion_vminfo(); if (!slot_has_argument(dest_arg_slot) || arg_slot == dest_arg_slot) { lose("bad rotate index", CHECK_(empty)); @@ -379,7 +378,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_DUP_ARGS: { + case java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS: { int dup_slots = chain().adapter_conversion_stack_pushes(); if (dup_slots <= 0) { lose("bad dup count", CHECK_(empty)); @@ -393,7 +392,7 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_DROP_ARGS: { + case java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS: { int drop_slots = -chain().adapter_conversion_stack_pushes(); if (drop_slots <= 0) { lose("bad drop count", CHECK_(empty)); @@ -407,12 +406,12 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_COLLECT_ARGS: { //NYI, may GC + case java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS: { //NYI, may GC lose("unimplemented", CHECK_(empty)); break; } - case sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS: { + case java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS: { klassOop array_klass_oop = NULL; BasicType array_type = java_lang_Class::as_BasicType(chain().adapter_arg_oop(), &array_klass_oop); @@ -470,8 +469,8 @@ break; } - case sun_dyn_AdapterMethodHandle::OP_FLYBY: //NYI, runs Java code - case sun_dyn_AdapterMethodHandle::OP_RICOCHET: //NYI, runs Java code + case java_lang_invoke_AdapterMethodHandle::OP_FLYBY: //NYI, runs Java code + case java_lang_invoke_AdapterMethodHandle::OP_RICOCHET: //NYI, runs Java code lose("unimplemented", CHECK_(empty)); break; @@ -533,7 +532,7 @@ // void MethodHandleWalker::walk_incoming_state(TRAPS) { Handle mtype(THREAD, chain().method_type_oop()); - int nptypes = java_dyn_MethodType::ptype_count(mtype()); + int nptypes = java_lang_invoke_MethodType::ptype_count(mtype()); _outgoing_argc = nptypes; int argp = nptypes - 1; if (argp >= 0) { @@ -542,7 +541,7 @@ for (int i = 0; i < nptypes; i++) { klassOop arg_type_klass = NULL; BasicType arg_type = java_lang_Class::as_BasicType( - java_dyn_MethodType::ptype(mtype(), i), &arg_type_klass); + java_lang_invoke_MethodType::ptype(mtype(), i), &arg_type_klass); int index = new_local_index(arg_type); ArgToken arg = make_parameter(arg_type, arg_type_klass, index, CHECK); debug_only(arg_type_klass = (klassOop) NULL); @@ -556,7 +555,7 @@ // call make_parameter at the end of the list for the return type klassOop ret_type_klass = NULL; BasicType ret_type = java_lang_Class::as_BasicType( - java_dyn_MethodType::rtype(mtype()), &ret_type_klass); + java_lang_invoke_MethodType::rtype(mtype()), &ret_type_klass); ArgToken ret = make_parameter(ret_type, ret_type_klass, -1, CHECK); // ignore ret; client can catch it if needed } @@ -631,7 +630,7 @@ // Get return type klass. Handle first_mtype(THREAD, chain().method_type_oop()); // _rklass is NULL for primitives. - _rtype = java_lang_Class::as_BasicType(java_dyn_MethodType::rtype(first_mtype()), &_rklass); + _rtype = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(first_mtype()), &_rklass); if (_rtype == T_ARRAY) _rtype = T_OBJECT; int params = _callee->size_of_parameters(); // Incoming arguments plus receiver. @@ -960,6 +959,16 @@ if (m == NULL) { // Get the intrinsic methodOop. m = vmIntrinsics::method_for(iid); + if (m == NULL && iid == vmIntrinsics::_checkSpreadArgument && AllowTransitionalJSR292) { + m = vmIntrinsics::method_for(vmIntrinsics::_checkSpreadArgument_TRANS); + if (m == NULL) + // sun.dyn.MethodHandleImpl not found, look for java.dyn.MethodHandleNatives: + m = vmIntrinsics::method_for(vmIntrinsics::_checkSpreadArgument_TRANS2); + } + if (m == NULL) { + ArgToken zero; + lose(vmIntrinsics::name_at(iid), CHECK_(zero)); + } } klassOop klass = m->method_holder(); @@ -1396,7 +1405,7 @@ void print_method_handle(oop mh) { if (!mh->is_oop()) { tty->print_cr("*** not a method handle: "INTPTR_FORMAT, (intptr_t)mh); - } else if (java_dyn_MethodHandle::is_instance(mh)) { + } else if (java_lang_invoke_MethodHandle::is_instance(mh)) { //MethodHandlePrinter::print(mh); } else { tty->print("*** not a method handle: "); diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/prims/methodHandleWalk.hpp --- a/src/share/vm/prims/methodHandleWalk.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/prims/methodHandleWalk.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,13 +48,13 @@ void set_last_method(oop target, TRAPS); static BasicType compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS); - oop MethodHandle_type_oop() { return java_dyn_MethodHandle::type(method_handle_oop()); } - oop MethodHandle_vmtarget_oop() { return java_dyn_MethodHandle::vmtarget(method_handle_oop()); } - int MethodHandle_vmslots() { return java_dyn_MethodHandle::vmslots(method_handle_oop()); } - int DirectMethodHandle_vmindex() { return sun_dyn_DirectMethodHandle::vmindex(method_handle_oop()); } - oop BoundMethodHandle_argument_oop() { return sun_dyn_BoundMethodHandle::argument(method_handle_oop()); } - int BoundMethodHandle_vmargslot() { return sun_dyn_BoundMethodHandle::vmargslot(method_handle_oop()); } - int AdapterMethodHandle_conversion() { return sun_dyn_AdapterMethodHandle::conversion(method_handle_oop()); } + oop MethodHandle_type_oop() { return java_lang_invoke_MethodHandle::type(method_handle_oop()); } + oop MethodHandle_vmtarget_oop() { return java_lang_invoke_MethodHandle::vmtarget(method_handle_oop()); } + int MethodHandle_vmslots() { return java_lang_invoke_MethodHandle::vmslots(method_handle_oop()); } + int DirectMethodHandle_vmindex() { return java_lang_invoke_DirectMethodHandle::vmindex(method_handle_oop()); } + oop BoundMethodHandle_argument_oop() { return java_lang_invoke_BoundMethodHandle::argument(method_handle_oop()); } + int BoundMethodHandle_vmargslot() { return java_lang_invoke_BoundMethodHandle::vmargslot(method_handle_oop()); } + int AdapterMethodHandle_conversion() { return java_lang_invoke_AdapterMethodHandle::conversion(method_handle_oop()); } public: MethodHandleChain(Handle root, TRAPS) diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/prims/methodHandles.cpp --- a/src/share/vm/prims/methodHandles.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/prims/methodHandles.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -163,9 +163,9 @@ // or it may use the klass/index form; both forms mean the same thing. methodOop m = decode_methodOop(methodOop(vmtarget), decode_flags_result); if ((decode_flags_result & _dmf_has_receiver) != 0 - && java_dyn_MethodType::is_instance(mtype)) { + && java_lang_invoke_MethodType::is_instance(mtype)) { // Extract receiver type restriction from mtype.ptypes[0]. - objArrayOop ptypes = java_dyn_MethodType::ptypes(mtype); + objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(mtype); oop ptype0 = (ptypes == NULL || ptypes->length() < 1) ? oop(NULL) : ptypes->obj_at(0); if (java_lang_Class::is_instance(ptype0)) receiver_limit_result = java_lang_Class::as_klassOop(ptype0); @@ -199,18 +199,18 @@ // (MemberName is the non-operational name used for queries and setup.) methodOop MethodHandles::decode_DirectMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) { - oop vmtarget = sun_dyn_DirectMethodHandle::vmtarget(mh); - int vmindex = sun_dyn_DirectMethodHandle::vmindex(mh); - oop mtype = sun_dyn_DirectMethodHandle::type(mh); + oop vmtarget = java_lang_invoke_DirectMethodHandle::vmtarget(mh); + int vmindex = java_lang_invoke_DirectMethodHandle::vmindex(mh); + oop mtype = java_lang_invoke_DirectMethodHandle::type(mh); return decode_vmtarget(vmtarget, vmindex, mtype, receiver_limit_result, decode_flags_result); } methodOop MethodHandles::decode_BoundMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) { - assert(sun_dyn_BoundMethodHandle::is_instance(mh), ""); + assert(java_lang_invoke_BoundMethodHandle::is_instance(mh), ""); assert(mh->klass() != SystemDictionary::AdapterMethodHandle_klass(), ""); for (oop bmh = mh;;) { // Bound MHs can be stacked to bind several arguments. - oop target = java_dyn_MethodHandle::vmtarget(bmh); + oop target = java_lang_invoke_MethodHandle::vmtarget(bmh); if (target == NULL) return NULL; decode_flags_result |= MethodHandles::_dmf_binds_argument; klassOop tk = target->klass(); @@ -218,7 +218,7 @@ bmh = target; continue; } else { - if (java_dyn_MethodHandle::is_subclass(tk)) { + if (java_lang_invoke_MethodHandle::is_subclass(tk)) { //assert(tk == SystemDictionary::DirectMethodHandle_klass(), "end of BMH chain must be DMH"); return decode_MethodHandle(target, receiver_limit_result, decode_flags_result); } else { @@ -240,9 +240,9 @@ assert(mh->klass() == SystemDictionary::AdapterMethodHandle_klass(), ""); for (oop amh = mh;;) { // Adapter MHs can be stacked to convert several arguments. - int conv_op = adapter_conversion_op(sun_dyn_AdapterMethodHandle::conversion(amh)); + int conv_op = adapter_conversion_op(java_lang_invoke_AdapterMethodHandle::conversion(amh)); decode_flags_result |= (_dmf_adapter_lsb << conv_op) & _DMF_ADAPTER_MASK; - oop target = java_dyn_MethodHandle::vmtarget(amh); + oop target = java_lang_invoke_MethodHandle::vmtarget(amh); if (target == NULL) return NULL; klassOop tk = target->klass(); if (tk == SystemDictionary::AdapterMethodHandle_klass()) { @@ -258,14 +258,14 @@ methodOop MethodHandles::decode_MethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) { if (mh == NULL) return NULL; klassOop mhk = mh->klass(); - assert(java_dyn_MethodHandle::is_subclass(mhk), "must be a MethodHandle"); + assert(java_lang_invoke_MethodHandle::is_subclass(mhk), "must be a MethodHandle"); if (mhk == SystemDictionary::DirectMethodHandle_klass()) { return decode_DirectMethodHandle(mh, receiver_limit_result, decode_flags_result); } else if (mhk == SystemDictionary::BoundMethodHandle_klass()) { return decode_BoundMethodHandle(mh, receiver_limit_result, decode_flags_result); } else if (mhk == SystemDictionary::AdapterMethodHandle_klass()) { return decode_AdapterMethodHandle(mh, receiver_limit_result, decode_flags_result); - } else if (sun_dyn_BoundMethodHandle::is_subclass(mhk)) { + } else if (java_lang_invoke_BoundMethodHandle::is_subclass(mhk)) { // could be a JavaMethodHandle (but not an adapter MH) return decode_BoundMethodHandle(mh, receiver_limit_result, decode_flags_result); } else { @@ -308,7 +308,7 @@ } else if (xk == SystemDictionary::MemberName_klass()) { // Note: This only works if the MemberName has already been resolved. return decode_MemberName(x, receiver_limit_result, decode_flags_result); - } else if (java_dyn_MethodHandle::is_subclass(xk)) { + } else if (java_lang_invoke_MethodHandle::is_subclass(xk)) { return decode_MethodHandle(x, receiver_limit_result, decode_flags_result); } else if (xk == SystemDictionary::reflect_Method_klass()) { oop clazz = java_lang_reflect_Method::clazz(x); @@ -327,7 +327,7 @@ } else { // unrecognized object assert(!x->is_method(), "already checked"); - assert(!sun_dyn_MemberName::is_instance(x), "already checked"); + assert(!java_lang_invoke_MemberName::is_instance(x), "already checked"); } return NULL; } @@ -336,15 +336,15 @@ int MethodHandles::decode_MethodHandle_stack_pushes(oop mh) { if (mh->klass() == SystemDictionary::DirectMethodHandle_klass()) return 0; // no push/pop - int this_vmslots = java_dyn_MethodHandle::vmslots(mh); + int this_vmslots = java_lang_invoke_MethodHandle::vmslots(mh); int last_vmslots = 0; oop last_mh = mh; for (;;) { - oop target = java_dyn_MethodHandle::vmtarget(last_mh); + oop target = java_lang_invoke_MethodHandle::vmtarget(last_mh); if (target->klass() == SystemDictionary::DirectMethodHandle_klass()) { - last_vmslots = java_dyn_MethodHandle::vmslots(target); + last_vmslots = java_lang_invoke_MethodHandle::vmslots(target); break; - } else if (!java_dyn_MethodHandle::is_instance(target)) { + } else if (!java_lang_invoke_MethodHandle::is_instance(target)) { // might be klass or method assert(target->is_method(), "must get here with a direct ref to method"); last_vmslots = methodOop(target)->size_of_parameters(); @@ -361,16 +361,16 @@ // MemberName support -// import sun_dyn_MemberName.* +// import java_lang_invoke_MemberName.* enum { - IS_METHOD = sun_dyn_MemberName::MN_IS_METHOD, - IS_CONSTRUCTOR = sun_dyn_MemberName::MN_IS_CONSTRUCTOR, - IS_FIELD = sun_dyn_MemberName::MN_IS_FIELD, - IS_TYPE = sun_dyn_MemberName::MN_IS_TYPE, - SEARCH_SUPERCLASSES = sun_dyn_MemberName::MN_SEARCH_SUPERCLASSES, - SEARCH_INTERFACES = sun_dyn_MemberName::MN_SEARCH_INTERFACES, + IS_METHOD = java_lang_invoke_MemberName::MN_IS_METHOD, + IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR, + IS_FIELD = java_lang_invoke_MemberName::MN_IS_FIELD, + IS_TYPE = java_lang_invoke_MemberName::MN_IS_TYPE, + SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES, + SEARCH_INTERFACES = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES, ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE, - VM_INDEX_UNINITIALIZED = sun_dyn_MemberName::VM_INDEX_UNINITIALIZED + VM_INDEX_UNINITIALIZED = java_lang_invoke_MemberName::VM_INDEX_UNINITIALIZED }; Handle MethodHandles::new_MemberName(TRAPS) { @@ -405,10 +405,10 @@ if (!do_dispatch || (flags & IS_CONSTRUCTOR) || m->can_be_statically_bound()) vmindex = methodOopDesc::nonvirtual_vtable_index; // implies never any dispatch assert(vmindex != VM_INDEX_UNINITIALIZED, "Java sentinel value"); - sun_dyn_MemberName::set_vmtarget(mname_oop, vmtarget); - sun_dyn_MemberName::set_vmindex(mname_oop, vmindex); - sun_dyn_MemberName::set_flags(mname_oop, flags); - sun_dyn_MemberName::set_clazz(mname_oop, Klass::cast(m->method_holder())->java_mirror()); + java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget); + java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); + java_lang_invoke_MemberName::set_flags(mname_oop, flags); + java_lang_invoke_MemberName::set_clazz(mname_oop, Klass::cast(m->method_holder())->java_mirror()); } void MethodHandles::init_MemberName(oop mname_oop, klassOop field_holder, AccessFlags mods, int offset) { @@ -416,21 +416,21 @@ oop vmtarget = field_holder; int vmindex = offset; // determines the field uniquely when combined with static bit assert(vmindex != VM_INDEX_UNINITIALIZED, "bad alias on vmindex"); - sun_dyn_MemberName::set_vmtarget(mname_oop, vmtarget); - sun_dyn_MemberName::set_vmindex(mname_oop, vmindex); - sun_dyn_MemberName::set_flags(mname_oop, flags); - sun_dyn_MemberName::set_clazz(mname_oop, Klass::cast(field_holder)->java_mirror()); + java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget); + java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); + java_lang_invoke_MemberName::set_flags(mname_oop, flags); + java_lang_invoke_MemberName::set_clazz(mname_oop, Klass::cast(field_holder)->java_mirror()); } methodOop MethodHandles::decode_MemberName(oop mname, klassOop& receiver_limit_result, int& decode_flags_result) { - int flags = sun_dyn_MemberName::flags(mname); + int flags = java_lang_invoke_MemberName::flags(mname); if ((flags & (IS_METHOD | IS_CONSTRUCTOR)) == 0) return NULL; // not invocable - oop vmtarget = sun_dyn_MemberName::vmtarget(mname); - int vmindex = sun_dyn_MemberName::vmindex(mname); + oop vmtarget = java_lang_invoke_MemberName::vmtarget(mname); + int vmindex = java_lang_invoke_MemberName::vmindex(mname); if (vmindex == VM_INDEX_UNINITIALIZED) return NULL; // not resolved methodOop m = decode_vmtarget(vmtarget, vmindex, NULL, receiver_limit_result, decode_flags_result); - oop clazz = sun_dyn_MemberName::clazz(mname); + oop clazz = java_lang_invoke_MemberName::clazz(mname); if (clazz != NULL && java_lang_Class::is_instance(clazz)) { klassOop klass = java_lang_Class::as_klassOop(clazz); if (klass != NULL) receiver_limit_result = klass; @@ -442,8 +442,8 @@ Symbol* MethodHandles::convert_to_signature(oop type_str, bool polymorphic, TRAPS) { - if (java_dyn_MethodType::is_instance(type_str)) { - return java_dyn_MethodType::as_signature(type_str, polymorphic, CHECK_NULL); + if (java_lang_invoke_MethodType::is_instance(type_str)) { + return java_lang_invoke_MethodType::as_signature(type_str, polymorphic, CHECK_NULL); } else if (java_lang_Class::is_instance(type_str)) { return java_lang_Class::as_signature(type_str, false, CHECK_NULL); } else if (java_lang_String::is_instance(type_str)) { @@ -461,7 +461,7 @@ // Resolving it plants a vmtarget/vmindex in it, // which refers dirctly to JVM internals. void MethodHandles::resolve_MemberName(Handle mname, TRAPS) { - assert(sun_dyn_MemberName::is_instance(mname()), ""); + assert(java_lang_invoke_MemberName::is_instance(mname()), ""); #ifdef ASSERT // If this assert throws, renegotiate the sentinel value used by the Java code, // so that it is distinct from any valid vtable index value, and any special @@ -472,12 +472,12 @@ const int sentinel_limit = methodOopDesc::highest_unused_vtable_index_value - sentinel_slop; assert(VM_INDEX_UNINITIALIZED < sentinel_limit, "Java sentinel != JVM sentinels"); #endif - if (sun_dyn_MemberName::vmindex(mname()) != VM_INDEX_UNINITIALIZED) + if (java_lang_invoke_MemberName::vmindex(mname()) != VM_INDEX_UNINITIALIZED) return; // already resolved - oop defc_oop = sun_dyn_MemberName::clazz(mname()); - oop name_str = sun_dyn_MemberName::name(mname()); - oop type_str = sun_dyn_MemberName::type(mname()); - int flags = sun_dyn_MemberName::flags(mname()); + oop defc_oop = java_lang_invoke_MemberName::clazz(mname()); + oop name_str = java_lang_invoke_MemberName::name(mname()); + oop type_str = java_lang_invoke_MemberName::type(mname()); + int flags = java_lang_invoke_MemberName::flags(mname()); if (defc_oop == NULL || name_str == NULL || type_str == NULL) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to resolve"); @@ -510,7 +510,7 @@ // convert the external string or reflective type to an internal signature TempNewSymbol type = convert_to_signature(type_str, polymorphic_signature, CHECK); - if (java_dyn_MethodType::is_instance(type_str) && polymorphic_signature) { + if (java_lang_invoke_MethodType::is_instance(type_str) && polymorphic_signature) { polymorphic_method_type = Handle(THREAD, type_str); //preserve exactly } @@ -557,9 +557,9 @@ vmtarget = result.resolved_klass()->as_klassOop(); } int mods = (m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS); - sun_dyn_MemberName::set_vmtarget(mname(), vmtarget); - sun_dyn_MemberName::set_vmindex(mname(), vmindex); - sun_dyn_MemberName::set_modifiers(mname(), mods); + java_lang_invoke_MemberName::set_vmtarget(mname(), vmtarget); + java_lang_invoke_MemberName::set_vmindex(mname(), vmindex); + java_lang_invoke_MemberName::set_modifiers(mname(), mods); DEBUG_ONLY(int junk; klassOop junk2); assert(decode_MemberName(mname(), junk2, junk) == result.resolved_method()(), "properly stored for later decoding"); @@ -586,9 +586,9 @@ oop vmtarget = m(); int vmindex = methodOopDesc::nonvirtual_vtable_index; int mods = (m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS); - sun_dyn_MemberName::set_vmtarget(mname(), vmtarget); - sun_dyn_MemberName::set_vmindex(mname(), vmindex); - sun_dyn_MemberName::set_modifiers(mname(), mods); + java_lang_invoke_MemberName::set_vmtarget(mname(), vmtarget); + java_lang_invoke_MemberName::set_vmindex(mname(), vmindex); + java_lang_invoke_MemberName::set_modifiers(mname(), mods); DEBUG_ONLY(int junk; klassOop junk2); assert(decode_MemberName(mname(), junk2, junk) == result.resolved_method()(), "properly stored for later decoding"); @@ -605,9 +605,9 @@ int vmindex = fd.offset(); int mods = (fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS); if (vmindex == VM_INDEX_UNINITIALIZED) break; // should not happen - sun_dyn_MemberName::set_vmtarget(mname(), vmtarget); - sun_dyn_MemberName::set_vmindex(mname(), vmindex); - sun_dyn_MemberName::set_modifiers(mname(), mods); + java_lang_invoke_MemberName::set_vmtarget(mname(), vmtarget); + java_lang_invoke_MemberName::set_vmindex(mname(), vmindex); + java_lang_invoke_MemberName::set_modifiers(mname(), mods); return; } default: @@ -618,11 +618,11 @@ if (polymorphic_method_type.not_null()) { // Look on a non-null class loader. Handle cur_class_loader; - const int nptypes = java_dyn_MethodType::ptype_count(polymorphic_method_type()); + const int nptypes = java_lang_invoke_MethodType::ptype_count(polymorphic_method_type()); for (int i = 0; i <= nptypes; i++) { oop type_mirror; - if (i < nptypes) type_mirror = java_dyn_MethodType::ptype(polymorphic_method_type(), i); - else type_mirror = java_dyn_MethodType::rtype(polymorphic_method_type()); + if (i < nptypes) type_mirror = java_lang_invoke_MethodType::ptype(polymorphic_method_type(), i); + else type_mirror = java_lang_invoke_MethodType::rtype(polymorphic_method_type()); klassOop example_type = java_lang_Class::as_klassOop(type_mirror); if (example_type == NULL) continue; oop class_loader = Klass::cast(example_type)->class_loader(); @@ -639,9 +639,9 @@ } if (m != NULL) { int mods = (m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS); - sun_dyn_MemberName::set_vmtarget(mname(), m); - sun_dyn_MemberName::set_vmindex(mname(), m->vtable_index()); - sun_dyn_MemberName::set_modifiers(mname(), mods); + java_lang_invoke_MemberName::set_vmtarget(mname(), m); + java_lang_invoke_MemberName::set_vmindex(mname(), m->vtable_index()); + java_lang_invoke_MemberName::set_modifiers(mname(), mods); return; } } @@ -653,17 +653,17 @@ // Resolving it plants a vmtarget/vmindex in it, // which refers directly to JVM internals. void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) { - assert(sun_dyn_MemberName::is_instance(mname()), ""); - oop vmtarget = sun_dyn_MemberName::vmtarget(mname()); - int vmindex = sun_dyn_MemberName::vmindex(mname()); + assert(java_lang_invoke_MemberName::is_instance(mname()), ""); + oop vmtarget = java_lang_invoke_MemberName::vmtarget(mname()); + int vmindex = java_lang_invoke_MemberName::vmindex(mname()); if (vmtarget == NULL || vmindex == VM_INDEX_UNINITIALIZED) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to expand"); } - bool have_defc = (sun_dyn_MemberName::clazz(mname()) != NULL); - bool have_name = (sun_dyn_MemberName::name(mname()) != NULL); - bool have_type = (sun_dyn_MemberName::type(mname()) != NULL); - int flags = sun_dyn_MemberName::flags(mname()); + bool have_defc = (java_lang_invoke_MemberName::clazz(mname()) != NULL); + bool have_name = (java_lang_invoke_MemberName::name(mname()) != NULL); + bool have_type = (java_lang_invoke_MemberName::type(mname()) != NULL); + int flags = java_lang_invoke_MemberName::flags(mname()); if (suppress != 0) { if (suppress & _suppress_defc) have_defc = true; @@ -687,16 +687,16 @@ if (receiver_limit != NULL && receiver_limit != defc && Klass::cast(receiver_limit)->is_subtype_of(defc)) defc = receiver_limit; - sun_dyn_MemberName::set_clazz(mname(), Klass::cast(defc)->java_mirror()); + java_lang_invoke_MemberName::set_clazz(mname(), Klass::cast(defc)->java_mirror()); } if (!have_name) { //not java_lang_String::create_from_symbol; let's intern member names Handle name = StringTable::intern(m->name(), CHECK); - sun_dyn_MemberName::set_name(mname(), name()); + java_lang_invoke_MemberName::set_name(mname(), name()); } if (!have_type) { Handle type = java_lang_String::create_from_symbol(m->signature(), CHECK); - sun_dyn_MemberName::set_type(mname(), type()); + java_lang_invoke_MemberName::set_type(mname(), type()); } return; } @@ -711,16 +711,16 @@ if (!defc->find_field_from_offset(vmindex, is_static, &fd)) break; // cannot expand if (!have_defc) { - sun_dyn_MemberName::set_clazz(mname(), defc->java_mirror()); + java_lang_invoke_MemberName::set_clazz(mname(), defc->java_mirror()); } if (!have_name) { //not java_lang_String::create_from_symbol; let's intern member names Handle name = StringTable::intern(fd.name(), CHECK); - sun_dyn_MemberName::set_name(mname(), name()); + java_lang_invoke_MemberName::set_name(mname(), name()); } if (!have_type) { Handle type = java_lang_String::create_from_symbol(fd.signature(), CHECK); - sun_dyn_MemberName::set_type(mname(), type()); + java_lang_invoke_MemberName::set_type(mname(), type()); } return; } @@ -775,7 +775,7 @@ --rskip; } else if (rfill < rlimit) { oop result = results->obj_at(rfill++); - if (!sun_dyn_MemberName::is_instance(result)) + if (!java_lang_invoke_MemberName::is_instance(result)) return -99; // caller bug! MethodHandles::init_MemberName(result, st.klass()->as_klassOop(), st.access_flags(), st.offset()); } else if (++overflow >= overflow_limit) { @@ -823,7 +823,7 @@ --rskip; } else if (rfill < rlimit) { oop result = results->obj_at(rfill++); - if (!sun_dyn_MemberName::is_instance(result)) + if (!java_lang_invoke_MemberName::is_instance(result)) return -99; // caller bug! MethodHandles::init_MemberName(result, m, true); } else if (++overflow >= overflow_limit) { @@ -857,9 +857,9 @@ // Sanitize out methodOops, klassOops, and any other non-Java data. // This is for debugging and reflection. oop MethodHandles::encode_target(Handle mh, int format, TRAPS) { - assert(java_dyn_MethodHandle::is_instance(mh()), "must be a MH"); + assert(java_lang_invoke_MethodHandle::is_instance(mh()), "must be a MH"); if (format == ETF_HANDLE_OR_METHOD_NAME) { - oop target = java_dyn_MethodHandle::vmtarget(mh()); + oop target = java_lang_invoke_MethodHandle::vmtarget(mh()); if (target == NULL) { return NULL; // unformed MH } @@ -874,10 +874,10 @@ if (target->klass() == SystemDictionary::DirectMethodHandle_klass()) { return target; } - if (!java_dyn_MethodHandle::is_instance(target)){ + if (!java_lang_invoke_MethodHandle::is_instance(target)){ return NULL; // unformed MH } - target = java_dyn_MethodHandle::vmtarget(target); + target = java_lang_invoke_MethodHandle::vmtarget(target); } } // cases of metadata in MH.vmtarget: @@ -904,7 +904,7 @@ instanceKlassHandle mname_klass(THREAD, SystemDictionary::MemberName_klass()); mname_klass->initialize(CHECK_NULL); Handle mname = mname_klass->allocate_instance_handle(CHECK_NULL); - sun_dyn_MemberName::set_vmindex(mname(), VM_INDEX_UNINITIALIZED); + java_lang_invoke_MemberName::set_vmindex(mname(), VM_INDEX_UNINITIALIZED); bool do_dispatch = ((decode_flags & MethodHandles::_dmf_does_dispatch) != 0); init_MemberName(mname(), m, do_dispatch); expand_MemberName(mname, 0, CHECK_NULL); @@ -923,6 +923,7 @@ "java/lang/Null", //"java/lang/Nothing", "sun/dyn/empty/Empty", + "sun/invoke/empty/Empty", NULL }; @@ -1025,7 +1026,7 @@ int first_ptype_pos, KlassHandle insert_ptype, TRAPS) { - objArrayHandle ptypes(THREAD, java_dyn_MethodType::ptypes(mtype())); + objArrayHandle ptypes(THREAD, java_lang_invoke_MethodType::ptypes(mtype())); int pnum = first_ptype_pos; int pmax = ptypes->length(); int mnum = 0; // method argument @@ -1036,7 +1037,7 @@ if (ss.at_return_type()) { if (pnum != pmax) { err = "too many arguments"; break; } - ptype_oop = java_dyn_MethodType::rtype(mtype()); + ptype_oop = java_lang_invoke_MethodType::rtype(mtype()); } else { if (pnum >= pmax) { err = "not enough arguments"; break; } @@ -1111,7 +1112,7 @@ } if (m_needs_receiver && err == NULL) { - objArrayOop ptypes = java_dyn_MethodType::ptypes(mtype()); + objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(mtype()); if (ptypes->length() < first_ptype_pos) { err = "receiver argument is missing"; goto die; } if (has_bound_recv) @@ -1131,15 +1132,15 @@ void MethodHandles::verify_vmslots(Handle mh, TRAPS) { // Verify vmslots. - int check_slots = argument_slot_count(java_dyn_MethodHandle::type(mh())); - if (java_dyn_MethodHandle::vmslots(mh()) != check_slots) { + int check_slots = argument_slot_count(java_lang_invoke_MethodHandle::type(mh())); + if (java_lang_invoke_MethodHandle::vmslots(mh()) != check_slots) { THROW_MSG(vmSymbols::java_lang_InternalError(), "bad vmslots in BMH"); } } void MethodHandles::verify_vmargslot(Handle mh, int argnum, int argslot, TRAPS) { // Verify that argslot points at the given argnum. - int check_slot = argument_slot(java_dyn_MethodHandle::type(mh()), argnum); + int check_slot = argument_slot(java_lang_invoke_MethodHandle::type(mh()), argnum); if (argslot != check_slot || argslot < 0) { const char* fmt = "for argnum of %d, vmargslot is %d, should be %d"; size_t msglen = strlen(fmt) + 3*11 + 1; @@ -1160,8 +1161,8 @@ int delete_argnum, oop dst_mtype, int dst_beg, int dst_end, bool raw) { - objArrayOop src_ptypes = java_dyn_MethodType::ptypes(src_mtype); - objArrayOop dst_ptypes = java_dyn_MethodType::ptypes(dst_mtype); + objArrayOop src_ptypes = java_lang_invoke_MethodType::ptypes(src_mtype); + objArrayOop dst_ptypes = java_lang_invoke_MethodType::ptypes(dst_mtype); int src_max = src_ptypes->length(); int dst_max = dst_ptypes->length(); @@ -1224,8 +1225,8 @@ } // Now compare return types also. - oop src_rtype = java_dyn_MethodType::rtype(src_mtype); - oop dst_rtype = java_dyn_MethodType::rtype(dst_mtype); + oop src_rtype = java_lang_invoke_MethodType::rtype(src_mtype); + oop dst_rtype = java_lang_invoke_MethodType::rtype(dst_mtype); if (src_rtype != dst_rtype) { err = check_return_type_change(dst_rtype, src_rtype, raw); // note reversal! if (err != NULL) return err; @@ -1314,7 +1315,7 @@ // then return a negative number. Otherwise, the result // is in the range [0..vmslots] inclusive. int MethodHandles::argument_slot(oop method_type, int arg) { - objArrayOop ptypes = java_dyn_MethodType::ptypes(method_type); + objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(method_type); int argslot = 0; int len = ptypes->length(); if (arg < -1 || arg >= len) return -99; @@ -1328,7 +1329,7 @@ // Given a slot number, return the argument number. int MethodHandles::argument_slot_to_argnum(oop method_type, int query_argslot) { - objArrayOop ptypes = java_dyn_MethodType::ptypes(method_type); + objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(method_type); int argslot = 0; int len = ptypes->length(); for (int i = len-1; i >= 0; i--) { @@ -1394,11 +1395,11 @@ void MethodHandles::verify_DirectMethodHandle(Handle mh, methodHandle m, TRAPS) { // Verify type. - Handle mtype(THREAD, java_dyn_MethodHandle::type(mh())); + Handle mtype(THREAD, java_lang_invoke_MethodHandle::type(mh())); verify_method_type(m, mtype, false, KlassHandle(), CHECK); // Verify vmslots. - if (java_dyn_MethodHandle::vmslots(mh()) != m->size_of_parameters()) { + if (java_lang_invoke_MethodHandle::vmslots(mh()) != m->size_of_parameters()) { THROW_MSG(vmSymbols::java_lang_InternalError(), "bad vmslots in DMH"); } } @@ -1410,7 +1411,7 @@ THROW(vmSymbols::java_lang_InternalError()); } - java_dyn_MethodHandle::init_vmslots(mh()); + java_lang_invoke_MethodHandle::init_vmslots(mh()); if (VerifyMethodHandles) { // The privileged code which invokes this routine should not make @@ -1470,8 +1471,8 @@ if (me == NULL) { THROW(vmSymbols::java_lang_InternalError()); } - sun_dyn_DirectMethodHandle::set_vmtarget(mh(), vmtarget); - sun_dyn_DirectMethodHandle::set_vmindex(mh(), vmindex); + java_lang_invoke_DirectMethodHandle::set_vmtarget(mh(), vmtarget); + java_lang_invoke_DirectMethodHandle::set_vmindex(mh(), vmindex); DEBUG_ONLY(int flags; klassOop rlimit); assert(MethodHandles::decode_method(mh(), rlimit, flags) == m(), "properly stored for later decoding"); @@ -1482,15 +1483,15 @@ assert(decode_MethodHandle_stack_pushes(mh()) == 0, "DMH does not move stack"); // Done! - java_dyn_MethodHandle::set_vmentry(mh(), me); + java_lang_invoke_MethodHandle::set_vmentry(mh(), me); } void MethodHandles::verify_BoundMethodHandle_with_receiver(Handle mh, methodHandle m, TRAPS) { // Verify type. - oop receiver = sun_dyn_BoundMethodHandle::argument(mh()); - Handle mtype(THREAD, java_dyn_MethodHandle::type(mh())); + oop receiver = java_lang_invoke_BoundMethodHandle::argument(mh()); + Handle mtype(THREAD, java_lang_invoke_MethodHandle::type(mh())); KlassHandle bound_recv_type; if (receiver != NULL) bound_recv_type = KlassHandle(THREAD, receiver->klass()); verify_method_type(m, mtype, true, bound_recv_type, CHECK); @@ -1498,11 +1499,11 @@ int receiver_pos = m->size_of_parameters() - 1; // Verify MH.vmargslot, which should point at the bound receiver. - verify_vmargslot(mh, -1, sun_dyn_BoundMethodHandle::vmargslot(mh()), CHECK); + verify_vmargslot(mh, -1, java_lang_invoke_BoundMethodHandle::vmargslot(mh()), CHECK); //verify_vmslots(mh, CHECK); // Verify vmslots. - if (java_dyn_MethodHandle::vmslots(mh()) != receiver_pos) { + if (java_lang_invoke_MethodHandle::vmslots(mh()) != receiver_pos) { THROW_MSG(vmSymbols::java_lang_InternalError(), "bad vmslots in BMH (receiver)"); } } @@ -1520,7 +1521,7 @@ KlassHandle receiver_klass; { - oop receiver_oop = sun_dyn_BoundMethodHandle::argument(mh()); + oop receiver_oop = java_lang_invoke_BoundMethodHandle::argument(mh()); if (receiver_oop != NULL) receiver_klass = KlassHandle(THREAD, receiver_oop->klass()); } @@ -1531,31 +1532,31 @@ if (m.is_null()) { THROW(vmSymbols::java_lang_InternalError()); } if (m->is_abstract()) { THROW(vmSymbols::java_lang_AbstractMethodError()); } - java_dyn_MethodHandle::init_vmslots(mh()); + java_lang_invoke_MethodHandle::init_vmslots(mh()); if (VerifyMethodHandles) { verify_BoundMethodHandle_with_receiver(mh, m, CHECK); } - sun_dyn_BoundMethodHandle::set_vmtarget(mh(), m()); + java_lang_invoke_BoundMethodHandle::set_vmtarget(mh(), m()); DEBUG_ONLY(int junk; klassOop junk2); assert(MethodHandles::decode_method(mh(), junk2, junk) == m(), "properly stored for later decoding"); assert(decode_MethodHandle_stack_pushes(mh()) == 1, "BMH pushes one stack slot"); // Done! - java_dyn_MethodHandle::set_vmentry(mh(), MethodHandles::entry(MethodHandles::_bound_ref_direct_mh)); + java_lang_invoke_MethodHandle::set_vmentry(mh(), MethodHandles::entry(MethodHandles::_bound_ref_direct_mh)); } void MethodHandles::verify_BoundMethodHandle(Handle mh, Handle target, int argnum, bool direct_to_method, TRAPS) { Handle ptype_handle(THREAD, - java_dyn_MethodType::ptype(java_dyn_MethodHandle::type(target()), argnum)); + java_lang_invoke_MethodType::ptype(java_lang_invoke_MethodHandle::type(target()), argnum)); KlassHandle ptype_klass; BasicType ptype = java_lang_Class::as_BasicType(ptype_handle(), &ptype_klass); int slots_pushed = type2size[ptype]; - oop argument = sun_dyn_BoundMethodHandle::argument(mh()); + oop argument = java_lang_invoke_BoundMethodHandle::argument(mh()); const char* err = NULL; @@ -1623,9 +1624,9 @@ if (err == NULL) { // Verify the rest of the method type. - err = check_method_type_insertion(java_dyn_MethodHandle::type(mh()), + err = check_method_type_insertion(java_lang_invoke_MethodHandle::type(mh()), argnum, ptype_handle(), - java_dyn_MethodHandle::type(target())); + java_lang_invoke_MethodHandle::type(target())); } if (err != NULL) { @@ -1635,20 +1636,20 @@ void MethodHandles::init_BoundMethodHandle(Handle mh, Handle target, int argnum, TRAPS) { // Check arguments. - if (mh.is_null() || target.is_null() || !java_dyn_MethodHandle::is_instance(target())) { + if (mh.is_null() || target.is_null() || !java_lang_invoke_MethodHandle::is_instance(target())) { THROW(vmSymbols::java_lang_InternalError()); } - java_dyn_MethodHandle::init_vmslots(mh()); + java_lang_invoke_MethodHandle::init_vmslots(mh()); if (VerifyMethodHandles) { int insert_after = argnum - 1; - verify_vmargslot(mh, insert_after, sun_dyn_BoundMethodHandle::vmargslot(mh()), CHECK); + verify_vmargslot(mh, insert_after, java_lang_invoke_BoundMethodHandle::vmargslot(mh()), CHECK); verify_vmslots(mh, CHECK); } // Get bound type and required slots. - oop ptype_oop = java_dyn_MethodType::ptype(java_dyn_MethodHandle::type(target()), argnum); + oop ptype_oop = java_lang_invoke_MethodType::ptype(java_lang_invoke_MethodHandle::type(target()), argnum); BasicType ptype = java_lang_Class::as_BasicType(ptype_oop); int slots_pushed = type2size[ptype]; @@ -1659,12 +1660,12 @@ bool direct_to_method = false; if (OptimizeMethodHandles && target->klass() == SystemDictionary::DirectMethodHandle_klass() && - (argnum == 0 || sun_dyn_DirectMethodHandle::vmindex(target()) < 0)) { + (argnum == 0 || java_lang_invoke_DirectMethodHandle::vmindex(target()) < 0)) { int decode_flags = 0; klassOop receiver_limit_oop = NULL; methodHandle m(THREAD, decode_method(target(), receiver_limit_oop, decode_flags)); if (m.is_null()) { THROW_MSG(vmSymbols::java_lang_InternalError(), "DMH failed to decode"); } DEBUG_ONLY(int m_vmslots = m->size_of_parameters() - slots_pushed); // pos. of 1st arg. - assert(sun_dyn_BoundMethodHandle::vmslots(mh()) == m_vmslots, "type w/ m sig"); + assert(java_lang_invoke_BoundMethodHandle::vmslots(mh()) == m_vmslots, "type w/ m sig"); if (argnum == 0 && (decode_flags & _dmf_has_receiver) != 0) { KlassHandle receiver_limit(THREAD, receiver_limit_oop); init_BoundMethodHandle_with_receiver(mh, m, @@ -1677,11 +1678,11 @@ // to bind another argument and still invoke the methodOop directly. if (!(decode_flags & _dmf_does_dispatch)) { direct_to_method = true; - sun_dyn_BoundMethodHandle::set_vmtarget(mh(), m()); + java_lang_invoke_BoundMethodHandle::set_vmtarget(mh(), m()); } } if (!direct_to_method) - sun_dyn_BoundMethodHandle::set_vmtarget(mh(), target()); + java_lang_invoke_BoundMethodHandle::set_vmtarget(mh(), target()); if (VerifyMethodHandles) { verify_BoundMethodHandle(mh, target, argnum, direct_to_method, CHECK); @@ -1703,7 +1704,7 @@ } // Done! - java_dyn_MethodHandle::set_vmentry(mh(), me); + java_lang_invoke_MethodHandle::set_vmentry(mh(), me); } static void throw_InternalError_for_bad_conversion(int conversion, const char* err, TRAPS) { @@ -1713,8 +1714,8 @@ } void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) { - jint conversion = sun_dyn_AdapterMethodHandle::conversion(mh()); - int argslot = sun_dyn_AdapterMethodHandle::vmargslot(mh()); + jint conversion = java_lang_invoke_AdapterMethodHandle::conversion(mh()); + int argslot = java_lang_invoke_AdapterMethodHandle::vmargslot(mh()); verify_vmargslot(mh, argnum, argslot, CHECK); verify_vmslots(mh, CHECK); @@ -1731,10 +1732,10 @@ BasicType dest = adapter_conversion_dest_type(conversion); int vminfo = adapter_conversion_vminfo(conversion); // should be zero - Handle argument(THREAD, sun_dyn_AdapterMethodHandle::argument(mh())); - Handle target(THREAD, sun_dyn_AdapterMethodHandle::vmtarget(mh())); - Handle src_mtype(THREAD, java_dyn_MethodHandle::type(mh())); - Handle dst_mtype(THREAD, java_dyn_MethodHandle::type(target())); + Handle argument(THREAD, java_lang_invoke_AdapterMethodHandle::argument(mh())); + Handle target(THREAD, java_lang_invoke_AdapterMethodHandle::vmtarget(mh())); + Handle src_mtype(THREAD, java_lang_invoke_MethodHandle::type(mh())); + Handle dst_mtype(THREAD, java_lang_invoke_MethodHandle::type(target())); const char* err = NULL; @@ -1760,7 +1761,7 @@ break; case _adapter_flyby: case _adapter_ricochet: - if (!java_dyn_MethodHandle::is_instance(argument())) + if (!java_lang_invoke_MethodHandle::is_instance(argument())) { err = "MethodHandle adapter argument required"; break; } break; default: @@ -1806,9 +1807,9 @@ err = "adapter requires src/dest conversion subfields for swap"; break; } int swap_size = type2size[src]; - oop src_mtype = sun_dyn_AdapterMethodHandle::type(mh()); - oop dest_mtype = sun_dyn_AdapterMethodHandle::type(target()); - int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(target()); + oop src_mtype = java_lang_invoke_AdapterMethodHandle::type(mh()); + oop dest_mtype = java_lang_invoke_AdapterMethodHandle::type(target()); + int slot_limit = java_lang_invoke_AdapterMethodHandle::vmslots(target()); int src_slot = argslot; int dest_slot = vminfo; bool rotate_up = (src_slot > dest_slot); // upward rotation @@ -1821,8 +1822,8 @@ } else if (ek == _adapter_swap_args && !(src_slot > dest_slot)) { err = "source of swap must be deeper in stack"; } else if (ek == _adapter_swap_args) { - err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, dest_arg), - java_dyn_MethodType::ptype(dest_mtype, src_arg), + err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, dest_arg), + java_lang_invoke_MethodType::ptype(dest_mtype, src_arg), dest_arg); } else if (ek == _adapter_rot_args) { if (rotate_up) { @@ -1830,8 +1831,8 @@ // rotate up: [dest_slot..src_slot-ss] --> [dest_slot+ss..src_slot] // that is: [src_arg+1..dest_arg] --> [src_arg..dest_arg-1] for (int i = src_arg+1; i <= dest_arg && err == NULL; i++) { - err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, i), - java_dyn_MethodType::ptype(dest_mtype, i-1), + err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, i), + java_lang_invoke_MethodType::ptype(dest_mtype, i-1), i); } } else { // rotate down @@ -1839,15 +1840,15 @@ // rotate down: [src_slot+ss..dest_slot] --> [src_slot..dest_slot-ss] // that is: [dest_arg..src_arg-1] --> [dst_arg+1..src_arg] for (int i = dest_arg; i <= src_arg-1 && err == NULL; i++) { - err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, i), - java_dyn_MethodType::ptype(dest_mtype, i+1), + err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, i), + java_lang_invoke_MethodType::ptype(dest_mtype, i+1), i); } } } if (err == NULL) - err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, src_arg), - java_dyn_MethodType::ptype(dest_mtype, dest_arg), + err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, src_arg), + java_lang_invoke_MethodType::ptype(dest_mtype, dest_arg), src_arg); } break; @@ -1918,8 +1919,8 @@ if (err == NULL) { // Make sure this adapter does not push too deeply. int slots_pushed = stack_move / stack_move_unit(); - int this_vmslots = java_dyn_MethodHandle::vmslots(mh()); - int target_vmslots = java_dyn_MethodHandle::vmslots(target()); + int this_vmslots = java_lang_invoke_MethodHandle::vmslots(mh()); + int target_vmslots = java_lang_invoke_MethodHandle::vmslots(target()); if (slots_pushed != (target_vmslots - this_vmslots)) { err = "stack_move inconsistent with previous and current MethodType vmslots"; } else if (slots_pushed > 0) { @@ -1961,7 +1962,7 @@ case _adapter_check_cast: { // The actual value being checked must be a reference: - err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype(), argnum), + err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype(), argnum), object_java_mirror(), argnum); if (err != NULL) break; @@ -1985,9 +1986,9 @@ } void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnum, TRAPS) { - oop argument = sun_dyn_AdapterMethodHandle::argument(mh()); - int argslot = sun_dyn_AdapterMethodHandle::vmargslot(mh()); - jint conversion = sun_dyn_AdapterMethodHandle::conversion(mh()); + oop argument = java_lang_invoke_AdapterMethodHandle::argument(mh()); + int argslot = java_lang_invoke_AdapterMethodHandle::vmargslot(mh()); + jint conversion = java_lang_invoke_AdapterMethodHandle::conversion(mh()); jint conv_op = adapter_conversion_op(conversion); // adjust the adapter code to the internal EntryKind enumeration: @@ -1995,11 +1996,11 @@ EntryKind ek_opt = ek_orig; // may be optimized // Finalize the vmtarget field (Java initialized it to null). - if (!java_dyn_MethodHandle::is_instance(target())) { + if (!java_lang_invoke_MethodHandle::is_instance(target())) { throw_InternalError_for_bad_conversion(conversion, "bad target", THREAD); return; } - sun_dyn_AdapterMethodHandle::set_vmtarget(mh(), target()); + java_lang_invoke_AdapterMethodHandle::set_vmtarget(mh(), target()); if (VerifyMethodHandles) { verify_AdapterMethodHandle(mh, argnum, CHECK); @@ -2083,7 +2084,7 @@ case _adapter_rot_args: { int swap_slots = type2size[src]; - int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(mh()); + int slot_limit = java_lang_invoke_AdapterMethodHandle::vmslots(mh()); int src_slot = argslot; int dest_slot = vminfo; int rotate = (ek_orig == _adapter_swap_args) ? 0 : (src_slot > dest_slot) ? 1 : -1; @@ -2147,10 +2148,10 @@ jint new_conversion = adapter_conversion(conv_op, src, dest, stack_move, vminfo); // Finalize the conversion field. (Note that it is final to Java code.) - sun_dyn_AdapterMethodHandle::set_conversion(mh(), new_conversion); + java_lang_invoke_AdapterMethodHandle::set_conversion(mh(), new_conversion); // Done! - java_dyn_MethodHandle::set_vmentry(mh(), entry(ek_opt)); + java_lang_invoke_MethodHandle::set_vmentry(mh(), entry(ek_opt)); // There should be enough memory barriers on exit from native methods // to ensure that the MH is fully initialized to all threads before @@ -2158,7 +2159,7 @@ } // -// Here are the native methods on sun.dyn.MethodHandleImpl. +// Here are the native methods on sun.invoke.MethodHandleImpl. // They are the private interface between this JVM and the HotSpot-specific // Java code that implements JSR 292 method handles. // @@ -2168,7 +2169,7 @@ // direct method handles for invokestatic or invokespecial // void init(DirectMethodHandle self, MemberName ref, boolean doDispatch, Class caller); -JVM_ENTRY(void, MHI_init_DMH(JNIEnv *env, jobject igcls, jobject mh_jh, +JVM_ENTRY(void, MHN_init_DMH(JNIEnv *env, jobject igcls, jobject mh_jh, jobject target_jh, jboolean do_dispatch, jobject caller_jh)) { ResourceMark rm; // for error messages @@ -2177,13 +2178,13 @@ Handle mh(THREAD, JNIHandles::resolve_non_null(mh_jh)); // Early returns out of this method leave the DMH in an unfinished state. - assert(java_dyn_MethodHandle::vmentry(mh()) == NULL, "must be safely null"); + assert(java_lang_invoke_MethodHandle::vmentry(mh()) == NULL, "must be safely null"); // which method are we really talking about? if (target_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); } oop target_oop = JNIHandles::resolve_non_null(target_jh); - if (sun_dyn_MemberName::is_instance(target_oop) && - sun_dyn_MemberName::vmindex(target_oop) == VM_INDEX_UNINITIALIZED) { + if (java_lang_invoke_MemberName::is_instance(target_oop) && + java_lang_invoke_MemberName::vmindex(target_oop) == VM_INDEX_UNINITIALIZED) { Handle mname(THREAD, target_oop); MethodHandles::resolve_MemberName(mname, CHECK); target_oop = mname(); // in case of GC @@ -2232,7 +2233,7 @@ JVM_END // bound method handles -JVM_ENTRY(void, MHI_init_BMH(JNIEnv *env, jobject igcls, jobject mh_jh, +JVM_ENTRY(void, MHN_init_BMH(JNIEnv *env, jobject igcls, jobject mh_jh, jobject target_jh, int argnum)) { ResourceMark rm; // for error messages @@ -2241,12 +2242,12 @@ Handle mh(THREAD, JNIHandles::resolve_non_null(mh_jh)); // Early returns out of this method leave the BMH in an unfinished state. - assert(java_dyn_MethodHandle::vmentry(mh()) == NULL, "must be safely null"); + assert(java_lang_invoke_MethodHandle::vmentry(mh()) == NULL, "must be safely null"); if (target_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); } Handle target(THREAD, JNIHandles::resolve_non_null(target_jh)); - if (!java_dyn_MethodHandle::is_instance(target())) { + if (!java_lang_invoke_MethodHandle::is_instance(target())) { // Target object is a reflective method. (%%% Do we need this alternate path?) Untested("init_BMH of non-MH"); if (argnum != 0) { THROW(vmSymbols::java_lang_InternalError()); } @@ -2269,7 +2270,7 @@ JVM_END // adapter method handles -JVM_ENTRY(void, MHI_init_AMH(JNIEnv *env, jobject igcls, jobject mh_jh, +JVM_ENTRY(void, MHN_init_AMH(JNIEnv *env, jobject igcls, jobject mh_jh, jobject target_jh, int argnum)) { // This is the guy we are initializing: if (mh_jh == NULL || target_jh == NULL) { @@ -2279,14 +2280,14 @@ Handle target(THREAD, JNIHandles::resolve_non_null(target_jh)); // Early returns out of this method leave the AMH in an unfinished state. - assert(java_dyn_MethodHandle::vmentry(mh()) == NULL, "must be safely null"); + assert(java_lang_invoke_MethodHandle::vmentry(mh()) == NULL, "must be safely null"); MethodHandles::init_AdapterMethodHandle(mh, target, argnum, CHECK); } JVM_END // method type forms -JVM_ENTRY(void, MHI_init_MT(JNIEnv *env, jobject igcls, jobject erased_jh)) { +JVM_ENTRY(void, MHN_init_MT(JNIEnv *env, jobject igcls, jobject erased_jh)) { if (erased_jh == NULL) return; if (TraceMethodHandles) { tty->print("creating MethodType form "); @@ -2307,9 +2308,9 @@ JVM_END // debugging and reflection -JVM_ENTRY(jobject, MHI_getTarget(JNIEnv *env, jobject igcls, jobject mh_jh, jint format)) { +JVM_ENTRY(jobject, MHN_getTarget(JNIEnv *env, jobject igcls, jobject mh_jh, jint format)) { Handle mh(THREAD, JNIHandles::resolve(mh_jh)); - if (!java_dyn_MethodHandle::is_instance(mh())) { + if (!java_lang_invoke_MethodHandle::is_instance(mh())) { THROW_NULL(vmSymbols::java_lang_IllegalArgumentException()); } oop target = MethodHandles::encode_target(mh, format, CHECK_NULL); @@ -2317,7 +2318,7 @@ } JVM_END -JVM_ENTRY(jint, MHI_getConstant(JNIEnv *env, jobject igcls, jint which)) { +JVM_ENTRY(jint, MHN_getConstant(JNIEnv *env, jobject igcls, jint which)) { switch (which) { case MethodHandles::GC_JVM_PUSH_LIMIT: guarantee(MethodHandlePushLimit >= 2 && MethodHandlePushLimit <= 0xFF, @@ -2341,36 +2342,36 @@ template(MethodHandles,ETF_DIRECT_HANDLE) \ template(MethodHandles,ETF_METHOD_NAME) \ template(MethodHandles,ETF_REFLECT_METHOD) \ - template(sun_dyn_MemberName,MN_IS_METHOD) \ - template(sun_dyn_MemberName,MN_IS_CONSTRUCTOR) \ - template(sun_dyn_MemberName,MN_IS_FIELD) \ - template(sun_dyn_MemberName,MN_IS_TYPE) \ - template(sun_dyn_MemberName,MN_SEARCH_SUPERCLASSES) \ - template(sun_dyn_MemberName,MN_SEARCH_INTERFACES) \ - template(sun_dyn_MemberName,VM_INDEX_UNINITIALIZED) \ - template(sun_dyn_AdapterMethodHandle,OP_RETYPE_ONLY) \ - template(sun_dyn_AdapterMethodHandle,OP_RETYPE_RAW) \ - template(sun_dyn_AdapterMethodHandle,OP_CHECK_CAST) \ - template(sun_dyn_AdapterMethodHandle,OP_PRIM_TO_PRIM) \ - template(sun_dyn_AdapterMethodHandle,OP_REF_TO_PRIM) \ - template(sun_dyn_AdapterMethodHandle,OP_PRIM_TO_REF) \ - template(sun_dyn_AdapterMethodHandle,OP_SWAP_ARGS) \ - template(sun_dyn_AdapterMethodHandle,OP_ROT_ARGS) \ - template(sun_dyn_AdapterMethodHandle,OP_DUP_ARGS) \ - template(sun_dyn_AdapterMethodHandle,OP_DROP_ARGS) \ - template(sun_dyn_AdapterMethodHandle,OP_COLLECT_ARGS) \ - template(sun_dyn_AdapterMethodHandle,OP_SPREAD_ARGS) \ - template(sun_dyn_AdapterMethodHandle,OP_FLYBY) \ - template(sun_dyn_AdapterMethodHandle,OP_RICOCHET) \ - template(sun_dyn_AdapterMethodHandle,CONV_OP_LIMIT) \ - template(sun_dyn_AdapterMethodHandle,CONV_OP_MASK) \ - template(sun_dyn_AdapterMethodHandle,CONV_VMINFO_MASK) \ - template(sun_dyn_AdapterMethodHandle,CONV_VMINFO_SHIFT) \ - template(sun_dyn_AdapterMethodHandle,CONV_OP_SHIFT) \ - template(sun_dyn_AdapterMethodHandle,CONV_DEST_TYPE_SHIFT) \ - template(sun_dyn_AdapterMethodHandle,CONV_SRC_TYPE_SHIFT) \ - template(sun_dyn_AdapterMethodHandle,CONV_STACK_MOVE_SHIFT) \ - template(sun_dyn_AdapterMethodHandle,CONV_STACK_MOVE_MASK) \ + template(java_lang_invoke_MemberName,MN_IS_METHOD) \ + template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \ + template(java_lang_invoke_MemberName,MN_IS_FIELD) \ + template(java_lang_invoke_MemberName,MN_IS_TYPE) \ + template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \ + template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \ + template(java_lang_invoke_MemberName,VM_INDEX_UNINITIALIZED) \ + template(java_lang_invoke_AdapterMethodHandle,OP_RETYPE_ONLY) \ + template(java_lang_invoke_AdapterMethodHandle,OP_RETYPE_RAW) \ + template(java_lang_invoke_AdapterMethodHandle,OP_CHECK_CAST) \ + template(java_lang_invoke_AdapterMethodHandle,OP_PRIM_TO_PRIM) \ + template(java_lang_invoke_AdapterMethodHandle,OP_REF_TO_PRIM) \ + template(java_lang_invoke_AdapterMethodHandle,OP_PRIM_TO_REF) \ + template(java_lang_invoke_AdapterMethodHandle,OP_SWAP_ARGS) \ + template(java_lang_invoke_AdapterMethodHandle,OP_ROT_ARGS) \ + template(java_lang_invoke_AdapterMethodHandle,OP_DUP_ARGS) \ + template(java_lang_invoke_AdapterMethodHandle,OP_DROP_ARGS) \ + template(java_lang_invoke_AdapterMethodHandle,OP_COLLECT_ARGS) \ + template(java_lang_invoke_AdapterMethodHandle,OP_SPREAD_ARGS) \ + template(java_lang_invoke_AdapterMethodHandle,OP_FLYBY) \ + template(java_lang_invoke_AdapterMethodHandle,OP_RICOCHET) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_OP_LIMIT) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_OP_MASK) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_VMINFO_MASK) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_VMINFO_SHIFT) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_OP_SHIFT) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_DEST_TYPE_SHIFT) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_SRC_TYPE_SHIFT) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_STACK_MOVE_SHIFT) \ + template(java_lang_invoke_AdapterMethodHandle,CONV_STACK_MOVE_MASK) \ /*end*/ #define ONE_PLUS(scope,value) 1+ @@ -2386,7 +2387,7 @@ #undef EACH_NAMED_CON #endif -JVM_ENTRY(jint, MHI_getNamedCon(JNIEnv *env, jobject igcls, jint which, jobjectArray box_jh)) { +JVM_ENTRY(jint, MHN_getNamedCon(JNIEnv *env, jobject igcls, jint which, jobjectArray box_jh)) { #ifndef PRODUCT if (which >= 0 && which < con_value_count) { int con = con_values[which]; @@ -2406,7 +2407,7 @@ JVM_END // void init(MemberName self, AccessibleObject ref) -JVM_ENTRY(void, MHI_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobject target_jh)) { +JVM_ENTRY(void, MHN_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobject target_jh)) { if (mname_jh == NULL || target_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); } Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); oop target_oop = JNIHandles::resolve_non_null(target_jh); @@ -2415,7 +2416,7 @@ JVM_END // void expand(MemberName self) -JVM_ENTRY(void, MHI_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) { +JVM_ENTRY(void, MHN_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) { if (mname_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); } Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); MethodHandles::expand_MemberName(mname, 0, CHECK); @@ -2423,14 +2424,14 @@ JVM_END // void resolve(MemberName self, Class caller) -JVM_ENTRY(void, MHI_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jclass caller_jh)) { +JVM_ENTRY(void, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jclass caller_jh)) { if (mname_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); } Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); // The trusted Java code that calls this method should already have performed // access checks on behalf of the given caller. But, we can verify this. if (VerifyMethodHandles && caller_jh != NULL) { - klassOop reference_klass = java_lang_Class::as_klassOop(sun_dyn_MemberName::clazz(mname())); + klassOop reference_klass = java_lang_Class::as_klassOop(java_lang_invoke_MemberName::clazz(mname())); if (reference_klass != NULL) { // Emulate LinkResolver::check_klass_accessability. klassOop caller = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(caller_jh)); @@ -2448,7 +2449,7 @@ // static native int getMembers(Class defc, String matchName, String matchSig, // int matchFlags, Class caller, int skip, MemberName[] results); -JVM_ENTRY(jint, MHI_getMembers(JNIEnv *env, jobject igcls, +JVM_ENTRY(jint, MHN_getMembers(JNIEnv *env, jobject igcls, jclass clazz_jh, jstring name_jh, jstring sig_jh, int mflags, jclass caller_jh, jint skip, jobjectArray results_jh)) { if (clazz_jh == NULL || results_jh == NULL) return -1; @@ -2487,14 +2488,14 @@ } JVM_END -JVM_ENTRY(void, MHI_registerBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh, jobject bsm_jh)) { +JVM_ENTRY(void, MHN_registerBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh, jobject bsm_jh)) { instanceKlassHandle ik = MethodHandles::resolve_instance_klass(caller_jh, THREAD); if (!AllowTransitionalJSR292) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "registerBootstrapMethod is only supported in JSR 292 EDR"); } ik->link_class(CHECK); - if (!java_dyn_MethodHandle::is_instance(JNIHandles::resolve(bsm_jh))) { + if (!java_lang_invoke_MethodHandle::is_instance(JNIHandles::resolve(bsm_jh))) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "method handle"); } const char* err = NULL; @@ -2522,29 +2523,28 @@ } JVM_END -JVM_ENTRY(jobject, MHI_getBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh)) { +JVM_ENTRY(jobject, MHN_getBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh)) { + if (!AllowTransitionalJSR292) + THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "getBootstrap: transitional only"); instanceKlassHandle ik = MethodHandles::resolve_instance_klass(caller_jh, THREAD); return JNIHandles::make_local(THREAD, ik->bootstrap_method()); } JVM_END -JVM_ENTRY(void, MHI_setCallSiteTarget(JNIEnv *env, jobject igcls, jobject site_jh, jobject target_jh)) { - // No special action required, yet. - oop site_oop = JNIHandles::resolve(site_jh); - if (!java_dyn_CallSite::is_instance(site_oop)) - THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "not a CallSite"); - java_dyn_CallSite::set_target(site_oop, JNIHandles::resolve(target_jh)); +JVM_ENTRY(void, MHN_setCallSiteTarget(JNIEnv *env, jobject igcls, jobject site_jh, jobject target_jh)) { + if (!AllowTransitionalJSR292) + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "setCallSite: transitional only"); } JVM_END /// JVM_RegisterMethodHandleMethods -#define ADR "J" - #define LANG "Ljava/lang/" -#define JDYN "Ljava/dyn/" -#define IDYN "Lsun/dyn/" +#define JLINV "Ljava/lang/invoke/" /* standard package */ +#define JDYN "Ljava/dyn/" /* alternative package to JLINV if AllowTransitionalJSR292 */ +#define IDYN "Lsun/dyn/" /* alternative package to JDYN if AllowTransitionalJSR292 */ +// FIXME: After AllowTransitionalJSR292 is removed, replace JDYN and IDYN by JLINV. #define OBJ LANG"Object;" #define CLS LANG"Class;" @@ -2552,7 +2552,6 @@ #define CST JDYN"CallSite;" #define MT JDYN"MethodType;" #define MH JDYN"MethodHandle;" -#define MHI IDYN"MethodHandleImpl;" #define MEM IDYN"MemberName;" #define AMH IDYN"AdapterMethodHandle;" #define BMH IDYN"BoundMethodHandle;" @@ -2561,32 +2560,58 @@ #define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) -// These are the native methods on sun.dyn.MethodHandleNatives. +// These are the native methods on sun.invoke.MethodHandleNatives. static JNINativeMethod methods[] = { // void init(MemberName self, AccessibleObject ref) - {CC"init", CC"("AMH""MH"I)V", FN_PTR(MHI_init_AMH)}, - {CC"init", CC"("BMH""OBJ"I)V", FN_PTR(MHI_init_BMH)}, - {CC"init", CC"("DMH""OBJ"Z"CLS")V", FN_PTR(MHI_init_DMH)}, - {CC"init", CC"("MT")V", FN_PTR(MHI_init_MT)}, - {CC"init", CC"("MEM""OBJ")V", FN_PTR(MHI_init_Mem)}, - {CC"expand", CC"("MEM")V", FN_PTR(MHI_expand_Mem)}, - {CC"resolve", CC"("MEM""CLS")V", FN_PTR(MHI_resolve_Mem)}, - {CC"getTarget", CC"("MH"I)"OBJ, FN_PTR(MHI_getTarget)}, - {CC"getConstant", CC"(I)I", FN_PTR(MHI_getConstant)}, + {CC"init", CC"("AMH""MH"I)V", FN_PTR(MHN_init_AMH)}, + {CC"init", CC"("BMH""OBJ"I)V", FN_PTR(MHN_init_BMH)}, + {CC"init", CC"("DMH""OBJ"Z"CLS")V", FN_PTR(MHN_init_DMH)}, + {CC"init", CC"("MT")V", FN_PTR(MHN_init_MT)}, + {CC"init", CC"("MEM""OBJ")V", FN_PTR(MHN_init_Mem)}, + {CC"expand", CC"("MEM")V", FN_PTR(MHN_expand_Mem)}, + {CC"resolve", CC"("MEM""CLS")V", FN_PTR(MHN_resolve_Mem)}, + {CC"getTarget", CC"("MH"I)"OBJ, FN_PTR(MHN_getTarget)}, + {CC"getConstant", CC"(I)I", FN_PTR(MHN_getConstant)}, // static native int getNamedCon(int which, Object[] name) - {CC"getNamedCon", CC"(I["OBJ")I", FN_PTR(MHI_getNamedCon)}, + {CC"getNamedCon", CC"(I["OBJ")I", FN_PTR(MHN_getNamedCon)}, // static native int getMembers(Class defc, String matchName, String matchSig, // int matchFlags, Class caller, int skip, MemberName[] results); - {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHI_getMembers)} + {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} }; // More entry points specifically for EnableInvokeDynamic. +// FIXME: Remove methods2 after AllowTransitionalJSR292 is removed. static JNINativeMethod methods2[] = { - {CC"registerBootstrap", CC"("CLS MH")V", FN_PTR(MHI_registerBootstrap)}, - {CC"getBootstrap", CC"("CLS")"MH, FN_PTR(MHI_getBootstrap)}, - {CC"setCallSiteTarget", CC"("CST MH")V", FN_PTR(MHI_setCallSiteTarget)} + {CC"registerBootstrap", CC"("CLS MH")V", FN_PTR(MHN_registerBootstrap)}, + {CC"getBootstrap", CC"("CLS")"MH, FN_PTR(MHN_getBootstrap)}, + {CC"setCallSiteTarget", CC"("CST MH")V", FN_PTR(MHN_setCallSiteTarget)} }; +static void hack_signatures(JNINativeMethod* methods, jint num_methods, const char* from_sig, const char* to_sig) { + for (int i = 0; i < num_methods; i++) { + const char* sig = methods[i].signature; + if (!strstr(sig, from_sig)) continue; + size_t buflen = strlen(sig) + 100; + char* buf = NEW_C_HEAP_ARRAY(char, buflen); + char* bufp = buf; + const char* sigp = sig; + size_t from_len = strlen(from_sig), to_len = strlen(to_sig); + while (*sigp != '\0') { + assert(bufp < buf + buflen - to_len - 1, "oob"); + if (strncmp(sigp, from_sig, from_len) != 0) { + *bufp++ = *sigp++; + } else { + strcpy(bufp, to_sig); + bufp += to_len; + sigp += from_len; + } + } + *bufp = '\0'; + methods[i].signature = buf; // replace with new signature + if (TraceMethodHandles) + tty->print_cr("MethodHandleNatives: %s: change signature %s => %s", methods[i].name, sig, buf); + } +} // This one function is exported, used by NativeLookup. @@ -2600,45 +2625,78 @@ return; // bind nothing } + if (SystemDictionary::MethodHandleNatives_klass() != NULL && + SystemDictionary::MethodHandleNatives_klass() != java_lang_Class::as_klassOop(JNIHandles::resolve(MHN_class))) { + warning("multiple versions of MethodHandleNatives in boot classpath; consider using -XX:+PreferTransitionalJSR292"); + THROW_MSG(vmSymbols::java_lang_InternalError(), "multiple versions of MethodHandleNatives in boot classpath; consider using -XX:+PreferTransitionalJSR292"); + } + bool enable_MH = true; - { + // Loop control. FIXME: Replace by dead reckoning after AllowTransitionalJSR292 is removed. + bool registered_natives = false; + bool try_plain = true, try_JDYN = true, try_IDYN = true; + for (;;) { ThreadToNativeFromVM ttnfv(thread); + if (try_plain) { try_plain = false; } + else if (try_JDYN) { try_JDYN = false; hack_signatures(methods, sizeof(methods)/sizeof(JNINativeMethod), IDYN, JDYN); } + else if (try_IDYN) { try_IDYN = false; hack_signatures(methods, sizeof(methods)/sizeof(JNINativeMethod), JDYN, JLINV); } + else { break; } int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod)); if (env->ExceptionOccurred()) { - MethodHandles::set_enabled(false); - warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); - enable_MH = false; env->ExceptionClear(); + // and try again... + } else { + registered_natives = true; + break; } } + if (!registered_natives) { + MethodHandles::set_enabled(false); + warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); + enable_MH = false; + } if (enable_MH) { + bool found_raise_exception = false; + KlassHandle MHN_klass = SystemDictionaryHandles::MethodHandleNatives_klass(); KlassHandle MHI_klass = SystemDictionaryHandles::MethodHandleImpl_klass(); - if (MHI_klass.not_null()) { + // Loop control. FIXME: Replace by dead reckoning after AllowTransitionalJSR292 is removed. + bool try_MHN = true, try_MHI = AllowTransitionalJSR292; + for (;;) { + KlassHandle try_klass; + if (try_MHN) { try_MHN = false; try_klass = MHN_klass; } + else if (try_MHI) { try_MHI = false; try_klass = MHI_klass; } + else { break; } + if (try_klass.is_null()) continue; TempNewSymbol raiseException_name = SymbolTable::new_symbol("raiseException", CHECK); TempNewSymbol raiseException_sig = SymbolTable::new_symbol("(ILjava/lang/Object;Ljava/lang/Object;)V", CHECK); - methodOop raiseException_method = instanceKlass::cast(MHI_klass->as_klassOop()) + methodOop raiseException_method = instanceKlass::cast(try_klass->as_klassOop()) ->find_method(raiseException_name, raiseException_sig); if (raiseException_method != NULL && raiseException_method->is_static()) { MethodHandles::set_raise_exception_method(raiseException_method); - } else { - warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); - enable_MH = false; + found_raise_exception = true; + break; } - } else { + } + if (!found_raise_exception) { + warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); enable_MH = false; } } if (enable_MH) { - // We need to link the MethodHandleImpl klass before we generate - // the method handle adapters as the _raise_exception adapter uses - // one of its methods (and its c2i-adapter). - KlassHandle k = SystemDictionaryHandles::MethodHandleImpl_klass(); - instanceKlass* ik = instanceKlass::cast(k()); - ik->link_class(CHECK); + if (AllowTransitionalJSR292) { + // We need to link the MethodHandleImpl klass before we generate + // the method handle adapters as the _raise_exception adapter uses + // one of its methods (and its c2i-adapter). + klassOop k = SystemDictionary::MethodHandleImpl_klass(); + if (k != NULL) { + instanceKlass* ik = instanceKlass::cast(k); + ik->link_class(CHECK); + } + } MethodHandles::generate_adapters(); MethodHandles::set_enabled(true); @@ -2649,16 +2707,14 @@ return; // bind nothing } - { + if (AllowTransitionalJSR292) { ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); if (env->ExceptionOccurred()) { - MethodHandles::set_enabled(false); - warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); + // Don't do this, since it's too late: + // MethodHandles::set_enabled(false) env->ExceptionClear(); - } else { - MethodHandles::set_enabled(true); } } } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/prims/methodHandles.hpp --- a/src/share/vm/prims/methodHandles.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/prims/methodHandles.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -37,8 +37,8 @@ class MethodHandles: AllStatic { // JVM support for MethodHandle, MethodType, and related types - // in java.dyn and java.dyn.hotspot. - // See also javaClasses for layouts java_dyn_Method{Handle,Type,Type::Form}. + // in java.lang.invoke and sun.invoke. + // See also javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}. public: enum EntryKind { _raise_exception, // stub for error generation from other stubs @@ -54,21 +54,21 @@ _bound_long_direct_mh, _adapter_mh_first, // adapter sequence goes here... - _adapter_retype_only = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY, - _adapter_retype_raw = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW, - _adapter_check_cast = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_CHECK_CAST, - _adapter_prim_to_prim = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM, - _adapter_ref_to_prim = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM, - _adapter_prim_to_ref = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_REF, - _adapter_swap_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS, - _adapter_rot_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_ROT_ARGS, - _adapter_dup_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_DUP_ARGS, - _adapter_drop_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_DROP_ARGS, - _adapter_collect_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_COLLECT_ARGS, - _adapter_spread_args = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS, - _adapter_flyby = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_FLYBY, - _adapter_ricochet = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RICOCHET, - _adapter_mh_last = _adapter_mh_first + sun_dyn_AdapterMethodHandle::CONV_OP_LIMIT - 1, + _adapter_retype_only = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY, + _adapter_retype_raw = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW, + _adapter_check_cast = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST, + _adapter_prim_to_prim = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM, + _adapter_ref_to_prim = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM, + _adapter_prim_to_ref = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF, + _adapter_swap_args = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS, + _adapter_rot_args = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS, + _adapter_dup_args = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS, + _adapter_drop_args = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS, + _adapter_collect_args = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS, + _adapter_spread_args = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS, + _adapter_flyby = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_FLYBY, + _adapter_ricochet = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RICOCHET, + _adapter_mh_last = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT - 1, // Optimized adapter types @@ -107,16 +107,16 @@ static void set_enabled(bool z); private: - enum { // import sun_dyn_AdapterMethodHandle::CONV_OP_* - CONV_OP_LIMIT = sun_dyn_AdapterMethodHandle::CONV_OP_LIMIT, - CONV_OP_MASK = sun_dyn_AdapterMethodHandle::CONV_OP_MASK, - CONV_VMINFO_MASK = sun_dyn_AdapterMethodHandle::CONV_VMINFO_MASK, - CONV_VMINFO_SHIFT = sun_dyn_AdapterMethodHandle::CONV_VMINFO_SHIFT, - CONV_OP_SHIFT = sun_dyn_AdapterMethodHandle::CONV_OP_SHIFT, - CONV_DEST_TYPE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT, - CONV_SRC_TYPE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT, - CONV_STACK_MOVE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT, - CONV_STACK_MOVE_MASK = sun_dyn_AdapterMethodHandle::CONV_STACK_MOVE_MASK + enum { // import java_lang_invoke_AdapterMethodHandle::CONV_OP_* + CONV_OP_LIMIT = java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT, + CONV_OP_MASK = java_lang_invoke_AdapterMethodHandle::CONV_OP_MASK, + CONV_VMINFO_MASK = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_MASK, + CONV_VMINFO_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_SHIFT, + CONV_OP_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_OP_SHIFT, + CONV_DEST_TYPE_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT, + CONV_SRC_TYPE_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT, + CONV_STACK_MOVE_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT, + CONV_STACK_MOVE_MASK = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_MASK }; static bool _enabled; @@ -471,7 +471,7 @@ }; -// Access methods for the "entry" field of a java.dyn.MethodHandle. +// Access methods for the "entry" field of a java.lang.invoke.MethodHandle. // The field is primarily a jump target for compiled calls. // However, we squirrel away some nice pointers for other uses, // just before the jump target. diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/prims/nativeLookup.cpp --- a/src/share/vm/prims/nativeLookup.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/prims/nativeLookup.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,29 +107,30 @@ void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass); } +#define CC (char*) /* cast a literal from (const char*) */ +#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) + +static JNINativeMethod lookup_special_native_methods[] = { + // Next two functions only exist for compatibility with 1.3.1 and earlier. + { CC"Java_java_io_ObjectOutputStream_getPrimitiveFieldValues", NULL, FN_PTR(JVM_GetPrimitiveFieldValues) }, // intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization + { CC"Java_java_io_ObjectInputStream_setPrimitiveFieldValues", NULL, FN_PTR(JVM_SetPrimitiveFieldValues) }, // intercept ObjectInputStream setPrimitiveFieldValues for faster serialization + + { CC"Java_sun_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) }, + { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, + { CC"Java_sun_dyn_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, // AllowTransitionalJSR292 + { CC"Java_java_dyn_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, // AllowTransitionalJSR292 + { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) } +}; + static address lookup_special_native(char* jni_name) { - // NB: To ignore the jni prefix and jni postfix strstr is used matching. - if (!JDK_Version::is_gte_jdk14x_version()) { - // These functions only exist for compatibility with 1.3.1 and earlier - // Intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization - if (strstr(jni_name, "Java_java_io_ObjectOutputStream_getPrimitiveFieldValues") != NULL) { - return CAST_FROM_FN_PTR(address, JVM_GetPrimitiveFieldValues); - } - // Intercept ObjectInputStream setPrimitiveFieldValues for faster serialization - if (strstr(jni_name, "Java_java_io_ObjectInputStream_setPrimitiveFieldValues") != NULL) { - return CAST_FROM_FN_PTR(address, JVM_SetPrimitiveFieldValues); + int i = !JDK_Version::is_gte_jdk14x_version() ? 0 : 2; // see comment in lookup_special_native_methods + int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod); + for (; i < count; i++) { + // NB: To ignore the jni prefix and jni postfix strstr is used matching. + if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) { + return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr); } } - if (strstr(jni_name, "Java_sun_misc_Unsafe_registerNatives") != NULL) { - return CAST_FROM_FN_PTR(address, JVM_RegisterUnsafeMethods); - } - if (strstr(jni_name, "Java_sun_dyn_MethodHandleNatives_registerNatives") != NULL) { - return CAST_FROM_FN_PTR(address, JVM_RegisterMethodHandleMethods); - } - if (strstr(jni_name, "Java_sun_misc_Perf_registerNatives") != NULL) { - return CAST_FROM_FN_PTR(address, JVM_RegisterPerfMethods); - } - return NULL; } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/runtime/advancedThresholdPolicy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/runtime/advancedThresholdPolicy.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -0,0 +1,450 @@ +/* +* Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved. +* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +*/ + +#include "precompiled.hpp" +#include "runtime/advancedThresholdPolicy.hpp" +#include "runtime/simpleThresholdPolicy.inline.hpp" + +#ifdef TIERED +// Print an event. +void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh, + int bci, CompLevel level) { + tty->print(" rate: "); + if (mh->prev_time() == 0) tty->print("n/a"); + else tty->print("%f", mh->rate()); + + tty->print(" k: %.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback), + threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback)); + +} + +void AdvancedThresholdPolicy::initialize() { + // Turn on ergonomic compiler count selection + if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) { + FLAG_SET_DEFAULT(CICompilerCountPerCPU, true); + } + int count = CICompilerCount; + if (CICompilerCountPerCPU) { + // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n + int log_cpu = log2_intptr(os::active_processor_count()); + int loglog_cpu = log2_intptr(MAX2(log_cpu, 1)); + count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2; + } + + set_c1_count(MAX2(count / 3, 1)); + set_c2_count(MAX2(count - count / 3, 1)); + + // Some inlining tuning +#ifdef X86 + if (FLAG_IS_DEFAULT(InlineSmallCode)) { + FLAG_SET_DEFAULT(InlineSmallCode, 2000); + } +#endif + +#ifdef SPARC + if (FLAG_IS_DEFAULT(InlineSmallCode)) { + FLAG_SET_DEFAULT(InlineSmallCode, 2500); + } +#endif + + + set_start_time(os::javaTimeMillis()); +} + +// update_rate() is called from select_task() while holding a compile queue lock. +void AdvancedThresholdPolicy::update_rate(jlong t, methodOop m) { + if (is_old(m)) { + // We don't remove old methods from the queue, + // so we can just zero the rate. + m->set_rate(0); + return; + } + + // We don't update the rate if we've just came out of a safepoint. + // delta_s is the time since last safepoint in milliseconds. + jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint(); + jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement + // How many events were there since the last time? + int event_count = m->invocation_count() + m->backedge_count(); + int delta_e = event_count - m->prev_event_count(); + + // We should be running for at least 1ms. + if (delta_s >= TieredRateUpdateMinTime) { + // And we must've taken the previous point at least 1ms before. + if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) { + m->set_prev_time(t); + m->set_prev_event_count(event_count); + m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond + } else + if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) { + // If nothing happened for 25ms, zero the rate. Don't modify prev values. + m->set_rate(0); + } + } +} + +// Check if this method has been stale from a given number of milliseconds. +// See select_task(). +bool AdvancedThresholdPolicy::is_stale(jlong t, jlong timeout, methodOop m) { + jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint(); + jlong delta_t = t - m->prev_time(); + if (delta_t > timeout && delta_s > timeout) { + int event_count = m->invocation_count() + m->backedge_count(); + int delta_e = event_count - m->prev_event_count(); + // Return true if there were no events. + return delta_e == 0; + } + return false; +} + +// We don't remove old methods from the compile queue even if they have +// very low activity. See select_task(). +bool AdvancedThresholdPolicy::is_old(methodOop method) { + return method->invocation_count() > 50000 || method->backedge_count() > 500000; +} + +double AdvancedThresholdPolicy::weight(methodOop method) { + return (method->rate() + 1) * ((method->invocation_count() + 1) * (method->backedge_count() + 1)); +} + +// Apply heuristics and return true if x should be compiled before y +bool AdvancedThresholdPolicy::compare_methods(methodOop x, methodOop y) { + if (x->highest_comp_level() > y->highest_comp_level()) { + // recompilation after deopt + return true; + } else + if (x->highest_comp_level() == y->highest_comp_level()) { + if (weight(x) > weight(y)) { + return true; + } + } + return false; +} + +// Is method profiled enough? +bool AdvancedThresholdPolicy::is_method_profiled(methodOop method) { + methodDataOop mdo = method->method_data(); + if (mdo != NULL) { + int i = mdo->invocation_count_delta(); + int b = mdo->backedge_count_delta(); + return call_predicate_helper(i, b, 1); + } + return false; +} + +// Called with the queue locked and with at least one element +CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) { + CompileTask *max_task = NULL; + methodOop max_method; + jlong t = os::javaTimeMillis(); + // Iterate through the queue and find a method with a maximum rate. + for (CompileTask* task = compile_queue->first(); task != NULL;) { + CompileTask* next_task = task->next(); + methodOop method = (methodOop)JNIHandles::resolve(task->method_handle()); + methodDataOop mdo = method->method_data(); + update_rate(t, method); + if (max_task == NULL) { + max_task = task; + max_method = method; + } else { + // If a method has been stale for some time, remove it from the queue. + if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { + if (PrintTieredEvents) { + print_event(KILL, method, method, task->osr_bci(), (CompLevel)task->comp_level()); + } + CompileTaskWrapper ctw(task); // Frees the task + compile_queue->remove(task); + method->clear_queued_for_compilation(); + task = next_task; + continue; + } + + // Select a method with a higher rate + if (compare_methods(method, max_method)) { + max_task = task; + max_method = method; + } + } + task = next_task; + } + + if (max_task->comp_level() == CompLevel_full_profile && is_method_profiled(max_method)) { + max_task->set_comp_level(CompLevel_limited_profile); + if (PrintTieredEvents) { + print_event(UPDATE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); + } + } + + return max_task; +} + +double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) { + double queue_size = CompileBroker::queue_size(level); + int comp_count = compiler_count(level); + double k = queue_size / (feedback_k * comp_count) + 1; + return k; +} + +// Call and loop predicates determine whether a transition to a higher +// compilation level should be performed (pointers to predicate functions +// are passed to common()). +// Tier?LoadFeedback is basically a coefficient that determines of +// how many methods per compiler thread can be in the queue before +// the threshold values double. +bool AdvancedThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level) { + switch(cur_level) { + case CompLevel_none: + case CompLevel_limited_profile: { + double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); + return loop_predicate_helper(i, b, k); + } + case CompLevel_full_profile: { + double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback); + return loop_predicate_helper(i, b, k); + } + default: + return true; + } +} + +bool AdvancedThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level) { + switch(cur_level) { + case CompLevel_none: + case CompLevel_limited_profile: { + double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); + return call_predicate_helper(i, b, k); + } + case CompLevel_full_profile: { + double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback); + return call_predicate_helper(i, b, k); + } + default: + return true; + } +} + +// If a method is old enough and is still in the interpreter we would want to +// start profiling without waiting for the compiled method to arrive. +// We also take the load on compilers into the account. +bool AdvancedThresholdPolicy::should_create_mdo(methodOop method, CompLevel cur_level) { + if (cur_level == CompLevel_none && + CompileBroker::queue_size(CompLevel_full_optimization) <= + Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { + int i = method->invocation_count(); + int b = method->backedge_count(); + double k = Tier0ProfilingStartPercentage / 100.0; + return call_predicate_helper(i, b, k) || loop_predicate_helper(i, b, k); + } + return false; +} + +// Create MDO if necessary. +void AdvancedThresholdPolicy::create_mdo(methodHandle mh, TRAPS) { + if (mh->is_native() || mh->is_abstract() || mh->is_accessor()) return; + if (mh->method_data() == NULL) { + methodOopDesc::build_interpreter_method_data(mh, THREAD); + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + } + } +} + + +/* + * Method states: + * 0 - interpreter (CompLevel_none) + * 1 - pure C1 (CompLevel_simple) + * 2 - C1 with invocation and backedge counting (CompLevel_limited_profile) + * 3 - C1 with full profiling (CompLevel_full_profile) + * 4 - C2 (CompLevel_full_optimization) + * + * Common state transition patterns: + * a. 0 -> 3 -> 4. + * The most common path. But note that even in this straightforward case + * profiling can start at level 0 and finish at level 3. + * + * b. 0 -> 2 -> 3 -> 4. + * This case occures when the load on C2 is deemed too high. So, instead of transitioning + * into state 3 directly and over-profiling while a method is in the C2 queue we transition to + * level 2 and wait until the load on C2 decreases. This path is disabled for OSRs. + * + * c. 0 -> (3->2) -> 4. + * In this case we enqueue a method for compilation at level 3, but the C1 queue is long enough + * to enable the profiling to fully occur at level 0. In this case we change the compilation level + * of the method to 2, because it'll allow it to run much faster without full profiling while c2 + * is compiling. + * + * d. 0 -> 3 -> 1 or 0 -> 2 -> 1. + * After a method was once compiled with C1 it can be identified as trivial and be compiled to + * level 1. These transition can also occur if a method can't be compiled with C2 but can with C1. + * + * e. 0 -> 4. + * This can happen if a method fails C1 compilation (it will still be profiled in the interpreter) + * or because of a deopt that didn't require reprofiling (compilation won't happen in this case because + * the compiled version already exists). + * + * Note that since state 0 can be reached from any other state via deoptimization different loops + * are possible. + * + */ + +// Common transition function. Given a predicate determines if a method should transition to another level. +CompLevel AdvancedThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) { + if (is_trivial(method)) return CompLevel_simple; + + CompLevel next_level = cur_level; + int i = method->invocation_count(); + int b = method->backedge_count(); + + switch(cur_level) { + case CompLevel_none: + // If we were at full profile level, would we switch to full opt? + if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) { + next_level = CompLevel_full_optimization; + } else if ((this->*p)(i, b, cur_level)) { + // C1-generated fully profiled code is about 30% slower than the limited profile + // code that has only invocation and backedge counters. The observation is that + // if C2 queue is large enough we can spend too much time in the fully profiled code + // while waiting for C2 to pick the method from the queue. To alleviate this problem + // we introduce a feedback on the C2 queue size. If the C2 queue is sufficiently long + // we choose to compile a limited profiled version and then recompile with full profiling + // when the load on C2 goes down. + if (CompileBroker::queue_size(CompLevel_full_optimization) > + Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { + next_level = CompLevel_limited_profile; + } else { + next_level = CompLevel_full_profile; + } + } + break; + case CompLevel_limited_profile: + if (is_method_profiled(method)) { + // Special case: we got here because this method was fully profiled in the interpreter. + next_level = CompLevel_full_optimization; + } else { + methodDataOop mdo = method->method_data(); + if (mdo != NULL) { + if (mdo->would_profile()) { + if (CompileBroker::queue_size(CompLevel_full_optimization) <= + Tier3DelayOff * compiler_count(CompLevel_full_optimization) && + (this->*p)(i, b, cur_level)) { + next_level = CompLevel_full_profile; + } + } else { + next_level = CompLevel_full_optimization; + } + } + } + break; + case CompLevel_full_profile: + { + methodDataOop mdo = method->method_data(); + if (mdo != NULL) { + if (mdo->would_profile()) { + int mdo_i = mdo->invocation_count_delta(); + int mdo_b = mdo->backedge_count_delta(); + if ((this->*p)(mdo_i, mdo_b, cur_level)) { + next_level = CompLevel_full_optimization; + } + } else { + next_level = CompLevel_full_optimization; + } + } + } + break; + } + return next_level; +} + +// Determine if a method should be compiled with a normal entry point at a different level. +CompLevel AdvancedThresholdPolicy::call_event(methodOop method, CompLevel cur_level) { + CompLevel osr_level = (CompLevel) method->highest_osr_comp_level(); + CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level); + + // If OSR method level is greater than the regular method level, the levels should be + // equalized by raising the regular method level in order to avoid OSRs during each + // invocation of the method. + if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) { + methodDataOop mdo = method->method_data(); + guarantee(mdo != NULL, "MDO should not be NULL"); + if (mdo->invocation_count() >= 1) { + next_level = CompLevel_full_optimization; + } + } else { + next_level = MAX2(osr_level, next_level); + } + + return next_level; +} + +// Determine if we should do an OSR compilation of a given method. +CompLevel AdvancedThresholdPolicy::loop_event(methodOop method, CompLevel cur_level) { + if (cur_level == CompLevel_none) { + // If there is a live OSR method that means that we deopted to the interpreter + // for the transition. + CompLevel osr_level = (CompLevel)method->highest_osr_comp_level(); + if (osr_level > CompLevel_none) { + return osr_level; + } + } + return common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level); +} + +// Update the rate and submit compile +void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) { + int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); + update_rate(os::javaTimeMillis(), mh()); + CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD); +} + + +// Handle the invocation event. +void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, + CompLevel level, TRAPS) { + if (should_create_mdo(mh(), level)) { + create_mdo(mh, THREAD); + } + if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { + CompLevel next_level = call_event(mh(), level); + if (next_level != level) { + compile(mh, InvocationEntryBci, next_level, THREAD); + } + } +} + +// Handle the back branch event. Notice that we can compile the method +// with a regular entry from here. +void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, + int bci, CompLevel level, TRAPS) { + if (should_create_mdo(mh(), level)) { + create_mdo(mh, THREAD); + } + + // If the method is already compiling, quickly bail out. + if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) { + // Use loop event as an opportinity to also check there's been + // enough calls. + CompLevel cur_level = comp_level(mh()); + CompLevel next_level = call_event(mh(), cur_level); + CompLevel next_osr_level = loop_event(mh(), level); + if (next_osr_level == CompLevel_limited_profile) { + next_osr_level = CompLevel_full_profile; // OSRs are supposed to be for very hot methods. + } + next_level = MAX2(next_level, + next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level); + bool is_compiling = false; + if (next_level != cur_level) { + compile(mh, InvocationEntryBci, next_level, THREAD); + is_compiling = true; + } + + // Do the OSR version + if (!is_compiling && next_osr_level != level) { + compile(mh, bci, next_osr_level, THREAD); + } + } +} + +#endif // TIERED diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/runtime/advancedThresholdPolicy.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/runtime/advancedThresholdPolicy.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved. +* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +*/ + +#ifndef SHARE_VM_RUNTIME_ADVANCEDTHRESHOLDPOLICY_HPP +#define SHARE_VM_RUNTIME_ADVANCEDTHRESHOLDPOLICY_HPP + +#include "runtime/simpleThresholdPolicy.hpp" + +#ifdef TIERED +class CompileTask; +class CompileQueue; + +/* + * The system supports 5 execution levels: + * * level 0 - interpreter + * * level 1 - C1 with full optimization (no profiling) + * * level 2 - C1 with invocation and backedge counters + * * level 3 - C1 with full profiling (level 2 + MDO) + * * level 4 - C2 + * + * Levels 0, 2 and 3 periodically notify the runtime about the current value of the counters + * (invocation counters and backedge counters). The frequency of these notifications is + * different at each level. These notifications are used by the policy to decide what transition + * to make. + * + * Execution starts at level 0 (interpreter), then the policy can decide either to compile the + * method at level 3 or level 2. The decision is based on the following factors: + * 1. The length of the C2 queue determines the next level. The observation is that level 2 + * is generally faster than level 3 by about 30%, therefore we would want to minimize the time + * a method spends at level 3. We should only spend the time at level 3 that is necessary to get + * adequate profiling. So, if the C2 queue is long enough it is more beneficial to go first to + * level 2, because if we transitioned to level 3 we would be stuck there until our C2 compile + * request makes its way through the long queue. When the load on C2 recedes we are going to + * recompile at level 3 and start gathering profiling information. + * 2. The length of C1 queue is used to dynamically adjust the thresholds, so as to introduce + * additional filtering if the compiler is overloaded. The rationale is that by the time a + * method gets compiled it can become unused, so it doesn't make sense to put too much onto the + * queue. + * + * After profiling is completed at level 3 the transition is made to level 4. Again, the length + * of the C2 queue is used as a feedback to adjust the thresholds. + * + * After the first C1 compile some basic information is determined about the code like the number + * of the blocks and the number of the loops. Based on that it can be decided that a method + * is trivial and compiling it with C1 will yield the same code. In this case the method is + * compiled at level 1 instead of 4. + * + * We also support profiling at level 0. If C1 is slow enough to produce the level 3 version of + * the code and the C2 queue is sufficiently small we can decide to start profiling in the + * interpreter (and continue profiling in the compiled code once the level 3 version arrives). + * If the profiling at level 0 is fully completed before level 3 version is produced, a level 2 + * version is compiled instead in order to run faster waiting for a level 4 version. + * + * Compile queues are implemented as priority queues - for each method in the queue we compute + * the event rate (the number of invocation and backedge counter increments per unit of time). + * When getting an element off the queue we pick the one with the largest rate. Maintaining the + * rate also allows us to remove stale methods (the ones that got on the queue but stopped + * being used shortly after that). +*/ + +/* Command line options: + * - Tier?InvokeNotifyFreqLog and Tier?BackedgeNotifyFreqLog control the frequency of method + * invocation and backedge notifications. Basically every n-th invocation or backedge a mutator thread + * makes a call into the runtime. + * + * - Tier?CompileThreshold, Tier?BackEdgeThreshold, Tier?MinInvocationThreshold control + * compilation thresholds. + * Level 2 thresholds are not used and are provided for option-compatibility and potential future use. + * Other thresholds work as follows: + * + * Transition from interpreter (level 0) to C1 with full profiling (level 3) happens when + * the following predicate is true (X is the level): + * + * i > TierXInvocationThreshold * s || (i > TierXMinInvocationThreshold * s && i + b > TierXCompileThreshold * s), + * + * where $i$ is the number of method invocations, $b$ number of backedges and $s$ is the scaling + * coefficient that will be discussed further. + * The intuition is to equalize the time that is spend profiling each method. + * The same predicate is used to control the transition from level 3 to level 4 (C2). It should be + * noted though that the thresholds are relative. Moreover i and b for the 0->3 transition come + * from methodOop and for 3->4 transition they come from MDO (since profiled invocations are + * counted separately). + * + * OSR transitions are controlled simply with b > TierXBackEdgeThreshold * s predicates. + * + * - Tier?LoadFeedback options are used to automatically scale the predicates described above depending + * on the compiler load. The scaling coefficients are computed as follows: + * + * s = queue_size_X / (TierXLoadFeedback * compiler_count_X) + 1, + * + * where queue_size_X is the current size of the compiler queue of level X, and compiler_count_X + * is the number of level X compiler threads. + * + * Basically these parameters describe how many methods should be in the compile queue + * per compiler thread before the scaling coefficient increases by one. + * + * This feedback provides the mechanism to automatically control the flow of compilation requests + * depending on the machine speed, mutator load and other external factors. + * + * - Tier3DelayOn and Tier3DelayOff parameters control another important feedback loop. + * Consider the following observation: a method compiled with full profiling (level 3) + * is about 30% slower than a method at level 2 (just invocation and backedge counters, no MDO). + * Normally, the following transitions will occur: 0->3->4. The problem arises when the C2 queue + * gets congested and the 3->4 transition is delayed. While the method is the C2 queue it continues + * executing at level 3 for much longer time than is required by the predicate and at suboptimal speed. + * The idea is to dynamically change the behavior of the system in such a way that if a substantial + * load on C2 is detected we would first do the 0->2 transition allowing a method to run faster. + * And then when the load decreases to allow 2->3 transitions. + * + * Tier3Delay* parameters control this switching mechanism. + * Tier3DelayOn is the number of methods in the C2 queue per compiler thread after which the policy + * no longer does 0->3 transitions but does 0->2 transitions instead. + * Tier3DelayOff switches the original behavior back when the number of methods in the C2 queue + * per compiler thread falls below the specified amount. + * The hysteresis is necessary to avoid jitter. + * + * - TieredCompileTaskTimeout is the amount of time an idle method can spend in the compile queue. + * Basically, since we use the event rate d(i + b)/dt as a value of priority when selecting a method to + * compile from the compile queue, we also can detect stale methods for which the rate has been + * 0 for some time in the same iteration. Stale methods can appear in the queue when an application + * abruptly changes its behavior. + * + * - TieredStopAtLevel, is used mostly for testing. It allows to bypass the policy logic and stick + * to a given level. For example it's useful to set TieredStopAtLevel = 1 in order to compile everything + * with pure c1. + * + * - Tier0ProfilingStartPercentage allows the interpreter to start profiling when the inequalities in the + * 0->3 predicate are already exceeded by the given percentage but the level 3 version of the + * method is still not ready. We can even go directly from level 0 to 4 if c1 doesn't produce a compiled + * version in time. This reduces the overall transition to level 4 and decreases the startup time. + * Note that this behavior is also guarded by the Tier3Delay mechanism: when the c2 queue is too long + * these is not reason to start profiling prematurely. + * + * - TieredRateUpdateMinTime and TieredRateUpdateMaxTime are parameters of the rate computation. + * Basically, the rate is not computed more frequently than TieredRateUpdateMinTime and is considered + * to be zero if no events occurred in TieredRateUpdateMaxTime. + */ + + +class AdvancedThresholdPolicy : public SimpleThresholdPolicy { + jlong _start_time; + + // Call and loop predicates determine whether a transition to a higher compilation + // level should be performed (pointers to predicate functions are passed to common(). + // Predicates also take compiler load into account. + typedef bool (AdvancedThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level); + bool call_predicate(int i, int b, CompLevel cur_level); + bool loop_predicate(int i, int b, CompLevel cur_level); + // Common transition function. Given a predicate determines if a method should transition to another level. + CompLevel common(Predicate p, methodOop method, CompLevel cur_level); + // Transition functions. + // call_event determines if a method should be compiled at a different + // level with a regular invocation entry. + CompLevel call_event(methodOop method, CompLevel cur_level); + // loop_event checks if a method should be OSR compiled at a different + // level. + CompLevel loop_event(methodOop method, CompLevel cur_level); + // Has a method been long around? + // We don't remove old methods from the compile queue even if they have + // very low activity (see select_task()). + inline bool is_old(methodOop method); + // Was a given method inactive for a given number of milliseconds. + // If it is, we would remove it from the queue (see select_task()). + inline bool is_stale(jlong t, jlong timeout, methodOop m); + // Compute the weight of the method for the compilation scheduling + inline double weight(methodOop method); + // Apply heuristics and return true if x should be compiled before y + inline bool compare_methods(methodOop x, methodOop y); + // Compute event rate for a given method. The rate is the number of event (invocations + backedges) + // per millisecond. + inline void update_rate(jlong t, methodOop m); + // Compute threshold scaling coefficient + inline double threshold_scale(CompLevel level, int feedback_k); + // If a method is old enough and is still in the interpreter we would want to + // start profiling without waiting for the compiled method to arrive. This function + // determines whether we should do that. + inline bool should_create_mdo(methodOop method, CompLevel cur_level); + // Create MDO if necessary. + void create_mdo(methodHandle mh, TRAPS); + // Is method profiled enough? + bool is_method_profiled(methodOop method); + +protected: + void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level); + + void set_start_time(jlong t) { _start_time = t; } + jlong start_time() const { return _start_time; } + + // Submit a given method for compilation (and update the rate). + virtual void submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS); + // event() from SimpleThresholdPolicy would call these. + virtual void method_invocation_event(methodHandle method, methodHandle inlinee, + CompLevel level, TRAPS); + virtual void method_back_branch_event(methodHandle method, methodHandle inlinee, + int bci, CompLevel level, TRAPS); +public: + AdvancedThresholdPolicy() : _start_time(0) { } + // Select task is called by CompileBroker. We should return a task or NULL. + virtual CompileTask* select_task(CompileQueue* compile_queue); + virtual void initialize(); +}; + +#endif // TIERED + +#endif // SHARE_VM_RUNTIME_ADVANCEDTHRESHOLDPOLICY_HPP diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/runtime/arguments.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1026,8 +1026,9 @@ } void Arguments::set_tiered_flags() { + // With tiered, set default policy to AdvancedThresholdPolicy, which is 3. if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) { - FLAG_SET_DEFAULT(CompilationPolicyChoice, 2); + FLAG_SET_DEFAULT(CompilationPolicyChoice, 3); } if (CompilationPolicyChoice < 2) { vm_exit_during_initialization( diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/runtime/compilationPolicy.cpp --- a/src/share/vm/runtime/compilationPolicy.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/runtime/compilationPolicy.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #include "oops/methodOop.hpp" #include "oops/oop.inline.hpp" #include "prims/nativeLookup.hpp" +#include "runtime/advancedThresholdPolicy.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/frame.hpp" #include "runtime/handles.inline.hpp" @@ -72,8 +73,15 @@ Unimplemented(); #endif break; + case 3: +#ifdef TIERED + CompilationPolicy::set_policy(new AdvancedThresholdPolicy()); +#else + Unimplemented(); +#endif + break; default: - fatal("CompilationPolicyChoice must be in the range: [0-2]"); + fatal("CompilationPolicyChoice must be in the range: [0-3]"); } CompilationPolicy::policy()->initialize(); } diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/runtime/globals.hpp Fri Mar 18 01:44:15 2011 -0700 @@ -3719,6 +3719,13 @@ experimental(bool, AllowTransitionalJSR292, true, \ "recognize pre-PFD formats of invokedynamic") \ \ + experimental(bool, PreferTransitionalJSR292, false, \ + "prefer pre-PFD APIs on boot class path, if they exist") \ + \ + experimental(bool, AllowInvokeForInvokeGeneric, false, \ + "accept MethodHandle.invoke and MethodHandle.invokeGeneric " \ + "as equivalent methods") \ + \ develop(bool, TraceInvokeDynamic, false, \ "trace internal invoke dynamic operations") \ \ diff -r 2074c95f707e -r fc5ebbb2d1a8 src/share/vm/runtime/sweeper.cpp --- a/src/share/vm/runtime/sweeper.cpp Wed Mar 16 23:45:04 2011 -0400 +++ b/src/share/vm/runtime/sweeper.cpp Fri Mar 18 01:44:15 2011 -0700 @@ -426,9 +426,7 @@ tty->vprint(format, ap); va_end(ap); } - tty->print_cr(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" - " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'", - CodeCache::nof_blobs(), CodeCache::nof_nmethods(), CodeCache::nof_adapters(), CodeCache::unallocated_capacity()); + CodeCache::log_state(tty); tty->cr(); } if (LogCompilation && (xtty != NULL)) { @@ -440,9 +438,7 @@ xtty->vprint(format, ap); va_end(ap); } - xtty->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" - " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'", - CodeCache::nof_blobs(), CodeCache::nof_nmethods(), CodeCache::nof_adapters(), CodeCache::unallocated_capacity()); + CodeCache::log_state(xtty); xtty->stamp(); xtty->end_elem(); }