1 /*
2 * Copyright (c) 2008, 2025, 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 *
29 #include "interp_masm_arm.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "oops/instanceKlass.hpp"
32 #include "oops/klassVtable.hpp"
33 #include "oops/klass.inline.hpp"
34 #include "runtime/sharedRuntime.hpp"
35 #include "vmreg_arm.inline.hpp"
36 #ifdef COMPILER2
37 #include "opto/runtime.hpp"
38 #endif
39
40 // machine-dependent part of VtableStubs: create VtableStub of correct size and
41 // initialize its code
42
43 #define __ masm->
44
45 #ifndef PRODUCT
46 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
47 #endif
48
49 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
50 // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
51 const int stub_code_length = code_size_limit(true);
52 VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
53 // Can be null if there is no free space in the code cache.
54 if (s == nullptr) {
55 return nullptr;
56 }
57
58 // Count unused bytes in instruction sequences of variable size.
59 // We add them to the computed buffer size in order to avoid
60 // overflow in subsequently generated stubs.
61 address start_pc;
62 int slop_bytes = 0;
63 int slop_delta = 0;
64
65 ResourceMark rm;
66 CodeBuffer cb(s->entry_point(), stub_code_length);
67 MacroAssembler* masm = new MacroAssembler(&cb);
68
69 #if (!defined(PRODUCT) && defined(COMPILER2))
70 if (CountCompiledCalls) {
71 // Implementation required?
72 }
99 }
100 slop_delta = 8 - (int)(__ pc() - start_pc);
101 slop_bytes += slop_delta;
102 assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
103
104 #ifndef PRODUCT
105 if (DebugVtables) {
106 // Implementation required?
107 }
108 #endif
109
110 address ame_addr = __ pc();
111 __ ldr(PC, Address(Rmethod, Method::from_compiled_offset()));
112
113 masm->flush();
114 bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
115
116 return s;
117 }
118
119 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
120 // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
121 const int stub_code_length = code_size_limit(false);
122 VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
123 // Can be null if there is no free space in the code cache.
124 if (s == nullptr) {
125 return nullptr;
126 }
127 // Count unused bytes in instruction sequences of variable size.
128 // We add them to the computed buffer size in order to avoid
129 // overflow in subsequently generated stubs.
130 address start_pc;
131 int slop_bytes = 0;
132 int slop_delta = 0;
133
134 ResourceMark rm;
135 CodeBuffer cb(s->entry_point(), stub_code_length);
136 MacroAssembler* masm = new MacroAssembler(&cb);
137
138 #if (!defined(PRODUCT) && defined(COMPILER2))
139 if (CountCompiledCalls) {
140 // Implementation required?
141 }
142 #endif
|
1 /*
2 * Copyright (c) 2008, 2026, 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 *
29 #include "interp_masm_arm.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "oops/instanceKlass.hpp"
32 #include "oops/klassVtable.hpp"
33 #include "oops/klass.inline.hpp"
34 #include "runtime/sharedRuntime.hpp"
35 #include "vmreg_arm.inline.hpp"
36 #ifdef COMPILER2
37 #include "opto/runtime.hpp"
38 #endif
39
40 // machine-dependent part of VtableStubs: create VtableStub of correct size and
41 // initialize its code
42
43 #define __ masm->
44
45 #ifndef PRODUCT
46 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
47 #endif
48
49 VtableStub* VtableStubs::create_vtable_stub(int vtable_index, bool caller_is_c1) {
50 // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
51 const int stub_code_length = code_size_limit(true);
52 VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index, caller_is_c1);
53 // Can be null if there is no free space in the code cache.
54 if (s == nullptr) {
55 return nullptr;
56 }
57
58 // Count unused bytes in instruction sequences of variable size.
59 // We add them to the computed buffer size in order to avoid
60 // overflow in subsequently generated stubs.
61 address start_pc;
62 int slop_bytes = 0;
63 int slop_delta = 0;
64
65 ResourceMark rm;
66 CodeBuffer cb(s->entry_point(), stub_code_length);
67 MacroAssembler* masm = new MacroAssembler(&cb);
68
69 #if (!defined(PRODUCT) && defined(COMPILER2))
70 if (CountCompiledCalls) {
71 // Implementation required?
72 }
99 }
100 slop_delta = 8 - (int)(__ pc() - start_pc);
101 slop_bytes += slop_delta;
102 assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
103
104 #ifndef PRODUCT
105 if (DebugVtables) {
106 // Implementation required?
107 }
108 #endif
109
110 address ame_addr = __ pc();
111 __ ldr(PC, Address(Rmethod, Method::from_compiled_offset()));
112
113 masm->flush();
114 bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
115
116 return s;
117 }
118
119 VtableStub* VtableStubs::create_itable_stub(int itable_index, bool caller_is_c1) {
120 // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
121 const int stub_code_length = code_size_limit(false);
122 VtableStub* s = new(stub_code_length) VtableStub(false, itable_index, caller_is_c1);
123 // Can be null if there is no free space in the code cache.
124 if (s == nullptr) {
125 return nullptr;
126 }
127 // Count unused bytes in instruction sequences of variable size.
128 // We add them to the computed buffer size in order to avoid
129 // overflow in subsequently generated stubs.
130 address start_pc;
131 int slop_bytes = 0;
132 int slop_delta = 0;
133
134 ResourceMark rm;
135 CodeBuffer cb(s->entry_point(), stub_code_length);
136 MacroAssembler* masm = new MacroAssembler(&cb);
137
138 #if (!defined(PRODUCT) && defined(COMPILER2))
139 if (CountCompiledCalls) {
140 // Implementation required?
141 }
142 #endif
|