1 | /* |
2 | * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | * |
5 | * This code is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License version 2 only, as |
7 | * published by the Free Software Foundation. |
8 | * |
9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 | * version 2 for more details (a copy is included in the LICENSE file that |
13 | * accompanied this code). |
14 | * |
15 | * You should have received a copy of the GNU General Public License version |
16 | * 2 along with this work; if not, write to the Free Software Foundation, |
17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | * |
19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 | * or visit www.oracle.com if you need additional information or have any |
21 | * questions. |
22 | * |
23 | */ |
24 | |
25 | #include "precompiled.hpp" |
26 | #include "ci/ciInstance.hpp" |
27 | #include "ci/ciMethodType.hpp" |
28 | #include "ci/ciUtilities.inline.hpp" |
29 | #include "classfile/javaClasses.inline.hpp" |
30 | |
31 | ciType* ciMethodType::class_to_citype(oop klass_oop) const { |
32 | if (java_lang_Class::is_primitive(klass_oop)) { |
33 | BasicType bt = java_lang_Class::primitive_type(klass_oop); |
34 | return ciType::make(bt); |
35 | } else { |
36 | Klass* k = java_lang_Class::as_Klass(klass_oop); |
37 | return CURRENT_ENV->get_klass(k); |
38 | } |
39 | } |
40 | |
41 | ciType* ciMethodType::rtype() const { |
42 | GUARDED_VM_ENTRY( |
43 | oop rtype = java_lang_invoke_MethodType::rtype(get_oop()); |
44 | return class_to_citype(rtype); |
45 | ) |
46 | } |
47 | |
48 | int ciMethodType::ptype_count() const { |
49 | GUARDED_VM_ENTRY(return java_lang_invoke_MethodType::ptype_count(get_oop());) |
50 | } |
51 | |
52 | int ciMethodType::ptype_slot_count() const { |
53 | GUARDED_VM_ENTRY(return java_lang_invoke_MethodType::ptype_slot_count(get_oop());) |
54 | } |
55 | |
56 | ciType* ciMethodType::ptype_at(int index) const { |
57 | GUARDED_VM_ENTRY( |
58 | oop ptype = java_lang_invoke_MethodType::ptype(get_oop(), index); |
59 | return class_to_citype(ptype); |
60 | ) |
61 | } |
62 | |