1 /*
2 * Copyright (c) 1997, 2009, 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
25 // A klassVtable abstracts the variable-length vtable that is embedded in instanceKlass
26 // and arrayKlass. klassVtable objects are used just as convenient transient accessors to the vtable,
27 // not to actually hold the vtable data.
28 // Note: the klassVtable should not be accessed before the class has been verified
29 // (until that point, the vtable is uninitialized).
30
31 // Currently a klassVtable contains a direct reference to the vtable data, and is therefore
32 // not preserved across GCs.
33
34 class vtableEntry;
35
36 class klassVtable : public ResourceObj {
37 KlassHandle _klass; // my klass
38 int _tableOffset; // offset of start of vtable data within klass
39 int _length; // length of vtable (number of entries)
40 #ifndef PRODUCT
41 int _verify_count; // to make verify faster
42 #endif
43
44 // Ordering important, so greater_than (>) can be used as an merge operator.
302 // Resolving of method to index
303 static int compute_itable_index(methodOop m);
304 // ...and back again:
305 static methodOop method_for_itable_index(klassOop klass, int itable_index);
306
307 // Debugging/Statistics
308 static void print_statistics() PRODUCT_RETURN;
309 private:
310 intptr_t* vtable_start() const { return ((intptr_t*)_klass()) + _table_offset; }
311 intptr_t* method_start() const { return vtable_start() + _size_offset_table * itableOffsetEntry::size(); }
312
313 // Helper methods
314 static int calc_itable_size(int num_interfaces, int num_methods) { return (num_interfaces * itableOffsetEntry::size()) + (num_methods * itableMethodEntry::size()); }
315
316 // Statistics
317 NOT_PRODUCT(static int _total_classes;) // Total no. of classes with itables
318 NOT_PRODUCT(static long _total_size;) // Total no. of bytes used for itables
319
320 static void update_stats(int size) PRODUCT_RETURN NOT_PRODUCT({ _total_classes++; _total_size += size; })
321 };
|
1 /*
2 * Copyright (c) 1997, 2010, 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
25 #ifndef SHARE_VM_OOPS_KLASSVTABLE_HPP
26 #define SHARE_VM_OOPS_KLASSVTABLE_HPP
27
28 #include "memory/allocation.hpp"
29 #include "oops/oopsHierarchy.hpp"
30 #include "runtime/handles.hpp"
31 #include "utilities/growableArray.hpp"
32
33 // A klassVtable abstracts the variable-length vtable that is embedded in instanceKlass
34 // and arrayKlass. klassVtable objects are used just as convenient transient accessors to the vtable,
35 // not to actually hold the vtable data.
36 // Note: the klassVtable should not be accessed before the class has been verified
37 // (until that point, the vtable is uninitialized).
38
39 // Currently a klassVtable contains a direct reference to the vtable data, and is therefore
40 // not preserved across GCs.
41
42 class vtableEntry;
43
44 class klassVtable : public ResourceObj {
45 KlassHandle _klass; // my klass
46 int _tableOffset; // offset of start of vtable data within klass
47 int _length; // length of vtable (number of entries)
48 #ifndef PRODUCT
49 int _verify_count; // to make verify faster
50 #endif
51
52 // Ordering important, so greater_than (>) can be used as an merge operator.
310 // Resolving of method to index
311 static int compute_itable_index(methodOop m);
312 // ...and back again:
313 static methodOop method_for_itable_index(klassOop klass, int itable_index);
314
315 // Debugging/Statistics
316 static void print_statistics() PRODUCT_RETURN;
317 private:
318 intptr_t* vtable_start() const { return ((intptr_t*)_klass()) + _table_offset; }
319 intptr_t* method_start() const { return vtable_start() + _size_offset_table * itableOffsetEntry::size(); }
320
321 // Helper methods
322 static int calc_itable_size(int num_interfaces, int num_methods) { return (num_interfaces * itableOffsetEntry::size()) + (num_methods * itableMethodEntry::size()); }
323
324 // Statistics
325 NOT_PRODUCT(static int _total_classes;) // Total no. of classes with itables
326 NOT_PRODUCT(static long _total_size;) // Total no. of bytes used for itables
327
328 static void update_stats(int size) PRODUCT_RETURN NOT_PRODUCT({ _total_classes++; _total_size += size; })
329 };
330
331 #endif // SHARE_VM_OOPS_KLASSVTABLE_HPP
|