27 #include "classfile/symbolTable.hpp"
28 #include "memory/resourceArea.hpp"
29
30 // This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field.
31 // It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded.
32
33 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) {
34 InstanceKlass* ik = InstanceKlass::cast(klass);
35 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name));
36 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature));
37 if (name_symbol == NULL || signature_symbol == NULL) {
38 #ifndef PRODUCT
39 ik->print_on(tty);
40 #endif
41 fatal("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string());
42 }
43
44 fieldDescriptor fd;
45 if (!ik->find_field(name_symbol, signature_symbol, &fd)) {
46 ResourceMark rm;
47 fatal("Invalid layout of %s at %s", name_symbol->as_C_string(), ik->external_name());
48 }
49 guarantee(fd.is_static() == static_field, "static/instance mismatch");
50 dest_offset = fd.offset();
51 assert(dest_offset != 0, "must be valid offset");
52 if (static_field) {
53 // Must ensure classes for static fields are initialized as the
54 // accessor itself does not include a class initialization check.
55 ik->initialize(CHECK);
56 }
57 }
58
59 // This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes.
60
61 #define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name "");
62
63 #define END_CLASS }
64
65 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field, CHECK);
66 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false)
67 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false)
|
27 #include "classfile/symbolTable.hpp"
28 #include "memory/resourceArea.hpp"
29
30 // This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field.
31 // It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded.
32
33 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) {
34 InstanceKlass* ik = InstanceKlass::cast(klass);
35 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name));
36 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature));
37 if (name_symbol == NULL || signature_symbol == NULL) {
38 #ifndef PRODUCT
39 ik->print_on(tty);
40 #endif
41 fatal("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string());
42 }
43
44 fieldDescriptor fd;
45 if (!ik->find_field(name_symbol, signature_symbol, &fd)) {
46 ResourceMark rm;
47 fatal("Invalid layout of %s %s at %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), ik->external_name());
48 }
49 guarantee(fd.is_static() == static_field, "static/instance mismatch");
50 dest_offset = fd.offset();
51 assert(dest_offset != 0, "must be valid offset");
52 if (static_field) {
53 // Must ensure classes for static fields are initialized as the
54 // accessor itself does not include a class initialization check.
55 ik->initialize(CHECK);
56 }
57 }
58
59 // This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes.
60
61 #define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name "");
62
63 #define END_CLASS }
64
65 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field, CHECK);
66 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false)
67 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false)
|