Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalJavaAccess.cpp @ 2890:c23d45daff9b
Renamed cpp/hpp file directory.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 08 Jun 2011 13:40:25 +0200 |
parents | src/share/vm/c1x/graalJavaAccess.cpp@2fb867285938 |
children | 75a99b4f1c98 |
comparison
equal
deleted
inserted
replaced
2889:2fb867285938 | 2890:c23d45daff9b |
---|---|
1 /* | |
2 * Copyright (c) 2011, 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 "c1x/c1x_JavaAccess.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 static void compute_offset(int &dest_offset, klassOop klass_oop, const char* name, const char* signature, bool static_field) { | |
32 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); | |
33 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); | |
34 #ifdef DEBUG | |
35 if (name_symbol == NULL) { | |
36 tty->print_cr("symbol with name %s was not found in symbol table (klass=%s)", name, klass_oop->klass_part()->name()->as_C_string()); | |
37 } | |
38 #endif | |
39 assert(name_symbol != NULL, "symbol not found - class layout changed?"); | |
40 assert(signature_symbol != NULL, "symbol not found - class layout changed?"); | |
41 | |
42 instanceKlass* ik = instanceKlass::cast(klass_oop); | |
43 fieldDescriptor fd; | |
44 if (!ik->find_field(name_symbol, signature_symbol, &fd)) { | |
45 ResourceMark rm; | |
46 tty->print_cr("Invalid layout of %s at %s", name_symbol->as_C_string(), ik->external_name()); | |
47 fatal("Invalid layout of preloaded class"); | |
48 } | |
49 assert(fd.is_static() == static_field, "static/instance mismatch"); | |
50 dest_offset = fd.offset(); | |
51 } | |
52 | |
53 // This piece of macro magic creates the contents of the c1x_compute_offsets method that initializes the field indices of all the access classes. | |
54 | |
55 #define START_CLASS(name) { klassOop k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name ""); | |
56 | |
57 #define END_CLASS } | |
58 | |
59 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field); | |
60 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false) | |
61 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false) | |
62 #define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false) | |
63 #define LONG_FIELD(klass, name) FIELD(klass, name, "J", 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 | |
67 | |
68 void c1x_compute_offsets() { | |
69 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, OOP_FIELD, STATIC_OOP_FIELD) | |
70 } | |
71 | |
72 #define EMPTY0 | |
73 #define EMPTY1(x) | |
74 #define EMPTY2(x,y) | |
75 #define FIELD2(klass, name) int klass::_##name##_offset = 0; | |
76 #define FIELD3(klass, name, sig) FIELD2(klass, name) | |
77 | |
78 COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3) | |
79 | |
80 | |
81 | |
82 | |
83 |