jdk

Форк
0
/
jvmciCompilerToVMInit.cpp 
537 строк · 25.3 Кб
1
/*
2
 * Copyright (c) 2011, 2024, 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
// no precompiled headers
25
#ifdef COMPILER1
26
#include "c1/c1_Compiler.hpp"
27
#endif
28
#include "ci/ciUtilities.hpp"
29
#include "compiler/compiler_globals.hpp"
30
#include "compiler/oopMap.hpp"
31
#include "gc/shared/barrierSet.hpp"
32
#include "gc/shared/barrierSetAssembler.hpp"
33
#include "gc/shared/barrierSetNMethod.hpp"
34
#include "gc/shared/cardTable.hpp"
35
#include "gc/shared/collectedHeap.hpp"
36
#include "gc/shared/gc_globals.hpp"
37
#include "gc/shared/tlab_globals.hpp"
38
#if INCLUDE_ZGC
39
#include "gc/x/xBarrierSetRuntime.hpp"
40
#include "gc/x/xThreadLocalData.hpp"
41
#include "gc/z/zBarrierSetRuntime.hpp"
42
#include "gc/z/zThreadLocalData.hpp"
43
#endif
44
#include "jvmci/jvmciCompilerToVM.hpp"
45
#include "jvmci/jvmciEnv.hpp"
46
#include "jvmci/vmStructs_jvmci.hpp"
47
#include "memory/universe.hpp"
48
#include "oops/compressedOops.hpp"
49
#include "oops/klass.inline.hpp"
50
#include "prims/jvmtiExport.hpp"
51
#ifdef COMPILER2
52
#include "opto/c2compiler.hpp"
53
#endif
54
#include "runtime/flags/jvmFlag.hpp"
55
#include "runtime/sharedRuntime.hpp"
56
#include "runtime/stubRoutines.hpp"
57
#include "utilities/resourceHash.hpp"
58

59

60
int CompilerToVM::Data::Klass_vtable_start_offset;
61
int CompilerToVM::Data::Klass_vtable_length_offset;
62

63
int CompilerToVM::Data::Method_extra_stack_entries;
64

65
address CompilerToVM::Data::SharedRuntime_ic_miss_stub;
66
address CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub;
67
address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack;
68
address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack_with_exception_in_tls;
69
address CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap;
70
address CompilerToVM::Data::SharedRuntime_polling_page_return_handler;
71

72
address CompilerToVM::Data::nmethod_entry_barrier;
73
int CompilerToVM::Data::thread_disarmed_guard_value_offset;
74
int CompilerToVM::Data::thread_address_bad_mask_offset;
75

76
address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_oop_field_preloaded;
77
address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_weak_oop_field_preloaded;
78
address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_phantom_oop_field_preloaded;
79
address CompilerToVM::Data::ZBarrierSetRuntime_weak_load_barrier_on_oop_field_preloaded;
80
address CompilerToVM::Data::ZBarrierSetRuntime_weak_load_barrier_on_weak_oop_field_preloaded;
81
address CompilerToVM::Data::ZBarrierSetRuntime_weak_load_barrier_on_phantom_oop_field_preloaded;
82
address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_oop_array;
83
address CompilerToVM::Data::ZBarrierSetRuntime_clone;
84

85
address CompilerToVM::Data::ZPointerVectorLoadBadMask_address;
86
address CompilerToVM::Data::ZPointerVectorStoreBadMask_address;
87
address CompilerToVM::Data::ZPointerVectorStoreGoodMask_address;
88

89
bool CompilerToVM::Data::continuations_enabled;
90

91
#ifdef AARCH64
92
int CompilerToVM::Data::BarrierSetAssembler_nmethod_patching_type;
93
address CompilerToVM::Data::BarrierSetAssembler_patching_epoch_addr;
94
#endif
95

96
size_t CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve;
97

98
CollectedHeap* CompilerToVM::Data::Universe_collectedHeap;
99
int CompilerToVM::Data::Universe_base_vtable_size;
100
address CompilerToVM::Data::Universe_narrow_oop_base;
101
int CompilerToVM::Data::Universe_narrow_oop_shift;
102
address CompilerToVM::Data::Universe_narrow_klass_base;
103
int CompilerToVM::Data::Universe_narrow_klass_shift;
104
void* CompilerToVM::Data::Universe_non_oop_bits;
105
uintptr_t CompilerToVM::Data::Universe_verify_oop_mask;
106
uintptr_t CompilerToVM::Data::Universe_verify_oop_bits;
107

108
bool       CompilerToVM::Data::_supports_inline_contig_alloc;
109
HeapWord** CompilerToVM::Data::_heap_end_addr;
110
HeapWord* volatile* CompilerToVM::Data::_heap_top_addr;
111
int CompilerToVM::Data::_max_oop_map_stack_offset;
112
int CompilerToVM::Data::_fields_annotations_base_offset;
113

114
CardTable::CardValue* CompilerToVM::Data::cardtable_start_address;
115
int CompilerToVM::Data::cardtable_shift;
116

117
#ifdef X86
118
int CompilerToVM::Data::L1_line_size;
119
#endif
120

121
size_t CompilerToVM::Data::vm_page_size;
122

123
int CompilerToVM::Data::sizeof_vtableEntry = sizeof(vtableEntry);
124
int CompilerToVM::Data::sizeof_ExceptionTableElement = sizeof(ExceptionTableElement);
125
int CompilerToVM::Data::sizeof_LocalVariableTableElement = sizeof(LocalVariableTableElement);
126
int CompilerToVM::Data::sizeof_ConstantPool = sizeof(ConstantPool);
127
int CompilerToVM::Data::sizeof_narrowKlass = sizeof(narrowKlass);
128
int CompilerToVM::Data::sizeof_arrayOopDesc = sizeof(arrayOopDesc);
129
int CompilerToVM::Data::sizeof_BasicLock = sizeof(BasicLock);
130
#if INCLUDE_ZGC
131
int CompilerToVM::Data::sizeof_ZStoreBarrierEntry = sizeof(ZStoreBarrierEntry);
132
#endif
133

134
address CompilerToVM::Data::dsin;
135
address CompilerToVM::Data::dcos;
136
address CompilerToVM::Data::dtan;
137
address CompilerToVM::Data::dexp;
138
address CompilerToVM::Data::dlog;
139
address CompilerToVM::Data::dlog10;
140
address CompilerToVM::Data::dpow;
141

142
address CompilerToVM::Data::symbol_init;
143
address CompilerToVM::Data::symbol_clinit;
144

145
int CompilerToVM::Data::data_section_item_alignment;
146

147
JVMTI_ONLY( int* CompilerToVM::Data::_should_notify_object_alloc; )
148

149
void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
150
  Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset());
151
  Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset());
152

153
  Method_extra_stack_entries = Method::extra_stack_entries();
154

155
  SharedRuntime_ic_miss_stub = SharedRuntime::get_ic_miss_stub();
156
  SharedRuntime_handle_wrong_method_stub = SharedRuntime::get_handle_wrong_method_stub();
157
  SharedRuntime_deopt_blob_unpack = SharedRuntime::deopt_blob()->unpack();
158
  SharedRuntime_deopt_blob_unpack_with_exception_in_tls = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
159
  SharedRuntime_deopt_blob_uncommon_trap = SharedRuntime::deopt_blob()->uncommon_trap();
160
  SharedRuntime_polling_page_return_handler = SharedRuntime::polling_page_return_handler_blob()->entry_point();
161

162
  BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
163
  if (bs_nm != nullptr) {
164
    thread_disarmed_guard_value_offset = in_bytes(bs_nm->thread_disarmed_guard_value_offset());
165
    nmethod_entry_barrier = StubRoutines::method_entry_barrier();
166
    BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
167
    AARCH64_ONLY(BarrierSetAssembler_nmethod_patching_type = (int) bs_asm->nmethod_patching_type());
168
    AARCH64_ONLY(BarrierSetAssembler_patching_epoch_addr = bs_asm->patching_epoch_addr());
169
  }
170

171
#if INCLUDE_ZGC
172
  if (UseZGC) {
173
    if (ZGenerational) {
174
      ZPointerVectorLoadBadMask_address   = (address) &ZPointerVectorLoadBadMask;
175
      ZPointerVectorStoreBadMask_address  = (address) &ZPointerVectorStoreBadMask;
176
      ZPointerVectorStoreGoodMask_address = (address) &ZPointerVectorStoreGoodMask;
177
    } else {
178
      thread_address_bad_mask_offset = in_bytes(XThreadLocalData::address_bad_mask_offset());
179
      // Initialize the old names for compatibility.  The proper XBarrierSetRuntime names are
180
      // exported as addresses in vmStructs_jvmci.cpp as are the new ZBarrierSetRuntime names.
181
      ZBarrierSetRuntime_load_barrier_on_oop_field_preloaded              = XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr();
182
      ZBarrierSetRuntime_load_barrier_on_weak_oop_field_preloaded         = XBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded_addr();
183
      ZBarrierSetRuntime_load_barrier_on_phantom_oop_field_preloaded      = XBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded_addr();
184
      ZBarrierSetRuntime_weak_load_barrier_on_oop_field_preloaded         = XBarrierSetRuntime::weak_load_barrier_on_oop_field_preloaded_addr();
185
      ZBarrierSetRuntime_weak_load_barrier_on_weak_oop_field_preloaded    = XBarrierSetRuntime::weak_load_barrier_on_weak_oop_field_preloaded_addr();
186
      ZBarrierSetRuntime_weak_load_barrier_on_phantom_oop_field_preloaded = XBarrierSetRuntime::weak_load_barrier_on_phantom_oop_field_preloaded_addr();
187
      ZBarrierSetRuntime_load_barrier_on_oop_array                        = XBarrierSetRuntime::load_barrier_on_oop_array_addr();
188
      ZBarrierSetRuntime_clone                                            = XBarrierSetRuntime::clone_addr();
189
    }
190
  }
191
#endif
192

193
  continuations_enabled = Continuations::enabled();
194

195
  ThreadLocalAllocBuffer_alignment_reserve = ThreadLocalAllocBuffer::alignment_reserve();
196

197
  Universe_collectedHeap = Universe::heap();
198
  Universe_base_vtable_size = Universe::base_vtable_size();
199
  if (UseCompressedOops) {
200
    Universe_narrow_oop_base = CompressedOops::base();
201
    Universe_narrow_oop_shift = CompressedOops::shift();
202
  } else {
203
    Universe_narrow_oop_base = nullptr;
204
    Universe_narrow_oop_shift = 0;
205
  }
206
  if (UseCompressedClassPointers) {
207
    Universe_narrow_klass_base = CompressedKlassPointers::base();
208
    Universe_narrow_klass_shift = CompressedKlassPointers::shift();
209
  } else {
210
    Universe_narrow_klass_base = nullptr;
211
    Universe_narrow_klass_shift = 0;
212
  }
213
  Universe_non_oop_bits = Universe::non_oop_word();
214
  Universe_verify_oop_mask = Universe::verify_oop_mask();
215
  Universe_verify_oop_bits = Universe::verify_oop_bits();
216

217
  _supports_inline_contig_alloc = false;
218
  _heap_end_addr = (HeapWord**) -1;
219
  _heap_top_addr = (HeapWord* volatile*) -1;
220

221
  _max_oop_map_stack_offset = (OopMapValue::register_mask - VMRegImpl::stack2reg(0)->value()) * VMRegImpl::stack_slot_size;
222
  int max_oop_map_stack_index = _max_oop_map_stack_offset / VMRegImpl::stack_slot_size;
223
  assert(OopMapValue::legal_vm_reg_name(VMRegImpl::stack2reg(max_oop_map_stack_index)), "should be valid");
224
  assert(!OopMapValue::legal_vm_reg_name(VMRegImpl::stack2reg(max_oop_map_stack_index + 1)), "should be invalid");
225

226
  symbol_init = (address) vmSymbols::object_initializer_name();
227
  symbol_clinit = (address) vmSymbols::class_initializer_name();
228

229
  _fields_annotations_base_offset = Array<AnnotationArray*>::base_offset_in_bytes();
230

231
  data_section_item_alignment = relocInfo::addr_unit();
232

233
  JVMTI_ONLY( _should_notify_object_alloc = &JvmtiExport::_should_notify_object_alloc; )
234

235
  BarrierSet* bs = BarrierSet::barrier_set();
236
  if (bs->is_a(BarrierSet::CardTableBarrierSet)) {
237
    CardTable::CardValue* base = ci_card_table_address();
238
    assert(base != nullptr, "unexpected byte_map_base");
239
    cardtable_start_address = base;
240
    cardtable_shift = CardTable::card_shift();
241
  } else {
242
    // No card mark barriers
243
    cardtable_start_address = 0;
244
    cardtable_shift = 0;
245
  }
246

247
#ifdef X86
248
  L1_line_size = VM_Version::L1_line_size();
249
#endif
250

251
  vm_page_size = os::vm_page_size();
252

253
#define SET_TRIGFUNC(name)                                      \
254
  if (StubRoutines::name() != nullptr) {                        \
255
    name = StubRoutines::name();                                \
256
  } else {                                                      \
257
    name = CAST_FROM_FN_PTR(address, SharedRuntime::name);      \
258
  }
259

260
  SET_TRIGFUNC(dsin);
261
  SET_TRIGFUNC(dcos);
262
  SET_TRIGFUNC(dtan);
263
  SET_TRIGFUNC(dexp);
264
  SET_TRIGFUNC(dlog10);
265
  SET_TRIGFUNC(dlog);
266
  SET_TRIGFUNC(dpow);
267

268
#undef SET_TRIGFUNC
269
}
270

271
static jboolean is_c1_supported(vmIntrinsics::ID id){
272
    jboolean supported = false;
273
#ifdef COMPILER1
274
    supported = (jboolean) Compiler::is_intrinsic_supported(id);
275
#endif
276
    return supported;
277
}
278

279
static jboolean is_c2_supported(vmIntrinsics::ID id){
280
    jboolean supported = false;
281
#ifdef COMPILER2
282
    supported = (jboolean) C2Compiler::is_intrinsic_supported(id);
283
#endif
284
    return supported;
285
}
286

287
JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) {
288
  int len = vmIntrinsics::number_of_intrinsics() - 1; // Exclude vmIntrinsics::_none, which is 0
289
  JVMCIObjectArray vmIntrinsics = JVMCIENV->new_VMIntrinsicMethod_array(len, JVMCI_CHECK_NULL);
290
  int index = 0;
291
  vmSymbolID kls_sid = vmSymbolID::NO_SID;
292
  JVMCIObject kls_str;
293
#define VM_SYMBOL_TO_STRING(s) \
294
  JVMCIENV->create_string(vmSymbols::symbol_at(VM_SYMBOL_ENUM_NAME(s)), JVMCI_CHECK_NULL)
295
#define VM_INTRINSIC_INFO(id, kls, name, sig, ignore_fcode) {            \
296
    vmSymbolID sid = VM_SYMBOL_ENUM_NAME(kls);                           \
297
    if (kls_sid != sid) {                                                \
298
      kls_str = VM_SYMBOL_TO_STRING(kls);                                \
299
      kls_sid = sid;                                                     \
300
    }                                                                    \
301
    JVMCIObject name_str = VM_SYMBOL_TO_STRING(name);                    \
302
    JVMCIObject sig_str = VM_SYMBOL_TO_STRING(sig);                      \
303
    JVMCIObject vmIntrinsicMethod = JVMCIENV->new_VMIntrinsicMethod(kls_str, name_str, sig_str, (jint) vmIntrinsics::id, \
304
                                    (jboolean) vmIntrinsics::is_intrinsic_available(vmIntrinsics::id),                   \
305
                                    is_c1_supported(vmIntrinsics::id),                       \
306
                                    is_c2_supported(vmIntrinsics::id), JVMCI_CHECK_NULL);    \
307
    JVMCIENV->put_object_at(vmIntrinsics, index++, vmIntrinsicMethod);   \
308
  }
309

310
  // VM_INTRINSICS_DO does *not* iterate over vmIntrinsics::_none
311
  VM_INTRINSICS_DO(VM_INTRINSIC_INFO, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE)
312
#undef VM_SYMBOL_TO_STRING
313
#undef VM_INTRINSIC_INFO
314

315
  assert(index == len, "must be");
316
  return vmIntrinsics;
317
}
318

319
#define PREDEFINED_CONFIG_FLAGS(do_bool_flag, do_int_flag, do_intx_flag, do_uintx_flag) \
320
  do_int_flag(AllocateInstancePrefetchLines)                               \
321
  do_int_flag(AllocatePrefetchDistance)                                    \
322
  do_intx_flag(AllocatePrefetchInstr)                                      \
323
  do_int_flag(AllocatePrefetchLines)                                       \
324
  do_int_flag(AllocatePrefetchStepSize)                                    \
325
  do_int_flag(AllocatePrefetchStyle)                                       \
326
  do_intx_flag(BciProfileWidth)                                            \
327
  do_bool_flag(BootstrapJVMCI)                                             \
328
  do_bool_flag(CITime)                                                     \
329
  do_bool_flag(CITimeEach)                                                 \
330
  do_uintx_flag(CodeCacheSegmentSize)                                      \
331
  do_intx_flag(CodeEntryAlignment)                                         \
332
  do_int_flag(ContendedPaddingWidth)                                       \
333
  do_bool_flag(DontCompileHugeMethods)                                     \
334
  do_bool_flag(EagerJVMCI)                                                 \
335
  do_bool_flag(EnableContended)                                            \
336
  do_bool_flag(FoldStableValues)                                           \
337
  do_bool_flag(ForceUnreachable)                                           \
338
  do_intx_flag(HugeMethodLimit)                                            \
339
  do_bool_flag(Inline)                                                     \
340
  do_intx_flag(JVMCICounterSize)                                           \
341
  do_bool_flag(JVMCIPrintProperties)                                       \
342
  do_int_flag(ObjectAlignmentInBytes)                                      \
343
  do_bool_flag(PrintInlining)                                              \
344
  do_bool_flag(ReduceInitialCardMarks)                                     \
345
  do_bool_flag(RestrictContended)                                          \
346
  do_intx_flag(StackReservedPages)                                         \
347
  do_intx_flag(StackShadowPages)                                           \
348
  do_uintx_flag(TLABWasteIncrement)                                        \
349
  do_intx_flag(TypeProfileWidth)                                           \
350
  do_bool_flag(UseAESIntrinsics)                                           \
351
  X86_ONLY(do_int_flag(UseAVX))                                            \
352
  do_bool_flag(UseCRC32Intrinsics)                                         \
353
  do_bool_flag(UseAdler32Intrinsics)                                       \
354
  do_bool_flag(UseCompressedClassPointers)                                 \
355
  do_bool_flag(UseCompressedOops)                                          \
356
  X86_ONLY(do_bool_flag(UseCountLeadingZerosInstruction))                  \
357
  X86_ONLY(do_bool_flag(UseCountTrailingZerosInstruction))                 \
358
  do_bool_flag(UseG1GC)                                                    \
359
  do_bool_flag(UseParallelGC)                                              \
360
  do_bool_flag(UseSerialGC)                                                \
361
  do_bool_flag(UseZGC)                                                     \
362
  do_bool_flag(UseEpsilonGC)                                               \
363
  COMPILER2_PRESENT(do_bool_flag(UseMontgomeryMultiplyIntrinsic))          \
364
  COMPILER2_PRESENT(do_bool_flag(UseMontgomerySquareIntrinsic))            \
365
  COMPILER2_PRESENT(do_bool_flag(UseMulAddIntrinsic))                      \
366
  COMPILER2_PRESENT(do_bool_flag(UseMultiplyToLenIntrinsic))               \
367
  do_bool_flag(UsePopCountInstruction)                                     \
368
  do_bool_flag(UseSHA1Intrinsics)                                          \
369
  do_bool_flag(UseSHA256Intrinsics)                                        \
370
  do_bool_flag(UseSHA512Intrinsics)                                        \
371
  X86_ONLY(do_int_flag(UseSSE))                                            \
372
  COMPILER2_PRESENT(do_bool_flag(UseSquareToLenIntrinsic))                 \
373
  do_bool_flag(UseTLAB)                                                    \
374
  do_bool_flag(VerifyOops)                                                 \
375
376
#define BOXED_BOOLEAN(name, value) name = ((jboolean)(value) ? boxedTrue : boxedFalse)
377
#define BOXED_DOUBLE(name, value) do { jvalue p; p.d = (jdouble) (value); name = JVMCIENV->create_box(T_DOUBLE, &p, JVMCI_CHECK_NULL);} while(0)
378
#define BOXED_LONG(name, value) \
379
  do { \
380
    jvalue p; p.j = (jlong) (value); \
381
    JVMCIObject* e = longs.get(p.j); \
382
    if (e == nullptr) { \
383
      JVMCIObject h = JVMCIENV->create_box(T_LONG, &p, JVMCI_CHECK_NULL); \
384
      longs.put(p.j, h); \
385
      name = h; \
386
    } else { \
387
      name = (*e); \
388
    } \
389
  } while (0)
390

391
#define CSTRING_TO_JSTRING(name, value) \
392
  JVMCIObject name; \
393
  do { \
394
    if (value != nullptr) { \
395
      JVMCIObject* e = strings.get(value); \
396
      if (e == nullptr) { \
397
        JVMCIObject h = JVMCIENV->create_string(value, JVMCI_CHECK_NULL); \
398
        strings.put(value, h); \
399
        name = h; \
400
      } else { \
401
        name = (*e); \
402
      } \
403
    } \
404
  } while (0)
405

406
jobjectArray readConfiguration0(JNIEnv *env, JVMCI_TRAPS) {
407
  JavaThread* THREAD = JavaThread::current(); // For exception macros.
408
  ResourceHashtable<jlong, JVMCIObject> longs;
409
  ResourceHashtable<const char*, JVMCIObject,
410
                    256, AnyObj::RESOURCE_AREA, mtInternal,
411
                    &CompilerToVM::cstring_hash, &CompilerToVM::cstring_equals> strings;
412

413
  jvalue prim;
414
  prim.z = true;  JVMCIObject boxedTrue =  JVMCIENV->create_box(T_BOOLEAN, &prim, JVMCI_CHECK_NULL);
415
  prim.z = false; JVMCIObject boxedFalse = JVMCIENV->create_box(T_BOOLEAN, &prim, JVMCI_CHECK_NULL);
416

417
  CompilerToVM::Data::initialize(JVMCI_CHECK_NULL);
418

419
  JVMCIENV->VMField_initialize(JVMCI_CHECK_NULL);
420
  JVMCIENV->VMFlag_initialize(JVMCI_CHECK_NULL);
421
  JVMCIENV->VMIntrinsicMethod_initialize(JVMCI_CHECK_NULL);
422

423
  int len = JVMCIVMStructs::localHotSpotVMStructs_count();
424
  JVMCIObjectArray vmFields = JVMCIENV->new_VMField_array(len, JVMCI_CHECK_NULL);
425
  for (int i = 0; i < len ; i++) {
426
    VMStructEntry vmField = JVMCIVMStructs::localHotSpotVMStructs[i];
427
    const size_t name_buf_size = strlen(vmField.typeName) + strlen(vmField.fieldName) + 2 + 1 /* "::" */;
