< prev index next >

src/hotspot/cpu/x86/runtime_x86_64.cpp

Print this page

  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  *
 23  */
 24 
 25 #ifdef COMPILER2
 26 #include "asm/macroAssembler.hpp"
 27 #include "asm/macroAssembler.inline.hpp"

 28 #include "code/vmreg.hpp"
 29 #include "interpreter/interpreter.hpp"
 30 #include "opto/runtime.hpp"
 31 #include "runtime/sharedRuntime.hpp"
 32 #include "runtime/stubRoutines.hpp"
 33 #include "runtime/vframeArray.hpp"
 34 #include "utilities/globalDefinitions.hpp"
 35 #include "vmreg_x86.inline.hpp"
 36 
 37 class SimpleRuntimeFrame {
 38 
 39   public:
 40 
 41   // Most of the runtime stubs have this simple frame layout.
 42   // This class exists to make the layout shared in one place.
 43   // Offsets are for compiler stack slots, which are jints.
 44   enum layout {
 45     // The frame sender code expects that rbp will be in the "natural" place and
 46     // will override any oopMap setting for it. We must therefore force the layout
 47     // so that it agrees with the frame sender code.

248 // Arguments:
249 //   rax: exception oop
250 //   rdx: exception pc
251 //
252 // Results:
253 //   rax: exception oop
254 //   rdx: exception pc in caller or ???
255 //   destination: exception handler of caller
256 //
257 // Note: the exception pc MUST be at a call (precise debug information)
258 //       Registers rax, rdx, rcx, rsi, rdi, r8-r11 are not callee saved.
259 //
260 
261 ExceptionBlob* OptoRuntime::generate_exception_blob() {
262   assert(!OptoRuntime::is_callee_saved_register(RDX_num), "");
263   assert(!OptoRuntime::is_callee_saved_register(RAX_num), "");
264   assert(!OptoRuntime::is_callee_saved_register(RCX_num), "");
265 
266   assert(SimpleRuntimeFrame::framesize % 4 == 0, "sp not 16-byte aligned");
267 






268   // Allocate space for the code
269   ResourceMark rm;
270   // Setup code generation tools
271   const char* name = OptoRuntime::stub_name(OptoStubId::exception_id);
272   CodeBuffer buffer(name, 2048, 1024);
273   if (buffer.blob() == nullptr) {
274     return nullptr;
275   }
276   MacroAssembler* masm = new MacroAssembler(&buffer);
277 
278 
279   address start = __ pc();
280 
281   // Exception pc is 'return address' for stack walker
282   __ push(rdx);
283   __ subptr(rsp, SimpleRuntimeFrame::return_off << LogBytesPerInt); // Prolog
284 
285   // Save callee-saved registers.  See x86_64.ad.
286 
287   // rbp is an implicitly saved callee saved register (i.e., the calling
288   // convention will save/restore it in the prolog/epilog). Other than that
289   // there are no callee save registers now that adapter frames are gone.
290 
291   __ movptr(Address(rsp, SimpleRuntimeFrame::rbp_off << LogBytesPerInt), rbp);

346   // Get the exception pc in case we are deoptimized
347   __ movptr(rdx, Address(r15_thread, JavaThread::exception_pc_offset()));
348 #ifdef ASSERT
349   __ movptr(Address(r15_thread, JavaThread::exception_handler_pc_offset()), NULL_WORD);
350   __ movptr(Address(r15_thread, JavaThread::exception_pc_offset()), NULL_WORD);
351 #endif
352   // Clear the exception oop so GC no longer processes it as a root.
353   __ movptr(Address(r15_thread, JavaThread::exception_oop_offset()), NULL_WORD);
354 
355   // rax: exception oop
356   // r8:  exception handler
357   // rdx: exception pc
358   // Jump to handler
359 
360   __ jmp(r8);
361 
362   // Make sure all code is generated
363   masm->flush();
364 
365   // Set exception blob
366   return ExceptionBlob::create(&buffer, oop_maps, SimpleRuntimeFrame::framesize >> 1);


367 }
368 #endif // COMPILER2

  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  *
 23  */
 24 
 25 #ifdef COMPILER2
 26 #include "asm/macroAssembler.hpp"
 27 #include "asm/macroAssembler.inline.hpp"
 28 #include "code/aotCodeCache.hpp"
 29 #include "code/vmreg.hpp"
 30 #include "interpreter/interpreter.hpp"
 31 #include "opto/runtime.hpp"
 32 #include "runtime/sharedRuntime.hpp"
 33 #include "runtime/stubRoutines.hpp"
 34 #include "runtime/vframeArray.hpp"
 35 #include "utilities/globalDefinitions.hpp"
 36 #include "vmreg_x86.inline.hpp"
 37 
 38 class SimpleRuntimeFrame {
 39 
 40   public:
 41 
 42   // Most of the runtime stubs have this simple frame layout.
 43   // This class exists to make the layout shared in one place.
 44   // Offsets are for compiler stack slots, which are jints.
 45   enum layout {
 46     // The frame sender code expects that rbp will be in the "natural" place and
 47     // will override any oopMap setting for it. We must therefore force the layout
 48     // so that it agrees with the frame sender code.

249 // Arguments:
250 //   rax: exception oop
251 //   rdx: exception pc
252 //
253 // Results:
254 //   rax: exception oop
255 //   rdx: exception pc in caller or ???
256 //   destination: exception handler of caller
257 //
258 // Note: the exception pc MUST be at a call (precise debug information)
259 //       Registers rax, rdx, rcx, rsi, rdi, r8-r11 are not callee saved.
260 //
261 
262 ExceptionBlob* OptoRuntime::generate_exception_blob() {
263   assert(!OptoRuntime::is_callee_saved_register(RDX_num), "");
264   assert(!OptoRuntime::is_callee_saved_register(RAX_num), "");
265   assert(!OptoRuntime::is_callee_saved_register(RCX_num), "");
266 
267   assert(SimpleRuntimeFrame::framesize % 4 == 0, "sp not 16-byte aligned");
268 
269   const char* name = OptoRuntime::stub_name(OptoStubId::exception_id);
270   CodeBlob* blob = AOTCodeCache::load_code_blob(AOTCodeEntry::Blob, (uint)OptoStubId::exception_id, name);
271   if (blob != nullptr) {
272     return blob->as_exception_blob();
273   }
274 
275   // Allocate space for the code
276   ResourceMark rm;
277   // Setup code generation tools

278   CodeBuffer buffer(name, 2048, 1024);
279   if (buffer.blob() == nullptr) {
280     return nullptr;
281   }
282   MacroAssembler* masm = new MacroAssembler(&buffer);
283 
284 
285   address start = __ pc();
286 
287   // Exception pc is 'return address' for stack walker
288   __ push(rdx);
289   __ subptr(rsp, SimpleRuntimeFrame::return_off << LogBytesPerInt); // Prolog
290 
291   // Save callee-saved registers.  See x86_64.ad.
292 
293   // rbp is an implicitly saved callee saved register (i.e., the calling
294   // convention will save/restore it in the prolog/epilog). Other than that
295   // there are no callee save registers now that adapter frames are gone.
296 
297   __ movptr(Address(rsp, SimpleRuntimeFrame::rbp_off << LogBytesPerInt), rbp);

352   // Get the exception pc in case we are deoptimized
353   __ movptr(rdx, Address(r15_thread, JavaThread::exception_pc_offset()));
354 #ifdef ASSERT
355   __ movptr(Address(r15_thread, JavaThread::exception_handler_pc_offset()), NULL_WORD);
356   __ movptr(Address(r15_thread, JavaThread::exception_pc_offset()), NULL_WORD);
357 #endif
358   // Clear the exception oop so GC no longer processes it as a root.
359   __ movptr(Address(r15_thread, JavaThread::exception_oop_offset()), NULL_WORD);
360 
361   // rax: exception oop
362   // r8:  exception handler
363   // rdx: exception pc
364   // Jump to handler
365 
366   __ jmp(r8);
367 
368   // Make sure all code is generated
369   masm->flush();
370 
371   // Set exception blob
372   ExceptionBlob* ex_blob = ExceptionBlob::create(&buffer, oop_maps, SimpleRuntimeFrame::framesize >> 1);
373   AOTCodeCache::store_code_blob(*ex_blob, AOTCodeEntry::Blob, (uint)OptoStubId::exception_id, name);
374   return ex_blob;
375 }
376 #endif // COMPILER2
< prev index next >