src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/share/vm/opto/library_call.cpp	Mon Mar 25 16:56:05 2013
--- new/src/share/vm/opto/library_call.cpp	Mon Mar 25 16:56:04 2013

*** 229,239 **** --- 229,238 ---- bool inline_array_copyOf(bool is_copyOfRange); bool inline_array_equals(); void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark); bool inline_native_clone(bool is_virtual); bool inline_native_Reflection_getCallerClass(); // Helper function for inlining native object hash method bool inline_native_hashcode(bool is_virtual, bool is_static); bool inline_native_getClass(); // Helper functions for inlining arraycopy
*** 391,401 **** --- 390,400 ---- return NULL; case vmIntrinsics::_getCallerClass: if (!UseNewReflection) return NULL; if (!InlineReflectionGetCallerClass) return NULL; ! if (!JDK_Version::is_gte_jdk14x_version()) return NULL; ! if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return NULL; break; case vmIntrinsics::_bitCount_i: if (!Matcher::match_rule_supported(Op_PopCountI)) return NULL; break;
*** 3870,4019 **** --- 3869,3961 ---- set_result(load_mirror_from_klass(load_object_klass(obj))); return true; } //-----------------inline_native_Reflection_getCallerClass--------------------- - // public static native Class<?> sun.reflect.Reflection.getCallerClass(int realFramesToSkip); // // In the presence of deep enough inlining, getCallerClass() becomes a no-op. // ! // NOTE that this code must perform the same logic as // vframeStream::security_get_caller_frame in that it must skip ! // Method.invoke() and auxiliary frames. ! // NOTE: This code must perform the same logic as JVM_GetCallerClass + // in that it must skip particular security frames and checks for ! // caller sensitive methods. bool LibraryCallKit::inline_native_Reflection_getCallerClass() { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass"); } #endif if (!jvms()->has_method()) { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { tty->print_cr(" Bailing out because intrinsic was inlined at top level"); } #endif return false; } // Walk back up the JVM state to find the caller at the required - // depth. NOTE that this code must perform the same logic as // vframeStream::security_get_caller_frame in that it must skip // Method.invoke() and auxiliary frames. Note also that depth is // 1-based (1 is the bottom of the inlining). int inlining_depth = _depth; JVMState* caller_jvms = NULL; if (inlining_depth > 0) { caller_jvms = jvms(); assert(caller_jvms = jvms()->of_depth(inlining_depth), "inlining_depth == our depth"); do { // The following if-tests should be performed in this order if (is_method_invoke_or_aux_frame(caller_jvms)) { // Skip a Method.invoke() or auxiliary frame } else if (caller_depth > 0) { // Skip real frame --caller_depth; } else { // We're done: reached desired caller after skipping. break; } caller_jvms = caller_jvms->caller(); --inlining_depth; } while (inlining_depth > 0); } + JVMState* caller_jvms = jvms(); if (inlining_depth == 0) { + // Cf. JVM_GetCallerClass + // NOTE: Start the loop at depth 1 because the current JVM state does + // not include the Reflection.getCallerClass() frame. + for (int n = 1; caller_jvms != NULL; caller_jvms = caller_jvms->caller(), n++) { + ciMethod* m = caller_jvms->method(); + switch (n) { + case 0: + fatal("current JVM state does not include the Reflection.getCallerClass frame"); + break; + case 1: + // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass). + if (!m->caller_sensitive()) { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { ! tty->print_cr(" Bailing out because caller depth (%d) exceeded inlining depth (%d)", caller_depth_type->get_con(), _depth); tty->print_cr(" JVM state at this point:"); for (int i = _depth; i >= 1; i--) { ciMethod* m = jvms()->of_depth(i)->method(); tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); } ! tty->print_cr(" Bailing out: CallerSensitive annotation expected at frame %d", n); } #endif return false; // Reached end of inlining + return false; // bail-out; let JVM_GetCallerClass do the work } // Acquire method holder as java.lang.Class + break; + default: + if (!m->is_ignored_by_security_stack_walk()) { + // We have reached the desired frame; return the holder class. + // Acquire method holder as java.lang.Class and push as constant. ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); ciInstance* caller_mirror = caller_klass->java_mirror(); set_result(makecon(TypeInstPtr::make(caller_mirror))); #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { ! tty->print_cr(" Succeeded: caller = %s.%s, caller depth = %d, depth = %d", caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), caller_depth_type->get_con(), _depth); ! tty->print_cr(" Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth()); tty->print_cr(" JVM state at this point:"); ! for (int i = _depth; i >= 1; i--) { ! for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { ciMethod* m = jvms()->of_depth(i)->method(); ! tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); ! tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); } } #endif return true; } + break; } } else if (method->is_method_handle_intrinsic() || method->is_compiled_lambda_form()) { // This is an internal adapter frame from the MethodHandleCompiler -- skip it ! return true; + + #ifndef PRODUCT + if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { ! tty->print_cr(" Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth()); + tty->print_cr(" JVM state at this point:"); + for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { + ciMethod* m = jvms()->of_depth(i)->method(); + tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); + } } + #endif ! return false; // bail-out; let JVM_GetCallerClass do the work } bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { Node* arg = argument(0); Node* result;

src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File