Mercurial > hg > graal-jvmci-8
comparison src/share/vm/jvmci/jvmciJavaClasses.cpp @ 22548:02fc27dc1da7
Rename jvmciJavaAccess.* to jvmciJavaClasses.*
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 09 Sep 2015 17:56:30 -0700 |
parents | src/share/vm/jvmci/jvmciJavaAccess.cpp@76af33d4d504 |
children | 456800cd1a17 |
comparison
equal
deleted
inserted
replaced
22547:10a9e989850e | 22548:02fc27dc1da7 |
---|---|
1 /* | |
2 * Copyright (c) 2011, 2012 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 #include "precompiled.hpp" | |
25 #include "jvmci/jvmciJavaClasses.hpp" | |
26 #include "runtime/jniHandles.hpp" | |
27 #include "classfile/symbolTable.hpp" | |
28 // This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field. | |
29 // It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded. | |
30 | |
31 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field) { | |
32 InstanceKlass* ik = InstanceKlass::cast(klass); | |
33 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); | |
34 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); | |
35 if (name_symbol == NULL || signature_symbol == NULL) { | |
36 #ifndef PRODUCT | |
37 ik->print_on(tty); | |
38 #endif | |
39 fatal(err_msg("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string())); | |
40 } | |
41 | |
42 fieldDescriptor fd; | |
43 if (!ik->find_field(name_symbol, signature_symbol, &fd)) { | |
44 ResourceMark rm; | |
45 fatal(err_msg("Invalid layout of %s at %s", name_symbol->as_C_string(), ik->external_name())); | |
46 } | |
47 guarantee(fd.is_static() == static_field, "static/instance mismatch"); | |
48 dest_offset = fd.offset(); | |
49 assert(dest_offset != 0, "must be valid offset"); | |
50 } | |
51 | |
52 // This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes. | |
53 | |
54 #define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name ""); | |
55 | |
56 #define END_CLASS } | |
57 | |
58 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field); | |
59 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false) | |
60 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false) | |
61 #define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false) | |
62 #define LONG_FIELD(klass, name) FIELD(klass, name, "J", false) | |
63 #define FLOAT_FIELD(klass, name) FIELD(klass, name, "F", false) | |
64 #define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false) | |
65 #define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true) | |
66 #define STATIC_INT_FIELD(klass, name) FIELD(klass, name, "I", true) | |
67 #define STATIC_BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", true) | |
68 | |
69 | |
70 void jvmci_compute_offsets() { | |
71 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) | |
72 guarantee(InstalledCode::_address_offset == sizeof(oopDesc), "codeBlob must be first field!"); | |
73 } | |
74 | |
75 #define EMPTY0 | |
76 #define EMPTY1(x) | |
77 #define EMPTY2(x,y) | |
78 #define FIELD2(klass, name) int klass::_##name##_offset = 0; | |
79 #define FIELD3(klass, name, sig) FIELD2(klass, name) | |
80 | |
81 COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2) | |
82 | |
83 | |
84 | |
85 | |
86 |