Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
40949 views
1
/*
2
* Copyright (c) 2011, 2020, 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
#ifndef SHARE_JVMCI_JVMCICOMPILERTOVM_HPP
25
#define SHARE_JVMCI_JVMCICOMPILERTOVM_HPP
26
27
#include "gc/shared/cardTable.hpp"
28
#include "jvmci/jvmciExceptions.hpp"
29
#include "runtime/javaCalls.hpp"
30
#include "runtime/signature.hpp"
31
32
class CollectedHeap;
33
class JVMCIObjectArray;
34
35
class CompilerToVM {
36
public:
37
class Data {
38
friend class JVMCIVMStructs;
39
40
private:
41
static int Klass_vtable_start_offset;
42
static int Klass_vtable_length_offset;
43
44
static int Method_extra_stack_entries;
45
46
static address SharedRuntime_ic_miss_stub;
47
static address SharedRuntime_handle_wrong_method_stub;
48
static address SharedRuntime_deopt_blob_unpack;
49
static address SharedRuntime_deopt_blob_unpack_with_exception_in_tls;
50
static address SharedRuntime_deopt_blob_uncommon_trap;
51
52
static size_t ThreadLocalAllocBuffer_alignment_reserve;
53
54
static CollectedHeap* Universe_collectedHeap;
55
static int Universe_base_vtable_size;
56
static address Universe_narrow_oop_base;
57
static int Universe_narrow_oop_shift;
58
static address Universe_narrow_klass_base;
59
static int Universe_narrow_klass_shift;
60
static uintptr_t Universe_verify_oop_mask;
61
static uintptr_t Universe_verify_oop_bits;
62
static void* Universe_non_oop_bits;
63
64
static bool _supports_inline_contig_alloc;
65
static HeapWord** _heap_end_addr;
66
static HeapWord* volatile* _heap_top_addr;
67
static int _max_oop_map_stack_offset;
68
static int _fields_annotations_base_offset;
69
70
static CardTable::CardValue* cardtable_start_address;
71
static int cardtable_shift;
72
73
static int vm_page_size;
74
75
static int sizeof_vtableEntry;
76
static int sizeof_ExceptionTableElement;
77
static int sizeof_LocalVariableTableElement;
78
static int sizeof_ConstantPool;
79
static int sizeof_narrowKlass;
80
static int sizeof_arrayOopDesc;
81
static int sizeof_BasicLock;
82
83
static address dsin;
84
static address dcos;
85
static address dtan;
86
static address dexp;
87
static address dlog;
88
static address dlog10;
89
static address dpow;
90
91
static address symbol_init;
92
static address symbol_clinit;
93
94
public:
95
static void initialize(JVMCI_TRAPS);
96
97
static int max_oop_map_stack_offset() {
98
assert(_max_oop_map_stack_offset > 0, "must be initialized");
99
return Data::_max_oop_map_stack_offset;
100
}
101
};
102
103
static bool cstring_equals(const char* const& s0, const char* const& s1) {
104
return strcmp(s0, s1) == 0;
105
}
106
107
static unsigned cstring_hash(const char* const& s) {
108
int h = 0;
109
const char* p = s;
110
while (*p != '\0') {
111
h = 31 * h + *p;
112
p++;
113
}
114
return h;
115
}
116
117
static JNINativeMethod methods[];
118
static JNINativeMethod jni_methods[];
119
120
static JVMCIObjectArray initialize_intrinsics(JVMCI_TRAPS);
121
public:
122
static int methods_count();
123
124
};
125
126
127
class JavaArgumentUnboxer : public SignatureIterator {
128
protected:
129
JavaCallArguments* _jca;
130
arrayOop _args;
131
int _index;
132
133
Handle next_arg(BasicType expectedType);
134
135
public:
136
JavaArgumentUnboxer(Symbol* signature,
137
JavaCallArguments* jca,
138
arrayOop args,
139
bool is_static)
140
: SignatureIterator(signature)
141
{
142
this->_return_type = T_ILLEGAL;
143
_jca = jca;
144
_index = 0;
145
_args = args;
146
if (!is_static) {
147
_jca->push_oop(next_arg(T_OBJECT));
148
}
149
do_parameters_on(this);
150
assert(_index == args->length(), "arg count mismatch with signature");
151
}
152
153
private:
154
friend class SignatureIterator; // so do_parameters_on can call do_type
155
void do_type(BasicType type) {
156
if (is_reference_type(type)) {
157
_jca->push_oop(next_arg(T_OBJECT));
158
return;
159
}
160
Handle arg = next_arg(type);
161
int box_offset = java_lang_boxing_object::value_offset(type);
162
switch (type) {
163
case T_BOOLEAN: _jca->push_int(arg->bool_field(box_offset)); break;
164
case T_CHAR: _jca->push_int(arg->char_field(box_offset)); break;
165
case T_SHORT: _jca->push_int(arg->short_field(box_offset)); break;
166
case T_BYTE: _jca->push_int(arg->byte_field(box_offset)); break;
167
case T_INT: _jca->push_int(arg->int_field(box_offset)); break;
168
case T_LONG: _jca->push_long(arg->long_field(box_offset)); break;
169
case T_FLOAT: _jca->push_float(arg->float_field(box_offset)); break;
170
case T_DOUBLE: _jca->push_double(arg->double_field(box_offset)); break;
171
default: ShouldNotReachHere();
172
}
173
}
174
};
175
176
class JNIHandleMark : public StackObj {
177
JavaThread* _thread;
178
public:
179
JNIHandleMark(JavaThread* thread) : _thread(thread) { push_jni_handle_block(thread); }
180
~JNIHandleMark() { pop_jni_handle_block(_thread); }
181
182
private:
183
static void push_jni_handle_block(JavaThread* thread);
184
static void pop_jni_handle_block(JavaThread* thread);
185
};
186
187
#endif // SHARE_JVMCI_JVMCICOMPILERTOVM_HPP
188
189