comparison src/share/vm/c1x/c1x_TargetMethod.cpp @ 1428:695451afc619

refactoring classes into separate files
author Lukas Stadler <lukas.stadler@oracle.com>
date Thu, 19 Aug 2010 14:34:52 -0700
parents
children abc670a709dc
comparison
equal deleted inserted replaced
1427:149b1d2316de 1428:695451afc619
1 /*
2 * Copyright 2000-2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25
26 # include "incls/_precompiled.incl"
27 # include "incls/_c1x_TargetMethod.cpp.incl"
28
29 static void compute_offset(int &dest_offset, klassOop klass_oop, const char* name, const char* signature, bool static_field) {
30 symbolOop name_symbol = SymbolTable::probe(name, strlen(name));
31 symbolOop signature_symbol = SymbolTable::probe(signature, strlen(signature));
32 assert(name_symbol != NULL, "symbol not found - class layout changed?");
33 assert(signature_symbol != NULL, "symbol not found - class layout changed?");
34
35 instanceKlass* ik = instanceKlass::cast(klass_oop);
36 fieldDescriptor fd;
37 if (!ik->find_field(name_symbol, signature_symbol, &fd)) {
38 ResourceMark rm;
39 tty->print_cr("Invalid layout of %s at %s", ik->external_name(), name_symbol->as_C_string());
40 fatal("Invalid layout of preloaded class");
41 }
42 assert(fd.is_static() == static_field, "static/instance mismatch");
43 dest_offset = fd.offset();
44 }
45
46 // create the compute_class
47 #define START_CLASS(name) { klassOop k = SystemDictionary::name##_klass();
48
49 #define END_CLASS }
50
51 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field);
52 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false)
53 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false)
54 #define LONG_FIELD(klass, name) FIELD(klass, name, "J", false)
55 #define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false)
56 #define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true)
57
58
59 void c1x_compute_offsets() {
60 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, LONG_FIELD, OOP_FIELD, STATIC_OOP_FIELD)
61 }
62
63 #define EMPTY0
64 #define EMPTY1(x)
65 #define EMPTY2(x,y)
66 #define FIELD2(klass, name) int klass::_##name##_offset = 0;
67 #define FIELD3(klass, name, sig) FIELD2(klass, name)
68
69 COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3)
70
71
72
73
74