< prev index next >

src/share/vm/runtime/stubRoutines.cpp

Print this page




  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 #include "precompiled.hpp"
  26 #include "asm/codeBuffer.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/interfaceSupport.hpp"
  30 #include "runtime/timerTrace.hpp"
  31 #include "runtime/sharedRuntime.hpp"
  32 #include "runtime/stubRoutines.hpp"
  33 #include "utilities/copy.hpp"

  34 #ifdef COMPILER2
  35 #include "opto/runtime.hpp"
  36 #endif
  37 
  38 
  39 // Implementation of StubRoutines - for a description
  40 // of how to extend it, see the header file.
  41 
  42 // Class Variables
  43 
  44 BufferBlob* StubRoutines::_code1                                = NULL;
  45 BufferBlob* StubRoutines::_code2                                = NULL;
  46 
  47 address StubRoutines::_call_stub_return_address                 = NULL;
  48 address StubRoutines::_call_stub_entry                          = NULL;
  49 
  50 address StubRoutines::_catch_exception_entry                    = NULL;
  51 address StubRoutines::_forward_exception_entry                  = NULL;
  52 address StubRoutines::_throw_AbstractMethodError_entry          = NULL;
  53 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;


 221   ((arraycopy_fn)func)(buffer, buffer2, 0);
 222   for (i = 0; i < sizeof(lbuffer); i++) {
 223     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
 224   }
 225   // adjust destination alignment
 226   ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
 227   for (i = 0; i < sizeof(lbuffer); i++) {
 228     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
 229   }
 230   // adjust source alignment
 231   ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
 232   for (i = 0; i < sizeof(lbuffer); i++) {
 233     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
 234   }
 235 }
 236 
 237 // simple test for SafeFetch32
 238 static void test_safefetch32() {
 239   if (CanUseSafeFetch32()) {
 240     int dummy = 17;
 241     int* const p_invalid = (int*) get_segfault_address();
 242     int* const p_valid = &dummy;
 243     int result_invalid = SafeFetch32(p_invalid, 0xABC);
 244     assert(result_invalid == 0xABC, "SafeFetch32 error");
 245     int result_valid = SafeFetch32(p_valid, 0xABC);
 246     assert(result_valid == 17, "SafeFetch32 error");
 247   }
 248 }
 249 
 250 // simple test for SafeFetchN
 251 static void test_safefetchN() {
 252   if (CanUseSafeFetchN()) {
 253 #ifdef _LP64
 254     const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
 255     const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
 256 #else
 257     const intptr_t v1 = 0xABCDABCD;
 258     const intptr_t v2 = 0xDEFDDEFD;
 259 #endif
 260     intptr_t dummy = v1;
 261     intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
 262     intptr_t* const p_valid = &dummy;
 263     intptr_t result_invalid = SafeFetchN(p_invalid, v2);
 264     assert(result_invalid == v2, "SafeFetchN error");
 265     intptr_t result_valid = SafeFetchN(p_valid, v2);
 266     assert(result_valid == v1, "SafeFetchN error");
 267   }
 268 }
 269 #endif
 270 
 271 void StubRoutines::initialize2() {
 272   if (_code2 == NULL) {
 273     ResourceMark rm;
 274     TraceTime timer("StubRoutines generation 2", TRACETIME_LOG(Info, startuptime));
 275     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
 276     if (_code2 == NULL) {
 277       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
 278     }
 279     CodeBuffer buffer(_code2);
 280     StubGenerator_generate(&buffer, true);
 281     // When new stubs added we need to make sure there is some space left




  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 #include "precompiled.hpp"
  26 #include "asm/codeBuffer.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/interfaceSupport.hpp"
  30 #include "runtime/timerTrace.hpp"
  31 #include "runtime/sharedRuntime.hpp"
  32 #include "runtime/stubRoutines.hpp"
  33 #include "utilities/copy.hpp"
  34 #include "utilities/vmError.hpp"
  35 #ifdef COMPILER2
  36 #include "opto/runtime.hpp"
  37 #endif
  38 
  39 
  40 // Implementation of StubRoutines - for a description
  41 // of how to extend it, see the header file.
  42 
  43 // Class Variables
  44 
  45 BufferBlob* StubRoutines::_code1                                = NULL;
  46 BufferBlob* StubRoutines::_code2                                = NULL;
  47 
  48 address StubRoutines::_call_stub_return_address                 = NULL;
  49 address StubRoutines::_call_stub_entry                          = NULL;
  50 
  51 address StubRoutines::_catch_exception_entry                    = NULL;
  52 address StubRoutines::_forward_exception_entry                  = NULL;
  53 address StubRoutines::_throw_AbstractMethodError_entry          = NULL;
  54 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;


 222   ((arraycopy_fn)func)(buffer, buffer2, 0);
 223   for (i = 0; i < sizeof(lbuffer); i++) {
 224     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
 225   }
 226   // adjust destination alignment
 227   ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
 228   for (i = 0; i < sizeof(lbuffer); i++) {
 229     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
 230   }
 231   // adjust source alignment
 232   ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
 233   for (i = 0; i < sizeof(lbuffer); i++) {
 234     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
 235   }
 236 }
 237 
 238 // simple test for SafeFetch32
 239 static void test_safefetch32() {
 240   if (CanUseSafeFetch32()) {
 241     int dummy = 17;
 242     int* const p_invalid = (int*) VMError::get_segfault_address();
 243     int* const p_valid = &dummy;
 244     int result_invalid = SafeFetch32(p_invalid, 0xABC);
 245     assert(result_invalid == 0xABC, "SafeFetch32 error");
 246     int result_valid = SafeFetch32(p_valid, 0xABC);
 247     assert(result_valid == 17, "SafeFetch32 error");
 248   }
 249 }
 250 
 251 // simple test for SafeFetchN
 252 static void test_safefetchN() {
 253   if (CanUseSafeFetchN()) {
 254 #ifdef _LP64
 255     const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
 256     const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
 257 #else
 258     const intptr_t v1 = 0xABCDABCD;
 259     const intptr_t v2 = 0xDEFDDEFD;
 260 #endif
 261     intptr_t dummy = v1;
 262     intptr_t* const p_invalid = (intptr_t*) VMError::get_segfault_address();
 263     intptr_t* const p_valid = &dummy;
 264     intptr_t result_invalid = SafeFetchN(p_invalid, v2);
 265     assert(result_invalid == v2, "SafeFetchN error");
 266     intptr_t result_valid = SafeFetchN(p_valid, v2);
 267     assert(result_valid == v1, "SafeFetchN error");
 268   }
 269 }
 270 #endif
 271 
 272 void StubRoutines::initialize2() {
 273   if (_code2 == NULL) {
 274     ResourceMark rm;
 275     TraceTime timer("StubRoutines generation 2", TRACETIME_LOG(Info, startuptime));
 276     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
 277     if (_code2 == NULL) {
 278       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
 279     }
 280     CodeBuffer buffer(_code2);
 281     StubGenerator_generate(&buffer, true);
 282     // When new stubs added we need to make sure there is some space left


< prev index next >