Wed, 12 Oct 2011 21:00:13 -0700
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
Reviewed-by: jrose, never
twisti@1573 | 1 | /* |
jrose@2639 | 2 | * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
twisti@1573 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
twisti@1573 | 4 | * |
twisti@1573 | 5 | * This code is free software; you can redistribute it and/or modify it |
twisti@1573 | 6 | * under the terms of the GNU General Public License version 2 only, as |
twisti@1573 | 7 | * published by the Free Software Foundation. |
twisti@1573 | 8 | * |
twisti@1573 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
twisti@1573 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
twisti@1573 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
twisti@1573 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
twisti@1573 | 13 | * accompanied this code). |
twisti@1573 | 14 | * |
twisti@1573 | 15 | * You should have received a copy of the GNU General Public License version |
twisti@1573 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
twisti@1573 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
twisti@1573 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
twisti@1573 | 22 | * |
twisti@1573 | 23 | */ |
twisti@1573 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_CI_CIMETHODHANDLE_HPP |
stefank@2314 | 26 | #define SHARE_VM_CI_CIMETHODHANDLE_HPP |
stefank@2314 | 27 | |
twisti@2898 | 28 | #include "ci/ciCallProfile.hpp" |
stefank@2325 | 29 | #include "ci/ciInstance.hpp" |
stefank@2314 | 30 | #include "prims/methodHandles.hpp" |
stefank@2314 | 31 | |
twisti@1573 | 32 | // ciMethodHandle |
twisti@1573 | 33 | // |
jrose@2639 | 34 | // The class represents a java.lang.invoke.MethodHandle object. |
twisti@1573 | 35 | class ciMethodHandle : public ciInstance { |
twisti@1573 | 36 | private: |
twisti@2898 | 37 | ciMethod* _callee; |
twisti@2903 | 38 | ciMethod* _caller; |
never@2949 | 39 | ciCallProfile _profile; |
never@3105 | 40 | ciMethod* _method_handle_adapter; |
never@3105 | 41 | ciMethod* _invokedynamic_adapter; |
twisti@1573 | 42 | |
twisti@1573 | 43 | // Return an adapter for this MethodHandle. |
never@3105 | 44 | ciMethod* get_adapter_impl(bool is_invokedynamic); |
never@3105 | 45 | ciMethod* get_adapter( bool is_invokedynamic); |
twisti@1573 | 46 | |
twisti@1573 | 47 | protected: |
never@3105 | 48 | void print_chain_impl(outputStream* st) PRODUCT_RETURN; |
twisti@1573 | 49 | |
twisti@1573 | 50 | public: |
twisti@2903 | 51 | ciMethodHandle(instanceHandle h_i) : |
twisti@2903 | 52 | ciInstance(h_i), |
twisti@2903 | 53 | _callee(NULL), |
never@3105 | 54 | _caller(NULL), |
never@3105 | 55 | _method_handle_adapter(NULL), |
never@3105 | 56 | _invokedynamic_adapter(NULL) |
twisti@2903 | 57 | {} |
twisti@1573 | 58 | |
twisti@1573 | 59 | // What kind of ciObject is this? |
twisti@1573 | 60 | bool is_method_handle() const { return true; } |
twisti@1573 | 61 | |
twisti@2903 | 62 | void set_callee(ciMethod* m) { _callee = m; } |
twisti@2903 | 63 | void set_caller(ciMethod* m) { _caller = m; } |
never@2949 | 64 | void set_call_profile(ciCallProfile profile) { _profile = profile; } |
twisti@2898 | 65 | |
twisti@1573 | 66 | // Return an adapter for a MethodHandle call. |
never@3105 | 67 | ciMethod* get_method_handle_adapter() { |
never@3105 | 68 | if (_method_handle_adapter == NULL) { |
never@3105 | 69 | _method_handle_adapter = get_adapter(false); |
never@3105 | 70 | } |
never@3105 | 71 | return _method_handle_adapter; |
never@3105 | 72 | } |
twisti@1573 | 73 | |
twisti@1573 | 74 | // Return an adapter for an invokedynamic call. |
never@3105 | 75 | ciMethod* get_invokedynamic_adapter() { |
never@3105 | 76 | if (_invokedynamic_adapter == NULL) { |
never@3105 | 77 | _invokedynamic_adapter = get_adapter(true); |
never@3105 | 78 | } |
never@3105 | 79 | return _invokedynamic_adapter; |
never@3105 | 80 | } |
never@3105 | 81 | |
never@3105 | 82 | void print_chain(outputStream* st = tty) PRODUCT_RETURN; |
twisti@1573 | 83 | }; |
stefank@2314 | 84 | |
stefank@2314 | 85 | #endif // SHARE_VM_CI_CIMETHODHANDLE_HPP |