src/hotspot/share/jvmci/jvmciJavaClasses.cpp
author herrick
Wed, 27 Mar 2019 08:27:58 -0400
branchJDK-8200758-branch
changeset 57288 0be43184f52a
parent 51467 12997ebbc0d8
child 54669 ad45b3802d4e
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
50409
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
#include "precompiled.hpp"
50409
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    25
#include "classfile/symbolTable.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
#include "jvmci/jvmciJavaClasses.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    27
#include "memory/resourceArea.hpp"
50409
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    28
#include "oops/oop.inline.hpp"
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    29
#include "runtime/jniHandles.inline.hpp"
51467
12997ebbc0d8 8209647: constantPoolHandle::constantPoolHandle(ConstantPool*) when precompiled header is disabled
iklam
parents: 50409
diff changeset
    30
#include "runtime/fieldDescriptor.inline.hpp"
50409
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    31
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    32
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    33
// This macro expands for non-inline functions, in class declarations.
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    34
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    35
#define START_CLASS(name)                                                                                                                                \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    36
    void name::check(oop obj, const char* field_name, int offset) {                                                                                          \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    37
      assert(obj != NULL, "NULL field access of %s.%s", #name, field_name);                                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    38
      assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected, found %s", obj->klass()->external_name());                       \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    39
      assert(offset != 0, "must be valid offset");                                                                                                           \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    40
    }
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    41
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    42
#define END_CLASS
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    43
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    44
#define FIELD(klass, name, type, accessor, cast)                                                                                                                                \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    45
    type klass::name(jobject obj)               { check(JNIHandles::resolve(obj), #name, _##name##_offset); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); }     \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    46
    void klass::set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name, _##name##_offset); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); }
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    47
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    48
#define EMPTY_CAST
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    49
#define CHAR_FIELD(klass, name) FIELD(klass, name, jchar, char_field, EMPTY_CAST)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    50
#define INT_FIELD(klass, name) FIELD(klass, name, jint, int_field, EMPTY_CAST)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    51
#define BOOLEAN_FIELD(klass, name) FIELD(klass, name, jboolean, bool_field, EMPTY_CAST)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    52
#define LONG_FIELD(klass, name) FIELD(klass, name, jlong, long_field, EMPTY_CAST)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    53
#define FLOAT_FIELD(klass, name) FIELD(klass, name, jfloat, float_field, EMPTY_CAST)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    54
#define OOP_FIELD(klass, name, signature) FIELD(klass, name, oop, obj_field, EMPTY_CAST)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    55
#define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(klass, name, objArrayOop, obj_field, (objArrayOop))
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    56
#define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(klass, name, typeArrayOop, obj_field, (typeArrayOop))
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    57
#define STATIC_OOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, oop, signature)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    58
#define STATIC_OBJARRAYOOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, objArrayOop, signature)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    59
#define STATIC_OOPISH_FIELD(klassName, name, type, signature)                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    60
    type klassName::name() {                                                                                   \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    61
      assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    62
      InstanceKlass* ik = klassName::klass();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    63
      oop base = ik->static_field_base_raw();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    64
      oop result = HeapAccess<>::oop_load_at(base, _##name##_offset);                                          \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    65
      return type(result);                                                                                     \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    66
    }                                                                                                          \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    67
    void klassName::set_##name(type x) {                                                                       \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    68
      assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    69
      assert(klassName::klass() != NULL, "Class not yet loaded: " #klassName);                                 \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    70
      InstanceKlass* ik = klassName::klass();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    71
      oop base = ik->static_field_base_raw();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    72
      HeapAccess<>::oop_store_at(base, _##name##_offset, x);                                                   \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    73
    }
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    74
#define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename)                                                     \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    75
    jtypename klassName::name() {                                                                              \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    76
      assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    77
      InstanceKlass* ik = klassName::klass();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    78
      oop base = ik->static_field_base_raw();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    79
      return HeapAccess<>::load_at(base, _##name##_offset);                                                    \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    80
    }                                                                                                          \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    81
    void klassName::set_##name(jtypename x) {                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    82
      assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    83
      InstanceKlass* ik = klassName::klass();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    84
      oop base = ik->static_field_base_raw();                                                                  \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    85
      HeapAccess<>::store_at(base, _##name##_offset, x);                                                       \
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    86
    }
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    87
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    88
#define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    89
#define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    90
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    91
COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, TYPEARRAYOOP_FIELD, OBJARRAYOOP_FIELD, STATIC_OOP_FIELD, STATIC_OBJARRAYOOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD)
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    92
#undef START_CLASS
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    93
#undef END_CLASS
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    94
#undef FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    95
#undef CHAR_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    96
#undef INT_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    97
#undef BOOLEAN_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    98
#undef LONG_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
    99
#undef FLOAT_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   100
#undef OOP_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   101
#undef TYPEARRAYOOP_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   102
#undef OBJARRAYOOP_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   103
#undef STATIC_OOPISH_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   104
#undef STATIC_OOP_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   105
#undef STATIC_OBJARRAYOOP_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   106
#undef STATIC_INT_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   107
#undef STATIC_BOOLEAN_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   108
#undef STATIC_PRIMITIVE_FIELD
76bca6678913 8204237: Clean up incorrectly included .inline.hpp files from jvmciJavaClasses.hpp
coleenp
parents: 47216
diff changeset
   109
#undef EMPTY_CAST
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   110
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
// This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   112
// It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   113
34192
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   114
void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   115
  InstanceKlass* ik = InstanceKlass::cast(klass);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   116
  Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   117
  Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   118
  if (name_symbol == NULL || signature_symbol == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   119
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   120
    ik->print_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   121
#endif
33198
dlong
parents: 33160
diff changeset
   122
    fatal("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   123
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   124
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   125
  fieldDescriptor fd;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   126
  if (!ik->find_field(name_symbol, signature_symbol, &fd)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   127
    ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 34192
diff changeset
   128
    fatal("Invalid layout of %s %s at %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), ik->external_name());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   129
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   130
  guarantee(fd.is_static() == static_field, "static/instance mismatch");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   131
  dest_offset = fd.offset();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   132
  assert(dest_offset != 0, "must be valid offset");
34192
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   133
  if (static_field) {
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   134
    // Must ensure classes for static fields are initialized as the
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   135
    // accessor itself does not include a class initialization check.
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   136
    ik->initialize(CHECK);
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   137
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   138
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   139
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   140
// This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   141
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   142
#define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name "");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   143
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   144
#define END_CLASS }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   145
34192
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   146
#define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   147
#define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   148
#define INT_FIELD(klass, name) FIELD(klass, name, "I", false)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   149
#define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   150
#define LONG_FIELD(klass, name) FIELD(klass, name, "J", false)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   151
#define FLOAT_FIELD(klass, name) FIELD(klass, name, "F", false)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   152
#define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   153
#define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   154
#define STATIC_INT_FIELD(klass, name) FIELD(klass, name, "I", true)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   155
#define STATIC_BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", true)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   156
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   157
34192
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 33632
diff changeset
   158
void JVMCIJavaClasses::compute_offsets(TRAPS) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   159
  COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, OOP_FIELD, OOP_FIELD, STATIC_OOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   160
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   161
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   162
#define EMPTY0
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   163
#define EMPTY1(x)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   164
#define EMPTY2(x,y)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   165
#define FIELD2(klass, name) int klass::_##name##_offset = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   166
#define FIELD3(klass, name, sig) FIELD2(klass, name)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   167
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   168
COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   169