428
    char* name_buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, name_buf_size);
429
    os::snprintf_checked(name_buf, name_buf_size, "%s::%s", vmField.typeName, vmField.fieldName);
430
    CSTRING_TO_JSTRING(name, name_buf);
431
    CSTRING_TO_JSTRING(type, vmField.typeString);
432
    JVMCIObject box;
433
    if (vmField.isStatic && vmField.typeString != nullptr) {
434
      if (strcmp(vmField.typeString, "bool") == 0) {
435
        BOXED_BOOLEAN(box, *(jbyte*) vmField.address);
436
        assert(box.is_non_null(), "must have a box");
437
      } else if (strcmp(vmField.typeString, "int") == 0 ||
438
                 strcmp(vmField.typeString, "jint") == 0 ||
439
                 strcmp(vmField.typeString, "uint") == 0 ||
440
                 strcmp(vmField.typeString, "uint32_t") == 0) {
441
        BOXED_LONG(box, *(jint*) vmField.address);
442
        assert(box.is_non_null(), "must have a box");
443
      } else if (strcmp(vmField.typeString, "uint64_t") == 0) {
444
        BOXED_LONG(box, *(uint64_t*) vmField.address);
445
        assert(box.is_non_null(), "must have a box");
446
      } else if (strcmp(vmField.typeString, "address") == 0 ||
447
                 strcmp(vmField.typeString, "intptr_t") == 0 ||
448
                 strcmp(vmField.typeString, "uintptr_t") == 0 ||
449
                 strcmp(vmField.typeString, "OopHandle") == 0 ||
450
                 strcmp(vmField.typeString, "size_t") == 0 ||
451
                 // All foo* types are addresses.
452
                 vmField.typeString[strlen(vmField.typeString) - 1] == '*') {
453
        BOXED_LONG(box, *((address*) vmField.address));
454
        assert(box.is_non_null(), "must have a box");
455
      } else {
456
        JVMCI_ERROR_NULL("VM field %s has unsupported type %s", name_buf, vmField.typeString);
457
      }
458
    }
