Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1/c1_GraphBuilder.cpp @ 12160:f98f5d48f511
7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
Summary: Do patching rather bailing out for unlinked call with appendix
Reviewed-by: twisti, kvn
author | roland |
---|---|
date | Wed, 21 Aug 2013 13:34:45 +0200 |
parents | b800986664f4 |
children | 59982ff9e0ec |
comparison
equal
deleted
inserted
replaced
12159:b17d8f6d9ed7 | 12160:f98f5d48f511 |
---|---|
1665 ciMethod* target = stream()->get_method(will_link, &declared_signature); | 1665 ciMethod* target = stream()->get_method(will_link, &declared_signature); |
1666 ciKlass* holder = stream()->get_declared_method_holder(); | 1666 ciKlass* holder = stream()->get_declared_method_holder(); |
1667 const Bytecodes::Code bc_raw = stream()->cur_bc_raw(); | 1667 const Bytecodes::Code bc_raw = stream()->cur_bc_raw(); |
1668 assert(declared_signature != NULL, "cannot be null"); | 1668 assert(declared_signature != NULL, "cannot be null"); |
1669 | 1669 |
1670 // FIXME bail out for now | 1670 if (!C1PatchInvokeDynamic && Bytecodes::has_optional_appendix(bc_raw) && !will_link) { |
1671 if (Bytecodes::has_optional_appendix(bc_raw) && !will_link) { | 1671 BAILOUT("unlinked call site (C1PatchInvokeDynamic is off)"); |
1672 BAILOUT("unlinked call site (FIXME needs patching or recompile support)"); | |
1673 } | 1672 } |
1674 | 1673 |
1675 // we have to make sure the argument size (incl. the receiver) | 1674 // we have to make sure the argument size (incl. the receiver) |
1676 // is correct for compilation (the call would fail later during | 1675 // is correct for compilation (the call would fail later during |
1677 // linkage anyway) - was bug (gri 7/28/99) | 1676 // linkage anyway) - was bug (gri 7/28/99) |
1711 break; | 1710 break; |
1712 case Bytecodes::_invokehandle: | 1711 case Bytecodes::_invokehandle: |
1713 code = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokespecial; | 1712 code = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokespecial; |
1714 break; | 1713 break; |
1715 } | 1714 } |
1715 } else { | |
1716 if (bc_raw == Bytecodes::_invokehandle) { | |
1717 assert(!will_link, "should come here only for unlinked call"); | |
1718 code = Bytecodes::_invokespecial; | |
1719 } | |
1716 } | 1720 } |
1717 | 1721 |
1718 // Push appendix argument (MethodType, CallSite, etc.), if one. | 1722 // Push appendix argument (MethodType, CallSite, etc.), if one. |
1719 if (stream()->has_appendix()) { | 1723 bool patch_for_appendix = false; |
1724 int patching_appendix_arg = 0; | |
1725 if (C1PatchInvokeDynamic && | |
1726 (Bytecodes::has_optional_appendix(bc_raw) && (!will_link || PatchALot))) { | |
1727 Value arg = append(new Constant(new ObjectConstant(compilation()->env()->unloaded_ciinstance()), copy_state_before())); | |
1728 apush(arg); | |
1729 patch_for_appendix = true; | |
1730 patching_appendix_arg = (will_link && stream()->has_appendix()) ? 0 : 1; | |
1731 } else if (stream()->has_appendix()) { | |
1720 ciObject* appendix = stream()->get_appendix(); | 1732 ciObject* appendix = stream()->get_appendix(); |
1721 Value arg = append(new Constant(new ObjectConstant(appendix))); | 1733 Value arg = append(new Constant(new ObjectConstant(appendix))); |
1722 apush(arg); | 1734 apush(arg); |
1723 } | 1735 } |
1724 | 1736 |
1730 ciMethod* exact_target = NULL; | 1742 ciMethod* exact_target = NULL; |
1731 Value better_receiver = NULL; | 1743 Value better_receiver = NULL; |
1732 if (UseCHA && DeoptC1 && klass->is_loaded() && target->is_loaded() && | 1744 if (UseCHA && DeoptC1 && klass->is_loaded() && target->is_loaded() && |
1733 !(// %%% FIXME: Are both of these relevant? | 1745 !(// %%% FIXME: Are both of these relevant? |
1734 target->is_method_handle_intrinsic() || | 1746 target->is_method_handle_intrinsic() || |
1735 target->is_compiled_lambda_form())) { | 1747 target->is_compiled_lambda_form()) && |
1748 !patch_for_appendix) { | |
1736 Value receiver = NULL; | 1749 Value receiver = NULL; |
1737 ciInstanceKlass* receiver_klass = NULL; | 1750 ciInstanceKlass* receiver_klass = NULL; |
1738 bool type_is_exact = false; | 1751 bool type_is_exact = false; |
1739 // try to find a precise receiver type | 1752 // try to find a precise receiver type |
1740 if (will_link && !target->is_static()) { | 1753 if (will_link && !target->is_static()) { |
1848 } | 1861 } |
1849 | 1862 |
1850 // check if we could do inlining | 1863 // check if we could do inlining |
1851 if (!PatchALot && Inline && klass->is_loaded() && | 1864 if (!PatchALot && Inline && klass->is_loaded() && |
1852 (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) | 1865 (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) |
1853 && target->is_loaded()) { | 1866 && target->is_loaded() |
1867 && !patch_for_appendix) { | |
1854 // callee is known => check if we have static binding | 1868 // callee is known => check if we have static binding |
1855 assert(target->is_loaded(), "callee must be known"); | 1869 assert(target->is_loaded(), "callee must be known"); |
1856 if (code == Bytecodes::_invokestatic || | 1870 if (code == Bytecodes::_invokestatic || |
1857 code == Bytecodes::_invokespecial || | 1871 code == Bytecodes::_invokespecial || |
1858 code == Bytecodes::_invokevirtual && target->is_final_method() || | 1872 code == Bytecodes::_invokevirtual && target->is_final_method() || |
1899 // The bytecode (code) might change in this method so we are checking this very late. | 1913 // The bytecode (code) might change in this method so we are checking this very late. |
1900 const bool has_receiver = | 1914 const bool has_receiver = |
1901 code == Bytecodes::_invokespecial || | 1915 code == Bytecodes::_invokespecial || |
1902 code == Bytecodes::_invokevirtual || | 1916 code == Bytecodes::_invokevirtual || |
1903 code == Bytecodes::_invokeinterface; | 1917 code == Bytecodes::_invokeinterface; |
1904 Values* args = state()->pop_arguments(target->arg_size_no_receiver()); | 1918 Values* args = state()->pop_arguments(target->arg_size_no_receiver() + patching_appendix_arg); |
1905 Value recv = has_receiver ? apop() : NULL; | 1919 Value recv = has_receiver ? apop() : NULL; |
1906 int vtable_index = Method::invalid_vtable_index; | 1920 int vtable_index = Method::invalid_vtable_index; |
1907 | 1921 |
1908 #ifdef SPARC | 1922 #ifdef SPARC |
1909 // Currently only supported on Sparc. | 1923 // Currently only supported on Sparc. |