# HG changeset patch # User rottenha # Date 1298961301 28800 # Node ID cef8c988e7b8e2caf660b6bc482469e67df471fc # Parent 23ae54207126266d2a10e028366c976d09dfb3fc# Parent c1a6154012c8f926f8327b3cff6ea6d515f558a0 Merge diff -r 23ae54207126 -r cef8c988e7b8 src/share/vm/classfile/stackMapFrame.cpp --- a/src/share/vm/classfile/stackMapFrame.cpp Mon Feb 28 15:35:45 2011 -0800 +++ b/src/share/vm/classfile/stackMapFrame.cpp Mon Feb 28 22:35:01 2011 -0800 @@ -170,6 +170,44 @@ return true; } +bool StackMapFrame::has_flag_match_exception( + const StackMapFrame* target) const { + // We allow flags of {UninitThis} to assign to {} if-and-only-if the + // target frame does not depend upon the current type. + // This is slightly too strict, as we need only enforce that the + // slots that were initialized by the (the things that were + // UninitializedThis before initialize_object() converted them) are unused. + // However we didn't save that information so we'll enforce this upon + // anything that might have been initialized. This is a rare situation + // and javac never generates code that would end up here, but some profilers + // (such as NetBeans) might, when adding exception handlers in + // methods to cover the invokespecial instruction. See 7020118. + + assert(max_locals() == target->max_locals() && + stack_size() == target->stack_size(), "StackMap sizes must match"); + + VerificationType top = VerificationType::top_type(); + VerificationType this_type = verifier()->current_type(); + + if (!flag_this_uninit() || target->flags() != 0) { + return false; + } + + for (int i = 0; i < target->locals_size(); ++i) { + if (locals()[i] == this_type && target->locals()[i] != top) { + return false; + } + } + + for (int i = 0; i < target->stack_size(); ++i) { + if (stack()[i] == this_type && target->stack()[i] != top) { + return false; + } + } + + return true; +} + bool StackMapFrame::is_assignable_to(const StackMapFrame* target, TRAPS) const { if (_max_locals != target->max_locals() || _stack_size != target->stack_size()) { return false; @@ -182,7 +220,9 @@ bool match_stack = is_assignable_to( _stack, target->stack(), _stack_size, CHECK_false); bool match_flags = (_flags | target->flags()) == target->flags(); - return (match_locals && match_stack && match_flags); + + return match_locals && match_stack && + (match_flags || has_flag_match_exception(target)); } VerificationType StackMapFrame::pop_stack_ex(VerificationType type, TRAPS) { diff -r 23ae54207126 -r cef8c988e7b8 src/share/vm/classfile/stackMapFrame.hpp --- a/src/share/vm/classfile/stackMapFrame.hpp Mon Feb 28 15:35:45 2011 -0800 +++ b/src/share/vm/classfile/stackMapFrame.hpp Mon Feb 28 22:35:01 2011 -0800 @@ -228,6 +228,8 @@ bool is_assignable_to( VerificationType* src, VerificationType* target, int32_t len, TRAPS) const; + bool has_flag_match_exception(const StackMapFrame* target) const; + // Debugging void print() const PRODUCT_RETURN; }; diff -r 23ae54207126 -r cef8c988e7b8 src/share/vm/classfile/verificationType.hpp --- a/src/share/vm/classfile/verificationType.hpp Mon Feb 28 15:35:45 2011 -0800 +++ b/src/share/vm/classfile/verificationType.hpp Mon Feb 28 22:35:01 2011 -0800 @@ -128,6 +128,7 @@ // Create verification types static VerificationType bogus_type() { return VerificationType(Bogus); } + static VerificationType top_type() { return bogus_type(); } // alias static VerificationType null_type() { return VerificationType(Null); } static VerificationType integer_type() { return VerificationType(Integer); } static VerificationType float_type() { return VerificationType(Float); }