459
    JVMCIObject vmFieldObj = JVMCIENV->new_VMField(name, type, vmField.offset, (jlong) vmField.address, box, JVMCI_CHECK_NULL);
460
    JVMCIENV->put_object_at(vmFields, i, vmFieldObj);
461
  }
462

463
  int ints_len = JVMCIVMStructs::localHotSpotVMIntConstants_count();
464
  int longs_len = JVMCIVMStructs::localHotSpotVMLongConstants_count();
465
  len = ints_len + longs_len;
466
  JVMCIObjectArray vmConstants = JVMCIENV->new_Object_array(len * 2, JVMCI_CHECK_NULL);
467
  int insert = 0;
468
  for (int i = 0; i < ints_len ; i++) {
469
    VMIntConstantEntry c = JVMCIVMStructs::localHotSpotVMIntConstants[i];
470
    CSTRING_TO_JSTRING(name, c.name);
471
    JVMCIObject value;
472
    BOXED_LONG(value, c.value);
473
    JVMCIENV->put_object_at(vmConstants, insert++, name);
474
    JVMCIENV->put_object_at(vmConstants, insert++, value);
475
  }
476
  for (int i = 0; i < longs_len ; i++) {
477
    VMLongConstantEntry c = JVMCIVMStructs::localHotSpotVMLongConstants[i];
478
    CSTRING_TO_JSTRING(name, c.name);
479
    JVMCIObject value;
480
    BOXED_LONG(value, c.value);
481
    JVMCIENV->put_object_at(vmConstants, insert++, name);
482
    JVMCIENV->put_object_at(vmConstants, insert++, value);
483
  }
