20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.inline.hpp"
28 #include "code/compiledIC.hpp"
29 #include "code/icBuffer.hpp"
30 #include "code/nmethod.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/safepoint.hpp"
34 #ifdef COMPILER2
35 #include "opto/matcher.hpp"
36 #endif
37
38 // ----------------------------------------------------------------------------
39
40 // A PPC CompiledStaticCall looks like this:
41 //
42 // >>>> consts
43 //
44 // [call target1]
45 // [IC cache]
46 // [call target2]
47 //
48 // <<<< consts
49 // >>>> insts
50 //
51 // bl offset16 -+ -+ ??? // How many bits available?
52 // | |
53 // <<<< insts | |
54 // >>>> stubs | |
55 // | |- trampoline_stub_Reloc
56 // trampoline stub: | <-+
57 // r2 = toc |
58 // r2 = [r2 + offset] | // Load call target1 from const section
59 // mtctr r2 |
60 // bctr |- static_stub_Reloc
146 #else
147 ShouldNotReachHere();
148 return NULL;
149 #endif
150 }
151 #undef __
152
153 // Size of java_to_interp stub, this doesn't need to be accurate but it must
154 // be larger or equal to the real size of the stub.
155 // Used for optimization in Compile::Shorten_branches.
156 int CompiledStaticCall::to_interp_stub_size() {
157 return 12 * BytesPerInstWord;
158 }
159
160 // Relocation entries for call stub, compiled java to interpreter.
161 // Used for optimization in Compile::Shorten_branches.
162 int CompiledStaticCall::reloc_to_interp_stub() {
163 return 5;
164 }
165
166 void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {
167 address stub = find_stub();
168 guarantee(stub != NULL, "stub not found");
169
170 if (TraceICs) {
171 ResourceMark rm;
172 tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
173 p2i(instruction_address()),
174 callee->name_and_sig_as_C_string());
175 }
176
177 // Creation also verifies the object.
178 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + IC_pos_in_java_to_interp_stub);
179 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
180
181 #ifdef ASSERT
182 // read the value once
183 volatile intptr_t data = method_holder->data();
184 volatile address destination = jump->jump_destination();
185 assert(data == 0 || data == (intptr_t)callee(),
186 "a) MT-unsafe modification of inline cache");
187 assert(destination == (address)-1 || destination == entry,
188 "b) MT-unsafe modification of inline cache");
189 #endif
190
191 // Update stub.
192 method_holder->set_data((intptr_t)callee());
193 jump->set_jump_destination(entry);
194
195 // Update jump to call.
196 set_destination_mt_safe(stub);
197 }
198
199 void CompiledStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
200 assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");
201 // Reset stub.
202 address stub = static_stub->addr();
203 assert(stub != NULL, "stub not found");
204 // Creation also verifies the object.
205 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + IC_pos_in_java_to_interp_stub);
206 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
207 method_holder->set_data(0);
208 jump->set_jump_destination((address)-1);
209 }
210
211 //-----------------------------------------------------------------------------
212 // Non-product mode code
213 #ifndef PRODUCT
214
215 void CompiledStaticCall::verify() {
216 // Verify call.
217 NativeCall::verify();
218 if (os::is_MP()) {
219 verify_alignment();
220 }
221
222 // Verify stub.
223 address stub = find_stub();
224 assert(stub != NULL, "no stub found for static call");
225 // Creation also verifies the object.
226 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + IC_pos_in_java_to_interp_stub);
227 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
228
229 // Verify state.
230 assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
231 }
232
233 #endif // !PRODUCT
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.inline.hpp"
28 #include "code/compiledIC.hpp"
29 #include "code/icBuffer.hpp"
30 #include "code/nmethod.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/safepoint.hpp"
34 #ifdef COMPILER2
35 #include "opto/matcher.hpp"
36 #endif
37
38 // ----------------------------------------------------------------------------
39
40 // A PPC CompiledDirectStaticCall looks like this:
41 //
42 // >>>> consts
43 //
44 // [call target1]
45 // [IC cache]
46 // [call target2]
47 //
48 // <<<< consts
49 // >>>> insts
50 //
51 // bl offset16 -+ -+ ??? // How many bits available?
52 // | |
53 // <<<< insts | |
54 // >>>> stubs | |
55 // | |- trampoline_stub_Reloc
56 // trampoline stub: | <-+
57 // r2 = toc |
58 // r2 = [r2 + offset] | // Load call target1 from const section
59 // mtctr r2 |
60 // bctr |- static_stub_Reloc
146 #else
147 ShouldNotReachHere();
148 return NULL;
149 #endif
150 }
151 #undef __
152
153 // Size of java_to_interp stub, this doesn't need to be accurate but it must
154 // be larger or equal to the real size of the stub.
155 // Used for optimization in Compile::Shorten_branches.
156 int CompiledStaticCall::to_interp_stub_size() {
157 return 12 * BytesPerInstWord;
158 }
159
160 // Relocation entries for call stub, compiled java to interpreter.
161 // Used for optimization in Compile::Shorten_branches.
162 int CompiledStaticCall::reloc_to_interp_stub() {
163 return 5;
164 }
165
166 void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, address entry) {
167 address stub = find_stub(/*is_aot*/ false);
168 guarantee(stub != NULL, "stub not found");
169
170 if (TraceICs) {
171 ResourceMark rm;
172 tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
173 p2i(instruction_address()),
174 callee->name_and_sig_as_C_string());
175 }
176
177 // Creation also verifies the object.
178 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + IC_pos_in_java_to_interp_stub);
179 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
180
181 #ifdef ASSERT
182 // read the value once
183 volatile intptr_t data = method_holder->data();
184 volatile address destination = jump->jump_destination();
185 assert(data == 0 || data == (intptr_t)callee(),
186 "a) MT-unsafe modification of inline cache");
187 assert(destination == (address)-1 || destination == entry,
188 "b) MT-unsafe modification of inline cache");
189 #endif
190
191 // Update stub.
192 method_holder->set_data((intptr_t)callee());
193 jump->set_jump_destination(entry);
194
195 // Update jump to call.
196 set_destination_mt_safe(stub);
197 }
198
199 void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
200 assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");
201 // Reset stub.
202 address stub = static_stub->addr();
203 assert(stub != NULL, "stub not found");
204 // Creation also verifies the object.
205 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + IC_pos_in_java_to_interp_stub);
206 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
207 method_holder->set_data(0);
208 jump->set_jump_destination((address)-1);
209 }
210
211 //-----------------------------------------------------------------------------
212 // Non-product mode code
213 #ifndef PRODUCT
214
215 void CompiledDirectStaticCall::verify() {
216 // Verify call.
217 _call->verify();
218 if (os::is_MP()) {
219 _call->verify_alignment();
220 }
221
222 // Verify stub.
223 address stub = find_stub(/*is_aot*/ false);
224 assert(stub != NULL, "no stub found for static call");
225 // Creation also verifies the object.
226 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + IC_pos_in_java_to_interp_stub);
227 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
228
229 // Verify state.
230 assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
231 }
232
233 #endif // !PRODUCT
|