src/share/vm/runtime/stubRoutines.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8148630.02 Sdiff src/share/vm/runtime

src/share/vm/runtime/stubRoutines.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. 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 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 "code/codeCacheExtensions.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/interfaceSupport.hpp"

  31 #include "runtime/sharedRuntime.hpp"
  32 #include "runtime/stubRoutines.hpp"
  33 #include "runtime/timer.hpp"
  34 #include "utilities/copy.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;


 166 double (* StubRoutines::_intrinsic_tan   )(double) = NULL;
 167 
 168 address StubRoutines::_safefetch32_entry                 = NULL;
 169 address StubRoutines::_safefetch32_fault_pc              = NULL;
 170 address StubRoutines::_safefetch32_continuation_pc       = NULL;
 171 address StubRoutines::_safefetchN_entry                  = NULL;
 172 address StubRoutines::_safefetchN_fault_pc               = NULL;
 173 address StubRoutines::_safefetchN_continuation_pc        = NULL;
 174 
 175 // Initialization
 176 //
 177 // Note: to break cycle with universe initialization, stubs are generated in two phases.
 178 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
 179 // The second phase includes all other stubs (which may depend on universe being initialized.)
 180 
 181 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators
 182 
 183 void StubRoutines::initialize1() {
 184   if (_code1 == NULL) {
 185     ResourceMark rm;
 186     TraceTime timer("StubRoutines generation 1", TraceStartupTime);
 187     _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
 188     if (_code1 == NULL) {
 189       vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
 190     }
 191     CodeBuffer buffer(_code1);
 192     StubGenerator_generate(&buffer, false);
 193     // When new stubs added we need to make sure there is some space left
 194     // to catch situation when we should increase size again.
 195     assert(code_size1 == 0 || buffer.insts_remaining() > 200, "increase code_size1");
 196   }
 197 }
 198 
 199 
 200 #ifdef ASSERT
 201 typedef void (*arraycopy_fn)(address src, address dst, int count);
 202 
 203 // simple tests of generated arraycopy functions
 204 static void test_arraycopy_func(address func, int alignment) {
 205   if (CodeCacheExtensions::use_pregenerated_interpreter() || !CodeCacheExtensions::is_executable(func)) {
 206     // Exit safely if stubs were generated but cannot be used.


 259     const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
 260     const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
 261 #else
 262     const intptr_t v1 = 0xABCDABCD;
 263     const intptr_t v2 = 0xDEFDDEFD;
 264 #endif
 265     intptr_t dummy = v1;
 266     intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
 267     intptr_t* const p_valid = &dummy;
 268     intptr_t result_invalid = SafeFetchN(p_invalid, v2);
 269     assert(result_invalid == v2, "SafeFetchN error");
 270     intptr_t result_valid = SafeFetchN(p_valid, v2);
 271     assert(result_valid == v1, "SafeFetchN error");
 272   }
 273 }
 274 #endif
 275 
 276 void StubRoutines::initialize2() {
 277   if (_code2 == NULL) {
 278     ResourceMark rm;
 279     TraceTime timer("StubRoutines generation 2", TraceStartupTime);
 280     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
 281     if (_code2 == NULL) {
 282       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
 283     }
 284     CodeBuffer buffer(_code2);
 285     StubGenerator_generate(&buffer, true);
 286     // When new stubs added we need to make sure there is some space left
 287     // to catch situation when we should increase size again.
 288     assert(code_size2 == 0 || buffer.insts_remaining() > 200, "increase code_size2");
 289   }
 290 
 291 #ifdef ASSERT
 292 
 293 #define TEST_ARRAYCOPY(type)                                                    \
 294   test_arraycopy_func(          type##_arraycopy(),          sizeof(type));     \
 295   test_arraycopy_func(          type##_disjoint_arraycopy(), sizeof(type));     \
 296   test_arraycopy_func(arrayof_##type##_arraycopy(),          sizeof(HeapWord)); \
 297   test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
 298 
 299   // Make sure all the arraycopy stubs properly handle zero count


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. 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 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 "code/codeCacheExtensions.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/interfaceSupport.hpp"
  31 #include "runtime/logTimer.hpp"
  32 #include "runtime/sharedRuntime.hpp"
  33 #include "runtime/stubRoutines.hpp"

  34 #include "utilities/copy.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;


 166 double (* StubRoutines::_intrinsic_tan   )(double) = NULL;
 167 
 168 address StubRoutines::_safefetch32_entry                 = NULL;
 169 address StubRoutines::_safefetch32_fault_pc              = NULL;
 170 address StubRoutines::_safefetch32_continuation_pc       = NULL;
 171 address StubRoutines::_safefetchN_entry                  = NULL;
 172 address StubRoutines::_safefetchN_fault_pc               = NULL;
 173 address StubRoutines::_safefetchN_continuation_pc        = NULL;
 174 
 175 // Initialization
 176 //
 177 // Note: to break cycle with universe initialization, stubs are generated in two phases.
 178 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
 179 // The second phase includes all other stubs (which may depend on universe being initialized.)
 180 
 181 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators
 182 
 183 void StubRoutines::initialize1() {
 184   if (_code1 == NULL) {
 185     ResourceMark rm;
 186     TraceStartupTime timer("StubRoutines generation 1");
 187     _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
 188     if (_code1 == NULL) {
 189       vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
 190     }
 191     CodeBuffer buffer(_code1);
 192     StubGenerator_generate(&buffer, false);
 193     // When new stubs added we need to make sure there is some space left
 194     // to catch situation when we should increase size again.
 195     assert(code_size1 == 0 || buffer.insts_remaining() > 200, "increase code_size1");
 196   }
 197 }
 198 
 199 
 200 #ifdef ASSERT
 201 typedef void (*arraycopy_fn)(address src, address dst, int count);
 202 
 203 // simple tests of generated arraycopy functions
 204 static void test_arraycopy_func(address func, int alignment) {
 205   if (CodeCacheExtensions::use_pregenerated_interpreter() || !CodeCacheExtensions::is_executable(func)) {
 206     // Exit safely if stubs were generated but cannot be used.


 259     const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
 260     const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
 261 #else
 262     const intptr_t v1 = 0xABCDABCD;
 263     const intptr_t v2 = 0xDEFDDEFD;
 264 #endif
 265     intptr_t dummy = v1;
 266     intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
 267     intptr_t* const p_valid = &dummy;
 268     intptr_t result_invalid = SafeFetchN(p_invalid, v2);
 269     assert(result_invalid == v2, "SafeFetchN error");
 270     intptr_t result_valid = SafeFetchN(p_valid, v2);
 271     assert(result_valid == v1, "SafeFetchN error");
 272   }
 273 }
 274 #endif
 275 
 276 void StubRoutines::initialize2() {
 277   if (_code2 == NULL) {
 278     ResourceMark rm;
 279     TraceStartupTime timer("StubRoutines generation 2");
 280     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
 281     if (_code2 == NULL) {
 282       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
 283     }
 284     CodeBuffer buffer(_code2);
 285     StubGenerator_generate(&buffer, true);
 286     // When new stubs added we need to make sure there is some space left
 287     // to catch situation when we should increase size again.
 288     assert(code_size2 == 0 || buffer.insts_remaining() > 200, "increase code_size2");
 289   }
 290 
 291 #ifdef ASSERT
 292 
 293 #define TEST_ARRAYCOPY(type)                                                    \
 294   test_arraycopy_func(          type##_arraycopy(),          sizeof(type));     \
 295   test_arraycopy_func(          type##_disjoint_arraycopy(), sizeof(type));     \
 296   test_arraycopy_func(arrayof_##type##_arraycopy(),          sizeof(HeapWord)); \
 297   test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
 298 
 299   // Make sure all the arraycopy stubs properly handle zero count


src/share/vm/runtime/stubRoutines.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File