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 *
94 // hash value). Each list is anchored in a little hash _table, indexed
95 // by that hash value.
96
97 VtableStub* VtableStubs::_table[VtableStubs::N];
98 int VtableStubs::_number_of_vtable_stubs = 0;
99
100
101 void VtableStubs::initialize() {
102 VtableStub::_receiver_location = SharedRuntime::name_for_receiver();
103 {
104 MutexLocker ml(VtableStubs_lock);
105 assert(_number_of_vtable_stubs == 0, "potential performance bug: VtableStubs initialized more than once");
106 assert(is_power_of_2(N), "N must be a power of 2");
107 for (int i = 0; i < N; i++) {
108 _table[i] = NULL;
109 }
110 }
111 }
112
113
114 address VtableStubs::create_stub(bool is_vtable_stub, int vtable_index, Method* method) {
115 assert(vtable_index >= 0, "must be positive");
116
117 VtableStub* s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
118 if (s == NULL) {
119 if (is_vtable_stub) {
120 s = create_vtable_stub(vtable_index);
121 } else {
122 s = create_itable_stub(vtable_index);
123 }
124 enter(is_vtable_stub, vtable_index, s);
125 if (PrintAdapterHandlers) {
126 tty->print_cr("Decoding VtableStub %s[%d]@%d",
127 is_vtable_stub? "vtbl": "itbl", vtable_index, VtableStub::receiver_location());
128 Disassembler::decode(s->code_begin(), s->code_end());
129 }
130 }
131 return s->entry_point();
132 }
133
134
|
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 *
94 // hash value). Each list is anchored in a little hash _table, indexed
95 // by that hash value.
96
97 VtableStub* VtableStubs::_table[VtableStubs::N];
98 int VtableStubs::_number_of_vtable_stubs = 0;
99
100
101 void VtableStubs::initialize() {
102 VtableStub::_receiver_location = SharedRuntime::name_for_receiver();
103 {
104 MutexLocker ml(VtableStubs_lock);
105 assert(_number_of_vtable_stubs == 0, "potential performance bug: VtableStubs initialized more than once");
106 assert(is_power_of_2(N), "N must be a power of 2");
107 for (int i = 0; i < N; i++) {
108 _table[i] = NULL;
109 }
110 }
111 }
112
113
114 address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
115 assert(vtable_index >= 0, "must be positive");
116
117 VtableStub* s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
118 if (s == NULL) {
119 if (is_vtable_stub) {
120 s = create_vtable_stub(vtable_index);
121 } else {
122 s = create_itable_stub(vtable_index);
123 }
124 enter(is_vtable_stub, vtable_index, s);
125 if (PrintAdapterHandlers) {
126 tty->print_cr("Decoding VtableStub %s[%d]@%d",
127 is_vtable_stub? "vtbl": "itbl", vtable_index, VtableStub::receiver_location());
128 Disassembler::decode(s->code_begin(), s->code_end());
129 }
130 }
131 return s->entry_point();
132 }
133
134
|