|
1 /* |
|
2 * Copyright (c) 2017, 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 #ifndef SHARE_VM_JFR_JNI_JFRJAVACALL_HPP |
|
26 #define SHARE_VM_JFR_JNI_JFRJAVACALL_HPP |
|
27 |
|
28 #include "jni.h" |
|
29 #include "jfr/utilities/jfrAllocation.hpp" |
|
30 #include "utilities/exceptions.hpp" |
|
31 |
|
32 class JavaCallArguments; |
|
33 class JavaThread; |
|
34 class JavaValue; |
|
35 class Klass; |
|
36 class Symbol; |
|
37 |
|
38 class JfrJavaArguments : public StackObj { |
|
39 friend class JfrJavaCall; |
|
40 public: |
|
41 JfrJavaArguments(JavaValue* result); |
|
42 JfrJavaArguments(JavaValue* result, const char* klass_name, const char* name, const char* signature, TRAPS); |
|
43 JfrJavaArguments(JavaValue* result, const Klass* klass, const Symbol* name, const Symbol* signature); |
|
44 |
|
45 Klass* klass() const; |
|
46 void set_klass(const char* klass_name, TRAPS); |
|
47 void set_klass(const Klass* klass); |
|
48 |
|
49 Symbol* name() const; |
|
50 void set_name(const char* name, TRAPS); |
|
51 void set_name(const Symbol* name); |
|
52 |
|
53 Symbol* signature() const; |
|
54 void set_signature(const char* signature, TRAPS); |
|
55 void set_signature(const Symbol* signature); |
|
56 |
|
57 int array_length() const; |
|
58 void set_array_length(int length); |
|
59 |
|
60 JavaValue* result() const; |
|
61 |
|
62 bool has_receiver() const; |
|
63 void set_receiver(const oop receiver); |
|
64 void set_receiver(Handle receiver); |
|
65 oop receiver() const; |
|
66 |
|
67 // parameters |
|
68 void push_oop(const oop obj); |
|
69 void push_oop(Handle h_obj); |
|
70 void push_jobject(jobject h); |
|
71 void push_int(jint i); |
|
72 void push_double(jdouble d); |
|
73 void push_long(jlong l); |
|
74 void push_float(jfloat f); |
|
75 |
|
76 int length() const; |
|
77 const JavaValue& param(int idx) const; |
|
78 |
|
79 private: |
|
80 class Parameters { |
|
81 friend class JfrJavaArguments; |
|
82 private: |
|
83 enum { SIZE = 16}; |
|
84 JavaValue _storage[SIZE]; |
|
85 int _storage_index; |
|
86 int _java_stack_slots; |
|
87 |
|
88 Parameters(); |
|
89 Parameters(const Parameters&); // no impl |
|
90 Parameters& operator=(const Parameters&); // no impl |
|
91 |
|
92 void push(const JavaValue& value); |
|
93 void push_large(const JavaValue& value); |
|
94 |
|
95 void push_oop(const oop obj); |
|
96 void push_oop(Handle h_obj); |
|
97 void push_jobject(jobject h); |
|
98 void push_jint(jint i); |
|
99 void push_jdouble(jdouble d); |
|
100 void push_jlong(jlong l); |
|
101 void push_jfloat(jfloat f); |
|
102 |
|
103 bool has_receiver() const; |
|
104 void set_receiver(const oop receiver); |
|
105 void set_receiver(Handle receiver); |
|
106 oop receiver() const; |
|
107 |
|
108 int length() const; |
|
109 int java_stack_slots() const; |
|
110 |
|
111 void copy(JavaCallArguments& args, TRAPS) const; |
|
112 const JavaValue& values(int idx) const; |
|
113 }; |
|
114 |
|
115 Parameters _params; |
|
116 const JavaValue* const _result; |
|
117 const Klass* _klass; |
|
118 const Symbol* _name; |
|
119 const Symbol* _signature; |
|
120 int _array_length; |
|
121 |
|
122 int java_call_arg_slots() const; |
|
123 void copy(JavaCallArguments& args, TRAPS); |
|
124 }; |
|
125 |
|
126 class JfrJavaCall : public AllStatic { |
|
127 friend class JfrJavaSupport; |
|
128 private: |
|
129 static void call_static(JfrJavaArguments* args, TRAPS); |
|
130 static void call_special(JfrJavaArguments* args, TRAPS); |
|
131 static void call_virtual(JfrJavaArguments* args, TRAPS); |
|
132 }; |
|
133 |
|
134 #endif // SHARE_VM_JFR_JNI_JFRJAVACALL_HPP |