1 /*
2 * Copyright (c) 1997, 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 *
809 // Sizing (in words)
810 static int header_size() { return align_object_offset(sizeof(InstanceKlass)/HeapWordSize); }
811 static int size(int vtable_length, int itable_length,
812 int nonstatic_oop_map_size,
813 bool is_interface, bool is_anonymous) {
814 return align_object_size(header_size() +
815 align_object_offset(vtable_length) +
816 align_object_offset(itable_length) +
817 ((is_interface || is_anonymous) ?
818 align_object_offset(nonstatic_oop_map_size) :
819 nonstatic_oop_map_size) +
820 (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) +
821 (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0));
822 }
823 int size() const { return size(vtable_length(),
824 itable_length(),
825 nonstatic_oop_map_size(),
826 is_interface(),
827 is_anonymous());
828 }
829
830 static int vtable_start_offset() { return header_size(); }
831 static int vtable_length_offset() { return offset_of(InstanceKlass, _vtable_len) / HeapWordSize; }
832
833 intptr_t* start_of_vtable() const { return ((intptr_t*)this) + vtable_start_offset(); }
834 intptr_t* start_of_itable() const { return start_of_vtable() + align_object_offset(vtable_length()); }
835 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
836
837 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
838
839 address static_field_addr(int offset);
840
841 OopMapBlock* start_of_nonstatic_oop_maps() const {
842 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
843 }
844
845 Klass** adr_implementor() const {
846 if (is_interface()) {
847 return (Klass**)(start_of_nonstatic_oop_maps() +
848 nonstatic_oop_map_count());
|
1 /*
2 * Copyright (c) 1997, 2013, 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 *
809 // Sizing (in words)
810 static int header_size() { return align_object_offset(sizeof(InstanceKlass)/HeapWordSize); }
811 static int size(int vtable_length, int itable_length,
812 int nonstatic_oop_map_size,
813 bool is_interface, bool is_anonymous) {
814 return align_object_size(header_size() +
815 align_object_offset(vtable_length) +
816 align_object_offset(itable_length) +
817 ((is_interface || is_anonymous) ?
818 align_object_offset(nonstatic_oop_map_size) :
819 nonstatic_oop_map_size) +
820 (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) +
821 (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0));
822 }
823 int size() const { return size(vtable_length(),
824 itable_length(),
825 nonstatic_oop_map_size(),
826 is_interface(),
827 is_anonymous());
828 }
829 #if INCLUDE_SERVICES
830 virtual void collect_statistics(KlassSizeStats *sz) const;
831 #endif
832
833 static int vtable_start_offset() { return header_size(); }
834 static int vtable_length_offset() { return offset_of(InstanceKlass, _vtable_len) / HeapWordSize; }
835
836 intptr_t* start_of_vtable() const { return ((intptr_t*)this) + vtable_start_offset(); }
837 intptr_t* start_of_itable() const { return start_of_vtable() + align_object_offset(vtable_length()); }
838 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
839
840 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
841
842 address static_field_addr(int offset);
843
844 OopMapBlock* start_of_nonstatic_oop_maps() const {
845 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
846 }
847
848 Klass** adr_implementor() const {
849 if (is_interface()) {
850 return (Klass**)(start_of_nonstatic_oop_maps() +
851 nonstatic_oop_map_count());
|