484
  assert(insert == len * 2, "must be");
485

486
  len = JVMCIVMStructs::localHotSpotVMAddresses_count();
487
  JVMCIObjectArray vmAddresses = JVMCIENV->new_Object_array(len * 2, JVMCI_CHECK_NULL);
488
  for (int i = 0; i < len ; i++) {
489
    VMAddressEntry a = JVMCIVMStructs::localHotSpotVMAddresses[i];
490
    CSTRING_TO_JSTRING(name, a.name);
491
    JVMCIObject value;
492
    BOXED_LONG(value, a.value);
493
    JVMCIENV->put_object_at(vmAddresses, i * 2, name);
494
    JVMCIENV->put_object_at(vmAddresses, i * 2 + 1, value);
495
  }
496

497
#define COUNT_FLAG(ignore) +1
498
#ifdef ASSERT
499
#define CHECK_FLAG(type, name) { \
500
  const JVMFlag* flag = JVMFlag::find_declared_flag(#name); \
501
  assert(flag != nullptr, "No such flag named " #name); \
502
  assert(flag->is_##type(), "JVMFlag " #name " is not of type " #type); \
503
}
504
#else
505
#define CHECK_FLAG(type, name)
506
#endif
507

508
#define ADD_FLAG(type, name, convert) {                                                \
509
  CHECK_FLAG(type, name)                                                               \
510
  CSTRING_TO_JSTRING(fname, #name);                                                    \
511
  CSTRING_TO_JSTRING(ftype, #type);                                                    \
512
  convert(value, name);                                                                \
513
  JVMCIObject vmFlagObj = JVMCIENV->new_VMFlag(fname, ftype, value, JVMCI_CHECK_NULL); \
514
  JVMCIENV->put_object_at(vmFlags, i++, vmFlagObj);                                    \
515
}
516
#define ADD_BOOL_FLAG(name)  ADD_FLAG(bool, name, BOXED_BOOLEAN)
517
#define ADD_INT_FLAG(name)   ADD_FLAG(int, name, BOXED_LONG)
518
#define ADD_INTX_FLAG(name)  ADD_FLAG(intx, name, BOXED_LONG)
519
#define ADD_UINTX_FLAG(name) ADD_FLAG(uintx, name, BOXED_LONG)
520

521
  len = 0 + PREDEFINED_CONFIG_FLAGS(COUNT_FLAG, COUNT_FLAG, COUNT_FLAG, COUNT_FLAG);
522
  JVMCIObjectArray vmFlags = JVMCIENV->new_VMFlag_array(len, JVMCI_CHECK_NULL);
523
  int i = 0;
524
  JVMCIObject value;
525
  PREDEFINED_CONFIG_FLAGS(ADD_BOOL_FLAG, ADD_INT_FLAG, ADD_INTX_FLAG, ADD_UINTX_FLAG)
526

527
  JVMCIObjectArray vmIntrinsics = CompilerToVM::initialize_intrinsics(JVMCI_CHECK_NULL);
528

529
  JVMCIObjectArray data = JVMCIENV->new_Object_array(5, JVMCI_CHECK_NULL);
530
  JVMCIENV->put_object_at(data, 0, vmFields);
531
  JVMCIENV->put_object_at(data, 1, vmConstants);
532
  JVMCIENV->put_object_at(data, 2, vmAddresses);
533
  JVMCIENV->put_object_at(data, 3, vmFlags);
534
  JVMCIENV->put_object_at(data, 4, vmIntrinsics);
535

536
  return JVMCIENV->get_jobjectArray(data);
537
}
538

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.