comparison src/cpu/x86/vm/compiledIC_x86.cpp @ 15046:5c71dcf0915d

use hotspot static stubs for call sites
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 09 Apr 2014 16:33:37 -0700
parents 359f7e70ae7f
children 52b4284cb496
comparison
equal deleted inserted replaced
15045:0286888f792b 15046:5c71dcf0915d
76 } 76 }
77 77
78 // ---------------------------------------------------------------------------- 78 // ----------------------------------------------------------------------------
79 79
80 #define __ _masm. 80 #define __ _masm.
81 void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { 81 void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {
82 // Stub is fixed up when the corresponding call is converted from 82 // Stub is fixed up when the corresponding call is converted from
83 // calling compiled code to calling interpreted code. 83 // calling compiled code to calling interpreted code.
84 // movq rbx, 0 84 // movq rbx, 0
85 // jmp -5 # to self 85 // jmp -5 # to self
86 86
87 address mark = cbuf.insts_mark(); // Get mark within main instrs section. 87 if (mark == NULL) {
88 mark = cbuf.insts_mark(); // Get mark within main instrs section.
89 }
88 90
89 // Note that the code buffer's insts_mark is always relative to insts. 91 // Note that the code buffer's insts_mark is always relative to insts.
90 // That's why we must use the macroassembler to generate a stub. 92 // That's why we must use the macroassembler to generate a stub.
91 MacroAssembler _masm(&cbuf); 93 MacroAssembler _masm(&cbuf);
92 94
93 address base = 95 address base =
94 __ start_a_stub(to_interp_stub_size()*2); 96 __ start_a_stub(to_interp_stub_size());
95 if (base == NULL) return; // CodeBuffer::expand failed. 97 guarantee(base != NULL, "out of space");
98
96 // Static stub relocation stores the instruction address of the call. 99 // Static stub relocation stores the instruction address of the call.
97 __ relocate(static_stub_Relocation::spec(mark), Assembler::imm_operand); 100 __ relocate(static_stub_Relocation::spec(mark), Assembler::imm_operand);
98 // Static stub relocation also tags the Method* in the code-stream. 101 // Static stub relocation also tags the Method* in the code-stream.
99 __ mov_metadata(rbx, (Metadata*) NULL); // Method is zapped till fixup time. 102 __ mov_metadata(rbx, (Metadata*) NULL); // Method is zapped till fixup time.
100 // This is recognized as unresolved by relocs/nativeinst/ic code. 103 // This is recognized as unresolved by relocs/nativeinst/ic code.
101 __ jump(RuntimeAddress(__ pc())); 104 __ jump(RuntimeAddress(__ pc()));
105
106 assert(__ pc() - base <= to_interp_stub_size(), "wrong stub size");
102 107
103 // Update current stubs pointer and restore insts_end. 108 // Update current stubs pointer and restore insts_end.
104 __ end_a_stub(); 109 __ end_a_stub();
105 } 110 }
106 #undef __ 111 #undef __
115 return 4; // 3 in emit_to_interp_stub + 1 in emit_call 120 return 4; // 3 in emit_to_interp_stub + 1 in emit_call
116 } 121 }
117 122
118 void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) { 123 void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {
119 address stub = find_stub(); 124 address stub = find_stub();
120 #ifdef GRAAL
121 if (stub == NULL) {
122 set_destination_mt_safe(entry);
123 return;
124 }
125 #endif
126 guarantee(stub != NULL, "stub not found"); 125 guarantee(stub != NULL, "stub not found");
127 126
128 if (TraceICs) { 127 if (TraceICs) {
129 ResourceMark rm; 128 ResourceMark rm;
130 tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s", 129 tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
170 NativeCall::verify(); 169 NativeCall::verify();
171 if (os::is_MP()) { 170 if (os::is_MP()) {
172 verify_alignment(); 171 verify_alignment();
173 } 172 }
174 173
175 #ifndef GRAAL
176 // Verify stub. 174 // Verify stub.
177 address stub = find_stub(); 175 address stub = find_stub();
178 assert(stub != NULL, "no stub found for static call"); 176 assert(stub != NULL, "no stub found for static call");
179 // Creation also verifies the object. 177 // Creation also verifies the object.
180 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); 178 NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
181 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); 179 NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
182 #endif
183 180
184 // Verify state. 181 // Verify state.
185 assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check"); 182 assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
186 } 183 }
187 184