hotspot/src/cpu/x86/vm/runtime_x86_32.cpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)runtime_x86_32.cpp   1.113 07/09/17 09:26:02 JVM"
   3 #endif
   4 /*
   5  * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


  64   enum layout { 
  65     thread_off,                 // last_java_sp                
  66     // The frame sender code expects that rbp will be in the "natural" place and
  67     // will override any oopMap setting for it. We must therefore force the layout
  68     // so that it agrees with the frame sender code.
  69     rbp_off,                
  70     return_off,                 // slot for return address
  71     framesize 
  72   };
  73 
  74   // allocate space for the code
  75   ResourceMark rm;
  76   // setup code generation tools  
  77   CodeBuffer   buffer("exception_blob", 512, 512);
  78   MacroAssembler* masm = new MacroAssembler(&buffer);
  79 
  80   OopMapSet *oop_maps = new OopMapSet();
  81 
  82   address start = __ pc();  
  83 
  84   __ pushl(rdx);
  85   __ subl(rsp, return_off * wordSize);   // Prolog!
  86 
  87   // rbp, location is implicitly known
  88   __ movl(Address(rsp,rbp_off  *wordSize),rbp);
  89           
  90   // Store exception in Thread object. We cannot pass any arguments to the
  91   // handle_exception call, since we do not want to make any assumption
  92   // about the size of the frame where the exception happened in.
  93   __ get_thread(rcx);
  94   __ movl(Address(rcx, JavaThread::exception_oop_offset()), rax);
  95   __ movl(Address(rcx, JavaThread::exception_pc_offset()),  rdx);
  96 
  97   // This call does all the hard work.  It checks if an exception handler
  98   // exists in the method.  
  99   // If so, it returns the handler address.
 100   // If not, it prepares for stack-unwinding, restoring the callee-save 
 101   // registers of the frame being removed.
 102   //  
 103   __ movl(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument
 104   __ set_last_Java_frame(rcx, noreg, noreg, NULL);
 105   
 106   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
 107 
 108   // No registers to map, rbp is known implicitly
 109   oop_maps->add_gc_map( __ pc() - start,  new OopMap( framesize, 0 ));
 110   __ get_thread(rcx);
 111   __ reset_last_Java_frame(rcx, false, false);
 112 
 113   // Restore callee-saved registers
 114   __ movl(rbp, Address(rsp, rbp_off * wordSize));
 115 
 116   __ addl(rsp, return_off * wordSize);   // Epilog!
 117   __ popl(rdx); // Exception pc
 118 
 119 
 120   // rax,: exception handler for given <exception oop/exception pc>
 121   
 122   // We have a handler in rax, (could be deopt blob)
 123   // rdx - throwing pc, deopt blob will need it.
 124 
 125   __ pushl(rax); 
 126 
 127   // rcx contains handler address
 128 
 129   __ get_thread(rcx);           // TLS
 130   // Get the exception
 131   __ movl(rax, Address(rcx, JavaThread::exception_oop_offset()));
 132   // Get the exception pc in case we are deoptimized
 133   __ movl(rdx, Address(rcx, JavaThread::exception_pc_offset()));
 134 #ifdef ASSERT
 135   __ movl(Address(rcx, JavaThread::exception_handler_pc_offset()), 0);
 136   __ movl(Address(rcx, JavaThread::exception_pc_offset()), 0); 
 137 #endif
 138   // Clear the exception oop so GC no longer processes it as a root.
 139   __ movl(Address(rcx, JavaThread::exception_oop_offset()), 0);
 140 
 141   __ popl(rcx);
 142 
 143   // rax,: exception oop
 144   // rcx: exception handler
 145   // rdx: exception pc
 146   __ jmp (rcx);
 147 
 148   // -------------
 149   // make sure all code is generated
 150   masm->flush();  
 151 
 152   _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize);  
 153 }



   1 /*
   2  * Copyright 1998-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


  61   enum layout {
  62     thread_off,                 // last_java_sp
  63     // The frame sender code expects that rbp will be in the "natural" place and
  64     // will override any oopMap setting for it. We must therefore force the layout
  65     // so that it agrees with the frame sender code.
  66     rbp_off,
  67     return_off,                 // slot for return address
  68     framesize
  69   };
  70 
  71   // allocate space for the code
  72   ResourceMark rm;
  73   // setup code generation tools
  74   CodeBuffer   buffer("exception_blob", 512, 512);
  75   MacroAssembler* masm = new MacroAssembler(&buffer);
  76 
  77   OopMapSet *oop_maps = new OopMapSet();
  78 
  79   address start = __ pc();
  80 
  81   __ push(rdx);
  82   __ subptr(rsp, return_off * wordSize);   // Prolog!
  83 
  84   // rbp, location is implicitly known
  85   __ movptr(Address(rsp,rbp_off  *wordSize), rbp);
  86 
  87   // Store exception in Thread object. We cannot pass any arguments to the
  88   // handle_exception call, since we do not want to make any assumption
  89   // about the size of the frame where the exception happened in.
  90   __ get_thread(rcx);
  91   __ movptr(Address(rcx, JavaThread::exception_oop_offset()), rax);
  92   __ movptr(Address(rcx, JavaThread::exception_pc_offset()),  rdx);
  93 
  94   // This call does all the hard work.  It checks if an exception handler
  95   // exists in the method.
  96   // If so, it returns the handler address.
  97   // If not, it prepares for stack-unwinding, restoring the callee-save
  98   // registers of the frame being removed.
  99   //
 100   __ movptr(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument
 101   __ set_last_Java_frame(rcx, noreg, noreg, NULL);
 102 
 103   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
 104 
 105   // No registers to map, rbp is known implicitly
 106   oop_maps->add_gc_map( __ pc() - start,  new OopMap( framesize, 0 ));
 107   __ get_thread(rcx);
 108   __ reset_last_Java_frame(rcx, false, false);
 109 
 110   // Restore callee-saved registers
 111   __ movptr(rbp, Address(rsp, rbp_off * wordSize));
 112 
 113   __ addptr(rsp, return_off * wordSize);   // Epilog!
 114   __ pop(rdx); // Exception pc
 115 
 116 
 117   // rax,: exception handler for given <exception oop/exception pc>
 118 
 119   // We have a handler in rax, (could be deopt blob)
 120   // rdx - throwing pc, deopt blob will need it.
 121 
 122   __ push(rax);
 123 
 124   // rcx contains handler address
 125 
 126   __ get_thread(rcx);           // TLS
 127   // Get the exception
 128   __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset()));
 129   // Get the exception pc in case we are deoptimized
 130   __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset()));
 131 #ifdef ASSERT
 132   __ movptr(Address(rcx, JavaThread::exception_handler_pc_offset()), (int32_t)NULL_WORD);
 133   __ movptr(Address(rcx, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD);
 134 #endif
 135   // Clear the exception oop so GC no longer processes it as a root.
 136   __ movptr(Address(rcx, JavaThread::exception_oop_offset()), (int32_t)NULL_WORD);
 137 
 138   __ pop(rcx);
 139 
 140   // rax,: exception oop
 141   // rcx: exception handler
 142   // rdx: exception pc
 143   __ jmp (rcx);
 144 
 145   // -------------
 146   // make sure all code is generated
 147   masm->flush();
 148 
 149   _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize);
 150 }